:root {
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --card-bg: #ffffff;
    --text-main: #1f2937;
    --text-muted: #6b7280;
    --border: #e5e7eb;
    --radius: 12px;
    --font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
}

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

body {
    font-family: var(--font-family);
    background: #ffffff;
    /* Clean white background */
    color: var(--text-main);
    line-height: 1.5;
    min-height: 100vh;
}

.app-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem;
}

/* Header & GitHub Logo */
header {
    position: relative;
    /* For absolute positioning of github logo */
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 3rem;
    padding: 1rem 0;
}

header h1 {
    font-weight: 800;
    font-size: 2.5rem;
    color: var(--primary);
    /* Title matches Download Button */
    letter-spacing: -0.02em;
}

.github-link {
    position: absolute;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    font-size: 1.75rem;
    color: var(--text-muted);
    transition: color 0.2s;
}

.github-link:hover {
    color: var(--primary);
}

main {
    display: grid;
    grid-template-columns: 1fr 450px;
    gap: 3rem;
    align-items: start;
}

/* Controls */
.controls {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.form-group-container {
    background: var(--card-bg);
    padding: 2rem;
    border-radius: var(--radius);
    /* Added border since background is white */
    border: 1px solid var(--border);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.03);
}

h2 {
    font-size: 1.15rem;
    margin-bottom: 1.5rem;
    border-bottom: 1px solid var(--border);
    padding-bottom: 0.75rem;
    display: flex;
    align-items: center;
    gap: 0.6rem;
    color: var(--text-main);
}

h2 i {
    color: var(--primary);
}

/* Subsections inside consolidated settings */
.subsection-title {
    font-size: 0.85rem;
    text-transform: uppercase;
    color: var(--text-muted);
    font-weight: 700;
    letter-spacing: 0.05em;
    margin-bottom: 1rem;
    margin-top: 0.5rem;
}

.divider {
    height: 1px;
    background: var(--border);
    margin: 1.5rem 0;
}

input,
select {
    width: 100%;
    padding: 0.75rem;
    margin-bottom: 0.75rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 0.9rem;
    font-family: inherit;
    transition: all 0.2s;
    background-color: #f9fafb;
    /* Slight grey input background for contrast */
}

input:focus,
select:focus {
    outline: none;
    border-color: var(--primary);
    background-color: #fff;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.input-group {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
}

.address-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
}

.full-width {
    grid-column: span 2;
}

.setting-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.75rem;
}

.checkbox-row {
    justify-content: flex-start;
    gap: 1rem;
    cursor: pointer;
    margin-bottom: 1.5rem;
}

.checkbox-row input {
    width: auto;
    margin: 0;
    cursor: pointer;
}

.setting-row input[type="color"] {
    width: 50px;
    padding: 2px;
    height: 35px;
    cursor: pointer;
    border: none;
    background: none;
}

.setting-row select {
    width: 60%;
    margin-bottom: 0;
}

/* Frame Selector */
.section-label {
    display: block;
    font-weight: 500;
    margin-bottom: 0.75rem;
    font-size: 0.9rem;
}

.frame-selector {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.5rem;
}

.frame-btn {
    background: #f3f4f6;
    border: 2px solid transparent;
    padding: 0.6rem 0.2rem;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.8rem;
    font-weight: 600;
    transition: all 0.2s;
    color: var(--text-muted);
}

.frame-btn:hover {
    background: #e5e7eb;
}

.frame-btn.active {
    background: #eff6ff;
    border-color: var(--primary);
    color: var(--primary);
}

/* Preview Area */
.preview-area {
    position: relative;
}

.sticky-wrapper {
    position: sticky;
    top: 2rem;
}

/* The Capture Container (The Card Itself) */
.capture-container {
    background: white;
    margin-bottom: 1.5rem;
    display: flex;
    justify-content: center;
    align-items: center;
    text-align: center;
    transition: all 0.3s ease;
    width: 100%;
    padding: 2rem;
    box-sizing: border-box;
}

.frame-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
}

