/* ═══════════════════════════════════════════════════════════════════════════
   custom.css — نظام إدارة القضايا | RTL | Bootstrap 5.3
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── Variables & Reset ──────────────────────────────────────────────────── */
:root {
  --primary: #1B3A6B;
  --secondary: #2E75B6;
  --accent: #1E7A3E;
  --danger: #dc3545;
  --warning: #ffc107;
  --success: #198754;
  --sidebar-w: 260px;
  --sidebar-bg: #0f2447;
  --sidebar-text: #c8d8f0;
  --topbar-h: 60px;
  --radius: 12px;
  --shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
  --shadow-md: 0 4px 24px rgba(0, 0, 0, 0.13);
  --transition: 0.25s ease;
  --purple: #6f42c1;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  font-size: 15px;
}

body {
  font-family: 'Tajawal', 'Segoe UI', sans-serif;
  background: #f0f4f9;
  color: #2c3e50;
  direction: rtl;
  text-align: right;
  margin: 0;
  padding: 0;
}

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

::-webkit-scrollbar-track {
  background: #f1f1f1;
}

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

::-webkit-scrollbar-thumb:hover {
  background: #888;
}

/* ═══════════════════════════════════════════════════════════════════════════
   SIDEBAR
   ═══════════════════════════════════════════════════════════════════════════ */
.sidebar {
  position: fixed;
  top: 0;
  right: 0;
  width: var(--sidebar-w);
  height: 100vh;
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  z-index: 1050;
  transition: transform var(--transition);
  overflow-y: auto;
  overflow-x: hidden;
}

.sidebar.collapsed {
  transform: translateX(100%);
}

