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

:root {
  --primary: #0B2A4A;
  --primary-light: #1A4D80;
  --brand: #0B2A4A;         /* لون البراند الثابت — مايتغيّرش بين الوضعين (خلفيات/أزرار البراند) */
  --brand-strong: #1B4F86;  /* درجة أوضح لأزرار البراند في الوضع الليلي */
  --accent: #FF6B35;
  --accent-hover: #E85D2A;
  --bg-color: #F3F4F6;
  --surface: #FFFFFF;
  --surface-2: #F9FAFB;
  --surface-3: #F3F4F6;
  --overlay: rgba(11,18,32,0.45);
  --text-main: #1F2937;
  --text-muted: #4B5563; /* darkened from #6B7280 for WCAG AA contrast on white */
  --white: #FFFFFF;
  --border: #E5E7EB;
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-full: 9999px;
  --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  --glass-bg: rgba(255, 255, 255, 0.85);
  --glass-border: rgba(255, 255, 255, 0.18);
  color-scheme: light;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: 'Avenir Next Arabic', 'Avenir Arabic', 'Cairo', -apple-system, BlinkMacSystemFont, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  background-color: var(--bg-color);
  color: var(--text-main);
  direction: rtl; /* Right-to-left for Arabic */
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: background-color .3s ease, color .3s ease;
}

/* Utilities */
.text-primary { color: var(--primary); }
.text-accent { color: var(--accent); }
.text-muted { color: var(--text-muted); }
.font-bold { font-weight: 700; }
.font-semibold { font-weight: 600; }

.d-flex { display: flex; }
.align-items-center { align-items: center; }
.align-items-end { align-items: flex-end; }
.justify-content-between { justify-content: space-between; }
.justify-content-center { justify-content: center; }
.gap-2 { gap: 0.5rem; }
.gap-3 { gap: 1rem; }
.gap-4 { gap: 1.5rem; }
.d-block { display: block; }
.flex-wrap { flex-wrap: wrap; }

/* Responsive Utilities */
.d-none { display: none !important; }
.d-block { display: block !important; }
.d-flex { display: flex !important; }

@media (min-width: 768px) {
  .d-md-none { display: none !important; }
  .d-md-flex { display: flex !important; }
  .d-md-block { display: block !important; }
}

.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: 0.25rem; }
.mb-2 { margin-bottom: 0.5rem; }
.mb-3 { margin-bottom: 1rem; }
.mb-4 { margin-bottom: 1.5rem; }
.mt-1 { margin-top: 0.25rem; }
.mt-3 { margin-top: 1rem; }
.mt-4 { margin-top: 1.5rem; }

/* Effects Classes */
.transition-hover { transition: var(--transition); }
.custom-hover:hover { background-color: rgba(255,255,255,0.1); transform: translateX(-5px); }
.shadow-hover:hover { box-shadow: 0 10px 20px rgba(0,0,0,0.15); transform: translateY(-3px); }
.btn-hover-effect { transition: var(--transition); }
.btn-hover-effect:hover { box-shadow: 0 8px 15px rgba(255, 107, 53, 0.3); transform: translateY(-3px); }

/* Animations Keyframes */
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes fadeInUp { from { opacity: 0; transform: translateY(25px); } to { opacity: 1; transform: translateY(0); } }
@keyframes fadeInDown { from { opacity: 0; transform: translateY(-25px); } to { opacity: 1; transform: translateY(0); } }
@keyframes pulseLogo { 0% { transform: scale(1); } 50% { transform: scale(1.05); } 100% { transform: scale(1); } }
@keyframes shimmer { 0% { background-position: -200% 0; } 100% { background-position: 200% 0; } }
@keyframes slideInRight { from { opacity:0; transform: translateX(30px); } to { opacity:1; transform: translateX(0); } }
@keyframes bounceIn { 0% { transform: scale(0.3); opacity: 0; } 50% { transform: scale(1.05); } 70% { transform: scale(0.9); } 100% { transform: scale(1); opacity: 1; } }

.fade-in { animation: fadeIn 0.4s ease forwards; opacity: 0; }
.fade-in-up { animation: fadeInUp 0.5s ease forwards; opacity: 0; }
.fade-in-down { animation: fadeInDown 0.5s ease forwards; opacity: 0; }

