/* ══════════════════════════════════════════
   نظام حضور وإجازات
   ══════════════════════════════════════════ */

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

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

:root {
  --navy-dark:    #0b1d35;
  --navy:         #0f2a4a;
  --navy-mid:     #163b62;
  --navy-light:   #1e4f84;
  --gold:         #c9952a;
  --gold-light:   #e0b04a;
  --gold-pale:    #fdf3dc;
  --danger:       #c0392b;
  --danger-light: #fdecea;
  --success:      #0a7c59;
  --success-light:#e6f6f1;
  --warn:         #b7600a;
  --warn-light:   #fef0e0;
  --info:         #1565c0;
  --info-light:   #e3f0ff;
  --bg:           #edf0f5;
  --surface:      #ffffff;
  --border:       #d5dce7;
  --border-light: #eaeff5;
  --text:         #0f1e31;
  --text-muted:   #5a7190;
  --text-light:   #8fa6bf;
  --sidebar-w:    260px;
  --radius:       14px;
  --radius-sm:    8px;
  --shadow:       0 2px 12px rgba(11,29,53,.08);
  --shadow-md:    0 6px 24px rgba(11,29,53,.12);
  --shadow-lg:    0 16px 48px rgba(11,29,53,.18);
}

body {
  font-family: 'Tajawal', 'Segoe UI', Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  direction: rtl;
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* ══ Login ══════════════════════════════════ */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--navy-dark);
  background-image:
    radial-gradient(ellipse 80% 60% at 50% -20%, rgba(201,149,42,.18) 0%, transparent 70%),
    linear-gradient(160deg, #0b1d35 0%, #0f2a4a 50%, #092038 100%);
  position: relative;
  overflow: hidden;
}

/* Geometric grid overlay */
.login-page::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(201,149,42,.06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(201,149,42,.06) 1px, transparent 1px);
  background-size: 48px 48px;
}

/* Glowing orbs */
.login-page::after {
  content: '';
  position: absolute;
  width: 600px; height: 600px;
  top: -200px; left: -200px;
  background: radial-gradient(circle, rgba(201,149,42,.08) 0%, transparent 70%);
  border-radius: 50%;
}

.login-card {
  position: relative;
  z-index: 1;
  background: var(--surface);
  border-radius: 20px;
  padding: 44px 40px;
  width: 420px;
  box-shadow: var(--shadow-lg), 0 0 0 1px rgba(201,149,42,.15);
}

.login-logo {
  text-align: center;
  margin-bottom: 32px;
}

.login-logo .brand-icon {
  width: 68px; height: 68px;
  background: linear-gradient(135deg, var(--navy) 0%, var(--navy-light) 100%);
  border-radius: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 30px;
  margin-bottom: 16px;
  box-shadow: 0 8px 24px rgba(15,42,74,.3);
}

.login-logo h1 {
  font-size: 20px;
  font-weight: 800;
  color: var(--navy);
  letter-spacing: -.3px;
}

.login-logo .subtitle {
  color: var(--text-muted);
  font-size: 13px;
  margin-top: 4px;
}

.login-divider {
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--gold), transparent);
  margin: 0 auto 28px;
  width: 60px;
  border-radius: 2px;
}

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

