/* ============================================================
   SistemBenim ChatBot — Admin Panel Stilleri
   Sky / Emerald / Indigo + Dark Mode
   ============================================================ */

:root {
  /* Renk paleti */
  --sb-primary: #0EA5E9;
  --sb-primary-dark: #0284C7;
  --sb-primary-light: #38BDF8;
  --sb-success: #10B981;
  --sb-success-dark: #059669;
  --sb-accent: #6366F1;
  --sb-accent-dark: #4F46E5;
  --sb-warning: #F59E0B;
  --sb-danger: #EF4444;
  --sb-danger-dark: #DC2626;

  /* Light tema yüzeyleri */
  --bg: #F1F5F9;
  --surface: #FFFFFF;
  --surface-2: #F8FAFC;
  --border: #E2E8F0;
  --text: #0F172A;
  --text-muted: #64748B;
  --text-soft: #94A3B8;
  --sidebar-bg: #0F172A;
  --sidebar-text: #CBD5E1;
  --sidebar-active: #0EA5E9;
  --shadow: 0 1px 3px rgba(15, 23, 42, 0.08), 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-lg: 0 10px 25px rgba(15, 23, 42, 0.10);

  --radius: 12px;
  --radius-sm: 8px;
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --mono: 'JetBrains Mono', 'SF Mono', Consolas, monospace;
  --sidebar-w: 248px;
}

[data-theme="dark"] {
  --bg: #0B1120;
  --surface: #131C2E;
  --surface-2: #1A2438;
  --border: #283449;
  --text: #E2E8F0;
  --text-muted: #94A3B8;
  --text-soft: #64748B;
  --sidebar-bg: #080D17;
  --sidebar-text: #94A3B8;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.5);
}

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

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--sb-primary); text-decoration: none; }
a:hover { color: var(--sb-primary-dark); }

code, .mono { font-family: var(--mono); font-size: 0.9em; }

/* ============================================================
   LAYOUT
   ============================================================ */
.layout { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  position: fixed;
  top: 0; left: 0; bottom: 0;
  display: flex;
  flex-direction: column;
  z-index: 100;
  transition: transform 0.25s ease;
  overflow-y: auto;
}

.sidebar-brand {
  padding: 22px 20px 18px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}
.sidebar-brand .logo { width: 36px; height: 36px; flex-shrink: 0; }
.sidebar-brand .brand-text { display: flex; flex-direction: column; }
.sidebar-brand .brand-name {
  font-weight: 600; font-size: 15px; color: #fff; letter-spacing: -0.01em;
}
.sidebar-brand .brand-sub { font-size: 11px; color: #64748B; }

.sidebar-nav { flex: 1; padding: 14px 12px; }
.nav-section-label {
  font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.06em;
  color: #475569; padding: 14px 12px 6px; font-weight: 600;
}
.nav-item {
  display: flex; align-items: center; gap: 11px;
  padding: 9px 12px; border-radius: var(--radius-sm);
  color: var(--sidebar-text); font-weight: 500; font-size: 13.5px;
  margin-bottom: 2px; transition: background 0.15s, color 0.15s;
}
.nav-item:hover { background: rgba(255,255,255,0.05); color: #fff; }
.nav-item.active {
  background: linear-gradient(135deg, var(--sb-primary), var(--sb-accent));
  color: #fff;
  box-shadow: 0 2px 8px rgba(14,165,233,0.35);
}
.nav-item .icon { width: 18px; height: 18px; flex-shrink: 0; }
.nav-item .badge-count {
  margin-left: auto; background: var(--sb-danger); color: #fff;
  font-size: 10px; padding: 1px 7px; border-radius: 10px; font-weight: 600;
}

.sidebar-footer {
  padding: 14px; border-top: 1px solid rgba(255,255,255,0.06);
  font-size: 12px; color: #64748B;
}

/* Main */
.main {
  flex: 1; margin-left: var(--sidebar-w);
  display: flex; flex-direction: column; min-height: 100vh;
}

.topbar {
  height: 60px; background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 16px;
  padding: 0 24px; position: sticky; top: 0; z-index: 50;
}
.topbar h1 { font-size: 18px; font-weight: 600; letter-spacing: -0.01em; }
.topbar .spacer { flex: 1; }
.menu-toggle { display: none; background: none; border: none; cursor: pointer;
  color: var(--text); font-size: 22px; }

.tenant-badge {
  display: flex; align-items: center; gap: 7px;
  background: var(--surface-2); border: 1px solid var(--border);
  padding: 6px 12px; border-radius: 20px; font-size: 12.5px; font-weight: 500;
}
.tenant-badge .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--sb-success); }

