﻿/* ═══════════════════════════════════════════════
   أكاديمية المعارف — "سجل المدرسة"
   ═══════════════════════════════════════════════ */

:root {
    --ink: #1B2A4A;
    --ink-soft: #33466E;
    --ink-muted: #5E6A84;
    --paper: #EEF1F5;
    --sheet: #FFFFFF;
    --rule: #D3DCEA;
    --rule-strong: #9FB1CF;
    --margin: #C8352B;
    --margin-soft: #FBE9E7;
    --green: #2F6B4F;
    --green-soft: #E4EFE8;
    --marker: #F2C94C;
    --marker-soft: #FBF0C9;
    --side-text: #C9D3E6;
    --font-display: 'Reem Kufi', 'Alexandria', system-ui, sans-serif;
    --font-body: 'Alexandria', system-ui, sans-serif;
    --radius: 6px;
    --sidebar: 264px;
    --row: 48px;
    --margin-line: 56px;
}
/* hidden يُخفي دائماً - حتى لو أعطى صنفٌ العنصرَ display: flex أو grid */
[hidden] {
    display: none !important;
}
*, *::before, *::after {
    box-sizing: border-box;
}

html {
    -webkit-text-size-adjust: 100%;
}

body {
    margin: 0;
    font-family: var(--font-body);
    font-size: 0.9375rem;
    line-height: 1.65;
    color: var(--ink);
    background: var(--paper);
    font-variant-numeric: tabular-nums;
}

h1, h2, h3 {
    font-family: var(--font-display);
    line-height: 1.25;
    margin: 0;
}

p {
    margin: 0;
}

a {
    color: inherit;
}

img {
    display: block;
    max-width: 100%;
}

code {
    font-size: 0.875em;
}

:focus-visible {
    outline: 3px solid var(--marker);
    outline-offset: 2px;
    border-radius: 3px;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
    border: 0;
}

.muted {
    color: var(--ink-muted);
}

/* قلم التظليل - للعنصر "الحالي" فقط */
mark.hl {
    background: linear-gradient(transparent 52%, var(--marker) 52%, var(--marker) 92%, transparent 92%);
    color: inherit;
    padding-inline: 2px;
}

/* ─────────────── القالب ─────────────── */

.panel {
    display: grid;
    grid-template-columns: var(--sidebar) minmax(0, 1fr);
    min-height: 100dvh;
}

.side {
    position: sticky;
    top: 0;
    height: 100dvh;
    display: flex;
    flex-direction: column;
    background: var(--ink);
    color: var(--side-text);
    padding-block: 22px 16px;
    padding-inline-start: 16px;
    overflow-y: auto;
    z-index: 30;
}

.side__brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding-inline-end: 16px;
    margin-bottom: 26px;
    text-decoration: none;
    color: #fff;
    font-family: var(--font-display);
    font-size: 1.25rem;
    font-weight: 600;
}

    .side__brand img {
        border-radius: 8px;
        background: #fff;
    }

.side__nav {
    flex: 1;
}

.side__group + .side__group {
    margin-top: 18px;
}

.side__group-title {
    font-size: 0.75rem;
    color: #8C99B5;
    margin-bottom: 6px;
    padding-inline-start: 12px;
}

.side__group ul {
    list-style: none;
    margin: 0;
    padding: 0;
}

/* العنصر النشط "لسان" بلون الورق يتصل بالصفحة */
.side__link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    text-decoration: none;
    font-size: 0.9rem;
    border-start-start-radius: 8px;
    border-end-start-radius: 8px;
    transition: background-color .15s, color .15s;
}

    .side__link svg {
        width: 18px;
        height: 18px;
        flex: none;
        opacity: .85;
    }

    .side__link:hover {
        background: rgba(255, 255, 255, .06);
        color: #fff;
    }

    .side__link.is-active {
        background: var(--paper);
        color: var(--ink);
        font-weight: 600;
    }

        .side__link.is-active svg {
            opacity: 1;
        }

.side__foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-top: 18px;
    padding-top: 14px;
    padding-inline-end: 12px;
    border-top: 1px solid rgba(255, 255, 255, .1);
}

