/* ====================================================================
   Al Widad — Shared theme layer (v737)
   The refined palette now lives in each page's :root as the single
   source of truth, and legacy hardcoded colours were removed from the
   inline stylesheets. This file no longer patches colours; it supplies
   shared component polish, spacing rhythm and responsive behaviour.
   !important appears only where an inline style attribute would win.
   ==================================================================== */

/* ---- Typography ---- */
body { background: var(--app-bg); color: var(--text-primary);
       font-size: 15.5px; line-height: 1.65; -webkit-font-smoothing: antialiased; }
h1, h2, h3, .card-title, .page-title-main { line-height: 1.35; font-weight: 600; }
label, .form-label, .stat-label { font-size: 13.5px; color: var(--text-secondary); }
.page-title-main { font-size: 19px; }
.stat-value, .stat-num { font-size: 24px; font-weight: 600; color: var(--text-primary); }
.clock-time { font-size: 34px; font-weight: 600; letter-spacing: .5px; }
small, .muted { color: var(--text-secondary); }

/* ---- Surfaces ---- */
.card, .stat-card, .log-card, .page-title, .emp-card,
.reward-card-item, .request-card, .empty-state {
  border-radius: var(--radius-md); box-shadow: var(--shadow-sm);
}
.modal-box, .modal-content { border-radius: var(--radius-lg); box-shadow: var(--shadow-md); }
.modal-overlay, .modal { background: rgba(16, 42, 67, .45); }

/* ---- Header: compact, white logo ---- */
.hero { padding: 18px 20px 46px; border-radius: 0 0 24px 24px; }
.hero.compact { padding: 12px 20px 38px; }
/* logo-white.png is a true white asset; filter is a safety net only
   if a coloured logo is ever swapped back in. */
.hero-logo, .login-brand img, .header-logo img { filter: brightness(0) invert(1); }
.hero.compact .hero-logo { width: 74px; }
.login-logo { max-width: 120px; height: auto; }

/* ---- Employee name card ---- */
.emp-card { display: flex; align-items: center; gap: 12px; }
.emp-card .emp-name { color: var(--text-primary); font-size: 16px; font-weight: 600; }
.emp-card .emp-role, .emp-card .emp-branch, .emp-card small { color: var(--text-secondary); font-size: 13px; }
.avatar { width: 44px; height: 44px; border-radius: 999px;
  background: var(--primary-soft); color: var(--primary-dark);
  border: 1px solid var(--border-color); font-size: 15px; font-weight: 600; letter-spacing: .5px; }

/* ---- Clock card ---- */
.clock-card { background: var(--surface-soft); border: 1px solid var(--border-color); padding: 16px 14px; }
.date-text { font-size: 13px; color: var(--text-secondary); }

/* ---- Buttons ---- */
.btn { border-radius: var(--radius-sm); font-size: 15.5px; font-weight: 500;
       transition: background .15s ease, border-color .15s ease, transform .1s ease; }
.btn-primary, .btn-checkin { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover, .btn-checkin:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn-outline { background: var(--surface); border: 1px solid var(--border-strong); color: var(--text-primary); }
.btn-outline:hover { background: var(--surface-soft); border-color: var(--primary); color: var(--primary-dark); }
.btn:active { transform: scale(.99); }
.btn-checkin, .btn-checkout, .btn-primary.btn-large { min-height: 54px; font-size: 16px; }
.btn:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.btn.disabled, .btn:disabled, button:disabled {
  background: #EEF2F1 !important; color: #7A8894 !important;
  border: 1px solid var(--border-strong) !important;
  opacity: 1 !important; box-shadow: none !important; cursor: not-allowed; }

/* ---- Inputs ---- */
input, select, textarea { border-radius: var(--radius-sm); border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--text-primary); }
::placeholder { color: var(--text-muted-soft); opacity: 1; }

/* ---- Badges ---- */
.badge, .log-status, .pill, .status-badge-inline { border-radius: 999px; font-weight: 500; }

/* ---- Bottom navigation ---- */
.bottom-tabs { background: var(--surface); border-top: 1px solid var(--border-color);
  box-shadow: 0 -2px 8px rgba(16, 42, 67, .05);
  padding-bottom: env(safe-area-inset-bottom, 0px); height: auto; }
