:root {
    --primary: #B91C1C;
    --primary-hover: #8B0F14;
    --primary-dark: #5A0A0F;
    --accent: #F59E0B;
    --accent-green: #84CC16;
    --bg-dark: #FFF8F4;
    --card-bg: #ffffff;
    --text-main: #2A0A0A;
    --text-muted: #7A5C5C;
    --border: #F4D8D8;
    --a3-width: 420mm;
    --a3-height: 297mm;
}

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

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-dark);
    background-image:
        radial-gradient(circle at 10% 0%, rgba(185, 28, 28, 0.08) 0%, transparent 40%),
        radial-gradient(circle at 90% 100%, rgba(245, 158, 11, 0.08) 0%, transparent 40%);
    background-attachment: fixed;
    color: var(--text-main);
    line-height: 1.6;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

body > .no-print:first-child {
    flex: 1 0 auto;
}

body > footer {
    flex-shrink: 0;
    margin-top: auto;
}

.container {
    max-width: 1000px;
    margin: 0 auto;
    padding: 0 20px;
}

/* Header */
header {
    background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 60%, #D62828 100%);
    backdrop-filter: blur(10px);
    border-bottom: 3px solid var(--accent);
    padding: 20px 0;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 4px 20px rgba(90, 10, 15, 0.25);
}

header .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo h1 {
    font-family: 'Outfit', sans-serif;
    font-size: 1.6rem;
    font-weight: 800;
    letter-spacing: -0.5px;
    color: #ffffff;
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
}

.logo h1 span {
    color: var(--accent);
    font-style: italic;
}

.logo p {
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.85);
    text-transform: uppercase;
    letter-spacing: 2px;
    font-weight: 600;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    border: none;
    font-family: inherit;
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent) 0%, #EAB308 100%);
    color: var(--primary-dark);
    font-weight: 800;
    box-shadow: 0 4px 12px rgba(245, 158, 11, 0.35);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.btn-primary:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 18px rgba(245, 158, 11, 0.5);
}

.btn-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-secondary {
    background-color: rgba(255, 255, 255, 0.15);
    color: #ffffff;
    border: 1.5px solid rgba(255, 255, 255, 0.4);
    backdrop-filter: blur(6px);
}

.btn-secondary:hover {
    background-color: rgba(255, 255, 255, 0.25);
    border-color: var(--accent);
}

/* Card & Upload */
.card {
    background-color: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 35px;
    margin-top: 40px;
    box-shadow: 0 8px 32px rgba(185, 28, 28, 0.08);
    position: relative;
    overflow: hidden;
}

.card::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, var(--primary) 0%, var(--accent) 50%, var(--accent-green) 100%);
}

.category-selector {
    margin-bottom: 25px;
    padding-bottom: 25px;
    border-bottom: 1px solid var(--border);
}

.category-selector h3 {
    font-size: 1rem;
    margin-bottom: 15px;
    color: var(--primary-dark);
    font-family: 'Outfit', sans-serif;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.radio-group {
    display: flex;
    gap: 15px;
}

.radio-option {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 15px 20px;
    border: 2px solid var(--border);
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s;
    background-color: var(--card-bg);
}

.radio-option:hover {
    border-color: var(--primary);
    background-color: rgba(185, 28, 28, 0.05);
}

.radio-option input[type="radio"] {
    accent-color: var(--primary);
    width: 18px;
    height: 18px;
    cursor: pointer;
}

.radio-option:has(input[type="radio"]:checked) {
    border-color: var(--primary);
    background: linear-gradient(135deg, rgba(185, 28, 28, 0.1) 0%, rgba(245, 158, 11, 0.08) 100%);
    box-shadow: 0 4px 12px rgba(185, 28, 28, 0.12);
}

.radio-label {
    font-weight: 800;
    letter-spacing: 1.5px;
    font-family: 'Outfit', sans-serif;
    color: var(--primary-dark);
}

.drop-zone {
    border: 2px dashed var(--border);
    border-radius: 12px;
    padding: 60px 40px;
    text-align: center;
    transition: all 0.3s;
    cursor: pointer;
}

.drop-zone:hover,
.drop-zone.drag-over {
    border-color: var(--primary);
    background-color: rgba(185, 28, 28, 0.04);
}

.upload-icon {
    color: var(--primary);
    margin-bottom: 20px;
    filter: drop-shadow(0 4px 8px rgba(185, 28, 28, 0.2));
}

.drop-zone h3 {
    font-size: 1.25rem;
    margin-bottom: 8px;
    color: var(--primary-dark);
    font-family: 'Outfit', sans-serif;
    font-weight: 800;
}

.drop-zone p {
    color: var(--text-muted);
}

.file-info {
    display: block;
    margin-top: 15px;
    font-size: 0.85rem;
    color: var(--text-muted);
    font-style: italic;
}

/* Stats */
.stats-section {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
    margin-top: 20px;
}

.stat-card {
    background-color: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 22px;
    text-align: center;
    box-shadow: 0 4px 16px rgba(185, 28, 28, 0.06);
    transition: transform 0.2s;
}

.stat-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 22px rgba(185, 28, 28, 0.12);
}