.side__user {
    display: grid;
    min-width: 0;
}

    .side__user span {
        color: #fff;
        font-size: 0.875rem;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .side__user small {
        color: #8C99B5;
        font-size: 0.75rem;
    }

.side-scrim {
    display: none;
}

.main {
    min-width: 0;
    padding: 24px 40px 64px;
}

.top {
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 8px;
}

.top__menu {
    display: none;
}

/* ─────────────── رأس الصفحة ─────────────── */

.page-head {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    padding-bottom: 18px;
    margin-bottom: 24px;
    border-bottom: 2px solid var(--ink);
}

    .page-head h1 {
        font-size: 2rem;
        font-weight: 600;
    }

    .page-head p {
        color: var(--ink-muted);
        margin-top: 6px;
        max-width: 70ch;
    }

/* ─────────────── الأزرار ─────────────── */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    height: 40px;
    padding: 0 18px;
    border: 1px solid transparent;
    border-radius: var(--radius);
    font: inherit;
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    text-decoration: none;
    white-space: nowrap;
    transition: background-color .15s, border-color .15s, opacity .15s;
}

    .btn svg {
        width: 17px;
        height: 17px;
    }

    .btn:disabled {
        opacity: .55;
        cursor: not-allowed;
    }

.btn--ink {
    background: var(--ink);
    color: #fff;
}

    .btn--ink:hover:not(:disabled) {
        background: var(--ink-soft);
    }

.btn--ghost {
    background: var(--sheet);
    color: var(--ink);
    border-color: var(--rule-strong);
}

    .btn--ghost:hover:not(:disabled) {
        border-color: var(--ink);
    }

.btn--danger {
    background: var(--margin);
    color: #fff;
}

.btn--sm {
    height: 32px;
    padding: 0 12px;
    font-size: 0.8125rem;
}

.btn--block {
    width: 100%;
}

.btn.is-busy {
    position: relative;
    color: transparent;
}

    .btn.is-busy::after {
        content: '';
        position: absolute;
        width: 16px;
        height: 16px;
        border: 2px solid #fff;
        border-inline-end-color: transparent;
        border-radius: 50%;
        animation: spin .7s linear infinite;
    }

.btn-icon {
    display: inline-grid;
    place-items: center;
    width: 34px;
    height: 34px;
    border: 0;
    border-radius: var(--radius);
    background: transparent;
    color: var(--ink-muted);
    cursor: pointer;
}

    .btn-icon svg {
        width: 17px;
        height: 17px;
    }

    .btn-icon:hover {
        background: var(--paper);
        color: var(--ink);
    }

.btn-icon--danger:hover {
    background: var(--margin-soft);
    color: var(--margin);
}

.btn-icon--light {
    color: var(--side-text);
}

    .btn-icon--light:hover {
        background: rgba(255, 255, 255, .08);
        color: #fff;
    }

.link-quiet {
    color: var(--ink-muted);
    font-size: 0.875rem;
    text-underline-offset: 3px;
}

    .link-quiet:hover {
        color: var(--ink);
    }

.link-strong {
    font-weight: 600;
    text-underline-offset: 3px;
}

/* ─────────────── الحقول ─────────────── */

.f {
    display: grid;
    gap: 6px;
    margin-bottom: 18px;
}

    .f label {
        font-weight: 500;
        font-size: 0.875rem;
    }

.f-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
}

.f__label-row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
}

.f__hint {
    color: var(--ink-muted);
    font-size: 0.8125rem;
}

.f__err {
    color: var(--margin);
    font-size: 0.8125rem;
    min-height: 0;
}

    .f__err:empty {
        display: none;
    }

.f input:not([type=checkbox]), .f select, .f textarea,
.toolbar input, .toolbar select {
    width: 100%;
    height: 42px;
    padding: 0 12px;
    border: 1px solid var(--rule-strong);
    border-radius: var(--radius);
    background: var(--sheet);
    color: var(--ink);
    font: inherit;
}

.f textarea {
    height: auto;
    min-height: 96px;
    padding: 10px 12px;
    resize: vertical;
}

    .f input:focus, .f select:focus, .f textarea:focus,
    .toolbar input:focus, .toolbar select:focus {
        outline: 3px solid var(--marker);
        outline-offset: 0;
        border-color: var(--ink);
    }