.tab-item { color: var(--text-secondary); gap: 3px; padding: 8px 4px 6px; font-size: 11px; min-height: 54px; }
.tab-item.active { color: var(--primary-dark); font-weight: 600; }
.tab-item .tab-icon { width: 22px; height: 22px; display: block; margin: 0 auto; }
.tab-item.active .tab-icon { stroke-width: 2; }
.page-title-icon { background: var(--primary-soft); border: 1px solid var(--border-color); }
.page-title-icon .pt-icon { width: 21px; height: 21px; color: var(--primary-dark); }
.content.app-mode { padding-bottom: calc(var(--bottom-nav-height) + env(safe-area-inset-bottom, 0px) + 24px); }

/* ---- States ---- */
.empty-state { background: var(--surface); border: 1px dashed var(--border-strong);
  color: var(--text-secondary); padding: 26px 20px; }
.empty-state .empty-icon { color: var(--primary); }
.empty-state.error { background: var(--danger-soft); border-color: #F3C3C3; color: #B91C1C; }
.btn-retry { margin-top: 12px; padding: 10px 22px; font-size: 14px; }

/* ---- Admin tabs + tables ---- */
.tabs { display: flex; flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch;
  gap: 6px; padding-bottom: 6px; scrollbar-width: thin; }
.tabs::-webkit-scrollbar { height: 4px; }
.tabs::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 999px; }
.tab-btn { flex: 0 0 auto; white-space: nowrap; border-radius: var(--radius-sm);
  color: var(--text-secondary); border: 1px solid transparent; font-size: 14px; }
.tab-btn:hover { background: var(--surface-soft); color: var(--primary-dark); }
.tab-btn.active { background: var(--primary-soft); color: var(--primary-dark);
  border-color: var(--border-strong); font-weight: 600; }
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch;
  border: 1px solid var(--border-color); border-radius: var(--radius-md); background: var(--surface); }
.table-wrap table { min-width: 720px; border-collapse: separate; border-spacing: 0; }
thead th { background: var(--surface-soft); color: var(--text-secondary); font-weight: 600;
  font-size: 12.5px; border-bottom: 1px solid var(--border-color); }
tbody td { padding: 12px 14px; border-bottom: 1px solid var(--border-color); }
tbody tr:last-child td { border-bottom: none; }
@media (hover: hover) { tbody tr:hover td { background: var(--surface-soft); } }

/* ---- Admin login ---- */
.login-screen { background: var(--app-bg); padding: 24px 16px; }
.login-card { background: var(--surface); border: 1px solid var(--border-color);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-md);
  padding: 30px 24px 26px; max-width: 380px; }
.login-brand { background: linear-gradient(160deg, var(--primary) 0%, var(--primary-dark) 100%);
  margin: -30px -24px 22px; padding: 22px 24px 18px;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0; text-align: center; }
.login-brand img { max-width: 110px; height: auto; }
.login-tagline { color: rgba(255,255,255,.85); letter-spacing: 3px; font-size: 10px; font-weight: 500; }
.login-title { color: var(--text-primary); font-size: 17px; font-weight: 600; margin-bottom: 18px; }
.login-card label { display: block; text-align: start; margin-bottom: 6px; font-weight: 500; }
.login-card .form-input { height: 48px; font-size: 16px; letter-spacing: 2px; }
.login-error { display: none; margin-top: 12px; padding: 10px 12px;
  background: var(--danger-soft); color: #B91C1C; border: 1px solid #F3C3C3;
  border-radius: var(--radius-sm); font-size: 13.5px; text-align: center; }
.login-error.show { display: block; }

/* ---- Responsive ---- */
html, body { max-width: 100%; overflow-x: hidden; }
img, svg, video, table { max-width: 100%; }
* { min-width: 0; }
@media (max-width: 768px) {
  input, select, textarea { font-size: 16px; }
  .section-title { align-items: flex-start; }
  .stats-grid { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); }
}
@media (max-width: 430px) {
  .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .content { padding-left: 14px; padding-right: 14px; }
}
@media (max-width: 360px) {
  .stats-grid { gap: 8px; }
  .stat-card { padding: 10px; }
  .stat-value, .stat-num { font-size: 20px; }
  .clock-time { font-size: 30px; }
  .page-title { padding: 12px; gap: 10px; }
  .page-title-main { font-size: 16.5px; }
  .tab-item { font-size: 10px; }
  .login-card { padding: 24px 18px 20px; }
}
.log-row { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.log-row-value { text-align: end; word-break: break-word; }
.modal-box, .modal-content { max-width: min(480px, calc(100vw - 24px));
  max-height: calc(100dvh - 32px); overflow-y: auto; }
.filters, .toolbar, .section-title, .header-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}

