/* =====================
   THERANOTES DESIGN SYSTEM
   ===================== */

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

:root {
  --bg: #f5f3ef;
  --surface: #ffffff;
  --border: #e8e4dc;
  --text-primary: #1a1a18;
  --text-secondary: #7a776e;
  --text-muted: #b0ada5;
  --accent: #7c3aed;
  --accent-light: #ede9fe;
  --accent-warm: #c17f24;
  --tag-bg: #f0ede8;
  --status-confirmed: #7c3aed;
  --status-pending: #c17f24;
  --status-cancelled: #9c6060;
  --status-completed: #7c3aed;
  --nav-h: 56px;
  --max-width: 860px;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text-primary);
  min-height: 100vh;
  font-weight: 400;
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* =====================
   TYPOGRAPHY
   ===================== */
h1, h2, h3, h4 {
  font-family: 'Instrument Serif', Georgia, serif;
  font-weight: 400;
  line-height: 1.2;
}

h1 { font-size: 2.2rem; letter-spacing: -0.01em; }
h2 { font-size: 1.6rem; letter-spacing: -0.01em; }
h3 { font-size: 1.2rem; }

a {
  color: var(--accent);
  text-decoration: none;
  transition: opacity 0.15s;
}

a:hover {
  opacity: 0.8;
}

/* =====================
   TOP NAVIGATION
   ===================== */
.top-nav {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(245, 243, 239, 0.92);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  height: var(--nav-h);
  display: flex;
  align-items: center;
  padding: 0 20px;
  justify-content: space-between;
  gap: 16px;
}

.nav-logo {
  font-family: 'Instrument Serif', Georgia, serif;
  font-size: 1.2rem;
  color: var(--text-primary);
  letter-spacing: -0.01em;
  white-space: nowrap;
  flex-shrink: 0;
}

.nav-logo span {
  font-style: italic;
  color: var(--accent);
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 2px;
  list-style: none;
}

.nav-links a {
  font-size: 0.85rem;
  font-weight: 400;
  color: var(--text-secondary);
  padding: 6px 14px;
  border-radius: 7px;
  transition: background 0.15s, color 0.15s;
}

.nav-links a:hover {
  background: var(--border);
  color: var(--text-primary);
}

.nav-links a.active {
  background: var(--surface);
  color: var(--text-primary);
  font-weight: 500;
  box-shadow: 0 1px 4px rgba(0,0,0,0.07);
}

/* Mobile bottom nav */
.bottom-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 100;
  background: rgba(255,255,255,0.97);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--border);
  padding: 8px 0 max(8px, env(safe-area-inset-bottom));
}

.bottom-nav ul {
  list-style: none;
  display: flex;
  justify-content: space-around;
  align-items: stretch;
}

.bottom-nav a {
  text-decoration: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 4px 24px;
  font-size: 0.68rem;
  font-weight: 500;
  color: var(--text-secondary);
  letter-spacing: 0.03em;
  transition: color 0.15s;
}

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

.bottom-nav .nav-icon {
  font-size: 1.2rem;
  line-height: 1;
}

@media (max-width: 600px) {
  .nav-links { display: none; }
  .bottom-nav { display: block; }
  body { padding-bottom: 72px; }
}

/* =====================
   PAGE CONTENT
   ===================== */
.content {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 36px 20px 48px;
}

.page-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 32px;
  flex-wrap: wrap;
}

.page-title {
  font-family: 'Instrument Serif', Georgia, serif;
  font-size: 2.2rem;
  line-height: 1;
  letter-spacing: -0.01em;
}

.page-title span {
  font-style: italic;
  color: var(--accent);
}

/* =====================
   WEEK NAVIGATION
   ===================== */
.week-nav {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.82rem;
  color: var(--text-secondary);
}

.week-nav button {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  width: 30px;
  height: 30px;
  cursor: pointer;
  font-size: 1rem;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color 0.15s, color 0.15s;
}

.week-nav button:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.week-label {
  font-weight: 500;
  color: var(--text-primary);
}

/* =====================
   STATS BAR
   ===================== */
