@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;800&display=swap');

:root {
    --primary-gradient: linear-gradient(135deg, #10b981 0%, #3b82f6 100%);
    --bg-color: #0f172a;
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --card-bg: rgba(30, 41, 59, 0.7);
    --panel-bg: rgba(22, 32, 50, 0.7);
    /* Distinct darker color for panels */
    --border-color: rgba(255, 255, 255, 0.06);
    --glass-blur: 20px;
    --accent: #10b981;
    --primary-color: #3b82f6;
    --cyan: #06b6d4;
    --input-bg: rgba(0, 0, 0, 0.3);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Outfit', sans-serif;
}

html {
    overflow-x: hidden;
    width: 100%;
}

body {
    background: var(--bg-color);
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: center;
    padding: 40px 20px;
    position: relative;
    overflow-x: hidden;
    width: 100%;
}

.bg-blobs {
    position: absolute;
    width: 100%;
    height: 100%;
    z-index: -1;
    overflow: hidden;
}

.blob {
    position: absolute;
    width: 600px;
    height: 600px;
    background: var(--primary-gradient);
    filter: blur(80px);
    border-radius: 50%;
    opacity: 0.12;
}

.blob-1 {
    top: -10%;
    right: -10%;
}

.blob-2 {
    bottom: -10%;
    left: -10%;
    animation-delay: -5s;
}

.calculator-card {
    background: var(--card-bg);
    backdrop-filter: blur(var(--glass-blur));
    -webkit-backdrop-filter: blur(var(--glass-blur));
    border: 1px solid var(--border-color);
    border-radius: 20px;
    padding: 40px;
    width: 100%;
    max-width: 900px;
    box-shadow: 0 30px 60px rgba(0, 0, 0, 0.4);
    display: flex;
    flex-direction: column;
    gap: 30px;
    z-index: 10;
}

header {
    text-align: center;
    margin-bottom: 5px;
}

header h1 {
    font-size: 2.2rem;
    font-weight: 800;
    color: var(--cyan);
    margin-bottom: 5px;
}

header p {
    color: var(--text-secondary);
    font-size: 0.95rem;
}

.app-container {
    display: flex;
    justify-content: center;
    width: 100%;
}

/* Main Card: column flex - full-width nav on top, then side-by-side row below */
.config-panel {
    background: var(--panel-bg);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    padding: 30px;
    display: flex;
    flex-direction: column;
    gap: 24px;
    width: 100%;
    max-width: 900px;
}

/* Horizontal row holding panel-left + output-panel */
.panel-row {
    display: flex;
    gap: 30px;
    align-items: flex-start;
    width: 100%;
}

/* Left: Inputs & Design section */
.panel-left {
    max-width: 500px;
    width: 100%;
    flex: 1;
}

/* Right: QR output, sticky scroll */
.output-panel {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    gap: 20px;
    padding: 0;
    border: none;
    position: sticky;
    top: 30px;
    flex-shrink: 0;
    align-self: flex-start;
    background: var(--card-bg);
    backdrop-filter: blur(var(--glass-blur));
    -webkit-backdrop-filter: blur(var(--glass-blur));
    border: 1px solid var(--border-color);
    border-radius: 24px;
    padding: 30px;
    z-index: 10;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.4);
}

.preview-header {
    width: 100%;
    text-align: center;
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 2px;
    margin-bottom: 5px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
}

.preview-header i {
    color: var(--accent);
    font-size: 0.8rem;
}

.preview-container {
    background: transparent;
    /* Remove background, frame will handle it */
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    aspect-ratio: 1;
    margin: 0 auto;
    flex-shrink: 0;
    position: relative;
    overflow: hidden;
    /* Contain frame overflows */
}

/* SVG Frame Wrapper styles */
.qr-wrapper {
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    width: 300px;
    /* Standardize size */
    height: 300px;
    z-index: 1;
    overflow: visible;
}

#qr-code {
    position: relative;
    z-index: 2;
    background: transparent;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    height: 100%;
}

#qr-code canvas,
#qr-code svg {
    max-width: 100% !important;
    max-height: 100% !important;
    height: auto !important;
    width: 100% !important;
    object-fit: contain;
}

.primary-btn {
    margin-top: 30px;
    width: 100%;
    background: var(--primary-gradient);
    color: white;
    border: none;
    padding: 12px;
    border-radius: 8px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.primary-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 20px rgba(16, 185, 129, 0.2);
}

/* Form Element Globals */
input[type="text"],
input[type="tel"],
input[type="email"],
textarea,
select {
    width: 100%;
    background: var(--input-bg);
    border: 1px solid rgba(255, 255, 255, 0.05);
    color: white;
    padding: 14px 16px;
    border-radius: 8px;
    font-size: 0.95rem;
    outline: none;
    transition: border-color 0.3s, background 0.3s;
    margin-bottom: 20px;
    margin-top: 8px;
}