.f .input-validation-error {
    border-color: var(--margin);
}

.input-code {
    letter-spacing: .5em;
    text-align: center;
    font-size: 1.25rem;
    font-weight: 600;
}

.check {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 18px;
    cursor: pointer;
    font-size: 0.9rem;
}

    .check input {
        width: 18px;
        height: 18px;
        accent-color: var(--ink);
    }

.toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 14px;
}

    .toolbar > * {
        flex: 0 1 220px;
    }

    .toolbar .toolbar__search {
        flex: 1 1 260px;
    }

/* ─────────────── الملاحظات والوسوم ─────────────── */

.note {
    padding: 12px 16px;
    border-radius: var(--radius);
    border-inline-start: 4px solid;
    margin-bottom: 18px;
    font-size: 0.9rem;
}

.note--red {
    background: var(--margin-soft);
    border-color: var(--margin);
}

.note--green {
    background: var(--green-soft);
    border-color: var(--green);
}

.note--marker {
    background: var(--marker-soft);
    border-color: var(--marker);
}

.note ul {
    margin: 0;
    padding-inline-start: 18px;
}

.validation-summary-valid {
    display: none;
}

.tag {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 1px 10px;
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 500;
    white-space: nowrap;
    vertical-align: middle;
}

    .tag::before {
        content: '';
        width: 6px;
        height: 6px;
        border-radius: 50%;
        background: currentColor;
    }

.tag--green {
    background: var(--green-soft);
    color: var(--green);
}

.tag--red {
    background: var(--margin-soft);
    color: var(--margin);
}

.tag--marker {
    background: var(--marker-soft);
    color: #7A5A00;
}

.tag--muted {
    background: var(--paper);
    color: var(--ink-muted);
}

/* ─────────────── السجل (الجدول) ─────────────── */

.register {
    position: relative;
    background: var(--sheet);
    border: 1px solid var(--rule);
    border-radius: var(--radius);
    overflow: hidden;
}

    /* خط الهامش الأحمر المزدوج */
    .register::before {
        content: '';
        position: absolute;
        inset-block: 0;
        inset-inline-start: calc(var(--margin-line) - 5px);
        width: 4px;
        border-inline: 1px solid var(--margin);
        opacity: .75;
        pointer-events: none;
        z-index: 1;
    }

.register__scroll {
    overflow-x: auto;
}

.register table {
    width: 100%;
    border-collapse: collapse;
}

.register th {
    height: 46px;
    padding: 0 14px;
    text-align: start;
    font-family: var(--font-display);
    font-weight: 500;
    font-size: 0.875rem;
    color: var(--ink-muted);
    border-bottom: 1.5px solid var(--rule-strong);
    white-space: nowrap;
}

.register td {
    height: var(--row);
    padding: 8px 14px;
    border-bottom: 1px solid var(--rule);
    vertical-align: middle;
}

.register tbody tr:last-child td {
    border-bottom: 0;
}

.register tbody tr:not(.register__empty):hover td {
    background: #F7F9FC;
}

.register__no {
    width: var(--margin-line);
    padding: 0 !important;
    text-align: center;
    color: var(--margin);
    font-size: 0.8125rem;
}

.register__actions {
    width: 1%;
    white-space: nowrap;
    text-align: end;
}

.register__empty td {
    height: 150px;
    text-align: center;
    color: var(--ink-muted);
}

.register__foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    padding: 10px 14px;
    padding-inline-start: calc(var(--margin-line) + 14px);
    border-top: 1px solid var(--rule);
    color: var(--ink-muted);
    font-size: 0.85rem;
}

.register__message {
    display: grid;
    justify-items: center;
    gap: 12px;
    padding: 40px 20px;
    color: var(--margin);
}

.pager {
    display: flex;
    gap: 4px;
    align-items: center;
}

