/* ===========================================
   JAVY 5 - Reusable Components
   Chappy AI V2 Style: 3D Glass, Inset Shadows
   =========================================== */

/* ================================================
   BUTTONS (Chappy AI V2 Style: 3D Glass)
   ================================================ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  padding: 8px 16px;
  font-size: var(--font-sm);
  font-weight: 500;
  font-family: var(--font-family);
  border-radius: var(--radius-md);
  transition: all var(--transition-spring);
  cursor: pointer;
  border: 1px solid transparent;
  white-space: nowrap;
  user-select: none;
  line-height: 1.4;
  min-height: 32px;
}

.btn:active {
  transform: scale(0.97);
}

/* Primary Button - Gradient with glow */
.btn-primary {
  background: linear-gradient(135deg, var(--accent-purple) 0%, #a78bfa 100%);
  color: white;
  border: none;
  box-shadow:
    0 4px 16px rgba(139, 92, 246, 0.4),
    var(--shadow-inset);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow:
    0 8px 24px rgba(139, 92, 246, 0.5),
    var(--shadow-inset);
  filter: brightness(1.05);
}

.btn-primary:active {
  transform: translateY(0) scale(0.97);
  box-shadow:
    0 2px 8px rgba(139, 92, 246, 0.3),
    var(--shadow-inset);
}

/* Ghost Button - Glass with 3D effect */
.btn-ghost {
  background: var(--bg-card);
  color: var(--text-secondary);
  border: 1px solid var(--glass-border);
  box-shadow:
    var(--shadow-sm),
    var(--shadow-inset),
    inset 0 -1px 0 rgba(0, 0, 0, 0.2);
}

.btn-ghost:hover {
  color: var(--text-primary);
  border-color: var(--glass-border-hover);
  transform: translateY(-2px);
  box-shadow:
    0 8px 20px rgba(0, 0, 0, 0.4),
    var(--shadow-inset);
}

.btn-ghost:active {
  transform: translateY(0) scale(0.97);
}

/* Danger Button */
.btn-danger {
  background: rgba(239, 68, 68, 0.1);
  color: var(--color-error);
  border: 1px solid rgba(239, 68, 68, 0.2);
}

.btn-danger:hover {
  background: rgba(239, 68, 68, 0.2);
  border-color: var(--color-error);
  transform: translateY(-2px);
  box-shadow: 0 0 12px rgba(239, 68, 68, 0.3);
}

/* Cyan accent button */
.btn-cyan {
  background: rgba(6, 182, 212, 0.1);
  color: var(--accent-cyan);
  border: 1px solid rgba(6, 182, 212, 0.2);
}

.btn-cyan:hover {
  background: rgba(6, 182, 212, 0.2);
  border-color: var(--accent-cyan);
  transform: translateY(-2px);
  box-shadow: 0 0 12px rgba(6, 182, 212, 0.3);
}

/* Button Sizes */
.btn-sm {
  padding: 4px 10px;
  font-size: var(--font-xs);
  min-height: 26px;
}

.btn-lg {
  padding: 10px 20px;
  font-size: var(--font-md);
  min-height: 40px;
}

/* Icon-only button */
.btn-icon {
  width: 32px;
  height: 32px;
  padding: 0;
  border-radius: var(--radius-md);
  background: var(--bg-card);
  border: 1px solid var(--glass-border);
  color: var(--text-muted);
  box-shadow:
    var(--shadow-sm),
    var(--shadow-inset),
    inset 0 -1px 0 rgba(0, 0, 0, 0.2);
}

.btn-icon:hover {
  color: var(--text-primary);
  border-color: var(--glass-border-hover);
  transform: translateY(-2px);
  box-shadow:
    0 8px 20px rgba(0, 0, 0, 0.4),
    var(--shadow-inset);
}

/* ================================================
   FORM INPUTS (Chappy AI V2 Style: Inset Shadows)
   ================================================ */

.input,
.textarea,
.select {
  width: 100%;
  padding: 0 8px;
  height: 28px;
  background: var(--bg-card);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: var(--font-xs);
  font-family: var(--font-family);
  transition: all var(--transition-spring);
  box-shadow:
    var(--shadow-inset),
    0 1px 3px rgba(0, 0, 0, 0.2);
  outline: none;
}

.input:hover,
.textarea:hover,
.select:hover {
  border-color: var(--glass-border-hover);
  box-shadow:
    var(--shadow-inset),
    0 2px 6px rgba(0, 0, 0, 0.25);
}

.input:focus,
.textarea:focus,
.select:focus {
  border-color: var(--accent-purple);
  box-shadow:
    0 0 0 2px rgba(139, 92, 246, 0.2),
    0 0 12px rgba(139, 92, 246, 0.1),
    var(--shadow-inset);
}

.input::placeholder,
.textarea::placeholder {
  color: var(--text-muted);
}

.textarea {
  min-height: 72px;
  max-height: 100px;
  height: auto;
  padding: var(--space-sm) 8px;
  resize: vertical;
  line-height: 1.5;
}

.select {
  appearance: none;
  -webkit-appearance: none;
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='rgba(255,255,255,0.4)' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  padding-right: 22px;
}

/* Input with label */
.form-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
}

