/* ══════════════════════════════════════════════
   RAZR LED · detail.css
   A4 Spec Sheet — strict fit, no overflow
   ══════════════════════════════════════════════ */

:root {
    --navy: #1e3a8a;
    --navy2: #2d4fa3;
    --orange: #f99000;
    --muted: #64748b;
    --border: #d1d5db;
    --bg-row: #f8fafc;
    --text: #1e293b;
    --sub: #334155;

    /* A4 exact */
    --a4-w: 210mm;
    --a4-h: 297mm;
    --pad: 10mm;
}

/* ── Reset ── */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

/* ── Screen body ── */
body {
    background: #cfd8e8;
    font-family: 'IBM Plex Sans Thai', sans-serif;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 0;
    margin: 0;
    min-height: 100vh;
    min-width: 840px; /* match viewport width */
    overflow-x: auto; /* allow horizontal scroll if window < 840px */
}

/* ── Toolbar ── */
.toolbar {
    position: fixed;
    top: 16px;
    right: 16px;
    z-index: 999;
    display: flex;
    gap: 10px;
    align-items: center;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(8px);
    border: 1px solid var(--border);
    padding: 8px 12px;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

@media (max-width: 600px) {
    .toolbar {
        top: 10px;
        right: 10px;
        left: 10px;
        justify-content: space-between;
        padding: 6px 10px;
    }
    .lang-pill { padding: 2px; }
    .lang-btn { padding: 4px 8px; font-size: 0.75rem; }
    .btn-pdf, .btn-back { padding: 6px 10px; font-size: 0.75rem; }
}

.lang-pill {
    display: inline-flex;
    background: #f1f5f9;
    border: 1px solid #cbd5e1;
    border-radius: 9px;
    padding: 3px;
    gap: 2px;
}

.lang-btn {
    border: none;
    background: transparent;
    color: var(--muted);
    font-weight: 700;
    font-size: .8rem;
    padding: 6px 13px;
    border-radius: 7px;
    cursor: pointer;
    transition: all .2s;
}

.lang-btn.active {
    background: linear-gradient(135deg, var(--navy), var(--navy2));
    color: #fff;
    box-shadow: 0 2px 8px rgba(30, 58, 138, .3);
}

.btn-pdf,
.btn-back {
    border: none;
    cursor: pointer;
    font-family: inherit;
    font-weight: 700;
    font-size: .8rem;
    padding: 8px 16px;
    border-radius: 8px;
    transition: all .2s;
}

.btn-pdf {
    background: var(--navy);
    color: #fff;
    box-shadow: 0 2px 8px rgba(30, 58, 138, .35);
}

.btn-pdf:hover {
    background: var(--navy2);
}

.btn-back {
    background: #fff;
    color: var(--navy);
    border: 1.5px solid var(--navy);
}

.btn-back:hover {
    background: #eff3fc;
    background: #eff3fc;
}

/* ══════════════════════════════════════════════
   A4 PAGE
   ══════════════════════════════════════════════ */
.a4-page {
    width: var(--a4-w);
    min-height: var(--a4-h);
    margin: 40px auto; /* Centering + breathing room */
    background: #fff;
    padding: var(--pad);
    box-shadow: 0 8px 40px rgba(0, 0, 0, .18);
    display: flex;
    flex-direction: column;
    color: var(--text);
    overflow: hidden;
    flex-shrink: 0;
}

/* ── Header ── */
.doc-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    border-bottom: 2.5px solid var(--navy);
    padding-bottom: 8px;
    margin-bottom: 10px;
    flex-shrink: 0;
}

.logo-area {
    display: flex;
    flex-direction: column;
    line-height: 1;
}

.logo-img {
    height: 42px;
    width: auto;
    display: block;
    object-fit: contain;
}

.doc-meta {
    text-align: right;
}

.doc-title {
    font-size: 1rem;
    font-weight: 900;
    color: var(--navy);
    letter-spacing: .5px;
    text-transform: uppercase;
}

.doc-subtitle {
    font-size: .65rem;
    color: var(--muted);
    font-weight: 600;
    margin-top: 2px;
}

