/* ============================================================
   CSS Custom Properties — Light Theme (default)
   ============================================================ */
:root {
  --bg-base:        #f4f5f7;
  --bg-surface:     #ffffff;
  --bg-surface-2:   #f9fafb;
  --bg-sidebar:     #1a1d23;
  --bg-topbar:      #ffffff;

  --text-primary:   #111827;
  --text-secondary: #6b7280;
  --text-muted:     #9ca3af;
  --text-sidebar:   #c9d1d9;
  --text-sidebar-muted: #6b7280;

  --border:         #e5e7eb;
  --border-strong:  #d1d5db;

  --accent:         #2563eb;
  --accent-hover:   #1d4ed8;
  --accent-text:    #ffffff;

  --sidebar-w:      240px;
  --topbar-h:       60px;
  --radius:         8px;
  --radius-lg:      12px;
  --shadow-sm:      0 1px 3px rgba(0,0,0,.08);
  --shadow-md:      0 4px 12px rgba(0,0,0,.10);

  --success:  #16a34a;
  --danger:   #dc2626;
  --warning:  #d97706;
  --info:     #0284c7;

  --stat-blue:   #eff6ff;
  --stat-blue-icon: #2563eb;
  --stat-green:  #f0fdf4;
  --stat-green-icon: #16a34a;
  --stat-amber:  #fffbeb;
  --stat-amber-icon: #d97706;
  --stat-purple: #faf5ff;
  --stat-purple-icon: #7c3aed;

  --transition: 150ms ease;
}

/* ============================================================
   Dark Theme
   ============================================================ */
[data-theme="dark"] {
  --bg-base:        #0d1117;
  --bg-surface:     #161b22;
  --bg-surface-2:   #1c2128;
  --bg-sidebar:     #0d1117;
  --bg-topbar:      #161b22;

  --text-primary:   #e6edf3;
  --text-secondary: #8b949e;
  --text-muted:     #6e7681;
  --text-sidebar:   #c9d1d9;
  --text-sidebar-muted: #6e7681;

  --border:         #30363d;
  --border-strong:  #484f58;

  --accent:         #3b82f6;
  --accent-hover:   #2563eb;

  --shadow-sm:      0 1px 3px rgba(0,0,0,.3);
  --shadow-md:      0 4px 12px rgba(0,0,0,.4);

  --stat-blue:   #1c2744;
  --stat-blue-icon: #60a5fa;
  --stat-green:  #14281e;
  --stat-green-icon: #4ade80;
  --stat-amber:  #2a1f08;
  --stat-amber-icon: #fbbf24;
  --stat-purple: #1e1433;
  --stat-purple-icon: #a78bfa;
}

/* ============================================================
   Reset & Base
   ============================================================ */
*, *::before, *::after { box-sizing: border-box; }

html {
  background: var(--bg-base);
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 14px;
  color: var(--text-primary);
  background: var(--bg-base);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

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

.admin-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  margin-left: var(--sidebar-w);
  transition: margin-left var(--transition);
}

.admin-content {
  flex: 1;
  padding: 24px;
  overflow-y: auto;
}

/* ============================================================
   Sidebar
   ============================================================ */
.admin-sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: var(--sidebar-w);
  height: 100vh;
  background: var(--bg-sidebar);
  display: flex;
  flex-direction: column;
  z-index: 200;
  border-right: 1px solid rgba(255,255,255,.04);
  transition: transform var(--transition);
  overflow: hidden;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 20px;
  height: var(--topbar-h);
  border-bottom: 1px solid rgba(255,255,255,.06);
  flex-shrink: 0;
}

.sidebar-brand-icon {
  font-size: 20px;
  color: var(--accent);
}

.sidebar-brand-text {
  font-weight: 600;
  font-size: 15px;
  color: #ffffff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-nav {
  flex: 1;
  padding: 16px 0;
  overflow-y: auto;
}

.sidebar-section-label {
  padding: 6px 20px 4px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--text-sidebar-muted);
}

.sidebar-menu {
  list-style: none;
  margin: 0;
  padding: 0 8px;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 6px;
  color: var(--text-sidebar);
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 500;
  transition: background var(--transition), color var(--transition);
  margin-bottom: 2px;
}

.sidebar-link:hover {
  background: rgba(255,255,255,.07);
  color: #ffffff;
}

.sidebar-link.active {
  background: var(--accent);
  color: #ffffff;
}

