/* ============================================================
   PracticeDesk Design System
   ============================================================ */

/* --- Variables ------------------------------------------------ */
:root {
  --bg-primary:    #0D0F14;
  --bg-secondary:  #0B1F4B;
  --text-primary:  #FFFFFF;
  --text-secondary:#8A8F9E;
  --accent:        #E8944A;
  --border:        rgba(255, 255, 255, 0.08);
  --border-hover:  rgba(255, 255, 255, 0.16);

  --font-display: 'Playfair Display', Georgia, serif;
  --font-body:    'Inter', system-ui, sans-serif;

  --radius-sm:  6px;
  --radius-md:  12px;
  --radius-pill:50px;

  --space-xs:  8px;
  --space-sm:  16px;
  --space-md:  24px;
  --space-lg:  40px;
  --space-xl:  64px;

  --transition: 0.2s ease;
}

/* --- Reset ---------------------------------------------------- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  background-color: var(--bg-primary);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 1rem;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100vh;
}

img, svg {
  display: block;
  max-width: 100%;
}

a {
  color: inherit;
  text-decoration: none;
}

button, input, select, textarea {
  font-family: var(--font-body);
  font-size: inherit;
}

/* --- Typography ---------------------------------------------- */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-display);
  font-weight: 500;
  line-height: 1.2;
  color: var(--text-primary);
}

h1 { font-size: clamp(2rem, 5vw, 3rem); }
h2 { font-size: clamp(1.5rem, 3.5vw, 2rem); }
h3 { font-size: 1.25rem; }

.text-muted {
  color: var(--text-secondary);
  font-size: 0.875rem;
}

.text-accent {
  color: var(--accent);
}

/* --- Navigation ---------------------------------------------- */
.navbar {
  background-color: var(--bg-primary);
  border-bottom: 1px solid var(--border);
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--space-md);
  position: sticky;
  top: 0;
  z-index: 100;
}

.logo {
  font-family: var(--font-display);
  font-size: 1.375rem;
  font-weight: 500;
  color: var(--text-primary);
  letter-spacing: -0.01em;
}

.logo .period {
  color: var(--accent);
}

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

.nav-link {
  color: var(--text-secondary);
  font-size: 0.9rem;
  transition: color var(--transition);
}

.nav-link:hover,
.nav-link.active {
  color: var(--text-primary);
}

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

/* --- Layout -------------------------------------------------- */
.container {
  width: 100%;
  max-width: 1120px;
  margin: 0 auto;
  padding: 0 var(--space-md);
}

.page-content {
  padding: var(--space-lg) var(--space-md);
  max-width: 1120px;
  margin: 0 auto;
}

/* --- Cards --------------------------------------------------- */
.card {
  background-color: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-md);
}

.card-title {
  font-family: var(--font-display);
  font-size: 1.125rem;
  font-weight: 500;
  margin-bottom: var(--space-xs);
}

.card-body {
  font-size: 0.9rem;
  color: var(--text-secondary);
}

/* --- Buttons ------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: var(--radius-pill);
  padding: 12px 28px;
  font-family: var(--font-body);
  font-size: 0.9375rem;
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: opacity var(--transition), background-color var(--transition);
  white-space: nowrap;
  text-decoration: none;
}

/* Primary — amber fill */
.btn-primary {
  background-color: var(--accent);
  color: #0D0F14;
}

.btn-primary:hover {
  opacity: 0.88;
}

.btn-primary:active {
  opacity: 0.75;
}

/* Secondary — white outline */
.btn-secondary {
  background-color: transparent;
  color: var(--text-primary);
  border: 1.5px solid var(--text-primary);
}

.btn-secondary:hover {
  background-color: rgba(255, 255, 255, 0.06);
}

/* Small variant */
.btn-sm {
  padding: 8px 20px;
  font-size: 0.875rem;
}

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* --- Inputs -------------------------------------------------- */
.input-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.input-label {
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-secondary);
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.input-field,
.select-field,
.textarea-field {
  background-color: var(--bg-secondary);
  color: var(--text-primary);
  border: 1.5px solid var(--border-hover);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  font-family: var(--font-body);
  font-size: 0.9375rem;
  width: 100%;
  transition: border-color var(--transition);
  appearance: none;
}

.input-field:hover,
.select-field:hover,
.textarea-field:hover {
  border-color: rgba(232, 148, 74, 0.4);
}

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

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

.select-field {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%238A8F9E' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 16px center;
  padding-right: 40px;
  cursor: pointer;
}

.textarea-field {
  resize: vertical;
  min-height: 100px;
}