/* Staggered lists */
.staggered-fade-in .item { opacity: 0; animation: fadeInUp 0.4s ease forwards; }
.staggered-fade-in .item:nth-child(1) { animation-delay: 0.1s; }
.staggered-fade-in .item:nth-child(2) { animation-delay: 0.2s; }
.staggered-fade-in .item:nth-child(3) { animation-delay: 0.3s; }
.staggered-fade-in .item:nth-child(4) { animation-delay: 0.4s; }
.staggered-fade-in .item:nth-child(5) { animation-delay: 0.5s; }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.6rem 1.5rem;
  border-radius: var(--radius-md);
  font-weight: 600;
  cursor: pointer;
  border: none;
  font-size: 0.95rem;
  gap: 0.5rem;
  font-family: inherit;
  letter-spacing: 0.02em;
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

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

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

.btn-outline {
  background-color: transparent;
  border: 1px solid var(--border);
  color: var(--text-main);
}
.btn-outline:hover {
  background-color: var(--bg-color);
}

/* Header Global Components (Shared by Admin & Employee) */
.header-action-btn {
  background: none;
  border: none;
  font-size: 1.25rem;
  color: var(--text-muted);
  cursor: pointer;
  position: relative;
  width: 42px;
  height: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: var(--transition);
}

.header-action-btn:hover {
  background: rgba(255,107,53,0.08);
  color: var(--accent);
}

.notif-badge {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 10px;
  height: 10px;
  background-color: var(--accent);
  border-radius: 50%;
  border: 2px solid var(--surface);
  box-shadow: 0 0 10px rgba(255,107,53,0.3);
}


.header-profile-btn {
  cursor: pointer;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  overflow: hidden;
  border: 2px solid var(--border);
  transition: var(--transition);
}

.header-profile-btn.active,
.header-profile-btn:hover {
  border-color: var(--primary);
  transform: scale(1.05);
}

.header-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 200px;
  display: none;
  flex-direction: column;
  padding: 0.5rem;
  margin-top: 10px;
  z-index: 1001;
  animation: fadeInDown 0.3s ease;
}

.header-dropdown.active {
  display: flex;
}

.dropdown-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0.75rem 1rem;
  font-size: 0.9rem;
  color: var(--text-main);
  text-decoration: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: var(--transition);
}

.dropdown-item:hover {
  background: var(--bg-color);
  color: var(--primary);
}

.dropdown-item i {
  font-size: 1.1rem;
  width: 20px;
  text-align: center;
}

.dropdown-item.text-error:hover {
  background: #fef2f2;
}

/* Notifications Dropdown */
.notif-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: 0 15px 40px rgba(0,0,0,0.15);
  width: 320px;
  display: none;
  flex-direction: column;
  padding: 0;
  margin-top: 12px;
  z-index: 1001;
  animation: fadeInDown 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
  max-height: 450px;
  overflow: hidden;
}

.notif-dropdown.active {
  display: flex;
}

.notif-header {
  padding: 1rem 1.2rem;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  font-weight: 800;
  color: var(--primary);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.95rem;
}

.notif-list {
  overflow-y: auto;
  max-height: 400px;
}

.notif-item {
  padding: 1.2rem;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  gap: 12px;
  position: relative;
}

.notif-item:last-child { border-bottom: none; }

.notif-item:hover {
  background: #fff8f5;
}

.notif-item.unread {
  background: rgba(255,107,53, 0.04);
}

.notif-item.unread::before {
  content: '';
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  width: 8px;
  height: 8px;
  background: var(--accent);
  border-radius: 50%;
}

.notif-icon {
  width: 40px;
  height: 40px;
  background: var(--bg-color);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent);
  flex-shrink: 0;
  font-size: 1.1rem;
}

.notif-item-body { flex: 1; }
.notif-title {
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--primary);
  margin-bottom: 2px;
}
.notif-message {
  font-size: 0.82rem;
  color: var(--text-muted);
  line-height: 1.4;
}
.notif-time {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-top: 4px;
}
.notif-empty {
  padding: 3rem 2rem;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.9rem;
}


/* Premium Dropdown Select Styling */
.premium-select-container {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
}

.premium-select-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 4px 12px;
  border-radius: 14px;
  transition: var(--transition);
  box-shadow: var(--shadow-sm);
  min-width: 120px;
}

.premium-select-wrapper:hover {
  border-color: var(--accent);
  box-shadow: 0 4px 12px rgba(255,107,53,0.12);
  transform: translateY(-1px);
}

.premium-select-wrapper i {
  color: var(--accent);
  font-size: 0.9rem;
  opacity: 0.9;
}