.sidebar-link i {
  font-size: 16px;
  flex-shrink: 0;
}

.sidebar-footer {
  padding: 12px 16px;
  border-top: 1px solid rgba(255,255,255,.06);
  flex-shrink: 0;
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
}

.sidebar-user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 13px;
  text-transform: uppercase;
  flex-shrink: 0;
}

.sidebar-user-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-sidebar);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-user-role {
  font-size: 11px;
  color: var(--text-sidebar-muted);
  text-transform: capitalize;
}

/* ============================================================
   Topbar
   ============================================================ */
.admin-topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--topbar-h);
  background: var(--bg-topbar);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  gap: 12px;
  box-shadow: var(--shadow-sm);
}

.topbar-left, .topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.sidebar-toggle,
.theme-toggle {
  background: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text-secondary);
  font-size: 16px;
  transition: background var(--transition), color var(--transition);
}

.sidebar-toggle:hover, .theme-toggle:hover {
  background: var(--bg-surface-2);
  color: var(--text-primary);
}

.breadcrumb {
  font-size: 13px;
}

.breadcrumb-item a {
  color: var(--text-secondary);
  text-decoration: none;
}

.breadcrumb-item a:hover { color: var(--accent); }
.breadcrumb-item.active { color: var(--text-primary); }
.breadcrumb-item + .breadcrumb-item::before { color: var(--text-muted); }

.topbar-user-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 5px 10px;
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  color: var(--text-primary);
  font-size: 13px;
  transition: background var(--transition);
}

.topbar-user-btn:hover { background: var(--bg-surface-2); }

.topbar-avatar {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 11px;
  text-transform: uppercase;
}

/* ============================================================
   Dropdown overrides
   ============================================================ */
.dropdown-menu {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  padding: 6px;
  min-width: 180px;
}

.dropdown-item {
  border-radius: 5px;
  font-size: 13px;
  color: var(--text-primary);
  padding: 7px 10px;
}

.dropdown-item:hover { background: var(--bg-surface-2); color: var(--text-primary); }
.dropdown-item.text-danger:hover { background: #fee2e2; }
.dropdown-item-text { font-size: 12px; padding: 4px 10px; }
.dropdown-divider { border-color: var(--border); margin: 4px 0; }

/* ============================================================
   Page Header
   ============================================================ */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 24px;
}

.page-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0;
  line-height: 1.2;
}

.page-subtitle {
  font-size: 13px;
  color: var(--text-secondary);
  margin: 4px 0 0;
}

.badge-online {
  background: #d1fae5;
  color: #065f46;
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 20px;
  font-weight: 500;
}

[data-theme="dark"] .badge-online {
  background: #14281e;
  color: #4ade80;
}

/* ============================================================
   Stat Cards
   ============================================================ */
.stat-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--transition);
}

.stat-card:hover { box-shadow: var(--shadow-md); }

.stat-icon {
  width: 48px;
  height: 48px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  flex-shrink: 0;
}

.stat-icon-blue   { background: var(--stat-blue);   color: var(--stat-blue-icon); }
.stat-icon-green  { background: var(--stat-green);  color: var(--stat-green-icon); }
.stat-icon-amber  { background: var(--stat-amber);  color: var(--stat-amber-icon); }
.stat-icon-purple { background: var(--stat-purple); color: var(--stat-purple-icon); }

.stat-value {
  font-size: 24px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1;
}

.stat-label {
  font-size: 12.5px;
  color: var(--text-secondary);
  margin-top: 4px;
}

/* ============================================================
   Card Panel
   ============================================================ */
.card-panel {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.card-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}

.card-panel-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0;
}

.card-panel-body {
  padding: 20px;
}

/* ============================================================
   Activity List
   ============================================================ */
.activity-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.activity-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
  transition: background var(--transition);
}

.activity-item:last-child { border-bottom: none; }
.activity-item:hover { background: var(--bg-surface-2); }
.activity-item.activity-empty { justify-content: center; padding: 24px; }

.activity-icon {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  flex-shrink: 0;
  margin-top: 1px;
}