.form-label {
  font-size: var(--font-sm);
  font-weight: 600;
  color: var(--text-secondary);
}

/* ================================================
   CARD (Glass - Chappy AI V2 Style)
   ================================================ */

.card {
  background: var(--bg-card);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  padding: var(--space-lg);
  transition: all var(--transition-fast);
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
}

/* Glass shine overlay */
.card::before {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--glass-shine);
  pointer-events: none;
  z-index: 1;
}

.card:hover {
  border-color: var(--glass-border-hover);
  box-shadow: var(--shadow-md);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-md);
  position: relative;
  z-index: 2;
}

.card-title {
  font-size: var(--font-md);
  font-weight: 600;
  color: var(--text-primary);
}

.card-body {
  color: var(--text-secondary);
  font-size: var(--font-sm);
  line-height: 1.6;
  position: relative;
  z-index: 2;
}

/* ================================================
   MODAL (Glass - Chappy AI V2 Style)
   ================================================ */

.modal-backdrop {
  position: fixed;
  inset: 0;
  padding-top: calc(60px + env(safe-area-inset-top, 0px));
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: var(--z-modal);
  display: flex;
  align-items: center;
  justify-content: center;
  padding-left: var(--space-lg);
  padding-right: var(--space-lg);
  padding-bottom: var(--space-lg);
  animation: fadeIn 200ms ease;
}

.modal {
  background: var(--bg-elevated);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-xl);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  box-shadow:
    var(--shadow-xl),
    0 0 40px rgba(139, 92, 246, 0.08);
  width: 100%;
  max-width: 420px;
  max-height: 75vh;
  overflow-y: auto;
  animation: modalIn 250ms cubic-bezier(0.34, 1.56, 0.64, 1);
  position: relative;
}

/* Glass shine on modal */
.modal::before {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--glass-shine);
  pointer-events: none;
  border-radius: inherit;
  z-index: 0;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-lg) var(--space-xl);
  border-bottom: 1px solid var(--glass-border);
  position: relative;
  z-index: 1;
}

.modal-title {
  font-size: var(--font-lg);
  font-weight: 600;
}

.modal-close {
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  transition: all var(--transition-fast);
  font-size: var(--font-lg);
}

.modal-close:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-primary);
}

.modal-body {
  padding: var(--space-xl);
  position: relative;
  z-index: 1;
}

.modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--space-sm);
  padding: var(--space-lg) var(--space-xl);
  border-top: 1px solid var(--glass-border);
  position: relative;
  z-index: 1;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes modalIn {
  from {
    opacity: 0;
    transform: scale(0.95) translateY(10px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

/* ================================================
   TOAST (Notification - Chappy AI V2 Style)
   ================================================ */

.toast-container {
  position: fixed;
  bottom: var(--space-xl);
  right: var(--space-xl);
  display: flex;
  flex-direction: column-reverse;
  gap: var(--space-sm);
  z-index: var(--z-toast);
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: 10px var(--space-lg);
  background: var(--bg-elevated);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  box-shadow: var(--shadow-lg);
  font-size: var(--font-sm);
  color: var(--text-primary);
  min-width: 260px;
  max-width: 380px;
  pointer-events: auto;
  animation: toastIn 300ms cubic-bezier(0.34, 1.56, 0.64, 1);
}

.toast.toast-out {
  animation: toastOut 200ms ease forwards;
}

.toast-icon {
  font-size: var(--font-md);
  flex-shrink: 0;
}

.toast-message {
  flex: 1;
  line-height: 1.4;
}

.toast-close {
  flex-shrink: 0;
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: var(--font-xs);
  transition: all var(--transition-fast);
}

.toast-close:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-primary);
}

/* Toast types */
.toast-success { border-left: 3px solid var(--color-success); }
.toast-error { border-left: 3px solid var(--color-error); }
.toast-warning { border-left: 3px solid var(--color-warning); }
.toast-info { border-left: 3px solid var(--color-info); }

@keyframes toastIn {
  from { opacity: 0; transform: translateX(100%) scale(0.8); }
  to { opacity: 1; transform: translateX(0) scale(1); }
}

@keyframes toastOut {
  from { opacity: 1; transform: translateX(0) scale(1); }
  to { opacity: 0; transform: translateX(100%) scale(0.8); }
}

@media (max-width: 639px) {
  .toast-container {
    left: var(--space-md);
    right: var(--space-md);
    bottom: var(--space-md);
  }
  .toast {
    min-width: auto;
    max-width: none;
    width: 100%;
  }
}

/* ================================================
   BADGE / TAG (Chappy AI V2 Style)
   ================================================ */

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 2px 8px;
  font-size: var(--font-xs);
  font-weight: 600;
  border-radius: var(--radius-sm);
  line-height: 1.4;
}