.theme-toggle {
  background: var(--surface-2); border: 1px solid var(--border);
  width: 38px; height: 38px; border-radius: 10px; cursor: pointer;
  display: flex; align-items: center; justify-content: center; color: var(--text);
  transition: background 0.15s;
}
.theme-toggle:hover { background: var(--border); }

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

.content { padding: 24px; flex: 1; }

/* ============================================================
   CARDS
   ============================================================ */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
  margin-bottom: 20px;
}
.card-header {
  padding: 16px 20px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 12px;
}
.card-header h2, .card-header h3 { font-size: 15px; font-weight: 600; }
.card-header .spacer { flex: 1; }
.card-body { padding: 20px; }

/* Stat cards */
.stat-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 16px; margin-bottom: 22px;
}
.stat-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow);
  position: relative; overflow: hidden;
}
.stat-card::before {
  content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 4px;
  background: var(--sb-primary);
}
.stat-card.success::before { background: var(--sb-success); }
.stat-card.accent::before { background: var(--sb-accent); }
.stat-card.warning::before { background: var(--sb-warning); }
.stat-card.danger::before { background: var(--sb-danger); }
.stat-label { font-size: 12.5px; color: var(--text-muted); font-weight: 500; }
.stat-value { font-size: 28px; font-weight: 700; margin-top: 4px; letter-spacing: -0.02em; }
.stat-sub { font-size: 12px; color: var(--text-soft); margin-top: 2px; }

/* ============================================================
   TABLES
   ============================================================ */
