/* ============================================================
   components.css
   Cael — UI Components
   Buttons, inputs, cards, mood selector, toasts, nav
   All mobile-first
   ============================================================ */


/* ── Buttons ── */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: 0.85rem 1.5rem;
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: var(--text-sm);
  font-weight: 400;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  transition: all var(--transition-base);
  white-space: nowrap;
  cursor: pointer;
  border: none;
  width: 100%;
}

/* Primary — dark, confident */
.btn-primary {
  background: var(--ink);
  color: var(--paper);
}

.btn-primary:hover {
  background: var(--accent);
}

.btn-primary:active {
  transform: scale(0.98);
}

.btn-primary:disabled {
  background: var(--muted);
  cursor: not-allowed;
  transform: none;
}

/* Secondary — outlined */
.btn-secondary {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--warm-mid);
}

.btn-secondary:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* Ghost — text only */
.btn-ghost {
  background: transparent;
  color: var(--muted);
  font-size: var(--text-xs);
  padding: 0.5rem 0.75rem;
  width: auto;
}

.btn-ghost:hover {
  color: var(--accent);
}

/* Inline — auto width */
.btn-inline {
  width: auto;
}

/* Loading state */
.btn-loading {
  position: relative;
  color: transparent !important;
  pointer-events: none;
}

.btn-loading::after {
  content: '';
  position: absolute;
  width: 16px;
  height: 16px;
  border: 1.5px solid transparent;
  border-top-color: currentColor;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  color: var(--paper);
}

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


/* ── Inputs ── */

.input-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.input-label {
  font-size: var(--text-xs);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}

.input {
  width: 100%;
  padding: 0.85rem 1rem;
  background: transparent;
  border: 1px solid var(--warm-mid);
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: var(--text-base);
  font-weight: 300;
  color: var(--ink);
  transition: border-color var(--transition-fast);
  -webkit-appearance: none;
}

.input::placeholder {
  color: var(--warm-mid);
}

.input:focus {
  outline: none;
  border-color: var(--accent);
}

.input:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Textarea */
.textarea {
  resize: none;
  min-height: 120px;
  line-height: 1.6;
}

.textarea-journal {
  min-height: 200px;
  font-size: var(--text-md);
  border: none;
  border-bottom: 1px solid var(--warm-light);
  border-radius: 0;
  padding: var(--space-4) 0;
}

.textarea-journal:focus {
  border-bottom-color: var(--accent);
}


/* ── Cards ── */

.card {
  background: white;
  border-radius: var(--radius-md);
  padding: var(--space-6);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--warm-light);
}

.card-flat {
  background: var(--paper-dark);
  border-radius: var(--radius-md);
  padding: var(--space-6);
  border: none;
}

.card-warm {
  background: linear-gradient(
    135deg,
    rgba(200, 184, 154, 0.12) 0%,
    rgba(245, 242, 236, 0) 100%
  );
  border: 1px solid var(--warm-light);
  border-radius: var(--radius-md);
  padding: var(--space-6);
}

/* Journal entry card */
.card-journal {
  background: white;
  border-radius: var(--radius-md);
  padding: var(--space-6);
  border: 1px solid var(--warm-light);
  border-left: 3px solid var(--warm-mid);
  transition: border-color var(--transition-base);
}

.card-journal:hover {
  border-left-color: var(--accent);
}


/* ── Mood Selector ── */
/* The heart of the check-in UI */

.mood-selector {
  display: flex;
  flex-direction: column;
  gap: var(--space-6);
  width: 100%;
}

.mood-selector-label {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: 300;
  font-style: italic;
  color: var(--ink-soft);
  text-align: center;
}

.mood-options {
  display: flex;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-2) 0;
}

.mood-option {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-2);
  cursor: pointer;
  padding: var(--space-3) var(--space-2);
  border-radius: var(--radius-md);
  transition: all var(--transition-base);
  border: 1px solid transparent;
  background: none;
  -webkit-tap-highlight-color: transparent;
}

.mood-option:hover .mood-dot {
  transform: scale(1.2);
}

.mood-option.selected {
  background: var(--paper-dark);
  border-color: var(--warm-light);
}

.mood-option.selected .mood-dot {
  transform: scale(1.3);
  box-shadow: 0 0 0 4px rgba(200, 184, 154, 0.2);
}

.mood-dot {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  transition: all var(--transition-base);
  flex-shrink: 0;
}

.mood-dot-1 { background: var(--mood-1); }
.mood-dot-2 { background: var(--mood-2); }
.mood-dot-3 { background: var(--mood-3); }
.mood-dot-4 { background: var(--mood-4); }
.mood-dot-5 { background: var(--mood-5); }

.mood-option-label {
  font-size: var(--text-xs);
  letter-spacing: 0.08em;
  color: var(--muted);
  text-align: center;
  line-height: 1.3;
}

