@import url('https://fonts.googleapis.com/css2?family=Cormorant+Garamond:ital,wght@0,300;0,400;0,500;1,300;1,400&family=Inter:wght@300;400;500;600&display=swap');

:root {
  --bg:         #F0F4F8;
  --white:      #FFFFFF;
  --surface:    #FFFFFF;
  --surface2:   #F8FAFC;
  --border:     #E2E8F0;
  --border-light: #F1F5F9;
  --blue:       #2563EB;
  --blue-dark:  #1D4ED8;
  --blue-light: #EFF6FF;
  --blue-mid:   #DBEAFE;
  --text:       #1E293B;
  --text-dim:   #64748B;
  --text-muted: #94A3B8;
  --danger:     #EF4444;
  --success:    #10B981;
  --radius:     16px;
  --radius-sm:  10px;
  --radius-xs:  8px;
  --shadow-sm:  0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow:     0 4px 16px rgba(0,0,0,0.08);
  --shadow-lg:  0 8px 32px rgba(0,0,0,0.12);
}

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

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', sans-serif;
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

.hidden { display: none !important; }

/* ─── Login ──────────────────────────────────────────────────────────────────── */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: linear-gradient(135deg, #EFF6FF 0%, #F0F4F8 50%, #E0E7FF 100%);
}

.login-box { width: 100%; max-width: 420px; }

.login-brand { text-align: center; margin-bottom: 36px; }

.login-brand .logo-mark {
  display: inline-flex;
  width: 56px; height: 56px;
  border-radius: 16px;
  background: var(--blue);
  align-items: center; justify-content: center;
  margin-bottom: 20px;
  box-shadow: 0 8px 24px rgba(37,99,235,0.3);
}

.login-brand .logo-mark svg {
  width: 24px; height: 24px;
  stroke: white; fill: none;
  stroke-width: 1.8; stroke-linecap: round;
}

.login-brand h1 {
  font-family: 'Cormorant Garamond', serif;
  font-size: 30px; font-weight: 400;
  color: var(--text); margin-bottom: 6px;
  letter-spacing: -0.01em;
}

.login-brand p {
  font-size: 13px; color: var(--text-dim);
  font-weight: 400; letter-spacing: 0.01em;
}

.login-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 36px;
  box-shadow: var(--shadow-lg);
}

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

.form-group label {
  display: block; font-size: 12px; font-weight: 600;
  letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--text-dim); margin-bottom: 8px;
}

.form-group input, .form-group select {
  width: 100%; padding: 12px 16px;
  background: var(--surface2);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-xs);
  color: var(--text);
  font-family: 'Inter', sans-serif; font-size: 14px;
  outline: none; transition: all 0.2s;
}

.form-group input:focus, .form-group select:focus {
  border-color: var(--blue);
  background: var(--white);
  box-shadow: 0 0 0 3px rgba(37,99,235,0.08);
}

.form-group input::placeholder { color: var(--text-muted); }

.btn-primary {
  width: 100%; padding: 13px;
  background: var(--blue); border: none;
  border-radius: var(--radius-xs);
  color: white;
  font-family: 'Inter', sans-serif; font-size: 14px; font-weight: 600;
  letter-spacing: 0.02em; cursor: pointer;
  transition: all 0.2s; margin-top: 4px;
  box-shadow: 0 4px 12px rgba(37,99,235,0.3);
}

.btn-primary:hover { background: var(--blue-dark); transform: translateY(-1px); box-shadow: 0 6px 16px rgba(37,99,235,0.35); }
.btn-primary:active { transform: translateY(0); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

.login-error {
  margin-top: 14px; padding: 10px 14px;
  background: #FEF2F2; border: 1px solid #FECACA;
  border-radius: var(--radius-xs);
  color: var(--danger); font-size: 13px; text-align: center;
}

.login-notice {
  margin-top: 24px; padding: 14px 16px;
  background: var(--blue-light);
  border: 1px solid var(--blue-mid);
  border-radius: var(--radius-xs);
  font-size: 12px; color: var(--text-dim);
  line-height: 1.6; text-align: center;
}

/* ─── Chat Layout ────────────────────────────────────────────────────────────── */
.chat-layout {
  display: flex; flex-direction: column; height: 100vh;
  background: var(--bg);
}

.chat-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 28px; height: 64px;
  background: var(--white);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  flex-shrink: 0; z-index: 10;
}

