/* =====================================================================
   سامانه حضور و عملکرد — Design system
   Calm / Premium / Professional. Navy + white, one restrained accent.
   Dark is default; .light on <html> flips to the light theme.
   ===================================================================== */

:root {
    --navy-900: #0b1220;
    --navy-850: #0f1830;
    --navy-800: #111c38;
    --navy-700: #16244a;
    --surface:  #131f3d;
    --surface-2:#182a52;
    --border:   rgba(255, 255, 255, .08);
    --border-2: rgba(255, 255, 255, .14);
    --text:     #eef2fb;
    --text-2:   #9aa7c7;
    --text-3:   #6b7799;
    --accent:   #3d7dff;
    --accent-2: #2f6ae6;
    --accent-soft: rgba(61, 125, 255, .14);

    --green: #35c78a;
    --amber: #f0b34e;
    --red:   #ec5f6a;
    --blue:  #4aa3ff;
    --gray:  #6b7799;

    --radius: 16px;
    --radius-sm: 10px;
    --shadow: 0 10px 40px rgba(0, 0, 0, .35);
    --shadow-sm: 0 4px 18px rgba(0, 0, 0, .22);
    --font: "Vazirmatn", "Segoe UI", Tahoma, sans-serif;
    --ease: cubic-bezier(.22, .61, .36, 1);
}

html.light {
    --navy-900: #eef1f7;
    --navy-850: #f3f5fa;
    --navy-800: #ffffff;
    --navy-700: #ffffff;
    --surface:  #ffffff;
    --surface-2:#f5f7fc;
    --border:   rgba(16, 28, 56, .10);
    --border-2: rgba(16, 28, 56, .18);
    --text:     #0f1830;
    --text-2:   #566187;
    --text-3:   #8a93ad;
    --accent-soft: rgba(61, 125, 255, .12);
    --shadow: 0 10px 40px rgba(16, 28, 56, .10);
    --shadow-sm: 0 4px 18px rgba(16, 28, 56, .07);
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--navy-900);
    color: var(--text);
    font-family: var(--font);
    font-size: 15px;
    line-height: 1.7;
    direction: rtl;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
h1, h2, h3, h4 { margin: 0 0 .6rem; font-weight: 700; letter-spacing: -.2px; }
h1 { font-size: 1.5rem; } h2 { font-size: 1.2rem; } h3 { font-size: 1.02rem; }
p { margin: .3rem 0; color: var(--text-2); }
small { color: var(--text-3); }

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

.sidebar {
    width: 264px;
    flex-shrink: 0;
    background: var(--navy-850);
    border-inline-start: 1px solid var(--border);
    padding: 22px 16px;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
}

.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 18px; }
.brand .logo {
    width: 38px; height: 38px; border-radius: 11px;
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
    display: grid; place-items: center; color: #fff; font-weight: 800;
    box-shadow: 0 6px 18px var(--accent-soft);
}
.brand b { font-size: 1.02rem; }
.brand span { display: block; color: var(--text-3); font-size: .72rem; }

.nav-group { margin: 14px 0 6px; padding: 0 8px; color: var(--text-3); font-size: .72rem; font-weight: 700; }
.nav a {
    display: flex; align-items: center; gap: 11px;
    padding: 10px 12px; border-radius: var(--radius-sm);
    color: var(--text-2); font-size: .92rem; margin-bottom: 2px;
    transition: background .18s var(--ease), color .18s var(--ease);
}
.nav a .ic { width: 20px; text-align: center; opacity: .9; }
.nav a:hover { background: var(--surface-2); color: var(--text); }
.nav a.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
    display: flex; align-items: center; justify-content: space-between;
    padding: 16px 26px; border-bottom: 1px solid var(--border);
    background: color-mix(in srgb, var(--navy-900) 82%, transparent);
    position: sticky; top: 0; z-index: 20; backdrop-filter: blur(10px);
}
.topbar .pagetitle { font-weight: 700; font-size: 1.05rem; }
.topbar .right { display: flex; align-items: center; gap: 14px; }

