/* ========================================
   Variables — Whimsical Fairytale theme
   ======================================== */
:root {
    --bg: linear-gradient(135deg, #eef3ff 0%, #e4edfc 55%, #f7eefc 100%);
    --bg-elevated: #ffffff;
    --bg-subtle: #f3f6fd;
    --text-primary: #3d4663;
    --text-secondary: #8590ad;
    --text-tertiary: #a3acc7;
    --border-color: #d3e0f7;
    --primary: #7b93d6;
    --primary-soft: rgba(123, 147, 214, 0.14);
    --success: #1fae6e;
    --error: #d6364a;
    --error-bg: rgba(214, 54, 74, 0.08);
    --radius: 20px;
    --radius-sm: 14px;
    --transition: all 0.18s ease;
    --shadow-sm: 0 1px 2px rgba(61, 70, 99, 0.06);
    --shadow-md: 0 8px 20px rgba(123, 147, 214, 0.16);

    --icon-gradient: linear-gradient(135deg, #cfe0ff 0%, #e6d9f7 100%);
    --icon-color: #5b6fae;
    --icon-shadow: 0 4px 10px rgba(123, 147, 214, 0.22);

    --btn-gradient: linear-gradient(135deg, #9db8ed 0%, #c3aef0 100%);
    --btn-text: #2c3454;
    --btn-shadow: 0 6px 16px rgba(123, 147, 214, 0.35);

    --card-border: #c3aef0;
    --card-shadow: 0 14px 30px rgba(123, 147, 214, 0.28), 0 2px 6px rgba(123, 147, 214, 0.15);
    --card-shadow-hover: 0 20px 40px rgba(123, 147, 214, 0.38), 0 4px 10px rgba(123, 147, 214, 0.2);

    --ill-url: #3a6fd8;      --ill-bg-url: radial-gradient(circle at 50% 40%, #cfe0ff 0%, #aecbff 70%);
    --ill-text: #6058b0;     --ill-bg-text: radial-gradient(circle at 50% 40%, #e3e6f5 0%, #c7c2ec 70%);
    --ill-email: #d97a3a;    --ill-bg-email: radial-gradient(circle at 50% 40%, #ffe3cf 0%, #ffc89a 70%);
    --ill-phone: #1f8a5c;    --ill-bg-phone: radial-gradient(circle at 50% 40%, #d2f3e2 0%, #a3e6c4 70%);
    --ill-sms: #c23e80;      --ill-bg-sms: radial-gradient(circle at 50% 40%, #ffd2e9 0%, #ffa8d4 70%);
    --ill-wifi: #6a5fc9;     --ill-bg-wifi: radial-gradient(circle at 50% 40%, #d9d4f9 0%, #b9aef0 70%);
    --ill-location: #15876f; --ill-bg-location: radial-gradient(circle at 50% 40%, #c9f1e8 0%, #8fe0cc 70%);
    --ill-vcard: #8540b8;    --ill-bg-vcard: radial-gradient(circle at 50% 40%, #e9d9f7 0%, #cfa3ef 70%);
}

[data-theme="dark"] {
    --bg: linear-gradient(135deg, #1c1c1f 0%, #202023 100%);
    --bg-elevated: #262629;
    --bg-subtle: #2c2c30;
    --text-primary: #ececec;
    --text-secondary: #98979c;
    --text-tertiary: #6f6e73;
    --border-color: #38383c;
    --primary: #9db4f0;
    --primary-soft: rgba(157, 180, 240, 0.14);
    --error-bg: rgba(214, 54, 74, 0.14);
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.4);

    --icon-gradient: linear-gradient(135deg, #5b6fd6 0%, #9a6fd0 100%);
    --icon-color: #ffffff;
    --icon-shadow: 0 0 14px rgba(123, 147, 230, 0.4);

    --btn-gradient: linear-gradient(135deg, #4a5fc4 0%, #9aa0ab 100%);
    --btn-text: #1c1c1f;
    --btn-shadow: 0 6px 18px rgba(74, 95, 196, 0.4);

    --card-border: #3a3a3e;
    --card-shadow: 0 14px 30px rgba(0, 0, 0, 0.4), 0 2px 6px rgba(0, 0, 0, 0.3);
    --card-shadow-hover: 0 20px 40px rgba(0, 0, 0, 0.5), 0 0 24px rgba(123, 147, 230, 0.25);

    --ill-url: #fdf8ee;      --ill-bg-url: radial-gradient(circle at 50% 40%, #3a5fc0 0%, #1f3a82 70%);
    --ill-text: #fdf8ee;     --ill-bg-text: radial-gradient(circle at 50% 40%, #5850a8 0%, #322a6e 70%);
    --ill-email: #fdf8ee;    --ill-bg-email: radial-gradient(circle at 50% 40%, #d97a3a 0%, #a3501c 70%);
    --ill-phone: #fdf8ee;    --ill-bg-phone: radial-gradient(circle at 50% 40%, #1f8a5c 0%, #145c3c 70%);
    --ill-sms: #fdf8ee;      --ill-bg-sms: radial-gradient(circle at 50% 40%, #c23e80 0%, #8a2a5c 70%);
    --ill-wifi: #fdf8ee;     --ill-bg-wifi: radial-gradient(circle at 50% 40%, #6a5fc9 0%, #463c94 70%);
    --ill-location: #fdf8ee; --ill-bg-location: radial-gradient(circle at 50% 40%, #15876f 0%, #0d5c4c 70%);
    --ill-vcard: #fdf8ee;    --ill-bg-vcard: radial-gradient(circle at 50% 40%, #8540b8 0%, #5c2c82 70%);
}

/* ========================================
   Reset & Base
   ======================================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Nunito', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text-primary);
    line-height: 1.5;
    min-height: 100vh;
    transition: background-color 0.2s ease, color 0.2s ease;
}

h1, h2, h3 {
    font-family: 'Quicksand', sans-serif;
    font-weight: 700;
}

button {
    font-family: inherit;
}

.hidden {
    display: none !important;
}

/* ========================================
   Top Bar — full width
   ======================================== */
.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 32px;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-elevated);
    position: relative;
    overflow: hidden;
}

/* slow light sweep across the bar */
.topbar::before {
    content: '';
    position: absolute;
    top: 0;
    left: -60%;
    width: 50%;
    height: 100%;
    background: linear-gradient(90deg, transparent, var(--primary-soft), transparent);
    animation: navShimmer 6s ease-in-out infinite;
    pointer-events: none;
}

@keyframes navShimmer {
    0%   { left: -60%; }
    50%  { left: 110%; }
    100% { left: 110%; }
}

.brand {
    display: flex;
    align-items: center;
    gap: 9px;
    position: relative;
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px 2px;
}

.brand-icon {
    width: 30px;
    height: 30px;
    border-radius: 9px;
    background: var(--icon-gradient, var(--btn-gradient));
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 10px rgba(123, 147, 214, 0.4);
    animation: brandBob 2.6s ease-in-out infinite;
}

@keyframes brandBob {
    0%, 100% { transform: translateY(0) rotate(0deg); }
    50%      { transform: translateY(-3px) rotate(-5deg); }
}

.brand-text {
    font-family: 'Quicksand', sans-serif;
    font-size: 17px;
    font-weight: 700;
    letter-spacing: 0.3px;
    background: linear-gradient(100deg, var(--text-primary) 0%, var(--primary) 35%, var(--text-primary) 70%);
    background-size: 220% auto;
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    animation: brandGradient 5s ease-in-out infinite;
}

@keyframes brandGradient {
    0%   { background-position: 0% center; }
    100% { background-position: 220% center; }
}

.brand-sparkle {
    position: absolute;
    top: -4px;
    right: -14px;
    font-size: 12px;
    color: #f0c869;
    animation: brandTwinkle 2.2s ease-in-out infinite;
}

@keyframes brandTwinkle {
    0%, 100% { opacity: 0.3; transform: scale(0.8); }
    50%      { opacity: 1; transform: scale(1.15); }
}

#themeToggle {
    background: var(--bg-subtle);
    border: 1px solid var(--border-color);
    border-radius: 50%;
    width: 38px;
    height: 38px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), border-color 0.2s ease, color 0.2s ease, box-shadow 0.2s ease;
}

#themeToggle:hover {
    border-color: var(--primary);
    color: var(--primary);
    transform: rotate(18deg) scale(1.08);
    box-shadow: 0 4px 12px var(--primary-soft);
}