.sidebar {
  width: var(--sidebar-w);
  background: var(--navy-dark);
  background-image: linear-gradient(180deg, #0b1d35 0%, #0f2a4a 100%);
  color: #fff;
  display: flex;
  flex-direction: column;
  position: fixed;
  height: 100vh;
  right: 0;
  z-index: 100;
  border-left: 1px solid rgba(201,149,42,.15);
}

/* Gold accent line at top of sidebar */
.sidebar::before {
  content: '';
  display: block;
  height: 3px;
  background: linear-gradient(90deg, var(--gold-light), var(--gold));
}

.sidebar-brand {
  padding: 20px 18px 18px;
  border-bottom: 1px solid rgba(255,255,255,.07);
}

.sidebar-brand .brand-name {
  font-size: 15px;
  font-weight: 800;
  color: #fff;
  letter-spacing: .2px;
}

.sidebar-brand .brand-sub {
  font-size: 11px;
  color: var(--gold-light);
  margin-top: 2px;
  opacity: .85;
}

.sidebar-brand p {
  font-size: 11px;
  opacity: .55;
  margin-top: 6px;
  border-top: 1px solid rgba(255,255,255,.08);
  padding-top: 6px;
}

.sidebar nav {
  flex: 1;
  padding: 10px 0;
  overflow-y: auto;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 11px 18px;
  color: rgba(255,255,255,.65);
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 500;
  transition: all .18s;
  cursor: pointer;
  border: none;
  background: none;
  width: 100%;
  text-align: right;
  border-right: 3px solid transparent;
  position: relative;
}

.nav-item:hover {
  background: rgba(255,255,255,.07);
  color: rgba(255,255,255,.92);
  border-right-color: rgba(201,149,42,.5);
}

.nav-item.active {
  background: rgba(201,149,42,.12);
  color: var(--gold-light);
  border-right-color: var(--gold);
  font-weight: 700;
}

.nav-item .icon { font-size: 17px; width: 22px; text-align: center; flex-shrink: 0; }

.sidebar-footer {
  padding: 14px 16px;
  border-top: 1px solid rgba(255,255,255,.07);
}

.main {
  margin-right: var(--sidebar-w);
  padding: 28px 28px 40px;
  flex: 1;
  min-width: 0;
}

/* ══ Page header ══════════════════════════════ */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  padding-bottom: 18px;
  border-bottom: 2px solid var(--border-light);
}

.page-header h1 {
  font-size: 22px;
  font-weight: 800;
  color: var(--navy);
  letter-spacing: -.3px;
}

.page-header p { color: var(--text-muted); font-size: 13px; margin-top: 3px; }

/* ══ Cards ════════════════════════════════════ */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--border-light);
  padding: 22px;
  margin-bottom: 20px;
}

.card-title {
  font-size: 15px;
  font-weight: 800;
  margin-bottom: 18px;
  color: var(--navy);
  display: flex;
  align-items: center;
  gap: 9px;
  padding-bottom: 12px;
  border-bottom: 1.5px solid var(--border-light);
}

/* ══ Stats grid ════════════════════════════════ */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(155px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 20px 18px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border-light);
  text-align: center;
  position: relative;
  overflow: hidden;
  transition: transform .18s, box-shadow .18s;
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 4px;
  background: var(--navy-light);
  border-radius: var(--radius) var(--radius) 0 0;
}

.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }

