/* ============================================================
   BTU Result Lookup — Main Stylesheet
   Covers: design tokens, layout, search card, guide card,
           status bar, result card, result tables, modal,
           responsive breakpoints, and print rules.
   ============================================================ */

/* ── Design Tokens ── */
:root {
    --primary:        #4f7cff;
    --primary-dark:   #3563e9;
    --primary-light:  #eef3ff;
    --primary-border: #c7d7fd;
    --success:        #16a34a;
    --success-bg:     #f0fdf4;
    --error:          #dc2626;
    --error-bg:       #fff1f2;
    --bg:             #f4f6fb;
    --surface:        #ffffff;
    --surface2:       #f8faff;
    --border:         #e2e8f0;
    --text-primary:   #0f172a;
    --text-secondary: #475569;
    --text-muted:     #94a3b8;
    --shadow-sm: 0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
    --shadow-md: 0 4px 16px rgba(0,0,0,.08), 0 2px 6px rgba(0,0,0,.05);
    --shadow-lg: 0 20px 60px rgba(0,0,0,.12), 0 8px 24px rgba(0,0,0,.08);
    --radius:    12px;
    --radius-sm:  8px;
    --radius-xs:  6px;
    --font: 'Inter', 'Poppins', Arial, sans-serif;
}

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; }

body {
    font-family: var(--font);
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--text-primary);
    min-height: 100vh;
}

/* ── Page Header ── */
.page-header {
    background: linear-gradient(135deg, #1e3a8a 0%, #2563eb 50%, #1d4ed8 100%);
    padding: 20px 16px 28px;
    text-align: center;
    position: relative;
    overflow: hidden;
}

.page-header::before {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(ellipse at 70% 50%, rgba(99,179,237,.18) 0%, transparent 70%);
    pointer-events: none;
}

.page-header-inner {
    position: relative;
    z-index: 1;
    max-width: 780px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
}

.page-header-icon {
    width: 44px;
    height: 44px;
    background: rgba(255,255,255,.15);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    backdrop-filter: blur(8px);
}

.page-header-icon svg { color: #fff; }

.page-header-text { text-align: left; }

.page-header h1 {
    margin: 0;
    color: #fff;
    font-size: clamp(18px, 4vw, 24px);
    font-weight: 700;
    letter-spacing: -.3px;
    line-height: 1.2;
}

.page-header p {
    margin: 3px 0 0;
    color: rgb(255 154 93);
    font-size: 13px;
    text-shadow: 2px 2px 4px rgb(10 0 157);
}

/* ── Page Body ── */
.page-body {
    max-width: 820px;
    margin: 0 auto;
    padding: 24px 16px 40px;
}

/* ── Search Card ── */
.search-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    padding: 20px;
    margin-bottom: 20px;
}

.search-card-title {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 16px;
}

.search-card-title span {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
}

.search-card-title svg { color: var(--primary); flex-shrink: 0; }

.search-row { display: flex; gap: 10px; flex-wrap: wrap; }

.search-input-wrap {
    flex: 1 1 220px;
    position: relative;
    min-width: 0;
}

.search-input-wrap svg.input-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    pointer-events: none;
}

.search-input {
    width: 100%;
    padding: 10px 12px 10px 38px;
    font-size: 14px;
    font-family: var(--font);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface2);
    color: var(--text-primary);
    text-transform: uppercase;
    outline: none;
    transition: border-color .2s, box-shadow .2s;
}

.search-input::placeholder { text-transform: none; color: var(--text-muted); }

.search-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79,124,255,.12);
    background: #fff;
}

/* ── Buttons ── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 10px 18px;
    font-size: 13.5px;
    font-family: var(--font);
    font-weight: 600;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background .18s, box-shadow .18s, opacity .18s, transform .1s;
    white-space: nowrap;
    text-decoration: none;
}

.btn:active { transform: scale(.97); }
.btn svg { flex-shrink: 0; }

.btn-primary {
    background: var(--primary);
    color: #fff;
    box-shadow: 0 2px 8px rgba(79,124,255,.3);
}
.btn-primary:hover { background: var(--primary-dark); box-shadow: 0 4px 14px rgba(79,124,255,.4); }
.btn-primary:disabled { opacity: .55; cursor: not-allowed; box-shadow: none; }

.btn-outline {
    background: #fff;
    color: var(--primary);
    border: 1.5px solid var(--primary-border);
}
.btn-outline:hover { background: var(--primary-light); }
.btn-outline:disabled { cursor: wait; opacity: .6; }

.btn-ghost {
    background: var(--surface2);
    color: var(--text-secondary);
    border: 1.5px solid var(--border);
}
.btn-ghost:hover { background: #edf0f7; }

.search-actions {
    margin-top: 12px;
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    align-items: center;
}

.print-all-btn-wrap { margin-left: auto; }

/* ── Guide Card ── */
.guide-card {
    background: var(--primary-light);
    border: 1px solid var(--primary-border);
    border-left: 4px solid var(--primary);
    border-radius: var(--radius);
    padding: 18px 20px;
    margin-bottom: 20px;
}