.header-brand { display: flex; align-items: center; gap: 12px; }

.header-logo {
  width: 36px; height: 36px; border-radius: 10px;
  background: var(--blue);
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 2px 8px rgba(37,99,235,0.25);
}

.header-logo svg {
  width: 18px; height: 18px;
  stroke: white; fill: none; stroke-width: 1.8; stroke-linecap: round;
}

.header-brand h2 {
  font-family: 'Cormorant Garamond', serif;
  font-size: 20px; font-weight: 400; color: var(--text);
  letter-spacing: -0.01em;
}

.header-brand span {
  font-size: 12px; color: var(--text-muted);
  font-weight: 400; margin-left: 2px;
}

.header-actions { display: flex; align-items: center; gap: 12px; }

.header-user {
  font-size: 13px; color: var(--text-dim); font-weight: 500;
  padding: 6px 12px;
  background: var(--surface2); border-radius: 20px;
  border: 1px solid var(--border);
}

.btn-end-session {
  padding: 7px 16px;
  background: transparent; border: 1.5px solid var(--border);
  border-radius: 20px; color: var(--text-dim);
  font-family: 'Inter', sans-serif; font-size: 12px; font-weight: 500;
  cursor: pointer; transition: all 0.2s;
}

.btn-end-session:hover {
  border-color: var(--blue); color: var(--blue);
  background: var(--blue-light);
}

/* ─── Messages ───────────────────────────────────────────────────────────────── */
.messages-area {
  flex: 1; overflow-y: auto; padding: 32px 0;
}

.messages-inner {
  width: 100%; max-width: 700px;
  margin: 0 auto; padding: 0 24px;
  display: flex; flex-direction: column; gap: 20px;
}

.message { display: flex; flex-direction: column; gap: 4px; animation: fadeUp 0.25s ease; }

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

.message-label {
  font-size: 11px; font-weight: 600;
  letter-spacing: 0.08em; text-transform: uppercase;
}

.message.assistant .message-label { color: var(--blue); padding-left: 4px; }
.message.user .message-label { color: var(--text-muted); text-align: right; padding-right: 4px; }

.message-bubble {
  padding: 14px 18px;
  font-size: 15px; line-height: 1.7;
}

.message.assistant .message-bubble {
  background: var(--white);
  border: 1px solid var(--border);
  border-left: 3px solid var(--blue);
  border-radius: 4px var(--radius) var(--radius) var(--radius);
  color: var(--text);
  box-shadow: var(--shadow-sm);
}

.message.user .message-bubble {
  background: var(--blue);
  border-radius: var(--radius) 4px var(--radius) var(--radius);
  color: white;
  text-align: right;
  box-shadow: 0 4px 12px rgba(37,99,235,0.25);
  margin-left: auto;
  max-width: 85%;
}

.typing-indicator {
  display: flex; gap: 5px;
  padding: 16px 18px;
  background: var(--white);
  border: 1px solid var(--border);
  border-left: 3px solid var(--blue);
  border-radius: 4px var(--radius) var(--radius) var(--radius);
  width: fit-content;
  box-shadow: var(--shadow-sm);
}

.typing-indicator span {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--blue);
  animation: bounce 1.2s ease-in-out infinite;
  opacity: 0.5;
}

.typing-indicator span:nth-child(2) { animation-delay: 0.2s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.4s; }

@keyframes bounce {
  0%, 80%, 100% { transform: translateY(0); opacity: 0.4; }
  40%            { transform: translateY(-6px); opacity: 1; }
}

