/* ===== نظام التعميد — Emerald Dossier ===== */

@font-face {
    font-family: "Thmanyah Sans";
    src: url("assets/fonts/sans/thmanyahsans-Regular.woff2") format("woff2");
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: "Thmanyah Sans";
    src: url("assets/fonts/sans/thmanyahsans-Bold.woff2") format("woff2");
    font-weight: 700;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: "Thmanyah Sans";
    src: url("assets/fonts/sans/thmanyahsans-Black.woff2") format("woff2");
    font-weight: 900;
    font-style: normal;
    font-display: swap;
}

:root {
    color-scheme: dark;
    --bg: #0a0c0b;
    --surface: #111514;
    --surface-2: #171d1b;
    --line: #26302c;
    --line-strong: #35443e;
    --accent: #45d69a;
    --accent-ink: #06231a;
    --accent-dim: rgba(69, 214, 154, 0.14);
    --text: #e9edeb;
    --muted: #9aa8a2;
    --faint: #6b7772;
    --danger: #ef6a62;
    --danger-dim: rgba(239, 106, 98, 0.12);
    --mono: "Cascadia Mono", ui-monospace, "Courier New", monospace;
    --r: 10px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    background: var(--bg);
    color: var(--text);
    font-family: "Thmanyah Sans", "Segoe UI", Tahoma, Arial, sans-serif;
    font-size: 16px;
    line-height: 1.7;
}

.app {
    width: min(1200px, 100vw - 32px);
    margin: 0 auto;
    padding: 24px 0 40px;
}

/* ===== الشريط العلوي ===== */
.topbar {
    position: sticky;
    top: 0;
    z-index: 50;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r);
    padding: 14px 18px;
    box-shadow: 0 10px 24px rgba(0, 0, 0, 0.35);
    margin-bottom: 20px;
}
.topbar-brand { display: flex; align-items: center; gap: 14px; }
.topbar-logo { width: 54px; height: 54px; object-fit: contain; }
.topbar h1 { font-size: 22px; font-weight: 900; line-height: 1.3; }
.topbar-sub { font-size: 13px; color: var(--muted); }
.topbar-meta {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 6px;
}
.meta-pill {
    display: inline-block;
    border: 1px solid var(--accent);
    background: var(--accent-dim);
    color: var(--accent);
    font-size: 12px;
    font-weight: 700;
    border-radius: 4px;
    padding: 2px 10px;
}
.meta-code {
    font-family: var(--mono);
    font-size: 11px;
    color: var(--faint);
    letter-spacing: 2px;
}

/* ===== التخطيط ===== */
.layout {
    display: grid;
    grid-template-columns: 264px 1fr;
    gap: 20px;
    align-items: start;
}
.rail {
    position: sticky;
    top: calc(var(--topbar-h, 88px) + 14px);
    display: grid;
    gap: 14px;
}

/* ===== الخطوات ===== */
.stepper {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r);
    overflow: hidden;
    display: grid;
}
.step {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    text-align: start;
    background: transparent;
    border: 0;
    border-bottom: 1px solid var(--line);
    padding: 12px 14px;
    font-family: inherit;
    color: var(--text);
    cursor: pointer;
}
.step:last-child { border-bottom: 0; }
.step-num {
    flex: 0 0 auto;
    width: 26px;
    height: 26px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-family: var(--mono);
    font-size: 13px;
    border: 1px solid var(--line-strong);
    border-radius: 4px;
    color: var(--muted);
}
.step-body { display: grid; line-height: 1.4; }
.step-body b { font-size: 14px; font-weight: 700; }
.step-status { font-style: normal; font-size: 12px; color: var(--faint); }
.step.is-current {
    background: var(--surface-2);
    box-shadow: inset 3px 0 0 var(--accent);
}
.step.is-current .step-num { border-color: var(--accent); color: var(--accent); }
.step.is-done .step-num {
    background: var(--accent);
    border-color: var(--accent);
    color: var(--accent-ink);
}