/* Header */
.sidebar-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px 18px;
  background: rgba(255, 255, 255, 0.06);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.logo-icon {
  width: 46px;
  height: 46px;
  background: linear-gradient(135deg, var(--secondary), var(--accent));
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.logo-icon i {
  font-size: 22px;
  color: #fff;
}

.logo-img {
  width: auto;
  height: 80px;
  object-fit: contain;
  border-radius: 10px;
  filter: drop-shadow(0px 2px 4px rgba(0, 0, 0, 0.2));
}

.firm-name {
  display: block;
  color: #fff;
  font-weight: 800;
  font-size: 0.95rem;
  line-height: 1.2;
}

.firm-subtitle {
  display: block;
  color: var(--sidebar-text);
  font-size: 0.72rem;
  opacity: 0.7;
}

/* User block */
.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 18px;
  background: rgba(255, 255, 255, 0.04);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.user-avatar {
  font-size: 28px;
  color: var(--sidebar-text);
  opacity: 0.8;
}

.user-name {
  display: block;
  color: #fff;
  font-size: 0.85rem;
  font-weight: 600;
}

.user-role {
  display: block;
  color: var(--sidebar-text);
  font-size: 0.72rem;
  opacity: 0.65;
}

/* Nav */
.sidebar-nav {
  list-style: none;
  margin: 0;
  padding: 10px 0;
  flex: 1;
}

.nav-section-title {
  padding: 14px 20px 6px;
  color: rgba(200, 216, 240, 0.45);
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.nav-item {
  padding: 2px 10px;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  color: var(--sidebar-text) !important;
  border-radius: 9px;
  font-size: 0.88rem;
  font-weight: 500;
  text-decoration: none;
  transition: all var(--transition);
}

.nav-link i {
  font-size: 18px;
  flex-shrink: 0;
  width: 22px;
  text-align: center;
}

.nav-link:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #fff !important;
}

.nav-link.active {
  background: linear-gradient(135deg, var(--secondary), #1B5BA6);
  color: #fff !important;
  box-shadow: 0 3px 12px rgba(46, 117, 182, 0.4);
  font-weight: 700;
}

/* Footer */
.sidebar-footer {
  padding: 14px 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.logout-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  color: #ff8a8a !important;
  border-radius: 9px;
  text-decoration: none;
  font-size: 0.88rem;
  transition: all var(--transition);
}

.logout-btn:hover {
  background: rgba(220, 53, 69, 0.15);
}

.logout-btn i {
  font-size: 18px;
}

/* ═══════════════════════════════════════════════════════════════════════════
   MAIN WRAPPER & TOP NAVBAR
   ═══════════════════════════════════════════════════════════════════════════ */
.main-wrapper {
  margin-right: var(--sidebar-w);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: margin var(--transition);
}

.main-wrapper.expanded {
  margin-right: 0;
}

/* Top Navbar */
.top-navbar {
  height: var(--topbar-h);
  background: #fff;
  border-bottom: 1px solid #e8ecf2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  box-shadow: 0 1px 6px rgba(0, 0, 0, 0.05);
  position: sticky;
  top: 0;
  z-index: 100;
}

.navbar-right,
.navbar-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.btn-icon {
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  background: #f0f4f9;
  border: none;
  color: var(--primary);
  font-size: 20px;
  cursor: pointer;
  transition: all var(--transition);
}

.btn-icon:hover {
  background: var(--primary);
  color: #fff;
}

.date-display {
  font-size: 0.82rem;
  color: #6c757d;
  font-weight: 500;
}

/* Breadcrumb */
.breadcrumb {
  font-size: 0.82rem;
}

.breadcrumb-item a {
  color: var(--secondary);
  text-decoration: none;
}

.breadcrumb-item.active {
  color: #6c757d;
}

/* ═══════════════════════════════════════════════════════════════════════════
   PAGE CONTENT
   ═══════════════════════════════════════════════════════════════════════════ */
.page-content {
  flex: 1;
  padding: 28px 28px 40px;
}

.page-header {
  margin-bottom: 24px;
}

.page-title {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--primary);
  margin: 0;
}

/* ═══════════════════════════════════════════════════════════════════════════
   CARDS
   ═══════════════════════════════════════════════════════════════════════════ */
.card {
  border: none;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.card-header-custom {
  padding: 14px 20px;
  background: var(--primary);
  color: #fff;
  font-weight: 700;
  font-size: 0.92rem;
  display: flex;
  align-items: center;
}

.card-header-custom.bg-success {
  background: var(--success) !important;
}

.card-header-custom.bg-primary {
  background: var(--primary) !important;
}

.card-header-custom.bg-info {
  background: #0dcaf0 !important;
  color: #000 !important;
}

.card-header-custom.bg-danger {
  background: var(--danger) !important;
}

.card-body {
  padding: 20px;
}

/* ═══════════════════════════════════════════════════════════════════════════
   STAT CARDS (لوحة التحكم)
   ═══════════════════════════════════════════════════════════════════════════ */
.stat-card {
  border-radius: var(--radius);
  padding: 24px 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow-md);
  color: #fff;
  min-height: 140px;
  transition: transform var(--transition), box-shadow var(--transition);
}

.stat-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.18);
}

.stat-card::before {
  content: '';
  position: absolute;
  top: -20px;
  left: -20px;
  width: 120px;
  height: 120px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
}