.select-premium {
  appearance: none;
  -webkit-appearance: none;
  background: transparent;
  border: none;
  padding: 0.5rem 0.5rem;
  padding-left: 1.8rem; /* space for the custom arrow in RTL */
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--primary);
  cursor: pointer;
  width: 100%;
  outline: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%23FF6B35' stroke-width='4'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' d='M19.5 8.25l-7.5 7.5-7.5-7.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: left 4px center;
  background-size: 0.9rem;
  font-family: inherit;
}

.select-premium:focus {
  color: var(--accent);
}

/* Forms */

.form-group {
  margin-bottom: 1.25rem;
}

.form-label {
  display: block;
  font-weight: 600;
  margin-bottom: 0.5rem;
  color: var(--text-main);
  font-size: 0.95rem;
}

.form-control {
  width: 100%;
  padding: 0.75rem 1rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  font-size: 0.95rem;
  transition: var(--transition), background-color .3s ease, color .3s ease;
  background-color: var(--surface);
  color: var(--text-main);
  font-family: inherit;
}

.form-control:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(255, 107, 53, 0.15);
}

/* Custom Select Arrow */
.custom-select-arrow {
  appearance: none;
  background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%231F2937' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
  background-repeat: no-repeat;
  background-position: left 1rem center;
  background-size: 1em;
}

/* Cards */
.card {
  background-color: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: 1.5rem;
  transition: all 0.35s cubic-bezier(0.4, 0, 0.2, 1), background-color .3s ease, color .3s ease;
  border: 1px solid var(--border);
}
.card:hover {
  box-shadow: var(--shadow-md);
}

/* Alerts */
.alert {
  padding: 1rem;
  border-radius: var(--radius-md);
  margin-bottom: 1.5rem;
  font-size: 0.95rem;
  display: none;
}
.alert.show { display: block; }
.alert-error {
  background-color: #fef2f2;
  color: #b91c1c;
  border: 1px solid #fecaca;
}
.alert-success {
  background-color: #f0fdf4;
  color: #15803d;
  border: 1px solid #bbf7d0;
}

/* Badges */
.badge {
  padding: 0.3rem 0.8rem;
  border-radius: var(--radius-full);
  font-size: 0.8rem;
  font-weight: 700;
}
.badge-active { background-color: #dcfce7; color: #166534; border: 1px solid #bbf7d0; }
.badge-expired { background-color: #f3f4f6; color: #4b5563; border: 1px solid #e5e7eb; }

.white-logo {
  filter: brightness(0) invert(1) drop-shadow(0 4px 10px rgba(0,0,0,0.3));
}

/* ═══════════════════════════════════════════════════════
   Login Page — 3D Glassmorphism Theme
   ═══════════════════════════════════════════════════════ */
.split-login-wrapper {
  display: flex;
  min-height: 100vh;
  background: url('../dev_hero.png') center/cover no-repeat fixed;
  background-color: var(--brand); /* fallback */
  position: relative;
  overflow: hidden;
}

/* Dark overlay to make text and form pop */
.split-login-wrapper::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(11, 42, 74, 0.75);
  z-index: 1;
}

.login-visual {
  flex: 1.2;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 3rem;
  position: relative;
  z-index: 2;
  background: transparent;
}

.login-form-side {
  flex: 1;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 2rem;
  background-color: transparent;
  position: relative;
  z-index: 2;
  overflow: hidden;
}

.login-card {
  background: rgba(11, 42, 74, 0.4);
  backdrop-filter: blur(25px);
  -webkit-backdrop-filter: blur(25px);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 24px;
  padding: 3.5rem 3rem;
  width: 100%;
  max-width: 450px;
  box-shadow: 0 30px 60px -15px rgba(0, 0, 0, 0.5), 
              inset 0 0 0 1px rgba(255,255,255,0.1);
  position: relative;
  z-index: 10;
  color: #fff;
}

.login-title {
  color: #ffffff;
  font-size: 1.6rem;
  font-weight: 800;
  margin-bottom: 0.5rem;
  text-align: center;
}

.login-card .text-muted {
  color: #cbd5e1 !important;
  text-align: center;
}

.login-card .form-label {
  color: #f1f5f9;
}

.login-card .form-control {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #fff;
}
.login-card .form-control::placeholder {
  color: rgba(255, 255, 255, 0.5);
}
.login-card .form-control:focus {
  background: rgba(255, 255, 255, 0.15);
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(255, 107, 53, 0.25);
}



/* Dashboard Layout */
.app-layout {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 280px;
  background-color: var(--brand);
  color: var(--white);
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
  z-index: 20;
  transition: var(--transition);
}

.sidebar-header {
  border-bottom: 1px solid rgba(255,255,255,0.05);
}

.sidebar-brand {
  color: var(--white);
  font-size: 1.5rem;
  font-weight: 800;
  text-decoration: none;
}

.sidebar-nav {
  padding: 1.5rem 1rem;
  flex: 1;
}

.nav-item {
  display: flex;
  align-items: center;
  padding: 0.8rem 1rem;
  color: rgba(255,255,255,0.8);
  text-decoration: none;
  border-radius: var(--radius-md);
  margin-bottom: 0.5rem;
  font-weight: 600;
  transition: var(--transition);
  cursor: pointer;
}

.nav-item:hover, .nav-item.active {
  background-color: rgba(255,255,255,0.1);
  color: var(--white);
}

.nav-item.active {
  border-right: 4px solid var(--accent);
}

.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}