/* ====================================================================
   v739 — Admin sidebar: reliable two-state drawer
   Source of truth: .is-open on the sidebar element (mobile/tablet).
   Desktop collapse is a separate concern, strictly scoped to >=1024px.
   No logical properties for the drawer axis — physical left/right only,
   because translateX() is direction-agnostic and mixing the two is what
   produced the centred/partial states.
   ==================================================================== */
:root {
  --sidebar-w: 248px;
  --sidebar-w-collapsed: 72px;
  --admin-header-height: 66px;   /* measured at runtime, see admin.html */
  --nav-active-bg: #E8F7F3;
  --nav-active-fg: #0F917D;
  --nav-inactive-fg: #52667A;
  --nav-hover-bg: #F4FAF8;
}

.header { gap: 12px; }
.hamburger {
  flex: 0 0 auto; width: 44px; height: 44px; display: inline-flex;
  align-items: center; justify-content: center;
  background: rgba(255,255,255,.14); color: #fff;
  border: 1px solid rgba(255,255,255,.3); border-radius: var(--radius-sm);
  cursor: pointer; transition: background .15s ease;
}
.hamburger:hover { background: rgba(255,255,255,.26); }
.hamburger:focus-visible { outline: none; box-shadow: 0 0 0 3px rgba(255,255,255,.55); }
.hamburger svg { width: 22px; height: 22px; }
.header-actions .btn-icon-only { display: inline-flex; align-items: center; justify-content: center; min-width: 40px; min-height: 40px; }
.header-actions .nav-icon { width: 19px; height: 19px; }

/* ---- Sidebar shell ------------------------------------------------- */
.sidebar {
  position: fixed;
  top: var(--admin-header-height);
  bottom: 0;
  z-index: 1200;
  margin: 0;                       /* never auto — would centre the drawer */
  width: var(--sidebar-w);
  background: var(--surface);
  display: flex; flex-direction: column;
  transition: transform 220ms ease;   /* transform ONLY — width must not animate */
}
html[dir="rtl"] .sidebar { right: 0; left: auto; border-left: 1px solid var(--border-color); }
html[dir="ltr"] .sidebar { left: 0; right: auto; border-right: 1px solid var(--border-color); }

.sidebar-nav { flex: 1 1 auto; overflow-y: auto; padding: 12px 10px; display: flex; flex-direction: column; gap: 3px; }
.sidebar-foot { border-top: 1px solid var(--border-color); padding: 10px; }