textarea {
    resize: vertical;
    min-height: 100px;
}

input:focus,
textarea:focus,
select:focus {
    border-color: rgba(255, 255, 255, 0.2);
    background: rgba(0, 0, 0, 0.4);
}

select option {
    background: var(--bg-color);
    color: white;
}

label {
    font-size: 0.85rem;
    color: var(--text-primary);
    font-weight: 600;
}

/* Content Type Navigation (Full-width pill bar at top) */
.content-type-nav {
    display: flex;
    flex-wrap: wrap;
    background: var(--input-bg);
    border-radius: 10px;
    padding: 6px;
    gap: 4px;
}

.nav-btn {
    flex: 0 0 auto;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    padding: 10px 16px;
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 6px;
}

.nav-btn:hover {
    color: white;
}

.nav-btn.active {
    background: rgba(255, 255, 255, 0.08);
    /* slight grey highlight */
    color: white;
}

/* Input Groups */
.input-group {
    display: none;
    animation: fadeIn 0.3s ease;
}

.input-group.active {
    display: block;
}

.grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.help-text {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
    margin-top: -0.25rem;
}

/* Design Section */
.design-section {
    margin-top: 1.5rem;
}

.design-section h3 {
    margin-bottom: 16px;
    font-size: 1.05rem;
    color: white;
    font-weight: 700;
}

/* Design Tabs (Pill style) */
.design-tabs {
    display: flex;
    background: var(--input-bg);
    border-radius: 8px;
    padding: 6px;
    gap: 4px;
    margin-bottom: 24px;
}

.tab-btn {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    padding: 10px;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.85rem;
    transition: all 0.2s ease;
}

.tab-btn:hover {
    color: white;
}

.tab-btn.active {
    background: rgba(255, 255, 255, 0.1);
    color: white;
}

.tab-pane {
    display: none;
    animation: fadeIn 0.3s ease;
}

.tab-pane.active {
    display: block;
}

/* Style Grids Option Tiles */
.style-grid,
.frame-grid,
.logo-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 25px;
    margin-top: 10px;
}

.style-option,
.logo-option {
    background: white;
    border: 2px solid var(--border-color);
    border-radius: 10px;
    width: 72px;
    height: 72px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    overflow: hidden;
    transition: all 0.2s ease;
}

.style-option canvas,
.style-option svg {
    width: 100% !important;
    height: 100% !important;
    display: block;
}

.frame-option {
    background: var(--input-bg);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 10px 16px;
    font-size: 0.95rem;
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    color: white;
    transition: all 0.2s ease;
}


.frame-option.active,
.style-option.active,
.logo-option.active {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.4);
    outline: none;
}

.frame-option.active i,
.style-option.active i,
.logo-option.active i {
    color: var(--accent);
}

.frame-input {
    width: 100%;
    padding: 12px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    color: white;
    font-family: inherit;
    font-size: 14px;
    margin-top: 8px;
    margin-bottom: 15px;
    transition: all 0.3s ease;
}

.frame-input:focus {
    outline: none;
    border-color: var(--accent);
    background: rgba(255, 255, 255, 0.1);
}

/* Color Pickers */
.color-picker-group {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
    margin-bottom: 1.5rem;
}

.color-picker-group input[type="color"] {
    width: 100%;
    height: 44px;
    padding: 0;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    background: none;
    margin-top: 8px;
}

.color-picker-group input[type="color"]::-webkit-color-swatch-wrapper {
    padding: 0;
}

.color-picker-group input[type="color"]::-webkit-color-swatch {
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
}

/* Frame specific classes added by JS */
.qr-wrapper svg.frame-svg {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 1;
    pointer-events: none;
    width: 130%;
    /* Allow frames to be slightly larger than the wrapper */
    height: 130%;
}

.qr-wrapper.qr-frame-none svg.frame-svg {
    display: none;
}

/* Frame specific classes added by JS */
.qr-wrapper svg.frame-svg {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 1;
    pointer-events: none;
    width: 100%;
    height: 100%;
}

.qr-wrapper.qr-frame-none {
    background: #ffffff;
    border-radius: 12px;
    padding: 15px;
}

.qr-wrapper.qr-frame-none #qr-code {
    transform: scale(1) !important;
}

/* Fix for Bubble clipping */
.qr-wrapper.qr-frame-bubble #qr-code {
    clip-path: circle(50% at 50% 50%);
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(5px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@media (max-width: 900px) {
    .config-panel {
        flex-direction: column;
        align-items: center;
        gap: 30px;
        padding: 24px;
    }

    .panel-left {
        max-width: 100%;
    }

    .output-panel {
        position: static;
        width: 100%;
        max-width: 320px;
        height: auto;
        padding: 40px 0 0 0;
        border-left: none;
        border-top: 1px solid rgba(255, 255, 255, 0.08);
        /* Horizontal Separator on mobile */
        gap: 20px;
    }
}