.topbar {
  background-color: var(--surface);
  padding: 0.7rem 1.8rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  z-index: 10;
  position: relative;
  border-bottom: 1px solid var(--border);
  transition: background-color .3s ease;
}

.user-profile-menu {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background-color: var(--accent);
  color: var(--white);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  font-size: 1.2rem;
  transition: var(--transition);
}

.content-area {
  padding: 2rem;
  flex: 1;
  overflow-y: auto;
}

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

/* Tabs */
.tab-content { display: none; }
.tab-content.active { display: block; }

/* Table */
.table-responsive {
  overflow-x: auto;
}

.table {
  width: 100%;
  border-collapse: collapse;
}

.table th, .table td {
  padding: 1.25rem 1rem;
  text-align: right;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.table th {
  background-color: var(--surface-2);
  font-weight: 700;
  color: var(--text-muted);
  font-size: 0.95rem;
  transition: background-color .3s ease, color .3s ease;
}

.table tbody tr {
  transition: var(--transition), background-color .3s ease;
}

.table tbody tr:hover {
  background-color: var(--surface-2);
}

/* Modals */
.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background-color: rgba(0,0,0,0.5);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 50;
  backdrop-filter: blur(4px);
}
.modal-overlay.active { display: flex; }

.modal {
  background-color: var(--surface);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 600px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  transition: background-color .3s ease, color .3s ease;
}

.modal-header {
  padding: 1.5rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: sticky;
  top: 0;
  background-color: var(--surface);
  z-index: 10;
}

.modal-title {
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--primary);
  display: flex;
  align-items: center;
  gap: 10px;
}

.modal-close {
  background: none; border: none;
  font-size: 1.8rem; color: var(--text-muted);
  cursor: pointer; line-height: 1;
}
.modal-close:hover { color: var(--accent); transform: scale(1.1); }

.modal-body {
  padding: 1.5rem;
}

.modal-footer {
  padding: 1.5rem;
  border-top: 1px solid var(--border);
  display: flex;
  /* RTL: زر التأكيد/الأساسي (آخر عنصر في الـ DOM) يظهر في أقصى اليمين والإلغاء يساره */
  flex-direction: row-reverse;
  justify-content: flex-end;
  gap: 1rem;
  position: sticky;
  bottom: 0;
  background-color: var(--surface);
  z-index: 10;
}

/* Mobile Menu Btn Default */
.mobile-only-btn { display: none !important; }

/* Responsive */
@media (max-width: 992px) {
  .split-login-wrapper { 
    flex-direction: column; 
    background-attachment: scroll !important; /* Fixed background is buggy on mobile */
    background-position: top center; /* Focus on the hero part of the image */
  }
  .login-visual { 
    flex: none; 
    min-height: 40vh; /* Give more vertical prominence to the visual on mobile */
    padding: 3rem 2rem; 
    justify-content: flex-end; 
  }
  .login-visual > div { max-width: 100% !important; text-align: center !important; }
}
@media (max-width: 768px) {
  .mobile-only-btn { display: block !important; border: 1px solid var(--border) !important; color: var(--text-main) !important; }
  .app-layout { flex-direction: column; }
  .sidebar { width: 280px; height: 100vh; position: fixed; top: 0; right: -280px; z-index: 1000; transition: 0.3s ease; }
  .sidebar.active { right: 0; box-shadow: 0 0 50px rgba(0,0,0,0.5); }
  .topbar { flex-wrap: wrap; }
  .content-area { padding: 1rem; }
  .page-title { font-size: 1.5rem; }
  .login-card { padding: 2rem; border-radius: 20px; }
  .bottom-nav { padding: 0.2rem 0; gap: 2px; }
}

