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

:root {
    --primary: #8b5cf6;
    --primary-light: #a78bfa;
    --primary-dark: #7c3aed;
    --primary-glow: rgba(139, 92, 246, 0.35);
    --accent: #06b6d4;
    --bg-dark: #0f0f1a;
    --bg-card: rgba(255, 255, 255, 0.04);
    --bg-card-hover: rgba(255, 255, 255, 0.07);
    --surface: #1a1a2e;
    --surface-light: #25253d;
    --text-primary: #f1f0f5;
    --text-secondary: #a0a0b8;
    --text-muted: #6b6b80;
    --border: rgba(255, 255, 255, 0.08);
    --border-focus: rgba(139, 92, 246, 0.5);
    --radius-sm: 8px;
    --radius-md: 14px;
    --radius-lg: 20px;
    --radius-xl: 28px;
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.2);
    --shadow-md: 0 8px 30px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 20px 60px rgba(0, 0, 0, 0.4);
    --shadow-glow: 0 0 40px var(--primary-glow);
    --transition-fast: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-smooth: 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-bounce: 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
    --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

/* ===== Base ===== */
html {
    height: 100%;
}

body {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: var(--bg-dark);
    font-family: var(--font);
    color: var(--text-primary);
    overflow-x: hidden;
    position: relative;
}

/* ===== Animated Background ===== */
.bg-particles {
    position: fixed;
    inset: 0;
    z-index: 0;
    overflow: hidden;
    pointer-events: none;
}

.particle {
    position: absolute;
    border-radius: 50%;
    opacity: 0.12;
    animation: float linear infinite;
}

.particle:nth-child(1) {
    width: 300px;
    height: 300px;
    background: var(--primary);
    top: -100px;
    left: -80px;
    animation-duration: 20s;
    filter: blur(80px);
}

.particle:nth-child(2) {
    width: 250px;
    height: 250px;
    background: var(--accent);
    bottom: -80px;
    right: -60px;
    animation-duration: 25s;
    animation-delay: -5s;
    filter: blur(70px);
}

.particle:nth-child(3) {
    width: 180px;
    height: 180px;
    background: #ec4899;
    top: 50%;
    right: 20%;
    animation-duration: 18s;
    animation-delay: -3s;
    filter: blur(60px);
}

.particle:nth-child(4) {
    width: 120px;
    height: 120px;
    background: var(--primary-light);
    top: 30%;
    left: 15%;
    animation-duration: 22s;
    animation-delay: -8s;
    filter: blur(50px);
}

.particle:nth-child(5) {
    width: 200px;
    height: 200px;
    background: var(--accent);
    top: 10%;
    right: 10%;
    animation-duration: 28s;
    animation-delay: -12s;
    filter: blur(70px);
    opacity: 0.08;
}

.particle:nth-child(6) {
    width: 150px;
    height: 150px;
    background: #8b5cf6;
    bottom: 20%;
    left: 30%;
    animation-duration: 24s;
    animation-delay: -7s;
    filter: blur(60px);
    opacity: 0.1;
}

@keyframes float {
    0%, 100% {
        transform: translate(0, 0) scale(1);
    }
    25% {
        transform: translate(40px, -60px) scale(1.1);
    }
    50% {
        transform: translate(-30px, 40px) scale(0.95);
    }
    75% {
        transform: translate(50px, 20px) scale(1.05);
    }
}

/* ===== Container Card ===== */
.container {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 460px;
    background: var(--bg-card);
    backdrop-filter: blur(24px) saturate(1.4);
    -webkit-backdrop-filter: blur(24px) saturate(1.4);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    padding: 40px 36px;
    margin: 40px 20px;
    box-shadow: var(--shadow-lg);
    transition: var(--transition-smooth);
    animation: card-enter 0.8s cubic-bezier(0.16, 1, 0.3, 1) both;
}

.container:hover {
    border-color: rgba(139, 92, 246, 0.15);
    box-shadow: var(--shadow-lg), var(--shadow-glow);
}