.capture-container h3 {
    margin-bottom: 1rem;
    font-weight: 700;
    color: var(--text-main);
    word-break: break-word;
    max-width: 100%;
}

.qr-wrapper {
    display: inline-block;
}

.preview-name {
    font-weight: 600;
    font-size: 1.2rem;
    color: var(--text-main);
    margin-top: 1rem;
}

.scan-me-arrow {
    display: none;
    margin-top: 0.5rem;
    font-weight: 700;
    color: var(--primary);
    text-transform: uppercase;
    font-size: 0.9rem;
    letter-spacing: 1px;
}

/* --- Frame Styles --- */

/* 1. Simple / Clean */
.frame-simple {
    border-radius: var(--radius);
    border: 1px solid var(--border);
    box-shadow: 0 10px 30px -10px rgba(0, 0, 0, 0.1);
    background: white;
}

/* 2. Modern (Gradient Border) */
.frame-modern {
    position: relative;
    background: white;
    border-radius: 20px;
    box-shadow: 0 10px 30px -10px rgba(0, 0, 0, 0.15);
    padding: 3px;
    /* Space for the gradient border */
    background-image: linear-gradient(135deg, #6366f1, #a855f7, #ec4899);
}

.frame-modern .frame-content {
    background: white;
    border-radius: 17px;
    padding: 2rem;
    height: 100%;
}

/* 3. Polaroid */
.frame-polaroid {
    background-color: #ffffff;
    padding: 1.5rem 1.5rem 5rem 1.5rem;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
    border: 1px solid #e5e7eb;
    transform: rotate(-1deg);
    /* Slight tilt for realism */
}

.frame-polaroid .frame-content {
    border: 1px solid #f0f0f0;
    padding: 2rem;
    background: #fafafa;
    box-shadow: inset 0 2px 5px rgba(0, 0, 0, 0.05);
}

/* 4. Badge / ID Card */
.frame-badge {
    background: white;
    border-radius: 16px;
    box-shadow: 0 10px 30px -10px rgba(0, 0, 0, 0.2);
    position: relative;
    overflow: hidden;
    border-top: 8px solid var(--primary);
}

.frame-badge::before {
    /* Hole punch */
    content: '';
    position: absolute;
    top: 15px;
    left: 50%;
    transform: translateX(-50%);
    width: 40px;
    height: 6px;
    background: #f3f4f6;
    border-radius: 10px;
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.2);
}

/* 5. Phone Frame */
.frame-phone {
    border: 10px solid #1f2937;
    border-radius: 36px;
    padding: 3rem 1.5rem;
    position: relative;
    box-shadow: 0 20px 40px -10px rgba(0, 0, 0, 0.2);
    background: white;
}

.frame-phone::before {
    /* Notch / Speaker */
    content: '';
    position: absolute;
    top: 12px;
    left: 50%;
    transform: translateX(-50%);
    width: 60px;
    height: 6px;
    background: #1f2937;
    border-radius: 10px;
}

/* 6. Speech Bubble */
.frame-speech {
    border: 4px solid var(--primary);
    border-radius: 24px;
    border-bottom-left-radius: 4px;
    /* Speech bubble tail effect */
    position: relative;
    box-shadow: 0 10px 25px -5px rgba(37, 99, 235, 0.15);
    background: white;
}

.frame-speech .scan-me-arrow {
    display: block;
    position: absolute;
    top: -18px;
    right: 20px;
    background: var(--primary);
    padding: 4px 12px;
    border-radius: 20px;
    color: white;
    font-size: 0.8rem;
    font-weight: 700;
    box-shadow: 0 4px 6px rgba(37, 99, 235, 0.3);
}

.frame-speech h3 {
    margin-top: 10px;
}

/* 7. Brutalism */
.frame-brutalism {
    border: 4px solid #000;
    box-shadow: 8px 8px 0px #000;
    border-radius: 0;
    background: #fff;
}

.frame-brutalism .frame-content {
    background: #fff;
}

