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

/* ============================
   CSS Variables
   ============================ */
:root {
  --sidebar-width: 260px;
  --header-height: 64px;
  --primary: #0f766e;
  --primary-dark: #0a5c56;
  --primary-darker: #064e48;
  --sidebar-bg: #0f172a;
  --sidebar-hover: #1e293b;
  --sidebar-active: #0f766e;
  --sidebar-text: #94a3b8;
  --sidebar-text-active: #ffffff;
  --body-bg: #f1f5f9;
  --card-bg: #ffffff;
  --text-main: #1e293b;
  --text-muted: #64748b;
  --border-color: #e2e8f0;
  --shadow-sm: 0 1px 3px rgba(15,23,42,.06);
  --shadow-md: 0 4px 16px rgba(15,23,42,.08);
  --shadow-lg: 0 10px 40px rgba(15,23,42,.1);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --transition: .25s cubic-bezier(.4,0,.2,1);
}

/* ============================
   Base
   ============================ */
*, *::before, *::after { box-sizing: border-box; }
body {
  font-family: 'Tajawal', Arial, sans-serif;
  background: var(--body-bg);
  color: var(--text-main);
  margin: 0;
  overflow-x: hidden;
}
a { text-decoration: none; }

/* ============================
   Sidebar
   ============================ */
.sidebar {
  position: fixed;
  top: 0;
  right: 0;
  width: var(--sidebar-width);
  height: 100vh;
  background: var(--sidebar-bg);
  z-index: 1040;
  display: flex;
  flex-direction: column;
  transition: transform var(--transition);
  box-shadow: -4px 0 24px rgba(0,0,0,.15);
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px 22px;
  border-bottom: 1px solid rgba(255,255,255,.07);
}
.sidebar-brand-icon {
  width: 44px;
  height: 44px;
  background: linear-gradient(135deg, var(--primary), #14b8a6);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  color: #fff;
  flex-shrink: 0;
}
.sidebar-brand-text { display: flex; flex-direction: column; }
.sidebar-brand-title {
  font-size: 15px;
  font-weight: 700;
  color: #fff;
  line-height: 1.3;
}
.sidebar-brand-sub {
  font-size: 11px;
  color: var(--sidebar-text);
  line-height: 1.3;
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 12px 0;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,.1) transparent;
}
.sidebar-nav::-webkit-scrollbar { width: 4px; }
.sidebar-nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,.1); border-radius: 4px; }

.sidebar-section-title {
  padding: 18px 22px 6px;
  font-size: 11px;
  font-weight: 700;
  color: rgba(148,163,184,.6);
  text-transform: uppercase;
  letter-spacing: .5px;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 22px;
  color: var(--sidebar-text);
  font-size: 14px;
  font-weight: 500;
  transition: all var(--transition);
  border-right: 3px solid transparent;
  margin: 2px 0;
}
.sidebar-link:hover {
  background: var(--sidebar-hover);
  color: #e2e8f0;
}
.sidebar-link.active {
  background: rgba(15,118,110,.15);
  color: var(--sidebar-text-active);
  border-right-color: var(--primary);
}
.sidebar-link.active i {
  color: #14b8a6;
}
.sidebar-link i {
  width: 20px;
  text-align: center;
  font-size: 15px;
  color: var(--sidebar-text);
  transition: color var(--transition);
}
.sidebar-link:hover i { color: #14b8a6; }

.sidebar-footer {
  border-top: 1px solid rgba(255,255,255,.07);
  padding: 16px 22px;
}
.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
}
.sidebar-user-avatar {
  width: 38px;
  height: 38px;
  background: linear-gradient(135deg, var(--primary), #14b8a6);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  color: #fff;
  flex-shrink: 0;
}
.sidebar-user-info { display: flex; flex-direction: column; }
.sidebar-user-name {
  font-size: 13px;
  font-weight: 600;
  color: #fff;
  line-height: 1.3;
}
.sidebar-user-role {
  font-size: 11px;
  color: var(--sidebar-text);
  line-height: 1.3;
}

/* Sidebar Overlay (mobile) */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15,23,42,.5);
  backdrop-filter: blur(4px);
  z-index: 1035;
  transition: opacity var(--transition);
}