/* ─── Input ──────────────────────────────────────────────────────────────────── */
.input-area {
  flex-shrink: 0;
  padding: 16px 24px 24px;
  background: var(--white);
  border-top: 1px solid var(--border);
}

.input-inner {
  max-width: 700px; margin: 0 auto;
  display: flex; gap: 10px; align-items: flex-end;
}

.input-wrapper { flex: 1; }

#message-input {
  width: 100%; min-height: 50px; max-height: 160px;
  padding: 13px 18px;
  background: var(--surface2);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: 'Inter', sans-serif; font-size: 15px; line-height: 1.5;
  resize: none; outline: none; transition: all 0.2s;
  overflow-y: auto;
}

#message-input:focus {
  border-color: var(--blue);
  background: var(--white);
  box-shadow: 0 0 0 3px rgba(37,99,235,0.08);
}

#message-input::placeholder { color: var(--text-muted); }

.btn-send {
  width: 50px; height: 50px; flex-shrink: 0;
  background: var(--blue); border: none;
  border-radius: var(--radius-sm); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.2s;
  box-shadow: 0 4px 12px rgba(37,99,235,0.3);
}

.btn-send:hover { background: var(--blue-dark); transform: translateY(-1px); }
.btn-send:active { transform: translateY(0); }
.btn-send:disabled { opacity: 0.4; cursor: not-allowed; transform: none; box-shadow: none; }

.btn-send svg {
  width: 18px; height: 18px; stroke: white; fill: none;
  stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
}

.input-hint {
  max-width: 700px; margin: 8px auto 0;
  font-size: 11px; color: var(--text-muted); letter-spacing: 0.01em;
}

/* ─── Modal ──────────────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(15,23,42,0.4); backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
  z-index: 100; animation: fadeIn 0.2s ease;
}

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

.modal-box {
  background: var(--white); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 36px;
  max-width: 380px; width: 90%; text-align: center;
  box-shadow: var(--shadow-lg);
}

.modal-box h3 {
  font-family: 'Cormorant Garamond', serif;
  font-size: 24px; font-weight: 400; color: var(--text); margin-bottom: 10px;
}

.modal-box p { font-size: 14px; color: var(--text-dim); line-height: 1.65; margin-bottom: 28px; }

.modal-actions { display: flex; gap: 10px; }

.btn-cancel {
  flex: 1; padding: 11px; background: var(--surface2);
  border: 1.5px solid var(--border); border-radius: var(--radius-xs);
  color: var(--text-dim); font-family: 'Inter', sans-serif; font-size: 14px; font-weight: 500;
  cursor: pointer; transition: all 0.2s;
}

.btn-cancel:hover { border-color: var(--text-dim); color: var(--text); }

.btn-confirm-end {
  flex: 1; padding: 11px;
  background: #FEF2F2; border: 1.5px solid #FECACA;
  border-radius: var(--radius-xs); color: var(--danger);
  font-family: 'Inter', sans-serif; font-size: 14px; font-weight: 500;
  cursor: pointer; transition: all 0.2s;
}

.btn-confirm-end:hover { background: #FEE2E2; }

/* ─── Empty state ────────────────────────────────────────────────────────────── */
.empty-state {
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; flex: 1; gap: 12px;
  color: var(--text-muted); padding: 60px 24px; text-align: center;
}

.empty-state .mark {
  width: 48px; height: 48px; border-radius: 14px;
  background: var(--blue-light); border: 1px solid var(--blue-mid);
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 8px;
  font-size: 22px;
}

.empty-state p { font-size: 14px; max-width: 240px; line-height: 1.65; color: var(--text-dim); }

/* ─── Admin Layout ───────────────────────────────────────────────────────────── */
.admin-layout { display: flex; height: 100vh; overflow: hidden; background: var(--bg); }

.admin-sidebar {
  width: 240px; flex-shrink: 0;
  background: var(--white);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  padding: 24px 0;
  box-shadow: var(--shadow-sm);
}

.sidebar-brand {
  padding: 0 20px 24px;
  border-bottom: 1px solid var(--border-light);
  margin-bottom: 12px;
  display: flex; align-items: center; gap: 10px;
}