.frame-brutalism h3 {
    text-transform: uppercase;
    font-weight: 900;
    letter-spacing: 2px;
    background: #000;
    color: #fff;
    padding: 0.5rem 1rem;
    display: inline-block;
}

/* 8. Neon */
.frame-neon {
    background: #0f0f0f;
    border: 2px solid #ff00ff;
    box-shadow: 0 0 15px rgba(255, 0, 255, 0.5);
    border-radius: 16px;
}

.frame-neon .frame-content {
    background: #0f0f0f;
}

.frame-neon h3 {
    color: #fff;
    text-shadow: 0 0 5px #ff00ff, 0 0 10px #ff00ff;
}

.frame-neon .preview-name {
    color: #fff;
    text-shadow: 0 0 5px #00ffff;
}

/* 9. Sketch */
.frame-sketch {
    border: 3px solid #333;
    border-radius: 2% 6% 5% 4% / 1% 1% 2% 4%;
    background: #fff;
    box-shadow: 2px 3px 15px rgba(0, 0, 0, 0.1);
    position: relative;
}

.frame-sketch::before {
    content: '';
    border: 2px solid rgba(0, 0, 0, 0.1);
    display: block;
    width: 100%;
    height: 100%;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) rotate(1deg);
    border-radius: 2% 6% 5% 4% / 1% 1% 2% 4%;
    z-index: 0;
    pointer-events: none;
}

.frame-sketch .frame-content {
    position: relative;
    z-index: 1;
}

/* 10. Coupon */
.frame-coupon {
    background: #fff;
    border: 2px dashed #9ca3af;
    border-radius: 12px;
    position: relative;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
}

.frame-coupon::before,
.frame-coupon::after {
    content: '';
    position: absolute;
    height: 20px;
    width: 20px;
    background-color: #f3f4f6;
    /* Match page bg if possible, or white/transparent */
    border-radius: 50%;
    top: 50%;
    transform: translateY(-50%);
    /* Since we can't easily match the external background, let's make them look like cutouts with a border */
    border: 2px dashed #9ca3af;
    z-index: 1;
}

.frame-coupon::before {
    left: -12px;
    border-right-color: transparent;
    border-top-color: transparent;
    border-bottom-color: transparent;
    background: white;
    /* Fallback */
}

.frame-coupon::after {
    right: -12px;
    border-left-color: transparent;
    border-top-color: transparent;
    border-bottom-color: transparent;
    background: white;
}

/* 11. Vintage */
.frame-vintage {
    background-color: #fdf6e3;
    border: 8px double #8b4513;
    border-radius: 4px;
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.2);
}

.frame-vintage h3 {
    font-family: 'Courier New', Courier, monospace;
    color: #5d4037;
    text-transform: uppercase;
    letter-spacing: 1px;
    border-bottom: 1px solid #5d4037;
    padding-bottom: 5px;
    display: inline-block;
}

.frame-vintage .preview-name {
    font-family: 'Courier New', Courier, monospace;
    color: #5d4037;
}

/* 12. Terminal */
.frame-terminal {
    background-color: #1e1e1e;
    border: 2px solid #33ff00;
    border-radius: 6px;
    box-shadow: 0 0 10px rgba(51, 255, 0, 0.2);
    color: #33ff00;
}

.frame-terminal .frame-content {
    background-color: #1e1e1e;
}

.frame-terminal h3,
.frame-terminal p,
.frame-terminal .preview-name {
    color: #33ff00 !important;
    font-family: monospace;
}

.frame-terminal h3::before {
    content: '> ';
}

/* 13. Notebook */
.frame-notebook {
    background: #fff;
    background-image: linear-gradient(#e5e7eb 1px, transparent 1px);
    background-size: 100% 24px;
    border: 1px solid #d1d5db;
    box-shadow: 5px 5px 15px rgba(0, 0, 0, 0.1);
    padding-left: 3rem;
    position: relative;
}

.frame-notebook::before {
    content: '';
    position: absolute;
    left: 2.5rem;
    top: 0;
    bottom: 0;
    width: 2px;
    background: #ef4444;
}

.frame-notebook h3 {
    background: white;
    display: inline-block;
    padding: 0 5px;
}

/* 14. Glass */
.frame-glass {
    background: rgba(255, 255, 255, 0.25);
    box-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.37);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.18);
}

