/* ===========================================================================
   app.css - Custom styles for the Gold Survey application
   Tailwind (CDN) provides the utility layer; this file holds everything that
   is awkward as utilities: RTL typography, the Likert matrix, wizard motion,
   admin components and all @media print rules.
   =========================================================================== */

/* --------------------------------------------------------------------------
   1) TYPOGRAPHY / DIRECTION
   ----------------------------------------------------------------------- */
html { scroll-behavior: smooth; }

body[dir="rtl"],
[dir="rtl"] body { font-family: "Noto Sans Arabic", Vazirmatn, system-ui, sans-serif; }

[dir="rtl"] .font-sans { font-family: "Noto Sans Arabic", Vazirmatn, system-ui, sans-serif; }

/* Keep Latin variable codes (EU1, GPI3…) readable inside RTL text. */
code, .code, .num { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; direction: ltr; unicode-bidi: isolate; }

::selection { background: #F7C24D; color: #122641; }

/* --------------------------------------------------------------------------
   2) WIZARD / STEP ANIMATION
   ----------------------------------------------------------------------- */
.step-enter { animation: stepIn .28s cubic-bezier(.22,.9,.3,1) both; }
@keyframes stepIn {
    from { opacity: 0; transform: translateY(10px); }
    to   { opacity: 1; transform: none; }
}

.progress-bar { transition: width .45s cubic-bezier(.22,.9,.3,1); }

/* --------------------------------------------------------------------------
   3) LIKERT MATRIX (card based, mobile-first)
   ----------------------------------------------------------------------- */
.likert-row {
    border-radius: 1rem;
    border: 1px solid #e2e8f0;
    background: #fff;
    box-shadow: 0 1px 2px rgba(15, 23, 42, .05);
    padding: 1rem;
}
.dark .likert-row { border-color: #1f4068; background: #0D1C31; }
@media (min-width: 640px) { .likert-row { padding: 1.25rem; } }
.likert-row.is-invalid { border-color: #ef4444; box-shadow: 0 0 0 3px rgba(239,68,68,.15); }
.likert-row.is-answered { border-color: #F7C24D; }

.likert-opts {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: .5rem;
    margin-top: .75rem;
}

.likert-opt { position: relative; }
.likert-opt input {
    position: absolute; inset: 0; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer;
}
.likert-opt span.pill {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    min-height: 46px; border-radius: .75rem;
    border: 1px solid #cbd5e1;
    background: #f8fafc;
    color: #334155;
    font-weight: 700; font-size: .95rem;
    transition: transform .12s ease, background .15s ease, border-color .15s ease, box-shadow .15s ease;
}
[dir="rtl"] .likert-opt span.pill { font-weight: 600; }
.dark .likert-opt span.pill { background: #0D1C31; border-color:#1f4068; color:#cbd5e1; }

.likert-opt span.pill small {
    display: none; font-size: .58rem; font-weight: 600; line-height: 1.15; text-align: center;
    margin-top: .15rem; color: #64748b; padding: 0 .15rem;
}
.dark .likert-opt span.pill small { color:#94a3b8; }

.likert-opt:hover span.pill { border-color: #EFAE23; transform: translateY(-2px); }
.likert-opt input:focus-visible + span.pill { outline: 3px solid #F7C24D; outline-offset: 2px; }

.likert-opt input:checked + span.pill {
    background: linear-gradient(180deg,#F7C24D,#D99412);
    border-color: #B45309;
    color: #1f1300;
    box-shadow: 0 6px 16px -6px rgba(180,83,9,.65);
    transform: translateY(-2px);
}
.likert-opt input:checked + span.pill small { color: #4a2107; }

@media (min-width: 640px) {
    .likert-opt span.pill small { display: block; }
}

/* Section header rows that mimic the questionnaire tables */
.likert-col-heads {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: .5rem;
}
.likert-col-heads span {
    text-align: center; font-size: .68rem; font-weight: 700; letter-spacing: .04em;
    text-transform: uppercase; color: #64748b;
}
.dark .likert-col-heads span { color:#94a3b8; }

/* --------------------------------------------------------------------------
   4) OPTION CARDS (demographics / consent)
   ----------------------------------------------------------------------- */
.opt-card { position: relative; }
.opt-card input { position: absolute; inset: 0; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.opt-card span.box {
    display: flex; align-items: flex-start; gap: .65rem;
    padding: .8rem .9rem; border-radius: .9rem;
    border: 1px solid #cbd5e1; background: #f8fafc; color: #1e293b;
    font-size: .9rem; font-weight: 600; line-height: 1.45;
    transition: all .15s ease; height: 100%;
}
.dark .opt-card span.box { background:#0D1C31; border-color:#1f4068; color:#e2e8f0; }
.opt-card span.box::before {
    content: ""; flex: 0 0 auto; width: 18px; height: 18px; margin-top: 2px;
    border-radius: 999px; border: 2px solid #94a3b8; background: #fff;
}
.dark .opt-card span.box::before { background:#08131F; }
.opt-card:hover span.box { border-color: #EFAE23; background: #FEF7E7; }
.dark .opt-card:hover span.box { background:#122641; }
.opt-card input:focus-visible + span.box { outline: 3px solid #F7C24D; outline-offset: 2px; }
.opt-card input:checked + span.box {
    border-color: #B45309;
    background: linear-gradient(180deg,#FEF7E7,#FDEBC2);
    color: #4A2107;
    box-shadow: 0 6px 18px -10px rgba(180,83,9,.7);
}
.dark .opt-card input:checked + span.box { background:#122641; color:#FBD98A; border-color:#D99412; }
.opt-card input:checked + span.box::before {
    border-color: #B45309; border-width: 5px; background: #fff;
}
.dark .opt-card input:checked + span.box::before { background:#FBD98A; border-color:#D99412; }

.opt-card.is-stop span.box::after {
    content: attr(data-stop-note);
    display: block; font-size: .68rem; color: #b91c1c; font-weight: 700; margin-inline-start: auto;
}
.dark .opt-card.is-stop span.box::after { color:#fca5a5; }

/* --------------------------------------------------------------------------
   5) SHARED UI PIECES
   ----------------------------------------------------------------------- */
.card {
    border-radius: 1rem;
    border: 1px solid #e2e8f0;
    background: #fff;
    box-shadow: 0 1px 2px rgba(15, 23, 42, .05);
}
.dark .card { border-color: #1f4068; background: #0D1C31; }

.badge {
    display: inline-flex; align-items: center; gap: .25rem;
    border-radius: 9999px; padding: .125rem .625rem;
    font-size: 11px; font-weight: 700; line-height: 1.4;
}

.stat-card {
    position: relative; overflow: hidden;
    padding: 1.25rem;
    border-radius: 1rem;
    border: 1px solid #e2e8f0;
    background: #fff;
    box-shadow: 0 1px 2px rgba(15, 23, 42, .05);
}
.dark .stat-card { border-color: #1f4068; background: #0D1C31; }

.stat-card::after {
    content:""; position:absolute; inset-inline-end:-30px; top:-30px; width:110px; height:110px;
    border-radius:999px; background: radial-gradient(circle, rgba(247,194,77,.28), transparent 65%);
}

.shake { animation: shake .35s ease; }
@keyframes shake {
    0%,100% { transform: translateX(0); }
    25% { transform: translateX(-6px); }
    75% { transform: translateX(6px); }
}

/* Data table */
.data-table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: .875rem; }
.data-table thead th {
    position: sticky; top: 0; z-index: 1;
    background: #1F3A5F; color: #fff; text-align: start;
    padding: .7rem .75rem; font-size: .72rem; text-transform: uppercase; letter-spacing: .05em;
    white-space: nowrap;
}
.data-table tbody td { padding: .65rem .75rem; border-bottom: 1px solid #e2e8f0; vertical-align: middle; }
.dark .data-table tbody td { border-color:#1f4068; }
.data-table tbody tr:hover { background: #FEF7E7; }
.dark .data-table tbody tr:hover { background:#122641; }
.data-table tfoot td { padding:.65rem .75rem; font-size:.78rem; color:#64748b; }

.sortable { cursor: pointer; user-select: none; }
.sortable i { opacity: .5; margin-inline-start: .25rem; }

/* Modal */
.modal-backdrop { background: rgba(8,19,31,.62); backdrop-filter: blur(3px); }

/* --------------------------------------------------------------------------
   6) PRINT STYLES  (@media print)
   ----------------------------------------------------------------------- */
@media print {
    @page { margin: 14mm 12mm; size: auto; }

    html, body { background: #fff !important; color: #000 !important; font-size: 11.5pt; }
    body[dir="rtl"], [dir="rtl"] body { font-family: "Noto Sans Arabic", serif; }

    .no-print, header.navbar, aside, nav, .btn, button, .modal-backdrop,
    [data-theme-toggle], [data-lang-btn], .skip-link, .print-hide { display: none !important; }

    .print-only { display: block !important; }

    .card, .stat-card, .likert-row {
        border: 1px solid #999 !important; box-shadow: none !important;
        background: #fff !important; break-inside: avoid; page-break-inside: avoid;
    }

    .print-sheet { max-width: none !important; padding: 0 !important; margin: 0 !important; }

    .data-table thead th { background: #1F3A5F !important; color: #fff !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
    .data-table tbody td { border-color: #bbb !important; }
    .data-table tbody tr:nth-child(even) { background: #f3f4f6 !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }

    a { text-decoration: none; color: #000 !important; }
    h1, h2, h3 { page-break-after: avoid; }
    table { page-break-inside: auto; }
    tr { page-break-inside: avoid; }

    .print-header { display: flex !important; justify-content: space-between; align-items: center;
        border-bottom: 2px solid #1F3A5F; padding-bottom: 8px; margin-bottom: 14px; }
    .print-footer { display: block !important; margin-top: 18px; padding-top: 8px;
        border-top: 1px solid #999; font-size: 9pt; color: #444; text-align: center; }
}

.print-only { display: none; }
.print-header, .print-footer { display: none; }
