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

:root {
  --bg-main: #f8fafc;
  --bg-card: rgba(255, 255, 255, 0.95);
  --bg-card-hover: #ffffff;
  --border-color: #e2e8f0;
  --border-glow: rgba(220, 38, 38, 0.25);
  
  --primary: #dc2626;          /* أحمر فاخر */
  --primary-hover: #b91c1c;    /* أحمر داكن */
  --primary-glow: rgba(220, 38, 38, 0.35);
  
  --accent-green: #10b981;
  --accent-green-bg: rgba(16, 185, 129, 0.1);
  --accent-amber: #d97706;
  --accent-amber-bg: rgba(217, 119, 6, 0.1);
  --accent-rose: #ef4444;
  --accent-rose-bg: rgba(239, 68, 68, 0.1);
  --accent-purple: #9333ea;
  
  --text-main: #0f172a;        /* نص غامق واضح */
  --text-muted: #475569;
  --text-dim: #94a3b8;
  
  --font-family: 'Cairo', 'Outfit', system-ui, -apple-system, sans-serif;
  --radius-sm: 10px;
  --radius-md: 16px;
  --radius-lg: 24px;
  --radius-full: 9999px;
  
  --shadow-sm: 0 4px 20px rgba(0, 0, 0, 0.05);
  --shadow-glow: 0 8px 30px rgba(220, 38, 38, 0.15);
  --transition-fast: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-normal: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
  font-family: var(--font-family);
  background-color: var(--bg-main);
  background-image: 
    radial-gradient(at 0% 0%, rgba(220, 38, 38, 0.05) 0px, transparent 50%),
    radial-gradient(at 100% 100%, rgba(239, 68, 68, 0.04) 0px, transparent 50%);
  background-attachment: fixed;
  color: var(--text-main);
  direction: rtl;
  text-align: right;
  min-height: 100vh;
  width: 100%;
  line-height: 1.6;
  overflow-x: hidden;
  max-width: 100vw;
}
html {
  overflow-x: hidden;
  max-width: 100vw;
}

/* Scrollbar */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: #f1f5f9;
}
::-webkit-scrollbar-thumb {
  background: rgba(220, 38, 38, 0.4);
  border-radius: var(--radius-full);
}
::-webkit-scrollbar-thumb:hover {
  background: var(--primary);
}

/* Glassmorphism Light Containers */
.glass-panel {
  background: var(--bg-card);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.04);
  transition: var(--transition-normal);
}

.glass-panel:hover {
  border-color: rgba(220, 38, 38, 0.2);
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.06);
}

/* General Layout - Full width for all laptops & monitors */
.app-container {
  display: flex;
  min-height: 100vh;
  width: 100%;
}

.sidebar {
  width: 260px;
  background: #ffffff;
  border-left: 1px solid var(--border-color);
  padding: 24px 16px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  position: fixed;
  top: 0;
  bottom: 0;
  right: 0;
  z-index: 100;
  box-shadow: -4px 0 20px rgba(0,0,0,0.03);
}

.main-content {
  margin-right: 260px;
  flex: 1;
  padding: 24px 32px;
  width: calc(100% - 260px);
  max-width: 100%;
  min-height: 100vh;
}

/* Top Navbar / Header */
.header-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border-color);
  width: 100%;
}

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

.header-title h1 {
  font-size: 1.75rem;
  font-weight: 800;
  color: var(--text-main);
}

.header-title p {
  color: var(--text-muted);
  font-size: 0.9rem;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* Hamburger Toggle Button & Drawer Close Button */
.hamburger-btn {
  display: none;
  background: #ffffff;
  border: 1px solid var(--border-color);
  color: var(--primary);
  width: 44px;
  height: 44px;
  border-radius: var(--radius-sm);
  font-size: 1.25rem;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: var(--transition-fast);
}

.hamburger-btn:hover {
  background: rgba(220, 38, 38, 0.08);
  border-color: var(--primary);
}

.sidebar-close-btn {
  display: none;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.5rem;
  cursor: pointer;
}

.sidebar-close-btn:hover {
  color: var(--primary);
}

.sidebar-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(15, 23, 42, 0.5);
  backdrop-filter: blur(4px);
  z-index: 999;
  display: none;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.sidebar-overlay.active {
  display: block;
  opacity: 1;
}

.user-badge {
  display: flex;
  align-items: center;
  gap: 12px;
  background: #f1f5f9;
  padding: 8px 16px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border-color);
}

.user-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary) 0%, #991b1b 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  color: #fff;
  box-shadow: 0 2px 10px var(--primary-glow);
}

/* Sidebar Navigation */
.nav-menu {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 24px;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  color: var(--text-muted);
  text-decoration: none;
  border-radius: var(--radius-sm);
  font-weight: 600;
  transition: var(--transition-fast);
}

.nav-link:hover, .nav-link.active {
  color: var(--primary);
  background: rgba(220, 38, 38, 0.08);
  border-right: 4px solid var(--primary);
}