.stat-card--blue {
  background: linear-gradient(135deg, #1B3A6B, #2E75B6);
}

.stat-card--green {
  background: linear-gradient(135deg, #1E7A3E, #27ae60);
}

.stat-card--orange {
  background: linear-gradient(135deg, #e67e22, #f39c12);
}

.stat-card--red {
  background: linear-gradient(135deg, #c0392b, #e74c3c);
}

.stat-icon {
  font-size: 34px;
  opacity: 0.85;
}

.stat-number {
  font-size: 2rem;
  font-weight: 800;
  line-height: 1;
}

.stat-label {
  font-size: 0.82rem;
  opacity: 0.85;
  font-weight: 500;
}

.stat-link {
  color: rgba(255, 255, 255, 0.8);
  font-size: 0.78rem;
  text-decoration: none;
  margin-top: auto;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: color var(--transition);
}

.stat-link:hover {
  color: #fff;
}

/* ═══════════════════════════════════════════════════════════════════════════
   TABLES
   ═══════════════════════════════════════════════════════════════════════════ */
.table {
  font-size: 0.88rem;
}

.table thead th {
  font-weight: 700;
  font-size: 0.82rem;
  padding: 12px 14px;
  vertical-align: middle;
  letter-spacing: 0.02em;
}

.table tbody td {
  padding: 11px 14px;
  vertical-align: middle;
}

.table tbody tr:hover {
  background: #f5f8ff !important;
}

/* Schedule Table */
.schedule-table thead.schedule-header th,
.schedule-table .schedule-header th {
  background: #1B3A6B !important;
  color: #fff !important;
}

.schedule-table tbody tr:nth-child(even) {
  background: #f7f9fc;
}

.schedule-table tbody tr:nth-child(odd) {
  background: #fff;
}

/* City header */
.city-header {
  margin-bottom: 12px;
}

.city-badge {
  display: inline-flex;
  align-items: center;
  background: var(--primary);
  color: #fff;
  padding: 8px 18px;
  border-radius: 30px;
  font-weight: 700;
  font-size: 1rem;
  box-shadow: var(--shadow);
}

/* ═══════════════════════════════════════════════════════════════════════════
   BADGES
   ═══════════════════════════════════════════════════════════════════════════ */
.badge {
  font-size: 0.78rem;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 6px;
}

.bg-purple {
  background-color: var(--purple) !important;
}

/* ═══════════════════════════════════════════════════════════════════════════
   FORMS
   ═══════════════════════════════════════════════════════════════════════════ */
.form-control,
.form-select {
  border-radius: 8px;
  border: 1px solid #d0d9e8;
  padding: 10px 14px;
  font-family: 'Tajawal', sans-serif;
  font-size: 0.9rem;
  transition: border-color var(--transition), box-shadow var(--transition);
  background-color: #fff;
}

.form-control:focus,
.form-select:focus {
  border-color: var(--secondary);
  box-shadow: 0 0 0 3px rgba(46, 117, 182, 0.15);
  outline: none;
}

.form-label {
  font-size: 0.88rem;
  color: #4a5568;
  margin-bottom: 5px;
}

.input-group .form-control {
  border-radius: 8px 0 0 8px;
}

.input-group .input-group-text {
  background: #e9ecef;
  border-color: #d0d9e8;
  font-family: 'Tajawal', sans-serif;
  font-size: 0.88rem;
}

/* ═══════════════════════════════════════════════════════════════════════════
   BUTTONS
   ═══════════════════════════════════════════════════════════════════════════ */
.btn {
  font-family: 'Tajawal', sans-serif;
  font-weight: 600;
  border-radius: 8px;
  transition: all var(--transition);
  font-size: 0.88rem;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.btn-primary {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.btn-primary:hover {
  background: #142d55;
  border-color: #142d55;
  color: #fff;
  transform: translateY(-1px);
}

.btn-success {
  background: var(--accent);
  border-color: var(--accent);
}

.btn-success:hover {
  background: #175e30;
  border-color: #175e30;
  transform: translateY(-1px);
}

.btn-warning {
  color: #000;
}

.btn-lg {
  padding: 12px 24px;
  font-size: 0.95rem;
  border-radius: 10px;
}

.btn-sm {
  padding: 5px 12px;
  font-size: 0.8rem;
  border-radius: 7px;
}

/* ═══════════════════════════════════════════════════════════════════════════
   DETAIL VIEW
   ═══════════════════════════════════════════════════════════════════════════ */
.detail-label {
  font-size: 0.75rem;
  color: #6c757d;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 3px;
}

.detail-value {
  font-size: 0.92rem;
  color: #2c3e50;
  font-weight: 500;
}

/* ═══════════════════════════════════════════════════════════════════════════
   FINANCIAL SUMMARY
   ═══════════════════════════════════════════════════════════════════════════ */
.financial-summary {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.financial-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  background: #f8f9fa;
  border-radius: 8px;
}

.fin-label {
  font-size: 0.88rem;
  color: #6c757d;
  font-weight: 600;
}

.fin-value {
  font-size: 1rem;
  font-weight: 700;
}

/* ═══════════════════════════════════════════════════════════════════════════
   MODALS
   ═══════════════════════════════════════════════════════════════════════════ */
.modal-content {
  border: none;
  border-radius: 16px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
  overflow: hidden;
}

.modal-header {
  padding: 16px 20px;
  font-weight: 700;
}

.modal-body {
  padding: 24px;
}

.modal-footer {
  padding: 14px 20px;
  background: #f8f9fa;
  border-top: 1px solid #dee2e6;
}

/* ═══════════════════════════════════════════════════════════════════════════
   TOASTS
   ═══════════════════════════════════════════════════════════════════════════ */
.toast {
  border-radius: 10px !important;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15) !important;
  min-width: 280px;
  font-family: 'Tajawal', sans-serif;
}

.toast-body {
  font-size: 0.9rem;
}

/* ═══════════════════════════════════════════════════════════════════════════
   ALERTS
   ═══════════════════════════════════════════════════════════════════════════ */
.alert {
  border-radius: 10px;
  border: none;
  font-size: 0.9rem;
}

.alert-info {
  background: #e7f3ff;
  color: #0c5460;
}

.alert-warning {
  background: #fff8e1;
  color: #856404;
}

.alert-success {
  background: #d1eddc;
  color: #155724;
}

.alert-danger {
  background: #fde8e8;
  color: #842029;
}

/* ═══════════════════════════════════════════════════════════════════════════
   LIST GROUP
   ═══════════════════════════════════════════════════════════════════════════ */
.list-group-item {
  border-color: #eef0f5;
  font-size: 0.88rem;
  transition: background var(--transition);
}

.list-group-item-action:hover {
  background: #f0f5ff !important;
}

/* ═══════════════════════════════════════════════════════════════════════════
   PROGRESS BAR
   ═══════════════════════════════════════════════════════════════════════════ */
.progress {
  border-radius: 10px;
  background: #e9ecef;
}

.progress-bar {
  border-radius: 10px;
  transition: width 0.6s ease;
}

/* ═══════════════════════════════════════════════════════════════════════════
   RESPONSIVE — MOBILE
   ═══════════════════════════════════════════════════════════════════════════ */
@media (max-width: 992px) {
  .sidebar {
    transform: translateX(100%);
  }

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

  .main-wrapper {
    margin-right: 0 !important;
  }

  .page-content {
    padding: 16px 14px 30px;
  }
}

@media (max-width: 576px) {
  .page-title {
    font-size: 1.2rem;
  }

  .stat-number {
    font-size: 1.6rem;
  }

  .top-navbar {
    padding: 0 14px;
  }
}

/* ═══════════════════════════════════════════════════════════════════════════
   PRINT
   ═══════════════════════════════════════════════════════════════════════════ */
@media print {
  .no-print {
    display: none !important;
  }

  .sidebar,
  .top-navbar {
    display: none !important;
  }

  .main-wrapper {
    margin: 0 !important;
  }

  .page-content {
    padding: 0 !important;
  }

  body {
    background: #fff;
    font-size: 12px;
  }

  .card {
    box-shadow: none;
    border: 1px solid #ddd;
  }

  .city-section {
    page-break-before: always;
  }

  .city-section:first-child {
    page-break-before: avoid;
  }

  .print-header {
    display: block !important;
  }

  table {
    font-size: 11px;
  }
}

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

.btn-group .btn {
  gap: 0;
}

/* animate cards on load */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(18px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.card,
.stat-card {
  animation: fadeInUp 0.35s ease forwards;
}

/* Sidebar overlay for mobile */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 1049;
}

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

/* ═══════════════════════════════════════════════════════════════════════════
   Chart.js canvas
   ═══════════════════════════════════════════════════════════════════════════ */
canvas {
  max-width: 100%;
}

/* ═══════════════════════════════════════════════════════════════════════════
   Form floating (login)
   ═══════════════════════════════════════════════════════════════════════════ */
.form-floating>.form-control {
  padding-top: 1.4rem;
}

.form-floating>label {
  right: 0;
  left: auto;
  padding-right: 1rem;
}

.alert-danger.animate__headShake {
    border-right: 5px solid #dc3545 !important; /* لجهة اليمين حيت السيت RTL */
    background-color: #fff5f5;
    animation-iteration-count: 2; /* كتهز جوج مرات غير كتحل الصفحة */
}