/* ============================================================
   Majalis Al-Quran Center - Staff Management System
   Plain white/blue, government-form aesthetic. No decoration.
   Animations kept under 250ms per spec.
   ============================================================ */

:root {
    --blue: #1a4d8f;
    --blue-dark: #123a6b;
    --blue-light: #eaf1fb;
    --white: #ffffff;
    --grey-line: #d7dbe0;
    --grey-bg: #f4f6f8;
    --text: #1c1f24;
    --text-light: #5a6068;
    --green: #1f8a4c;
    --red: #b3261e;
    --yellow: #a67c00;
    --grey-toggle: #8a8f96;
    --sidebar-width: 230px;
    --topbar-height: 60px;
    --radius: 4px;
    --transition: 200ms ease;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    font-family: 'Segoe UI', Arial, Helvetica, sans-serif;
    background: var(--grey-bg);
    color: var(--text);
    font-size: 15px;
}

a { color: var(--blue); text-decoration: none; }

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

.sidebar {
    width: var(--sidebar-width);
    background: var(--white);
    border-right: 1px solid var(--grey-line);
    flex-shrink: 0;
    position: fixed;
    top: 0; bottom: 0; left: 0;
    display: flex;
    flex-direction: column;
    z-index: 50;
    transition: transform var(--transition);
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 16px 18px;
    border-bottom: 1px solid var(--grey-line);
}
.sidebar-brand img { width: 34px; height: 34px; object-fit: contain; }
.sidebar-brand .name { font-weight: 700; font-size: 14px; line-height: 1.25; color: var(--blue-dark); }
.sidebar-brand .sub { font-size: 11px; color: var(--text-light); }

.nav-list { list-style: none; margin: 10px 0; padding: 0; flex: 1; }
.nav-list li a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 18px;
    color: var(--text);
    font-size: 14px;
    border-left: 3px solid transparent;
    transition: background var(--transition), border-color var(--transition);
}
.nav-list li a i { width: 18px; text-align: center; color: var(--text-light); }
.nav-list li a:hover { background: var(--blue-light); }
.nav-list li a.active {
    background: var(--blue-light);
    border-left-color: var(--blue);
    color: var(--blue-dark);
    font-weight: 600;
}
.nav-list li a.active i { color: var(--blue); }

.sidebar-footer {
    padding: 12px 18px;
    border-top: 1px solid var(--grey-line);
    font-size: 11px;
    color: var(--text-light);
}

.main {
    margin-left: var(--sidebar-width);
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.topbar {
    height: var(--topbar-height);
    background: var(--white);
    border-bottom: 1px solid var(--grey-line);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 22px;
    position: sticky;
    top: 0;
    z-index: 40;
}
.topbar .page-title { font-size: 17px; font-weight: 700; color: var(--blue-dark); }
.topbar .date-display { font-size: 13px; color: var(--text-light); }
.topbar .menu-toggle {
    display: none;
    background: none; border: 1px solid var(--grey-line); border-radius: var(--radius);
    padding: 6px 10px; cursor: pointer;
}

.content { padding: 22px; flex: 1; }

/* ---------- Cards ---------- */
.summary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}
.summary-card {
    background: var(--white);
    border: 1px solid var(--grey-line);
    border-radius: var(--radius);
    padding: 16px 18px;
    border-left: 4px solid var(--blue);
}
.summary-card .label { font-size: 12px; color: var(--text-light); text-transform: uppercase; letter-spacing: .03em; }
.summary-card .value { font-size: 28px; font-weight: 700; color: var(--blue-dark); margin-top: 6px; }

/* ---------- Toolbar (search + register) ---------- */
.toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}
.search-box {
    flex: 1;
    min-width: 200px;
    max-width: 340px;
    display: flex;
    align-items: center;
    background: var(--white);
    border: 1px solid var(--grey-line);
    border-radius: var(--radius);
    padding: 8px 12px;
}
.search-box i { color: var(--text-light); margin-right: 8px; }
.search-box input {
    border: none; outline: none; flex: 1; font-size: 14px; background: transparent;
}