.activity-login        { background: #dbeafe; color: #1d4ed8; }
.activity-logout       { background: #f3f4f6; color: #374151; }
.activity-login_failed { background: #fee2e2; color: #dc2626; }
.activity-setup_complete { background: #d1fae5; color: #065f46; }

[data-theme="dark"] .activity-login        { background: #1c2744; color: #60a5fa; }
[data-theme="dark"] .activity-logout       { background: #1c2128; color: #8b949e; }
[data-theme="dark"] .activity-login_failed { background: #2d1515; color: #f87171; }
[data-theme="dark"] .activity-setup_complete { background: #14281e; color: #4ade80; }

.activity-text {
  font-size: 13px;
  color: var(--text-primary);
}

.activity-time {
  font-size: 11.5px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* ============================================================
   Auth Pages
   ============================================================ */
.auth-body {
  background: var(--bg-base);
  min-height: 100vh;
}

.auth-wrapper {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
}

.auth-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 36px;
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow-md);
}

.setup-card { max-width: 480px; }

.auth-card-header {
  text-align: center;
  margin-bottom: 28px;
}

.auth-logo {
  width: 52px;
  height: 52px;
  background: var(--accent);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  color: #fff;
  margin: 0 auto 16px;
}

.auth-title {
  font-size: 22px;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0 0 6px;
}

.auth-subtitle {
  font-size: 13.5px;
  color: var(--text-secondary);
  margin: 0;
}

.form-section-title {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--text-muted);
  margin-bottom: 12px;
}

/* ============================================================
   Form overrides
   ============================================================ */
.form-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
  margin-bottom: 6px;
}

.form-control,
.input-group-text {
  background: var(--bg-surface);
  border-color: var(--border);
  color: var(--text-primary);
  font-size: 13.5px;
  border-radius: 6px;
}

.form-control:focus {
  background: var(--bg-surface);
  border-color: var(--accent);
  color: var(--text-primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,.15);
}

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

.input-group-text {
  background: var(--bg-surface-2);
  color: var(--text-secondary);
  border-right: none;
}

.input-group .form-control:not(:first-child) {
  border-left: none;
}

.input-group .btn-outline-secondary {
  border-color: var(--border);
  color: var(--text-secondary);
  background: var(--bg-surface-2);
}

.input-group .btn-outline-secondary:hover {
  background: var(--bg-base);
  color: var(--text-primary);
}

/* ============================================================
   Buttons
   ============================================================ */
.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 500;
  border-radius: 6px;
  transition: background var(--transition);
}

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

.btn-lg { padding: 10px 20px; font-size: 14px; }

/* ============================================================
   Alert overrides
   ============================================================ */
.alert {
  font-size: 13.5px;
  border-radius: var(--radius);
  border-width: 1px;
}

.alert-success {
  background: #f0fdf4;
  border-color: #bbf7d0;
  color: #166534;
}

.alert-danger {
  background: #fff1f2;
  border-color: #fecdd3;
  color: #9f1239;
}

[data-theme="dark"] .alert-success {
  background: #14281e;
  border-color: #166534;
  color: #4ade80;
}

[data-theme="dark"] .alert-danger {
  background: #2d1515;
  border-color: #7f1d1d;
  color: #fca5a5;
}

/* ============================================================
   Error Page
   ============================================================ */
.error-code {
  font-size: 72px;
  font-weight: 800;
  color: var(--accent);
  line-height: 1;
  margin-bottom: 8px;
}

/* ============================================================
   Bootstrap dark overrides (Bootstrap kendi data-bs-theme kullanır,
   biz data-theme kullanıyoruz — tüm Bootstrap bileşenlerini override et)
   ============================================================ */
[data-theme="dark"] .text-muted,
[data-theme="dark"] .text-secondary {
  color: var(--text-secondary) !important;
}

[data-theme="dark"] .form-control,
[data-theme="dark"] .form-select {
  background-color: var(--bg-surface-2);
  border-color: var(--border);
  color: var(--text-primary);
}

[data-theme="dark"] .form-control:focus,
[data-theme="dark"] .form-select:focus {
  background-color: var(--bg-surface-2);
  border-color: var(--accent);
  color: var(--text-primary);
  box-shadow: 0 0 0 3px rgba(59,130,246,.2);
}

[data-theme="dark"] .form-control::placeholder {
  color: var(--text-muted);
}

[data-theme="dark"] .input-group-text {
  background-color: var(--bg-base);
  border-color: var(--border);
  color: var(--text-secondary);
}

[data-theme="dark"] .input-group .btn-outline-secondary {
  background-color: var(--bg-base);
  border-color: var(--border);
  color: var(--text-secondary);
}

[data-theme="dark"] .input-group .btn-outline-secondary:hover {
  background-color: var(--bg-surface-2);
  color: var(--text-primary);
  border-color: var(--border-strong);
}

[data-theme="dark"] .btn-close {
  filter: invert(1) grayscale(100%) brightness(200%);
}

[data-theme="dark"] .dropdown-item.text-danger {
  color: #f87171 !important;
}

[data-theme="dark"] .dropdown-item.text-danger:hover {
  background: #2d1515;
  color: #fca5a5 !important;
}

[data-theme="dark"] .badge.bg-secondary {
  background-color: var(--bg-base) !important;
  color: var(--text-muted) !important;
  border: 1px solid var(--border);
}

[data-theme="dark"] hr,
[data-theme="dark"] .dropdown-divider {
  border-color: var(--border);
  opacity: 1;
}

/* ============================================================
   Scrollbar
   ============================================================ */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 3px; }

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 768px) {
  .admin-sidebar {
    transform: translateX(calc(-1 * var(--sidebar-w)));
  }

  .admin-sidebar.open {
    transform: translateX(0);
    box-shadow: var(--shadow-md);
  }

  .admin-main {
    margin-left: 0;
  }

  .admin-content { padding: 16px; }
  .auth-card { padding: 24px 20px; }
}

/* ============================================================
   Table overrides
   ============================================================ */
.table {
  color: var(--text-primary);
  border-color: var(--border);
}
.table>:not(caption)>*>* {
  background-color: transparent;
  border-bottom-color: var(--border);
  color: var(--text-primary);
  padding: 12px 16px;
  vertical-align: middle;
}
.table thead th {
  padding: 10px 16px;
  font-weight: 600;
}
.table-hover>tbody>tr:hover>* {
  background-color: var(--bg-surface-2);
}

/* Form switch overrides */
.form-check-input:checked {
  background-color: var(--accent);
  border-color: var(--accent);
}
.form-check-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(37,99,235,.15);
}
/* Switch track — unchecked */
.form-check-input[type="checkbox"]:not(:checked) {
  background-color: #4b5563;
  border-color: #4b5563;
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='-4 -4 8 8'%3e%3ccircle r='3' fill='%23fff'/%3e%3c/svg%3e");
}
[data-theme="dark"] .form-check-input {
  border-color: var(--border-strong);
}
[data-theme="dark"] .form-check-input[type="checkbox"]:not(:checked) {
  background-color: #374151;
  border-color: #4b5563;
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='-4 -4 8 8'%3e%3ccircle r='3' fill='%23fff'/%3e%3c/svg%3e");
}
[data-theme="dark"] .form-check-input:checked {
  background-color: var(--accent);
  border-color: var(--accent);
}

/* Modal overrides */
.modal-content {
  background: var(--bg-surface) !important;
  border: 1px solid var(--border) !important;
}
.modal-header, .modal-footer {
  border-color: var(--border) !important;
}
.modal-title {
  color: var(--text-primary) !important;
}
[data-theme="dark"] .modal-backdrop {
  opacity: 0.7;
}

/* btn-outline-secondary dark overrides */
[data-theme="dark"] .btn-outline-secondary {
  color: var(--text-secondary);
  border-color: var(--border);
}
[data-theme="dark"] .btn-outline-secondary:hover {
  background: var(--bg-surface-2);
  color: var(--text-primary);
  border-color: var(--border-strong);
}

/* Alert overrides for settings page */
.alert-warning {
  background: #fffbeb;
  border-color: #fde68a;
  color: #92400e;
}
[data-theme="dark"] .alert-warning {
  background: #2a1f08;
  border-color: #78350f;
  color: #fbbf24;
}
.alert-danger {
  background: #fff1f2;
  border-color: #fecdd3;
  color: #9f1239;
}
[data-theme="dark"] .alert-danger {
  background: #2a0a0f;
  border-color: #7f1d1d;
  color: #f87171;
}

.stat-hint {
  font-size: 10.5px;
  color: var(--text-muted);
  margin-top: 2px;
  opacity: 0.75;
}

/* Stat card uniform height fix */
.stat-card {
  align-items: center;
  min-height: 88px;
}

.stat-body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.stat-label {
  white-space: normal;
  line-height: 1.3;
  min-height: 2.6em;
  display: flex;
  align-items: flex-end;
}

/* Dual stat value (görüntülenme/kullanım) */
.stat-value {
  font-size: 22px;
}