.week-stats {
  display: flex;
  gap: 24px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.stat {
  display: flex;
  align-items: baseline;
  gap: 6px;
}

.stat-num {
  font-family: 'Instrument Serif', Georgia, serif;
  font-size: 1.5rem;
}

.stat-label {
  font-size: 0.78rem;
  color: var(--text-secondary);
}

.stat + .stat {
  padding-left: 24px;
  border-left: 1px solid var(--border);
}

@media (max-width: 520px) {
  .stat + .stat { padding-left: 16px; }
  .week-stats { gap: 16px; }
  .page-title { font-size: 1.8rem; }
}

.week-nav-container {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-bottom: 32px;
}

.week-nav-arrow {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  width: 36px;
  height: 72px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  color: var(--text-secondary);
  text-decoration: none;
  transition: border-color .15s, color .15s;
  flex-shrink: 0;
}

.week-nav-arrow:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* =====================
   WEEK GRID
   ===================== */
.week-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
  width: 100%;
}

.wg-cell {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 14px 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-height: 80px;
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s, transform 0.15s;
  text-align: center;
}

.wg-cell:hover {
  border-color: #d0ccc4;
  box-shadow: 0 2px 10px rgba(0,0,0,0.06);
  transform: translateY(-1px);
}

.wg-cell.is-today {
  background: var(--accent-light);
  border-color: rgba(45, 106, 79, 0.35);
}

.wg-cell.is-empty {
  opacity: 0.45;
}

.wg-day {
  font-size: 0.62rem;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--text-secondary);
}

.wg-cell.is-today .wg-day {
  color: var(--accent);
}

.wg-date {
  font-family: 'Instrument Serif', Georgia, serif;
  font-size: 1.2rem;
  line-height: 1;
  color: var(--text-primary);
}

.wg-cell.is-today .wg-date {
  color: var(--accent);
}

.wg-count {
  font-size: 0.68rem;
  font-weight: 500;
  color: var(--text-secondary);
  background: var(--tag-bg);
  border-radius: 10px;
  padding: 1px 7px;
  min-width: 20px;
  margin-top: 2px;
}

.wg-cell.is-today .wg-count {
  background: rgba(45, 106, 79, 0.15);
  color: var(--accent);
}

.wg-count.is-zero {
  background: transparent;
  color: var(--border);
}

@media (max-width: 520px) {
  .wg-cell {
    padding: 8px 4px;
    border-radius: 7px;
  }
  .wg-date { font-size: 1rem; }
  .wg-day { font-size: 0.55rem; }
  .wg-count { font-size: 0.62rem; padding: 1px 5px; }
}

/* =====================
   SCHEDULE / DAY BLOCKS
   ===================== */
.schedule {
  display: flex;
  flex-direction: column;
}

.day-block {
  display: grid;
  grid-template-columns: 110px 1fr;
  gap: 0;
  border-top: 1px solid var(--border);
  padding: 22px 0;
  animation: fadeUp 0.4s ease both;
}

.day-block:last-child {
  border-bottom: 1px solid var(--border);
}

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.day-block:nth-child(1) { animation-delay: 0.04s; }
.day-block:nth-child(2) { animation-delay: 0.08s; }
.day-block:nth-child(3) { animation-delay: 0.12s; }
.day-block:nth-child(4) { animation-delay: 0.16s; }
.day-block:nth-child(5) { animation-delay: 0.20s; }
.day-block:nth-child(6) { animation-delay: 0.24s; }
.day-block:nth-child(7) { animation-delay: 0.28s; }

.day-label {
  padding-top: 2px;
  position: sticky;
  top: calc(var(--nav-h) + 12px);
  align-self: start;
}

.day-name {
  font-family: 'Instrument Serif', Georgia, serif;
  font-size: 1.1rem;
  line-height: 1.2;
}

.day-date {
  font-size: 0.76rem;
  color: var(--text-secondary);
  margin-top: 2px;
}

.day-today .day-name {
  color: var(--accent);
}

.day-today .day-name::after {
  content: 'today';
  display: block;
  font-family: 'DM Sans', sans-serif;
  font-size: 0.62rem;
  font-style: normal;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--accent);
  margin-top: 5px;
}

.day-sessions {
  display: flex;
  flex-direction: column;
  gap: 9px;
}

.empty-day {
  padding: 12px 0;
  font-size: 0.82rem;
  color: var(--text-secondary);
  font-style: italic;
}

