/* ================================================
   نظام الحضور — Custom CSS (Bootstrap 5 Override)
   ================================================ */

:root {
    --primary:   #1d4ed8;
    --primary-l: #3b82f6;
    --success:   #16a34a;
    --danger:    #dc2626;
    --warning:   #d97706;
    --sidebar-w: 260px;
    --sidebar-bg:#0f172a;
}

/* ── Body ─────────────────────────────────────── */
body {
    font-family: 'Segoe UI', Tahoma, Arial, sans-serif;
    background: #f1f5f9;
    color: #1e293b;
    direction: rtl;
}

/* ── Sidebar ──────────────────────────────────── */
#sidebar {
    width: var(--sidebar-w);
    min-height: 100vh;
    background: var(--sidebar-bg);
    position: fixed;
    top: 0;
    right: 0;
    z-index: 1000;
    transition: transform .3s ease;
    overflow-y: auto;
}

#sidebar .sidebar-brand {
    padding: 1.25rem 1rem;
    border-bottom: 1px solid rgba(255,255,255,.08);
}

#sidebar .sidebar-brand h5 {
    color: #e2e8f0;
    font-weight: 700;
    margin: 0;
    font-size: .95rem;
}

#sidebar .nav-link {
    color: #94a3b8;
    padding: .6rem 1.25rem;
    border-radius: 8px;
    margin: 2px 8px;
    display: flex;
    align-items: center;
    gap: .6rem;
    font-size: .88rem;
    transition: background .2s, color .2s;
}

#sidebar .nav-link:hover,
#sidebar .nav-link.active {
    background: rgba(59,130,246,.18);
    color: #93c5fd;
}

#sidebar .nav-link i { width: 18px; text-align: center; }

#sidebar .nav-section {
    color: #475569;
    font-size: .7rem;
    font-weight: 700;
    letter-spacing: .08em;
    text-transform: uppercase;
    padding: 1rem 1.25rem .3rem;
}

/* ── Collapsible sidebar portals (accordion) ──── */
#sidebar .nav-section-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    color: #94a3b8;
    font-size: .72rem;
    font-weight: 700;
    letter-spacing: .06em;
    text-transform: uppercase;
    padding: .85rem 1.25rem;
    margin: 2px 8px;
    border-radius: 8px;
    text-decoration: none;
    cursor: pointer;
    user-select: none;
    transition: background .15s;
}
#sidebar .nav-section-toggle:hover { background: rgba(255,255,255,.06); color: #cbd5e1; }
#sidebar .nav-section-toggle .section-label { display: flex; align-items: center; gap: .55rem; }
#sidebar .nav-section-toggle .section-label i { width: 16px; text-align: center; }
#sidebar .nav-section-toggle .toggle-icon { font-size: .62rem; transition: transform .2s ease; }
#sidebar .nav-section-toggle[aria-expanded="true"] { color: #e2e8f0; }
#sidebar .nav-section-toggle[aria-expanded="true"] .toggle-icon { transform: rotate(180deg); }

/* ── Main Content ─────────────────────────────── */
#main-content {
    margin-right: var(--sidebar-w);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ── Top Navbar ───────────────────────────────── */
.top-navbar {
    background: #fff;
    border-bottom: 1px solid #e2e8f0;
    padding: .75rem 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 900;
    box-shadow: 0 1px 3px rgba(0,0,0,.06);
}

.top-navbar .page-title {
    font-size: 1.05rem;
    font-weight: 700;
    color: #1e293b;
    margin: 0;
}

.top-navbar .user-info {
    display: flex;
    align-items: center;
    gap: .75rem;
}

.top-navbar .avatar {
    width: 36px; height: 36px;
    background: var(--primary);
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    color: #fff; font-weight: 700; font-size: .9rem;
}

/* ── Page Body ────────────────────────────────── */
.page-body { padding: 1.5rem; flex: 1; }

/* ── Cards ────────────────────────────────────── */
.card {
    border: none;
    border-radius: 12px;
    box-shadow: 0 1px 4px rgba(0,0,0,.07);
}

.card-header {
    background: #fff;
    border-bottom: 1px solid #f1f5f9;
    font-weight: 700;
    padding: 1rem 1.25rem;
    border-radius: 12px 12px 0 0 !important;
}

.stat-card {
    background: #fff;
    border-radius: 12px;
    padding: 1.25rem 1.5rem;
    box-shadow: 0 1px 4px rgba(0,0,0,.07);
    display: flex;
    align-items: center;
    gap: 1rem;
}

.stat-card .icon-box {
    width: 50px; height: 50px;
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.4rem;
}