/* --- Date/time picker — amber calendar icon ------------------ */
input[type="datetime-local"]::-webkit-calendar-picker-indicator {
  filter: invert(65%) sepia(55%) saturate(600%) hue-rotate(340deg) brightness(105%);
  cursor: pointer;
  opacity: 0.75;
  transition: opacity var(--transition);
}
input[type="datetime-local"]::-webkit-calendar-picker-indicator:hover {
  opacity: 1;
}

/* --- Loading Animation --------------------------------------- */
@keyframes amber-pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.25; }
}

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

/* Inline loading indicator (used inside cards / buttons) */
.loading-indicator {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--accent);
  font-size: 0.875rem;
}

.loading-dots {
  display: flex;
  gap: 5px;
}

.loading-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background-color: var(--accent);
  animation: amber-pulse 1.4s ease-in-out infinite;
}

.loading-dot:nth-child(2) { animation-delay: 0.28s; }
.loading-dot:nth-child(3) { animation-delay: 0.56s; }

/* Full-screen loading overlay */
.loading-overlay {
  position: fixed;
  inset: 0;
  background-color: rgba(13, 15, 20, 0.88);
  backdrop-filter: blur(4px);
  z-index: 999;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-md);
}

.loading-overlay .loading-dots {
  gap: 8px;
}

.loading-overlay .loading-dot {
  width: 10px;
  height: 10px;
}

.loading-status {
  color: var(--text-secondary);
  font-size: 0.9rem;
  min-height: 1.4em;
  transition: opacity 0.3s ease;
}

/* --- Flash / Alert Messages ---------------------------------- */
.flash-container {
  position: fixed;
  top: 72px;
  right: var(--space-md);
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 360px;
}

.flash {
  padding: 14px 20px;
  border-radius: var(--radius-md);
  font-size: 0.9rem;
  border: 1px solid var(--border);
  background-color: var(--bg-secondary);
  color: var(--text-primary);
  animation: fade-in 0.25s ease;
}

.flash-success { border-color: rgba(74, 222, 128, 0.3); }
.flash-error   { border-color: rgba(248, 113, 113, 0.3); }
.flash-info    { border-color: rgba(232, 148, 74, 0.3); }

@keyframes fade-in {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* --- Readiness Badges --------------------------------------- */
.readiness-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8125rem;
  font-weight: 500;
  padding: 4px 12px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border);
}

.readiness-high         { border-color: rgba(74, 222, 128, 0.25); color: #4ade80; }
.readiness-building     { border-color: rgba(232, 148, 74, 0.3);  color: var(--accent); }
.readiness-needs-attention { border-color: rgba(248, 113, 113, 0.25); color: #f87171; }

/* --- Status Pills ------------------------------------------- */
.status-pill {
  font-size: 0.75rem;
  font-weight: 500;
  padding: 3px 10px;
  border-radius: var(--radius-pill);
}

.status-completed  { background: rgba(74, 222, 128, 0.12); color: #4ade80; }
.status-in-progress{ background: rgba(232, 148, 74, 0.12);  color: var(--accent); }
.status-not-sent   { background: rgba(138, 143, 158, 0.12); color: var(--text-secondary); }

/* --- Modal -------------------------------------------------- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(13, 15, 20, 0.85);
  backdrop-filter: blur(6px);
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-md);
}

.modal {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-lg);
  max-width: 680px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 1.25rem;
  padding: 4px;
  transition: color var(--transition);
}

.modal-close:hover { color: var(--text-primary); }

/* --- Divider ------------------------------------------------ */
.divider {
  height: 1px;
  background: var(--border);
  margin: var(--space-md) 0;
}

/* --- Utility ------------------------------------------------ */
.sr-only {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}

.flex         { display: flex; }
.flex-col     { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-sm       { gap: var(--space-sm); }
.gap-md       { gap: var(--space-md); }
.mt-sm        { margin-top: var(--space-sm); }
.mt-md        { margin-top: var(--space-md); }
.mt-lg        { margin-top: var(--space-lg); }

/* --- Dashboard ─────────────────────────────────────────────── */

/* Appointment banner — slim vertical padding */
.banner-card {
  padding: var(--space-md) var(--space-lg);
}

.banner-content {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-md);
}

.banner-left { flex: 1; min-width: 0; }
.banner-right { flex-shrink: 0; }

/* Main dashboard grid — intake (left) + right column */
.dashboard-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-md);
  align-items: start;
}

/* Right column — briefs + sessions stacked */
.dashboard-right {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}

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

.tile {
  display: flex;
  flex-direction: column;
}

/* Tile list (Briefs + Sessions) */
.tile-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.tile-list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background-color var(--transition);
}