.doc-ref {
    font-size: .6rem;
    color: var(--muted);
    font-family: 'IBM Plex Mono', monospace;
    margin-top: 3px;
}

/* ══════════════════════════════════════════════
   PREVIEW SECTION
   ══════════════════════════════════════════════ */
.preview-section {
    background: #f1f5f9;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    padding: 12px;
    position: relative;
    height: 280px;
    /* fixed height — never grows */
    margin-bottom: 10px;
    flex-shrink: 0;
    overflow: hidden;
}

/* Ground line */
.ground-line {
    position: absolute;
    left: 5%;
    right: 5%;
    bottom: 30px;
    height: 2px;
    background: #94a3b8;
    z-index: 5;
}

.ground-label {
    position: absolute;
    left: 50%;
    bottom: -17px;
    transform: translateX(-50%);
    font-size: .55rem;
    color: #64748b;
    font-weight: 800;
    text-transform: uppercase;
    white-space: nowrap;
}

/* Human silhouette */
.scale-ref {
    position: absolute;
    bottom: 30px;
    display: flex;
    flex-direction: column;
    align-items: center;
    z-index: 10;
}

.human-svg {
    color: #1e293b;
    display: block;
}

.human-label {
    font-size: .55rem;
    color: #475569;
    font-weight: 800;
    writing-mode: vertical-rl;
    transform: rotate(180deg);
    position: absolute;
    right: -18px;
    top: 50%;
    transform: translateY(-50%) rotate(180deg);
    white-space: nowrap;
}

/* Product label top */
.screen-product-label {
    position: absolute;
    top: 12px;
    left: 12px;
    /* Moved to top-left corner to avoid overlap with centered screen and dimension labels */
    font-size: .65rem;
    font-weight: 600;
    color: var(--navy);
    background: rgba(255, 255, 255, .9);
    border: 1px solid var(--orange);
    border-radius: 5px;
    padding: 3px 10px;
    white-space: nowrap;
    z-index: 20;
}

.label-badge {
    display: inline-block;
    background: var(--orange);
    color: #fff;
    font-size: .55rem;
    font-weight: 900;
    border-radius: 3px;
    padding: 1px 4px;
    margin-left: 5px;
}

/* Screen box */
.screen-viz {
    position: absolute;
    bottom: 30px;
    border: 2.5px solid var(--orange);
    background: #0a0a14;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 8px 24px rgba(0, 0, 0, .4), inset 0 0 30px rgba(249, 144, 0, .08);
    z-index: 10;
    overflow: hidden;
}

.screen-image-bg {
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg,
            #0a1628 0%, #0d2a4a 25%, #1a4a7a 50%, #0d2a4a 75%, #0a1628 100%);
    opacity: .9;
}

/* dimension lines */
.dim-top-line {
    position: absolute;
    top: -12px;
    left: 0;
    right: 0;
    height: 1px;
    background: var(--orange);
    opacity: .7;
}

.dim-top-line::before,
.dim-top-line::after {
    content: '';
    position: absolute;
    width: 1px;
    height: 6px;
    background: var(--orange);
    top: -3px;
}

.dim-top-line::before {
    left: 0;
}

.dim-top-line::after {
    right: 0;
}

.dim-right-line {
    position: absolute;
    right: -12px;
    top: 0;
    bottom: 0;
    width: 1px;
    background: var(--orange);
    opacity: .7;
}

.dim-right-line::before,
.dim-right-line::after {
    content: '';
    position: absolute;
    height: 1px;
    width: 6px;
    background: var(--orange);
    right: -3px;
}

.dim-right-line::before {
    top: 0;
}

.dim-right-line::after {
    bottom: 0;
}

.dim-label {
    position: absolute;
    font-size: .62rem;
    font-weight: 900;
    color: var(--orange);
    background: #f1f5f9;
    padding: 0 4px;
    white-space: nowrap;
    font-family: 'IBM Plex Mono', monospace;
    z-index: 12;
}

.dim-w-label {
    top: -12px;
    left: 50%;
    transform: translate(-50%, -50%);
}

.dim-h-label {
    right: -40px;
    top: 50%;
    transform: translateY(-50%);
}

