/* ============================================================
   ToGo Admin Panel - Global Styles
   ============================================================ */

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

:root {
  --primary: #FF6B35;
  --primary-dark: #e85a26;
  --primary-light: rgba(255, 107, 53, 0.12);
  --secondary: #2D3748;
  --success: #48BB78;
  --danger: #F56565;
  --warning: #ECC94B;
  --info: #4299E1;
  --bg: #0F1117;
  --surface: #1A1D2E;
  --surface2: #252840;
  --border: rgba(255,255,255,0.08);
  --text: #E2E8F0;
  --text-muted: #718096;
  --radius: 12px;
  --shadow: 0 4px 24px rgba(0,0,0,0.4);
  --sidebar-width: 260px;
  --header-height: 64px;
}

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

html { font-size: 15px; direction: rtl; }

body {
  font-family: 'Cairo', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
}

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

/* ── Links ── */
a { color: var(--primary); text-decoration: none; }
a:hover { opacity: 0.85; }

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

/* ── Sidebar ── */
.sidebar {
  width: var(--sidebar-width);
  background: var(--surface);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  right: 0;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  z-index: 100;
  transition: transform 0.3s;
}

.sidebar-brand {
  padding: 20px 20px 16px;
  border-bottom: 1px solid var(--border);
}

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

.sidebar-brand .logo img {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  object-fit: cover;
}

.sidebar-brand h1 {
  font-size: 1.2rem;
  font-weight: 800;
  color: var(--primary);
}

.sidebar-brand small {
  font-size: 0.7rem;
  color: var(--text-muted);
  display: block;
}

.sidebar-nav { padding: 12px 0; flex: 1; }

.nav-group { margin-bottom: 4px; }

.nav-group-title {
  padding: 8px 20px 4px;
  font-size: 0.65rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1.2px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 20px;
  color: var(--text-muted);
  font-size: 0.88rem;
  font-weight: 500;
  transition: all 0.2s;
  border-radius: 0;
  position: relative;
  cursor: pointer;
}

.nav-item:hover, .nav-item.active {
  background: var(--primary-light);
  color: var(--primary);
}

.nav-item.active::before {
  content: '';
  position: absolute;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 70%;
  background: var(--primary);
  border-radius: 3px 0 0 3px;
}

.nav-item .icon { font-size: 1.1rem; min-width: 20px; text-align: center; }

.nav-badge {
  margin-right: auto;
  background: var(--danger);
  color: white;
  font-size: 0.65rem;
  padding: 1px 6px;
  border-radius: 20px;
  font-weight: 700;
}

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

/* ── Header ── */
.header {
  height: var(--header-height);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 50;
}

.header-title { font-size: 1.1rem; font-weight: 700; }
.header-right { display: flex; align-items: center; gap: 12px; }

.header-user {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface2);
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 0.85rem;
}

.header-user .avatar {
  width: 30px;
  height: 30px;
  background: var(--primary);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 700;
  color: white;
}

.header-btn {
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 7px 14px;
  border-radius: 8px;
  font-size: 0.82rem;
  cursor: pointer;
  font-family: 'Cairo', sans-serif;
  transition: all 0.2s;
}
.header-btn:hover { background: var(--danger); color: white; border-color: transparent; }

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

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}

.page-header h2 { font-size: 1.4rem; font-weight: 700; }
.page-header p { color: var(--text-muted); font-size: 0.85rem; margin-top: 2px; }

/* ── Stats Cards ── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  transition: transform 0.2s, box-shadow 0.2s;
}

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

.stat-card .stat-icon {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  margin-bottom: 12px;
}

.stat-card .stat-value {
  font-size: 1.8rem;
  font-weight: 800;
  line-height: 1;
}

.stat-card .stat-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 4px;
}

.stat-card .stat-change {
  font-size: 0.75rem;
  margin-top: 8px;
  display: flex;
  align-items: center;
  gap: 4px;
}

/* ── Tables ── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

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

.card-header h3 { font-size: 1rem; font-weight: 700; }
.card-body { padding: 20px; }

.table-container { overflow-x: auto; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

thead th {
  background: var(--surface2);
  padding: 12px 14px;
  text-align: right;
  font-weight: 700;
  color: var(--text-muted);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  white-space: nowrap;
}

tbody td {
  padding: 13px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: rgba(255,255,255,0.02); }

/* ── Badges ── */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 0.72rem;
  font-weight: 700;
  white-space: nowrap;
}

