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

body {
    font-family: Arial, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 20px;
    padding-top: 60px; /* Space for beta notification */
}

.beta-notification {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background: linear-gradient(45deg, #ff6b6b, #ff8e53);
    color: white;
    padding: 8px 20px;
    text-align: center;
    font-size: 14px;
    font-weight: bold;
    z-index: 1000;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
}

.beta-notification::before {
    content: "🧪";
    margin-right: 8px;
}

.container {
    max-width: 800px;
    margin: 0 auto;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 15px;
    padding: 30px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
    backdrop-filter: blur(10px);
}

.logo-wrap {
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 30px;
    flex-direction: column;
}

h1 {
    text-align: center;
    color: #333;
    margin-bottom: 15px;
    font-size: 2.5rem;
    background: linear-gradient(45deg, #667eea, #764ba2);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.subtitle {
    text-align: center;
    color: #333;
    margin-top: 8px;
    margin-bottom: 30px;
    font-size: 1.5rem;
    background: linear-gradient(45deg, #667eea, #764ba2);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.container h1 {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.logo-inline {
    height: 36px;
    width: auto;
    vertical-align: middle;
    filter: drop-shadow(0 2px 6px rgba(0,0,0,0.12));
}

.logo-wrap {
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 16px;
}
.logo-wrap span {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}
.logo-wrap h1 {
    margin: 0; /* remove default margins that offset vertical centering */
    line-height: 1; /* tighten line height for better vertical alignment */
}
.logo-wrap img {
    width: 70px;
    height: auto;
    filter: drop-shadow(0 4px 12px rgba(0,0,0,0.15));
}

.input-section {
    margin-bottom: 30px;
}

label {
    display: block;
    margin-bottom: 10px;
    font-weight: bold;
    color: #555;
    font-size: 1.1rem;
}

textarea {
    width: 100%;
    height: 150px;
    padding: 15px;
    border: 2px solid #e0e0e0;
    border-radius: 10px;
    font-family: 'Courier New', monospace;
    font-size: 14px;
    resize: vertical;
    transition: all 0.3s ease;
    background: rgba(255, 255, 255, 0.8);
}

textarea:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 10px rgba(102, 126, 234, 0.3);
    transform: translateY(-2px);
}

.button-group {
    display: flex;
    gap: 15px;
    justify-content: center;
    margin-bottom: 30px;
}

button {
    padding: 12px 30px;
    border: none;
    border-radius: 25px;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.btn-generate {
    background: linear-gradient(45deg, #667eea, #764ba2);
    color: white;
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}

.btn-generate:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.6);
}

.btn-print {
    background: linear-gradient(45deg, #48bb78, #38a169);
    color: white;
    box-shadow: 0 5px 15px rgba(72, 187, 120, 0.4);
}

.btn-print:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(72, 187, 120, 0.6);
}

/* Download button styling */
.btn-download {
    background: linear-gradient(45deg, #06b6d4, #0ea5e9); /* cyan to blue */
    color: white;
    box-shadow: 0 5px 15px rgba(14, 165, 233, 0.4);
}

.btn-download:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(14, 165, 233, 0.6);
}

button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none !important;
}

/* Stack buttons on small screens */
@media (max-width: 600px) {
    .button-group {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
    }

    .button-group button {
        width: 100%;
    }
}

.status {
    text-align: center;
    margin: 20px 0;
    font-weight: bold;
    padding: 10px;
    border-radius: 8px;
}

.status.success {
    color: #38a169;
    background: rgba(72, 187, 120, 0.1);
}

.status.error {
    color: #e53e3e;
    background: rgba(229, 62, 62, 0.1);
}

.preview {
    margin-top: 30px;
    padding: 20px;
    background: rgba(240, 240, 240, 0.5);
    border-radius: 10px;
}

.preview h3 {
    margin-bottom: 15px;
    color: #555;
}

.seo-section {
    max-width: 800px;
    margin: 30px auto 0;
    background: rgba(255, 255, 255, 0.9);
    border-radius: 12px;
    padding: 24px;
    box-shadow: 0 10px 24px rgba(0,0,0,0.08);
    line-height: 1.6;
    color: #333;
}

.seo-section h2 {
    font-size: 1.8rem;
    margin-bottom: 12px;
    background: linear-gradient(45deg, #667eea, #764ba2);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-align: center;
}

.seo-section h3 {
    margin-top: 18px;
    margin-bottom: 8px;
    color: #444;
}

.seo-section p { margin: 10px 0 14px; }
.seo-section p strong { color: #4f46e5; }

.seo-section ul,
.seo-section ol {
    padding-left: 20px;
}

.seo-section li { margin-bottom: 8px; }

/* Feature list with checkmarks and subtle cards */
.seo-section ul {
    list-style: none;
    padding-left: 0;
    margin: 8px 0 0;
}
.seo-section ul li {
    position: relative;
    padding: 10px 12px 10px 36px;
    background: rgba(102, 126, 234, 0.06);
    border: 1px solid rgba(102, 126, 234, 0.15);
    border-radius: 10px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.04);
}
.seo-section ul li::before {
    content: "✔";
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: #22c55e;
    font-weight: 700;
}

/* Steps list spacing */
.seo-section ol { margin-top: 8px; }
.seo-section ol li { padding: 4px 0; }

.seo-note {
    margin-top: 12px;
    color: #555;
}

/* Responsive: two columns for features on wider screens */
@media (min-width: 800px) {
    .seo-section ul {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 10px 14px;
    }
}

.qr-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 20px;
    max-height: 400px;
    overflow-y: auto;
    padding: 10px;
}

.qr-item {
    text-align: center;
    padding: 12px;
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    transition: transform 0.2s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    overflow: hidden; /* prevent inner QR from bleeding out */
}

.qr-item:hover {
    transform: scale(1.05);
}

.qr-item img {
    margin-bottom: 10px;
    max-width: 100%;
    height: auto;
}

/* Ensure canvases/SVGs from qr-code-styling fit within the card */
.qr-item canvas,
.qr-item svg,
.qr-item > div {
    max-width: 100%;
    height: auto;
    display: block;
}

.qr-code-text {
    font-weight: bold;
    color: #333;
    font-size: 16px;
}

.controls-section {
    margin-bottom: 25px;
    padding: 20px;
    background: linear-gradient(135deg, rgba(240, 240, 240, 0.3), rgba(255, 255, 255, 0.5));
    border-radius: 10px;
    border: 1px solid rgba(102, 126, 234, 0.15);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.controls-section h3 {
    margin-bottom: 15px;
    color: #444;
    font-size: 1.2rem;
    border-bottom: 1px solid rgba(102, 126, 234, 0.2);
    padding-bottom: 6px;
}

.controls-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 12px;
    align-items: stretch;
}

.control-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 8px;
    background: rgba(255, 255, 255, 0.6);
    border: 1px solid rgba(102, 126, 234, 0.1);
    border-radius: 6px;
    transition: all 0.2s ease;
}