.tile-list-item:hover {
  background-color: rgba(255, 255, 255, 0.04);
}

/* Brief modal sections */
.brief-section {
  margin-bottom: 24px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--border);
}

.brief-section:last-child {
  border-bottom: none;
  margin-bottom: 0;
}

.brief-section-label {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-secondary);
  margin-bottom: 10px;
}

.brief-section-body p {
  color: var(--text-secondary);
  font-size: 0.9375rem;
  line-height: 1.65;
}

.brief-list-items {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.brief-list-items li {
  color: var(--text-secondary);
  font-size: 0.9375rem;
  line-height: 1.5;
  padding-left: 16px;
  position: relative;
}

.brief-list-items li::before {
  content: '—';
  position: absolute;
  left: 0;
  color: var(--accent);
}

.lang-tag {
  display: inline-block;
  background: rgba(232, 148, 74, 0.1);
  color: var(--accent);
  border: 1px solid rgba(232, 148, 74, 0.25);
  border-radius: var(--radius-pill);
  padding: 3px 12px;
  font-size: 0.8125rem;
}

.coaches-note {
  background: rgba(255, 255, 255, 0.02);
  border-radius: var(--radius-sm);
  padding: 16px;
  border: none !important;
}

/* --- Responsive --------------------------------------------- */
@media (max-width: 900px) {
  .dashboard-grid {
    grid-template-columns: 1fr;
  }

  .banner-content {
    flex-direction: column;
    align-items: flex-start;
  }

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

/* --- Intake (Welcome + Closing) ------------------------------ */

.intake-fullscreen {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 80px var(--space-md) var(--space-md);
  text-align: center;
}

.intake-center {
  max-width: 560px;
  width: 100%;
}

.intake-greeting {
  font-size: clamp(2.5rem, 7vw, 4rem);
  font-weight: 500;
  line-height: 1.1;
  margin-bottom: 24px;
}

.intake-subtext {
  color: var(--text-secondary);
  font-size: clamp(1rem, 2.5vw, 1.125rem);
  line-height: 1.7;
  margin-bottom: 40px;
}

.intake-cta {
  font-size: 1.0625rem;
  padding: 14px 40px;
}

.intake-ai-notice {
  font-size: 0.875rem;
  color: var(--text-secondary);
  max-width: 480px;
  line-height: 1.6;
  margin-bottom: 28px;
  border-left: 2px solid #E8944A;
  padding-left: 14px;
  text-align: left;
}

.intake-consent-label {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.9375rem;
  color: var(--text-primary);
  cursor: pointer;
  margin-bottom: 32px;
  user-select: none;
}

.intake-consent-label input[type="checkbox"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.intake-checkbox-box {
  width: 18px;
  height: 18px;
  border: 2px solid var(--border);
  border-radius: 4px;
  background: transparent;
  flex-shrink: 0;
  transition: border-color 0.2s, background 0.2s;
  position: relative;
  display: inline-block;
}

.intake-checkbox-box.is-checked {
  background: #E8944A;
  border-color: #E8944A;
}

.intake-checkbox-box.is-checked::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 5px;
  width: 4px;
  height: 8px;
  border: 2px solid #0D0F14;
  border-top: none;
  border-left: none;
  transform: rotate(45deg);
}

.intake-cta:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

/* --- Chat screen --------------------------------------------- */

.chat-container {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 64px); /* 64px = navbar height */
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 32px 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  scroll-behavior: smooth;
}

/* Scrollbar styling */
.chat-messages::-webkit-scrollbar { width: 4px; }
.chat-messages::-webkit-scrollbar-track { background: transparent; }
.chat-messages::-webkit-scrollbar-thumb { background: var(--border-hover); border-radius: 2px; }

/* Message bubbles */
.message {
  max-width: min(72%, 540px);
  padding: 14px 18px;
  border-radius: 18px;
  line-height: 1.65;
  font-size: 0.9375rem;
  white-space: pre-wrap;
  word-break: break-word;
}

.message-ai {
  background-color: var(--bg-secondary);
  color: var(--text-primary);
  align-self: flex-start;
  border-bottom-left-radius: 4px;
}

.message-client {
  background-color: #FFFFFF;
  color: #0D0F14;
  align-self: flex-end;
  border-bottom-right-radius: 4px;
}

/* Typing indicator bubble */
.typing-indicator {
  padding: 14px 20px;
}

.typing-indicator .loading-dots {
  gap: 5px;
}

.typing-indicator .loading-dot {
  width: 7px;
  height: 7px;
}

/* Input area */
.chat-input-area {
  border-top: 1px solid var(--border);
  background-color: var(--bg-primary);
  padding: 16px 24px;
  display: flex;
  align-items: flex-end;
  gap: 12px;
}

.chat-textarea {
  flex: 1;
  background-color: var(--bg-secondary);
  color: var(--text-primary);
  border: 1.5px solid transparent;
  border-radius: 18px;
  padding: 12px 18px;
  font-family: var(--font-body);
  font-size: 0.9375rem;
  line-height: 1.5;
  resize: none;
  overflow: hidden;
  min-height: 46px;
  max-height: 140px;
  transition: border-color var(--transition);
}

.chat-textarea::placeholder {
  color: var(--text-secondary);
}

.chat-textarea:focus {
  outline: none;
  border-color: var(--accent);
  overflow-y: auto;
}

.chat-send-btn {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background-color: var(--accent);
  color: #0D0F14;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: opacity var(--transition);
}

.chat-send-btn:hover  { opacity: 0.88; }
.chat-send-btn:active { opacity: 0.7; }
.chat-send-btn:disabled { opacity: 0.35; cursor: not-allowed; }

/* --- Responsive --------------------------------------------- */
@media (max-width: 768px) {
  .page-content {
    padding: var(--space-md) var(--space-sm);
  }

  .navbar {
    padding: 0 var(--space-sm);
  }

  .modal {
    padding: var(--space-md);
  }

  .chat-messages {
    padding: 20px 16px;
  }

  .chat-input-area {
    padding: 12px 16px;
  }

  .message {
    max-width: 88%;
  }

  .intake-fullscreen {
    padding: 72px 20px 24px;
  }
}

/* --- Terms Acceptance ---------------------------------------- */

.terms-page {
  min-height: calc(100vh - 64px);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: var(--space-xl) var(--space-md);
}

.terms-container {
  width: 100%;
  max-width: 720px;
}

.terms-header {
  margin-bottom: var(--space-lg);
}

.terms-heading {
  font-size: clamp(2rem, 5vw, 2.75rem);
  font-weight: 500;
  margin-bottom: var(--space-sm);
}

.terms-subtext {
  color: var(--text-secondary);
  font-size: 1rem;
  line-height: 1.7;
}

.terms-error {
  background: rgba(248, 113, 113, 0.08);
  border: 1px solid rgba(248, 113, 113, 0.3);
  border-radius: var(--radius-md);
  color: #f87171;
  font-size: 0.9rem;
  padding: 14px 18px;
  margin-bottom: var(--space-md);
}

.terms-boxes {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
  margin-bottom: var(--space-lg);
}

.terms-box {
  background-color: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-md);
}