.badge-success  { background: rgba(72,187,120,0.15); color: var(--success); }
.badge-danger   { background: rgba(245,101,101,0.15); color: var(--danger); }
.badge-warning  { background: rgba(236,201,75,0.15); color: var(--warning); }
.badge-info     { background: rgba(66,153,225,0.15); color: var(--info); }
.badge-primary  { background: var(--primary-light); color: var(--primary); }
.badge-secondary{ background: rgba(255,255,255,0.08); color: var(--text-muted); }

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  font-family: 'Cairo', sans-serif;
  transition: all 0.2s;
  text-decoration: none;
  white-space: nowrap;
}

.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-dark); color: white; }
.btn-success { background: var(--success); color: white; }
.btn-success:hover { opacity: 0.88; }
.btn-danger  { background: var(--danger); color: white; }
.btn-danger:hover { opacity: 0.88; }
.btn-warning { background: var(--warning); color: #1a1a1a; }
.btn-info    { background: var(--info); color: white; }
.btn-ghost   { background: var(--surface2); color: var(--text); border: 1px solid var(--border); }
.btn-ghost:hover { border-color: var(--primary); color: var(--primary); }
.btn-sm { padding: 5px 10px; font-size: 0.78rem; }

/* ── Forms ── */
.form-group { margin-bottom: 16px; }

.form-group label {
  display: block;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.form-control {
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  padding: 10px 14px;
  font-family: 'Cairo', sans-serif;
  font-size: 0.88rem;
  transition: border-color 0.2s;
  outline: none;
}

.form-control:focus { border-color: var(--primary); }

select.form-control option { background: var(--surface2); }

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

/* ── Alerts ── */
.alert {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 14px 18px;
  border-radius: 8px;
  margin-bottom: 16px;
  font-size: 0.88rem;
}

.alert-success { background: rgba(72,187,120,0.1); border: 1px solid rgba(72,187,120,0.3); color: var(--success); }
.alert-danger  { background: rgba(245,101,101,0.1); border: 1px solid rgba(245,101,101,0.3); color: var(--danger); }
.alert-warning { background: rgba(236,201,75,0.1);  border: 1px solid rgba(236,201,75,0.3);  color: var(--warning); }
.alert-info    { background: rgba(66,153,225,0.1);  border: 1px solid rgba(66,153,225,0.3);  color: var(--info); }

/* ── Search & Filters ── */
.filters-bar {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 20px;
}

.filters-bar .form-control { flex: 1; min-width: 180px; }

/* ── Pagination ── */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 16px 0;
}

.pagination a, .pagination span {
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 600;
  background: var(--surface2);
  color: var(--text-muted);
  border: 1px solid var(--border);
  transition: all 0.2s;
}

.pagination a:hover { border-color: var(--primary); color: var(--primary); }
.pagination .active { background: var(--primary); color: white; border-color: var(--primary); }

/* ── Login Page ── */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  position: relative;
  overflow: hidden;
}

.login-page::before {
  content: '';
  position: absolute;
  top: -50%;
  right: -20%;
  width: 600px;
  height: 600px;
  background: radial-gradient(circle, rgba(255,107,53,0.08) 0%, transparent 70%);
  pointer-events: none;
}

.login-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 40px;
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow);
  position: relative;
}

.login-logo {
  text-align: center;
  margin-bottom: 30px;
}

.login-logo .icon {
  width: 70px;
  height: 70px;
  background: var(--primary-light);
  border-radius: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  margin: 0 auto 14px;
}

.login-logo h1 {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--primary);
}

.login-logo p { color: var(--text-muted); font-size: 0.88rem; }

/* ── Modal ── */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(4px);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  width: 100%;
  max-width: 540px;
  max-height: 90vh;
  overflow-y: auto;
}

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

.modal-header h3 { font-size: 1.05rem; font-weight: 700; }
.modal-close { background: none; border: none; color: var(--text-muted); cursor: pointer; font-size: 1.2rem; padding: 4px; }
.modal-close:hover { color: var(--danger); }
.modal-body { padding: 24px; }
.modal-footer { padding: 16px 24px; border-top: 1px solid var(--border); display: flex; gap: 10px; justify-content: flex-end; }

/* ── Live Indicator ── */
.live-dot {
  width: 8px;
  height: 8px;
  background: var(--success);
  border-radius: 50%;
  animation: pulse 2s infinite;
  display: inline-block;
}

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%       { opacity: 0.5; transform: scale(1.3); }
}

/* ── Empty State ── */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}

.empty-state .icon { font-size: 3rem; margin-bottom: 12px; }
.empty-state h3 { font-size: 1rem; font-weight: 600; color: var(--text); }
.empty-state p { font-size: 0.85rem; margin-top: 6px; }

/* ── Responsive ── */
@media (max-width: 768px) {
  .sidebar { transform: translateX(100%); }
  .sidebar.open { transform: translateX(0); }
  .main { margin-right: 0; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .form-row { grid-template-columns: 1fr; }
}