.mood-option.selected .mood-option-label {
  color: var(--ink-soft);
}

/* Mood note — optional text after selecting */
.mood-note-wrap {
  overflow: hidden;
  max-height: 0;
  opacity: 0;
  transition: max-height 0.4s ease, opacity 0.3s ease;
}

.mood-note-wrap.visible {
  max-height: 120px;
  opacity: 1;
}


/* ── Session type selector ── */
/* Opening / Closing / Just checking in */

.session-options {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  width: 100%;
}

.session-option {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  padding: var(--space-4) var(--space-5);
  border: 1px solid var(--warm-light);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-base);
  background: none;
  text-align: left;
  width: 100%;
  -webkit-tap-highlight-color: transparent;
}

.session-option:hover {
  border-color: var(--warm-mid);
  background: var(--paper-dark);
}

.session-option.selected {
  border-color: var(--accent);
  background: var(--paper-dark);
}

.session-option-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--warm-mid);
  flex-shrink: 0;
  transition: background var(--transition-base);
}

.session-option.selected .session-option-dot {
  background: var(--accent);
}

.session-option-text {
  flex: 1;
}

.session-option-title {
  font-size: var(--text-base);
  color: var(--ink-soft);
  font-weight: 300;
}

.session-option-desc {
  font-size: var(--text-xs);
  color: var(--muted);
  margin-top: 0.15rem;
}


/* ── Chat bubbles ── */

.chat-messages {
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
  padding: var(--space-6) 0;
  flex: 1;
}

/* Cael's message */
.msg-cael {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  align-items: flex-start;
  max-width: 88%;
}

.msg-cael-name {
  font-size: var(--text-xs);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  padding-left: var(--space-2);
}

.msg-cael-bubble {
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 300;
  font-style: italic;
  line-height: 1.6;
  color: var(--ink-soft);
  padding: 0;
}

/* User's message */
.msg-user {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  max-width: 88%;
  align-self: flex-end;
}

.msg-user-bubble {
  background: var(--ink);
  color: var(--paper);
  padding: var(--space-3) var(--space-5);
  border-radius: var(--radius-full);
  font-size: var(--text-base);
  font-weight: 300;
  line-height: 1.5;
}

/* Typing indicator */
.typing-indicator {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: var(--space-2) 0;
  height: 28px;
}

.typing-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--warm-mid);
  animation: typingBounce 1.2s ease-in-out infinite;
}

.typing-dot:nth-child(2) { animation-delay: 0.15s; }
.typing-dot:nth-child(3) { animation-delay: 0.3s; }

@keyframes typingBounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30%           { transform: translateY(-6px); opacity: 1; }
}

/* Chat input area */
.chat-input-wrap {
  display: flex;
  gap: var(--space-3);
  align-items: flex-end;
  padding: var(--space-4) 0;
  padding-bottom: calc(var(--space-4) + var(--safe-bottom));
  border-top: 1px solid var(--warm-light);
}

.chat-input {
  flex: 1;
  min-height: 44px;
  max-height: 160px;
  padding: 0.65rem 1rem;
  border: 1px solid var(--warm-light);
  border-radius: var(--radius-full);
  font-family: var(--font-body);
  font-size: var(--text-base);
  font-weight: 300;
  color: var(--ink);
  background: white;
  resize: none;
  overflow-y: auto;
  line-height: 1.5;
  transition: border-color var(--transition-fast);
}

.chat-input:focus {
  outline: none;
  border-color: var(--warm-mid);
}

.chat-send-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--ink);
  color: var(--paper);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background var(--transition-fast);
  border: none;
  cursor: pointer;
}

.chat-send-btn:hover {
  background: var(--accent);
}

.chat-send-btn:disabled {
  background: var(--warm-light);
  cursor: not-allowed;
}

/* Send icon — pure CSS arrow */
.send-icon {
  width: 0;
  height: 0;
  border-top: 5px solid transparent;
  border-bottom: 5px solid transparent;
  border-left: 9px solid var(--paper);
  margin-left: 2px;
}


/* ── Navigation ── */
/* Bottom nav for mobile */

.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--paper);
  border-top: 1px solid var(--warm-light);
  display: flex;
  justify-content: space-around;
  align-items: center;
  padding: var(--space-3) var(--space-4);
  padding-bottom: calc(var(--space-3) + var(--safe-bottom));
  z-index: var(--z-overlay);
}

.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-fast);
  border: none;
  background: none;
  -webkit-tap-highlight-color: transparent;
  text-decoration: none;
}

.nav-item-icon {
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0.35;
  transition: opacity var(--transition-fast);
}

.nav-item-label {
  font-size: 0.62rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  transition: color var(--transition-fast);
}

.nav-item.active .nav-item-icon {
  opacity: 1;
}

.nav-item.active .nav-item-label {
  color: var(--accent);
}