.terms-box-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-sm);
  margin-bottom: var(--space-sm);
}

.terms-box-title {
  font-family: var(--font-display);
  font-size: 1.125rem;
  font-weight: 500;
  color: var(--text-primary);
}

.terms-read-link {
  color: var(--accent);
  font-size: 0.875rem;
  white-space: nowrap;
  flex-shrink: 0;
  transition: opacity var(--transition);
}

.terms-read-link:hover {
  opacity: 0.75;
}

.terms-points {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.terms-points li {
  color: var(--text-secondary);
  font-size: 0.9375rem;
  line-height: 1.6;
  padding-left: 20px;
  position: relative;
}

.terms-points li::before {
  content: '—';
  position: absolute;
  left: 0;
  color: var(--accent);
}

/* Checkbox — reuses intake pattern with minor adjustments */
.terms-checkbox-label {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  cursor: pointer;
  margin-bottom: var(--space-md);
  user-select: none;
}

.terms-checkbox-label input[type="checkbox"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.terms-checkbox-box {
  width: 20px;
  height: 20px;
  min-width: 20px;
  border: 2px solid var(--border-hover);
  border-radius: 4px;
  background: transparent;
  margin-top: 2px;
  transition: border-color 0.2s, background 0.2s;
  position: relative;
  display: inline-block;
}

.terms-checkbox-box.is-checked {
  background: var(--accent);
  border-color: var(--accent);
}

.terms-checkbox-box.is-checked::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 5px;
  width: 5px;
  height: 9px;
  border: 2px solid #0D0F14;
  border-top: none;
  border-left: none;
  transform: rotate(45deg);
}

.terms-checkbox-text {
  color: var(--text-primary);
  font-size: 0.9375rem;
  line-height: 1.6;
}

.terms-submit-btn {
  width: 100%;
  margin-top: 4px;
  padding: 14px 28px;
  font-size: 1rem;
}

@media (max-width: 768px) {
  .terms-page {
    padding: var(--space-lg) var(--space-sm);
    align-items: flex-start;
  }

  .terms-box-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
  }
}