.iconbtn {
    width: 40px; height: 40px; border-radius: 11px; border: 1px solid var(--border);
    background: var(--surface); color: var(--text-2); cursor: pointer;
    display: grid; place-items: center; font-size: 1.05rem; position: relative;
    transition: .18s var(--ease);
}
.iconbtn:hover { border-color: var(--border-2); color: var(--text); }
.badge-dot {
    position: absolute; top: -3px; left: -3px; min-width: 17px; height: 17px;
    background: var(--red); color: #fff; border-radius: 9px; font-size: .62rem;
    display: grid; place-items: center; padding: 0 4px; font-weight: 700;
}

.avatar {
    width: 38px; height: 38px; border-radius: 50%; object-fit: cover;
    background: var(--surface-2); border: 1px solid var(--border);
    display: grid; place-items: center; color: var(--text-2); font-weight: 700;
}

.content { padding: 26px; max-width: 1180px; width: 100%; margin: 0 auto; animation: fadeUp .34s var(--ease); }

@keyframes fadeUp { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes scaleIn { from { opacity: 0; transform: scale(.96); } to { opacity: 1; transform: none; } }

/* ---------- Cards & grid ---------- */
.card {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow-sm);
    margin-bottom: 18px;
}
.card.pad-lg { padding: 26px; }
.grid { display: grid; gap: 16px; }
.grid.cols-2 { grid-template-columns: repeat(2, 1fr); }
.grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
.grid.cols-4 { grid-template-columns: repeat(4, 1fr); }
.row { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; }
.spread { justify-content: space-between; }
.muted { color: var(--text-3); }
.mt { margin-top: 14px; } .mb { margin-bottom: 14px; }

/* ---------- Stat tiles ---------- */
.stat {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 18px 20px;
}
.stat .label { color: var(--text-3); font-size: .82rem; }
.stat .value { font-size: 1.7rem; font-weight: 800; margin-top: 4px; letter-spacing: -.5px; }
.stat .value.pos { color: var(--green); }
.stat .value.neg { color: var(--red); }
.stat .sub { color: var(--text-3); font-size: .76rem; margin-top: 2px; }

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex; align-items: center; gap: 8px; cursor: pointer;
    border: 1px solid var(--border-2); background: var(--surface-2); color: var(--text);
    padding: 10px 18px; border-radius: var(--radius-sm); font: inherit; font-weight: 600;
    font-size: .9rem; transition: .16s var(--ease);
}
.btn:hover { transform: translateY(-1px); border-color: var(--accent); }
.btn.primary { background: linear-gradient(135deg, var(--accent), var(--accent-2)); border-color: transparent; color: #fff; }
.btn.primary:hover { box-shadow: 0 8px 22px var(--accent-soft); }
.btn.ghost { background: transparent; }
.btn.danger { border-color: var(--red); color: var(--red); background: transparent; }
.btn.sm { padding: 6px 12px; font-size: .82rem; }
.btn.block { width: 100%; justify-content: center; }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }

/* ---------- Forms ---------- */
label.field { display: block; margin-bottom: 12px; }
label.field .lbl { display: block; color: var(--text-2); font-size: .84rem; margin-bottom: 6px; }
input, select, textarea {
    width: 100%; padding: 11px 13px; border-radius: var(--radius-sm);
    border: 1px solid var(--border-2); background: var(--navy-800); color: var(--text);
    font: inherit; font-size: .92rem; transition: .16s var(--ease);
}
input:focus, select:focus, textarea:focus {
    outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft);
}
input[type=time] { direction: ltr; text-align: center; }
input.time24 { direction: ltr; text-align: center; letter-spacing: 1px; max-width: 130px; }
textarea { min-height: 90px; resize: vertical; }

