/* ============================================================
   ToGo Admin Panel - Global Dark Theme System (Laravel Edition)
   ============================================================ */

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

:root {
  --primary: #FF6B35;
  --primary-dark: #e85a26;
  --primary-light: rgba(255, 107, 53, 0.14);
  --secondary: #2D3748;
  --success: #48BB78;
  --danger: #F56565;
  --warning: #ECC94B;
  --info: #4299E1;
  --bg: #0F1117;
  --surface: #1A1D2E;
  --surface2: #252840;
  --card-bg: #1A1D2E;
  --surface-bg: #1A1D2E;
  --background: #0F1117;
  --border: rgba(255,255,255,0.08);
  --text: #E2E8F0;
  --text-muted: #94A3B8;
  --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;
}

/* ── Scrollbars ── */
::-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; transition: all 0.2s ease; }
a:hover { opacity: 0.85; }

/* ── Layout & Aliases ── */
.layout, .app-layout {
  min-height: 100vh;
  width: 100%;
  max-width: 100vw;
  background: var(--bg);
  position: relative;
  overflow-x: hidden;
}

/* ── 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 ease;
}

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

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

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

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

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

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

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

.nav-group-title {
  padding: 10px 20px 4px;
  font-size: 0.68rem;
  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 ease;
  position: relative;
  cursor: pointer;
  text-decoration: none;
}

.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: 4px;
  height: 70%;
  background: var(--primary);
  border-radius: 4px 0 0 4px;
}

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

/* ── Main Content Area & Aliases ── */
.main, .main-content {
  margin-right: var(--sidebar-width);
  width: calc(100% - var(--sidebar-width));
  max-width: calc(100% - var(--sidebar-width));
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  background: var(--bg);
  min-width: 0;
  box-sizing: border-box;
}

/* ── Header / Topbar ── */
.header, .topbar {
  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, .topbar h2 {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
  margin: 0;
}

.menu-toggle {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
  padding: 6px 10px;
  border-radius: 8px;
  cursor: pointer;
  display: none;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 14px;
}

.header-user {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface2);
  padding: 6px 14px;
  border-radius: 10px;
  font-size: 0.88rem;
  border: 1px solid var(--border);
}

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

/* ── Page Content & Body ── */
.page-content, .content-body {
  padding: 24px;
  flex: 1;
  min-width: 0;
  width: 100%;
  box-sizing: border-box;
}

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

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

/* ── Stats Grid & Cards ── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 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;
  display: flex;
  align-items: center;
  gap: 16px;
}

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

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

.stat-card .stat-value {
  font-size: 1.65rem;
  font-weight: 800;
  line-height: 1.1;
  color: var(--text);
}

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

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

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

.card-header h3 {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text);
  margin: 0;
}

.card-body {
  padding: 20px;
}

/* ── Tables ── */
.table-container, .table-responsive {
  overflow-x: auto;
  width: 100%;
}

table, .table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
  text-align: right;
}

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

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

tbody tr:last-child td {
  border-bottom: none;
}

tbody tr:hover {
  background: rgba(255,255,255,0.02);
}

/* ── Badges ── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 0.74rem;
  font-weight: 700;
  white-space: nowrap;
}

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

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: 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 ease;
  text-decoration: none;
  white-space: nowrap;
}

.btn-primary {
  background: var(--primary);
  color: white;
}
.btn-primary:hover {
  background: var(--primary-dark);
  color: white;
}

.btn-outline {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-outline:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.btn-ghost {
  background: var(--surface2);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-ghost:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.btn-danger {
  background: var(--danger);
  color: white;
}
.btn-danger:hover {
  opacity: 0.9;
}

.btn-success {
  background: var(--success);
  color: white;
}
.btn-success:hover {
  opacity: 0.9;
}

.btn-sm {
  padding: 5px 10px;
  font-size: 0.78rem;
  border-radius: 6px;
}

/* ── 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, input[type="text"], input[type="email"], input[type="password"], input[type="number"], select, textarea {
  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, box-shadow 0.2s;
  outline: none;
}

.form-control:focus, input:focus, select:focus, textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(255, 107, 53, 0.15);
}

select option {
  background: var(--surface2);
  color: var(--text);
}

/* ── Flash Alerts ── */
.flash-alert {
  padding: 14px 20px;
  border-radius: 10px;
  margin-bottom: 20px;
  font-size: 0.92rem;
  display: flex;
  align-items: center;
  gap: 12px;
  animation: fadeIn 0.3s ease;
}

.flash-success {
  background: rgba(72,187,120,0.15);
  color: var(--success);
  border: 1px solid rgba(72,187,120,0.3);
}

.flash-error {
  background: rgba(245,101,101,0.15);
  color: var(--danger);
  border: 1px solid rgba(245,101,101,0.3);
}

/* ── Timeline ── */
.timeline {
  display: flex;
  flex-direction: column;
  gap: 15px;
  margin-top: 10px;
}

.timeline-item {
  display: flex;
  gap: 15px;
}

.timeline-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--border);
  margin-top: 5px;
  position: relative;
  z-index: 2;
  flex-shrink: 0;
}

.timeline-item.done .timeline-dot {
  background: var(--primary);
  box-shadow: 0 0 0 4px rgba(255,107,53,0.2);
}

.timeline-content {
  flex: 1;
  padding-bottom: 18px;
  border-right: 2px solid var(--border);
  padding-right: 18px;
  position: relative;
  left: 8px;
}

.timeline-item:last-child .timeline-content {
  border-right: none;
  padding-bottom: 0;
}

.timeline-item.done .timeline-content {
  border-right-color: var(--primary);
}

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

.empty-state .icon {
  font-size: 3rem;
  margin-bottom: 12px;
  color: var(--border);
}

.empty-state h3 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
}

/* ── Responsive ── */
@media (max-width: 900px) {
  .sidebar { transform: translateX(100%); }
  .sidebar.active, .sidebar.open { transform: translateX(0); }
  .main, .main-content {
    margin-right: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
  }
  .menu-toggle { display: block; }
  .stats-grid { grid-template-columns: 1fr 1fr !important; }
  .charts-grid { grid-template-columns: 1fr !important; }
}

@media (max-width: 768px) {
  div[style*="grid-template-columns: 1fr 1fr"] { grid-template-columns: 1fr !important; }
}

@media (max-width: 540px) {
  .stats-grid { grid-template-columns: 1fr !important; }
}
