/* =====================================================
   تجوال - Tijwal | ملف CSS الرئيسي المحسّن v4 (Responsive)
   الألوان: أزرق فاتح #29ABE2 | أزرق غامق #1A3A6B | أبيض #FFFFFF
   متجاوب تماماً مع الهاتف، التابلت، والكمبيوتر
   ===================================================== */

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

/* ===== المتغيرات ===== */
:root {
  --primary:        #29ABE2;
  --primary-dark:   #1A3A6B;
  --primary-light:  #e8f7fd;
  --primary-mid:    #0d7ab5;
  --primary-glow:   rgba(41,171,226,.25);
  --white:          #ffffff;
  --bg:             #f4f8fc;
  --bg2:            #eef3f9;
  --card:           #ffffff;
  --border:         #ddeef8;
  --text:           #1a2d4a;
  --text-muted:     #6b87a3;
  --text-light:     #a8c0d4;
  --success:        #22c55e;
  --success-bg:     #dcfce7;
  --danger:         #ef4444;
  --danger-bg:      #fee2e2;
  --warning:        #f59e0b;
  --warning-bg:     #fef9c3;
  --shadow-xs:      0 1px 4px rgba(26,58,107,.06);
  --shadow-sm:      0 2px 10px rgba(26,58,107,.09);
  --shadow-md:      0 6px 24px rgba(26,58,107,.13);
  --shadow-lg:      0 12px 48px rgba(26,58,107,.18);
  --radius-sm:      10px;
  --radius-md:      16px;
  --radius-lg:      22px;
  --radius-xl:      30px;
  --transition:     all .28s cubic-bezier(.4,0,.2,1);
  --sidebar-w:      268px;
  /* Responsive Breakpoints */
  --mobile:         480px;
  --tablet:         768px;
  --desktop:        1024px;
  --wide:           1440px;
}

/* ===== Reset ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; direction: rtl; }
body {
  font-family: 'Tajawal', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
a { text-decoration: none; color: inherit; }
img { max-width: 100%; height: auto; display: block; }
button { cursor: pointer; font-family: 'Tajawal', sans-serif; border: none; }
input, select, textarea { font-family: 'Tajawal', sans-serif; }

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: var(--primary); }

/* =====================================================
   SPLASH SCREEN
   ===================================================== */
.splash-page {
  min-height: 100vh;
  background: #ffffff;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
  padding: 20px;
}
.splash-bg-image {
  position: absolute;
  inset: 0;
  background-image: url('/assets/images/splash.jpg');
  background-size: cover;
  background-position: center bottom;
  opacity: 0.12;
}
.splash-content {
  position: relative;
  z-index: 2;
  text-align: center;
  animation: splashFadeIn 1s ease-out;
}
.splash-logo {
  width: min(190px, 80vw);
  height: auto;
  margin-bottom: 24px;
  animation: splashScale 1.2s ease-out;
  filter: drop-shadow(0 8px 24px rgba(41,171,226,.3));
}
.splash-title {
  font-size: clamp(32px, 8vw, 44px);
  font-weight: 900;
  color: var(--primary-dark);
  margin-bottom: 12px;
}
.splash-subtitle {
  font-size: clamp(14px, 4vw, 18px);
  color: var(--text-muted);
  margin-bottom: 40px;
}
.splash-spinner {
  width: 40px;
  height: 40px;
  border: 4px solid var(--primary-light);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes splashFadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes splashScale { from { transform: scale(0.8); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@keyframes spin { to { transform: rotate(360deg); } }

/* =====================================================
   DASHBOARD LAYOUT (متجاوب)
   ===================================================== */
.dash-layout {
  display: flex;
  min-height: 100vh;
  background: var(--bg);
}

/* Sidebar - Mobile First */
.dash-sidebar {
  position: fixed;
  left: 0;
  top: 0;
  width: 100%;
  height: 100vh;
  background: var(--white);
  z-index: 1000;
  overflow-y: auto;
  transform: translateX(-100%);
  transition: var(--transition);
  box-shadow: var(--shadow-lg);
}

.dash-sidebar.active {
  transform: translateX(0);
}

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

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 900;
  font-size: 18px;
  color: var(--primary-dark);
}

.sidebar-close {
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
  color: var(--text-muted);
}

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

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 20px;
  color: var(--text-muted);
  transition: var(--transition);
  border-right: 3px solid transparent;
  cursor: pointer;
  font-size: 14px;
}

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

.nav-icon {
  font-size: 20px;
  flex-shrink: 0;
}

.nav-label {
  flex: 1;
}

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 999;
}

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