@keyframes card-enter {
    from {
        opacity: 0;
        transform: translateY(30px) scale(0.97);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* ===== Header ===== */
header {
    text-align: center;
    margin-bottom: 32px;
}

.logo {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 64px;
    height: 64px;
    border-radius: var(--radius-md);
    background: linear-gradient(135deg, var(--primary), var(--accent));
    color: white;
    margin-bottom: 20px;
    box-shadow: 0 8px 24px rgba(139, 92, 246, 0.3);
    animation: logo-pulse 3s ease-in-out infinite;
}

@keyframes logo-pulse {
    0%, 100% {
        box-shadow: 0 8px 24px rgba(139, 92, 246, 0.3);
    }
    50% {
        box-shadow: 0 8px 36px rgba(139, 92, 246, 0.5);
    }
}

header h1 {
    font-size: 1.85rem;
    font-weight: 800;
    letter-spacing: -0.03em;
    line-height: 1.2;
    color: var(--text-primary);
}

.gradient-text {
    background: linear-gradient(135deg, var(--primary-light), var(--accent));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.subtitle {
    margin-top: 8px;
    font-size: 0.92rem;
    color: var(--text-secondary);
    font-weight: 400;
    line-height: 1.5;
}

/* ===== Form ===== */
.form {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.input-icon {
    position: absolute;
    left: 16px;
    color: var(--text-muted);
    transition: color var(--transition-fast);
    flex-shrink: 0;
}

.input-wrapper:focus-within .input-icon {
    color: var(--primary-light);
}

.form input {
    width: 100%;
    height: 54px;
    padding: 0 42px 0 48px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--surface);
    color: var(--text-primary);
    font-size: 0.95rem;
    font-family: var(--font);
    outline: none;
    transition: all var(--transition-fast);
}

.form input::placeholder {
    color: var(--text-muted);
    font-weight: 400;
}

.form input:focus {
    border-color: var(--border-focus);
    background: var(--surface-light);
    box-shadow: 0 0 0 4px rgba(139, 92, 246, 0.1);
}

.form input.error {
    border-color: #ef4444;
    box-shadow: 0 0 0 4px rgba(239, 68, 68, 0.1);
    animation: shake 0.5s ease-in-out;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    20% { transform: translateX(-6px); }
    40% { transform: translateX(6px); }
    60% { transform: translateX(-4px); }
    80% { transform: translateX(4px); }
}

.clear-btn {
    position: absolute;
    right: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border: none;
    border-radius: 50%;
    background: var(--surface-light);
    color: var(--text-muted);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.clear-btn:hover {
    background: rgba(239, 68, 68, 0.15);
    color: #ef4444;
}

/* ===== Generate Button ===== */
.generate-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    height: 54px;
    border: none;
    border-radius: var(--radius-md);
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
    font-size: 1rem;
    font-weight: 600;
    font-family: var(--font);
    cursor: pointer;
    position: relative;
    overflow: hidden;
    transition: all var(--transition-fast);
    box-shadow: 0 4px 16px rgba(139, 92, 246, 0.3);
}

.generate-btn::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, transparent, rgba(255, 255, 255, 0.1), transparent);
    transform: translateX(-100%);
    transition: transform 0.6s ease;
}

.generate-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 28px rgba(139, 92, 246, 0.45);
}

.generate-btn:hover::before {
    transform: translateX(100%);
}

.generate-btn:active {
    transform: translateY(0);
    box-shadow: 0 2px 10px rgba(139, 92, 246, 0.3);
}

.generate-btn.loading {
    pointer-events: none;
    opacity: 0.85;
}

.generate-btn.loading .btn-icon {
    animation: spin 1s linear infinite;
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* ===== QR Code Output ===== */
.qr-code {
    max-height: 0;
    opacity: 0;
    overflow: hidden;
    margin-top: 0;
    transition: max-height 0.6s cubic-bezier(0.4, 0, 0.2, 1),
                opacity 0.4s ease 0.1s,
                margin-top 0.4s ease;
}

.container.active .qr-code {
    max-height: 400px;
    opacity: 1;
    margin-top: 28px;
}

.qr-code-inner {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 28px;
    border-radius: var(--radius-md);
    background: #ffffff;
    border: 1px solid rgba(0, 0, 0, 0.06);
    box-shadow: var(--shadow-sm);
}

.qr-code img {
    width: 200px;
    height: 200px;
    object-fit: contain;
    border-radius: 4px;
}

.download-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    height: 44px;
    margin-top: 14px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-md);
    background: transparent;
    color: var(--text-secondary);
    font-size: 0.88rem;
    font-weight: 500;
    font-family: var(--font);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.download-btn:hover {
    border-color: var(--primary);
    color: var(--primary-light);
    background: rgba(139, 92, 246, 0.06);
}

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

/* ===== Footer ===== */
footer {
    position: relative;
    z-index: 1;
    padding: 20px;
    text-align: center;
}

footer p {
    font-size: 0.82rem;
    color: var(--text-muted);
    font-weight: 400;
}

footer a {
    color: var(--primary-light);
    text-decoration: none;
    font-weight: 500;
    transition: color var(--transition-fast);
}

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

.heart {
    color: #ef4444;
    display: inline-block;
    animation: heartbeat 1.5s ease-in-out infinite;
}

@keyframes heartbeat {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.2); }
}

/* ===== Responsive ===== */
@media (max-width: 520px) {
    .container {
        margin: 24px 16px;
        padding: 32px 24px;
        border-radius: var(--radius-lg);
    }

    header h1 {
        font-size: 1.5rem;
    }

    .subtitle {
        font-size: 0.85rem;
    }

    .logo {
        width: 56px;
        height: 56px;
    }

    .logo svg {
        width: 32px;
        height: 32px;
    }

    .form input,
    .generate-btn {
        height: 50px;
        font-size: 0.9rem;
    }

    .qr-code img {
        width: 170px;
        height: 170px;
    }

    .qr-code-inner {
        padding: 24px;
    }
}

@media (max-width: 360px) {
    .container {
        padding: 24px 18px;
    }

    header h1 {
        font-size: 1.3rem;
    }
}

/* ===== Accessibility ===== */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* ===== Selection ===== */
::selection {
    background: rgba(139, 92, 246, 0.3);
    color: white;
}

/* ===== Scrollbar ===== */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: var(--bg-dark);
}

::-webkit-scrollbar-thumb {
    background: var(--surface-light);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--primary);
}