/* ===== كتل الشريط الجانبي ===== */
.rail-block {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r);
    padding: 14px 16px;
    display: grid;
    gap: 8px;
    justify-items: start;
}
.rail-block h3 {
    font-size: 12px;
    font-weight: 900;
    color: var(--faint);
    letter-spacing: 0.5px;
}
.rail-note { font-size: 12px; color: var(--muted); }
.rail-hint { font-size: 12px; color: var(--faint); }
.rail-stat {
    font-size: 18px;
    font-weight: 900;
    color: var(--accent);
    font-family: var(--mono);
}
.checklist { list-style: none; display: grid; gap: 4px; }
.checklist li {
    font-size: 13px;
    color: var(--muted);
    padding-inline-start: 20px;
    position: relative;
}
.checklist li::before {
    content: "✓";
    position: absolute;
    inset-inline-start: 0;
    color: var(--accent);
    font-weight: 900;
}

/* ===== اللوحات ===== */
.content { min-width: 0; }
.panel {
    display: none;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r);
    padding: 20px;
}
.panel.is-open { display: block; }
.panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding-bottom: 14px;
    margin-bottom: 18px;
    border-bottom: 1px dashed var(--line-strong);
}
.panel-head h2 { font-size: 20px; font-weight: 900; }
.panel-tag {
    background: var(--surface-2);
    border: 1px solid var(--line-strong);
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
    border-radius: 4px;
    padding: 2px 10px;
    white-space: nowrap;
}
.panel-foot {
    display: flex;
    justify-content: center;
    gap: 12px;
    padding-top: 16px;
    margin-top: 18px;
    border-top: 1px dashed var(--line-strong);
}
.panel-foot.split { justify-content: space-between; }
.panel-foot.center { justify-content: center; }

/* ===== الأزرار ===== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 42px;
    padding: 0 18px;
    border-radius: 6px;
    font-family: inherit;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    border: 1px solid transparent;
    background: transparent;
    color: var(--text);
    text-decoration: none;
    transition: border-color 0.15s ease, color 0.15s ease, filter 0.15s ease;
}
.btn-solid { background: var(--accent); color: var(--accent-ink); }
.btn-solid:hover { filter: brightness(1.1); }
.btn-ghost { border-color: var(--line-strong); }
.btn-ghost:hover { border-color: var(--accent); color: var(--accent); }
.btn-small { min-height: 34px; font-size: 13px; padding: 0 14px; }

/* ===== الحقول ===== */
.fields {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}
.field { display: grid; gap: 5px; align-content: start; }
.field label { font-size: 13px; font-weight: 700; color: var(--muted); }
.field .optional { font-weight: 400; color: var(--faint); }
.field small { font-size: 12px; color: var(--faint); }
.field input,
.field select,
.field textarea {
    width: 100%;
    min-height: 42px;
    background: var(--bg);
    border: 1px solid var(--line-strong);
    border-radius: 6px;
    color: var(--text);
    font-family: inherit;
    font-size: 14px;
    padding: 8px 12px;
}
.field input:focus,
.field select:focus,
.field textarea:focus {
    outline: none;
    border-color: var(--accent);
}
.field input[readonly] {
    background: var(--surface-2);
    color: var(--accent);
    font-weight: 700;
    font-family: var(--mono);
}
.field input::placeholder { color: var(--faint); }
.field small.is-selected { color: var(--accent); font-weight: 700; }

/* حقل البحث بقائمة نتائج */
.search-wrap { position: relative; }
.search-results {
    position: absolute;
    top: calc(100% + 4px);
    inset-inline: 0;
    z-index: 60;
    background: var(--surface);
    border: 1px solid var(--line-strong);
    border-radius: 6px;
    overflow: hidden auto;
    max-height: 280px;
    box-shadow: 0 14px 28px rgba(0, 0, 0, 0.45);
}
.search-row {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    text-align: start;
    background: transparent;
    border: 0;
    border-bottom: 1px solid var(--line);
    padding: 9px 12px;
    font-family: inherit;
    font-size: 13px;
    color: var(--text);
    cursor: pointer;
}
.search-row:last-child { border-bottom: 0; }
.search-row:hover { background: var(--surface-2); }
.sr-callsign {
    font-family: var(--mono);
    font-size: 12px;
    font-weight: 700;
    color: var(--accent);
    direction: ltr;
    white-space: nowrap;
}
.sr-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    direction: ltr;
    text-align: start;
}
.sr-rank {
    font-size: 11px;
    color: var(--muted);
    background: var(--surface-2);
    border: 1px solid var(--line-strong);
    border-radius: 4px;
    padding: 0 8px;
    white-space: nowrap;
}
.search-empty {
    padding: 10px 12px;
    font-size: 12px;
    color: var(--faint);
}

