/* ═══════════════════════════════════════════
   BUTTONS
   ═══════════════════════════════════════════ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-5);
  font-size: var(--text-sm);
  font-weight: 500;
  line-height: 1;
  border-radius: var(--radius-md);
  transition: all var(--duration-fast) var(--ease);
  white-space: nowrap;
  height: 40px;
}

.btn-primary {
  background: var(--color-accent);
  color: var(--color-text-inverse);
}

.btn-primary:hover {
  background: var(--color-accent-hover);
  color: var(--color-text-inverse);
}

.btn-primary:active {
  transform: translateY(1px);
  background: #7C2D12;
}

.btn:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

.btn-secondary {
  background: var(--color-surface);
  color: var(--color-text);
  border: 1px solid var(--color-border);
}

.btn-secondary:hover {
  background: var(--color-surface-secondary);
  border-color: var(--color-text-tertiary);
}

.btn-secondary:active {
  transform: translateY(1px);
  background: var(--color-border-light);
}

.btn-ghost {
  color: var(--color-text-secondary);
}

.btn-ghost:hover {
  background: var(--color-surface-secondary);
  color: var(--color-text);
}

.btn-danger {
  color: var(--color-danger);
}

.btn-danger:hover {
  background: var(--color-danger-light);
}

.btn-icon {
  width: 40px;
  padding: 0;
}

.btn-sm {
  height: 32px;
  padding: var(--space-1) var(--space-3);
  font-size: var(--text-xs);
}

/* ═══════════════════════════════════════════
   INPUTS
   ═══════════════════════════════════════════ */
.input-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.input-group label {
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--color-text-secondary);
}

.input {
  width: 100%;
  height: 40px;
  padding: 0 var(--space-3);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  transition: border-color var(--duration-fast) var(--ease),
              box-shadow var(--duration-fast) var(--ease);
}

.input:focus {
  border-color: var(--color-accent);
  box-shadow: 0 0 0 3px var(--color-accent-light);
}

.input::placeholder {
  color: var(--color-text-tertiary);
}

textarea.input {
  height: auto;
  min-height: 80px;
  padding: var(--space-3);
  resize: vertical;
}

select.input {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='%2378716C' viewBox='0 0 16 16'%3E%3Cpath d='M4.5 6l3.5 3.5L11.5 6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right var(--space-3) center;
  padding-right: var(--space-8);
}

/* ═══════════════════════════════════════════
   CARDS
   ═══════════════════════════════════════════ */
.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-5);
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--duration-fast) var(--ease);
}

.card:hover {
  box-shadow: var(--shadow-md);
}

/* ═══════════════════════════════════════════
   TAG PILLS
   ═══════════════════════════════════════════ */
.tag {
  display: inline-flex;
  align-items: center;
  padding: var(--space-1) var(--space-3);
  font-size: var(--text-xs);
  font-weight: 500;
  border-radius: var(--radius-full);
  background: var(--color-surface-secondary);
  color: var(--color-text-secondary);
  letter-spacing: var(--tracking-wide);
}

.tag-accent {
  background: var(--color-accent-light);
  color: var(--color-accent);
}

.tag-danger {
  background: var(--color-danger-light);
  color: var(--color-danger);
}

.tag-spice {
  background: var(--color-spice-light);
  color: var(--color-spice);
}

/* ═══════════════════════════════════════════
   SPICE DOTS
   ═══════════════════════════════════════════ */
.spice-dots {
  display: inline-flex;
  gap: 3px;
  align-items: center;
}

.spice-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--color-border);
  transition: background var(--duration-fast) var(--ease);
}

.spice-dot.active {
  background: var(--color-spice);
}

/* ═══════════════════════════════════════════
   CHAT BUBBLES
   ═══════════════════════════════════════════ */
.chat-message {
  display: flex;
  flex-direction: column;
  max-width: 85%;
  animation: msgSlideIn var(--duration-base) var(--ease) both;
}