.stat-label {
    display: block;
    color: var(--text-muted);
    font-size: 0.85rem;
    margin-bottom: 5px;
}

.stat-value {
    font-size: 2rem;
    font-weight: 900;
    font-family: 'Outfit', sans-serif;
    background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.preview-label {
    margin-top: 40px;
    padding: 20px 0;
    border-top: 2px dashed var(--border);
}

.preview-label h3 {
    font-family: 'Outfit', sans-serif;
    color: var(--primary-dark);
    font-weight: 800;
    margin-bottom: 6px;
}

.preview-label p {
    color: var(--text-muted);
}

/* PRINT AREA & BIB DESIGN */
.print-area {
    margin-top: 40px;
}

/* Simulation of A3 in browser */
.page-a3 {
    background-color: white;
    width: var(--a3-width);
    height: var(--a3-height);
    margin: 40px auto;
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 1fr 1fr;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    overflow: hidden;
    color: black;
}

/* Garis Potong (Cutting Lines) */
.page-a3::before {
    content: "";
    position: absolute;
    top: 50%;
    left: 0;
    width: 100%;
    height: 1px;
    border-top: 1px dashed #aaaaaa;
    z-index: 10;
    pointer-events: none;
    display: none; /* Sembunyikan di layar */
}

.page-a3::after {
    content: "";
    position: absolute;
    top: 0;
    left: 50%;
    width: 1px;
    height: 100%;
    border-left: 1px dashed #aaaaaa;
    z-index: 10;
    pointer-events: none;
    display: none; /* Sembunyikan di layar */
}

.bib-item {
    border: none;
    display: block;
    padding: 0;
    position: relative;
    overflow: hidden;
    font-family: 'Outfit', sans-serif;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
}

.bib-item.umum {
    background-image: url('umum.jpg');
}

.bib-item.pelajar {
    background-image: url('pelajar.jpg');
}

/* Number */
.bib-number-wrapper {
    position: absolute;
    top: 22%;
    left: 5%;
    width: 90%;
    height: 30%;
    background-color: transparent;
    display: flex;
    justify-content: center;
    align-items: center;
}

.bib-number {
    font-size: 110pt;
    font-weight: 900;
    line-height: 1;
    font-family: 'Inter', sans-serif;
    color: #222;
}

/* Bottom Row (Name and QR overlay via absolute pos) */

.bib-name-wrapper {
    position: absolute;
    top: 60%;
    left: 5.2%;
    width: 68%;
    height: 14%;
    background-color: transparent;
    display: flex;
    justify-content: center;
    align-items: center;
}

.bib-name {
    font-size: 26pt;
    font-weight: 800;
    text-transform: uppercase;
    text-align: center;
    font-style: italic;
    color: #222;
    white-space: normal;
    word-wrap: break-word;
    line-height: 1.1;
    max-width: 100%;
}

.bib-qr-code {
    position: absolute;
    top: 58.4%;
    left: 76.4%;
    width: 12%;
    aspect-ratio: 1;
    background-color: transparent;
    display: flex;
    justify-content: center;
    align-items: center;
}

.bib-qr-code img,
.bib-qr-code canvas {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

/* Media Print */
@media print {
    @page {
        size: A3 landscape;
        margin: 0;
    }

    * {
        margin: 0 !important;
        padding: 0 !important;
    }

    html, body {
        width: 420mm;
        background: #fff;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    .no-print,
    footer {
        display: none !important;
        height: 0 !important;
        overflow: hidden !important;
    }

    .print-area {
        display: block !important;
        width: 420mm;
    }

    .page-a3 {
        box-shadow: none !important;
        page-break-after: always;
        page-break-inside: avoid;
        width: 420mm !important;
        height: 297mm !important;
        display: grid !important;
        grid-template-columns: 1fr 1fr;
        grid-template-rows: 1fr 1fr;
        position: relative;
        overflow: hidden;
        outline: none;
        background-color: white;
    }

    .page-a3:last-child {
        page-break-after: auto;
    }

    .page-a3::before, .page-a3::after {
        display: block !important;
        margin: 0 !important;
        padding: 0 !important;
    }

    .bib-item {
        border: none;
        background-color: transparent;
    }

    .bib-number-wrapper,
    .bib-name-wrapper,
    .bib-qr-code {
        box-shadow: none;
        border: none;
    }
}

footer {
    padding: 40px 0;
    margin-top: 60px;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.9rem;
    border-top: 2px solid var(--border);
    background: linear-gradient(180deg, transparent 0%, rgba(185, 28, 28, 0.03) 100%);
}