.border-right-accent { border-right: 5px solid var(--accent) !important; }
.border-right-primary { border-right: 5px solid var(--primary) !important; }

@media (max-width: 480px) {
  .bottom-nav-item span { font-size: 0.58rem !important; letter-spacing: -0.5px; }
  .bottom-nav-item i { font-size: 0.9rem !important; }
  .bottom-nav-item { padding: 0.3rem 0; }
}

/* News Feed Specifics */
.news-card {
    transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275), box-shadow 0.4s ease;
    border: 1px solid rgba(255,255,255,0.3) !important;
}
.news-card:hover {
    transform: translateY(-8px) scale(1.02);
    box-shadow: 0 20px 40px rgba(0,0,0,0.12) !important;
}
.news-image-wrapper {
    overflow: hidden;
}
.news-image-wrapper img {
    transition: transform 0.6s ease;
}
.news-card:hover .news-image-wrapper img {
    transform: scale(1.1);
}

/* Layout Polish - Fixed Header Gap & System Status Bar Integration */
html, body {
  margin: 0;
  padding: 0;
  background-color: var(--bg-color);
}

.emp-layout, .app-layout {
  padding-top: 0 !important;
  min-height: 100vh;
}

/* Ensure background color extends into the status bar area (iOS/Android Support) */
.emp-header, .topbar {
  padding-top: env(safe-area-inset-top, 0.8rem) !important;
}

.emp-content, .main-content {
  padding-top: 0.5rem !important; /* Managed spacing for content below fixed header */
}

/* Custom Alert & Toast System (Replacements for browser alert) */
.custom-alert-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(11, 42, 74, 0.4);
  backdrop-filter: blur(8px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  animation: fadeIn 0.3s ease;
  padding: 20px;
}
.custom-alert-overlay.active { display: flex; }

.custom-alert {
  background: var(--surface);
  border-radius: 20px;
  width: 100%;
  max-width: 400px;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
  overflow: hidden;
  animation: bounceIn 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

.custom-alert-header {
  padding: 24px 24px 12px;
  text-align: center;
}

.custom-alert-icon {
  font-size: 3rem;
  margin-bottom: 10px;
  display: block;
}

.custom-alert-title {
  font-size: 1.3rem;
  font-weight: 800;
  color: var(--primary);
  margin-bottom: 8px;
}

.custom-alert-body {
  padding: 0 24px 24px;
  color: var(--text-muted);
  text-align: center;
  line-height: 1.6;
  font-size: 0.95rem;
  white-space: pre-line; /* يحافظ على فواصل الأسطر (\n) في رسائل متعددة الأسطر */
}

.custom-alert-footer {
  padding: 0 24px 24px;
  display: flex;
  justify-content: center;
}

.custom-alert-btn {
  padding: 12px 30px;
  border-radius: 12px;
  font-weight: 700;
  cursor: pointer;
  border: none;
  background: var(--brand);
  color: white;
  transition: var(--transition);
  width: 100%;
  font-size: 1rem;
}

.custom-alert-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 15px -3px rgba(11, 42, 74, 0.3);
}

/* Custom Toast */
.custom-toast {
  position: fixed;
  bottom: 110px; 
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: var(--brand);
  color: white;
  padding: 12px 24px;
  border-radius: 50px;
  box-shadow: 0 10px 25px rgba(0,0,0,0.2);
  z-index: 11000;
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: 600;
  font-size: 0.95rem;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.custom-toast.active {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

/* Funny Modal Fine-Tuning */
#funnyWarningModal .modal {
  max-width: 380px !important;
  width: 90% !important;
  border-radius: 30px !important;
  border: 4px solid var(--accent) !important;
  overflow: visible !important;
}

@media (max-width: 480px) {
  .news-card {
    margin-bottom: 2.5rem !important;
  }
  .emp-content {
      padding-top: 0.5rem !important;
  }
}


/* ════════════════════════════════════════ */
/* Dashboard Stats Grid (New Premium Section) */
/* ════════════════════════════════════════ */
.dashboard-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 24px;
}

.stat-card-premium {
  background: var(--surface);
  padding: 1rem 0.5rem;
  border-radius: 18px;
  border: 1px solid var(--border);
  text-align: center;
  transition: var(--transition);
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.stat-card-premium:hover {
  transform: translateY(-5px);
  box-shadow: 0 10px 25px rgba(0,0,0,0.08);
  border-color: var(--accent);
}

.stat-card-premium i {
  font-size: 1.3rem;
  color: var(--accent);
  background: rgba(255,107,53,0.1);
  width: 45px;
  height: 45px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 14px;
}

.stat-card-val {
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--primary);
}

