/* ========================================= */
/* SYSTEM DESIGN VARIABLES */
/* ========================================= */
:root {
  /* Primary Brand Colors - Modern Corporate Blue/Indigo */
  --primary-hue: 220;
  --primary: hsl(var(--primary-hue), 90%, 56%);
  /* #3b82f6 */
  --primary-dark: hsl(var(--primary-hue), 90%, 45%);
  /* #2563eb */
  --primary-light: hsl(var(--primary-hue), 100%, 96%);
  /* #eff6ff */

  /* Accent - Vibrant Teal/Green */
  --accent: #10b981;
  --accent-light: #d1fae5;

  /* Neutrals - Slate Gray Scale */
  --bg-body: #f1f5f9;
  /* Slate 100 */
  --bg-surface: #ffffff;
  /* White */
  --text-main: #1e293b;
  /* Slate 800 */
  --text-muted: #64748b;
  /* Slate 500 */
  --border-color: #e2e8f0;
  /* Slate 200 */

  /* Shadows & Effects */
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
  --radius-md: 12px;
  --radius-lg: 16px;
  --transition: all 0.2s ease-in-out;
}

@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Sans+Arabic:wght@300;400;500;600;700&display=swap');

/* ========================================= */
/* GLOBAL RESET & TYPOGRAPHY */
/* ========================================= */
body {
  font-family: 'IBM Plex Sans Arabic', sans-serif;
  background-color: var(--bg-body);
  color: var(--text-main);
  direction: rtl;
  text-align: right;
  overflow-x: hidden;
}

h1,
h2,
h3,
h4,
h5,
h6 {
  color: var(--text-main);
  font-weight: 700;
}

/* ========================================= */
/* SIDEBAR (Modern & Floating) */
/* ========================================= */
#wrapper {
  display: flex;
  width: 100%;
}

#sidebar {
  min-width: 260px;
  max-width: 260px;
  background: #0f172a;
  /* Dark Slate */
  color: #fff;
  min-height: 100vh;
  box-shadow: 4px 0 15px rgba(0, 0, 0, 0.05);
  z-index: 100;
}

.sidebar-header {
  padding: 2rem 1.5rem;
  background: rgba(255, 255, 255, 0.05);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar-header h3 {
  color: #fff;
  font-size: 1.25rem;
  margin: 0;
  font-weight: 600;
  letter-spacing: -0.5px;
}

#sidebar ul.components {
  padding: 1rem 0;
}

#sidebar ul li a {
  position: relative;
  padding: 14px 24px;
  font-size: 1rem;
  font-weight: 500;
  color: #94a3b8;
  /* Slate 400 */
  display: flex;
  align-items: center;
  text-decoration: none;
  transition: var(--transition);
  border-right: 4px solid transparent;
}

#sidebar ul li a i {
  width: 24px;
  font-size: 1.1rem;
  margin-left: 12px;
  /* RTL Margin */
  opacity: 0.8;
}

#sidebar ul li a:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.05);
}

/* Active State */
#sidebar ul li.active>a {
  color: #ffffff;
  background: linear-gradient(90deg, rgba(59, 130, 246, 0.15) 0%, rgba(59, 130, 246, 0) 100%);
  border-right-color: var(--primary);
}

/* Submenu Styling */
#sidebar ul li ul {
    background: rgba(0, 0, 0, 0.2);
    padding-bottom: 5px;
}

#sidebar ul li ul li a {
    padding: 10px 48px !important; /* Indent sub-items */
    font-size: 0.9rem !important;
    border-right: none !important;
    color: #94a3b8;
}

#sidebar ul li ul li a:hover {
    background: transparent !important;
    color: #fff !important;
}

#sidebar ul li ul li.active a {
    color: #fff !important;
    font-weight: 600;
}

.dropdown-toggle::after {
    display: inline-block;
    margin-right: auto; /* Push to left in RTL */
    vertical-align: middle;
    content: "";
    border-top: 0.3em solid;
    border-right: 0.3em solid transparent;
    border-bottom: 0;
    border-left: 0.3em solid transparent;
    transition: transform 0.2s ease-in-out;
}

.dropdown-toggle[aria-expanded="true"]::after {
    transform: rotate(180deg);
}