.pager__btn {
    min-width: 32px;
    height: 32px;
    padding: 0 6px;
    border: 1px solid transparent;
    border-radius: var(--radius);
    background: transparent;
    color: var(--ink);
    font: inherit;
    font-size: 0.85rem;
    cursor: pointer;
}

    .pager__btn svg {
        width: 16px;
        height: 16px;
        vertical-align: middle;
    }

    .pager__btn:hover:not(:disabled) {
        border-color: var(--rule-strong);
    }

    .pager__btn.is-current {
        background: var(--ink);
        color: #fff;
    }

    .pager__btn:disabled {
        opacity: .35;
        cursor: default;
    }

.pager__gap {
    padding: 0 4px;
}

.sk {
    display: block;
    height: 10px;
    border-radius: 3px;
    background: linear-gradient(90deg, var(--paper), #E2E8F1, var(--paper));
    background-size: 200% 100%;
    animation: shimmer 1.2s ease-in-out infinite;
}

.register__loading td {
    height: var(--row);
}

/* ─────────────── النافذة الجانبية ─────────────── */

.drawer {
    position: fixed;
    inset-block: 0;
    inset-inline-start: auto;
    inset-inline-end: 0;
    width: min(460px, 100vw);
    max-width: 100vw;
    height: 100dvh;
    max-height: 100dvh;
    margin: 0;
    padding: 0;
    border: 0;
    background: var(--sheet);
    color: var(--ink);
    box-shadow: 0 0 0 1px var(--rule), 24px 0 60px rgba(27, 42, 74, .18);
}

    .drawer[open] {
        animation: drawer-in .22s ease-out;
    }

    .drawer::backdrop {
        background: rgba(27, 42, 74, .38);
    }

.drawer__form {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.drawer__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 20px 24px 16px;
    border-bottom: 2px solid var(--ink);
}

    .drawer__head h2 {
        font-size: 1.35rem;
        font-weight: 600;
    }

.drawer__body {
    flex: 1;
    overflow-y: auto;
    padding: 22px 24px;
}

.drawer__foot {
    display: flex;
    gap: 10px;
    padding: 14px 24px;
    border-top: 1px solid var(--rule);
    background: var(--paper);
}

/* ─────────────── اللوحة الرئيسية ─────────────── */

.ledger {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    background: var(--sheet);
    border: 1px solid var(--rule);
    border-radius: var(--radius);
    margin-bottom: 28px;
}

.ledger__cell {
    display: grid;
    gap: 2px;
    padding: 18px 22px;
    border-inline-start: 1px solid var(--rule);
}

    .ledger__cell:first-child {
        border-inline-start: 0;
    }

.ledger__num {
    font-family: var(--font-display);
    font-size: 2.25rem;
    font-weight: 600;
    line-height: 1.1;
}

.ledger__label {
    color: var(--ink-muted);
    font-size: 0.875rem;
}

.split {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 20px;
    align-items: start;
}

.box {
    background: var(--sheet);
    border: 1px solid var(--rule);
    border-radius: var(--radius);
}

.box__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 18px;
    border-bottom: 1.5px solid var(--rule-strong);
}

    .box__head h2 {
        display: inline-flex;
        align-items: center;
        gap: 8px;
        font-size: 1.1rem;
        font-weight: 600;
    }

.box__empty {
    padding: 28px 18px;
    color: var(--ink-muted);
    text-align: center;
}

.roll {
    list-style: none;
    margin: 0;
    padding: 0;
}

    .roll li {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 12px;
        padding: 12px 18px;
        border-bottom: 1px solid var(--rule);
    }

        .roll li:last-child {
            border-bottom: 0;
        }

        .roll li > div {
            display: grid;
            min-width: 0;
        }

        .roll li .muted {
            font-size: 0.85rem;
        }

.roll__meta {
    color: var(--ink-muted);
    font-size: 0.875rem;
    white-space: nowrap;
}

.live-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--margin);
    box-shadow: 0 0 0 0 rgba(200, 53, 43, .5);
    animation: pulse 1.6s ease-out infinite;
}

/* ─────────────── المراحل والصفوف ─────────────── */

.stages {
    display: grid;
    gap: 28px;
}

.stage__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 10px;
}

.stage__title {
    display: flex;
    align-items: baseline;
    gap: 12px;
    flex-wrap: wrap;
}

    .stage__title h2 {
        font-size: 1.35rem;
        font-weight: 600;
    }