.frame-glass .frame-content {
    background: transparent;
}

/* 15. Gold */
.frame-gold {
    background: linear-gradient(to bottom right, #000, #222);
    border: 4px solid transparent;
    border-image: linear-gradient(to bottom right, #bf953f, #fcf6ba, #b38728, #fbf5b7, #aa771c);
    border-image-slice: 1;
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.5);
}

.frame-gold .frame-content {
    background: transparent;
}

.frame-gold h3,
.frame-gold .preview-name {
    color: #fcf6ba;
    text-shadow: 0 2px 2px rgba(0, 0, 0, 0.5);
}

/* 16. Cyber */
.frame-cyber {
    background: #fce300;
    clip-path: polygon(0 0,
            100% 0,
            100% calc(100% - 20px),
            calc(100% - 20px) 100%,
            0 100%);
    padding: 2rem;
    border-right: 5px solid #000;
    border-bottom: 5px solid #000;
}

.frame-cyber .frame-content {
    background: #fce300;
}

.frame-cyber h3 {
    background: #000;
    color: #fce300;
    padding: 5px 10px;
    text-transform: uppercase;
    font-weight: 900;
}

/* 17. Blueprint */
.frame-blueprint {
    background-color: #269;
    background-image: linear-gradient(white 2px, transparent 2px),
        linear-gradient(90deg, white 2px, transparent 2px),
        linear-gradient(rgba(255, 255, 255, .3) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, .3) 1px, transparent 1px);
    background-size: 100px 100px, 100px 100px, 20px 20px, 20px 20px;
    background-position: -2px -2px, -2px -2px, -1px -1px, -1px -1px;
    border: 4px solid white;
    box-shadow: 0 0 0 4px #269;
}

.frame-blueprint .frame-content {
    background: transparent;
}

.frame-blueprint h3,
.frame-blueprint .preview-name {
    color: white;
    font-family: 'Courier New', Courier, monospace;
    text-transform: uppercase;
}

/* 18. Wood */
.frame-wood {
    background: #deb887;
    border: 15px solid #8b4513;
    border-radius: 4px;
    box-shadow: inset 0 0 20px rgba(0, 0, 0, 0.5), 5px 5px 10px rgba(0, 0, 0, 0.3);
}

.frame-wood .frame-content {
    background: #fdf5e6;
    padding: 1.5rem;
    box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.2);
}

/* 19. Rainbow */
.frame-rainbow {
    position: relative;
    background: white;
    border-radius: 10px;
    padding: 5px;
}

.frame-rainbow::before {
    content: "";
    position: absolute;
    top: -4px;
    left: -4px;
    right: -4px;
    bottom: -4px;
    background: linear-gradient(45deg, #ff0000, #ff7300, #fffb00, #48ff00, #00ffd5, #002bff, #7a00ff, #ff00c8, #ff0000);
    z-index: -1;
    border-radius: 14px;
    background-size: 400%;
    animation: glowing 20s linear infinite;
}

@keyframes glowing {
    0% {
        background-position: 0 0;
    }

    50% {
        background-position: 400% 0;
    }

    100% {
        background-position: 0 0;
    }
}

/* 20. Dark */
.frame-dark {
    background: #121212;
    border: 1px solid #333;
    border-radius: 12px;
    color: #e0e0e0;
}

.frame-dark .frame-content {
    background: #121212;
}

.frame-dark h3,
.frame-dark .preview-name {
    color: #e0e0e0;
}

/* 21. Postcard */
.frame-postcard {
    background: #fff;
    border: 1px solid #ddd;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
    position: relative;
    padding-top: 3rem;
}

.frame-postcard::after {
    content: "";
    position: absolute;
    top: 1rem;
    right: 1rem;
    width: 50px;
    height: 60px;
    border: 2px dotted #ccc;
    background: #f9f9f9;
}

/* 22. Sticker */
.frame-sticker {
    background: white;
    padding: 1rem;
    border-radius: 10px;
    border: 8px solid white;
    box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.1), 5px 5px 10px rgba(0, 0, 0, 0.1);
}