.chat-message-user {
  align-self: flex-end;
}

.chat-message-ai {
  align-self: flex-start;
}

.chat-bubble {
  padding: var(--space-3) var(--space-4);
  font-size: var(--text-sm);
  line-height: var(--leading-relaxed);
  border-radius: var(--radius-lg);
  word-break: break-word;
}

.chat-message-user .chat-bubble {
  background: var(--color-accent-light);
  color: var(--color-text);
  border-bottom-right-radius: var(--radius-sm);
}

.chat-message-ai .chat-bubble {
  background: var(--color-surface);
  color: var(--color-text);
  border: 1px solid var(--color-border);
  border-bottom-left-radius: var(--radius-sm);
}

.chat-timestamp {
  font-size: var(--text-xs);
  color: var(--color-text-tertiary);
  margin-top: var(--space-1);
  padding: 0 var(--space-1);
}

.chat-message-user .chat-timestamp {
  text-align: right;
}

@keyframes msgSlideIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ═══════════════════════════════════════════
   TYPING INDICATOR
   ═══════════════════════════════════════════ */
.typing-indicator {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: var(--space-3) var(--space-4);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  border-bottom-left-radius: var(--radius-sm);
  width: fit-content;
}

.typing-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--color-text-tertiary);
  animation: typingBounce 1.4s ease-in-out infinite;
}

.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes typingBounce {
  0%, 60%, 100% {
    transform: translateY(0);
    opacity: 0.4;
  }
  30% {
    transform: translateY(-4px);
    opacity: 1;
  }
}

/* ═══════════════════════════════════════════
   CHAT INPUT BAR
   ═══════════════════════════════════════════ */
.chat-input-bar {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-3);
  background: var(--color-surface);
  border-top: 1px solid var(--color-border);
}

.chat-input {
  flex: 1;
  height: 44px;
  padding: 0 var(--space-4);
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-full);
  font-size: var(--text-sm);
  transition: border-color var(--duration-fast) var(--ease),
              box-shadow var(--duration-fast) var(--ease);
}

.chat-input:focus {
  border-color: var(--color-accent);
  box-shadow: 0 0 0 3px var(--color-accent-light);
}

.chat-send-btn,
.chat-mic-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  flex-shrink: 0;
  transition: all var(--duration-fast) var(--ease);
}

.chat-send-btn {
  background: var(--color-accent);
  color: var(--color-text-inverse);
}

.chat-send-btn:hover {
  background: var(--color-accent-hover);
}

.chat-send-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.chat-mic-btn {
  color: var(--color-text-tertiary);
}

.chat-mic-btn:hover {
  background: var(--color-surface-secondary);
  color: var(--color-text);
}

.chat-mic-btn.listening {
  color: var(--color-accent);
  background: var(--color-accent-light);
  animation: micPulse 1.5s ease-in-out infinite;
}

@keyframes micPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(180, 83, 9, 0.2); }
  50% { box-shadow: 0 0 0 10px rgba(180, 83, 9, 0); }
}

/* ═══════════════════════════════════════════
   SUGGESTION CHIPS
   ═══════════════════════════════════════════ */
.suggestion-chips {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
}

.chip {
  padding: var(--space-2) var(--space-4);
  font-size: var(--text-sm);
  font-weight: 500;
  border-radius: var(--radius-full);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  color: var(--color-text-secondary);
  cursor: pointer;
  transition: all var(--duration-fast) var(--ease);
}

.chip:hover {
  border-color: var(--color-accent);
  color: var(--color-accent);
  background: var(--color-accent-light);
}

/* ═══════════════════════════════════════════
   TOAST NOTIFICATIONS
   ═══════════════════════════════════════════ */
.toast-container {
  position: fixed;
  top: var(--space-4);
  right: var(--space-4);
  z-index: 10000;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.toast {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-5);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  font-size: var(--text-sm);
  animation: toastIn var(--duration-base) var(--ease) both;
  max-width: 360px;
}