/* صندوق تأكيد الحضور */
.confirm-box {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 18px;
    background: var(--surface-2);
    border: 1px solid var(--line-strong);
    border-radius: 6px;
    padding: 14px 16px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 700;
}
.confirm-box:has(input:checked) {
    border-color: var(--accent);
    background: var(--accent-dim);
}
.confirm-box input {
    appearance: none;
    flex: 0 0 auto;
    width: 20px;
    height: 20px;
    border: 1px solid var(--line-strong);
    border-radius: 4px;
    background: var(--bg);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.confirm-box input:checked {
    background: var(--accent);
    border-color: var(--accent);
}
.confirm-box input:checked::after {
    content: "✓";
    color: var(--accent-ink);
    font-size: 14px;
    font-weight: 900;
    line-height: 1;
}

/* ===== أسئلة الاختبار ===== */
.quiz-note {
    font-size: 13px;
    font-weight: 700;
    color: var(--muted);
    margin-bottom: 14px;
}
.info-panel {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    background: var(--surface-2);
    border: 1px solid var(--line-strong);
    border-radius: 6px;
    padding: 12px 16px;
    margin: 14px 0;
}
.info-panel b { font-size: 14px; display: block; }
.info-panel span { font-size: 12px; color: var(--muted); }
.info-panel .btn { flex: 0 0 auto; }

.q {
    border: 1px solid var(--line);
    border-radius: 6px;
    overflow: hidden;
    margin-bottom: 10px;
}
.q-head {
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--surface-2);
    border-bottom: 1px solid var(--line);
    padding: 10px 14px;
}
.q-num {
    font-family: var(--mono);
    font-size: 14px;
    font-weight: 700;
    color: var(--accent);
}
.q-head b { font-size: 15px; font-weight: 700; }
.q-opt {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    color: var(--muted);
    cursor: pointer;
    font-size: 14px;
}
.q-opt:hover { background: var(--surface-2); }
.q-opt input {
    appearance: none;
    flex: 0 0 auto;
    width: 18px;
    height: 18px;
    border: 1px solid var(--line-strong);
    border-radius: 4px;
    background: var(--bg);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.q-opt input:checked { background: var(--accent); border-color: var(--accent); }
.q-opt input:checked::after {
    content: "✓";
    color: var(--accent-ink);
    font-size: 12px;
    font-weight: 900;
    line-height: 1;
}
.q-opt:has(input:checked) { background: var(--accent-dim); color: var(--text); }
.q.is-locked { opacity: 0.45; }
.q.is-locked .q-opt { cursor: not-allowed; }
.q.is-locked .q-opt:hover { background: transparent; }

.notes-block {
    background: var(--surface-2);
    border: 1px solid var(--line-strong);
    border-radius: 6px;
    padding: 14px 16px;
    margin-top: 14px;
    display: grid;
    gap: 8px;
}
.notes-block h3 { font-size: 13px; font-weight: 900; color: var(--muted); }

/* ===== المخرجات ===== */
.output-block {
    display: grid;
    gap: 10px;
    justify-items: start;
    margin-bottom: 18px;
}
.output-block h3 { font-size: 16px; font-weight: 900; }
.output {
    width: 100%;
    background: var(--bg);
    border: 1px solid var(--line-strong);
    border-radius: 6px;
    color: var(--text);
    font-family: var(--mono);
    font-size: 13px;
    line-height: 1.6;
    padding: 12px;
    min-height: 150px;
    resize: vertical;
}
.output:focus { outline: none; border-color: var(--accent); }
.output-tall { min-height: 260px; }

/* ===== صناديق الرفع ===== */
.duo {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}
.duo-cell {
    background: var(--surface-2);
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 16px;
    display: grid;
    gap: 8px;
    align-content: start;
}
.duo-cell h3 { font-size: 16px; font-weight: 900; }
.duo-note { font-size: 13px; color: var(--faint); }
.unit-code {
    color: var(--accent);
    font-family: var(--mono);
    font-size: 15px;
}
.dropzone {
    position: relative;
    min-height: 260px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px dashed var(--line-strong);
    border-radius: 6px;
    background: var(--bg);
    padding: 10px;
    transition: border-color 0.15s ease;
}
.dropzone:hover { border-color: var(--accent); }
.dropzone.locked { opacity: 0.55; cursor: not-allowed; }
.dropzone.locked:hover { border-color: var(--line-strong); }
.drop-hint { font-size: 13px; color: var(--faint); }
.dropzone img {
    max-width: 100%;
    max-height: 380px;
    object-fit: contain;
}
.dropzone input[type="file"] {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
}
.dropzone input[type="file"]:disabled { cursor: not-allowed; }
.lock-hint { font-size: 12px; color: var(--faint); margin-top: 8px; }

/* ===== تلميح اللصق ===== */
.paste-hint {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 20px;
    font-size: 12px;
    color: var(--faint);
}
.paste-hint kbd {
    background: var(--surface-2);
    border: 1px solid var(--line-strong);
    border-radius: 4px;
    padding: 1px 7px;
    font-family: var(--mono);
    font-size: 11px;
    color: var(--muted);
}

/* ===== معاينة البطاقة ===== */
.card-preview {
    width: 100%;
    background: var(--bg);
    border: 1px solid var(--line-strong);
    border-radius: 6px;
    padding: 10px;
    display: flex;
    justify-content: center;
}
.card-preview img { max-width: 100%; max-height: 640px; object-fit: contain; }

/* ===== الأخطاء ===== */
.errors {
    background: var(--danger-dim);
    border: 1px solid var(--danger);
    color: var(--danger);
    font-size: 13px;
    border-radius: 6px;
    padding: 12px 16px;
    margin-top: 16px;
}

/* ===== شريط الاحتياط ===== */
.fallback[hidden] { display: none; }
.fallback {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    background: var(--surface-2);
    border: 1px solid var(--line-strong);
    border-radius: 6px;
    padding: 10px 14px;
    margin-top: 16px;
    font-size: 13px;
    color: var(--muted);
}

/* ===== التوست ===== */
.toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translate(-50%, 12px);
    background: var(--accent);
    color: var(--accent-ink);
    font-size: 14px;
    font-weight: 700;
    border-radius: 6px;
    padding: 10px 22px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease, transform 0.2s ease;
    z-index: 90;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ===== الفوتر ===== */
.footer {
    border-top: 1px solid var(--line);
    margin-top: 28px;
    padding-top: 16px;
}
.credit { font-size: 13px; color: var(--faint); text-align: center; }
.credit b { color: var(--accent); font-weight: 700; }

/* ===== الاستجابة ===== */
@media (max-width: 920px) {
    .layout { grid-template-columns: 1fr; }
    .rail { position: static; }
    .stepper { grid-template-columns: repeat(4, 1fr); }
    .step {
        flex-direction: column;
        gap: 6px;
        text-align: center;
        border-bottom: 0;
        border-inline-end: 1px solid var(--line);
        padding: 10px 6px;
    }
    .step:last-child { border-inline-end: 0; }
    .step-status { display: none; }
    .step.is-current { box-shadow: inset 0 -3px 0 var(--accent); }
    .fields, .duo { grid-template-columns: 1fr; }
}

@media (max-width: 560px) {
    .topbar {
        position: static;
        flex-direction: column;
        align-items: flex-start;
    }
    .topbar-meta { align-items: flex-start; }
    .step-body b { font-size: 12px; }
}

@media (prefers-reduced-motion: reduce) {
    * { transition: none !important; animation: none !important; }
}