/* Tablet and up */
@media (min-width: 768px) {
  .dash-sidebar {
    position: relative;
    width: var(--sidebar-w);
    height: 100vh;
    transform: translateX(0);
    box-shadow: none;
    border-right: 1px solid var(--border);
  }
  
  .sidebar-close {
    display: none;
  }
  
  .sidebar-overlay {
    display: none !important;
  }
}

/* Main Content */
.dash-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  width: 100%;
  overflow-y: auto;
}

/* Topbar */
.dash-topbar {
  background: var(--white);
  border-bottom: 1px solid var(--border);
  padding: 12px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow-xs);
}

.topbar-title {
  font-weight: 700;
  font-size: 16px;
  color: var(--text);
}

.menu-toggle {
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
  color: var(--primary-dark);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 4px;
}

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

@media (min-width: 768px) {
  .menu-toggle {
    display: none;
  }
  
  .dash-topbar {
    padding: 16px 24px;
  }
}

/* Content Area */
.dash-content {
  flex: 1;
  padding: 16px;
  overflow-y: auto;
}

@media (min-width: 768px) {
  .dash-content {
    padding: 24px;
  }
}

@media (min-width: 1024px) {
  .dash-content {
    padding: 32px;
  }
}

/* =====================================================
   CARDS & CONTAINERS
   ===================================================== */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-xs);
  transition: var(--transition);
  margin-bottom: 16px;
  overflow: hidden;
}

.card:hover {
  box-shadow: var(--shadow-sm);
  border-color: var(--primary-light);
}

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

.card-title {
  font-weight: 700;
  font-size: 16px;
  color: var(--text);
}

.card-body {
  padding: 16px;
}

@media (min-width: 768px) {
  .card-header {
    padding: 20px;
  }
  
  .card-body {
    padding: 20px;
  }
}

/* =====================================================
   BUTTONS
   ===================================================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 14px;
  transition: var(--transition);
  border: none;
  cursor: pointer;
  white-space: nowrap;
  text-decoration: none;
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: var(--white);
}

.btn-primary:hover {
  box-shadow: 0 4px 12px rgba(41,171,226,.3);
  transform: translateY(-2px);
}

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

.btn-danger:hover {
  background: #dc2626;
}

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

.btn-outline:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.btn-sm {
  padding: 8px 12px;
  font-size: 12px;
}

.btn-lg {
  padding: 14px 24px;
  font-size: 16px;
}

.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* =====================================================
   FORMS
   ===================================================== */
.form-group {
  margin-bottom: 16px;
}

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

.form-input,
.form-select,
.form-textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-family: inherit;
  transition: var(--transition);
  background: var(--white);
  color: var(--text);
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
}

.form-textarea {
  resize: vertical;
  min-height: 100px;
}

/* =====================================================
   TABLES (Responsive)
   ===================================================== */