.toast-success {
  border-left: 3px solid var(--color-success);
}

.toast-error {
  border-left: 3px solid var(--color-danger);
}

.toast-exit {
  animation: toastOut var(--duration-fast) var(--ease) both;
}

@keyframes toastIn {
  from { opacity: 0; transform: translateX(20px); }
  to { opacity: 1; transform: translateX(0); }
}

@keyframes toastOut {
  from { opacity: 1; transform: translateX(0); }
  to { opacity: 0; transform: translateX(20px); }
}

/* ═══════════════════════════════════════════
   SKELETON LOADING
   ═══════════════════════════════════════════ */
.skeleton {
  background: linear-gradient(
    90deg,
    var(--color-surface-secondary) 25%,
    var(--color-border-light) 50%,
    var(--color-surface-secondary) 75%
  );
  background-size: 200% 100%;
  animation: shimmer 1.5s ease-in-out infinite;
  border-radius: var(--radius-sm);
}

.skeleton-text {
  height: 14px;
  margin-bottom: var(--space-2);
}

.skeleton-title {
  height: 20px;
  width: 60%;
  margin-bottom: var(--space-3);
}

.skeleton-card {
  height: 140px;
  border-radius: var(--radius-md);
}

@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ═══════════════════════════════════════════
   CHECKBOX & TOGGLE GROUPS
   ═══════════════════════════════════════════ */
.checkbox-group {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.checkbox-pill {
  position: relative;
}

.checkbox-pill input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.checkbox-pill label {
  display: inline-flex;
  align-items: center;
  padding: var(--space-1) var(--space-3);
  font-size: var(--text-sm);
  border-radius: var(--radius-full);
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  color: var(--color-text-secondary);
  cursor: pointer;
  transition: all var(--duration-fast) var(--ease);
  user-select: none;
}

.checkbox-pill input:checked + label {
  background: var(--color-accent-light);
  border-color: var(--color-accent);
  color: var(--color-accent);
}

.checkbox-pill label:hover {
  border-color: var(--color-text-tertiary);
}

/* ═══════════════════════════════════════════
   RANGE SLIDER
   ═══════════════════════════════════════════ */
.range-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 4px;
  border-radius: 2px;
  background: var(--color-border);
  outline: none;
}

.range-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--color-accent);
  cursor: pointer;
  border: 3px solid var(--color-surface);
  box-shadow: var(--shadow-md);
  transition: transform var(--duration-fast) var(--ease);
}

.range-slider::-webkit-slider-thumb:hover {
  transform: scale(1.15);
}

.range-slider::-moz-range-thumb {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--color-accent);
  cursor: pointer;
  border: 3px solid var(--color-surface);
  box-shadow: var(--shadow-md);
}

/* ═══════════════════════════════════════════
   CHAT FAB + OVERLAY PANEL
   ═══════════════════════════════════════════ */
.chat-fab {
  position: fixed;
  bottom: var(--space-6);
  right: var(--space-6);
  z-index: 900;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--color-accent);
  color: var(--color-text-inverse);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-lg), var(--glow-fab);
  transition: transform var(--duration-fast) var(--ease),
              background var(--duration-fast) var(--ease),
              opacity var(--duration-fast) var(--ease);
}

.chat-fab:hover {
  background: var(--color-accent-hover);
  transform: scale(1.05);
}

.chat-fab.hidden {
  opacity: 0;
  pointer-events: none;
  transform: scale(0.8);
}

.chat-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: flex-end;
  justify-content: flex-end;
  background: transparent;
  pointer-events: none;
  transition: background var(--duration-base) var(--ease);
}

.chat-overlay.open {
  pointer-events: auto;
  background: var(--overlay-bg);
}

.chat-panel {
  width: 100%;
  max-width: 420px;
  height: 85dvh;
  max-height: 700px;
  background: var(--color-bg);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-xl), var(--glow-chat);
  transform: translateY(100%);
  transition: transform var(--duration-base) var(--ease);
  overflow: hidden;
}