/* ============================
   Main Wrapper
   ============================ */
.main-wrapper {
  margin-right: var(--sidebar-width);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: margin var(--transition);
}

/* ============================
   Top Header
   ============================ */
.top-header {
  height: var(--header-height);
  background: var(--card-bg);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  position: sticky;
  top: 0;
  z-index: 1020;
  box-shadow: var(--shadow-sm);
}
.top-header-right {
  display: flex;
  align-items: center;
  gap: 16px;
}
.top-header-left {
  display: flex;
  align-items: center;
  gap: 16px;
}
.page-title {
  font-size: 18px;
  font-weight: 700;
  margin: 0;
  color: var(--text-main);
}
.sidebar-toggle {
  background: none;
  border: 1px solid var(--border-color);
  width: 38px;
  height: 38px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text-muted);
  transition: all var(--transition);
  display: none;
}
.sidebar-toggle:hover {
  background: var(--body-bg);
  color: var(--primary);
}
.header-date {
  font-size: 13px;
  color: var(--text-muted);
  background: var(--body-bg);
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  font-weight: 500;
}
.header-date i { margin-left: 4px; }
.header-logout {
  border-radius: var(--radius-sm) !important;
  font-size: 13px;
  font-weight: 500;
}

/* ============================
   Main Content
   ============================ */
.main-content {
  flex: 1;
  padding: 28px;
}

/* ============================
   Cards
   ============================ */
.card {
  border: 0;
  border-radius: var(--radius-lg);
  background: var(--card-bg);
  box-shadow: var(--shadow-md);
  transition: box-shadow var(--transition);
}
.card:hover {
  box-shadow: var(--shadow-lg);
}

/* ============================
   Stat Cards (Dashboard)
   ============================ */
.stat-card {
  background: var(--card-bg);
  border-radius: var(--radius-xl);
  padding: 24px;
  box-shadow: var(--shadow-md);
  position: relative;
  overflow: hidden;
  transition: all var(--transition);
}
.stat-card::before {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  width: 80px;
  height: 80px;
  background: linear-gradient(135deg, rgba(15,118,110,.1), rgba(20,184,166,.05));
  border-radius: 0 var(--radius-xl) 0 50%;
}
.stat-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-lg);
}
.stat-card i {
  font-size: 28px;
  color: var(--primary);
  margin-bottom: 8px;
}
.stat-card h3 {
  font-size: 28px;
  font-weight: 800;
  color: var(--text-main);
  margin: 4px 0;
}
.stat-card p {
  font-size: 13px;
  color: var(--text-muted);
  margin: 0;
  font-weight: 500;
}

/* ============================
   Buttons
   ============================ */