/* 23. Gameboy */
.frame-gameboy {
    background: #c0c0c0;
    border-radius: 10px 10px 40px 10px;
    padding: 2rem 1rem 4rem 1rem;
    border: 2px solid #999;
    box-shadow: inset -5px -5px 10px rgba(0, 0, 0, 0.1);
    position: relative;
}

.frame-gameboy .frame-content {
    background: #9ca04c;
    border: 4px solid #555;
    border-radius: 5px;
    padding: 1rem;
    box-shadow: inset 2px 2px 5px rgba(0, 0, 0, 0.2);
}

/* Action Buttons */
.actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    align-items: center;
}

.btn {
    border: none;
    padding: 0.85rem;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    font-size: 1rem;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.5rem;
    transition: transform 0.1s, opacity 0.2s;
    width: 100%;
    text-decoration: none;
    box-sizing: border-box;
}

.btn:active {
    transform: scale(0.98);
}

.btn.primary {
    background-color: var(--primary);
    color: white;
}

.btn.primary:hover {
    background-color: var(--primary-hover);
}

.btn.secondary {
    background-color: white;
    border: 1px solid var(--border);
    color: var(--text-main);
}

.btn.secondary:hover {
    background-color: #f9fafb;
    border-color: #d1d5db;
}

.btn.bmc {
    background-color: #FFDD00;
    color: #000000;
    /* Add a border to match the size of secondary buttons if needed, or keep none */
    border: 1px solid #FFDD00;
}

.btn.bmc:hover {
    background-color: #ffea00;
    border-color: #ffea00;
    opacity: 0.9;
}

/* Responsive */
@media (max-width: 900px) {
    main {
        grid-template-columns: 1fr;
    }

    .sticky-wrapper {
        position: static;
    }

    .github-link {
        top: 0;
        right: 0;
        position: absolute;
        padding: 1rem;
    }
}

/* Print Styling */
@media print {
    body {
        background: white;
        min-height: auto;
    }

    header,
    .controls,
    footer,
    .actions {
        display: none !important;
    }

    .app-container {
        padding: 0;
        margin: 0;
        max-width: none;
    }

    main {
        display: block;
    }

    .preview-area {
        width: 100%;
        height: 100vh;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .capture-container {
        box-shadow: none !important;
        border: none !important;
        transform: scale(1.2);
    }

    .frame-phone {
        border: 8px solid #333 !important;
        -webkit-print-color-adjust: exact;
    }

    .frame-speech {
        border: 4px solid #2563eb !important;
        -webkit-print-color-adjust: exact;
    }

    .scan-me-arrow {
        border: 2px solid #2563eb !important;
    }
}

/* Collapsible Settings */
.collapsible-header {
    cursor: pointer;
    justify-content: space-between;
    user-select: none;
}

.transition-icon {
    transition: transform 0.3s ease;
}

.settings-content {
    overflow: hidden;
    transition: max-height 0.3s ease-out, opacity 0.3s ease-out;
    max-height: 2000px;
    opacity: 1;
}

.settings-content.collapsed {
    max-height: 0;
    opacity: 0;
    margin: 0;
    padding: 0;
    pointer-events: none;
}

.collapsible-header.collapsed .transition-icon {
    transform: rotate(-90deg);
}

/* Footer */
footer {
    margin-top: 4rem;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.9rem;
    padding-bottom: 2rem;
}

footer a {
    color: var(--text-main);
    text-decoration: none;
    border-bottom: 1px dotted var(--text-muted);
    transition: color 0.2s, border-color 0.2s;
}

footer a:hover {
    color: var(--primary);
    border-color: var(--primary);
}

footer .credits {
    margin-top: 0.5rem;
    font-size: 0.8rem;
    opacity: 0.8;
}