/* ── RESET & TOKENS ─────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --primary:      #0D8A8A;
  --primary-d:    #0A6E6E;
  --primary-l:    #E6F7F7;
  --accent:       #F59E0B;
  --accent-l:     #FEF3C7;
  --success:      #10B981;
  --error:        #EF4444;
  --warning:      #F59E0B;
  --info:         #0D8A8A;
  --bg:           #F0F7F7;
  --surface:      #FFFFFF;
  --sidebar-bg:   #0A3D3D;
  --sidebar-text: rgba(255,255,255,0.65);
  --sidebar-act:  rgba(255,255,255,0.1);
  --border:       #D1E8E8;
  --text:         #0A2E2E;
  --text-s:       #4A7070;
  --text-h:       #8AABAB;
  --shadow:       0 1px 3px rgba(13,138,138,0.08), 0 4px 16px rgba(13,138,138,0.06);
  --shadow-lg:    0 8px 32px rgba(13,138,138,0.14);
  --radius:       14px;
  --sidebar-w:    260px;
  --font:         'Cairo', sans-serif;
  --mono:         'JetBrains Mono', monospace;
  --bottom-nav-h: 0px;
}

/* ── ADS & PLANS RESPONSIVE GRID ── */
/* @media (max-width: 1200px) {
  #ads-grid   { grid-template-columns: repeat(2, 1fr) !important; }
  #plans-grid { grid-template-columns: repeat(2, 1fr) !important; }
}
@media (max-width: 768px) {
  #ads-grid   { grid-template-columns: 1fr !important; }
  #plans-grid { grid-template-columns: 1fr !important; }
} */

/* ── ADS PAGE FIXES ── */
#ads-grid {
  display: grid !important;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)) !important;
  gap: 20px !important;
  width: 100% !important;
  margin-top: 16px;
}

@media (max-width: 768px) {
  #ads-grid {
    grid-template-columns: 1fr !important;
    gap: 16px !important;
  }
}

/* تحسين أزرار الإعلانات */
#ads-grid .btn-sm {
  padding: 6px 12px !important;
  font-size: 12px !important;
  white-space: nowrap !important;
}

#ads-grid .flex-buttons {
  display: flex !important;
  flex-direction: row !important;
  gap: 8px !important;
  flex-wrap: wrap !important;
}

/* ── DARK MODE ────────────────────────────────────────────────────── */
body.dark-mode {
  --bg:      #0D1117;
  --surface: #161B22;
  --border:  #30363D;
  --text:    #E6EDF3;
  --text-s:  #8B949E;
  --text-h:  #484F58;
  --primary-l: #0A3030;
  --shadow:  0 1px 3px rgba(0,0,0,0.3), 0 4px 16px rgba(0,0,0,0.2);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.4);
}

/* Smooth theme transition */
* {
  transition: background-color var(--transition), color 0.2s ease, border-color 0.2s ease;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  overflow-x: hidden;
  transition: background 0.2s, color 0.2s;
}

/* ── DARK MODE CHART FIX ── */
body.dark-mode canvas {
  filter: none;
}

body.dark-mode .chartjs-render-monitor {
  background: var(--surface) !important;
}


/* ── ENHANCED STAT CARDS ───────────────────────────────────────── */
.stat-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 18px 18px 14px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 0;
  transition: all var(--transition);
  cursor: default;
  position: relative;
  overflow: hidden;
  border: 1px solid var(--border);
}

.stat-card:hover {
  transform: translateY(-6px);
  box-shadow: var(--shadow-xl);
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--primary), var(--accent));
  opacity: 0;
  transition: opacity var(--transition);
}

.stat-card:hover::before {
  opacity: 1;
}


/* ── SIDEBAR ─────────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  min-height: 100vh;
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  position: fixed;
  right: 0;
  top: 0;
  bottom: 0;
  z-index: 300;
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  /* Desktop: always visible */
}

.sidebar-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 299;
  opacity: 0;
  transition: opacity 0.25s ease;
  display: none;
}
.sidebar-overlay.active { opacity: 1; }