.sidebar-brand .logo-mark {
  width: 36px; height: 36px; border-radius: 10px;
  background: var(--blue); flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 2px 8px rgba(37,99,235,0.25);
}

.sidebar-brand .logo-mark svg {
  width: 18px; height: 18px;
  stroke: white; fill: none; stroke-width: 1.8; stroke-linecap: round;
}

.sidebar-brand h1 {
  font-family: 'Cormorant Garamond', serif;
  font-size: 18px; font-weight: 400; color: var(--text);
}

.sidebar-brand span {
  font-size: 10px; color: var(--blue); font-weight: 600;
  letter-spacing: 0.08em; text-transform: uppercase;
  display: block; margin-top: 1px;
}

.sidebar-nav { flex: 1; padding: 0 10px; }

.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: var(--radius-xs);
  color: var(--text-dim); font-size: 14px; font-weight: 500;
  cursor: pointer; transition: all 0.15s; margin-bottom: 2px;
  border: none; background: none; width: 100%; text-align: left;
}

.nav-item:hover { background: var(--surface2); color: var(--text); }
.nav-item.active { background: var(--blue-light); color: var(--blue); }

.nav-item svg {
  width: 16px; height: 16px; stroke: currentColor;
  fill: none; stroke-width: 1.8; stroke-linecap: round; flex-shrink: 0;
}

.sidebar-footer {
  padding: 16px 20px 0;
  border-top: 1px solid var(--border-light);
}

.sidebar-user { font-size: 12px; color: var(--text-muted); margin-bottom: 10px; font-weight: 500; }

.btn-logout {
  font-size: 12px; color: var(--danger); font-weight: 500;
  background: none; border: none; cursor: pointer; padding: 0;
}

.btn-logout:hover { text-decoration: underline; }

.admin-main { flex: 1; overflow-y: auto; padding: 36px 40px; }

.admin-view { display: none; }
.admin-view.active { display: block; }

.admin-view h2 {
  font-family: 'Cormorant Garamond', serif;
  font-size: 28px; font-weight: 400; color: var(--text);
  margin-bottom: 28px; letter-spacing: -0.01em;
}

/* Stats */
.stats-grid {
  display: grid; grid-template-columns: repeat(3, 1fr);
  gap: 16px; margin-bottom: 36px;
}

.stat-card {
  background: var(--white); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 24px;
  box-shadow: var(--shadow-sm);
}

.stat-card .stat-label {
  font-size: 11px; font-weight: 600; letter-spacing: 0.07em;
  text-transform: uppercase; color: var(--text-muted); margin-bottom: 10px;
}

.stat-card .stat-value {
  font-family: 'Cormorant Garamond', serif;
  font-size: 40px; font-weight: 300; color: var(--text); line-height: 1;
}

.stat-card .stat-sub { font-size: 12px; color: var(--text-muted); margin-top: 6px; }

/* Table */
.section-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 14px;
}

.section-header h3 {
  font-size: 13px; font-weight: 600;
  letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-dim);
}

.btn-add {
  display: flex; align-items: center; gap: 6px;
  padding: 8px 16px;
  background: var(--blue); border: none;
  border-radius: var(--radius-xs); color: white;
  font-family: 'Inter', sans-serif; font-size: 13px; font-weight: 500;
  cursor: pointer; transition: all 0.2s;
  box-shadow: 0 2px 8px rgba(37,99,235,0.25);
}

.btn-add:hover { background: var(--blue-dark); }

.btn-add svg {
  width: 14px; height: 14px; stroke: currentColor;
  fill: none; stroke-width: 2.5; stroke-linecap: round;
}

.users-table {
  background: var(--white); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.table-row {
  display: grid;
  grid-template-columns: 1fr 160px 80px 120px 60px;
  align-items: center;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border-light);
  transition: background 0.1s;
}

.table-row:last-child { border-bottom: none; }

.table-header { background: var(--surface2); }

