/* ═══════════════════════════════════════════════════════════
   Smart Attendance App — Styles
   Navy + Gold + Teal palette (as requested)
   RTL support for Kurdish (Sorani) + Arabic
   ═══════════════════════════════════════════════════════════ */

:root{
  --navy:#0D1B4C;
  --navy-2:#152964;
  --teal:#3FBFB5;
  --teal-dk:#0F7A72;
  --gold:#D9A441;
  --coral:#E2665B;
  --green:#4ADE80;
  --paper:#FAF9F5;
  --ink:#151625;
  --line:#E7E4DA;
  --card:#FFFFFF;
  --muted:#8B8A98;
}
[data-theme="dark"]{
  --paper:#111319;
  --ink:#EDEDF2;
  --line:#272A38;
  --card:#1A1D29;
  --muted:#93949F;
  --teal-dk:#5FE0D4;
}
[data-theme="dark"] thead th,
[data-theme="dark"] thead th.name-col{ background:#1F2230; }
[data-theme="dark"] tbody tr:nth-child(even){ background:#181B26; }
[data-theme="dark"] .cell-empty{ color:#3A3D4D; }
[data-theme="dark"] .btn-secondary{ background:#242736; color:var(--ink); }
[data-theme="dark"] .del-btn:hover{ background:rgba(226,102,91,.18); }
[data-theme="dark"] .modal-close{ background:#242736; color:var(--ink); }
[data-theme="dark"] .empty-state{ color:#93949F; }
[data-theme="dark"] .stat-card:hover{ box-shadow:0 8px 22px rgba(0,0,0,.4); }
[data-theme="dark"] .gender-toggle button{ background:var(--paper); }
[data-theme="dark"] .form-grid input,
[data-theme="dark"] .date-input,
[data-theme="dark"] .search input{ background:var(--card); color:var(--ink); }

*{ box-sizing:border-box; }
html,body{ margin:0; padding:0; }
body{
  font-family:'Vazirmatn','Cairo','Tajawal','Noto Kufi Arabic',-apple-system,BlinkMacSystemFont,'Segoe UI','Tahoma','Geeza Pro','Noto Naskh Arabic','Noto Sans Arabic',sans-serif;
  background:var(--paper);
  color:var(--ink);
  min-height:100vh;
  -webkit-tap-highlight-color:transparent;
}
h1,h2,h3,.display{ font-weight:800; }
button,select,input{ font-family:inherit; }
::selection{ background:var(--teal); color:#fff; }
input[type="date"]{ direction:ltr; }

.app{ max-width:1180px; margin:0 auto; padding-bottom:60px; }

/* Loading screen */
.loading-screen{
  min-height:100vh; display:flex; flex-direction:column;
  align-items:center; justify-content:center; gap:16px;
}
.loading-spinner{
  width:44px; height:44px; border-radius:50%;
  border:3px solid var(--line); border-top-color:var(--teal);
  animation:spin 0.8s linear infinite;
}
@keyframes spin{ to{ transform:rotate(360deg); } }
.loading-screen p{ color:var(--muted); font-weight:600; font-size:14px; }

/* Sync status */
.sync-status{
  position:fixed; top:12px; left:12px; z-index:100;
  background:var(--card); border:1px solid var(--line);
  padding:6px 12px; border-radius:999px;
  font-size:11px; font-weight:700; color:var(--muted);
  display:flex; align-items:center; gap:6px;
  box-shadow:0 4px 12px rgba(0,0,0,.06);
}
.sync-dot{
  width:8px; height:8px; border-radius:50%;
  background:var(--teal); animation:pulse 1.5s ease-in-out infinite;
}
@keyframes pulse{
  0%,100%{ opacity:1; transform:scale(1); }
  50%{ opacity:.5; transform:scale(.85); }
}
.sync-status.offline .sync-dot{ background:var(--coral); animation:none; }
.sync-status.synced .sync-dot{ background:var(--green); animation:none; }

/* Header */
header.top{
  position:sticky; top:0; z-index:40;
  background:linear-gradient(135deg,var(--navy) 0%,var(--navy-2) 100%);
  color:#fff;
  padding:18px 20px 16px;
  border-radius:0 0 22px 22px;
  box-shadow:0 6px 24px rgba(13,27,76,.18);
}
.top-row{ display:flex; align-items:flex-start; justify-content:space-between; gap:12px; flex-wrap:wrap; }
.brand{ display:flex; align-items:center; gap:12px; }
.brand-mark{
  width:42px; height:42px; border-radius:13px;
  background:var(--teal);
  display:flex; align-items:center; justify-content:center;
  box-shadow:0 3px 10px rgba(63,191,181,.4);
  flex-shrink:0;
}
.brand-mark svg{ width:22px; height:22px; }
.brand h1{ font-size:16px; font-weight:800; margin:0; line-height:1.3; }
.brand p{ font-size:11px; margin:2px 0 0; opacity:.72; font-weight:500; }

.top-actions{ display:flex; gap:8px; flex-wrap:wrap; align-items:center; }
.icon-btn{
  width:38px; height:38px; border-radius:50%; border:none;
  background:rgba(255,255,255,.14); color:#fff;
  display:flex; align-items:center; justify-content:center;
  cursor:pointer; transition:.15s; flex-shrink:0;
}
.icon-btn:hover{ background:rgba(255,255,255,.22); }
.icon-btn:active{ transform:scale(.92); }

.lang-toggle{
  display:flex; background:rgba(255,255,255,.12); border-radius:999px; padding:3px; gap:2px;
}
.lang-toggle button{
  border:none; background:transparent; color:rgba(255,255,255,.75);
  padding:7px 13px; border-radius:999px; font-size:12px; font-weight:700; cursor:pointer;
  transition:.15s;
}
.lang-toggle button.active{ background:#fff; color:var(--navy); }

.pill-btn{
  border:none; border-radius:999px; padding:9px 16px; font-size:13px; font-weight:700;
  cursor:pointer; display:inline-flex; align-items:center; gap:6px; transition:.15s; white-space:nowrap;
}
.pill-btn.gold{ background:var(--gold); color:var(--navy); }
.pill-btn.gold:hover{ filter:brightness(1.06); }
.pill-btn.ghost{ background:rgba(255,255,255,.14); color:#fff; }
.pill-btn.ghost:hover{ background:rgba(255,255,255,.22); }
.pill-btn:active{ transform:scale(.97); }

.tabs{
  display:flex; gap:4px; margin-top:16px;
  background:rgba(255,255,255,.10); padding:4px; border-radius:999px;
  width:fit-content; max-width:100%; overflow-x:auto; -webkit-overflow-scrolling:touch;
}
.tabs button{
  border:none; background:transparent; color:rgba(255,255,255,.7);
  padding:9px 18px; border-radius:999px; font-size:13px; font-weight:700; cursor:pointer;
  white-space:nowrap; transition:background-color .12s, color .12s;
}
.tabs button.active{ background:#fff; color:var(--navy); }

/* Main */
main{ padding:20px; }

.toolbar{ display:flex; gap:10px; flex-wrap:wrap; align-items:center; margin-bottom:16px; }
.period-modes{
  display:flex; gap:2px; background:var(--card); border:1px solid var(--line);
  border-radius:999px; padding:4px; flex-wrap:wrap;
}
.period-modes button{
  border:none; background:transparent; padding:7px 13px; border-radius:999px;
  font-size:12px; font-weight:700; color:var(--muted); cursor:pointer;
  white-space:nowrap; transition:.15s;
}
.period-modes button.active{ background:var(--navy); color:#fff; }

.date-input{
  padding:9px 14px; border:1px solid var(--line); border-radius:999px;
  font-size:13px; background:var(--card); color:var(--ink); outline:none;
}
.date-input:focus{ border-color:var(--teal); }

.range-inputs{
  display:flex; align-items:center; gap:7px;
  font-size:12px; color:var(--muted); font-weight:600; flex-wrap:wrap;
}

.month-picker{
  display:flex; align-items:center; gap:2px;
  background:var(--card); border:1px solid var(--line);
  border-radius:16px; padding:5px;
}
.month-picker select{
  border:none; background:transparent; padding:8px 10px;
  font-size:13px; font-weight:700; color:var(--ink);
  border-radius:12px; cursor:pointer;
}
.month-picker .sep{ width:1px; height:18px; background:var(--line); }

.days-note{ font-size:12px; color:var(--muted); font-weight:500; }
.days-note b{ color:var(--ink); }

/* Stats */
.stats{ display:grid; grid-template-columns:repeat(4,1fr); gap:10px; margin-bottom:18px; }
.stat-card{
  background:var(--card); border:1px solid var(--line); border-radius:16px; padding:14px;
  transition:.15s; cursor:pointer;
}
.stat-card:hover{ transform:translateY(-2px); box-shadow:0 8px 20px rgba(21,22,37,.06); }
.stat-card:active{ transform:scale(.97); }
.stat-top{ display:flex; justify-content:space-between; align-items:center; margin-bottom:8px; }
.stat-icon{ width:30px; height:30px; border-radius:10px; display:flex; align-items:center; justify-content:center; }
.stat-num{ font-size:22px; font-weight:800; }
.stat-label{ font-size:11px; color:var(--muted); font-weight:600; }

.search{ position:relative; flex:1; min-width:180px; max-width:320px; }
.search input{
  width:100%; padding:10px 40px 10px 14px;
  border:1px solid var(--line); border-radius:999px;
  font-size:13px; background:var(--card); color:var(--ink); outline:none;
}
.search input:focus{ border-color:var(--teal); }
.search svg{ position:absolute; right:14px; top:50%; transform:translateY(-50%); opacity:.4; width:15px; height:15px; }

.legend{ display:flex; gap:6px; flex-wrap:wrap; align-items:center; font-size:11px; }
.legend .hint{ color:var(--muted); }
.chip{ padding:3px 10px; border-radius:999px; font-weight:800; font-size:11px; }

/* Card / table */
.card{ background:var(--card); border:1px solid var(--line); border-radius:18px; overflow:hidden; }
.print-title{ display:none; text-align:center; padding:14px; border-bottom:2px solid var(--navy); }

.table-scroll{ overflow-x:auto; -webkit-overflow-scrolling:touch; }
table{ width:100%; border-collapse:collapse; font-size:12px; }
thead th{
  position:sticky; top:0; background:#FBFAF7; border-bottom:1px solid var(--line);
  padding:9px 6px; font-weight:700; color:var(--muted); text-align:center;
}
thead th.name-col{
  text-align:right; position:sticky; right:0; background:#FBFAF7;
  min-width:150px; z-index:2;
}
td{ border-bottom:1px solid var(--line); padding:6px; text-align:center; }
td.name-col{
  text-align:right; position:sticky; right:0; background:inherit;
  font-weight:600; min-width:150px;
}
tbody tr:nth-child(even){ background:#FCFBF8; }
.emp-name-wrap{ display:flex; align-items:center; gap:7px; }
.dot{ width:6px; height:6px; border-radius:50%; background:var(--teal); flex-shrink:0; }
.dot.female{ background:#EC4899; }
.emp-job{ font-size:10px; color:var(--muted); margin-right:13px; }

.day-col{ min-width:34px; }
.day-col.fri{ background:rgba(226,102,91,.06); color:var(--coral); }
.weekday{ font-size:8px; opacity:.6; font-weight:500; }

.cell-btn{
  width:26px; height:26px; border-radius:50%;
  display:inline-flex; align-items:center; justify-content:center;
  font-weight:800; font-size:11px; cursor:pointer; color:#fff;
  border:none; user-select:none; transition:transform .1s;
}
.cell-btn:active{ transform:scale(.85); }
.cell-empty{
  color:#DDD9CC; cursor:pointer; font-size:14px;
  background:transparent; border:1px dashed var(--line);
  width:26px; height:26px; border-radius:50%;
  display:inline-flex; align-items:center; justify-content:center;
}
.sum-col{ font-weight:800; }

.empty-state{ text-align:center; padding:60px 20px; color:var(--muted); }
.empty-state svg{ width:34px; height:34px; opacity:.3; margin-bottom:10px; }
.empty-state .add-link{
  margin-top:14px; display:inline-flex; gap:6px; align-items:center;
  background:var(--teal); color:#fff; padding:9px 18px; border-radius:999px;
  font-size:13px; font-weight:700; border:none; cursor:pointer;
}

/* Employees */
.add-form{
  background:var(--card); border:1px solid rgba(63,191,181,.35);
  border-radius:18px; padding:18px; margin-bottom:14px;
}
.add-form h3{ font-size:13px; font-weight:800; margin:0 0 12px; display:flex; align-items:center; gap:7px; }
.form-grid{
  display:grid; grid-template-columns:repeat(auto-fit,minmax(150px,1fr));
  gap:10px; margin-bottom:12px;
}
.form-grid input{
  padding:10px 14px; border:1px solid var(--line); border-radius:999px;
  font-size:13px; outline:none; background:var(--paper); color:var(--ink);
}
.form-grid input:focus{ border-color:var(--teal); }
.form-actions{ display:flex; gap:8px; }
.btn-secondary{
  background:#F0EFE9; color:var(--ink); border:none; border-radius:999px;
  padding:9px 18px; font-size:13px; font-weight:700; cursor:pointer;
}

.gender-field{ margin-bottom:12px; }
.gender-field-label{ font-size:11px; color:var(--muted); font-weight:700; margin-bottom:6px; display:block; }
.gender-toggle{ display:flex; gap:8px; }
.gender-toggle button{
  flex:1; padding:10px; border:1.5px solid var(--line); background:var(--paper); color:var(--muted);
  border-radius:999px; font-size:13px; font-weight:700; cursor:pointer;
  display:flex; align-items:center; justify-content:center; gap:6px;
  transition:.15s;
}
.gender-toggle button.active.M{
  background:rgba(63,131,232,.12); border-color:#2E5FC4; color:#2E5FC4;
}
.gender-toggle button.active.F{
  background:rgba(232,63,152,.12); border-color:#C4297E; color:#C4297E;
}

.gender-badge{
  width:20px; height:20px; border-radius:50%;
  display:flex; align-items:center; justify-content:center;
  font-size:11px; font-weight:800; flex-shrink:0;
}
.gender-badge.M{ background:rgba(63,131,232,.15); color:#2E5FC4; }
.gender-badge.F{ background:rgba(232,63,152,.15); color:#C4297E; }

.tel-link{
  color:var(--teal-dk); text-decoration:none; font-weight:700;
  display:inline-flex; align-items:center; gap:3px;
}
.tel-link:active{ opacity:.65; }

.emp-row{
  display:flex; align-items:center; gap:12px;
  padding:13px 18px; border-bottom:1px solid var(--line);
}
.emp-row:last-child{ border-bottom:none; }
.avatar{
  width:36px; height:36px; border-radius:50%;
  background:rgba(63,191,181,.15); color:var(--teal-dk);
  display:flex; align-items:center; justify-content:center;
  font-weight:800; font-size:14px; flex-shrink:0;
}
.avatar.female{ background:rgba(236,72,153,.15); color:#EC4899; }
.emp-info{ flex:1; min-width:0; }
.emp-info .nm{
  font-weight:700; font-size:13.5px;
  white-space:nowrap; overflow:hidden; text-overflow:ellipsis;
  display:flex; align-items:center; gap:6px;
}
.emp-info .meta{ font-size:11px; color:var(--muted); margin-top:2px; display:flex; gap:8px; flex-wrap:wrap; align-items:center; }
.mini-stats{ display:flex; gap:5px; font-size:9.5px; flex-shrink:0; }
.mini-chip{ padding:2px 7px; border-radius:999px; font-weight:800; }
.del-btn{
  background:none; border:none; color:var(--coral);
  padding:7px; border-radius:50%; cursor:pointer; flex-shrink:0;
}
.del-btn:hover{ background:rgba(226,102,91,.1); }

/* Report */
.report-table th{ text-align:right; padding:11px; font-size:12px; }
.report-table th.c{ text-align:center; }
.report-table td{ padding:11px; font-size:13px; }
.report-table td.c{ text-align:center; font-weight:700; }
.pct-chip{ padding:3px 10px; border-radius:999px; font-size:11px; font-weight:800; }

.notes-card{
  background:var(--card); border:1px solid var(--line);
  border-radius:18px; padding:18px; margin-top:14px;
}
.notes-card h3{ font-size:13px; font-weight:800; margin:0 0 10px; display:flex; gap:7px; align-items:center; }
.notes-card ul{ margin:0; padding:0; list-style:none; display:flex; flex-direction:column; gap:8px; }
.notes-card li{ display:flex; gap:8px; font-size:12.5px; color:#565566; align-items:flex-start; }
.notes-card li svg{ flex-shrink:0; margin-top:2px; width:12px; height:12px; color:var(--teal); }

/* Toast */
.toast{
  position:fixed; bottom:24px; left:50%; transform:translateX(-50%);
  background:var(--navy); color:#fff; padding:12px 22px; border-radius:999px;
  font-size:13px; font-weight:600; box-shadow:0 10px 30px rgba(0,0,0,.2); z-index:200;
  animation:up .2s ease-out;
}
.toast.error{ background:var(--coral); }
.toast.success{ background:var(--teal-dk); }
@keyframes up{
  from{ opacity:0; transform:translate(-50%,10px); }
  to  { opacity:1; transform:translate(-50%,0); }
}

/* Modal */
.modal-bg{
  position:fixed; inset:0; background:rgba(13,27,76,.55);
  backdrop-filter:blur(3px);
  display:flex; align-items:center; justify-content:center; padding:16px; z-index:300;
}
.modal{
  background:var(--card); max-width:560px; width:100%; max-height:88vh;
  overflow:auto; border-radius:24px; box-shadow:0 20px 60px rgba(0,0,0,.3);
}
.modal-head{
  position:sticky; top:0; background:var(--card); padding:18px 20px; border-bottom:1px solid var(--line);
  display:flex; justify-content:space-between; align-items:flex-start; gap:10px;
}
.modal-head h2{ font-size:15px; font-weight:800; margin:0; }
.modal-head p{ font-size:11.5px; color:var(--muted); margin:4px 0 0; }
.modal-close{
  background:#F0EFE9; border:none; width:30px; height:30px; border-radius:50%; cursor:pointer;
  flex-shrink:0; display:flex; align-items:center; justify-content:center;
}
.modal-body{ padding:18px 20px; }

.note-banner{
  background:linear-gradient(120deg,rgba(63,191,181,.12),rgba(217,164,65,.10));
  border:1px solid rgba(63,191,181,.25); border-radius:16px; padding:12px 14px;
  font-size:12px; font-weight:600;
  display:flex; gap:10px; align-items:flex-start; margin-bottom:16px;
}

/* Report share modal specific */
.report-preview{
  background:var(--paper); border:1px solid var(--line);
  border-radius:14px; padding:14px; font-size:12.5px; line-height:1.7;
  white-space:pre-wrap; max-height:260px; overflow-y:auto; color:var(--ink);
}
.share-actions{ display:flex; gap:8px; flex-wrap:wrap; margin-top:14px; }
.share-actions button{
  flex:1; min-width:120px; padding:11px 14px; border-radius:999px;
  border:none; font-weight:800; font-size:12.5px; cursor:pointer;
  display:inline-flex; align-items:center; justify-content:center; gap:6px;
  transition:.15s;
}
.share-actions .wa{ background:#25D366; color:#fff; }
.share-actions .wa:hover{ filter:brightness(1.05); }
.share-actions .tel{ background:rgba(63,191,181,.15); color:var(--teal-dk); }
.share-actions .copy{ background:#F0EFE9; color:var(--ink); }
[data-theme="dark"] .share-actions .copy{ background:#242736; color:var(--ink); }

/* Settings */
.settings-section{ margin-bottom:18px; }
.settings-section > label{
  font-size:11px; color:var(--muted); font-weight:700;
  margin-bottom:6px; display:flex; align-items:center; gap:6px;
}
.settings-section input[type="text"]{
  width:100%; padding:10px 14px; border:1px solid var(--line); border-radius:999px;
  font-size:13px; background:var(--paper); color:var(--ink); outline:none;
}
[data-theme="dark"] .settings-section input[type="text"]{ background:var(--card); }
.settings-section input[type="text"]:focus{ border-color:var(--teal); }

.theme-toggle,
.lang-select{ display:flex; gap:8px; }
.theme-toggle button,
.lang-select button{
  flex:1; padding:10px; border:1.5px solid var(--line); background:var(--paper); color:var(--muted);
  border-radius:999px; font-size:12.5px; font-weight:700; cursor:pointer;
  display:flex; align-items:center; justify-content:center; gap:6px;
  transition:.15s;
}
[data-theme="dark"] .theme-toggle button,
[data-theme="dark"] .lang-select button{ background:var(--card); }
.theme-toggle button.active,
.lang-select button.active{
  background:rgba(63,191,181,.12); border-color:var(--teal); color:var(--teal-dk);
}

.danger-zone{
  border:1px solid rgba(226,102,91,.3); border-radius:14px; padding:12px;
  background:rgba(226,102,91,.05); margin-top:14px;
}
.danger-zone h4{
  margin:0 0 8px; font-size:12px; font-weight:800; color:var(--coral);
  display:flex; align-items:center; gap:6px;
}
.danger-zone button{
  background:var(--coral); color:#fff; border:none; border-radius:999px;
  padding:9px 16px; font-size:12px; font-weight:800; cursor:pointer;
}

.firebase-warning{
  background:linear-gradient(120deg,rgba(226,102,91,.14),rgba(217,164,65,.12));
  border:1px solid rgba(226,102,91,.3); border-radius:16px; padding:16px 18px;
  font-size:13px; line-height:1.7; margin:20px;
}
.firebase-warning h3{ margin:0 0 8px; font-size:15px; color:var(--coral); }
.firebase-warning code{
  background:rgba(0,0,0,.06); padding:2px 6px; border-radius:6px; font-size:12px;
  font-family:'Consolas','Monaco',monospace;
}

/* Responsive */
@media (max-width:640px){
  .stats{ grid-template-columns:repeat(2,1fr); }
  main{ padding:14px; }
  .brand h1{ font-size:14px; }
  .brand p{ font-size:10px; }
}

/* Print */
@media print{
  header.top,
  .toolbar,
  .legend .hint,
  .print\:hide,
  .notes-card,
  .sync-status,
  .del-btn,
  .share-actions,
  .add-form{ display:none !important; }
  body{ background:#fff; }
  .print-title{ display:block !important; }
  .card{ border:2px solid var(--navy); }
  @page{ size:A4 landscape; margin:10mm; }
}