/* ---- Nav items ----------------------------------------------------- */
.sidebar .nav-item {
  display: flex; align-items: center; gap: 11px; width: 100%;
  padding: 10px 12px; border: none; background: transparent;
  border-radius: var(--radius-sm); cursor: pointer; font-family: inherit;
  font-size: 14px; font-weight: 500; color: var(--nav-inactive-fg);
  text-align: start; position: relative; white-space: nowrap;
  transition: background .13s ease, color .13s ease;
  min-height: 44px; flex: 0 0 auto; min-width: 0;
}
.sidebar .nav-item:hover { background: var(--nav-hover-bg); color: var(--nav-active-fg); }
.sidebar .nav-item:focus-visible { outline: none; box-shadow: 0 0 0 2px var(--primary); }
.sidebar .nav-item.active { background: var(--nav-active-bg); color: var(--nav-active-fg); font-weight: 600; }
.sidebar .nav-item.active::before {
  content: ''; position: absolute; inset-inline-start: 0; top: 50%;
  transform: translateY(-50%); width: 3px; height: 22px;
  background: var(--nav-active-fg); border-radius: 0 3px 3px 0;
}
html[dir="ltr"] .sidebar .nav-item.active::before { border-radius: 3px 0 0 3px; }
.nav-icon { width: 20px; height: 20px; flex: 0 0 20px; }
.nav-text { flex: 1 1 auto; overflow: hidden; text-overflow: ellipsis; }
.nav-logout { color: var(--danger); }
.nav-logout:hover { background: var(--danger-soft); color: #B91C1C; }

.sidebar .tab-badge {
  background: var(--warning); color: #fff; font-size: 10.5px; font-weight: 700;
  min-width: 20px; padding: 1px 6px; border-radius: 10px; text-align: center;
  margin: 0; flex: 0 0 auto;
}
.sidebar .nav-item.active .tab-badge { background: var(--danger); }

/* ---- Backdrop ------------------------------------------------------ */
.sidebar-backdrop {
  position: fixed; inset: 0; z-index: 1100;
  background: rgba(16,42,67,.45); border: 0;
  opacity: 0; pointer-events: none; transition: opacity 200ms ease;
}
.sidebar-backdrop.is-visible { opacity: 1; pointer-events: auto; }

/* ====================================================================
   MOBILE / TABLET  (< 1024px) — exactly two states, nothing else
   ==================================================================== */
@media (max-width: 1023px) {
  .sidebar {
    width: min(82vw, 280px);
    box-shadow: 0 0 24px rgba(16,42,67,.16);
  }
  /* CLOSED: fully outside the viewport, no visible sliver */
  html[dir="rtl"] .sidebar { transform: translateX(100%); }
  html[dir="ltr"] .sidebar { transform: translateX(-100%); }
  /* OPEN: flush against its edge */
  html[dir="rtl"] .sidebar.is-open,
  html[dir="ltr"] .sidebar.is-open { transform: translateX(0); }

  /* The drawer overlays content; it never pushes or shifts it */
  .container { margin-inline-end: 0; margin-inline-start: 0; }

  /* Desktop collapse must have no effect here */
  .sidebar .nav-text { display: block; }
  .sidebar .nav-item { justify-content: flex-start; padding: 10px 12px; gap: 11px; }
  .sidebar .nav-item::after { content: none; }
  .sidebar .tab-badge {
    position: static; min-width: 20px; height: auto;
    padding: 1px 6px; font-size: 10.5px; line-height: normal; border-radius: 10px;
  }

  body.sidebar-locked { overflow: hidden; }
}

/* ====================================================================
   DESKTOP (>= 1024px) — sidebar always docked; collapse is separate
   ==================================================================== */
@media (min-width: 1024px) {
  .sidebar { transform: none; }          /* never transformed on desktop */
  .sidebar-backdrop { display: none; }
  .container { margin-inline-end: var(--sidebar-w); transition: margin .2s ease; max-width: 1100px; }
  html[dir="ltr"] .container { margin-inline-end: 0; margin-inline-start: var(--sidebar-w); }

  body.sidebar-collapsed .sidebar { width: var(--sidebar-w-collapsed); }
  body.sidebar-collapsed .container { margin-inline-end: var(--sidebar-w-collapsed); }
  html[dir="ltr"] body.sidebar-collapsed .container { margin-inline-end: 0; margin-inline-start: var(--sidebar-w-collapsed); }

  body.sidebar-collapsed .sidebar .nav-text { display: none; }
  body.sidebar-collapsed .sidebar .nav-item { justify-content: center; padding: 10px 8px; gap: 0; }
  body.sidebar-collapsed .sidebar .tab-badge {
    position: absolute; top: 5px; inset-inline-end: 8px;
    min-width: 8px; height: 8px; padding: 0; font-size: 0; line-height: 0; border-radius: 50%;
  }
  body.sidebar-collapsed .sidebar .nav-item::after {
    content: attr(data-label); position: absolute; inset-inline-end: calc(100% + 8px);
    top: 50%; transform: translateY(-50%);
    background: var(--text-primary); color: #fff; font-size: 12px; font-weight: 500;
    padding: 5px 9px; border-radius: 7px; white-space: nowrap;
    opacity: 0; pointer-events: none; transition: opacity .12s ease; z-index: 1300;
  }
  body.sidebar-collapsed .sidebar .nav-item:hover::after,
  body.sidebar-collapsed .sidebar .nav-item:focus-visible::after { opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
  .sidebar, .container, .sidebar-backdrop { transition: none; }
}