/* ---------- Tables ---------- */
table { width: 100%; border-collapse: collapse; }
th, td { padding: 12px 10px; text-align: right; border-bottom: 1px solid var(--border); font-size: .9rem; }
th { color: var(--text-3); font-weight: 600; font-size: .8rem; }
tr:last-child td { border-bottom: none; }
tbody tr { transition: background .15s var(--ease); }
tbody tr:hover { background: var(--surface-2); }

/* ---------- Chips / status ---------- */
.chip {
    display: inline-flex; align-items: center; gap: 6px; padding: 4px 11px;
    border-radius: 999px; font-size: .78rem; font-weight: 600;
    background: var(--surface-2); color: var(--text-2);
}
.chip.green { background: rgba(53,199,138,.14); color: var(--green); }
.chip.amber { background: rgba(240,179,78,.14); color: var(--amber); }
.chip.red   { background: rgba(236,95,106,.14); color: var(--red); }
.chip.blue  { background: rgba(74,163,255,.14); color: var(--blue); }
.chip.gray  { background: var(--surface-2); color: var(--text-3); }

/* ---------- Line boxes (today's presence) ---------- */
.linebox {
    display: flex; align-items: center; justify-content: space-between;
    padding: 14px 18px; border: 1px solid var(--border); border-radius: var(--radius-sm);
    background: var(--surface); margin-bottom: 10px;
}
.linebox .who { display: flex; align-items: center; gap: 12px; font-weight: 600; }
.linebox .times { display: flex; gap: 26px; }
.linebox .times div { text-align: center; }
.linebox .times .t { font-size: 1.05rem; font-weight: 700; direction: ltr; }
.linebox .times .k { font-size: .7rem; color: var(--text-3); }

/* ---------- Flash ---------- */
.flash { padding: 12px 16px; border-radius: var(--radius-sm); margin-bottom: 16px; font-weight: 600; font-size: .9rem; animation: scaleIn .25s var(--ease); }
.flash.ok  { background: rgba(53,199,138,.14); color: var(--green); border: 1px solid rgba(53,199,138,.3); }
.flash.err { background: rgba(236,95,106,.14); color: var(--red); border: 1px solid rgba(236,95,106,.3); }

/* ---------- Clock widget ---------- */
.clock-wrap { text-align: center; padding: 10px 0 4px; }
.clock-time { font-size: 3.2rem; font-weight: 800; letter-spacing: 1px; direction: ltr; }
.clock-date { color: var(--text-3); margin-bottom: 16px; }

/* ---------- Flip sheet (desktop) ---------- */
.sheet { perspective: 1800px; }
.sheet-inner { position: relative; transition: transform .7s var(--ease); transform-style: preserve-3d; }
.sheet.flipped .sheet-inner { transform: rotateY(180deg); }
.sheet-face { backface-visibility: hidden; }
.sheet-back { position: absolute; inset: 0; transform: rotateY(180deg); }

/* ---------- Calendar ---------- */
.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 8px; }
.cal .head { text-align: center; color: var(--text-3); font-size: .78rem; padding-bottom: 4px; }
.cal .cell {
    aspect-ratio: 1 / .92; border: 1px solid var(--border); border-radius: var(--radius-sm);
    padding: 8px; position: relative; background: var(--surface); cursor: pointer;
    transition: .15s var(--ease); display: flex; flex-direction: column;
}
.cal .cell:hover { border-color: var(--accent); transform: translateY(-2px); }
.cal .cell .d { font-weight: 700; }
.cal .cell .tag { margin-top: auto; font-size: .68rem; }
.cal .cell.empty { background: transparent; border: none; cursor: default; }
.cal .cell.holiday { background: rgba(236,95,106,.10); border-color: rgba(236,95,106,.3); }
.cal .cell.remote  { background: rgba(74,163,255,.10);  border-color: rgba(74,163,255,.3); }
.cal .cell.complete{ border-inline-start: 3px solid var(--green); }
.cal .cell.late    { border-inline-start: 3px solid var(--amber); }
.cal .cell.shortage{ border-inline-start: 3px solid var(--red); }
.cal .cell.leave   { border-inline-start: 3px solid var(--blue); }
.cal .cell.friday  { opacity: .6; }