.table-header span {
  font-size: 11px; font-weight: 600;
  letter-spacing: 0.07em; text-transform: uppercase; color: var(--text-muted);
}

.table-row:not(.table-header):hover { background: var(--blue-light); cursor: pointer; }

.user-name { font-size: 14px; color: var(--text); font-weight: 500; }
.user-email { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.user-date { font-size: 13px; color: var(--text-dim); }
.user-sessions { font-size: 13px; color: var(--text-dim); text-align: center; font-weight: 500; }

.badge {
  display: inline-flex; align-items: center;
  padding: 3px 10px; border-radius: 20px;
  font-size: 11px; font-weight: 600; letter-spacing: 0.03em;
}

.badge-active   { background: #D1FAE5; color: #065F46; }
.badge-inactive { background: #FEE2E2; color: #991B1B; }
.badge-progress { background: var(--blue-mid); color: var(--blue-dark); }
.badge-onboarding { background: var(--surface2); color: var(--text-muted); border: 1px solid var(--border); }

.row-actions { display: flex; justify-content: flex-end; }

.btn-icon {
  width: 30px; height: 30px; border-radius: 8px;
  background: none; border: 1.5px solid transparent;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  transition: all 0.15s; color: var(--text-muted);
}

.btn-icon:hover { border-color: var(--border); color: var(--blue); background: var(--blue-light); }
.btn-icon svg { width: 14px; height: 14px; stroke: currentColor; fill: none; stroke-width: 1.8; }

/* Detail panel */
.detail-panel {
  background: var(--white); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 28px;
  box-shadow: var(--shadow-sm); margin-top: 20px;
}

.detail-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  margin-bottom: 24px; padding-bottom: 20px;
  border-bottom: 1px solid var(--border-light);
}

.detail-name {
  font-family: 'Cormorant Garamond', serif;
  font-size: 24px; font-weight: 400; color: var(--text);
}

.detail-email { font-size: 13px; color: var(--text-muted); margin-top: 4px; }

.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-bottom: 20px; }

.detail-field label {
  font-size: 11px; font-weight: 600; letter-spacing: 0.07em;
  text-transform: uppercase; color: var(--text-muted); display: block; margin-bottom: 6px;
}

.detail-field p { font-size: 14px; color: var(--text); line-height: 1.6; }
.detail-field p.empty { color: var(--text-muted); font-style: italic; }

.sessions-list { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }

.session-item {
  padding: 10px 14px;
  background: var(--surface2); border: 1px solid var(--border-light);
  border-radius: var(--radius-xs);
  font-size: 13px; color: var(--text-dim); line-height: 1.6;
}

/* Form Modal */
.form-modal {
  position: fixed; inset: 0;
  background: rgba(15,23,42,0.4); backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
  z-index: 100;
}

.form-modal-box {
  background: var(--white); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 36px;
  width: 440px; max-width: 90vw;
  box-shadow: var(--shadow-lg);
}

.form-modal-box h3 {
  font-family: 'Cormorant Garamond', serif;
  font-size: 24px; font-weight: 400; color: var(--text); margin-bottom: 24px;
}

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

.btn-secondary {
  flex: 1; padding: 12px; background: var(--surface2);
  border: 1.5px solid var(--border); border-radius: var(--radius-xs);
  color: var(--text-dim); font-family: 'Inter', sans-serif; font-size: 14px; font-weight: 500;
  cursor: pointer; transition: all 0.2s;
}

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

.alert {
  padding: 10px 14px; border-radius: var(--radius-xs);
  font-size: 13px; margin-top: 14px; font-weight: 500;
}

.alert-success { background: #D1FAE5; border: 1px solid #A7F3D0; color: #065F46; }
.alert-error   { background: #FEE2E2; border: 1px solid #FECACA; color: #991B1B; }

.patterns-list { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }

.pattern-tag {
  padding: 4px 12px; background: var(--blue-light);
  border: 1px solid var(--blue-mid); border-radius: 20px;
  font-size: 12px; color: var(--blue-dark); font-weight: 500;
}