.stat-card-label {
  font-size: 0.65rem;
  color: var(--text-muted);
  font-weight: 700;
}

/* ════════════════════════════════════════ */
/* Attendance Card (Check-in/Out)           */
/* ════════════════════════════════════════ */
.attendance-card {
  background: linear-gradient(135deg, var(--brand), #2d3e50);
  padding: 2rem 1.5rem;
  border-radius: 24px;
  color: var(--white);
  text-align: center;
  position: relative;
  overflow: hidden;
  box-shadow: 0 15px 35px rgba(26, 42, 62, 0.25);
  margin-bottom: 24px;
}

.attendance-card::before {
  content: '';
  position: absolute;
  top: -50%;
  right: -50%;
  width: 100%;
  height: 100%;
  background: radial-gradient(circle, rgba(255,107,53,0.15) 0%, transparent 70%);
}

.attendance-time {
  font-size: 2.8rem;
  font-weight: 800;
  margin-bottom: 0.5rem;
  letter-spacing: -1px;
}

.attendance-date {
  font-size: 0.9rem;
  opacity: 0.8;
  margin-bottom: 1.5rem;
}

.attendance-btn-container {
  display: flex;
  justify-content: center;
  gap: 15px;
}

.att-btn {
  padding: 0.8rem 1.5rem;
  border-radius: 14px;
  border: none;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.95rem;
  box-shadow: 0 4px 15px rgba(0,0,0,0.2);
}

.att-btn-in {
  background: #10b981;
  color: white;
}

.att-btn-out {
  background: #ef4444;
  color: white;
}

.att-btn:hover {
  transform: scale(1.05);
  filter: brightness(1.1);
}

.att-btn:active {
  transform: scale(0.95);
}

.att-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

/* ════════════════════════════════════════ */
/* Admin Analytics (Charts/Bars)            */
/* ════════════════════════════════════════ */
.analytics-chart-container {
  margin-top: 15px;
}

.chart-bar-item {
  margin-bottom: 15px;
}

.chart-bar-info {
  display: flex;
  justify-content: space-between;
  margin-bottom: 6px;
  font-size: 0.85rem;
  font-weight: 600;
}

.chart-bar-bg {
  height: 8px;
  background: var(--surface-3);
  border-radius: 10px;
  overflow: hidden;
}

.chart-bar-fill {
  height: 100%;
  border-radius: 10px;
  transition: width 1s ease-in-out;
}

/* ════════════════════════════════════════════════════════ */
/* 🎨 UI/UX Polish v2.1 — Mobile + Consistency Improvements */
/* ════════════════════════════════════════════════════════ */

/* — Tables: better mobile experience — */
.table-responsive {
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  scrollbar-color: var(--accent) transparent;
}
.table-responsive::-webkit-scrollbar { height: 6px; }
.table-responsive::-webkit-scrollbar-thumb {
  background: var(--accent);
  border-radius: 10px;
}

/* Sticky table headers for long lists */
.table thead th {
  position: sticky;
  top: 0;
  z-index: 5;
  background-color: var(--surface-2);
}

/* — Action button rows: ensure they wrap nicely — */
.d-flex.gap-2,
.d-flex.gap-3 {
  row-gap: 0.5rem;
}

/* — Better focus states for accessibility — */
.btn:focus-visible,
.form-control:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* — Smooth empty states — */
.table tbody tr td.text-center.text-muted {
  padding: 2.5rem 1rem;
  font-size: 0.95rem;
}

/* — Mobile-first table & button refinements — */
@media (max-width: 768px) {
  /* Reduce table cell padding on mobile so more fits on screen */
  .table th,
  .table td {
    padding: 0.85rem 0.6rem;
    font-size: 0.85rem;
  }
  .table th {
    font-size: 0.78rem;
  }

  /* Action buttons in table rows: stack vertically on small screens */
  .table td .btn {
    padding: 0.4rem 0.6rem !important;
    font-size: 0.75rem;
  }

  /* Make headline action button rows scroll horizontally instead of cramming */
  .d-flex.justify-content-between.flex-wrap > .d-flex.gap-2 {
    flex-wrap: wrap;
    justify-content: flex-start;
    width: 100%;
  }
  .d-flex.justify-content-between.flex-wrap > .d-flex.gap-2 .btn {
    flex: 1 1 calc(50% - 0.25rem);
    min-width: 0;
    font-size: 0.8rem;
    padding: 0.55rem 0.7rem;
    white-space: nowrap;
  }

  /* Modal full-width feel on mobile */
  .modal {
    max-width: 95vw;
    border-radius: 16px;
  }
  .modal-header,
  .modal-body,
  .modal-footer {
    padding: 1rem;
  }
  .modal-title {
    font-size: 1.05rem;
  }

  /* Cards spacing */
  .card {
    padding: 1rem;
  }
}

@media (max-width: 480px) {
  .table th,
  .table td {
    padding: 0.6rem 0.45rem;
    font-size: 0.78rem;
  }
  /* Action buttons in headline rows take full width on tiny screens */
  .d-flex.justify-content-between.flex-wrap > .d-flex.gap-2 .btn {
    flex: 1 1 100%;
  }
  .page-title {
    font-size: 1.2rem !important;
  }
}

/* — Loading skeleton (subtle shimmer for empty states) — */
@keyframes oaf-shimmer {
  0%   { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}
.oaf-skeleton {
  background: linear-gradient(90deg, var(--surface-2) 25%, var(--surface-3) 50%, var(--surface-2) 75%);
  background-size: 200% 100%;
  animation: oaf-shimmer 1.4s ease-in-out infinite;
  border-radius: 8px;
}

/* — Button hover refinement for consistency — */
.btn-hover-effect {
  position: relative;
  overflow: hidden;
}
.btn-hover-effect::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, transparent 0%, rgba(255,255,255,0.18) 50%, transparent 100%);
  transform: translateX(-100%);
  transition: transform 0.5s ease;
  pointer-events: none;
}
.btn-hover-effect:hover::after {
  transform: translateX(100%);
}