.control-group:hover {
    background: rgba(255, 255, 255, 0.8);
    border-color: rgba(102, 126, 234, 0.2);
}

.control-group label {
    font-size: 0.9rem;
    color: #444;
    font-weight: 600;
    margin-bottom: 2px;
}

.color-input {
    width: 42px;
    height: 24px;
    border: 1px solid rgba(102, 126, 234, 0.3);
    border-radius: 4px;
    cursor: pointer;
    transition: border-color 0.2s ease;
}

.color-input:hover {
    border-color: rgba(102, 126, 234, 0.8);
}

.checkbox-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

.checkbox-group input[type="checkbox"] {
    width: auto;
    margin: 0;
    accent-color: #667eea;
}

.control-group select,
.control-group input[type="range"] {
    padding: 4px 6px;
    border: 1px solid rgba(102, 126, 234, 0.2);
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.8);
    transition: border-color 0.2s ease;
    font-size: 0.9rem;
}

.control-group select:focus,
.control-group input[type="range"]:focus {
    outline: none;
    border-color: rgba(102, 126, 234, 0.8);
    box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.2);
}

/* Print styles */
@media print {
    body {
        background: white;
        padding: 0;
        margin: 0;
    }

    .container {
        max-width: none;
        background: white;
        border-radius: 0;
        padding: 0;
        box-shadow: none;
    }

    .input-section, .button-group, .preview h3, .controls-section, .beta-notification, .logo-wrap, .seo-section {
        display: none;
    }

    /* Hide inline logo in title when printing */
    .logo-inline {
        display: none !important;
    }

    /* General reset for grid to avoid clipping */
    .qr-grid {
        display: block;
        max-height: none !important;
        overflow: visible !important;
        padding: 0;
    }

    /* Single per page layout */
    body.print-single .qr-grid {
        display: block;
        max-height: none;
        overflow: visible;
        padding: 0;
    }

    body.print-single .qr-item {
        /* Force each item to its own page */
        page-break-after: always;
        break-after: page;
        page-break-inside: avoid;
        break-inside: avoid;
        width: 100%;
        /* Fill printable area height (account for @page 10mm margins on top/bottom) for vertical centering */
        min-height: calc(100vh - 20mm);
        height: auto;
        box-sizing: border-box;
        display: flex;
        flex-direction: column;
        justify-content: center;
        align-items: center;
        margin: 0;
        padding: 0;
        box-shadow: none;
        background: white;
        position: relative;
        orphans: 1;
        widows: 1;
    }

    body.print-single .qr-item:last-child {
        page-break-after: auto;
        break-after: auto;
    }

    /* Defensive: ensure grid wrapper doesn't introduce unexpected breaks */
    body.print-single .qr-grid {
        page-break-before: auto;
        break-before: auto;
        margin: 0;
        padding: 0;
    }

    /* Multiple per page layout */
    body.print-multiple .qr-grid {
        display: flex;
        flex-wrap: wrap;
        gap: 8mm;
        padding: 10mm;
        max-height: none;
        overflow: visible;
        justify-content: center; /* center tiles across the row */
    }

    body.print-multiple .qr-item {
        page-break-inside: avoid;
        break-inside: avoid;
        flex: 0 0 auto;
        /* Box width = QR size + horizontal padding + border */
        width: calc(var(--qr-print-size, 40mm) + 8mm);
        height: auto;
        margin: 0;
        padding: 4mm;
        box-shadow: none;
        background: transparent; /* no tile background in print */
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center; /* center QR within the tile */
        border: none; /* remove border in print */
        border-radius: 0;
    }

    /* Allow inner QR container to size naturally */
    body.print-multiple .qr-item > div {
        width: auto !important;
        height: auto !important;
        max-width: none !important;
    }

    /* Ensure QR graphic uses requested size in both modes */
    .qr-item img,
    .qr-item canvas,
    .qr-item svg,
    .qr-item > div > canvas,
    .qr-item > div > svg,
    .qr-item > div {
        width: var(--qr-print-size, 40mm) !important;
        height: auto !important;
        aspect-ratio: 1 / 1 !important;
        margin-bottom: 2mm !important;
        display: block !important;
        max-width: none !important;
        max-height: none !important;
    }

    .qr-code-text {
        font-size: 22pt;
        font-weight: bold;
        text-align: center;
        margin: 0 auto;
    }
}
