/* CSS Variables - GOLDEN RATIO SYSTEM */
:root {
    --coral: #FF5A29;
    --dark-grey: #2C2C2C;
    --black: #1A1A1A;
    --white: #FFFFFF;
    --paper-bg: #FFFFFF;

    --font-serif: 'Literata', serif;
    --font-sans: 'Manrope', sans-serif;

    /* MODULAR SCALE (Base 12px) */
    /* Phi = 1.618 */
    --phi: 1.618;

    /* Typography */
    /* 12px * 1.618^3 ≈ 50px */
    --fs-xxl: 3rem;
    /* 12px * 1.618^2 ≈ 31px -> 2rem */
    --fs-xl: 2.2rem;
    /* 12px * 1.618 ≈ 19px -> 1.25rem */
    --fs-lg: 1.35rem;
    /* Base 12px -> 0.75rem */
    --fs-md: 0.85rem;
    /* 12px / 1.618 ≈ 7.5px -> 0.6rem (Legality) */
    --fs-sm: 0.5rem;

    /* SPACING */
    /* 99mm = 374px. 10% padding = ~37px -> 2.3rem */
    --margin-outer: 2.4rem;
    --golden-gap: 1.6rem;
}

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

body {
    background-color: #f0f0f0;
    font-family: var(--font-sans);
    display: flex;
    flex-direction: row;
    height: 100vh;
}

/* --- AUTHENTICATION OVERLAY --- */
.auth-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    z-index: 9999;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: opacity 0.5s ease;
}

.auth-box {
    background: white;
    padding: 2.5rem;
    border-radius: 8px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
    text-align: center;
    border: 1px solid #eee;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    width: 300px;
}

.auth-box h2 {
    font-size: 1.2rem;
    font-family: var(--font-serif);
    color: var(--dark-grey);
    margin: 0;
}

.auth-box input {
    padding: 0.8rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 1rem;
    text-align: center;
}