/* Sidebar user profile card */
.sidebar-profile {
    margin: 0;
    padding: 12px 16px;
    border-top: 1px solid rgba(255,255,255,0.08);
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    transition: background 0.15s;
}
.sidebar-profile:hover { background: rgba(255,255,255,0.05); }
.sidebar-profile-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: #3b82f6;
    color: #fff;
    font-size: 14px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.sidebar-profile-info { flex: 1; min-width: 0; }
.sidebar-profile-name {
    color: #e2e8f0;
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.sidebar-profile-role {
    font-size: 11px;
    color: #64748b;
}
.sidebar-profile-edit {
    color: #64748b;
    font-size: 13px;
    flex-shrink: 0;
}

/* ========================================= */
/* CONTENT AREA */
/* ========================================= */
#content {
  width: 100%;
  padding: 2rem;
  min-height: 100vh;
}

/* ========================================= */
/* COMPONENTS: CARDS & WIDGETS */
/* ========================================= */
.card {
  background: var(--bg-surface);
  border: none;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  transition: var(--transition);
  overflow: hidden;
  margin-bottom: 1.5rem;
}

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

.card-header {
  background: transparent;
  border-bottom: 1px solid var(--border-color);
  padding: 1.25rem 1.5rem;
  font-weight: 600;
  font-size: 1rem;
  color: var(--text-main);
}

.card-body {
  padding: 1.5rem;
}

/* KPI Cards Specifics */
.kpi-card-title {
  font-size: 0.875rem;
  color: var(--text-muted);
  font-weight: 500;
  margin-bottom: 0.5rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.kpi-value {
  font-size: 2rem;
  font-weight: 700;
  color: var(--text-main);
  line-height: 1.2;
}

/* Primary KPI Override (Total Revenue) */
.bg-primary {
  background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 100%) !important;
}

.bg-primary .kpi-card-title,
.bg-primary .kpi-value,
.bg-primary .card-text small {
  color: #fff !important;
  opacity: 0.95;
}

/* ========================================= */
/* COMPONENTS: TABLES */
/* ========================================= */
.table-responsive {
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.table {
  margin-bottom: 0;
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
}

.table thead th {
  background-color: #f8fafc;
  /* Slate 50 */
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.85rem;
  text-transform: uppercase;
  padding: 1rem;
  border-bottom: 1px solid var(--border-color);
}

.table tbody td {
  padding: 1rem;
  vertical-align: middle;
  border-bottom: 1px solid var(--border-color);
  color: var(--text-main);
  font-size: 0.95rem;
}

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

.table-hover tbody tr:hover {
  background-color: #f8fafc;
}

/* ========================================= */
/* COMPONENTS: BADGES & BUTTONS */
/* ========================================= */
.badge {
  padding: 0.5em 0.8em;
  border-radius: 6px;
  font-weight: 500;
  font-size: 0.85em;
  letter-spacing: 0.3px;
}

.bg-success {
  background-color: var(--accent-light) !important;
  color: #065f46 !important;
  /* Dark Green */
}

.bg-warning {
  background-color: #fef3c7 !important;
  /* Amber 100 */
  color: #92400e !important;
  /* Amber 800 */
}

.bg-secondary {
  background-color: #e2e8f0 !important;
  /* Slate 200 */
  color: #475569 !important;
  /* Slate 600 */
}

.btn-primary {
  background-color: var(--primary);
  border-color: var(--primary);
  border-radius: 8px;
  padding: 0.6rem 1.2rem;
  font-weight: 500;
  box-shadow: 0 4px 6px -1px rgba(59, 130, 246, 0.4);
}

.btn-primary:hover {
  background-color: var(--primary-dark);
  box-shadow: 0 6px 8px -1px rgba(59, 130, 246, 0.5);
  transform: translateY(-1px);
}

.btn-outline-secondary {
  border-color: var(--border-color);
  color: var(--text-muted);
  border-radius: 8px;
}

.btn-outline-secondary:hover {
  background-color: #f1f5f9;
  color: var(--text-main);
}

/* ========================================= */
/* UTILITIES */
/* ========================================= */
.text-muted {
  color: var(--text-muted) !important;
}

.fw-bold {
  font-weight: 700 !important;
}

.ms-2 {
  margin-left: 0.5rem !important;
}

.mb-4 {
  margin-bottom: 1.5rem !important;
}

/* Scrollbar Polish */
::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

/* ========================================= */
/* MOBILE / PWA STYLES (< 768px)             */
/* ========================================= */

/* --- Hide sidebar, show full-width content on mobile --- */
@media (max-width: 767.98px) {
  #sidebar { display: none !important; }
  #wrapper { display: block; }

  #content {
    padding: 0.875rem;
    padding-bottom: 80px; /* leave room for bottom nav */
    min-height: 100vh;
  }

  /* Smaller KPI values */
  .kpi-value { font-size: 1.5rem; }

  /* Stack cards */
  .card { margin-bottom: 1rem; }

  /* Hide desktop-only sections on mobile */
  .desktop-only { display: none !important; }

  /* Show mobile-only sections */
  .mobile-only { display: block !important; }
}