/* Top nav for desktop */
.top-nav {
  display: none;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-5) 0;
  border-bottom: 1px solid var(--warm-light);
}

.top-nav-brand {
  font-family: var(--font-display);
  font-size: 1.2rem;
  font-weight: 300;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--accent);
}

.top-nav-links {
  display: flex;
  gap: var(--space-8);
  align-items: center;
}

.top-nav-link {
  font-size: var(--text-xs);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  transition: color var(--transition-fast);
  cursor: pointer;
}

.top-nav-link:hover,
.top-nav-link.active {
  color: var(--accent);
}

@media (min-width: 768px) {
  .bottom-nav { display: none; }
  .top-nav    { display: flex; }
}


/* ── Toast notifications ── */

.toast-wrap {
  position: fixed;
  top: calc(var(--space-4) + var(--safe-top));
  left: 50%;
  transform: translateX(-50%);
  z-index: var(--z-toast);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  pointer-events: none;
  width: calc(100% - 2rem);
  max-width: 400px;
}

.toast {
  background: var(--ink);
  color: var(--paper);
  padding: var(--space-3) var(--space-5);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  font-weight: 300;
  line-height: 1.5;
  box-shadow: var(--shadow-md);
  animation: slideDown 0.3s ease, fadeOut 0.3s ease 2.7s forwards;
  pointer-events: all;
}

.toast-success {
  background: var(--success);
}

.toast-warning {
  background: var(--warning);
}

@keyframes slideDown {
  from { opacity: 0; transform: translateY(-10px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes fadeOut {
  to { opacity: 0; }
}


/* ── Progress / Streak ── */

.streak-bar {
  display: flex;
  gap: var(--space-2);
  align-items: center;
}

.streak-day {
  width: 28px;
  height: 4px;
  border-radius: 2px;
  background: var(--warm-light);
  transition: background var(--transition-base);
}

.streak-day.done {
  background: var(--accent-soft);
}

.streak-day.today {
  background: var(--accent);
  animation: pulse 2s ease-in-out infinite;
}


/* ── Intention chip ── */

.intention-chip {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-4);
  border: 1px solid var(--warm-light);
  border-radius: var(--radius-full);
  font-size: var(--text-sm);
  color: var(--ink-soft);
  background: white;
  transition: all var(--transition-fast);
  cursor: pointer;
}

.intention-chip:hover {
  border-color: var(--warm-mid);
}

.intention-chip.active {
  border-color: var(--accent);
  color: var(--accent);
}

.intention-chip-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--warm-mid);
  flex-shrink: 0;
}

.intention-chip.active .intention-chip-dot {
  background: var(--accent);
}


/* ── Empty states ── */

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-4);
  padding: var(--space-12) var(--space-8);
  text-align: center;
}

.empty-state-title {
  font-family: var(--font-display);
  font-size: var(--text-xl);
  font-weight: 300;
  font-style: italic;
  color: var(--muted);
}

.empty-state-body {
  font-size: var(--text-sm);
  color: var(--muted);
  line-height: 1.7;
  max-width: 280px;
}


/* ── Crisis banner ── */
/* Shown when crisis flag is triggered */

.crisis-banner {
  background: rgba(184, 92, 74, 0.08);
  border: 1px solid rgba(184, 92, 74, 0.2);
  border-radius: var(--radius-md);
  padding: var(--space-5) var(--space-6);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.crisis-banner-title {
  font-size: var(--text-sm);
  color: var(--crisis);
  font-weight: 400;
  letter-spacing: 0.05em;
}

.crisis-banner-body {
  font-size: var(--text-sm);
  color: var(--ink-soft);
  line-height: 1.7;
}

.crisis-resource {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  font-size: var(--text-sm);
  color: var(--ink-soft);
  padding: var(--space-3) 0;
  border-top: 1px solid var(--warm-light);
}

.crisis-resource strong {
  color: var(--ink);
  font-weight: 400;
}


/* ── Photo upload ── */

.photo-upload-area {
  border: 1px dashed var(--warm-mid);
  border-radius: var(--radius-md);
  padding: var(--space-8);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-3);
  cursor: pointer;
  transition: all var(--transition-base);
  text-align: center;
}

.photo-upload-area:hover {
  border-color: var(--accent);
  background: var(--paper-dark);
}

.photo-upload-label {
  font-size: var(--text-sm);
  color: var(--muted);
}

.photo-preview {
  width: 100%;
  aspect-ratio: 4/3;
  object-fit: cover;
  border-radius: var(--radius-md);
}


/* ── Desktop enhancements ── */

@media (min-width: 768px) {

  .btn {
    width: auto;
    min-width: 160px;
  }

  .mood-dot {
    width: 44px;
    height: 44px;
  }

  .msg-cael-bubble {
    font-size: 1.15rem;
  }

  .card {
    padding: var(--space-8);
  }
}