/* ---------- Timeline ---------- */
.timeline { position: relative; padding-inline-start: 22px; }
.timeline::before { content: ""; position: absolute; inset-inline-start: 6px; top: 4px; bottom: 4px; width: 2px; background: var(--border-2); }
.timeline .ev { position: relative; padding: 6px 0; }
.timeline .ev::before { content: ""; position: absolute; inset-inline-start: -20px; top: 12px; width: 10px; height: 10px; border-radius: 50%; background: var(--accent); }

/* ---------- Progress / meter ---------- */
.meter { height: 8px; border-radius: 6px; background: var(--surface-2); overflow: hidden; }
.meter > i { display: block; height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent-2)); }

/* ---------- Tabs (mobile week) ---------- */
.tabs { display: flex; gap: 6px; background: var(--surface-2); padding: 5px; border-radius: 12px; margin-bottom: 16px; }
.tabs button { flex: 1; border: none; background: transparent; color: var(--text-2); padding: 9px; border-radius: 9px; font: inherit; font-weight: 600; cursor: pointer; }
.tabs button.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }

/* ---------- Activity items editor ---------- */
.act-item { display: flex; gap: 8px; margin-bottom: 8px; align-items: flex-start; }
.act-item .num { flex-shrink: 0; width: 28px; height: 42px; display: grid; place-items: center; color: var(--text-3); font-weight: 700; }
.act-item .del { flex-shrink: 0; }

/* ---------- Read-only daily report list (admin dashboard) ---------- */
.report-list { margin: 0; padding-inline-start: 22px; display: flex; flex-direction: column; gap: 6px; }
.report-list li { font-size: .9rem; line-height: 1.7; color: var(--text-2, var(--text)); padding-inline-start: 4px; }
.report-list li::marker { color: var(--accent); font-weight: 700; }

/* ---------- Modal ---------- */
.modal-bg { position: fixed; inset: 0; background: rgba(0,0,0,.55); display: none; place-items: center; z-index: 100; padding: 20px; }
.modal-bg.open { display: grid; animation: fadeUp .2s var(--ease); }
.modal { background: var(--surface); border: 1px solid var(--border-2); border-radius: var(--radius); padding: 24px; max-width: 480px; width: 100%; animation: scaleIn .22s var(--ease); box-shadow: var(--shadow); }

/* ---------- Skeleton ---------- */
.skel { background: linear-gradient(90deg, var(--surface) 25%, var(--surface-2) 37%, var(--surface) 63%); background-size: 400% 100%; animation: shimmer 1.4s infinite; border-radius: 8px; }
@keyframes shimmer { 0% { background-position: 100% 0; } 100% { background-position: -100% 0; } }

/* ---------- Mobile ---------- */
.mobile-only { display: none; }
.menu-btn { display: none; }
@media (max-width: 900px) {
    .sidebar { position: fixed; inset-inline-end: 0; transform: translateX(100%); z-index: 60; transition: transform .3s var(--ease); box-shadow: var(--shadow); }
    .sidebar.open { transform: none; }
    .menu-btn { display: grid; }
    .grid.cols-4 { grid-template-columns: repeat(2, 1fr); }
    .grid.cols-3 { grid-template-columns: 1fr; }
    .grid.cols-2 { grid-template-columns: 1fr; }
    .desktop-only { display: none !important; }
    .mobile-only { display: block; }
    .content { padding: 16px; }
    .linebox { flex-direction: column; align-items: flex-start; gap: 10px; }
    .linebox .times { gap: 20px; }
    .scrim { position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 55; }
}