.table-wrap { overflow-x: auto; }
table.data {
  width: 100%; border-collapse: collapse; font-size: 13.5px;
}
table.data th {
  text-align: left; padding: 11px 16px; font-weight: 600;
  color: var(--text-muted); border-bottom: 2px solid var(--border);
  font-size: 12px; text-transform: uppercase; letter-spacing: 0.03em;
  white-space: nowrap;
}
table.data td {
  padding: 12px 16px; border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
table.data tbody tr:hover { background: var(--surface-2); }
table.data tbody tr:last-child td { border-bottom: none; }

/* ============================================================
   BADGES
   ============================================================ */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 10px; border-radius: 20px; font-size: 11.5px; font-weight: 600;
  white-space: nowrap;
}
.badge-success { background: rgba(16,185,129,0.12); color: var(--sb-success-dark); }
.badge-primary { background: rgba(14,165,233,0.12); color: var(--sb-primary-dark); }
.badge-accent  { background: rgba(99,102,241,0.12); color: var(--sb-accent-dark); }
.badge-warning { background: rgba(245,158,11,0.14); color: #B45309; }
.badge-danger  { background: rgba(239,68,68,0.12); color: var(--sb-danger-dark); }
.badge-muted   { background: var(--surface-2); color: var(--text-muted); border: 1px solid var(--border); }
[data-theme="dark"] .badge-success { color: #34D399; }
[data-theme="dark"] .badge-primary { color: #38BDF8; }
[data-theme="dark"] .badge-accent  { color: #818CF8; }
[data-theme="dark"] .badge-warning { color: #FBBF24; }
[data-theme="dark"] .badge-danger  { color: #F87171; }

.channel-icon {
  display: inline-flex; align-items: center; gap: 5px; font-weight: 500;
}

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 9px 16px; border-radius: var(--radius-sm); border: 1px solid transparent;
  font-family: var(--font); font-size: 13.5px; font-weight: 500; cursor: pointer;
  transition: all 0.15s; text-decoration: none; white-space: nowrap;
}
.btn-primary { background: var(--sb-primary); color: #fff; }
.btn-primary:hover { background: var(--sb-primary-dark); color: #fff; }
.btn-success { background: var(--sb-success); color: #fff; }
.btn-success:hover { background: var(--sb-success-dark); color: #fff; }
.btn-danger { background: var(--sb-danger); color: #fff; }
.btn-danger:hover { background: var(--sb-danger-dark); color: #fff; }
.btn-secondary {
  background: var(--surface); color: var(--text); border-color: var(--border);
}
.btn-secondary:hover { background: var(--surface-2); }
.btn-sm { padding: 6px 11px; font-size: 12.5px; }
.btn-block { width: 100%; justify-content: center; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ============================================================
   FORMS
   ============================================================ */
.form-group { margin-bottom: 16px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
label { display: block; font-size: 13px; font-weight: 500; margin-bottom: 6px; color: var(--text); }
.form-hint { font-size: 12px; color: var(--text-soft); margin-top: 4px; }
input[type="text"], input[type="password"], input[type="email"], input[type="number"],
input[type="datetime-local"], input[type="date"], select, textarea {
  width: 100%; padding: 9px 12px; border: 1px solid var(--border);
  border-radius: var(--radius-sm); background: var(--surface); color: var(--text);
  font-family: var(--font); font-size: 13.5px; transition: border 0.15s, box-shadow 0.15s;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--sb-primary);
  box-shadow: 0 0 0 3px rgba(14,165,233,0.12);
}
textarea { resize: vertical; min-height: 80px; }
.checkbox-row { display: flex; align-items: center; gap: 9px; }
.checkbox-row input[type="checkbox"] { width: 17px; height: 17px; accent-color: var(--sb-primary); }
.checkbox-row label { margin-bottom: 0; }

/* ============================================================
   FLASH
   ============================================================ */
.flash-wrap { margin-bottom: 18px; }
.flash {
  padding: 12px 16px; border-radius: var(--radius-sm); margin-bottom: 10px;
  font-size: 13.5px; display: flex; align-items: center; gap: 10px;
  border-left: 4px solid;
}
.flash-success { background: rgba(16,185,129,0.10); border-color: var(--sb-success); color: var(--sb-success-dark); }
.flash-danger  { background: rgba(239,68,68,0.10); border-color: var(--sb-danger); color: var(--sb-danger-dark); }
.flash-warning { background: rgba(245,158,11,0.10); border-color: var(--sb-warning); color: #B45309; }
.flash-info    { background: rgba(14,165,233,0.10); border-color: var(--sb-primary); color: var(--sb-primary-dark); }
[data-theme="dark"] .flash-success { color: #34D399; }
[data-theme="dark"] .flash-danger { color: #F87171; }
[data-theme="dark"] .flash-warning { color: #FBBF24; }
[data-theme="dark"] .flash-info { color: #38BDF8; }

/* ============================================================
   TABS
   ============================================================ */
.tabs { display: flex; gap: 4px; border-bottom: 2px solid var(--border); margin-bottom: 22px; overflow-x: auto; }
.tab {
  padding: 10px 18px; font-weight: 500; font-size: 13.5px; color: var(--text-muted);
  border-bottom: 2px solid transparent; margin-bottom: -2px; cursor: pointer;
  white-space: nowrap; background: none; border-top: none; border-left: none; border-right: none;
  font-family: var(--font);
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--sb-primary); border-bottom-color: var(--sb-primary); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ============================================================
   CHAT TRANSCRIPT
   ============================================================ */
.chat-transcript { display: flex; flex-direction: column; gap: 14px; padding: 8px 0; }
.msg { display: flex; gap: 10px; max-width: 78%; }
.msg-user { align-self: flex-end; flex-direction: row-reverse; }
.msg-bubble {
  padding: 11px 15px; border-radius: 16px; font-size: 13.5px; line-height: 1.5;
}
.msg-user .msg-bubble {
  background: linear-gradient(135deg, var(--sb-primary), var(--sb-primary-dark));
  color: #fff; border-bottom-right-radius: 4px;
}
.msg-assistant .msg-bubble {
  background: var(--surface-2); border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
}
.msg-tool .msg-bubble {
  background: rgba(99,102,241,0.08); border: 1px dashed var(--sb-accent);
  font-family: var(--mono); font-size: 12px; color: var(--text-muted);
}
.msg-meta { font-size: 10.5px; color: var(--text-soft); margin-top: 3px; }
.msg-role-tag {
  font-size: 10px; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.04em; opacity: 0.7;
}
.voice-badge {
  display: inline-flex; align-items: center; gap: 4px;
  background: rgba(99,102,241,0.14); color: var(--sb-accent-dark);
  font-size: 10px; padding: 1px 7px; border-radius: 10px; margin-left: 6px; font-weight: 600;
}

/* ============================================================
   PROGRESS BAR (budget)
   ============================================================ */
.progress { height: 9px; background: var(--surface-2); border-radius: 20px; overflow: hidden; border: 1px solid var(--border); }
.progress-bar { height: 100%; background: linear-gradient(90deg, var(--sb-primary), var(--sb-accent)); transition: width 0.4s; }
.progress-bar.warning { background: linear-gradient(90deg, var(--sb-warning), var(--sb-danger)); }

/* ============================================================
   MISC
   ============================================================ */
.pagination { display: flex; gap: 6px; justify-content: center; margin-top: 20px; }
.pagination a, .pagination span {
  padding: 7px 13px; border-radius: var(--radius-sm); border: 1px solid var(--border);
  background: var(--surface); font-size: 13px;
}
.pagination .current { background: var(--sb-primary); color: #fff; border-color: var(--sb-primary); }

.filter-bar { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 18px; align-items: center; }
.filter-bar select, .filter-bar input { width: auto; min-width: 140px; }

.empty-state { text-align: center; padding: 50px 20px; color: var(--text-soft); }
.empty-state .icon { font-size: 42px; margin-bottom: 12px; opacity: 0.4; }

.page-actions { display: flex; gap: 10px; align-items: center; }

.help-text { font-size: 12.5px; color: var(--text-muted); background: var(--surface-2);
  padding: 10px 14px; border-radius: var(--radius-sm); border-left: 3px solid var(--sb-primary); margin-bottom: 14px; }

.kv-list { display: grid; grid-template-columns: auto 1fr; gap: 8px 20px; font-size: 13.5px; }
.kv-list dt { color: var(--text-muted); font-weight: 500; }
.kv-list dd { color: var(--text); }

.check-row { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--border); }
.check-row:last-child { border: none; }
.check-status { width: 11px; height: 11px; border-radius: 50%; flex-shrink: 0; }
.check-ok { background: var(--sb-success); }
.check-fail { background: var(--sb-danger); }
.check-na { background: var(--text-soft); }

/* ============================================================
   LOGIN
   ============================================================ */
.login-page {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background:
    radial-gradient(circle at 20% 20%, rgba(14,165,233,0.18), transparent 40%),
    radial-gradient(circle at 80% 70%, rgba(99,102,241,0.18), transparent 40%),
    var(--bg);
  padding: 20px;
}
.login-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 18px; box-shadow: var(--shadow-lg);
  width: 100%; max-width: 410px; padding: 38px 34px;
}
.login-logo { display: flex; flex-direction: column; align-items: center; gap: 12px; margin-bottom: 26px; }
.login-logo .logo { width: 56px; height: 56px; }
.login-logo h1 { font-size: 21px; font-weight: 700; letter-spacing: -0.02em; }
.login-logo p { font-size: 13px; color: var(--text-muted); }

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 860px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main { margin-left: 0; }
  .menu-toggle { display: block; }
  .form-row { grid-template-columns: 1fr; }
  .msg { max-width: 90%; }
  .sidebar-backdrop {
    display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 99;
  }
  .sidebar-backdrop.show { display: block; }
}