/* --- Mobile Bottom Navigation --- */
.mobile-bottom-nav {
  display: none; /* hidden on desktop */
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 64px;
  background: #fff;
  border-top: 1px solid #e2e8f0;
  box-shadow: 0 -4px 16px rgba(0,0,0,0.08);
  z-index: 9999;
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

@media (max-width: 767.98px) {
  .mobile-bottom-nav { display: flex; }
}

.mobile-bottom-nav .nav-tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  color: #94a3b8;
  font-size: 10px;
  font-weight: 600;
  gap: 3px;
  padding: 6px 0;
  transition: color 0.15s;
  border: none;
  background: none;
  cursor: pointer;
}

.mobile-bottom-nav .nav-tab i { font-size: 20px; }
.mobile-bottom-nav .nav-tab.active { color: #1a73e8; }
.mobile-bottom-nav .nav-tab:active { opacity: 0.7; }

/* --- PWA Install Banner --- */
.pwa-install-banner {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 10000;
  background: linear-gradient(90deg, #1a73e8, #0f62d0);
  color: #fff;
  padding: 10px 16px;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  font-weight: 600;
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

@media (max-width: 767.98px) {
  .pwa-install-banner.visible { display: flex; }
}

.pwa-install-banner .banner-text { flex: 1; }
.pwa-install-banner .btn-install {
  background: #fff;
  color: #1a73e8;
  border: none;
  border-radius: 20px;
  padding: 5px 14px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
}
.pwa-install-banner .btn-dismiss {
  background: none;
  border: none;
  color: rgba(255,255,255,0.7);
  font-size: 18px;
  cursor: pointer;
  line-height: 1;
  padding: 2px 4px;
}

/* --- Mobile Reservation Cards --- */
.res-mobile-cards { display: none; }

@media (max-width: 767.98px) {
  /* Show mobile cards, hide table */
  .res-mobile-cards { display: block; }
  #reservationsTable { display: none !important; }

  /* Mobile status tabs */
  .mobile-status-tabs {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 4px;
    scrollbar-width: none;
    margin-bottom: 12px;
  }
  .mobile-status-tabs::-webkit-scrollbar { display: none; }

  /* Hide desktop filter card on mobile (show only mobile tabs) */
  .desktop-filter-card { display: none; }

  /* Topbar adjustments */
  .navbar h2 { font-size: 1.25rem; }
  .navbar p { font-size: 0.8rem; }

  /* Hide charts on mobile dashboard */
  .charts-section { display: none; }
}

.res-card {
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.07);
  padding: 14px 16px;
  margin-bottom: 12px;
  border: 1px solid #f1f5f9;
}

.res-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 10px;
}

.res-card-name { font-weight: 700; font-size: 15px; color: #1e293b; }
.res-card-id { font-size: 11px; color: #94a3b8; }
.res-card-meta { font-size: 13px; color: #475569; line-height: 1.8; }
.res-card-meta i { width: 16px; color: #94a3b8; margin-left: 4px; }

.res-card-actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
  border-top: 1px solid #f1f5f9;
  padding-top: 10px;
}

.res-card-actions .btn { flex: 1; border-radius: 10px; font-size: 13px; font-weight: 600; }

/* --- Mobile Recent Reservations (index.html) --- */
.mobile-recent-res { display: none; }
@media (max-width: 767.98px) {
  .mobile-recent-res { display: block; }
}

.recent-res-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid #f1f5f9;
}
.recent-res-item:last-child { border-bottom: none; }
.recent-res-name { font-weight: 600; font-size: 14px; color: #1e293b; }
.recent-res-sub { font-size: 12px; color: #94a3b8; }