/* overlay text */
.screen-overlay {
    position: relative;
    z-index: 11;
    text-align: center;
}

.overlay-array {
    font-size: .9rem;
    font-weight: 900;
    color: var(--orange);
    font-family: 'IBM Plex Mono', monospace;
    letter-spacing: 1px;
}

.overlay-res {
    font-size: .6rem;
    color: rgba(255, 255, 255, .7);
    font-weight: 600;
    margin-top: 2px;
}

/* ══════════════════════════════════════════════
   SPEC TABLE — THE CRITICAL PART
   Forces exact column widths so nothing overflows
   ══════════════════════════════════════════════ */
.section-title {
    font-size: .82rem;
    font-weight: 900;
    color: var(--navy);
    margin: 6px 0 6px;
    padding-bottom: 4px;
    border-bottom: 2px solid #e2e8f0;
    flex-shrink: 0;
}

.spec-table {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
    /* ← mandatory: columns NEVER flex beyond col width */
    font-size: .7rem;
    font-family: 'IBM Plex Sans Thai', sans-serif;
    border: 1.5px solid var(--navy);
    flex-shrink: 0;
    margin-bottom: 8px;
}

/* Column width budget:
   Total usable = 190mm (210mm - 2×10mm padding)
   We split: 25% | 25% | 25% | 25% (equal distribution)
   Balanced left and right sections */
.col-label-l {
    width: 25%;
}

.col-val-l {
    width: 25%;
}

.col-label-r {
    width: 25%;
}

.col-val-r {
    width: 25%;
}

.spec-table thead th {
    background: var(--navy);
    color: #fff;
    font-weight: 800;
    font-size: .68rem;
    text-align: center;
    padding: 7px 6px;
    border: 1px solid #1a327a;
    text-transform: uppercase;
    letter-spacing: .3px;
}

.spec-table tbody td {
    padding: 4px 6px;
    border: 1px solid var(--border);
    vertical-align: middle;
    overflow: visible;
    text-overflow: clip;
    white-space: normal;
    word-wrap: break-word;
    line-height: 1.2;
}

/* Label cells — bold dark */
.spec-table tbody td:nth-child(1),
.spec-table tbody td:nth-child(3) {
    font-weight: 700;
    color: var(--text);
}

/* Value cells — mono, right-aligned */
.spec-table tbody td:nth-child(2),
.spec-table tbody td:nth-child(4) {
    font-family: 'IBM Plex Mono', monospace;
    font-weight: 600;
    text-align: right;
    color: var(--sub);
    font-size: .66rem;
}

.spec-table tbody tr:nth-child(even) {
    background: var(--bg-row);
}

/* highlight important rows */
.spec-table tbody tr.highlight-row td {
    background: #fffbf0;
}

.spec-table tbody tr.highlight-row td:nth-child(2),
.spec-table tbody tr.highlight-row td:nth-child(4) {
    color: #b45309;
}

.unit-sfx {
    font-size: .58rem;
    color: var(--muted);
    margin-left: 2px;
    font-weight: 500;
}

/* ── Footer ── */
.doc-footer {
    margin-top: auto;
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    font-size: .62rem;
    color: var(--muted);
    padding-top: 10px;
    border-top: 1px solid #e2e8f0;
    flex-shrink: 0;
}

.footer-brand {
    font-weight: 900;
    color: var(--navy);
}

.footer-right {
    text-align: right;
    line-height: 1.6;
}

/* ══════════════════════════════════════════════
   PRINT OVERRIDES
   ══════════════════════════════════════════════ */
@media print {
    body {
        background: #fff;
        padding: 0;
        margin: 0;
    }

    .no-print {
        display: none !important;
    }

    .toolbar {
        display: none !important;
    }

    .a4-page {
        width: 210mm;
        height: 297mm;
        min-height: unset;
        padding: 10mm;
        box-shadow: none;
        overflow: hidden;
        margin: 0;
    }

    @page {
        size: A4 portrait;
        margin: 0;
    }

    /* Force table stays on one page */
    .spec-table {
        page-break-inside: avoid;
    }
}