@media (max-width: 520px) {
  .day-block {
    grid-template-columns: 1fr;
    gap: 10px;
  }
  .day-label {
    position: static;
    display: flex;
    align-items: baseline;
    gap: 8px;
  }
  .day-name { font-size: 1rem; }
  .day-date { margin-top: 0; }
}

/* =====================
   SESSION CARDS
   ===================== */
.session {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 13px 16px;
  display: grid;
  grid-template-columns: 62px 1fr auto;
  align-items: center;
  gap: 14px;
  transition: box-shadow 0.18s, transform 0.18s, border-color 0.18s;
  cursor: default;
}

.session:hover {
  box-shadow: 0 4px 18px rgba(0,0,0,0.07);
  transform: translateY(-1px);
  border-color: #d8d4cc;
}

.session-time {
  font-size: 0.78rem;
  color: var(--text-secondary);
  line-height: 1.5;
  white-space: nowrap;
}

.session-time-start {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-primary);
}

.session-info {
  min-width: 0;
}

.session-client {
  font-size: 0.93rem;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 5px;
}

.session-tags {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-wrap: wrap;
}

/* Condition tags */
.tag {
  font-size: 0.68rem;
  font-weight: 500;
  letter-spacing: 0.03em;
  padding: 2px 7px;
  border-radius: 4px;
  background: var(--tag-bg);
  color: var(--text-secondary);
  white-space: nowrap;
}

.tag-anxiety    { background: #eef3fd; color: #3b5cc7; }
.tag-depression { background: #f0edf8; color: #6b3fa8; }
.tag-trauma     { background: #fdeee8; color: #b84c1c; }
.tag-grief      { background: #eef6f9; color: #2b7a99; }
.tag-ocd        { background: #fdf3e3; color: #9a6010; }
.tag-adhd       { background: #e8f8f0; color: #1a7a50; }
.tag-ptsd       { background: #fde8e8; color: #9c3030; }
.tag-stress     { background: #f5f0e8; color: #7a5c2a; }
.tag-phobia     { background: #f0e8f5; color: #7a3a9c; }
.tag-addiction  { background: #e8f0fd; color: #2a4a9c; }

.session-note {
  font-size: 0.76rem;
  color: var(--text-secondary);
  margin-top: 5px;
  display: flex;
  align-items: center;
  gap: 4px;
}

.session-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
}

/* Status dots */
.status-dot {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 0.73rem;
  font-weight: 500;
  white-space: nowrap;
}

.status-dot::before {
  content: '';
  display: block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}

.status-confirmed { color: var(--status-confirmed); }
.status-confirmed::before { background: var(--status-confirmed); }

.status-pending { color: var(--status-pending); }
.status-pending::before { background: var(--status-pending); }

.status-cancelled { color: var(--status-cancelled); }
.status-cancelled::before { background: var(--status-cancelled); }

.status-completed { color: var(--status-completed); }
.status-completed::before { background: var(--status-completed); }

/* Action buttons */
.session-actions {
  display: flex;
  gap: 4px;
  opacity: 0;
  transition: opacity 0.18s;
}

.session:hover .session-actions {
  opacity: 1;
}

.btn-icon {
  border: 1px solid var(--border);
  background: var(--bg);
  border-radius: 6px;
  width: 27px;
  height: 27px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 0.82rem;
  color: var(--text-secondary);
  transition: border-color 0.15s, color 0.15s, background 0.15s;
  text-decoration: none;
}

.btn-icon:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-light);
}

/* Cancelled session */
.session-cancelled {
  opacity: 0.5;
  background: #fafaf9;
}

.session-cancelled .session-client {
  text-decoration: line-through;
  text-decoration-color: var(--text-secondary);
}

@media (max-width: 520px) {
  .session {
    grid-template-columns: 55px 1fr;
    grid-template-rows: auto auto;
  }
  .session-right {
    grid-column: 2;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
  }
  .session-actions {
    opacity: 1;
  }
}

/* =====================
   FORMS
   ===================== */
.form {
  max-width: 500px;
}

.form-group {
  margin-bottom: 20px;
}

.form-group label {
  display: block;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 10px 12px;
  font-size: 0.95rem;
  font-family: inherit;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text-primary);
  transition: border-color 0.15s, box-shadow 0.15s;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-light);
}

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

.form-actions {
  display: flex;
  gap: 12px;
  margin-top: 24px;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 20px;
  font-size: 0.9rem;
  font-weight: 500;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.15s;
  text-decoration: none;
  border: none;
}

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

.btn-primary:hover {
  background: #245c4a;
  opacity: 1;
}

.btn-secondary {
  background: var(--surface);
  color: var(--text-primary);
  border: 1px solid var(--border);
}

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

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border: none;
}

.btn-ghost:hover {
  color: var(--text-primary);
  background: var(--border);
}

/* =====================
   CARDS
   ===================== */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 24px;
  margin-bottom: 20px;
}

.card h3 {
  margin-bottom: 16px;
  font-family: 'Instrument Serif', Georgia, serif;
  font-size: 1.3rem;
}

/* =====================
   CLIENTS LIST
   ===================== */
.client-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 12px;
}

.client-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px;
  transition: box-shadow 0.18s, transform 0.18s, border-color 0.18s;
  cursor: pointer;
}

.client-card:hover {
  box-shadow: 0 4px 18px rgba(0,0,0,0.07);
  transform: translateY(-1px);
  border-color: #d8d4cc;
}

.client-name {
  font-size: 1rem;
  font-weight: 500;
  margin-bottom: 4px;
}

.client-meta {
  font-size: 0.82rem;
  color: var(--text-secondary);
}

/* =====================
   UTILITIES
   ===================== */
.empty-state {
  text-align: center;
  padding: 48px 20px;
  color: var(--text-secondary);
  font-size: 0.95rem;
}

.text-muted {
  color: var(--text-secondary);
}

.mt-4 { margin-top: 16px; }
.mb-4 { margin-bottom: 16px; }

/* Page header variations */
.page-header-simple {
  margin-bottom: 24px;
}

/* Auth pages */
.auth-container {
  max-width: 400px;
  margin: 60px auto;
  padding: 0 20px;
}

.auth-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 32px;
}