.sidebar-logo {
  padding: 24px 20px 20px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  display: flex;
  align-items: center;
  gap: 12px;
}
.logo-icon {
  width: 40px; height: 40px;
  background: var(--primary);
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}
.logo-text { color: #fff; font-weight: 800; font-size: 16px; line-height: 1.2; }
.logo-sub  { color: var(--sidebar-text); font-size: 11px; }

.sidebar-nav { flex: 1; padding: 12px; overflow-y: auto; }
.badge-info { background: var(--primary); color: #fff; }
.badge-gray { background: var(--border); color: var(--text-s); }
.tag { display:inline-block; background:var(--bg); border:1px solid var(--border); border-radius:6px; padding:2px 8px; font-size:11px; }
.imgs-grid { display:grid; grid-template-columns:repeat(auto-fill,minmax(80px,1fr)); gap:8px; margin-top:8px; }
.imgs-grid-item { position:relative; aspect-ratio:1; border-radius:8px; overflow:hidden; }
.imgs-grid-item img { width:100%; height:100%; object-fit:cover; }
.del-img-btn { position:absolute; top:2px; right:2px; background:rgba(0,0,0,0.6); color:#fff; border:none; border-radius:50%; width:20px; height:20px; font-size:12px; cursor:pointer; display:flex; align-items:center; justify-content:center; }
.card-header { display:flex; justify-content:space-between; align-items:center; margin-bottom:14px; }
.card-title { font-size:15px; font-weight:700; }
.nav-section-label {
  color: rgba(255,255,255,0.3);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1.5px;
  padding: 16px 8px 6px;
  text-transform: uppercase;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: 10px;
  cursor: pointer;
  color: var(--sidebar-text);
  font-size: 14px;
  font-weight: 500;
  transition: all 0.15s;
  margin-bottom: 2px;
  text-decoration: none;
  user-select: none;
}
.nav-item:hover { background: var(--sidebar-act); color: #fff; }
.nav-item.active {
  background: rgba(255,255,255,0.08);
  color: #fff;
  position: relative;
}
.nav-item.active::before {
  content: '';
  position: absolute;
  right: 0;
  top: 6px;
  bottom: 6px;
  width: 3px;
  background: var(--primary);
  border-radius: 3px 0 0 3px;
}
.nav-item.active .icon { color: var(--primary); }
.nav-item .icon { font-size: 18px; width: 22px; text-align: center; flex-shrink: 0; transition: color 0.15s; }
.nav-item .badge {
  margin-right: auto;
  background: var(--accent);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 20px;
}

.sidebar-footer {
  padding: 16px;
  border-top: 1px solid rgba(255,255,255,0.08);
}
.admin-pill {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px;
  background: rgba(255,255,255,0.07);
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.06);
}
.admin-av {
  width: 34px; height: 34px;
  background: var(--primary);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; color: #fff; font-size: 14px;
  flex-shrink: 0;
  position: relative;
}
.admin-av::after {
  content: '';
  position: absolute;
  bottom: 1px; left: 1px;
  width: 9px; height: 9px;
  background: #22C55E;
  border-radius: 50%;
  border: 2px solid var(--sidebar-bg);
}
.admin-name { color: #fff; font-size: 13px; font-weight: 600; }
.admin-role { color: var(--sidebar-text); font-size: 11px; }

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

/* ── TOPBAR ──────────────────────────────────────────────────────── */
.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  height: 64px;
  display: flex;
  align-items: center;
  gap: 12px;
  position: sticky;
  top: 0;
  z-index: 200;
  transition: background 0.2s;
}
.topbar-title { font-size: 18px; font-weight: 700; flex: 1; }
.topbar-sub { font-size: 13px; color: var(--text-s); display: none; }

.topbar-search {
  display: flex; align-items: center; gap: 8px;
  background: var(--bg);
  border: 1.5px solid var(--border);
  border-radius: 10px;
  padding: 8px 14px;
  width: 220px;
  transition: width 0.2s, border-color 0.2s, box-shadow 0.2s;
}
.topbar-search:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(13,138,138,0.15);
  width: 260px;
}
.topbar-search input {
  border: none; background: none; outline: none;
  font-family: var(--font); font-size: 13px; color: var(--text);
  width: 100%;
}

.topbar-btn {
  width: 38px; height: 38px;
  min-width: 38px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; font-size: 16px;
  position: relative; transition: background 0.15s;
}
.topbar-btn:hover { background: var(--primary-l); }
.topbar-btn .dot {
  position: absolute; top: 6px; left: 6px;
  width: 8px; height: 8px;
  background: var(--accent); border-radius: 50%;
  border: 2px solid var(--surface);
}

/* ── MOBILE BOTTOM NAV ───────────────────────────────────────────── */
.bottom-nav {
  display: none;
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: var(--surface);
  border-top: 1px solid var(--border);
  z-index: 250;
  padding: 6px 0 env(safe-area-inset-bottom, 6px);
}
.bottom-nav-items {
  display: flex;
  justify-content: space-around;
  align-items: center;
}
.bottom-nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 6px 12px;
  border-radius: 10px;
  cursor: pointer;
  color: var(--text-s);
  font-size: 11px;
  font-weight: 600;
  transition: all 0.15s;
  flex: 1;
  position: relative;
}
.bottom-nav-item .nav-icon { font-size: 20px; }
.bottom-nav-item.active { color: var(--primary); }
.bottom-nav-item.active .nav-icon-bg {
  position: absolute;
  top: 2px;
  width: 48px; height: 28px;
  background: var(--primary-l);
  border-radius: 20px;
}
.bottom-nav-item .bn-badge {
  position: absolute;
  top: 2px; right: 12px;
  background: var(--error);
  color: #fff;
  font-size: 9px;
  font-weight: 700;
  width: 16px; height: 16px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  border: 2px solid var(--surface);
}

/* ── MENU TOGGLE ─────────────────────────────────────────────────── */
.menu-toggle {
  display: none;
  width: 38px; height: 38px;
  min-width: 38px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 18px;
  cursor: pointer;
  align-items: center; justify-content: center;
  flex-shrink: 0;
}

/* ── TOAST ───────────────────────────────────────────────────────── */
#toast-container {
  position: fixed;
  bottom: calc(var(--bottom-nav-h) + 16px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
  min-width: 280px;
}
.toast {
  background: var(--sidebar-bg);
  color: #fff;
  padding: 12px 18px;
  border-radius: 12px;
  font-size: 13px;
  font-weight: 500;
  font-family: var(--font);
  display: flex;
  align-items: center;
  gap: 8px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.3);
  animation: toastIn 0.3s ease forwards;
  pointer-events: all;
}
.toast.success { background: #064E3B; }
.toast.error   { background: #7F1D1D; }
.toast.warning { background: #78350F; }
@keyframes toastIn {
  from { opacity: 0; transform: translateY(16px) scale(0.95); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes toastOut {
  to { opacity: 0; transform: translateY(-8px) scale(0.95); }
}

/* ── SKELETON ─────────────────────────────────────────────────────── */
.skeleton {
  background: linear-gradient(90deg, var(--border) 25%, #f3f4f6 50%, var(--border) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: 8px;
}
@keyframes shimmer {
  from { background-position: 200% 0; }
  to   { background-position: -200% 0; }
}

/* ── PAGES ───────────────────────────────────────────────────────── */
.page { display: none; padding: 24px; animation: fadeIn 0.25s ease; padding-bottom: calc(var(--bottom-nav-h) + 24px); }
.page.active { display: block; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: translateY(0); } }

/* ── STAT CARDS ──────────────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 14px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 18px 18px 14px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 0;
  transition: transform 0.2s, box-shadow 0.2s;
  cursor: default;
  position: relative;
  overflow: hidden;
  border: 1px solid var(--border);
}
.stat-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); }
.stat-card-stripe {
  position: absolute;
  top: 0; right: 0;
  width: 4px;
  height: 100%;
  border-radius: 0 var(--radius) var(--radius) 0;
}
.stat-card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 14px;
}
.stat-icon {
  width: 44px; height: 44px;
  border-radius: 11px;
  display: flex; align-items: center; justify-content: center;
  font-size: 19px; flex-shrink: 0;
}
.stat-card-menu {
  display: flex; flex-direction: column; gap: 3px;
  padding: 4px; cursor: pointer; opacity: 0.35;
  transition: opacity 0.15s;
}
.stat-card:hover .stat-card-menu { opacity: 0.7; }
.stat-card-menu span { width: 13px; height: 1.5px; background: var(--text-s); border-radius: 2px; display: block; }
.stat-value {
  font-size: 28px;
  font-weight: 800;
  line-height: 1;
  letter-spacing: -1px;
}
.stat-label {
  font-size: 12px;
  color: var(--text-s);
  margin-top: 4px;
  font-weight: 500;
  letter-spacing: 0.2px;
}
.stat-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}
.stat-sparkline {
  display: flex;
  align-items: flex-end;
  gap: 2px;
  height: 22px;
}
.stat-sparkline span {
  width: 5px;
  border-radius: 2px;
  opacity: 0.55;
  transition: opacity 0.2s;
}
.stat-sparkline span:last-child { opacity: 1; }
.stat-card:hover .stat-sparkline span { opacity: 0.8; }
.stat-card:hover .stat-sparkline span:last-child { opacity: 1; }
.stat-change {
  font-size: 11px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 3px 7px;
  border-radius: 20px;
  white-space: nowrap;
}
.stat-change.up { background: #DCFCE7; color: #15803D; }
.stat-change.dn { background: #FEE2E2; color: #B91C1C; }
.stat-change.neutral { background: var(--primary-l); color: var(--primary); }
body.dark-mode .stat-change.up { background: rgba(16,185,129,0.15); color: #34D399; }
body.dark-mode .stat-change.dn { background: rgba(239,68,68,0.15); color: #F87171; }
body.dark-mode .stat-change.neutral { background: rgba(13,138,138,0.2); color: #5DCFCF; }

/* ── CHARTS GRID ─────────────────────────────────────────────────── */
.charts-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 16px;
  margin-bottom: 20px;
}

.card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  transition: background 0.2s, border-color 0.2s;
}
.card-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 16px;
}
.card-title { font-size: 15px; font-weight: 700; }
.card-sub { font-size: 12px; color: var(--text-s); }

/* ── TABLE ───────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; border-radius: 0 0 var(--radius) var(--radius); }
table { width: 100%; border-collapse: collapse; min-width: 500px; }
th {
  text-align: right;
  padding: 11px 14px;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-s);
  letter-spacing: 0.6px;
  text-transform: uppercase;
  border-bottom: 1.5px solid var(--border);
  background: var(--bg);
  white-space: nowrap;
  position: sticky;
  top: 0;
  user-select: none;
  cursor: default;
}
th.sortable { cursor: pointer; transition: color 0.15s; }
th.sortable:hover { color: var(--primary); }
th .sort-arrows {
  display: inline-flex;
  flex-direction: column;
  gap: 1px;
  margin-right: 5px;
  vertical-align: middle;
  opacity: 0.35;
}
th.sorted .sort-arrows { opacity: 1; color: var(--primary); }
th .sort-arrows::before { content: '▲'; font-size: 7px; line-height: 1; display: block; }
th .sort-arrows::after  { content: '▼'; font-size: 7px; line-height: 1; display: block; }
td {
  padding: 12px 14px;
  font-size: 13px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
  transition: background 0.1s;
}
tbody tr:nth-child(even) td { background: rgba(0,0,0,0.018); }
body.dark-mode tbody tr:nth-child(even) td { background: rgba(255,255,255,0.025); }
tr:last-child td { border-bottom: none; }
tbody tr:hover td {
  background: var(--primary-l) !important;
}
body.dark-mode tbody tr:hover td { background: var(--sidebar-act) !important; }


/* Quick Actions Styles */
.quick-actions {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 1000;
}

.fab-quick {
  width: 56px;
  height: 56px;
  border-radius: 28px;
  background: linear-gradient(135deg, var(--primary), var(--primary-d));
  color: white;
  border: none;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
  font-size: 24px;
  transition: transform 0.2s;
}

.fab-quick:hover {
  transform: scale(1.1);
}

.quick-menu {
  display: none;
  position: absolute;
  bottom: 70px;
  right: 0;
  background: var(--surface);
  border-radius: 12px;
  padding: 8px;
  min-width: 180px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.2);
  border: 1px solid var(--border);
}

.quick-menu.open {
  display: block;
  animation: fadeInUp 0.2s ease;
}

.quick-menu button {
  display: block;
  width: 100%;
  padding: 10px 16px;
  text-align: right;
  background: none;
  border: none;
  cursor: pointer;
  font-family: var(--font);
  font-size: 13px;
  color: var(--text);
  border-radius: 8px;
}

.quick-menu button:hover {
  background: var(--bg);
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Timeline Styles */
.timeline {
  position: relative;
  padding: 20px 0;
}

.timeline-item {
  position: relative;
  padding: 12px 0 12px 30px;
  border-left: 2px solid var(--border);
  margin-left: 20px;
}

.timeline-item::before {
  content: '';
  position: absolute;
  left: -8px;
  top: 16px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--primary);
  border: 2px solid var(--surface);
}

/* Skeleton Loading */
.skeleton-text {
  height: 16px;
  border-radius: 8px;
  margin: 8px 0;
  background: linear-gradient(90deg, var(--border) 25%, var(--surface) 50%, var(--border) 75%);
  background-size: 200% 100%;
  animation: skeleton-loading 1.5s infinite;
}

@keyframes skeleton-loading {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ── BADGES ──────────────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px 3px 7px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}
.badge::before {
  content: '';
  width: 6px; height: 6px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}
.badge-success {
  background: #DCFCE7; color: #15803D;
  border: 1px solid rgba(21,128,61,0.2);
}
.badge-success::before { background: #15803D; }
.badge-warning {
  background: #FEF3C7; color: #B45309;
  border: 1px solid rgba(180,83,9,0.2);
}
.badge-warning::before { background: #D97706; }
.badge-error {
  background: #FEE2E2; color: #B91C1C;
  border: 1px solid rgba(185,28,28,0.2);
}
.badge-error::before { background: #EF4444; }
.badge-info {
  background: #E6F7F7; color: #0A5A5A;
  border: 1px solid rgba(13,138,138,0.2);
}
.badge-info::before { background: #0D8A8A; }
.badge-gray {
  background: var(--bg); color: var(--text-s);
  border: 1px solid var(--border);
}
.badge-gray::before { background: var(--text-h); }
body.dark-mode .badge-success { background: rgba(16,185,129,0.12); color: #34D399; border-color: rgba(52,211,153,0.2); }
body.dark-mode .badge-warning { background: rgba(245,158,11,0.12); color: #FCD34D; border-color: rgba(252,211,77,0.2); }
body.dark-mode .badge-error   { background: rgba(239,68,68,0.12);  color: #F87171; border-color: rgba(248,113,113,0.2); }
body.dark-mode .badge-info    { background: rgba(13,138,138,0.15); color: #5DCFCF; border-color: rgba(93,207,207,0.2); }

/* ── BUTTONS ─────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 9px 18px; border-radius: 10px;
  font-family: var(--font); font-size: 13px; font-weight: 600;
  cursor: pointer; border: none; transition: all 0.15s;
  white-space: nowrap;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-d); }
.btn-accent  { background: var(--accent); color: #fff; }
.btn-accent:hover { filter: brightness(0.9); }
.btn-outline { background: none; color: var(--primary); border: 1.5px solid var(--primary); }
.btn-outline:hover { background: var(--primary-l); }
.btn-ghost { background: var(--bg); color: var(--text); border: 1px solid var(--border); }
.btn-ghost:hover { background: var(--border); }
.btn-sm { padding: 6px 12px; font-size: 12px; border-radius: 8px; }
.btn-danger { background: var(--error); color: #fff; }
.btn-danger:hover { filter: brightness(0.9); }

/* ── PAGE HEADER ─────────────────────────────────────────────────── */
.page-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 12px;
}
.page-header-title { font-size: 20px; font-weight: 800; }
.page-header-sub { font-size: 13px; color: var(--text-s); margin-top: 2px; }

/* ── MODAL ───────────────────────────────────────────────────────── */
.modal-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 500; align-items: flex-end; justify-content: center;
  backdrop-filter: blur(2px);
}
.modal-overlay.open { display: flex; }
.modal {
  background: var(--surface);
  border-radius: 20px 20px 0 0;
  width: 100%; max-width: 560px;
  max-height: 92vh;
  box-shadow: var(--shadow-lg);
  animation: modalIn 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.modal > .modal-body {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  flex: 1;
  min-height: 0;
}
@keyframes modalIn { from { opacity:0; transform: translateY(40px); } to { opacity:1; transform: translateY(0); } }
.modal-header {
  padding: 16px 20px;
  display: flex; align-items: center; gap: 12px;
  position: sticky; top: 0;
  background: var(--sidebar-bg);
  z-index: 1;
  flex-shrink: 0;
}
.modal-header-icon {
  width: 34px; height: 34px;
  background: rgba(13,138,138,0.35);
  border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
  font-size: 15px;
  flex-shrink: 0;
}
.modal-header h3 { font-size: 15px; font-weight: 700; color: #fff; flex: 1; margin: 0; }
.modal-close {
  width: 30px; height: 30px;
  border-radius: 8px; background: rgba(255,255,255,0.1);
  border: none; cursor: pointer; font-size: 16px;
  display: flex; align-items: center; justify-content: center;
  color: rgba(255,255,255,0.65);
  transition: background 0.15s, color 0.15s;
  flex-shrink: 0;
}
.modal-close:hover { background: rgba(255,255,255,0.18); color: #fff; }
.modal-body { padding: 20px 24px; }
.modal-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  display: flex; gap: 10px; justify-content: flex-end;
  flex-wrap: wrap;
  position: sticky; bottom: 0;
  background: var(--surface);
  flex-shrink: 0;
}
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; color: var(--text); }
.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  font-family: var(--font); font-size: 14px;
  background: var(--bg); color: var(--text);
  outline: none; transition: border-color 0.15s, background 0.2s;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus { border-color: var(--primary); background: var(--surface); }

/* ── LOGIN ───────────────────────────────────────────────────────── */
#login-screen {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh; width: 100%;
  background: linear-gradient(135deg, #0A3D3D 0%, #0D8A8A 100%);
  padding: 16px;
}
.login-box {
  background: #fff;
  border-radius: 20px;
  padding: 36px 32px;
  width: 100%; max-width: 400px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}
.login-logo {
  display: flex; align-items: center; gap: 12px;
  margin-bottom: 28px;
}
.login-logo .icon {
  width: 48px; height: 48px;
  background: var(--primary);
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px;
}
.login-logo .text { font-size: 18px; font-weight: 800; }
.login-logo .sub { font-size: 12px; color: var(--text-s); }
.login-title { font-size: 22px; font-weight: 800; margin-bottom: 6px; }
.login-sub { font-size: 14px; color: var(--text-s); margin-bottom: 24px; }

/* ── MISC ────────────────────────────────────────────────────────── */
.flex { display: flex; }
.items-center { align-items: center; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.ml-auto { margin-right: auto; }
.text-s { color: var(--text-s); font-size: 13px; }
.text-xs { font-size: 11px; }
.fw-700 { font-weight: 700; }
.mb-4 { margin-bottom: 16px; }
.mt-4 { margin-top: 16px; }
.tag {
  font-size: 10px; font-weight: 700;
  padding: 2px 8px; border-radius: 20px;
  background: var(--primary-l); color: var(--primary);
  white-space: nowrap;
}
.avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--primary-l);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 13px; color: var(--primary);
  flex-shrink: 0;
}
.progress {
  height: 6px; background: var(--border); border-radius: 3px; overflow: hidden;
}
.progress-bar { height: 100%; border-radius: 3px; background: var(--primary); }
.empty-state {
  text-align: center; padding: 48px 24px; color: var(--text-s);
}
.empty-state .icon { font-size: 48px; margin-bottom: 12px; opacity: 0.4; }
.empty-state p { font-size: 14px; }
.alert {
  padding: 12px 16px; border-radius: 10px;
  font-size: 13px; margin-bottom: 16px;
  display: flex; align-items: center; gap: 8px;
}
.alert-success { background: #DCFCE7; color: #15803D; }
.alert-error   { background: #FEE2E2; color: #B91C1C; }

/* ── API URL BAR ─────────────────────────────────────────────────── */
.api-bar {
  background: #0A3D3D;
  color: #a8d8ff;
  font-family: var(--mono);
  font-size: 12px;
  padding: 8px 16px;
  border-radius: 8px;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  word-break: break-all;
}
.api-bar .method {
  background: var(--success);
  color: #fff;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 700;
  flex-shrink: 0;
}
.api-bar .method.post { background: var(--accent); }
.api-bar .method.put  { background: var(--warning); }
.api-bar .method.del  { background: var(--error); }

/* ── PULL TO REFRESH ─────────────────────────────────────────────── */
.ptr-indicator {
  position: fixed;
  top: 64px; left: 50%;
  transform: translateX(-50%) translateY(-60px);
  background: var(--primary);
  color: #fff;
  padding: 8px 16px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  z-index: 199;
  transition: transform 0.3s;
  pointer-events: none;
  display: none;
  white-space: nowrap;
}
.ptr-indicator.show { display: block; transform: translateX(-50%) translateY(8px); }

/* ── RESPONSIVE ──────────────────────────────────────────────────── */
@media (max-width: 1024px) {
  .charts-grid { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
  :root { --bottom-nav-h: 68px; }

  /* Sidebar: hidden off-screen to the RIGHT (RTL — sidebar is on the right) */
  .sidebar {
    transform: translateX(100%); /* push it off-screen to the right */
    box-shadow: none;
  }
  .sidebar.open {
    transform: translateX(0);   /* slide it back in from the right */
    box-shadow: -4px 0 24px rgba(0,0,0,0.35);
  }

  .main { margin-right: 0 !important; }
  .menu-toggle { display: flex; }
  .topbar { padding: 0 14px; height: 56px; }
  .topbar-title { font-size: 15px; }
  .topbar-search { display: none; }

  .bottom-nav { display: block; }

  .page { padding: 14px; padding-bottom: calc(var(--bottom-nav-h) + 20px); }

  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
  }
  .stat-card { padding: 12px 12px 10px; }
  .stat-icon { width: 38px; height: 38px; font-size: 16px; border-radius: 9px; }
  .stat-value { font-size: 22px; }

  .charts-grid { grid-template-columns: 1fr; gap: 12px; }
  .card { padding: 14px; }

  #page-dashboard > div:last-child { grid-template-columns: 1fr !important; }

  .page-header { margin-bottom: 14px; }
  .page-header-title { font-size: 17px; }

  /* Modal as bottom sheet */
  .modal-overlay { align-items: flex-end; }
  .modal {
    border-radius: 20px 20px 0 0;
    max-height: 90vh;
    max-width: 100%;
  }
  .modal-footer { flex-direction: column; }
  .modal-footer .btn { width: 100%; justify-content: center; }

  /* Tables scroll nicely */
  table { min-width: 550px; }
  th, td { padding: 9px 11px; font-size: 12px; }

  /* Hide extra topbar buttons, keep dark + notif */
  .topbar-btn { display: none; }
  .topbar-btn.menu-toggle,
  .topbar-btn.topbar-notif,
  .topbar-btn.topbar-dark { display: flex; }
}

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .stat-value { font-size: 20px; letter-spacing: -0.5px; }
  .stat-label { font-size: 11px; }
  .stat-card-footer { gap: 4px; }
  .page-header { flex-direction: column; align-items: flex-start; }
  .page-header .flex { width: 100%; }
  .page-header .btn { flex: 1; justify-content: center; font-size: 12px; padding: 8px 10px; }
  #page-users .card.mb-4 { flex-direction: column; }
  #user-search { width: 100%; }
}

/* ── DASHBOARD NEW WIDGETS ────────────────────────────────────────── */
.dash-alert-item {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 14px; border-radius: 10px;
  font-size: 13px; font-weight: 500; margin-bottom: 8px;
  cursor: pointer; transition: filter 0.15s;
}
.dash-alert-item:hover { filter: brightness(0.96); }
.dash-alert-item:last-child { margin-bottom: 0; }
.dash-alert-item .alert-time { margin-right: auto; font-size: 11px; opacity: 0.7; font-weight: 400; }
.dash-alert-danger { background:#FEE2E2; color:#991B1B; border:1px solid rgba(185,28,28,0.15); }
.dash-alert-warn   { background:#FEF3C7; color:#92400E; border:1px solid rgba(180,83,9,0.15); }
.dash-alert-info   { background:#EFF6FF; color:#1E40AF; border:1px solid rgba(30,64,175,0.15); }
body.dark-mode .dash-alert-danger { background:rgba(239,68,68,0.12); color:#FCA5A5; border-color:rgba(252,165,165,0.15); }
body.dark-mode .dash-alert-warn   { background:rgba(245,158,11,0.12); color:#FCD34D; border-color:rgba(252,211,77,0.15); }
body.dark-mode .dash-alert-info   { background:rgba(13,138,138,0.15); color:#5DCFCF; border-color:rgba(93,207,207,0.2); }

.dash-feed-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 9px 0; border-bottom: 1px solid var(--border);
}
.dash-feed-item:last-child { border-bottom: none; }
.dash-feed-title { font-size: 13px; font-weight: 600; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; max-width:200px; }
.dash-feed-meta  { font-size: 11px; color: var(--text-s); margin-top: 2px; }

.heat-grid { display:grid; grid-template-columns:repeat(10,1fr); gap:4px; }
.heat-cell {
  height: 14px; border-radius: 3px;
  background: var(--border);
  transition: transform 0.1s;
  cursor: default;
}
.heat-cell:hover { transform: scale(1.3); }
.heat-0 { background: var(--border); }
.heat-1 { background: #B2E8E8; }
.heat-2 { background: #4DBFBF; }
.heat-3 { background: #0D8A8A; }
.heat-4 { background: #0A5A5A; }
body.dark-mode .heat-1 { background: #0A3030; }
body.dark-mode .heat-2 { background: #0A5050; }
body.dark-mode .heat-3 { background: #0D8A8A; }
body.dark-mode .heat-4 { background: #3DBFBF; }

.top-user-row {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 0; border-bottom: 1px solid var(--border);
}
.top-user-row:last-child { border-bottom: none; }
.top-user-av {
  width: 32px; height: 32px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 12px; flex-shrink: 0;
}
.top-section-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 9px 0; border-bottom: 1px solid var(--border);
}
.top-section-row:last-child { border-bottom: none; }
.section-rank {
  width: 20px; height: 20px; border-radius: 50%;
  background: var(--primary-l); color: var(--primary);
  font-size: 10px; font-weight: 800;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.week-cal-grid {
  display: grid; grid-template-columns: repeat(7,1fr); gap: 6px; margin-top: 8px;
}
.week-cal-day { text-align: center; }
.week-cal-lbl { font-size: 10px; color: var(--text-s); margin-bottom: 4px; font-weight: 500; }
.week-cal-num {
  border-radius: 8px; padding: 6px 2px;
  font-size: 13px; font-weight: 700;
  background: var(--bg); color: var(--text);
  transition: transform 0.15s;
}
.week-cal-num:hover { transform: scale(1.1); }
.week-cal-num.today { background: var(--primary); color: #fff; }
.week-cal-num.busy  { background: var(--primary-l); color: var(--primary); }
.week-cal-num.empty { opacity: 0.4; }

.conv-ring {
  position: relative; width: 80px; height: 80px; margin: 8px auto;
}
.conv-ring svg { transform: rotate(-90deg); }
.conv-ring-label {
  position: absolute; top: 50%; left: 50%;
  transform: translate(-50%,-50%);
  font-size: 18px; font-weight: 800; color: var(--text);
}

.rating-mini-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 8px;
}
.rating-mini-cell {
  background: var(--bg); border-radius: 8px; padding: 8px;
  text-align: center;
}
.rating-mini-val { font-size: 16px; font-weight: 700; }
.rating-mini-lbl { font-size: 10px; color: var(--text-s); margin-top: 2px; }

.rev-main { font-size: 28px; font-weight: 800; letter-spacing:-1px; color: var(--accent); }
.rev-sub  { font-size: 12px; color: var(--text-s); margin-top:3px; }
.rev-row  { display:flex; justify-content:space-between; font-size:12px; margin-top:6px; padding-top:6px; border-top:1px solid var(--border); }

@media (max-width: 768px) {
  #page-dashboard > div:nth-child(4) { grid-template-columns: 1fr !important; }
  #page-dashboard > div:nth-child(5) { grid-template-columns: 1fr !important; }
  #page-dashboard > div:nth-child(6) { grid-template-columns: 1fr !important; }
}


.search-highlight { background: #FEF08A; border-radius: 2px; padding: 0 2px; }

/* ── CONFIRM DIALOG ──────────────────────────────────────────────── */
.confirm-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 9000; align-items: center; justify-content: center;
  padding: 16px;
}
.confirm-overlay.open { display: flex; }
.confirm-box {
  background: var(--surface);
  border-radius: 18px;
  padding: 28px 24px;
  max-width: 340px; width: 100%;
  text-align: center;
  box-shadow: var(--shadow-lg);
  animation: modalIn 0.2s ease;
}
.confirm-box .confirm-icon { font-size: 44px; margin-bottom: 12px; }
.confirm-box h3 { font-size: 17px; font-weight: 700; margin-bottom: 8px; }
.confirm-box p { font-size: 13px; color: var(--text-s); margin-bottom: 20px; line-height: 1.6; }
.confirm-btns { display: flex; gap: 10px; }
.confirm-btns .btn { flex: 1; justify-content: center; }

/* Loading spinner */
.spinner {
  display: inline-block;
  width: 18px; height: 18px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  flex-shrink: 0;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Fab button (mobile only) */
.fab {
  display: none;
  position: fixed;
  bottom: calc(var(--bottom-nav-h) + 16px);
  left: 16px;
  width: 52px; height: 52px;
  background: var(--primary);
  color: #fff;
  border-radius: 16px;
  font-size: 24px;
  align-items: center; justify-content: center;
  box-shadow: 0 4px 16px rgba(13,138,138,0.4);
  cursor: pointer;
  z-index: 199;
  border: none;
  font-family: var(--font);
  transition: transform 0.15s;
}
.fab:active { transform: scale(0.95); }
@media (max-width: 768px) { .fab { display: flex; } }


.imgs-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(76px,1fr));gap:8px;margin-top:10px}
.imgs-grid-item{position:relative;aspect-ratio:1;border-radius:8px;overflow:hidden}
.imgs-grid-item img{width:100%;height:100%;object-fit:cover}
.imgs-grid-item .del-img-btn{position:absolute;top:3px;left:3px;background:rgba(239,68,68,.9);color:#fff;border:none;border-radius:50%;width:20px;height:20px;font-size:12px;cursor:pointer;line-height:1;display:flex;align-items:center;justify-content:center}

/* ── IMAGE UPLOAD ─────────────────────────────────────────────────── */
.img-upload-area{border:2px dashed var(--border);border-radius:10px;padding:20px;text-align:center;cursor:pointer;transition:border-color .2s;background:var(--bg);margin-top:6px}
.img-upload-area:hover{border-color:var(--primary)}
.img-upload-area input[type=file]{display:none}
.img-preview{width:100%;height:160px;object-fit:cover;border-radius:10px;margin-top:10px;display:none;border:1px solid var(--border)}

/* ── SKELETON LOADING ─────────────────────────────────────────────── */
.skel { background: linear-gradient(90deg, var(--border) 25%, var(--bg) 50%, var(--border) 75%); background-size: 200% 100%; animation: shimmer 1.4s infinite; border-radius: 8px; }
@keyframes shimmer { from{background-position:200% 0} to{background-position:-200% 0} }
.skel-line { height: 14px; border-radius: 6px; margin-bottom: 8px; }
.skel-title { height: 18px; width: 60%; border-radius: 6px; margin-bottom: 12px; }
.skel-card { height: 90px; border-radius: var(--radius); }

/* ── GLOBAL SEARCH OVERLAY ────────────────────────────────────────── */
#search-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,0.55); z-index: 9000;
  align-items: flex-start; justify-content: center;
  padding-top: 80px; backdrop-filter: blur(4px);
}
#search-overlay.open { display: flex; }
.search-modal {
  background: var(--surface); border-radius: 16px; width: 100%; max-width: 580px;
  box-shadow: 0 24px 60px rgba(0,0,0,0.25); overflow: hidden;
  animation: modalIn 0.2s ease;
}
.search-input-wrap {
  display: flex; align-items: center; gap: 12px;
  padding: 16px 20px; border-bottom: 1px solid var(--border);
}
.search-input-wrap input {
  flex: 1; border: none; background: none; outline: none;
  font-family: var(--font); font-size: 17px; color: var(--text);
}
.search-input-wrap .search-kbd { background: var(--bg); border: 1px solid var(--border); border-radius: 6px; padding: 2px 7px; font-size: 11px; color: var(--text-s); }
#search-results { max-height: 420px; overflow-y: auto; padding: 8px 0; }
.search-result-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 20px; cursor: pointer; transition: background 0.1s;
}
.search-result-item:hover { background: var(--bg); }
.search-result-icon { width: 36px; height: 36px; border-radius: 8px; background: var(--primary-l); display: flex; align-items: center; justify-content: center; font-size: 16px; flex-shrink: 0; }
.search-result-title { font-size: 14px; font-weight: 600; }
.search-result-type { font-size: 11px; color: var(--text-s); margin-top: 1px; }
.search-empty { padding: 32px; text-align: center; color: var(--text-s); font-size: 14px; }
.search-section-header { font-size: 10px; font-weight: 700; color: var(--text-h); letter-spacing: 1px; text-transform: uppercase; padding: 8px 20px 4px; }

/* ── NOTIFICATION PANEL ───────────────────────────────────────────── */
#notif-panel {
  position: fixed; top: 64px; left: 16px;
  width: 420px; max-height: 82vh;
  background: var(--surface); border-radius: 16px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.2);
  z-index: 400; display: none; flex-direction: column;
  border: 1px solid var(--border);
  animation: modalIn 0.2s ease;
  overflow: hidden;
}
#notif-panel.open { display: flex; }
.notif-panel-head {
  padding: 16px 18px 12px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 8px;
  flex-shrink: 0;
}
.notif-panel-head h3 { font-size: 15px; font-weight: 700; flex: 1; }
.notif-tabs { display: flex; gap: 4px; padding: 8px 14px; border-bottom: 1px solid var(--border); flex-shrink: 0; }
.notif-tab { padding: 5px 12px; border-radius: 20px; font-size: 12px; font-weight: 600; cursor: pointer; color: var(--text-s); transition: all 0.15s; border: none; background: none; font-family: var(--font); }
.notif-tab.active { background: var(--primary-l); color: var(--primary); }
#notif-list { overflow-y: auto; flex: 1; }
.notif-item {
  display: flex; gap: 12px; padding: 12px 16px;
  border-bottom: 1px solid var(--border); cursor: pointer;
  transition: background 0.1s; position: relative;
}
.notif-item:hover { background: var(--bg); }
.notif-item.unread { background: var(--primary-l); }
.notif-item.unread::before { content:''; position:absolute; right:0; top:50%; transform:translateY(-50%); width:4px; height:60%; background:var(--primary); border-radius:2px 0 0 2px; }
.notif-avatar { width: 38px; height: 38px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 17px; flex-shrink: 0; background: var(--bg); }
.notif-content { flex: 1; min-width: 0; }
.notif-title { font-size: 13px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.notif-body { font-size: 12px; color: var(--text-s); margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.notif-time { font-size: 10px; color: var(--text-h); margin-top: 4px; }
.notif-panel-footer { padding: 12px 16px; border-top: 1px solid var(--border); display: flex; gap: 8px; flex-shrink: 0; }

/* ── SEND NOTIFICATION MODAL ──────────────────────────────────────── */
.notif-target-btn {
  flex: 1; padding: 10px 8px; border-radius: 10px; border: 2px solid var(--border);
  background: var(--bg); cursor: pointer; text-align: center;
  font-family: var(--font); font-size: 12px; font-weight: 600; color: var(--text-s);
  transition: all 0.15s;
}
.notif-target-btn.selected { border-color: var(--primary); background: var(--primary-l); color: var(--primary); }
.notif-target-btn .icon { font-size: 20px; display: block; margin-bottom: 4px; }
.notif-preview { background: var(--sidebar-bg); border-radius: 12px; padding: 14px 16px; color: #fff; margin-top: 8px; }
.notif-preview-title { font-size: 13px; font-weight: 700; margin-bottom: 3px; }
.notif-preview-body { font-size: 12px; opacity: 0.75; }

/* ── EXPORT BUTTON ────────────────────────────────────────────────── */
.btn-export { background: var(--bg); color: var(--text-s); border: 1px solid var(--border); }
.btn-export:hover { background: var(--primary-l); color: var(--primary); border-color: var(--primary); }

/* ── KEYBOARD SHORTCUTS ───────────────────────────────────────────── */
#kbd-hint {
  position: fixed; bottom: calc(var(--bottom-nav-h) + 8px); left: 50%;
  transform: translateX(-50%);
  background: var(--sidebar-bg); color: rgba(255,255,255,0.55);
  padding: 6px 14px; border-radius: 20px; font-size: 11px;
  z-index: 100; pointer-events: none; opacity: 0;
  transition: opacity 0.3s; white-space: nowrap;
}
#kbd-hint.show { opacity: 1; }
.kbd { display: inline-block; background: rgba(255,255,255,0.15); border-radius: 4px; padding: 1px 5px; margin: 0 2px; font-size: 10px; }

/* ── AUDIT LOG ────────────────────────────────────────────────────── */
.audit-row { display: flex; align-items: center; gap: 12px; padding: 10px 14px; border-bottom: 1px solid var(--border); }
.audit-row:last-child { border-bottom: none; }
.audit-action { font-size: 10px; font-weight: 700; padding: 2px 8px; border-radius: 20px; white-space: nowrap; flex-shrink: 0; }
.audit-create { background: #DCFCE7; color: #15803D; }
.audit-update { background: #E6F7F7; color: var(--primary); }
.audit-delete { background: #FEE2E2; color: #B91C1C; }
.audit-login  { background: #FEF3C7; color: #B45309; }

/* ── EMPTY STATES IMPROVED ────────────────────────────────────────── */
.empty-state-pro {
  display: flex; flex-direction: column; align-items: center;
  padding: 48px 24px; text-align: center; color: var(--text-s);
}
.empty-state-pro .es-icon { font-size: 52px; margin-bottom: 14px; opacity: 0.45; }
.empty-state-pro .es-title { font-size: 15px; font-weight: 700; color: var(--text); margin-bottom: 6px; }
.empty-state-pro .es-sub { font-size: 13px; margin-bottom: 18px; }

/* ── BULK SELECT ──────────────────────────────────────────────────── */
.bulk-toolbar {
  display: none; align-items: center; gap: 10px;
  padding: 10px 16px; background: var(--primary); color: #fff;
  border-radius: var(--radius) var(--radius) 0 0;
  font-size: 13px; font-weight: 600;
}
.bulk-toolbar.show { display: flex; }
.bulk-toolbar .btn { background: rgba(255,255,255,0.2); color: #fff; border: none; font-size: 12px; padding: 6px 12px; }
.bulk-toolbar .btn:hover { background: rgba(255,255,255,0.3); }

/* ── AI Assistant ───────────────────────────────────────────── */
.ai-fab {
  position: fixed; left: 24px; bottom: 24px; z-index: 1200;
  width: 52px; height: 52px; border-radius: 50%;
  background: linear-gradient(135deg, #0A3D3D, #0D8A8A);
  color: #fff; border: none; cursor: pointer;
  box-shadow: 0 4px 16px rgba(13,138,138,0.4);
  display: flex; align-items: center; justify-content: center;
  font-size: 22px; transition: transform .2s, box-shadow .2s;
}
.ai-fab:hover { transform: scale(1.1); box-shadow: 0 6px 20px rgba(13,138,138,0.5); }
.ai-panel {
  position: fixed; left: 24px; bottom: 88px; z-index: 1199;
  width: 360px; max-height: 500px;
  background: var(--card); border: 1px solid var(--border);
  border-radius: 16px; display: flex; flex-direction: column;
  box-shadow: 0 8px 32px rgba(0,0,0,0.15);
  display: none; overflow: hidden;
}
.ai-panel.open { display: flex; }
.ai-panel-head {
  padding: 14px 16px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 10px;
  background: linear-gradient(135deg, #0A3D3D, #0D8A8A); color: #fff;
}
.ai-panel-head .ai-title { font-size: 14px; font-weight: 700; flex: 1; }
.ai-panel-head .ai-close { background: none; border: none; color: #fff; cursor: pointer; font-size: 18px; padding: 0; }
.ai-messages {
  flex: 1; overflow-y: auto; padding: 14px; display: flex;
  flex-direction: column; gap: 10px; min-height: 200px; max-height: 340px;
}
.ai-msg { display: flex; gap: 8px; align-items: flex-start; }
.ai-msg.user { flex-direction: row-reverse; }
.ai-avatar {
  width: 28px; height: 28px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700;
}
.ai-msg.bot  .ai-avatar { background: var(--primary-l); color: var(--primary); }
.ai-msg.user .ai-avatar { background: #E8F4F8; color: #0A6E6E; }
.ai-bubble {
  max-width: 260px; padding: 8px 12px; border-radius: 12px;
  font-size: 13px; line-height: 1.6; direction: rtl;
}
.ai-msg.bot  .ai-bubble { background: var(--bg); border: 1px solid var(--border); color: var(--text); border-radius: 4px 12px 12px 12px; }
.ai-msg.user .ai-bubble { background: var(--primary); color: #fff; border-radius: 12px 4px 12px 12px; }
.ai-typing { display: flex; gap: 4px; align-items: center; padding: 4px 0; }
.ai-typing span { width: 7px; height: 7px; border-radius: 50%; background: var(--text-s); animation: aiDot 1.2s infinite; }
.ai-typing span:nth-child(2) { animation-delay: .2s; }
.ai-typing span:nth-child(3) { animation-delay: .4s; }
@keyframes aiDot { 0%,80%,100%{transform:scale(.7);opacity:.5} 40%{transform:scale(1);opacity:1} }
.ai-input-row {
  padding: 10px 12px; border-top: 1px solid var(--border);
  display: flex; gap: 8px; align-items: center;
}
.ai-input-row input {
  flex: 1; border: 1px solid var(--border); border-radius: 8px;
  padding: 8px 12px; font-family: var(--font); font-size: 13px;
  background: var(--bg); color: var(--text); direction: rtl;
}
.ai-input-row input:focus { outline: none; border-color: var(--primary); }
.ai-send-btn {
  background: var(--primary); color: #fff; border: none;
  border-radius: 8px; width: 34px; height: 34px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; flex-shrink: 0; transition: opacity .15s;
}
.ai-send-btn:disabled { opacity: .5; cursor: default; }
.ai-suggestions { padding: 0 12px 10px; display: flex; flex-wrap: wrap; gap: 6px; }
.ai-chip {
  font-size: 11px; padding: 4px 10px; border-radius: 20px;
  border: 1px solid var(--border); background: var(--bg);
  color: var(--text-s); cursor: pointer; transition: all .15s; direction: rtl;
}
.ai-chip:hover { border-color: var(--primary); color: var(--primary); }


/* ── HTML Editor Toolbar ─────────────────────────────────────────────────── */
.html-editor-toolbar {
  display: flex; gap: 6px; flex-wrap: wrap;
  padding: 8px 12px; background: var(--bg);
  border: 1px solid var(--border); border-bottom: none;
  border-radius: var(--radius) var(--radius) 0 0;
}
.html-editor-toolbar button {
  padding: 4px 10px; border: 1px solid var(--border);
  border-radius: 6px; background: #fff; cursor: pointer;
  font-size: 12px; font-family: var(--font); color: var(--text);
}
.html-editor-toolbar button:hover { background: var(--primary); color: #fff; border-color: var(--primary); }
/* ── Analytics Tab Buttons ───────────────────────────────────────────────── */
.analytics-tab-btn {
  padding: 7px 14px; border: 1px solid var(--border);
  border-radius: 8px; background: #fff; cursor: pointer;
  font-family: var(--font); font-size: 13px; color: var(--text-s);
}
.analytics-tab-btn.active { background: var(--primary); color: #fff; border-color: var(--primary); }
/* ── Place Image ─────────────────────────────────────────────────────────── */
.place-img { width: 44px; height: 44px; border-radius: 8px; object-fit: cover; background: var(--bg); }

/* ═══════════════════════════════════════════════════════════════════════ */
/* MOBILE UX IMPROVEMENTS - أضف هذا القسم قبل                */
/* ═══════════════════════════════════════════════════════════════════════ */

/* تحسين اللمس للأزرار */
@media (max-width: 768px) {
  .btn, .nav-item, .bottom-nav-item, .stat-card, .modal-footer button, .table-wrap button {
    min-height: 44px;
    min-width: 44px;
  }
  
  .table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  
  .modal .modal-body {
    padding: 12px;
    max-height: 60vh;
  }
  
  .form-group input, .form-group select, .form-group textarea {
    font-size: 16px !important;
    padding: 12px 14px;
  }
  
  .scroll-top-btn {
    position: fixed;
    bottom: calc(var(--bottom-nav-h) + 16px);
    right: 16px;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    border: none;
    box-shadow: 0 2px 12px rgba(0,0,0,0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 200;
    opacity: 0;
    transition: opacity 0.3s;
    font-size: 20px;
  }
  
  .scroll-top-btn.visible { opacity: 1; }
  
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
  }
  
  .stat-card { padding: 12px; }
  .stat-value { font-size: 20px; }
  
  .topbar-search { display: none; }
  
  .mobile-search-btn {
    display: flex;
    width: 44px;
    height: 44px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 10px;
    align-items: center;
    justify-content: center;
    cursor: pointer;
  }
  
  .fab {
    width: 56px;
    height: 56px;
    border-radius: 28px;
    bottom: calc(var(--bottom-nav-h) + 16px);
    left: 16px;
    font-size: 24px;
  }
  
  #notif-panel {
    width: calc(100% - 32px);
    left: 16px;
    right: 16px;
    top: auto;
    bottom: calc(var(--bottom-nav-h) + 16px);
    max-height: 70vh;
    border-radius: 16px;
  }
  
  #search-overlay { padding-top: 60px; }
  
  .search-modal {
    margin: 0 16px;
    width: calc(100% - 32px);
  }
  
  .stat-card:hover { transform: none; }
  .btn:hover { transform: none; }
}

/* مؤشر حالة الاتصال */
.connection-status {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  background: #F59E0B;
  color: #fff;
  text-align: center;
  padding: 8px;
  font-size: 12px;
  z-index: 10000;
  transform: translateY(-100%);
  transition: transform 0.3s;
}

.connection-status.show { transform: translateY(0); }
.connection-status.retrying { background: #F59E0B; }
.connection-status.offline { background: #EF4444; }
.connection-status.online { background: #10B981; transform: translateY(-100%); }

/* إعادة تعيين الـ Checkbox الافتراضية */
input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  width: 20px;
  height: 20px;
  min-width: 20px;
  min-height: 20px;
  background: var(--bg);
  border: 2px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
  position: relative;
  transition: all 0.2s ease;
  pointer-events: none;
  margin: 0;
  padding: 0;
}

/* حالة hover */
input[type="checkbox"]:hover {
  border-color: var(--primary);
  background: var(--primary-l);
}
/* checkboxes الأخبار — تفعيل الضغط (تغلب على pointer-events:none العام) */
.news-row-check, #news-select-all, .media-check,
.da-wd, .dire-wd, .ma-wday, .me-wday, .place-wd, .r-wd, .re-wd,
.ad-checkbox { pointer-events: auto !important; cursor: pointer; }

/* حالة التأشير (checked) */
input[type="checkbox"]:checked {
  background: var(--primary);
  border-color: var(--primary);
}

/* علامة الصح */
input[type="checkbox"]:checked::after {
  content: "✓";
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: white;
  font-size: 13px;
  font-weight: bold;
}

/* حالة التركيز (للوصولية) */
input[type="checkbox"]:focus {
  outline: none;
  box-shadow: 0 0 0 3px rgba(13, 138, 138, 0.3);
  border-color: var(--primary);
}

/* تعطيل الـ Checkbox */
input[type="checkbox"]:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Checkbox كبير الحجم (للصفحات الرئيسية) */
.checkbox-lg {
  width: 24px !important;
  height: 24px !important;
  min-width: 24px !important;
  min-height: 24px !important;
}

.checkbox-lg:checked::after {
  font-size: 16px !important;
}

/* Checkbox صغير الحجم للجداول */
.checkbox-sm {
  width: 16px !important;
  height: 16px !important;
  min-width: 16px !important;
  min-height: 16px !important;
}

.checkbox-sm:checked::after {
  font-size: 10px !important;
}

/* مجموعة Checkbox مع تسميات */
.checkbox-group {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  user-select: none;
}

.checkbox-group span {
  font-size: 13px;
  color: var(--text);
}

/* تحسين الـ Checkbox في الموبايل */
@media (max-width: 768px) {
  input[type="checkbox"] {
    width: 22px;
    height: 22px;
    min-width: 22px;
    min-height: 22px;
  }
  
  .checkbox-group span {
    font-size: 14px;
  }
}

/* لون مختلف لـ Checkbox التحذير (مثل حذف نهائي) */
.checkbox-danger:checked {
  background: var(--error);
  border-color: var(--error);
}

/* Checkbox على شكل دائري (radio style) */
.checkbox-round {
  border-radius: 50%;
}

.checkbox-round:checked::after {
  content: "";
  width: 8px;
  height: 8px;
  background: white;
  border-radius: 50%;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}