.stat-card.yellow::before { background: linear-gradient(90deg, #e0a000, #f0c040); }
.stat-card.green::before  { background: linear-gradient(90deg, #059669, #34d399); }
.stat-card.blue::before   { background: linear-gradient(90deg, #1565c0, #42a5f5); }
.stat-card.red::before    { background: linear-gradient(90deg, #c0392b, #ef5350); }

.stat-num {
  font-size: 34px;
  font-weight: 800;
  color: var(--navy);
  line-height: 1;
  margin: 8px 0 4px;
  letter-spacing: -1px;
}

.stat-label {
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .2px;
}

/* ══ Forms ════════════════════════════════════ */
.form-group { margin-bottom: 18px; }

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

input, select, textarea {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-family: inherit;
  background: #fff;
  color: var(--text);
  direction: rtl;
  transition: border-color .2s, box-shadow .2s;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--navy-light);
  box-shadow: 0 0 0 3px rgba(30,79,132,.1);
}

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }

/* ══ Buttons ══════════════════════════════════ */
.btn {
  padding: 10px 22px;
  border-radius: var(--radius-sm);
  border: none;
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  transition: all .18s;
  letter-spacing: .2px;
}

.btn:hover { transform: translateY(-1px); box-shadow: var(--shadow-md); }
.btn:active { transform: translateY(0); box-shadow: none; }

.btn-primary {
  background: linear-gradient(135deg, var(--navy-mid) 0%, var(--navy) 100%);
  color: #fff;
  box-shadow: 0 3px 10px rgba(15,42,74,.25);
}

.btn-primary:hover {
  background: linear-gradient(135deg, var(--navy-light) 0%, var(--navy-mid) 100%);
}

.btn-accent {
  background: linear-gradient(135deg, var(--gold) 0%, var(--gold-light) 100%);
  color: var(--navy-dark);
  font-weight: 800;
  box-shadow: 0 3px 10px rgba(201,149,42,.3);
}

.btn-success {
  background: linear-gradient(135deg, #0a7c59 0%, #0ea472 100%);
  color: #fff;
}

.btn-danger {
  background: linear-gradient(135deg, #c0392b 0%, #e74c3c 100%);
  color: #fff;
}

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

.btn-outline:hover {
  border-color: var(--navy-light);
  color: var(--navy);
  background: rgba(30,79,132,.05);
}

.btn-sm  { padding: 6px 14px; font-size: 12px; }
.btn-lg  { padding: 14px 32px; font-size: 15px; }
.btn-block { width: 100%; justify-content: center; }

/* ══ Tables ═══════════════════════════════════ */
.table-wrap { overflow-x: auto; }

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

th {
  background: var(--navy);
  background-image: linear-gradient(90deg, var(--navy), var(--navy-mid));
  color: rgba(255,255,255,.92);
  padding: 11px 13px;
  text-align: center;
  font-weight: 700;
  white-space: nowrap;
  font-size: 12px;
  letter-spacing: .3px;
}

th:first-child { border-radius: 0; }

td {
  padding: 10px 13px;
  text-align: center;
  border-bottom: 1px solid var(--border-light);
  vertical-align: middle;
  color: var(--text);
}

tr:hover td { background: #f4f7fb; }
tr:nth-child(even) td { background: #fafbfd; }

/* ══ Badges ═══════════════════════════════════ */
.badge {
  padding: 3px 11px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
  display: inline-block;
  letter-spacing: .2px;
}

.badge-yellow  { background: #fef3c7; color: #92400e; border: 1px solid #fde68a; }
.badge-orange  { background: #ffedd5; color: #9a3412; border: 1px solid #fdba74; }
.badge-blue    { background: #dbeafe; color: #1e40af; border: 1px solid #93c5fd; }
.badge-green   { background: #d1fae5; color: #065f46; border: 1px solid #6ee7b7; }
.badge-red     { background: #fee2e2; color: #991b1b; border: 1px solid #fca5a5; }
.badge-gray    { background: #f1f5f9; color: #475569; border: 1px solid #cbd5e1; }
.badge-purple  { background: #ede9fe; color: #5b21b6; border: 1px solid #c4b5fd; }

/* ══ Attendance chips ═════════════════════════ */
.att-present  { background: #fef9c3; color: #713f12; border: 1px solid #fde047; }
.att-vacation { background: #ede9fe; color: #5b21b6; border: 1px solid #c4b5fd; }
.att-holiday  { background: #fdba74; color: #7c2d12; border: 1px solid #f97316; }
.att-sick     { background: #bfdbfe; color: #1e3a8a; border: 1px solid #60a5fa; }
.att-friday   { background: #e2e8f0; color: #475569; border: 1px solid #cbd5e1; }
.att-bta      { background: #bbf7d0; color: #14532d; border: 1px solid #4ade80; }
.att-absent   { background: #fecaca; color: #991b1b; border: 1px solid #f87171; }
.att-empty    { background: #f8fafc; color: #94a3b8; }

.day-chip {
  width: 36px; height: 27px; border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  font-size: 10px; font-weight: 700;
  transition: transform .12s;
}
.day-chip:hover { transform: scale(1.18); }

/* ══ Modal ════════════════════════════════════ */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(11,29,53,.55);
  backdrop-filter: blur(3px);
  display: flex; align-items: center; justify-content: center;
  z-index: 999; padding: 16px;
}

.modal {
  background: var(--surface);
  border-radius: 18px;
  width: 100%;
  max-width: 500px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg), 0 0 0 1px rgba(201,149,42,.1);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--border-light);
  background: linear-gradient(90deg, #f8fafd, #fff);
  border-radius: 18px 18px 0 0;
}

.modal-title { font-size: 16px; font-weight: 800; color: var(--navy); }
.modal-close {
  background: var(--bg); border: 1px solid var(--border);
  font-size: 18px; cursor: pointer; color: var(--text-muted);
  line-height: 1; width: 32px; height: 32px;
  border-radius: 8px; display: flex; align-items: center; justify-content: center;
  transition: all .15s;
}
.modal-close:hover { background: var(--danger-light); color: var(--danger); border-color: var(--danger); }
.modal-body { padding: 22px 24px; }
.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border-light);
  display: flex; gap: 10px; justify-content: flex-end;
  background: #fafbfd;
  border-radius: 0 0 18px 18px;
}

/* ══ Alerts ═══════════════════════════════════ */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 9px;
  font-weight: 600;
}

.alert-success { background: var(--success-light); color: var(--success); border: 1px solid #6ee7b7; }
.alert-error   { background: var(--danger-light); color: var(--danger); border: 1px solid #fca5a5; }
.alert-info    { background: var(--info-light); color: var(--info); border: 1px solid #93c5fd; }

/* ══ Tabs ══════════════════════════════════════ */
.tabs { display: flex; gap: 4px; margin-bottom: 20px; border-bottom: 2px solid var(--border-light); }
.tab {
  padding: 9px 20px; cursor: pointer; font-weight: 700; font-size: 13px;
  color: var(--text-muted); border: none; background: none; font-family: inherit;
  border-bottom: 2px solid transparent; margin-bottom: -2px;
  transition: color .15s;
}
.tab.active { color: var(--navy); border-bottom-color: var(--gold); }

/* ══ Filter row ═══════════════════════════════ */
.filter-row {
  display: flex; gap: 12px; align-items: flex-end;
  flex-wrap: wrap; margin-bottom: 20px;
}
.filter-row .form-group { margin-bottom: 0; }

/* ══ Status tags ══════════════════════════════ */
.status-tags { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.status-tag {
  padding: 4px 12px; border-radius: 6px; font-size: 11px; font-weight: 700;
  cursor: pointer; border: 2px solid transparent; transition: all .15s;
}
.status-tag.selected { border-color: var(--navy); transform: scale(1.05); }

/* ══ Clock (employee today tab) ═══════════════ */
.big-clock {
  font-size: 60px; font-weight: 800; color: var(--navy);
  font-variant-numeric: tabular-nums; letter-spacing: 4px;
  text-align: center;
  background: linear-gradient(135deg, var(--navy) 0%, var(--navy-light) 100%);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text;
  filter: drop-shadow(0 2px 4px rgba(15,42,74,.15));
}

.big-date {
  color: var(--text-muted); font-size: 14px; text-align: center;
  margin-top: 6px; margin-bottom: 28px; font-weight: 500;
}

/* ══ Utility ══════════════════════════════════ */
.hidden { display: none !important; }

/* Toast */
#toast {
  position: fixed; bottom: 28px; left: 50%; transform: translateX(-50%);
  background: var(--navy-dark); color: #fff;
  padding: 13px 26px; border-radius: 12px;
  font-size: 13px; font-weight: 700;
  box-shadow: var(--shadow-lg);
  z-index: 9999; opacity: 0; transition: opacity .25s;
  pointer-events: none;
  border: 1px solid rgba(201,149,42,.25);
}
#toast.show { opacity: 1; }

/* Scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #c5d0de; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--navy-light); }

/* ══ Mobile Top Bar ══════════════════════════ */
.top-bar {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 54px;
  background: var(--navy-dark);
  border-bottom: 2px solid var(--gold);
  align-items: center;
  padding: 0 14px;
  gap: 12px;
  z-index: 200;
  box-shadow: 0 2px 16px rgba(0,0,0,.35);
}

.hamburger {
  background: none;
  border: 1px solid rgba(255,255,255,.25);
  cursor: pointer;
  padding: 8px 10px;
  border-radius: 8px;
  transition: background .15s;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: 40px;
  height: 38px;
}
.hamburger:hover, .hamburger:active { background: rgba(255,255,255,.14); }

.hb-line {
  display: block;
  width: 100%;
  height: 2px;
  background: #fff;
  border-radius: 2px;
  transition: transform .25s, opacity .2s, width .25s;
}

/* Animate to X when sidebar is open */
.hamburger.is-open .hb-line:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.hamburger.is-open .hb-line:nth-child(2) { opacity: 0; width: 0; }
.hamburger.is-open .hb-line:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

.top-bar-title {
  color: #fff;
  font-size: 14px;
  font-weight: 800;
  flex: 1;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.top-bar-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Dimming overlay when sidebar is open */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.52);
  z-index: 99;
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
}
.sidebar-overlay.active { display: block; }

/* ══ Responsive ═══════════════════════════════ */
@media (max-width: 768px) {
  :root { --sidebar-w: 260px; }

  .top-bar { display: flex; }

  /* Sidebar slides in from right instead of display:none */
  .sidebar {
    display: flex;
    transform: translateX(100%);
    transition: transform .28s cubic-bezier(.4, 0, .2, 1);
    z-index: 150;
    box-shadow: none;
  }
  .sidebar.sidebar-open {
    transform: translateX(0);
    box-shadow: -6px 0 32px rgba(0,0,0,.4);
  }

  .main {
    margin-right: 0;
    padding: 70px 12px 28px;
  }

  /* Stats: 2 columns */
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    margin-bottom: 16px;
  }
  .stat-card { padding: 14px 12px; }
  .stat-num  { font-size: 26px; }
  .stat-label{ font-size: 11px; }

  /* Form rows stack */
  .form-row, .form-row-3 { grid-template-columns: 1fr; gap: 0; }

  /* Tabs scroll horizontally */
  .tabs { overflow-x: auto; flex-wrap: nowrap; padding-bottom: 2px; gap: 0; }
  .tab  { white-space: nowrap; padding: 9px 13px; font-size: 12px; flex-shrink: 0; }

  /* Cards */
  .card { padding: 14px 12px; }
  .card-title { font-size: 13px; margin-bottom: 14px; }

  /* Page header */
  .page-header { margin-bottom: 14px; padding-bottom: 12px; flex-wrap: wrap; gap: 8px; }
  .page-header h1 { font-size: 17px; }

  /* Tables: horizontal scroll */
  .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  table { min-width: 520px; }

  /* Filter row */
  .filter-row { gap: 8px; }
  .filter-row .form-group { min-width: 120px; }

  /* Buttons */
  .btn-lg { padding: 12px 20px; font-size: 14px; }

  /* Modal: bottom sheet on mobile */
  .modal-overlay { align-items: flex-end; padding: 0; }
  .modal {
    border-radius: 20px 20px 0 0;
    max-height: 92vh;
    width: 100%;
    max-width: 100%;
  }

  /* Login page */
  .login-card {
    width: 100%;
    max-width: 100%;
    min-height: 100dvh;
    border-radius: 0;
    padding: 40px 22px 32px;
    display: flex;
    flex-direction: column;
    justify-content: center;
  }

  /* Big clock */
  .big-clock { font-size: 44px; letter-spacing: 2px; }
}

@media (max-width: 380px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .stat-num   { font-size: 22px; }
  .tab        { padding: 8px 10px; font-size: 11px; }
  .main       { padding: 66px 10px 24px; }
}

/* ══ Timesheet mobile tweaks ══════════════════ */
@media (max-width: 768px) {
  /* Week table min-width so it scrolls gracefully */
  .week-table { min-width: 500px; }

  /* Time inputs */
  .t24 {
    width: 72px !important;
    padding: 5px 4px !important;
    font-size: 12px !important;
  }

  /* OT value cells */
  .ot-val { font-size: 11px; }

  /* Month grid (admin attendance) */
  .month-grid { min-width: max-content; }

  /* Result boxes in leave/BTA */
  .result-box { font-size: 12px; }
  .rrow { padding: 6px 8px; }

  /* Admin grid: fix col-emp width on small screens */
  .col-emp {
    width: 160px !important;
    min-width: 160px !important;
    max-width: 160px !important;
    font-size: 11px !important;
  }

  /* Lang toggle button */
  .lang-btn { font-size: 11px; padding: 6px 10px; }
}
