/* ============================================================
   KFOO Admin — Design System
   Bootstrap 5 RTL + Custom Dark Theme
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Tajawal:wght@300;400;500;700;800&family=Inter:wght@400;500;600&display=swap');

/* ── Variables ── */
:root {
  --sidebar-w: 260px;
  --topbar-h: 64px;

  /* Backgrounds */
  --bg-body:     #080d1a;
  --bg-sidebar:  #0c1226;
  --bg-card:     #101828;
  --bg-card-2:   #131f35;
  --bg-input:    #1a2540;

  /* Borders */
  --border:      #1e2d4a;
  --border-light:#243252;

  /* Accent */
  --primary:        #6366f1;
  --primary-hover:  #4f46e5;
  --primary-glow:   rgba(99,102,241,0.25);
  --primary-subtle: rgba(99,102,241,0.12);

  --success:        #10b981;
  --success-subtle: rgba(16,185,129,0.12);
  --warning:        #f59e0b;
  --warning-subtle: rgba(245,158,11,0.12);
  --danger:         #ef4444;
  --danger-subtle:  rgba(239,68,68,0.12);
  --info:           #06b6d4;
  --info-subtle:    rgba(6,182,212,0.12);

  /* Text */
  --text:        #e2e8f0;
  --text-muted:  #94a3b8;
  --text-dim:    #4b5e7e;

  /* Radius & Shadow */
  --radius:    12px;
  --radius-sm: 8px;
  --shadow:    0 4px 24px rgba(0,0,0,0.4);
  --shadow-sm: 0 2px 8px rgba(0,0,0,0.3);
}

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

body {
  font-family: 'Tajawal', 'Inter', sans-serif;
  background: var(--bg-body);
  color: var(--text);
  direction: rtl;
  min-height: 100vh;
  overflow-x: hidden;
  font-size: 15px;
}

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-light); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--primary); }

/* ══════════════════════════════════════
   SIDEBAR
══════════════════════════════════════ */
.sidebar {
  position: fixed;
  top: 0; right: 0;
  width: var(--sidebar-w);
  height: 100vh;
  background: var(--bg-sidebar);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 1000;
  transition: transform .3s cubic-bezier(.4,0,.2,1);
  overflow-y: auto;
  overflow-x: hidden;
}