[data-theme="light"] .moon-icon,
[data-theme="dark"] .sun-icon {
    display: none;
}

/* ========================================
   View containers — full width, max-width inner
   ======================================== */
.view {
    width: 100%;
    min-height: calc(100vh - 75px);
}

/* ========================================
   Landing View
   ======================================== */
.landing-inner {
    max-width: 1100px;
    margin: 0 auto;
    padding: 56px 32px 80px;
}

.landing-intro {
    text-align: center;
    margin-bottom: 40px;
}

.landing-intro h1 {
    font-size: 30px;
    margin-bottom: 10px;
    letter-spacing: 0.3px;
}

.landing-intro p {
    color: var(--text-secondary);
    font-size: 15px;
}

/* Flex + wrap + center, so the last (odd) row centers itself
   instead of being left-aligned and orphaned-looking */
.type-grid {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 26px;
}

.type-card {
    display: flex;
    flex-direction: column;
    width: 310px;
    text-align: left;
    border: 2px solid var(--card-border);
    border-radius: 26px;
    background: var(--bg-elevated);
    cursor: pointer;
    transition: var(--transition);
    font-family: inherit;
    overflow: hidden;
    padding: 0;
    box-shadow: var(--card-shadow);
}

.type-card:hover {
    transform: translateY(-4px) scale(1.015);
    box-shadow: var(--card-shadow-hover);
}