.chat-overlay.open .chat-panel {
  transform: translateY(0);
}

@media (min-width: 600px) {
  .chat-panel {
    margin: var(--space-4);
    margin-bottom: 0;
    border-radius: var(--radius-lg);
    height: 600px;
  }

  .chat-overlay.open .chat-panel {
    margin-bottom: var(--space-4);
  }

  .chat-overlay {
    padding: var(--space-4);
  }
}

.chat-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--color-border);
  background: var(--color-surface);
  flex-shrink: 0;
}

.chat-panel-title {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: 600;
}

.chat-panel-subtitle {
  font-size: var(--text-xs);
  color: var(--color-text-secondary);
  margin-top: 2px;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-4);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

/* ═══════════════════════════════════════════
   FULL-PAGE CHAT LAYOUT
   ═══════════════════════════════════════════ */
.chat-fullpage {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  background: var(--color-bg);
  position: relative;
}

.chat-fullpage::before {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(ellipse 60% 50% at 50% 40%, rgba(245, 158, 11, 0.03) 0%, transparent 70%);
  z-index: 0;
}

[data-theme="dark"] .chat-fullpage::before {
  background: radial-gradient(ellipse 60% 50% at 50% 40%, rgba(245, 158, 11, 0.05) 0%, transparent 70%);
}

.chat-fullpage > * {
  position: relative;
  z-index: 1;
}

.chat-fullpage-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--header-height);
  padding: 0 var(--space-4);
  border-bottom: 1px solid var(--color-border);
  background: var(--header-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  flex-shrink: 0;
}

.chat-fullpage-brand {
  font-family: var(--font-display);
  font-size: var(--text-xl);
  font-weight: 600;
}

.chat-fullpage-brand span {
  color: var(--color-accent);
}

.chat-fullpage .chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-4);
  max-width: 640px;
  width: 100%;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.chat-fullpage .suggestion-chips {
  max-width: 640px;
  width: 100%;
  margin: 0 auto;
  justify-content: center;
}

.chat-fullpage .chat-input-bar {
  max-width: 640px;
  width: 100%;
  margin: 0 auto;
  border-top: none;
  padding: var(--space-3) var(--space-4) calc(var(--space-6) + env(safe-area-inset-bottom, 0px));
}

/* ── Chat Page Footer ── */
.chat-fullpage-footer {
  text-align: center;
  padding: var(--space-2) var(--space-4);
  flex-shrink: 0;
}

.chat-footer-brand {
  font-family: var(--font-display);
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--color-text-tertiary);
}

.chat-footer-brand span {
  color: var(--color-accent);
}

/* Safe-area insets for notched phones */
.chat-input-bar {
  padding-bottom: calc(var(--space-3) + env(safe-area-inset-bottom, 0px));
}

.chat-fab {
  bottom: calc(var(--space-6) + env(safe-area-inset-bottom, 0px));
}

/* ═══════════════════════════════════════════
   THEME TOGGLE
   ═══════════════════════════════════════════ */
.theme-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-full);
  color: var(--color-text-secondary);
  transition: background var(--duration-fast) var(--ease),
              color var(--duration-fast) var(--ease);
  flex-shrink: 0;
}

.theme-toggle:hover {
  background: var(--color-surface-secondary);
  color: var(--color-text);
}

.theme-toggle .icon-sun,
.theme-toggle .icon-moon {
  width: 20px;
  height: 20px;
  transition: transform var(--duration-base) var(--ease),
              opacity var(--duration-fast) var(--ease);
}

.theme-toggle .icon-sun {
  display: block;
}

.theme-toggle .icon-moon {
  display: none;
}

[data-theme="dark"] .theme-toggle .icon-sun {
  display: none;
}

[data-theme="dark"] .theme-toggle .icon-moon {
  display: block;
}