/* Logo */
.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 20px 16px;
  border-bottom: 1px solid var(--border);
}
.sidebar-logo .logo-icon {
  width: 36px; height: 36px;
  background: var(--primary);
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px;
  box-shadow: 0 0 16px var(--primary-glow);
}
.sidebar-logo .logo-text {
  font-size: 20px;
  font-weight: 800;
  letter-spacing: 1px;
  background: linear-gradient(135deg, #a5b4fc, #818cf8);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}
.sidebar-logo .logo-sub {
  font-size: 11px;
  color: var(--text-dim);
  margin-top: -2px;
}

/* Admin Info */
.sidebar-admin {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  margin: 12px 12px 6px;
  background: var(--bg-card);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}
.admin-avatar {
  width: 36px; height: 36px;
  background: linear-gradient(135deg, var(--primary), #8b5cf6);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 15px; font-weight: 700;
  flex-shrink: 0;
}
.admin-name { font-size: 13px; font-weight: 600; }
.admin-level { margin-top: 2px; }

/* Navigation */
.sidebar-nav {
  flex: 1;
  padding: 8px 0;
}
.nav-section {
  padding: 16px 20px 6px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: var(--text-dim);
}
.sidebar-link {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px 16px;
  margin: 2px 10px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  transition: all .2s;
  position: relative;
}
.sidebar-link:hover {
  background: var(--primary-subtle);
  color: var(--text);
}
.sidebar-link.active {
  background: var(--primary-subtle);
  color: #a5b4fc;
  border: 1px solid rgba(99,102,241,0.2);
}
.sidebar-link.active::before {
  content: '';
  position: absolute;
  right: -10px; top: 50%;
  transform: translateY(-50%);
  width: 3px; height: 20px;
  background: var(--primary);
  border-radius: 2px 0 0 2px;
}
.sidebar-link i { font-size: 17px; flex-shrink: 0; }
.sidebar-link .nav-count {
  margin-right: auto;
  margin-left: 0;
  font-size: 11px;
  background: var(--bg-input);
  padding: 1px 7px;
  border-radius: 20px;
  color: var(--text-dim);
}

/* Sidebar Footer */
.sidebar-footer {
  padding: 12px 10px;
  border-top: 1px solid var(--border);
}
.sidebar-footer .sidebar-link { margin: 2px 0; }

/* ══════════════════════════════════════
   MAIN CONTENT
══════════════════════════════════════ */
.main-content {
  margin-right: var(--sidebar-w);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ── Top Navbar ── */
.topbar {
  position: sticky;
  top: 0; z-index: 100;
  height: var(--topbar-h);
  background: rgba(8,13,26,0.85);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
}
.topbar-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
}
.topbar-breadcrumb {
  font-size: 12px;
  color: var(--text-dim);
  margin-top: 2px;
}
.topbar-actions { display: flex; align-items: center; gap: 8px; }
.topbar-btn {
  width: 36px; height: 36px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  color: var(--text-muted);
  text-decoration: none;
  transition: all .2s;
  font-size: 16px;
}
.topbar-btn:hover { border-color: var(--primary); color: var(--primary); }

/* ── Page Content ── */
.page-content {
  flex: 1;
  padding: 28px 28px 40px;
}

/* ── Page Header ── */
.page-header {
  margin-bottom: 24px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}
.page-header-title {
  font-size: 22px;
  font-weight: 800;
}
.page-header-sub {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 3px;
}

/* ══════════════════════════════════════
   STAT CARDS
══════════════════════════════════════ */
.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  transition: all .25s;
  text-decoration: none;
  color: inherit;
  position: relative;
  overflow: hidden;
}
.stat-card::after {
  content: '';
  position: absolute;
  top: 0; right: 0;
  width: 3px; height: 100%;
  background: var(--card-accent, var(--primary));
  border-radius: 0 var(--radius) var(--radius) 0;
}
.stat-card:hover {
  border-color: var(--card-accent, var(--primary));
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}
.stat-icon {
  width: 52px; height: 52px;
  border-radius: var(--radius-sm);
  background: var(--card-accent-subtle, var(--primary-subtle));
  display: flex; align-items: center; justify-content: center;
  font-size: 24px;
  flex-shrink: 0;
}
.stat-label {
  font-size: 12px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .6px;
  font-weight: 600;
}
.stat-value {
  font-size: 28px;
  font-weight: 800;
  line-height: 1.1;
  margin-top: 4px;
}
.stat-sub {
  font-size: 12px;
  color: var(--text-dim);
  margin-top: 3px;
}
.stat-badge {
  position: absolute;
  top: 14px; left: 14px;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 20px;
}

/* ══════════════════════════════════════
   CARDS (General)
══════════════════════════════════════ */
.kfoo-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.kfoo-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.kfoo-card-title {
  font-size: 14px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
}
.kfoo-card-title i { color: var(--primary); }
.kfoo-card-body { padding: 20px; }
.kfoo-card-body.p-0 { padding: 0; }

/* ══════════════════════════════════════
   TABLES
══════════════════════════════════════ */
.kfoo-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
  background: transparent !important;
}
.kfoo-table thead th {
  padding: 10px 14px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .6px;
  color: var(--text-dim);
  background: var(--bg-card-2);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.kfoo-table tbody tr { background: transparent !important; }
.kfoo-table tbody td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  vertical-align: middle;
  background: transparent !important;
}
.kfoo-table tbody tr:last-child td { border-bottom: none; }
.kfoo-table tbody tr:hover td { background: rgba(255,255,255,0.03) !important; }

/* ══════════════════════════════════════
   BADGES
══════════════════════════════════════ */
.badge-active   { background: var(--success-subtle); color: var(--success); border: 1px solid rgba(16,185,129,.25); }
.badge-expired  { background: var(--danger-subtle);  color: var(--danger);  border: 1px solid rgba(239,68,68,.25); }
.badge-pending  { background: var(--warning-subtle); color: var(--warning); border: 1px solid rgba(245,158,11,.25); }
.badge-info     { background: var(--info-subtle);    color: var(--info);    border: 1px solid rgba(6,182,212,.25); }

.kfoo-badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11.5px;
  font-weight: 600;
}