.auth-box button {
    padding: 0.8rem;
    background: var(--dark-grey);
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* --- Controls Side --- */
.controls {
    width: 350px;
    background: white;
    padding: 2rem;
    border-right: 1px solid #ccc;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    box-shadow: 2px 0 10px rgba(0, 0, 0, 0.1);
    z-index: 10;
}

.controls header {
    display: flex;
    align-items: center;
    gap: 0;
    /* No gap (controlled by negative margin) */
    margin-bottom: 2rem;
}

/* --- CONTROL PANEL HEADER CONFIGURATION --- */

.control-logo {
    /* [LOGO HEIGHT] Change this number to make logo bigger/smaller */
    height: 80px;
    width: auto;

    /* [SPACING] Negative number pulls text closer, Positive pushes it away */
    margin-right: 0px;
    margin-left: 0;
}

/* New Header Text Container */
.header-text {
    display: flex;
    flex-direction: column;
    justify-content: center;
    /* [LINE SPACING] Distance between "GENERADOR" and "DE BONOS" */
    gap: 0;

    /* [TEXT BLOCK HEIGHT] Should match Logo Height roughly */
    height: 85px;
    padding-top: 4px;
    padding-bottom: 4px;
}

.header-text span {
    font-family: var(--font-sans);
    font-weight: 300;
    font-size: 1.6rem;
    /* Larger to match scale */
    text-transform: uppercase;
    line-height: 0.9;
    color: var(--dark-grey);
    letter-spacing: 2px;
}

/* Duplicate logo rule removed */

.controls h1 {
    font-size: 1.2rem;
    color: var(--dark-grey);
}

.input-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.input-group label {
    font-size: 0.9rem;
    /* Unified size */
    text-transform: uppercase;
    letter-spacing: 1px;
    color: #444;
    /* Slightly darker for better readability */
    font-weight: 500;
}

input,
select {
    padding: 0.8rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-family: var(--font-sans);
    font-size: 0.9rem;
    /* Unified size */
    color: #333;
    background: white;
}

.print-btn {
    margin-top: auto;
    padding: 1rem;
    background: var(--dark-grey);
    color: white;
    border: none;
    font-size: 1rem;
    font-weight: bold;
    cursor: pointer;
    transition: background 0.2s;
}

.print-btn:hover {
    background: black;
}

/* --- Print Area / Canvas --- */
.print-area {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 2rem;
    background: #555;
    overflow: auto;
}

/* The Card Itself */
.voucher-card {
    /* DL Envelope size: 210mm x 99mm */
    width: 210mm;
    height: 99mm;
    display: flex;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
    transition: all 0.3s ease;
    overflow: hidden;
    position: relative;
    background: var(--paper-bg);
}

/* --- Layout Internals --- */
.voucher-content {
    flex: 1;
    padding: var(--margin-outer);
    /* GOLDEN PADDING */
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    /* Stick footer to bottom */
}

/* Side Stub 38% vs 62% roughly */
.voucher-side {
    width: 25%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 1rem;
    border-left: 1px solid rgba(0, 0, 0, 0.05);
    /* Very subtle divider */
}

/* Branding */
.brand-header {
    /* No bottom margin needed if we use flex space-between, but let's keep it just in case */
}

.re-logo-img {
    height: 65px;
    /* Harmonized size */
    width: auto;
    object-fit: contain;
}

/* Details */
.main-details {
    display: flex;
    flex-direction: column;
    gap: var(--golden-gap);
    margin-top: 1rem;
}

.detail-block {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

.label {
    font-family: var(--font-sans);
    text-transform: uppercase;
    font-size: 0.65rem;
    /* Standard Utility Size */
    letter-spacing: 2px;
    opacity: 0.5;
    display: block;
    color: var(--black);
}

h2 {
    font-family: var(--font-serif);
    font-size: var(--fs-xl);
    /* 2.2rem */
    font-weight: 400;
    line-height: 1.1;
    color: var(--black);
    margin: 0;
}

h3 {
    font-family: var(--font-serif);
    font-size: var(--fs-lg);
    /* 1.35rem */
    font-weight: 400;
    line-height: 1.2;
    color: var(--dark-grey);
    margin: 0;
}

/* Footer & Data */
.footer-info {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
}

.info-block {
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
}

/* DATA - Unified Size */
.info-block span:not(.label) {
    font-family: var(--font-sans);
    font-size: var(--fs-md);
    /* 0.85rem */
    font-weight: 500;
    letter-spacing: 0.5px;
    color: var(--dark-grey);
}

.code {
    font-weight: 600;
}

/* Legal */
.terms-text {
    position: absolute;
    bottom: 0.6rem;
    left: 0;
    width: 100%;
    /* Only show on left content side technically, but centering is safer */
    padding-left: 2.4rem;
    /* Match var(--margin-outer) */
    padding-right: 25%;
    /* Avoid side stub */
    font-size: var(--fs-sm);
    color: #CCC;
    text-align: left;
    /* Aligned left for cleaner look */
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Side Panel */
.side-text {
    /* Removed vertical writing mode for better stacking */
    font-family: var(--font-sans);
    text-transform: uppercase;
    letter-spacing: 2px;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--dark-grey);
    text-align: center;
    margin-bottom: 0.5rem;
}

/* QR Code styling */
#qrcode img {
    border: 4px solid white;
    border-radius: 2px;
}

#qrcode-link {
    text-decoration: none;
    cursor: pointer;
}

/* --- PRINT STYLES --- */
@page {
    size: 220mm 110mm;
    /* DL Envelope */
    margin: 0;
}

@media print {
    @page {
        size: 220mm 110mm;
        margin: 0;
    }

    .no-print,
    .controls {
        display: none !important;
    }

    html,
    body {
        width: 100%;
        height: 100%;
        margin: 0;
        padding: 0;
        background: white;
    }

    body {
        display: flex;
        justify-content: center;
        align-items: center;
    }

    .print-area {
        width: 100%;
        height: 100%;
        display: flex;
        justify-content: center;
        align-items: center;
        background: white;
        margin: 0;
        padding: 0;
    }

    .voucher-card {
        width: 210mm !important;
        height: 99mm !important;
        box-shadow: none !important;
        border: none !important;
        /* Removed border */
        display: flex;
        /* Ensure internal flex works */
        margin: 0 auto;
        /* Horizontal centering fallback */
        position: relative;
        /* Reset absolute */
        top: auto;
        left: auto;
        transform: none;
        break-inside: avoid;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }
}