/* ── Variables ── */
:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-light: #dbeafe;
  --brand-green: #10b981;
  --brand-green-dark: #059669;
  --success: #16a34a;
  --danger: #dc2626;
  --warning: #d97706;
  --gray-50: #f8fafc;
  --gray-100: #f1f5f9;
  --gray-200: #e2e8f0;
  --gray-300: #cbd5e1;
  --gray-500: #64748b;
  --gray-700: #334155;
  --gray-900: #0f172a;
  --sidebar-w: 224px;
}

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 14px; }
body { font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
       color: var(--gray-900); background: var(--gray-100); line-height: 1.5; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
button { font-family: inherit; }
code, pre { font-family: 'SF Mono', 'Fira Code', ui-monospace, monospace; }

/* ── Admin Layout ── */
.layout { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  background: #0f172a;
  color: #cbd5e1;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  z-index: 100;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 18px;
  font-size: 20px;
  font-weight: 800;
  color: #f1f5f9;
  letter-spacing: -.02em;
}
.sidebar-brand span { color: #3b82f6; }
.sidebar-brand:hover { text-decoration: none; }

.sidebar-nav {
  flex: 1;
  padding: 4px 10px 16px;
}
.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: 6px;
  color: #94a3b8;
  font-size: 14px;
  margin-bottom: 2px;
  transition: background .1s, color .1s;
}
.sidebar-nav a:hover { background: rgba(255,255,255,.06); color: #e2e8f0; text-decoration: none; }
.sidebar-nav a.active { background: rgba(59,130,246,.15); color: #93c5fd; }
.sidebar-nav a.active svg { stroke: #60a5fa; }
.sidebar-nav a svg { flex-shrink: 0; opacity: .7; }
.sidebar-nav a.active svg { opacity: 1; }

.sidebar-footer {
  padding: 14px 18px;
  border-top: 1px solid rgba(255,255,255,.07);
  font-size: 12px;
}
.sidebar-user { color: #94a3b8; word-break: break-all; margin-bottom: 2px; }
.sidebar-role { color: #60a5fa; font-size: 11px; margin-bottom: 6px; }
.btn-link-muted { background: none; border: none; color: #64748b; cursor: pointer;
                   font-size: 13px; padding: 0; }
.btn-link-muted:hover { color: #94a3b8; }

.content { margin-left: var(--sidebar-w); flex: 1; }
.page { padding: 28px 32px; max-width: 1200px; }

/* ── Page Headers ── */
.page-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  margin-bottom: 24px; gap: 16px; flex-wrap: wrap;
}
.page-title { font-size: 22px; font-weight: 700; color: var(--gray-900); }
.text-muted { color: var(--gray-500); }
.text-sm { font-size: 12px; }
.font-mono { font-family: 'SF Mono', ui-monospace, monospace; }

/* ── Cards ── */
.card { background: white; border: 1px solid var(--gray-200); border-radius: 10px; overflow: hidden; }
.card-body { padding: 20px; }
.card-header {
  padding: 14px 20px;
  border-bottom: 1px solid var(--gray-100);
  font-weight: 600;
  font-size: 14px;
  color: var(--gray-700);
}

/* ── Stats ── */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 14px; margin-bottom: 24px; }
.stat-card { background: white; border: 1px solid var(--gray-200); border-radius: 10px; padding: 18px 20px; }
.stat-value { font-size: 30px; font-weight: 700; color: var(--primary); line-height: 1.1; }
.stat-label { color: var(--gray-500); font-size: 12px; margin-top: 5px; font-weight: 500; }
.text-warning { color: var(--warning) !important; }

.stat-mini { text-align: center; }
.stat-mini-val { font-size: 20px; font-weight: 700; color: var(--primary); }
.stat-mini-lbl { font-size: 11px; color: var(--gray-500); margin-top: 2px; }

/* ── Tables ── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th {
  background: var(--gray-50); padding: 10px 16px;
  text-align: left; font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .06em;
  color: var(--gray-500); border-bottom: 1px solid var(--gray-200);
  white-space: nowrap;
}
td { padding: 11px 16px; border-bottom: 1px solid var(--gray-100); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: #fafbfc; }
tfoot td { background: var(--gray-50); border-top: 2px solid var(--gray-200); }

/* ── Badges ── */
.badge {
  display: inline-block; padding: 2px 9px; border-radius: 999px;
  font-size: 11px; font-weight: 600; letter-spacing: .02em;
}
.badge-success { background: #dcfce7; color: #15803d; }
.badge-warning { background: #fef9c3; color: #a16207; }
.badge-danger  { background: #fee2e2; color: #b91c1c; }
.badge-info    { background: #dbeafe; color: #1d4ed8; }
.badge-gray    { background: var(--gray-100); color: var(--gray-500); }

/* ── Buttons ── */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 8px 16px; border-radius: 7px; font-size: 14px; font-weight: 500;
  border: 1px solid transparent; cursor: pointer; gap: 6px;
  transition: background .12s, opacity .12s, box-shadow .12s;
  white-space: nowrap; text-decoration: none !important;
}
.btn:hover { opacity: .9; text-decoration: none !important; }
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-dark); opacity: 1; }
.btn-secondary { background: white; color: var(--gray-700); border-color: var(--gray-200); }
.btn-secondary:hover { background: var(--gray-50); opacity: 1; }
.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { background: #b91c1c; opacity: 1; }
.btn-success { background: var(--success); color: white; }
.btn-success:hover { background: #15803d; opacity: 1; }
.btn-sm { padding: 5px 11px; font-size: 12px; border-radius: 5px; }
.btn-link { background: none; border: none; color: var(--primary); cursor: pointer;
             font-size: inherit; padding: 0; }
.btn-link:hover { text-decoration: underline; }
.btn-white { background: white; color: var(--primary); font-weight: 600; }
.btn-white:hover { background: var(--gray-50); }
.btn-primary-outline { background: transparent; color: white; border: 2px solid rgba(255,255,255,.5); }
.btn-primary-outline:hover { background: rgba(255,255,255,.1); opacity: 1; }
.btn-outline-white { background: transparent; color: white; border: 1px solid rgba(255,255,255,.4); }
.btn-outline-white:hover { background: rgba(255,255,255,.1); opacity: 1; }
.w-full { width: 100%; }

/* ── Forms ── */
.form-group { margin-bottom: 16px; }
.form-row { display: flex; gap: 16px; flex-wrap: wrap; }
label {
  display: block; font-size: 13px; font-weight: 500;
  color: var(--gray-700); margin-bottom: 5px;
}
input[type=text], input[type=email], input[type=password],
input[type=number], input[type=tel], select, textarea {
  width: 100%; padding: 8px 12px; border: 1px solid var(--gray-200);
  border-radius: 7px; font-size: 14px; color: var(--gray-900);
  background: white; outline: none; font-family: inherit;
  transition: border-color .12s, box-shadow .12s;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,.1);
}
input[readonly] { background: var(--gray-50); color: var(--gray-500); cursor: not-allowed; }
textarea { min-height: 80px; resize: vertical; line-height: 1.5; }

/* ── Flash ── */
.flash {
  padding: 11px 16px; border-radius: 7px; margin-bottom: 16px;
  font-size: 14px; border: 1px solid;
}
.flash-success { background: #dcfce7; color: #15803d; border-color: #bbf7d0; }
.flash-error   { background: #fee2e2; color: #b91c1c; border-color: #fecaca; }
.flash-info    { background: #dbeafe; color: #1d4ed8; border-color: #bfdbfe; }
.flash-warning { background: #fef9c3; color: #a16207; border-color: #fde68a; }

/* ── Tabs ── */
.tab-bar { display: flex; gap: 0; border-bottom: 2px solid var(--gray-200); }
.tab-link {
  padding: 10px 18px; font-size: 14px; font-weight: 500;
  color: var(--gray-500); border-bottom: 2px solid transparent;
  margin-bottom: -2px; text-decoration: none !important;
  transition: color .12s, border-color .12s;
}
.tab-link:hover { color: var(--gray-700); }
.tab-link.active { color: var(--primary); border-bottom-color: var(--primary); }

/* ── Pagination ── */
.pagination { display: flex; gap: 6px; align-items: center; justify-content: flex-end; padding: 16px 0 0; }
.page-link {
  padding: 6px 12px; border: 1px solid var(--gray-200); border-radius: 6px;
  color: var(--gray-700); font-size: 13px;
}
.page-link:hover { background: var(--gray-50); text-decoration: none; }
.page-link.active { background: var(--primary); color: white; border-color: var(--primary); }

/* ── Empty State ── */
.empty-state { text-align: center; padding: 48px 24px; }
.empty-state h3 { font-size: 16px; font-weight: 600; color: var(--gray-700); margin-bottom: 8px; }
.empty-state p { color: var(--gray-500); }

/* ── Detail rows ── */
.detail-row { display: flex; justify-content: space-between; align-items: center;
               padding: 8px 0; border-bottom: 1px solid var(--gray-100); }
.detail-row:last-child { border-bottom: none; }
.detail-label { font-size: 12px; font-weight: 500; color: var(--gray-500); text-transform: uppercase;
                 letter-spacing: .05em; }

/* ── Login ── */
.login-page {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #f0f4ff 0%, #e8f0fe 100%);
}
.login-card {
  background: white; border-radius: 14px; padding: 40px;
  width: 100%; max-width: 400px;
  box-shadow: 0 4px 24px rgba(0,0,0,.08), 0 1px 3px rgba(0,0,0,.05);
}
.login-logo { text-align: center; margin-bottom: 28px; }

/* ── Landing ── */
.landing-page { background: #0f172a; color: white; min-height: 100vh; }
.landing-nav {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 40px; background: rgba(0,0,0,.3);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  position: sticky; top: 0; z-index: 50;
  border-bottom: 1px solid rgba(255,255,255,.05);
}
.landing-nav-brand { font-size: 20px; font-weight: 800; color: #f1f5f9; display:flex; align-items:center; gap:10px; }
.landing-nav-brand span { color: #60a5fa; }
.landing-hero {
  min-height: 60vh; display: flex; align-items: center; justify-content: center;
  text-align: center; padding: 72px 20px 56px;
  background: linear-gradient(160deg, #0f172a 0%, #0d2657 50%, #0f1f3d 100%);
  position: relative; overflow: hidden;
}
.landing-hero::before {
  content: '';
  position: absolute; inset: 0;
  background: radial-gradient(ellipse 70% 60% at 50% 40%, rgba(37,99,235,.18) 0%, transparent 70%);
  pointer-events: none;
}
.landing-content { max-width: 640px; }
.landing-badge {
  display: inline-block; background: rgba(59,130,246,.2); border: 1px solid rgba(59,130,246,.4);
  border-radius: 999px; padding: 4px 14px; font-size: 12px; color: #93c5fd;
  margin-bottom: 20px; letter-spacing: .04em;
}
.landing-title { font-size: 52px; font-weight: 800; letter-spacing: -.03em; margin-bottom: 16px; }
.landing-title span { color: #60a5fa; }
.landing-tagline { font-size: 18px; color: #94a3b8; line-height: 1.7; margin-bottom: 36px; }
.landing-actions { display: flex; gap: 14px; justify-content: center; flex-wrap: wrap; }

.landing-features {
  padding: 60px 40px;
  background: #111827;
}
.features-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 24px; max-width: 1000px; margin: 0 auto; }
.feature-card {
  background: rgba(255,255,255,.04); border: 1px solid rgba(255,255,255,.08);
  border-radius: 12px; padding: 24px;
}
.feature-icon { font-size: 28px; margin-bottom: 14px; display:flex; }
.feature-card h3 { font-size: 16px; font-weight: 600; margin-bottom: 8px; }
.feature-card p { font-size: 13px; color: #94a3b8; line-height: 1.6; }

.landing-demo {
  padding: 60px 40px; text-align: center;
  background: #1e293b;
}
.landing-demo h2 { font-size: 28px; font-weight: 700; margin-bottom: 8px; }
.landing-demo p { color: #94a3b8; margin-bottom: 28px; }
.demo-cards { display: flex; gap: 16px; justify-content: center; flex-wrap: wrap; }
.demo-card {
  background: rgba(255,255,255,.05); border: 1px solid rgba(255,255,255,.1);
  border-radius: 12px; padding: 20px 28px; min-width: 200px;
  display: flex; flex-direction: column; gap: 6px;
  text-decoration: none !important; transition: background .15s;
}
.demo-card:hover { background: rgba(255,255,255,.1); }
.demo-card strong { color: white; font-size: 15px; }
.demo-card span { color: #94a3b8; font-size: 12px; }

.landing-footer {
  padding: 24px 40px; background: #0a0f1e; border-top: 1px solid rgba(255,255,255,.06);
  display: flex; gap: 24px; align-items: center; color: #64748b; font-size: 13px;
  flex-wrap: wrap;
}
.landing-footer a { color: #64748b; }
.landing-footer a:hover { color: #94a3b8; }

/* ── Landing — stats bar ── */
.landing-stats {
  display: flex; align-items: center; justify-content: center;
  flex-wrap: wrap; gap: 0;
  background: rgba(255,255,255,.04); border-top: 1px solid rgba(255,255,255,.06);
  border-bottom: 1px solid rgba(255,255,255,.06);
  padding: 20px 40px;
}
.landing-stat { text-align: center; padding: 8px 32px; }
.landing-stat-val { display: block; font-size: 22px; font-weight: 800; color: #60a5fa; line-height: 1.2; }
.landing-stat-lbl { display: block; font-size: 12px; color: #64748b; margin-top: 3px; }
.landing-stat-divider { width: 1px; height: 36px; background: rgba(255,255,255,.08); }

/* ── Landing — how it works ── */
.landing-how {
  padding: 60px 40px; background: #111827; color: white;
}
.how-steps {
  display: flex; align-items: flex-start; justify-content: center;
  gap: 20px; flex-wrap: wrap; max-width: 860px; margin: 0 auto;
}
.how-step {
  flex: 1; min-width: 200px; max-width: 240px; text-align: center;
}
.how-step-num {
  width: 40px; height: 40px; border-radius: 50%;
  background: var(--primary); color: white;
  font-size: 18px; font-weight: 800; line-height: 40px;
  margin: 0 auto 14px;
}
.how-step h4 { font-size: 15px; font-weight: 600; margin-bottom: 8px; }
.how-step p { font-size: 13px; color: #94a3b8; line-height: 1.6; }
.how-step em { color: #60a5fa; font-style: normal; }
.how-arrow {
  font-size: 24px; color: #334155; padding-top: 48px; flex-shrink: 0;
}
@media (max-width: 640px) {
  .how-arrow { display: none; }
}

/* ── Chat ── */
.chat-outer {
  display: flex; height: 100vh; max-width: 960px;
  margin: 0 auto; box-shadow: 0 0 40px rgba(0,0,0,.15);
}
.chat-sidebar-panel {
  width: 280px; background: white; border-right: 1px solid var(--gray-200);
  overflow-y: auto; flex-shrink: 0;
}
.chat-cmd-list { display: flex; flex-direction: column; gap: 8px; }
.chat-cmd {
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
}
.chat-cmd code {
  background: var(--gray-100); padding: 2px 7px; border-radius: 4px;
  font-size: 12px; color: var(--primary); white-space: nowrap;
}
.chat-cmd span { font-size: 12px; color: var(--gray-500); }

.chat-window { flex: 1; display: flex; flex-direction: column; background: #e5ddd5; }

.chat-header-bar {
  background: #075e54; color: white; padding: 14px 18px;
  display: flex; align-items: center; gap: 12px; flex-shrink: 0;
}
.chat-avatar {
  width: 38px; height: 38px; border-radius: 50%; background: #25d366;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 13px; flex-shrink: 0;
}

.chat-messages {
  flex: 1; overflow-y: auto; padding: 16px; display: flex;
  flex-direction: column; gap: 10px;
}

.chat-msg { max-width: 75%; }
.chat-msg-user { align-self: flex-end; }
.chat-msg-bot  { align-self: flex-start; }

.chat-bubble {
  padding: 10px 14px; border-radius: 10px;
  font-size: 14px; line-height: 1.55; white-space: pre-wrap;
}
.chat-msg-user .chat-bubble { background: #dcf8c6; border-radius: 10px 2px 10px 10px; }
.chat-msg-bot  .chat-bubble { background: white; border-radius: 2px 10px 10px 10px;
                                box-shadow: 0 1px 2px rgba(0,0,0,.1); }
.chat-time { font-size: 11px; color: var(--gray-500); margin-top: 4px; text-align: right; }
.chat-msg-bot .chat-time { text-align: left; }

.chat-input-row {
  display: flex; gap: 8px; padding: 10px 14px;
  background: #f0f2f5; flex-shrink: 0;
}
.chat-input {
  flex: 1; padding: 10px 14px; border-radius: 24px;
  border: none; font-size: 14px; background: white;
  outline: none; font-family: inherit;
}
.chat-send {
  background: #25d366; color: white; border: none; border-radius: 50%;
  width: 42px; height: 42px; cursor: pointer;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
  transition: background .12s;
}
.chat-send:hover { background: #1ebe5d; }

/* ── Register page uses login-page style ── */

/* ── Responsive ── */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .content { margin-left: 0; }
  .page { padding: 16px; }
  .chat-outer { flex-direction: column; height: auto; }
  .chat-sidebar-panel { width: 100%; border-right: none; border-bottom: 1px solid var(--gray-200); max-height: 220px; }
  .chat-window { height: 70vh; }
  .landing-title { font-size: 36px; }
  .landing-nav { padding: 14px 20px; }
  .landing-features { padding: 40px 20px; }
  .landing-demo { padding: 40px 20px; }
  .landing-footer { padding: 20px; }
}