.guide-card-title {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
}
.guide-card-title svg { color: var(--primary); flex-shrink: 0; }
.guide-card-title h2 { margin: 0; font-size: 14px; font-weight: 700; color: #1d4ed8; }

.guide-card p { margin: 0 0 12px; font-size: 13px; line-height: 1.7; color: #1e3a5f; }
.guide-card ol { margin: 0; padding-left: 20px; }
.guide-card li { font-size: 13px; line-height: 1.7; color: #1e3a5f; margin-bottom: 6px; }
.guide-card .guide-hi { color: #475569; }

.guide-note {
    margin-top: 12px;
    padding: 10px 14px;
    background: rgba(255,255,255,.6);
    border-radius: var(--radius-xs);
    font-size: 12px;
    color: #475569;
}

code.tag {
    background: var(--primary);
    color: #fff;
    border-radius: 4px;
    padding: 1px 6px;
    font-size: 12px;
}

code.tag-outline {
    color: var(--primary);
    border: 1px solid var(--primary-border);
    border-radius: 4px;
    padding: 1px 5px;
    font-size: 12px;
}

/* ── Status Bar ── */
.status-bar {
    display: none;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 500;
    margin-bottom: 18px;
    animation: fadeSlideIn .25s ease;
}
.status-bar.visible { display: flex; }
.status-bar svg { flex-shrink: 0; }
.status-bar.loading { background: #eff6ff; color: #1d4ed8; border: 1px solid #bfdbfe; }
.status-bar.success { background: var(--success-bg); color: var(--success); border: 1px solid #bbf7d0; }
.status-bar.error   { background: var(--error-bg);   color: var(--error);   border: 1px solid #fecaca; }

@keyframes fadeSlideIn {
    from { opacity: 0; transform: translateY(-6px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ── Result Card ── */
.result-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    margin-bottom: 24px;
    overflow: hidden;
}

.result-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: var(--surface2);
    border-bottom: 1px solid var(--border);
    flex-wrap: wrap;
    gap: 8px;
}

.result-meta {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: var(--text-secondary);
    flex-wrap: wrap;
}

.meta-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: var(--primary-light);
    color: var(--primary-dark);
    border: 1px solid var(--primary-border);
    border-radius: 20px;
    padding: 3px 10px;
    font-size: 12px;
    font-weight: 600;
}
.meta-badge svg { width: 12px; height: 12px; }

/* ── Result Sheet Wrapper (mobile scroll) ── */
.result-sheet-wrap {
    padding: 10px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* ── Result Tables (original layout preserved) ── */
table.result_tb,
table.result-frame {
    border: 1px solid #a0aec0;
    border-collapse: collapse;
    outline: rgba(68,68,68,.6) solid 1px;
    outline-offset: 2px;
}

table.result_tb td {
    border: 1px solid #a0aec0;
    padding: 5px;
    font-family: Arial, sans-serif;
}

.text-center { text-align: center; }
.text-start  { text-align: left; }

.semester-cell        { width: 10%; font-size: 12px; padding: 10px; }
.semester-cell-head   { width: 10%; font-size: 12px; padding: 10px; font-weight: bold; }
.semester-label       { width: 20%; font-size: 12px; padding: 10px; }
.subject-row, .subject-header-row, .subject-total-row { height: 20px; }
.subject-name-cell    { font-size: small; width: 30%; background-color: white; padding: 4px; }
.subject-cell         { font-size: small; text-align: center; background-color: white; }
.subject-end-max,
.subject-end-obt,
.subject-internal-max,
.subject-internal-obt,
.subject-total-max,
.subject-total-obt    { width: 8%; }
.subject-grade        { width: 7%; }
.subject-points,
.subject-credit,
.subject-credit-points { width: 5%; }
.subject-total-label  { font-size: 16px; text-align: right; width: 50%; background-color: white; }
.subject-total-cell   { font-size: small; width: 5%; text-align: center; background-color: white; }
.result-logo-spacer   { width: 10%; }
.result-logo-cell     { width: 80%; padding-left: 50px; }
.result-logo          { height: 70px; width: 480px; }
.result-content       { font-family: Arial, sans-serif; display: flex; flex-direction: column; align-items: center; padding: 0 10px; }
.result-header-table  { width: 100%; padding-left: 5px; border-collapse: collapse; border-color: #E3DDD5; }
.result-header-row    { height: 24px; }
.result-title         { text-align: center; font-size: small; font-weight: bold; }
.result-title span    { font-size: 15px; font-weight: bold; }
.student-info-cell    { width: 50%; font-size: 12px; font-weight: bold; }
.student-college-cell { font-size: 12px; font-weight: bold; }
.subject-table        { width: 100%; margin-left: 5px; margin-right: 5px; border-collapse: collapse; }
.result-summary       { width: 100%; border-top: 1px solid gray; margin-bottom: 5px; }
.result-label-cell    { width: 30%; font-size: 12px; padding: 10px; text-align: right; font-weight: bold; }
.result-value-cell    { width: 60%; font-size: 12px; padding: 10px; font-weight: bold; }
.semester-heading-cell    { width: 20%; font-size: 12px; padding: 10px; text-align: left; font-weight: bold; }
.previous-appearance-label { width: 35%; font-size: 12px; padding: 10px; }
.previous-appearance-cell  { width: 10%; font-size: 12px; padding: 10px; }
.declaration-cell,
.instruction-cell     { width: 50%; font-size: 12px; padding: 10px; font-weight: bold; }

/* individual print btn override */
.individual-print { padding: 7px 14px; font-size: 12px; }

/* ── Edge Modal ── */
.edge-modal {
    position: fixed;
    inset: 0;
    z-index: 2000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: rgba(15,23,42,.6);
    backdrop-filter: blur(4px);
}
.edge-modal.is-visible { display: flex; }

.edge-modal-card {
    width: min(380px, 100%);
    padding: 28px 24px;
    border-radius: 16px;
    background: #fff;
    box-shadow: var(--shadow-lg);
    text-align: center;
    animation: modalPop .22s cubic-bezier(.34,1.56,.64,1);
}

@keyframes modalPop {
    from { opacity: 0; transform: scale(.9); }
    to   { opacity: 1; transform: scale(1); }
}

.edge-modal-image   { display: block; width: 80px; height: 80px; margin: 0 auto 16px; object-fit: cover; border-radius: 16px; }
.edge-modal-title   { margin: 0 0 8px; color: var(--text-primary); font-size: 20px; font-weight: 700; }
.edge-modal-message { margin: 0 0 22px; color: var(--text-secondary); font-size: 14px; line-height: 1.6; }

.edge-modal-close {
    min-width: 100px;
    padding: 10px 22px;
    border: 0;
    border-radius: var(--radius-sm);
    background: var(--primary);
    color: #fff;
    cursor: pointer;
    font: 600 14px var(--font);
    transition: background .18s;
}
.edge-modal-close:hover { background: var(--primary-dark); }

/* ── Disclaimer ── */
.disclaimer strong { color: #c2410c; }
.disclaimer .branches { display: flex; flex-wrap: wrap; gap: 6px 10px; margin-top: 6px; }
.disclaimer .branch-tag {
    background: #fff7ed;
    border: 1px solid #fdba74;
    border-radius: 4px;
    padding: 2px 8px;
    font-size: 12px;
    font-weight: 600;
    color: #c2410c;
}

/* ── Responsive ── */
@media (max-width: 640px) {
    .page-header { padding: 16px 12px 22px; }
    .page-body   { padding: 16px 12px 32px; }
    .search-card { padding: 16px; }
    .search-row  { flex-direction: column; }
    .search-input-wrap { flex: 1 1 100%; }
    .search-actions { flex-direction: column; align-items: stretch; }
    .search-actions .btn { justify-content: center; }
    .print-all-btn-wrap { margin-left: 0; }
    .result-logo { width: 100%; max-width: 360px; height: auto; }
    .result-logo-cell { padding-left: 10px; }
    .guide-card { padding: 14px; }
}

@media (max-width: 420px) {
    .page-header h1 { font-size: 16px; }
    .page-header p  { font-size: 11px; }
    .page-header-icon { width: 36px; height: 36px; }
}

/* ── Print ── */
@media print {
    @page { size: auto; width: 800px; }

    body { background: white; margin: auto; width: 800px; }

    .search-card, .guide-card, .status-bar, .no-print { display: none !important; }
    .page-header { background: none !important; padding: 0; }
    .page-header h1 { color: #000; }

    .result-card {
        width: 100% !important;
        max-width: 100% !important;
        margin-bottom: 0;
        box-shadow: none !important;
        border: none !important;
        page-break-after: always;
        break-after: page;
        page-break-inside: avoid;
        break-inside: avoid;
    }

    .result-sheet-wrap { overflow: visible; }

    .result-sheet,
    .subject-table,
    .result-header-table,
    .result-summary {
        width: 100% !important;
        max-width: 100% !important;
        margin-left: auto !important;
        margin-right: auto !important;
        box-sizing: border-box;
    }

    body.printing-single #resultsContainer .result-card { display: none !important; }
    body.printing-single #resultsContainer .result-card.print-target { display: block !important; }
}
