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

/* ===== Variables ===== */
:root {
  --primary:        #3b5bdb;
  --primary-light:  #e8ecff;
  --primary-hover:  #2f4ac0;
  --success:        #25c160;
  --success-light:  #e6f9ee;
  --warning:        #f59e0b;
  --warning-light:  #fef3c7;
  --danger:         #ef4444;
  --danger-light:   #fef2f2;
  --info:           #3b82f6;
  --body-bg:        #f5f7fa;
  --card-bg:        #ffffff;
  --text-dark:      #1a1d23;
  --text-mid:       #495057;
  --text-muted:     #8896aa;
  --border:         #e9ecef;
  --nav-h:          56px;
  --radius:         10px;
  --radius-sm:      7px;
  --shadow-sm:      0 1px 4px rgba(0,0,0,0.07);
  --shadow:         0 2px 16px rgba(0,0,0,0.09);
  --transition:     all 0.2s ease;
}

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

body {
  font-family: 'Cairo', 'Segoe UI', Tahoma, Arial, sans-serif;
  background: var(--body-bg);
  color: var(--text-dark);
  font-size: 14px;
  line-height: 1.6;
  min-height: 100vh;
  padding-top: var(--nav-h);
}

/* ===== Top Navbar ===== */
.top-navbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--nav-h);
  background: var(--card-bg);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  z-index: 1050;
  box-shadow: var(--shadow-sm);
}

.navbar-brand-logo {
  width: 36px; height: 36px;
  background: var(--primary);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: #fff;
  font-weight: 800;
  font-size: 1rem;
  text-decoration: none;
  flex-shrink: 0;
}

.navbar-nav-links {
  display: flex;
  align-items: center;
  gap: 4px;
  list-style: none;
  margin: 0; padding: 0;
}

.nav-link-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: var(--radius-sm);
  color: var(--text-mid);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.875rem;
  transition: var(--transition);
  white-space: nowrap;
}
.nav-link-item i { font-size: 0.9rem; }
.nav-link-item:hover {
  background: var(--primary-light);
  color: var(--primary);
}
.nav-link-item.active {
  background: var(--primary-light);
  color: var(--primary);
}

.navbar-home-btn {
  width: 36px; height: 36px;
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  color: var(--text-muted);
  text-decoration: none;
  transition: var(--transition);
  border: 1px solid var(--border);
}
.navbar-home-btn:hover { color: var(--primary); border-color: var(--primary); background: var(--primary-light); }

.navbar-notif-btn {
  position: relative;
  width: 36px; height: 36px;
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  color: var(--text-muted);
  background: none;
  border: 1px solid var(--border);
  cursor: pointer;
  transition: var(--transition);
}
.navbar-notif-btn:hover { color: var(--primary); border-color: var(--primary); background: var(--primary-light); }
.notif-badge {
  position: absolute;
  top: -4px; left: -4px;
  min-width: 18px; height: 18px;
  background: var(--danger);
  color: #fff;
  border-radius: 50%;
  font-size: 0.65rem;
  font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  border: 2px solid var(--card-bg);
  padding: 0 3px;
}

/* ===== Page Layout ===== */
.page-wrapper {
  max-width: 1400px;
  margin: 0 auto;
  padding: 28px 24px 60px;
}

/* ===== Page Header ===== */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 28px;
  flex-wrap: wrap;
  gap: 12px;
}
.page-header-info { text-align: right; }
.page-header-title {
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--text-dark);
  margin: 0 0 2px;
  display: flex;
  align-items: center;
  gap: 10px;
  justify-content: flex-end;
}
.page-header-title .page-icon {
  width: 40px; height: 40px;
  border-radius: var(--radius-sm);
  background: var(--primary-light);
  display: flex; align-items: center; justify-content: center;
  color: var(--primary);
  font-size: 1rem;
}
.page-header-sub {
  color: var(--text-muted);
  font-size: 0.83rem;
  margin: 0;
}

/* ===== Stat Cards ===== */
.stat-cards-row { margin-bottom: 24px; }

.stat-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 22px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  transition: var(--transition);
  cursor: default;
  position: relative;
  overflow: hidden;
}
.stat-card::before {
  content: '';
  position: absolute;
  right: 0; top: 0; bottom: 0;
  width: 3px;
  background: transparent;
  border-radius: 0 var(--radius) var(--radius) 0;
  transition: var(--transition);
}
.stat-card:hover { box-shadow: var(--shadow); }
.stat-card.selected {
  background: var(--primary-light);
  border-color: var(--primary);
}
.stat-card.selected::before { background: var(--primary); }
.stat-card.selected .stat-label { color: var(--primary); }