/* ══════════════════════════════════════
   BUTTONS
══════════════════════════════════════ */
.btn-kfoo {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 18px;
  border-radius: var(--radius-sm);
  font-size: 13.5px; font-weight: 600;
  transition: all .2s;
  border: none; cursor: pointer;
  text-decoration: none;
}
.btn-kfoo-primary {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 4px 12px var(--primary-glow);
}
.btn-kfoo-primary:hover { background: var(--primary-hover); color: #fff; }
.btn-kfoo-outline {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
}
.btn-kfoo-outline:hover { border-color: var(--primary); color: var(--primary); }

/* ══════════════════════════════════════
   ALERTS / FLASH
══════════════════════════════════════ */
.flash-container { margin-bottom: 20px; }
.alert {
  border-radius: var(--radius-sm);
  border: none;
  font-size: 14px;
}
.alert-success { background: var(--success-subtle); color: var(--success); }
.alert-danger   { background: var(--danger-subtle);  color: var(--danger); }
.alert-warning  { background: var(--warning-subtle); color: var(--warning); }
.alert-info     { background: var(--info-subtle);    color: var(--info); }

/* ══════════════════════════════════════
   CHARTS
══════════════════════════════════════ */
.chart-container { position: relative; }

/* ══════════════════════════════════════
   FORMS
══════════════════════════════════════ */
.kfoo-input, .form-control, .form-select, .input-group-text {
  background: var(--bg-input) !important;
  border: 1px solid var(--border) !important;
  color: var(--text) !important;
  border-radius: var(--radius-sm) !important;
  font-family: inherit;
  font-size: 14px;
  padding: 9px 14px;
  transition: border-color .2s;
}
.kfoo-input:focus, .form-control:focus, .form-select:focus {
  border-color: var(--primary) !important;
  box-shadow: 0 0 0 3px var(--primary-glow) !important;
  outline: none;
}
.form-label { font-size: 13px; font-weight: 600; color: var(--text-muted); margin-bottom: 6px; }

/* ══════════════════════════════════════
   LOGIN PAGE
══════════════════════════════════════ */
.login-page {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg-body);
  position: relative;
}
.login-page::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at 50% 0%, rgba(99,102,241,0.15) 0%, transparent 60%);
  pointer-events: none;
}
.login-card {
  width: 100%; max-width: 400px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 40px 36px;
  box-shadow: var(--shadow);
}
.login-logo {
  text-align: center;
  margin-bottom: 28px;
}
.login-logo .icon {
  width: 56px; height: 56px;
  background: var(--primary);
  border-radius: 14px;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 28px;
  margin-bottom: 12px;
  box-shadow: 0 0 24px var(--primary-glow);
}
.login-logo h1 {
  font-size: 22px; font-weight: 800;
  background: linear-gradient(135deg, #a5b4fc, #818cf8);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
}
.login-logo p { font-size: 13px; color: var(--text-muted); margin-top: 4px; }
.login-card .btn-kfoo-primary {
  width: 100%; justify-content: center; padding: 12px;
}

/* ══════════════════════════════════════
   EXPIRY WARNING STRIP
══════════════════════════════════════ */
.expiry-strip {
  display: flex; align-items: center; gap: 8px;
  padding: 3px 0;
}
.expiry-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* ══════════════════════════════════════
   MOBILE
══════════════════════════════════════ */
.sidebar-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,.6);
  z-index: 999;
}

@media (max-width: 991.98px) {
  .sidebar {
    transform: translateX(100%);
  }
  .sidebar.open {
    transform: translateX(0);
  }
  .sidebar-overlay.open { display: block; }
  .main-content { margin-right: 0; }
  .page-content { padding: 16px; }
}

/* ══════════════════════════════════════
   UTILITIES
══════════════════════════════════════ */
.text-primary-kfoo { color: var(--primary) !important; }
.text-success-kfoo  { color: var(--success) !important; }
.text-warning-kfoo  { color: var(--warning) !important; }
.text-danger-kfoo   { color: var(--danger) !important; }
.text-info-kfoo     { color: var(--info) !important; }
.text-muted-kfoo, .text-muted { color: var(--text-muted) !important; }

.bg-card-kfoo { background: var(--bg-card) !important; }
.border-kfoo  { border-color: var(--border) !important; }

.fw-800 { font-weight: 800; }

/* Gradient text */
.grad-text {
  background: linear-gradient(135deg, #a5b4fc, #38bdf8);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

/* Pulse dot */
.pulse-dot {
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 0 0 rgba(16,185,129,.4);
  animation: pulse 2s infinite;
}
@keyframes pulse {
  0%   { box-shadow: 0 0 0 0 rgba(16,185,129,.4); }
  70%  { box-shadow: 0 0 0 8px rgba(16,185,129,0); }
  100% { box-shadow: 0 0 0 0 rgba(16,185,129,0); }
}

/* Fade in animation */
.fade-in {
  animation: fadeIn .4s ease;
}
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Bootstrap overrides for dark theme */
.modal-content {
  background: var(--bg-card-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
}
.modal-header {
  border-bottom: 1px solid var(--border);
  padding: 16px 20px;
}
.modal-footer { border-top: 1px solid var(--border); }
.dropdown-menu {
  background: var(--bg-card-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.dropdown-item { color: var(--text-muted); font-size: 14px; }
.dropdown-item:hover { background: var(--primary-subtle); color: var(--text); }
.pagination .page-link {
  background: var(--bg-card);
  border-color: var(--border);
  color: var(--text-muted);
}
.pagination .page-link:hover { background: var(--primary-subtle); color: var(--primary); }
.pagination .page-item.active .page-link { background: var(--primary); border-color: var(--primary); }