/* — Disabled buttons clarity — */
.btn:disabled,
.btn[disabled] {
  cursor: not-allowed;
  opacity: 0.5;
  pointer-events: none;
}


/* ════════════════════════════════════════════════════════ */
/* ♿ Accessibility, RTL & Reusable Helpers                   */
/* ════════════════════════════════════════════════════════ */

/* — Comfortable touch target for buttons (44px) — */
/* مساحة لمس مريحة للأزرار مع الحفاظ على الأزرار المدمجة/الصغيرة */
.btn {
  min-height: 44px;
}
/* استثناءات: الأزرار المدمجة داخل الجداول والصفوف الصغيرة لا تتأثر */
.table td .btn,
.btn-compact,
.btn-sm,
.btn-icon {
  min-height: 0;
}
@media (max-width: 768px) {
  /* أزرار صفوف العناوين المضغوطة على الموبايل تبقى مدمجة */
  .d-flex.justify-content-between.flex-wrap > .d-flex.gap-2 .btn {
    min-height: 0;
  }
}

/* — Visible keyboard focus rings (focus-visible) — */
/* حلقات تركيز واضحة للوحة المفاتيح على العناصر التفاعلية */
.btn:focus-visible,
.btn-danger:focus-visible,
.home-grid-item:focus-visible,
.home-att-btn:focus-visible,
.header-action-btn:focus-visible,
.header-profile-btn:focus-visible,
.nav-item:focus-visible,
.ts-pill:focus-visible,
.dropdown-item:focus-visible,
.att-btn:focus-visible,
.modal-close:focus-visible,
.custom-alert-btn:focus-visible,
button:focus-visible,
a:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}
/* الحفاظ على الشكل الدائري أثناء التركيز للعناصر الدائرية */
.header-action-btn:focus-visible,
.header-profile-btn:focus-visible,
.modal-close:focus-visible {
  border-radius: 50%;
}

/* — Destructive action button — */
/* زر الإجراءات الخطرة (الحذف/المسح) — تستخدمه admin.html بـ class "btn-danger" */
.btn-danger {
  background: #b91c1c;
  color: #fff;
  border: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem; /* مسافة للأيقونة */
}
.btn-danger:hover {
  background: #991b1b;
}

/* — Reusable skeleton shimmer (loading placeholders) — */
/* عنصر هيكلي متحرك لأماكن التحميل */
.skeleton {
  background: linear-gradient(90deg, var(--surface-2) 25%, var(--surface-3) 50%, var(--surface-2) 75%);
  background-size: 200% 100%;
  animation: oaf-shimmer 1.4s ease-in-out infinite;
  border-radius: var(--radius-md);
  display: block;
  min-height: 1rem;
}
@media (prefers-reduced-motion: reduce) {
  .skeleton { animation: none; }
  .oaf-skeleton { animation: none; }
}

