/* ============================================
   ADMIN CSS — Shared Admin Panel Styles
   ============================================ */

@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700;800&display=swap');

:root {
  --primary: #0084ff;
  --primary-dark: #006fd6;
  --primary-light: #e8f4ff;
  --accent: #6366f1;
  --success: #10b981;
  --danger: #ef4444;
  --warning: #f59e0b;
  --bg: #f5f7fb;
  --sidebar-bg: #0f172a;
  --sidebar-text: #94a3b8;
  --sidebar-active: #ffffff;
  --white: #ffffff;
  --text: #1a1d23;
  --text-muted: #6b7280;
  --border: #e5e8ef;
  --card-shadow: 0 2px 16px rgba(0,0,0,0.07);
  --radius: 14px;
  --radius-sm: 8px;
  --font: 'Plus Jakarta Sans', sans-serif;
  --sidebar-w: 240px;
  --topbar-h: 64px;
}

/* Reset */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
button { cursor: pointer; font-family: var(--font); }
input, textarea, select { font-family: var(--font); }

/* ============================================================
   AUTH PAGES (login / signup)
============================================================ */
.auth-page {
  min-height: 100vh;
  background: linear-gradient(135deg, #ECF7F9 0%, #F5FBF9 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  position: relative;
  overflow: hidden;
}
.auth-page::before {
  content: '';
  position: absolute;
  width: 600px; height: 600px;
  background: radial-gradient(circle, rgba(0,132,255,0.15) 0%, transparent 70%);
  top: -100px; right: -100px;
  pointer-events: none;
}
.auth-page::after {
  content: '';
  position: absolute;
  width: 400px; height: 400px;
  background: radial-gradient(circle, rgba(99,102,241,0.12) 0%, transparent 70%);
  bottom: -80px; left: -80px;
  pointer-events: none;
}
.auth-card {
  background: var(--white);
  border-radius: 20px;
  padding: 40px;
  width: 100%;
  max-width: 440px;
  box-shadow: 0 24px 60px rgba(0,0,0,0.25);
  position: relative;
  z-index: 1;
  animation: authIn 0.4s ease;
}
@keyframes authIn {
  from { opacity: 0; transform: translateY(24px); }
  to   { opacity: 1; transform: translateY(0); }
}
.auth-logo {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 28px;
}
.auth-logo-icon img{ width: 100%; }
.auth-logo-icon {
  width: 44px; height: 44px;
  background: linear-gradient(135deg, #ECF7F9 0%, #F5FBF9 100%);
  border-radius: 50px;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px;
}
.auth-logo-text { font-size: 18px; font-weight: 800; color: var(--text); }
.auth-logo-text span { color: var(--primary); }
.auth-title { font-size: 22px; font-weight: 800; margin-bottom: 4px; }
.auth-subtitle { color: var(--text-muted); font-size: 14px; margin-bottom: 28px; }

.form-group { margin-bottom: 18px; }
.form-label {
  display: block;
  font-size: 13px; font-weight: 600;
  color: var(--text); margin-bottom: 6px;
}
.form-control {
  width: 100%;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 11px 14px;
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.form-control:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(0,132,255,0.1);
  background: #fff;
}
.form-control.error { border-color: var(--danger); }
.form-error { color: var(--danger); font-size: 12px; margin-top: 4px; display: none; }
.form-error.show { display: block; }

.input-group { position: relative; }
.input-group .form-control { padding-right: 44px; }
.input-toggle {
  position: absolute; right: 12px; top: 50%;
  transform: translateY(-50%);
  background: none; border: none; color: var(--text-muted);
  font-size: 16px; cursor: pointer;
}

.btn-primary {
  width: 100%;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  color: #fff; border: none;
  border-radius: var(--radius-sm);
  padding: 13px;
  font-size: 15px; font-weight: 700;
  transition: opacity 0.2s, transform 0.15s;
  margin-top: 8px;
}
.btn-primary:hover { opacity: 0.92; transform: translateY(-1px); }
.btn-primary:active { transform: translateY(0); }
.btn-primary:disabled { opacity: 0.6; cursor: not-allowed; transform: none; }

.auth-footer { text-align: center; margin-top: 22px; font-size: 14px; color: var(--text-muted); }
.auth-footer a { font-weight: 600; }

.alert {
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  margin-bottom: 16px;
  font-size: 14px;
  display: none;
}
.alert.show { display: block; }
.alert-danger { background: #fef2f2; color: #dc2626; border: 1px solid #fecaca; }
.alert-success { background: #f0fdf4; color: #15803d; border: 1px solid #bbf7d0; }

/* ============================================================
   ADMIN LAYOUT
============================================================ */
.admin-layout {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* ---- Sidebar ---- */
.sidebar {
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  transition: transform 0.3s;
  z-index: 200;
  overflow-y: auto;
}
.sidebar-logo {
  padding: 20px 20px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  display: flex; align-items: center; gap: 10px;
}
.sidebar-logo-icon {
  width: 36px; height: 36px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px;
}
.sidebar-logo-text { font-size: 15px; font-weight: 800; color: #fff; }
.sidebar-logo-text span { color: var(--primary); }

.sidebar-nav { padding: 16px 12px; flex: 1; }
.nav-section-label {
  font-size: 10.5px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 1px;
  color: #475569; padding: 0 8px; margin: 16px 0 6px;
}
.nav-item {
  display: flex; align-items: center; gap: 11px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: var(--sidebar-text);
  font-size: 14px; font-weight: 500;
  text-decoration: none;
  transition: background 0.18s, color 0.18s;
  margin-bottom: 2px;
  cursor: pointer;
  border: none; background: transparent; width: 100%;
  text-align: left;
}
.nav-item:hover { background: rgba(255,255,255,0.06); color: #e2e8f0; text-decoration: none; }
.nav-item.active { background: rgba(0,132,255,0.18); color: var(--primary); font-weight: 600; }
.nav-item .nav-icon { font-size: 17px; flex-shrink: 0; }
.nav-badge {
  margin-left: auto;
  background: var(--danger);
  color: #fff; font-size: 11px; font-weight: 700;
  padding: 1px 7px; border-radius: 50px;
}
.sidebar-footer {
  padding: 16px 12px;
  border-top: 1px solid rgba(255,255,255,0.06);
}

/* ---- Main ---- */
.admin-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ---- Topbar ---- */
.topbar {
  height: var(--topbar-h);
  background: var(--white);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 28px;
  flex-shrink: 0;
  gap: 16px;
}
.topbar-left { display: flex; align-items: center; gap: 16px; }
.topbar-title { font-size: 17px; font-weight: 700; }
.topbar-right { display: flex; align-items: center; gap: 14px; }

.search-box {
  display: flex; align-items: center;
  background: var(--bg);
  border: 1.5px solid var(--border);
  border-radius: 50px;
  padding: 7px 14px;
  gap: 8px;
}
.search-box input {
  border: none; background: transparent;
  outline: none; font-size: 14px; width: 220px;
  color: var(--text);
}
.search-icon { color: var(--text-muted); font-size: 15px; }

.topbar-avatar {
  width: 36px; height: 36px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 700; font-size: 14px;
  cursor: pointer;
}

/* ---- Content ---- */
.admin-content {
  flex: 1;
  overflow-y: auto;
  padding: 28px;
}
.admin-content::-webkit-scrollbar { width: 5px; }
.admin-content::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

/* ---- Cards ---- */
.card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--card-shadow);
  border: 1px solid var(--border);
}
.card-header {
  padding: 18px 22px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.card-title { font-size: 15px; font-weight: 700; }
.card-body { padding: 22px; }

/* ---- Stat Cards ---- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 18px;
  margin-bottom: 28px;
}
.stat-card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 20px;
  border: 1px solid var(--border);
  box-shadow: var(--card-shadow);
  display: flex; align-items: center; gap: 16px;
}
.stat-icon {
  width: 48px; height: 48px;
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px; flex-shrink: 0;
}
.stat-icon.blue  { background: #e8f4ff; }
.stat-icon.green { background: #ecfdf5; }
.stat-icon.purple{ background: #ede9fe; }
.stat-icon.orange{ background: #fff7ed; }
.stat-value { font-size: 24px; font-weight: 800; line-height: 1; }
.stat-label { font-size: 12.5px; color: var(--text-muted); margin-top: 3px; }

/* ---- Table ---- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th {
  text-align: left; padding: 11px 16px;
  font-size: 12px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.5px; color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  background: var(--bg);
}
td {
  padding: 13px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}
tr:last-child td { border-bottom: none; }
tr.clickable:hover td { background: #f9fafb; cursor: pointer; }

.badge {
  display: inline-flex; align-items: center;
  padding: 3px 10px; border-radius: 50px;
  font-size: 12px; font-weight: 600;
}
.badge-blue   { background: #e8f4ff; color: var(--primary); }
.badge-green  { background: #ecfdf5; color: var(--success); }
.badge-gray   { background: #f3f4f6; color: #4b5563; }

.btn {
  border: none; border-radius: var(--radius-sm);
  padding: 8px 16px; font-size: 13px; font-weight: 600;
  transition: opacity 0.2s, transform 0.15s;
}
.btn:hover { opacity: 0.88; transform: translateY(-1px); }
.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-blue  { background: var(--primary-light); color: var(--primary); }
.btn-solid { background: var(--primary); color: #fff; }
.btn-danger{ background: #fef2f2; color: var(--danger); }

/* ---- Chat Viewer ---- */
.sessions-layout {
  display: grid;
  grid-template-columns: 340px 1fr;
  gap: 20px;
  height: calc(100vh - var(--topbar-h) - 56px);
}
.session-list { overflow-y: auto; }
.session-item {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.15s;
}
.session-item:hover, .session-item.active { background: var(--primary-light); }
.session-item.active { border-left: 3px solid var(--primary); }
.session-id { font-weight: 700; font-size: 13px; margin-bottom: 3px; }
.session-preview { font-size: 13px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.session-time { font-size: 11.5px; color: var(--text-muted); float: right; }

.conv-viewer {
  display: flex; flex-direction: column;
  border-left: 1px solid var(--border);
}
.conv-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  font-weight: 700; font-size: 14px;
  background: var(--white);
  display: flex; align-items: center; justify-content: space-between;
}
.conv-messages {
  flex: 1; overflow-y: auto;
  padding: 20px;
  display: flex; flex-direction: column; gap: 10px;
  background: var(--bg);
}
.conv-msg { display: flex; flex-direction: column; max-width: 70%; }
.conv-msg.user { align-self: flex-end; align-items: flex-end; }
.conv-msg.bot  { align-self: flex-start; align-items: flex-start; }
.conv-bubble {
  padding: 10px 14px; border-radius: 14px;
  font-size: 13.5px; line-height: 1.5;
}
.conv-msg.user .conv-bubble { background: var(--primary); color: #fff; border-bottom-right-radius: 4px; }
.conv-msg.bot  .conv-bubble { background: var(--white); color: var(--text); border-bottom-left-radius: 4px; box-shadow: var(--card-shadow); }
.conv-time { font-size: 11px; color: var(--text-muted); margin-top: 3px; }
.conv-empty {
  flex: 1; display: flex; align-items: center; justify-content: center;
  flex-direction: column; gap: 10px; color: var(--text-muted);
}
.conv-empty-icon { font-size: 40px; }

/* ---- Settings ---- */
.settings-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}
@media (max-width: 900px) { .settings-grid { grid-template-columns: 1fr; } }

.faq-entry {
  background: var(--bg); border-radius: var(--radius-sm);
  padding: 14px; margin-bottom: 10px;
  border: 1px solid var(--border);
  display: grid; gap: 8px;
}
.faq-entry .remove-faq {
  background: none; border: none;
  color: var(--danger); font-size: 13px; cursor: pointer;
  align-self: start; justify-self: end;
}

/* Toggle Switch */
.toggle-wrap { display: flex; align-items: center; gap: 12px; }
.toggle {
  position: relative; width: 44px; height: 24px; flex-shrink: 0;
}
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
  position: absolute; inset: 0;
  background: #d1d5db; border-radius: 50px;
  cursor: pointer; transition: background 0.2s;
}
.toggle-slider::before {
  content: '';
  position: absolute;
  width: 18px; height: 18px; border-radius: 50%;
  background: #fff;
  top: 3px; left: 3px;
  transition: transform 0.2s;
  box-shadow: 0 1px 4px rgba(0,0,0,0.2);
}
.toggle input:checked + .toggle-slider { background: var(--primary); }
.toggle input:checked + .toggle-slider::before { transform: translateX(20px); }

/* ---- Responsive ---- */
.hamburger {
  display: none; background: none; border: none;
  font-size: 22px; cursor: pointer; color: var(--text);
}
.sidebar-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,0.4); z-index: 199;
}

@media (max-width: 768px) {
  .sidebar {
    position: fixed; top: 0; left: 0; bottom: 0;
    transform: translateX(-100%);
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-overlay.show { display: block; }
  .hamburger { display: block; }
  .admin-content { padding: 16px; }
  .sessions-layout { grid-template-columns: 1fr; }
  .conv-viewer { display: none; }
  .conv-viewer.show { display: flex; position: fixed; inset: 0; z-index: 300; background: var(--white); }
  .search-box input { width: 140px; }
}