.auth-title {
  font-family: 'Instrument Serif', Georgia, serif;
  font-size: 1.8rem;
  text-align: center;
  margin-bottom: 24px;
}

/* Alerts */
.alert {
  padding: 12px 16px;
  border-radius: 8px;
  margin-bottom: 20px;
  font-size: 0.9rem;
}

.alert-success {
  background: #d1e7dd;
  border: 1px solid #a3cfbb;
  color: #0f5132;
}

.alert-error {
  background: #f8d7da;
  border: 1px solid #f1aeb5;
  color: #842029;
}

/* Login/Register links */
.auth-links {
  text-align: center;
  margin-top: 20px;
  font-size: 0.9rem;
  color: var(--text-secondary);
}

.auth-footer {
  text-align: center;
  margin-top: 20px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}

.auth-footer a {
  color: var(--accent);
  text-decoration: none;
}

.auth-footer a:hover {
  text-decoration: underline;
}

/* Responsive utilities */
@media (max-width: 600px) {
  .content {
    padding: 24px 16px 40px;
  }
  
  .page-header {
    margin-bottom: 24px;
  }
  
  .form-actions {
    flex-direction: column;
  }
  
  .btn {
    width: 100%;
  }
}

/* =====================
   TABLES
   ===================== */
.table-container {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
}

.table {
  width: 100%;
  border-collapse: collapse;
}

.table th,
.table td {
  padding: 14px 16px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.table th {
  background: var(--bg);
  font-weight: 500;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-secondary);
}

.table tbody tr {
  transition: background .15s;
}

.table tbody tr:hover {
  background: rgba(45, 106, 79, 0.03);
}

.table tbody tr:last-child td {
  border-bottom: none;
}

.table a {
  color: var(--accent);
  text-decoration: none;
  font-weight: 500;
}

.table a:hover {
  text-decoration: underline;
}

.table .actions {
  white-space: nowrap;
}

.table .btn-link {
  color: var(--text-secondary);
  font-size: 0.85rem;
  margin-right: 12px;
}

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

.table .btn-danger {
  color: #9c6060;
}

.table .btn-danger:hover {
  color: #c04040;
}

@media (max-width: 600px) {
  .table-container {
    border-radius: 8px;
  }
  
  .table th,
  .table td {
    padding: 10px 12px;
    font-size: 0.9rem;
  }
}