/* ════════════════════════════════════════════════════════ */
/* Dark Theme Overrides                                     */
/* Activated via <html data-theme="dark"> on the root      */
/* ════════════════════════════════════════════════════════ */
html[data-theme="dark"] {
  --bg-color:   #0B1220;
  --surface:    #121A2B;
  --surface-2:  #1B2740;
  --surface-3:  #223052;
  --text-main:  #E6EAF2;
  --text-muted: #9AA7BD;
  --border:     #243049;
  --overlay:    rgba(0,0,0,0.6);
  --shadow-sm:  0 1px 2px rgba(0,0,0,.4);
  --shadow-md:  0 4px 12px rgba(0,0,0,.45);
  --shadow-lg:  0 12px 32px rgba(0,0,0,.5);
  --primary:       #7FB0DA;  /* "primary" كنص → أزرق فاتح مقروء على الخلفية الغامقة */
  /* --accent (برتقالي) و --brand (كحلي) ثابتين — واضحين على الغامق */
  color-scheme: dark;
}

/* Dark mode: أزرار البراند تتلوّن أوضح عشان تبان على الخلفية الغامقة */
html[data-theme="dark"] .btn-primary { background-color: var(--brand-strong); }

/* Dark mode: skeleton shimmer uses dark-friendly palette */
html[data-theme="dark"] .oaf-skeleton,
html[data-theme="dark"] .skeleton {
  background: linear-gradient(90deg, var(--surface-2) 25%, var(--surface-3) 50%, var(--surface-2) 75%);
  background-size: 200% 100%;
}

/* Dark mode: notif-item hover & unread use surface tokens */
html[data-theme="dark"] .notif-item:hover {
  background: var(--surface-2);
}
html[data-theme="dark"] .notif-item.unread {
  background: rgba(255,107,53,0.06);
}

/* Dark mode: dropdown error item hover */
html[data-theme="dark"] .dropdown-item.text-error:hover {
  background: rgba(185,28,28,0.15);
}

/* Dark mode: modal-btn-cancel subtle bg */
html[data-theme="dark"] .modal-btn-cancel:hover {
  background: var(--surface-2);
}

/* ═══════════════════════════════════════ */
/* Smart Dashboard (لوحة المعلومات الذكية)  */
/* ═══════════════════════════════════════ */
#smartDashboard { margin-bottom: 1.5rem; }
.dash-kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem; margin-bottom: 1.25rem; }
.dash-kpi { display: flex; align-items: center; gap: .9rem; background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 1.1rem 1.2rem; box-shadow: var(--shadow-sm); transition: transform .2s ease, box-shadow .2s ease; }
.dash-kpi:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); }
.dash-kpi-icon { width: 52px; height: 52px; border-radius: 14px; display: flex; align-items: center; justify-content: center; font-size: 1.4rem; flex-shrink: 0; }
.dash-kpi-value { font-size: 1.8rem; font-weight: 800; color: var(--text-main); line-height: 1.1; }
.dash-kpi-label { font-size: .85rem; color: var(--text-muted); margin-top: 2px; }
.dash-kpi-sub { font-size: .72rem; color: var(--text-muted); margin-top: 3px; opacity: .9; }
.dash-trend { font-size: .72rem; font-weight: 700; padding: 2px 7px; border-radius: 6px; display: inline-block; margin-top: 3px; }
.dash-trend.up { color: #10b981; background: rgba(16,185,129,.12); }
.dash-trend.down { color: #ef4444; background: rgba(239,68,68,.12); }
.dash-trend.flat { color: var(--text-muted); background: var(--surface-2); }
.dash-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; margin-bottom: 1.25rem; }
.dash-card { padding: 1.2rem; }
.dash-h { font-size: 1rem; color: var(--text-main); margin: 0 0 1rem; font-weight: 700; }
.dash-chart { position: relative; height: 240px; }
.dash-empty { display: flex; flex-direction: column; align-items: center; justify-content: center; height: 100%; min-height: 180px; color: var(--text-muted); gap: .5rem; font-size: .9rem; text-align: center; }
.dash-empty i { font-size: 1.8rem; opacity: .4; }
.dash-insights .dash-insight { display: flex; align-items: center; gap: .6rem; padding: .7rem .9rem; background: var(--surface-2); border-radius: 10px; margin-bottom: .6rem; font-size: .9rem; color: var(--text-main); }
.dash-insights .dash-insight:last-child { margin-bottom: 0; }
@media (max-width: 992px) { .dash-grid { grid-template-columns: 1fr; } .dash-kpis { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 560px) { .dash-kpis { grid-template-columns: 1fr; } }