.nav-link i {
  font-size: 1.2rem;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  font-family: var(--font-family);
  font-size: 0.95rem;
  font-weight: 700;
  border-radius: var(--radius-sm);
  border: none;
  cursor: pointer;
  transition: var(--transition-fast);
  text-decoration: none;
  min-height: 44px;
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary) 0%, #b91c1c 100%);
  color: #fff;
  box-shadow: 0 4px 14px var(--primary-glow);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px var(--primary-glow);
  background: linear-gradient(135deg, #b91c1c 0%, #991b1b 100%);
}

.btn-success {
  background: linear-gradient(135deg, var(--accent-green) 0%, #059669 100%);
  color: #fff;
  box-shadow: 0 4px 14px rgba(16, 185, 129, 0.25);
}

.btn-success:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(16, 185, 129, 0.35);
}

.btn-secondary {
  background: #f1f5f9;
  color: var(--text-main);
  border: 1px solid var(--border-color);
}

.btn-secondary:hover {
  background: #e2e8f0;
}

.btn-danger {
  background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
  color: #fff;
}

.btn-sm {
  padding: 6px 14px;
  font-size: 0.85rem;
  min-height: 36px;
}

.btn-lg {
  padding: 14px 28px;
  font-size: 1.1rem;
  border-radius: var(--radius-md);
  min-height: 52px;
}

/* Forms & Inputs */
.form-group {
  margin-bottom: 20px;
}

.form-label {
  display: block;
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 8px;
}

.form-control {
  width: 100%;
  padding: 12px 16px;
  background: #ffffff;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-main);
  font-family: var(--font-family);
  font-size: 0.95rem;
  transition: var(--transition-fast);
  min-height: 44px;
}

.form-control:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
  background: #ffffff;
}

/* KPI Stat Cards */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 20px;
  margin-bottom: 32px;
  width: 100%;
}

.stat-card {
  padding: 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.stat-info h3 {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 6px;
  font-weight: 700;
}

.stat-info .stat-value {
  font-size: 1.8rem;
  font-weight: 800;
  color: var(--text-main);
}

.stat-icon {
  width: 54px;
  height: 54px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
}

.stat-icon.primary { background: rgba(220, 38, 38, 0.12); color: var(--primary); }
.stat-icon.green { background: rgba(16, 185, 129, 0.12); color: var(--accent-green); }
.stat-icon.amber { background: rgba(217, 119, 6, 0.12); color: var(--accent-amber); }
.stat-icon.purple { background: rgba(147, 51, 234, 0.12); color: var(--accent-purple); }

/* Data Tables */
.table-responsive {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.custom-table {
  width: 100%;
  border-collapse: collapse;
  text-align: right;
  min-width: 600px;
}

.custom-table th {
  background: #f8fafc;
  padding: 14px 18px;
  font-size: 0.85rem;
  color: var(--text-muted);
  font-weight: 800;
  border-bottom: 2px solid var(--border-color);
}

.custom-table td {
  padding: 16px 18px;
  font-size: 0.95rem;
  border-bottom: 1px solid #f1f5f9;
  color: var(--text-main);
}

.custom-table tbody tr:hover {
  background: rgba(220, 38, 38, 0.02);
}

/* Modals */
.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(6px);
  z-index: 1000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal-backdrop.active {
  display: flex;
}

.modal-card {
  width: 100%;
  max-width: 550px;
  max-height: 90vh;
  overflow-y: auto;
  background: #ffffff;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-glow);
  position: relative;
}

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

.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.4rem;
  cursor: pointer;
}

.modal-close:hover {
  color: var(--primary);
}

/* Mobile Header & Responsive Layout Rules (ترتيب الهيدر بعرض كامل على التلفون والتابلت واللابتوب) */
@media (max-width: 900px) {
  .hamburger-btn {
    display: inline-flex !important;
    flex-shrink: 0;
    width: 44px;
    height: 44px;
  }

  .sidebar-close-btn {
    display: block;
  }

  .app-container {
    flex-direction: column;
  }

  .sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    right: 0;
    width: 280px;
    height: 100vh;
    background: #ffffff;
    z-index: 1000;
    transform: translateX(100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: -10px 0 30px rgba(0, 0, 0, 0.15);
    border-left: 1px solid var(--border-color);
    padding: 20px 16px;
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .main-content {
    margin-right: 0 !important;
    width: 100% !important;
    padding: 14px !important;
  }

  .header-bar {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    width: 100%;
    gap: 12px;
    padding: 16px;
    background: #ffffff;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.03);
    margin-bottom: 20px;
  }

  .header-top-row {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
  }

  .header-title {
    flex: 1;
  }

  .header-title h1 {
    font-size: 1.25rem !important;
    line-height: 1.3;
  }

  .header-title p {
    font-size: 0.8rem !important;
    margin-top: 2px;
  }

  .header-actions {
    width: 100%;
    margin-top: 4px;
    display: flex;
    flex-direction: column;
    gap: 8px;
  }

  .header-actions .btn {
    width: 100% !important;
    justify-content: center;
  }

  .stats-grid {
    grid-template-columns: 1fr;
  }
}