.stage__actions {
    display: flex;
    align-items: center;
    gap: 4px;
}

/* ─────────────── شرح الخطوات ─────────────── */

.howto {
    margin-bottom: 20px;
    background: var(--sheet);
    border: 1px solid var(--rule);
    border-radius: var(--radius);
}

    .howto summary {
        padding: 12px 16px;
        cursor: pointer;
        font-weight: 500;
    }

    .howto ol {
        margin: 0;
        padding: 4px 40px 16px 16px;
        padding-inline-start: 40px;
    }

    .howto li {
        padding: 2px 0;
    }

/* ─────────────── صفحات الدخول ─────────────── */

/* ورقة مسطرة بهامش أحمر */
body.auth {
    min-height: 100dvh;
    display: grid;
    place-items: center;
    padding: 24px 16px;
    background-color: var(--paper);
    background-image: linear-gradient(to left, transparent 71px, var(--margin) 71px, var(--margin) 72px, transparent 72px, transparent 75px, var(--margin) 75px, var(--margin) 76px, transparent 76px), repeating-linear-gradient(to bottom, transparent 0 31px, var(--rule) 31px 32px);
}

.auth__sheet {
    width: min(420px, 100%);
    background: var(--sheet);
    border: 1px solid var(--rule);
    border-radius: 10px;
    padding: 34px 32px 28px;
    box-shadow: 0 18px 50px rgba(27, 42, 74, .10);
}

.auth__brand {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 26px;
    font-family: var(--font-display);
    font-size: 1.5rem;
    font-weight: 600;
}

    .auth__brand img {
        border-radius: 10px;
    }

.auth__title {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 6px;
}

.auth__lead {
    color: var(--ink-muted);
    margin-bottom: 22px;
}

.auth__meta {
    color: var(--ink-muted);
    font-size: 0.85rem;
    margin-bottom: 18px;
}

.auth__back {
    display: inline-block;
    margin-top: 18px;
}

.auth__sheet form + form .btn--block,
.auth__sheet .btn--block + .btn--block {
    margin-top: 10px;
}

/* ─────────────── SweetAlert بالعربي ─────────────── */

.swal2-popup {
    direction: rtl;
    font-family: var(--font-body) !important;
}

.swal2-title {
    font-family: var(--font-display) !important;
}

.swal2-confirm {
    background: var(--ink) !important;
}

/* ─────────────── الحركة ─────────────── */

@keyframes drawer-in {
    from {
        transform: translateX(-28px);
        opacity: 0;
    }
}

@keyframes shimmer {
    to {
        background-position: -200% 0;
    }
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

@keyframes pulse {
    70% {
        box-shadow: 0 0 0 8px rgba(200, 53, 43, 0);
    }

    100% {
        box-shadow: 0 0 0 0 rgba(200, 53, 43, 0);
    }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation: none !important;
        transition: none !important;
    }
}

/* ─────────────── الشاشات الصغيرة ─────────────── */

@media (max-width: 960px) {
    .panel {
        grid-template-columns: minmax(0, 1fr);
    }

    .side {
        position: fixed;
        inset-block: 0;
        inset-inline-start: 0;
        width: min(290px, 86vw);
        transform: translateX(100%);
        transition: transform .22s ease-out;
        padding-inline-end: 0;
    }

        .side.is-open {
            transform: none;
        }

    .side-open .side-scrim {
        display: block;
        position: fixed;
        inset: 0;
        background: rgba(27, 42, 74, .38);
        z-index: 25;
    }

    .main {
        padding: 14px 16px 48px;
    }

    .top {
        margin-bottom: 10px;
    }

    .top__menu {
        display: inline-grid;
    }

    .page-head h1 {
        font-size: 1.6rem;
    }

    .f-row {
        grid-template-columns: 1fr;
    }

    [data-hide-sm] {
        display: none;
    }

    .ledger__cell:nth-child(odd) {
        border-inline-start: 0;
    }

    .ledger__cell:nth-child(n+3) {
        border-top: 1px solid var(--rule);
    }
}