.btn {
  border-radius: var(--radius-md);
  font-weight: 500;
  padding: .5rem 1.2rem;
  font-size: 14px;
  transition: all var(--transition);
}
.btn:hover { transform: translateY(-1px); }
.btn-success {
  background: linear-gradient(135deg, var(--primary), #14b8a6);
  border: none;
  box-shadow: 0 4px 12px rgba(15,118,110,.25);
}
.btn-success:hover {
  background: linear-gradient(135deg, var(--primary-dark), var(--primary));
  box-shadow: 0 6px 20px rgba(15,118,110,.35);
}
.btn-primary {
  background: linear-gradient(135deg, #3b82f6, #60a5fa);
  border: none;
}
.btn-primary:hover {
  background: linear-gradient(135deg, #2563eb, #3b82f6);
}

/* ============================
   Tables
   ============================ */
.table { vertical-align: middle; font-size: 14px; }
.table thead th {
  background: linear-gradient(135deg, #f0fdfa, #f0f9ff);
  color: var(--primary-dark);
  font-weight: 600;
  font-size: 13px;
  padding: 12px 16px;
  border-bottom: 2px solid var(--border-color);
  white-space: nowrap;
}
.table tbody td {
  padding: 10px 16px;
  border-bottom: 1px solid #f1f5f9;
}
.table-hover tbody tr:hover {
  background: #f8fafc;
}

/* ============================
   Forms
   ============================ */
.form-control, .form-select {
  border-radius: var(--radius-md);
  padding: .6rem 1rem;
  border: 1.5px solid var(--border-color);
  font-size: 14px;
  transition: all var(--transition);
}
.form-control:focus, .form-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(15,118,110,.1);
}
label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 4px;
}

/* ============================
   Select2 Customization
   ============================ */
.select2-container--bootstrap-5 .select2-selection {
  border-radius: var(--radius-md) !important;
  border: 1.5px solid var(--border-color) !important;
  padding: .5rem .8rem !important;
  min-height: 42px !important;
  font-size: 14px;
}
.select2-container--bootstrap-5 .select2-selection--single .select2-selection__rendered {
  padding: 0 !important;
  line-height: 1.6 !important;
}
.select2-container--bootstrap-5.select2-container--focus .select2-selection,
.select2-container--bootstrap-5.select2-container--open .select2-selection {
  border-color: var(--primary) !important;
  box-shadow: 0 0 0 3px rgba(15,118,110,.1) !important;
}
.select2-dropdown {
  border-radius: var(--radius-md) !important;
  border: 1.5px solid var(--border-color) !important;
  box-shadow: var(--shadow-lg) !important;
  overflow: hidden;
}
.select2-results__option {
  padding: 8px 14px !important;
  font-size: 14px;
}
.select2-results__option--highlighted[aria-selected] {
  background: var(--primary) !important;
}
.select2-search--dropdown .select2-search__field {
  border-radius: var(--radius-sm) !important;
  border: 1.5px solid var(--border-color) !important;
  padding: 8px 12px !important;
}

/* ============================
   Badges
   ============================ */
.badge {
  font-size: .8rem;
  font-weight: 600;
  padding: .4em .8em;
  border-radius: var(--radius-sm);
}

/* ============================
   Alerts
   ============================ */
.alert {
  border-radius: var(--radius-md);
  border: none;
  font-size: 14px;
  font-weight: 500;
}

/* ============================
   Login Page
   ============================ */
.login-bg {
  min-height: 100vh;
  background: linear-gradient(135deg, #0f172a 0%, #1e293b 50%, #0f766e 100%);
  display: flex;
  align-items: center;
  position: relative;
}
.login-bg::before {
  content: '';
  position: absolute;
  top: -50%;
  right: -20%;
  width: 600px;
  height: 600px;
  background: radial-gradient(circle, rgba(20,184,166,.15), transparent 70%);
  border-radius: 50%;
}
.login-bg .card {
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  backdrop-filter: blur(8px);
}

/* ============================
   Scrollbar
   ============================ */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

/* ============================
   Responsive
   ============================ */
@media (max-width: 991.98px) {
  .sidebar {
    transform: translateX(100%);
  }
  .sidebar.show {
    transform: translateX(0);
  }
  .sidebar-overlay.show {
    display: block;
    opacity: 1;
  }
  .main-wrapper {
    margin-right: 0;
  }
  .sidebar-toggle {
    display: flex !important;
  }
  .main-content {
    padding: 16px;
  }
  .top-header {
    padding: 0 16px;
  }
}

/* ============================
   Print
   ============================ */
.print-header { display: none; }
@media print {
  .sidebar, .sidebar-overlay, .top-header, .no-print, .btn, .alert { display: none !important; }
  .main-wrapper { margin-right: 0 !important; }
  .main-content { padding: 0 !important; }
  .card { box-shadow: none; border: 1px solid #ddd; }
  .print-header { display: block; }
  .table thead th { background: #eee !important; color: #000 !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