.stat-text {}
.stat-label { font-size: 0.82rem; color: var(--text-muted); font-weight: 600; margin-bottom: 4px; }
.stat-number { font-size: 2rem; font-weight: 800; color: var(--text-dark); line-height: 1; }
.stat-sub { font-size: 0.75rem; color: var(--text-muted); margin-top: 3px; }

.stat-icon-box {
  width: 48px; height: 48px;
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.2rem;
  flex-shrink: 0;
}
.stat-icon-box.blue    { background: var(--primary-light); color: var(--primary); }
.stat-icon-box.green   { background: var(--success-light); color: var(--success); }
.stat-icon-box.orange  { background: var(--warning-light); color: var(--warning); }
.stat-icon-box.red     { background: var(--danger-light);  color: var(--danger);  }

/* ===== Cards ===== */
.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.card-header {
  background: transparent;
  border-bottom: 1px solid var(--border);
  padding: 14px 20px;
  font-weight: 700;
  font-size: 0.95rem;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-dark);
}
.card-header i { color: var(--primary); }
.card-body { padding: 20px; }

/* ===== Badges ===== */
.badge-status {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 50px;
  font-size: 0.75rem;
  font-weight: 700;
}
.badge-status.active        { background: var(--success-light); color: #166534; }
.badge-status.expiring_soon { background: var(--warning-light); color: #92400e; }
.badge-status.expired       { background: var(--danger-light);  color: #991b1b; }
.badge-status.inactive      { background: #f1f5f9; color: #64748b; }

.badge-type {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  border-radius: 50px;
  font-size: 0.73rem;
  font-weight: 700;
}
.badge-type.openvpn   { background: #ede9fe; color: #4c1d95; }
.badge-type.wireguard { background: #dbeafe; color: #1e40af; }

/* ===== Buttons ===== */
.btn-primary {
  background: var(--primary);
  border-color: var(--primary);
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 0.875rem;
  padding: 9px 20px;
}
.btn-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }

.btn-outline-primary {
  border-color: var(--primary);
  color: var(--primary);
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 0.875rem;
  padding: 7px 16px;
}
.btn-outline-primary:hover { background: var(--primary); color: #fff; }
.btn-outline-secondary { border-radius: var(--radius-sm); font-weight: 600; font-size: 0.875rem; }
.btn-light             { border-radius: var(--radius-sm); font-weight: 600; font-size: 0.875rem; }

.btn-sm  { padding: 5px 12px !important; font-size: 0.78rem !important; border-radius: var(--radius-sm) !important; }
.btn-icon {
  width: 32px; height: 32px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
}

/* ===== Forms ===== */
.form-label { font-weight: 600; font-size: 0.85rem; color: var(--text-mid); margin-bottom: 5px; }
.form-control, .form-select {
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  font-size: 0.875rem;
  font-family: 'Cairo', sans-serif;
  color: var(--text-dark);
  transition: var(--transition);
}
.form-control:focus, .form-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(59,91,219,0.10);
}
.input-group-text {
  background: #f8f9fa;
  border-color: var(--border);
  color: var(--primary);
  font-size: 0.85rem;
}
.input-group .form-control:focus { z-index: 1; }

/* ===== Select2 ===== */
.select2-container--bootstrap-5 .select2-selection {
  border: 1.5px solid var(--border) !important;
  border-radius: var(--radius-sm) !important;
  font-family: 'Cairo', sans-serif;
  font-size: 0.875rem;
  min-height: 42px !important;
}
.select2-container--bootstrap-5.select2-container--focus .select2-selection {
  border-color: var(--primary) !important;
  box-shadow: 0 0 0 3px rgba(59,91,219,0.10) !important;
}
.select2-container--bootstrap-5 .select2-dropdown {
  border-radius: var(--radius-sm);
  border-color: var(--border);
  font-family: 'Cairo', sans-serif;
  font-size: 0.875rem;
}

/* ===== Flatpickr overrides ===== */
.flatpickr-input { background: #fff !important; }
.flatpickr-calendar { font-family: 'Cairo', sans-serif; border-radius: var(--radius); box-shadow: var(--shadow); border: 1px solid var(--border); }
.flatpickr-day.selected, .flatpickr-day.selected:hover { background: var(--primary); border-color: var(--primary); }
.flatpickr-day:hover { background: var(--primary-light); }

/* ===== DataTables ===== */
.dataTables_wrapper .dataTables_length select,
.dataTables_wrapper .dataTables_filter input {
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  font-family: 'Cairo', sans-serif;
  font-size: 0.85rem;
}
.dataTables_wrapper .dataTables_filter input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(59,91,219,0.10);
}
table.dataTable {
  border-collapse: collapse !important;
}
table.dataTable thead th {
  background: #f8f9fa;
  color: var(--text-muted);
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  border-bottom: 1px solid var(--border) !important;
  border-top: none !important;
  padding: 10px 14px;
  white-space: nowrap;
}
table.dataTable thead th.sorting::before,
table.dataTable thead th.sorting::after,
table.dataTable thead th.sorting_asc::before,
table.dataTable thead th.sorting_asc::after,
table.dataTable thead th.sorting_desc::before,
table.dataTable thead th.sorting_desc::after {
  opacity: 0.4;
}
table.dataTable tbody td {
  padding: 11px 14px;
  vertical-align: middle;
  border-bottom: 1px solid #f1f3f7;
  border-top: none !important;
}
table.dataTable tbody tr:hover td { background: #f8f9fc; }
table.dataTable tbody tr.table-danger td  { background: #fff5f5; }
table.dataTable tbody tr.table-warning td { background: #fffbeb; }

/* ===== Notification dropdown ===== */
.notification-dropdown {
  border-radius: var(--radius) !important;
  border: 1px solid var(--border) !important;
  box-shadow: var(--shadow) !important;
}
.notif-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 11px 16px;
  border-bottom: 1px solid #f1f3f7;
  transition: var(--transition);
}
.notif-item:hover { background: #f8f9fc; }
.notif-item:last-child { border-bottom: none; }
.notif-dot {
  width: 34px; height: 34px;
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  font-size: 0.85rem;
  flex-shrink: 0;
}
.notif-dot.expired       { background: var(--danger-light);  color: var(--danger); }
.notif-dot.expiring_soon { background: var(--warning-light); color: var(--warning); }
.notif-dot.info          { background: var(--primary-light); color: var(--primary); }
.notif-msg  { font-size: 0.8rem; color: var(--text-mid); line-height: 1.4; }
.notif-time { font-size: 0.7rem; color: var(--text-muted); margin-top: 2px; }

/* ===== Notifications page ===== */
.notif-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 18px;
  margin-bottom: 8px;
  border-right: 4px solid transparent;
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: center;
  gap: 14px;
}
.notif-card.expiring_soon { border-right-color: var(--warning); }
.notif-card.expired       { border-right-color: var(--danger);  }

/* ===== File Upload ===== */
.dropzone-area {
  border: 2px dashed #c7d2fe;
  border-radius: var(--radius);
  padding: 28px;
  text-align: center;
  background: #fafbff;
  transition: var(--transition);
  cursor: pointer;
}
.dropzone-area:hover, .dropzone-area.dragover {
  border-color: var(--primary);
  background: var(--primary-light);
}
.dropzone-area .upload-icon { font-size: 2rem; color: #a5b4fc; margin-bottom: 8px; }
.dropzone-area p { color: var(--text-muted); font-size: 0.82rem; margin: 0; }

.attachment-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  background: #f8f9fa;
  border-radius: var(--radius-sm);
  margin-bottom: 6px;
  border: 1px solid var(--border);
}
.attachment-icon { font-size: 1.2rem; }
.attachment-name { font-size: 0.82rem; font-weight: 600; color: var(--text-mid); }
.attachment-size { font-size: 0.72rem; color: var(--text-muted); }

/* ===== Progress ===== */
.progress { height: 7px; border-radius: 10px; background: #f1f3f7; }
.progress-bar { border-radius: 10px; }

/* ===== Tables inside cards ===== */
.table-card tbody tr:last-child td { border-bottom: none; }

/* ===== Agent view card ===== */
.agent-info-row {
  display: flex;
  gap: 6px;
  align-items: flex-start;
  margin-bottom: 10px;
}
.agent-info-label { color: var(--text-muted); font-size: 0.78rem; width: 90px; flex-shrink: 0; }
.agent-info-val   { font-size: 0.85rem; font-weight: 600; color: var(--text-mid); }

/* ===== Footer ===== */
.page-footer {
  text-align: center;
  padding: 16px;
  color: var(--text-muted);
  font-size: 0.78rem;
  border-top: 1px solid var(--border);
  background: var(--card-bg);
  margin-top: 40px;
}

/* ===== Toastr RTL ===== */
#toast-container { direction: rtl; }
#toast-container > .toast { text-align: right; }

/* ===== Misc ===== */
.cursor-pointer { cursor: pointer; }
.gap-10 { gap: 10px; }
.text-primary { color: var(--primary) !important; }
.bg-primary   { background: var(--primary) !important; }
.btn-primary, .badge.bg-primary { background: var(--primary) !important; border-color: var(--primary) !important; }

/* ===== Equal-height stat cards in a row ===== */
.stat-cards-row.align-items-stretch .stat-card {
  height: 100%;
  min-height: 88px;
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
  .page-wrapper { padding: 20px 14px 40px; }
  .page-header-title { font-size: 1.3rem; }
  .navbar-nav-links { gap: 2px; }
  .nav-link-item { padding: 6px 10px; font-size: 0.8rem; }
}