.type-illustration {
    position: relative;
    height: 165px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.sparkle {
    position: absolute;
    color: #f0c869;
    z-index: 2;
}

.sparkle.s1 { top: 16px; left: 26px; font-size: 17px; }
.sparkle.s2 { bottom: 20px; right: 28px; font-size: 13px; }

.type-card-body {
    padding: 18px 20px 22px;
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.type-card-title {
    font-family: 'Quicksand', sans-serif;
    font-size: 16px;
    font-weight: 700;
    color: var(--text-primary);
}

.type-card-desc {
    font-size: 13px;
    color: var(--text-tertiary);
    line-height: 1.4;
}

.ill-url      { background: var(--ill-bg-url);      color: var(--ill-url); }
.ill-text     { background: var(--ill-bg-text);     color: var(--ill-text); }
.ill-email    { background: var(--ill-bg-email);    color: var(--ill-email); }
.ill-phone    { background: var(--ill-bg-phone);    color: var(--ill-phone); }
.ill-sms      { background: var(--ill-bg-sms);      color: var(--ill-sms); }
.ill-wifi     { background: var(--ill-bg-wifi);     color: var(--ill-wifi); }
.ill-location { background: var(--ill-bg-location); color: var(--ill-location); }
.ill-vcard    { background: var(--ill-bg-vcard);    color: var(--ill-vcard); }

/* ========================================
   Generator View
   ======================================== */
.generator-topline {
    padding: 18px 32px 0;
}

.back-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    padding: 8px 0;
    transition: var(--transition);
}

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

.generator-stage {
    display: flex;
    justify-content: center;
    padding: 24px 32px 80px;
    min-height: calc(100vh - 140px);
}

.generator-stage.has-result {
    display: grid;
    grid-template-columns: minmax(320px, 460px) 1fr;
    gap: 40px;
    max-width: 1280px;
    margin: 0 auto;
    align-items: start;
}

.form-pane {
    width: 100%;
    max-width: 460px;
}

.generator-stage:not(.has-result) .form-pane {
    margin: 0 auto;
}

.generator-intro {
    margin-bottom: 24px;
}

.generator-intro h2 {
    font-size: 21px;
    margin-bottom: 6px;
}

.generator-intro p {
    color: var(--text-secondary);
    font-size: 13.5px;
}

.result-pane {
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-elevated);
    border: 1.5px solid var(--border-color);
    border-radius: var(--radius);
    padding: 48px;
    min-height: 420px;
}