.table-responsive {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.table thead {
  background: var(--bg2);
  border-bottom: 2px solid var(--border);
}

.table th {
  padding: 12px;
  text-align: right;
  font-weight: 700;
  color: var(--text);
}

.table td {
  padding: 12px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
}

.table tbody tr:hover {
  background: var(--primary-light);
}

@media (max-width: 767px) {
  .table {
    font-size: 12px;
  }
  
  .table th,
  .table td {
    padding: 8px;
  }
}

/* =====================================================
   STATS GRID
   ===================================================== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}

.stat-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px;
  display: flex;
  gap: 12px;
  align-items: flex-start;
  transition: var(--transition);
}

.stat-card:hover {
  box-shadow: var(--shadow-sm);
  border-color: var(--primary-light);
}

.stat-icon {
  font-size: 28px;
  flex-shrink: 0;
}

.stat-num {
  font-weight: 900;
  font-size: 20px;
  color: var(--text);
}

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

@media (min-width: 768px) {
  .stats-grid {
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px;
  }
  
  .stat-card {
    padding: 20px;
  }
}

@media (min-width: 1024px) {
  .stats-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

/* =====================================================
   BADGES
   ===================================================== */
.badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
  background: var(--primary-light);
  color: var(--primary);
}

.badge-success {
  background: var(--success-bg);
  color: var(--success);
}

.badge-danger {
  background: var(--danger-bg);
  color: var(--danger);
}

.badge-warning {
  background: var(--warning-bg);
  color: var(--warning);
}

/* =====================================================
   MODALS
   ===================================================== */
.modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 2000;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal.active {
  display: flex;
}

.modal-content {
  background: var(--card);
  border-radius: var(--radius-lg);
  padding: 24px;
  width: 100%;
  max-width: 500px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
}

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

.modal-title {
  font-weight: 700;
  font-size: 18px;
  color: var(--text);
}

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

.modal-body {
  margin-bottom: 20px;
}

.modal-footer {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
}

/* =====================================================
   RESPONSIVE GRIDS
   ===================================================== */
.grid {
  display: grid;
  gap: 16px;
}

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

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

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

@media (min-width: 768px) {
  .grid-2 {
    grid-template-columns: repeat(2, 1fr);
  }
  
  .grid-3 {
    grid-template-columns: repeat(2, 1fr);
  }
  
  .grid-4 {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (min-width: 1024px) {
  .grid-2 {
    grid-template-columns: repeat(2, 1fr);
  }
  
  .grid-3 {
    grid-template-columns: repeat(3, 1fr);
  }
  
  .grid-4 {
    grid-template-columns: repeat(4, 1fr);
  }
}

/* =====================================================
   UTILITIES
   ===================================================== */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-left { text-align: left; }

.mt-0 { margin-top: 0; }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mt-4 { margin-top: 32px; }

.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }
.mb-4 { margin-bottom: 32px; }

.p-0 { padding: 0; }
.p-1 { padding: 8px; }
.p-2 { padding: 16px; }
.p-3 { padding: 24px; }
.p-4 { padding: 32px; }

.flex { display: flex; }
.flex-col { flex-direction: column; }
.flex-center { align-items: center; justify-content: center; }
.flex-between { justify-content: space-between; }
.gap-1 { gap: 8px; }
.gap-2 { gap: 16px; }
.gap-3 { gap: 24px; }

.hidden { display: none; }
.visible { display: block; }

@media (max-width: 767px) {
  .hidden-mobile { display: none; }
}

@media (min-width: 768px) {
  .hidden-tablet { display: none; }
}

@media (min-width: 1024px) {
  .hidden-desktop { display: none; }
}

/* =====================================================
   EMPTY STATE
   ===================================================== */
.empty-state {
  text-align: center;
  padding: 40px 20px;
}

.empty-icon {
  font-size: 64px;
  margin-bottom: 16px;
}

.empty-title {
  font-weight: 700;
  font-size: 18px;
  color: var(--text);
  margin-bottom: 8px;
}

.empty-desc {
  font-size: 14px;
  color: var(--text-muted);
}

/* =====================================================
   ANIMATIONS
   ===================================================== */
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

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

@keyframes slideDown {
  from { transform: translateY(-20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

/* =====================================================
   PRINT STYLES
   ===================================================== */
@media print {
  .dash-sidebar,
  .dash-topbar,
  .menu-toggle {
    display: none;
  }
  
  .dash-main {
    width: 100%;
  }
}