.stat-card .stat-label { font-size: .8rem; color: #64748b; margin: 0; }
.stat-card .stat-value { font-size: 1.6rem; font-weight: 800; margin: 0; line-height: 1; }

/* ── Badge pills ──────────────────────────────── */
.status-badge {
    font-size: .75rem;
    padding: .25rem .65rem;
    border-radius: 20px;
    font-weight: 600;
}
.badge-pending  { background: #fef3c7; color: #92400e; }
.badge-approved { background: #d1fae5; color: #065f46; }
.badge-rejected { background: #fee2e2; color: #991b1b; }
.badge-admin    { background: #ede9fe; color: #5b21b6; }

/* ── Tables ───────────────────────────────────── */
.table th { font-size: .8rem; color: #64748b; font-weight: 600; border-bottom: 2px solid #f1f5f9; }
.table td { font-size: .88rem; vertical-align: middle; border-color: #f8fafc; }
.table-hover tbody tr:hover { background: #f8fafc; }

/* ── Forms ────────────────────────────────────── */
.form-label { font-weight: 600; font-size: .87rem; color: #374151; }
.form-control, .form-select {
    border-radius: 8px;
    border: 1.5px solid #e5e7eb;
    font-size: .9rem;
    transition: border-color .2s, box-shadow .2s;
}
.form-control:focus, .form-select:focus {
    border-color: var(--primary-l);
    box-shadow: 0 0 0 3px rgba(59,130,246,.12);
}

/* ── Buttons ──────────────────────────────────── */
.btn { border-radius: 8px; font-weight: 600; font-size: .87rem; }
.btn-primary { background: var(--primary); border-color: var(--primary); }
.btn-primary:hover { background: #1e40af; border-color: #1e40af; }

/* ── Balance Card ─────────────────────────────── */
.balance-card {
    background: #f0f9ff;
    border: 1.5px solid #7dd3fc;
    border-radius: 10px;
    padding: 14px 18px;
}
.balance-card .bal-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 4px 0;
    border-bottom: 1px solid #bae6fd;
    font-size: .85rem;
}
.balance-card .bal-row:last-child { border-bottom: none; padding-top: 6px; }
.balance-card .bal-label { color: #0369a1; font-weight: 700; }
.balance-card .bal-value { font-weight: 900; color: #0c4a6e; font-size: 1.1rem; }
.balance-card .bal-value.negative { color: var(--danger); }

/* ── Toast ────────────────────────────────────── */
#toast-container {
    position: fixed;
    top: 1rem;
    left: 1rem;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: .5rem;
}
.app-toast {
    min-width: 280px;
    padding: .85rem 1.1rem;
    border-radius: 10px;
    font-size: .87rem;
    font-weight: 600;
    box-shadow: 0 4px 12px rgba(0,0,0,.15);
    animation: slideIn .3s ease;
}
.app-toast.success { background: #d1fae5; color: #065f46; border-right: 4px solid #16a34a; }
.app-toast.error   { background: #fee2e2; color: #991b1b; border-right: 4px solid #dc2626; }
.app-toast.info    { background: #e0f2fe; color: #075985; border-right: 4px solid #0ea5e9; }

@keyframes slideIn {
    from { transform: translateX(-20px); opacity: 0; }
    to   { transform: translateX(0);     opacity: 1; }
}

/* ── Login Page ───────────────────────────────── */
.login-page {
    min-height: 100vh;
    background: linear-gradient(135deg, #0f172a 0%, #1e3a5f 100%);
    display: flex;
    align-items: center;
    justify-content: center;
}

.login-card {
    background: #fff;
    border-radius: 16px;
    padding: 2.5rem 2rem;
    width: 100%;
    max-width: 400px;
    box-shadow: 0 20px 60px rgba(0,0,0,.3);
}

.login-logo {
    width: 64px; height: 64px;
    background: var(--primary);
    border-radius: 16px;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.8rem;
    color: #fff;
    margin: 0 auto 1.25rem;
}

/* ── Responsive ───────────────────────────────── */
@media (max-width: 768px) {
    #sidebar { transform: translateX(100%); }
    #sidebar.show { transform: translateX(0); }
    #main-content { margin-right: 0; }
    .page-body { padding: 1rem; }
}

/* ── Signature Canvas ─────────────────────────── */
canvas.sig-canvas {
    border: 2px dashed #cbd5e1;
    border-radius: 8px;
    width: 100%;
    height: 150px;
    cursor: crosshair;
    background: #f8fafc;
    touch-action: none;
}

canvas.sig-canvas.signed { border-color: var(--success); border-styl