.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    border: 1px solid var(--blue);
    background: var(--blue);
    color: var(--white);
    padding: 9px 16px;
    border-radius: var(--radius);
    font-size: 14px;
    cursor: pointer;
    transition: background var(--transition), transform 100ms ease;
}
.btn:hover { background: var(--blue-dark); }
.btn:active { transform: scale(0.97); }
.btn.btn-outline { background: var(--white); color: var(--blue); }
.btn.btn-outline:hover { background: var(--blue-light); }
.btn.btn-danger { background: var(--red); border-color: var(--red); }
.btn.btn-danger:hover { background: #8f1e18; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ---------- Tables ---------- */
.table-wrap {
    background: var(--white);
    border: 1px solid var(--grey-line);
    border-radius: var(--radius);
    overflow-x: auto;
    animation: fadeIn 220ms ease;
}
table.data-table { width: 100%; border-collapse: collapse; min-width: 560px; }
table.data-table th, table.data-table td {
    padding: 11px 14px;
    text-align: left;
    border-bottom: 1px solid var(--grey-line);
    font-size: 14px;
    color: var(--text);
}
table.data-table th {
    background: var(--grey-bg);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: .03em;
    color: var(--text-light);
    border-bottom: 1px solid var(--grey-line);
}
table.data-table tbody tr { transition: background var(--transition); cursor: pointer; }
table.data-table tbody tr:hover { background: var(--blue-light); }
table.data-table tbody tr:last-child td { border-bottom: none; }

.status-pill {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    user-select: none;
    transition: background var(--transition), color var(--transition);
}
.status-pill.active { background: #e3f5e9; color: var(--green); }
.status-pill.inactive { background: #eceef0; color: var(--grey-toggle); }

/* Attendance toggle buttons */
.att-toggle-group { display: flex; gap: 6px; flex-wrap: wrap; }
.att-btn {
    border: 1px solid var(--grey-line);
    background: var(--white);
    color: var(--text-light);
    padding: 6px 12px;
    border-radius: var(--radius);
    font-size: 13px;
    cursor: pointer;
    transition: background var(--transition), color var(--transition), border-color var(--transition);
}
.att-btn[data-state="present"].is-active { background: var(--green); border-color: var(--green); color: var(--white); }
.att-btn[data-state="absent"].is-active { background: var(--red); border-color: var(--red); color: var(--white); }
.att-btn[data-state="leave"].is-active { background: var(--yellow); border-color: var(--yellow); color: var(--white); }
.att-btn[data-state="none"].is-active { background: var(--grey-toggle); border-color: var(--grey-toggle); color: var(--white); }

.session-tabs { display: flex; gap: 8px; margin-bottom: 16px; flex-wrap: wrap; }
.session-tab {
    padding: 8px 16px;
    border: 1px solid var(--grey-line);
    border-radius: var(--radius);
    background: var(--white);
    cursor: pointer;
    font-size: 14px;
    color: var(--text);
}
.session-tab.active { background: var(--blue); color: var(--white); border-color: var(--blue); }

/* ---------- Modal ---------- */
.modal-overlay {
    position: fixed; inset: 0;
    background: rgba(20, 30, 45, 0.45);
    display: none;
    align-items: center; justify-content: center;
    z-index: 100;
    animation: fadeIn 200ms ease;
}
.modal-overlay.open { display: flex; }
.modal-box {
    background: var(--white);
    border-radius: var(--radius);
    width: 100%;
    max-width: 440px;
    max-height: 88vh;
    overflow-y: auto;
    padding: 22px 24px;
    position: relative;
    animation: modalScale 200ms ease;
    border: 1px solid var(--grey-line);
}
@keyframes modalScale { from { transform: scale(.96); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.modal-close {
    position: absolute; top: 14px; right: 14px;
    background: none; border: none; font-size: 18px; cursor: pointer;
    color: var(--text-light);
    width: 28px; height: 28px; border-radius: 50%;
    transition: background var(--transition), transform 200ms ease;
}
.modal-close:hover { background: var(--grey-bg); transform: rotate(90deg); }

.modal-box h3 { margin-top: 0; color: var(--blue-dark); font-size: 18px; }
.modal-field { margin-bottom: 12px; }
.modal-field label { display: block; font-size: 12px; color: var(--text-light); margin-bottom: 3px; text-transform: uppercase; letter-spacing: .03em; }
.modal-field .val { font-size: 14px; }
.modal-field input {
    width: 100%; padding: 8px 10px; border: 1px solid var(--grey-line); border-radius: var(--radius); font-size: 14px;
}
.modal-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 14px 0; }
.modal-stats .stat-box { background: var(--grey-bg); border-radius: var(--radius); padding: 10px; text-align: center; }
.modal-stats .stat-box .num { font-size: 20px; font-weight: 700; color: var(--blue-dark); }
.modal-stats .stat-box .lbl { font-size: 11px; color: var(--text-light); }
.modal-actions { display: flex; gap: 10px; margin-top: 18px; }

/* ---------- Toast ---------- */
.toast {
    position: fixed;
    bottom: 20px; right: 20px;
    background: var(--blue-dark);
    color: var(--white);
    padding: 12px 18px;
    border-radius: var(--radius);
    font-size: 14px;
    z-index: 200;
    animation: fadeIn 200ms ease;
}
.toast.error { background: var(--red); }

/* ---------- Forms ---------- */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-field { display: flex; flex-direction: column; gap: 5px; }
.form-field label { font-size: 12px; color: var(--text-light); }
.form-field input {
    padding: 9px 10px; border: 1px solid var(--grey-line); border-radius: var(--radius); font-size: 14px;
}
.form-field input:focus, .att-btn:focus, .btn:focus, .status-pill:focus, .session-tab:focus {
    outline: 2px solid var(--blue); outline-offset: 1px;
}

/* ---------- Payments ---------- */
.pay-section-title { font-size: 15px; font-weight: 700; color: var(--blue-dark); margin: 22px 0 10px; }
.paid-pill { background: #e3f5e9; color: var(--green); padding: 3px 10px; border-radius: 12px; font-size: 12px; font-weight: 600; }
.unpaid-pill { background: #fdeceb; color: var(--red); padding: 3px 10px; border-radius: 12px; font-size: 12px; font-weight: 600; }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); }
    .main { margin-left: 0; }
    .topbar .menu-toggle { display: inline-block; }
    .form-grid { grid-template-columns: 1fr; }
}
@media (max-width: 560px) {
    .content { padding: 14px; }
    .summary-grid { grid-template-columns: 1fr 1fr; }
    .modal-box { padding: 18px; }
}