#qrImage {
    max-width: 100%;
    width: 320px;
    height: auto;
    border-radius: 8px;
}

/* ========================================
   Form Elements
   ======================================== */
.input-group {
    margin-bottom: 18px;
}

.field {
    margin-bottom: 14px;
}

.field:last-child {
    margin-bottom: 0;
}

.optional-tag {
    font-size: 10px;
    font-weight: 500;
    color: var(--text-tertiary);
    text-transform: none;
    letter-spacing: 0;
    margin-left: 4px;
}

.checkbox-field {
    display: flex;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
}

.checkbox-label input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--primary);
    cursor: pointer;
}

label {
    display: block;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 6px;
    font-size: 12.5px;
}

input[type="text"],
textarea,
select {
    width: 100%;
    padding: 11px 14px;
    border: 1.5px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 14px;
    color: var(--text-primary);
    background: var(--bg-elevated);
    transition: var(--transition);
    font-family: inherit;
    resize: vertical;
}

select {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1L6 6L11 1' stroke='%238590ad' stroke-width='1.6' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
    padding-right: 36px;
}

input[type="text"]:focus,
textarea:focus,
select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-soft);
}

textarea {
    min-height: 80px;
}

.char-counter {
    text-align: right;
    font-size: 11px;
    color: var(--text-tertiary);
    margin-top: 4px;
}

.btn-link {
    background: none;
    border: none;
    color: var(--primary);
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    padding: 4px 0;
    text-align: left;
}

.btn-link:hover {
    text-decoration: underline;
}

/* ========================================
   Buttons
   ======================================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 13px 28px;
    border: none;
    border-radius: 999px;
    font-size: 13.5px;
    font-weight: 700;
    cursor: pointer;
    transition: var(--transition);
    font-family: 'Quicksand', sans-serif;
}

.btn-primary {
    background: var(--btn-gradient);
    color: var(--btn-text);
    width: 100%;
    margin-top: 6px;
    box-shadow: var(--btn-shadow);
}

.btn-primary:hover:not(:disabled) {
    transform: translateY(-1px);
    filter: brightness(1.05);
}

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

.btn-secondary {
    background: var(--bg-subtle);
    color: var(--text-primary);
    border: 1.5px solid var(--border-color);
    flex: 1;
}

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

/* ========================================
   Error Message
   ======================================== */
.error-message {
    background: var(--error-bg);
    color: var(--error);
    padding: 12px 14px;
    border-radius: var(--radius-sm);
    margin-bottom: 14px;
    font-size: 13px;
    font-weight: 600;
    border: 1px solid var(--error);
}

/* ========================================
   Result Details (left pane, post-generation)
   ======================================== */
.result-details {
    margin-top: 24px;
    padding-top: 20px;
    border-top: 1px solid var(--border-color);
}

.encoded-label {
    display: block;
    font-size: 11px;
    font-weight: 700;
    color: var(--primary);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 8px;
}

.encoded-content {
    font-family: 'Courier New', monospace;
    font-size: 12.5px;
    color: var(--text-secondary);
    word-break: break-all;
    line-height: 1.6;
    background: var(--bg-subtle);
    padding: 12px 14px;
    border-radius: var(--radius-sm);
    margin-bottom: 16px;
    max-height: 120px;
    overflow-y: auto;
}

.download-row {
    display: flex;
    gap: 10px;
    margin-bottom: 16px;
}

/* ========================================
   Responsive
   ======================================== */
@media (max-width: 900px) {
    .generator-stage.has-result {
        grid-template-columns: 1fr;
        gap: 24px;
    }

    .form-pane {
        max-width: none;
    }
}

@media (max-width: 640px) {
    .topbar {
        padding: 14px 20px;
    }

    .landing-inner {
        padding: 32px 20px 60px;
    }

    .landing-intro h1 {
        font-size: 24px;
    }

    .type-card {
        width: 100%;
        max-width: 360px;
    }

    .generator-topline,
    .generator-stage {
        padding-left: 20px;
        padding-right: 20px;
    }

    .download-row {
        flex-wrap: wrap;
    }
}