.badge-purple {
  background: rgba(139, 92, 246, 0.1);
  color: var(--accent-purple);
  border: 1px solid rgba(139, 92, 246, 0.2);
}

.badge-cyan {
  background: rgba(6, 182, 212, 0.1);
  color: var(--accent-cyan);
  border: 1px solid rgba(6, 182, 212, 0.2);
}

.badge-pink {
  background: rgba(236, 72, 153, 0.1);
  color: var(--accent-pink);
  border: 1px solid rgba(236, 72, 153, 0.2);
}

.badge-success {
  background: rgba(16, 185, 129, 0.1);
  color: var(--color-success);
  border: 1px solid rgba(16, 185, 129, 0.2);
}

.badge-error {
  background: rgba(239, 68, 68, 0.1);
  color: var(--color-error);
  border: 1px solid rgba(239, 68, 68, 0.2);
}

.tag {
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
  padding: var(--space-xs) var(--space-sm);
  font-size: var(--font-xs);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-full);
  color: var(--text-secondary);
}

/* ================================================
   SPINNER / PROGRESS
   ================================================ */

.spinner {
  width: 20px;
  height: 20px;
  border: 2px solid var(--glass-border);
  border-top-color: var(--accent-purple);
  border-radius: 50%;
  animation: spin 600ms linear infinite;
}

.spinner-sm { width: 14px; height: 14px; }
.spinner-lg { width: 32px; height: 32px; border-width: 3px; }

@keyframes spin {
  to { transform: rotate(360deg); }
}

.progress-bar {
  width: 100%;
  height: 3px;
  background: rgba(255, 255, 255, 0.06);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  background: var(--gradient-primary-wide);
  border-radius: var(--radius-full);
  transition: width var(--transition-normal);
}

/* ================================================
   TOOLTIP
   ================================================ */

.tooltip {
  position: relative;
}

.tooltip::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%) scale(0.9);
  padding: 4px 8px;
  background: var(--bg-elevated);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  font-size: var(--font-xs);
  color: var(--text-primary);
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: all var(--transition-fast);
  box-shadow: var(--shadow-md);
  z-index: var(--z-tooltip);
}

.tooltip:hover::after {
  opacity: 1;
  transform: translateX(-50%) scale(1);
}

/* ================================================
   DROPDOWN (Chappy AI V2 Style)
   ================================================ */

.dropdown {
  position: relative;
  display: inline-block;
}

.dropdown-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 180px;
  background: var(--bg-card);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  box-shadow: var(--shadow-lg);
  padding: var(--space-sm);
  z-index: var(--z-dropdown);
  animation: dropdownIn 150ms ease;
}

.dropdown-menu.hidden {
  display: none;
}

.dropdown-item {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-lg);
  font-size: var(--font-sm);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
  width: 100%;
  text-align: left;
  border-radius: var(--radius-md);
  font-family: var(--font-family);
}

.dropdown-item:hover {
  background: var(--accent-purple-light);
  color: var(--text-primary);
}

.dropdown-divider {
  height: 1px;
  background: var(--glass-border);
  margin: var(--space-xs) 0;
}

@keyframes dropdownIn {
  from { opacity: 0; transform: translateY(-4px) scale(0.95); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
