/* ============================================
   QaskMe – Global Styles
   Dark/Light mode, card-based UI, event vibes
   ============================================ */

:root {
    /* Shared tokens */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;
    --radius-full: 9999px;
    --font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --transition: 0.2s ease;

    --accent-primary: #2563eb;
    --accent-light: #3b82f6;
    --accent-cyan: #06b6d4;
    --accent-green: #22d3ee;
    --accent-neon: #00ff88;
    --accent-pink: #ec4899;

    --gradient-primary: linear-gradient(135deg, #1e40af, #2563eb);
    --gradient-glow: linear-gradient(135deg, #2563eb, #06b6d4);
    --gradient-neon: linear-gradient(135deg, #00ff88, #06b6d4);
    --gradient-warm: linear-gradient(135deg, #ec4899, #8b5cf6);
}

/* ---- Dark mode (default) ---- */
:root, [data-theme="dark"] {
    --bg-primary: #060d1a;
    --bg-secondary: #0b1628;
    --bg-card: #15274d;
    --bg-card-hover: #1b3060;
    --bg-input: #091322;

    --text-primary: #f1f5f9;
    --text-secondary: #adbdd8;
    --text-muted: #7088b0;

    --glow-primary: 0 0 20px rgba(37, 99, 235, 0.3);
    --glow-cyan: 0 0 20px rgba(6, 182, 212, 0.3);
    --glow-neon: 0 0 20px rgba(0, 255, 136, 0.3);

    --border-color: rgba(255, 255, 255, 0.13);
    --border-active: rgba(37, 99, 235, 0.5);

    --color-scheme: dark;
}

/* ---- Light mode ---- */
[data-theme="light"] {
    --bg-primary: #edf1f7;
    --bg-secondary: #dae1ed;
    --bg-card: #ffffff;
    --bg-card-hover: #f5f7fa;
    --bg-input: #f1f5f9;

    --text-primary: #0c1425;
    --text-secondary: #3d4f68;
    --text-muted: #6a7d9b;

    --glow-primary: 0 0 20px rgba(37, 99, 235, 0.15);
    --glow-cyan: 0 0 20px rgba(6, 182, 212, 0.15);
    --glow-neon: 0 0 20px rgba(0, 255, 136, 0.15);

    --border-color: rgba(0, 0, 0, 0.13);
    --border-active: rgba(37, 99, 235, 0.4);

    --card-shadow: 0 1px 4px rgba(0, 0, 0, 0.08), 0 2px 8px rgba(0, 0, 0, 0.04);

    --color-scheme: light;
}

/* Apply system preference when no explicit theme set */
@media (prefers-color-scheme: light) {
    :root:not([data-theme]) {
        --bg-primary: #edf1f7;
        --bg-secondary: #dae1ed;
        --bg-card: #ffffff;
        --bg-card-hover: #f5f7fa;
        --bg-input: #f1f5f9;

        --text-primary: #0c1425;
        --text-secondary: #3d4f68;
        --text-muted: #6a7d9b;

        --glow-primary: 0 0 20px rgba(37, 99, 235, 0.15);
        --glow-cyan: 0 0 20px rgba(6, 182, 212, 0.15);
        --glow-neon: 0 0 20px rgba(0, 255, 136, 0.15);

        --border-color: rgba(0, 0, 0, 0.13);
        --border-active: rgba(37, 99, 235, 0.4);

        --card-shadow: 0 1px 4px rgba(0, 0, 0, 0.08), 0 2px 8px rgba(0, 0, 0, 0.04);

        --color-scheme: light;
    }
}

/* Theme overrides */
body.theme-festival {
    --accent-primary: #f59e0b;
    --accent-light: #fbbf24;
    --gradient-primary: linear-gradient(135deg, #d97706, #f59e0b);
    --gradient-glow: linear-gradient(135deg, #f59e0b, #ec4899);
}
body.theme-church {
    --accent-primary: #4f46e5;
    --accent-light: #6366f1;
    --gradient-primary: linear-gradient(135deg, #4338ca, #6366f1);
}
[data-theme="dark"] body.theme-church,
:root:not([data-theme]) body.theme-church {
    --bg-primary: #0a1020;
}
body.theme-stream {
    --accent-primary: #10b981;
    --accent-light: #34d399;
    --gradient-primary: linear-gradient(135deg, #059669, #10b981);
    --gradient-glow: linear-gradient(135deg, #10b981, #06b6d4);
}

/* ---- Theme toggle button ---- */
.theme-toggle {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-full);
    width: 38px;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all var(--transition);
    padding: 0;
    color: var(--text-secondary);
    flex-shrink: 0;
}

.theme-toggle:hover {
    border-color: var(--border-active);
    color: var(--text-primary);
    transform: scale(1.05);
}

.theme-toggle .icon-sun,
.theme-toggle .icon-moon,
.theme-toggle .icon-system {
    display: none;
    width: 18px;
    height: 18px;
}

/* Show correct icon based on current state */
[data-theme="dark"] .theme-toggle .icon-sun {
    display: block;
}
[data-theme="light"] .theme-toggle .icon-moon {
    display: block;
}
/* Fallback: when no explicit theme, show sun (assumes dark default) */
:root:not([data-theme]) .theme-toggle .icon-sun {
    display: block;
}
@media (prefers-color-scheme: light) {
    :root:not([data-theme]) .theme-toggle .icon-sun {
        display: none;
    }
    :root:not([data-theme]) .theme-toggle .icon-moon {
        display: block;
    }
}

/* Presentation toggle button */
.presentation-toggle {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-full);
    width: 38px;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all var(--transition);
    padding: 0;
    color: var(--text-secondary);
    flex-shrink: 0;
}
.presentation-toggle:hover {
    border-color: var(--border-active);
    color: var(--text-primary);
    transform: scale(1.05);
}
.presentation-toggle svg {
    width: 18px;
    height: 18px;
}

/* Light mode: adjust logo text to stay vibrant */
[data-theme="light"] .logo-text {
    --gradient-primary: linear-gradient(135deg, #1e40af, #2563eb);
}

/* Light mode: QR box doesn't need white bg */
[data-theme="light"] .qr-box {
    background: #f8fafc;
    border: 1px solid var(--border-color);
}

/* Light mode: shadow on cards instead of border glow */
[data-theme="light"] .btn-primary:hover:not(:disabled) {
    box-shadow: 0 4px 15px rgba(37, 99, 235, 0.3);
}

/* Smooth transition for theme changes */
html.theme-transitioning,
html.theme-transitioning *,
html.theme-transitioning *::before,
html.theme-transitioning *::after {
    transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease !important;
}

/* System default light mode QR box */
@media (prefers-color-scheme: light) {
    :root:not([data-theme]) .qr-box {
        background: #f8fafc;
        border: 1px solid var(--border-color);
    }
    :root:not([data-theme]) .logo-text {
        --gradient-primary: linear-gradient(135deg, #1e40af, #2563eb);
    }
    :root:not([data-theme]) .btn-primary:hover:not(:disabled) {
        box-shadow: 0 4px 15px rgba(37, 99, 235, 0.3);
    }
}

/* Reset */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: var(--font);
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

a {
    color: inherit;
    text-decoration: none;
}

img { max-width: 100%; }

/* ---- Nav ---- */
.nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.5rem;
    max-width: 1200px;
    margin: 0 auto;
    width: 100%;
}

.nav-brand {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 800;
    font-size: 1.25rem;
    text-decoration: none;
    cursor: pointer;
}

.logo-icon {
    font-size: 1.5rem;
}

.logo-text {
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.nav-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* ---- Buttons ---- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.625rem 1.25rem;
    border: none;
    border-radius: var(--radius-md);
    font-family: var(--font);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
    outline: none;
    white-space: nowrap;
    text-decoration: none;
}

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

.btn-primary {
    background: var(--gradient-primary);
    color: white;
    box-shadow: var(--glow-primary);
}
.btn-primary:hover:not(:disabled) {
    box-shadow: 0 0 30px rgba(37, 99, 235, 0.5);
    transform: translateY(-1px);
}

.btn-secondary {
    background: var(--bg-card);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}
.btn-secondary:hover:not(:disabled) {
    background: var(--bg-card-hover);
    border-color: var(--border-active);
}

.btn-glow {
    background: var(--gradient-glow);
    color: white;
    box-shadow: var(--glow-cyan);
}
.btn-glow:hover:not(:disabled) {
    box-shadow: 0 0 30px rgba(37, 99, 235, 0.5);
    transform: translateY(-1px);
}

.btn-danger {
    background: rgba(239, 68, 68, 0.15);
    color: #ef4444;
    border: 1px solid rgba(239, 68, 68, 0.2);
}
.btn-danger:hover:not(:disabled) {
    background: rgba(239, 68, 68, 0.25);
}

.btn-success {
    background: rgba(34, 211, 238, 0.15);
    color: var(--accent-green);
    border: 1px solid rgba(34, 211, 238, 0.2);
}
.btn-success:hover:not(:disabled) {
    background: rgba(34, 211, 238, 0.25);
}

.btn-xl {
    padding: 0.875rem 2rem;
    font-size: 1.05rem;
    border-radius: var(--radius-lg);
}

.btn-sm {
    padding: 0.4rem 0.8rem;
    font-size: 0.8rem;
}

.btn-full {
    width: 100%;
}

.btn-icon {
    padding: 0.5rem;
    border-radius: var(--radius-sm);
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
}
.btn-icon:hover:not(:disabled) {
    color: var(--text-primary);
    border-color: var(--border-active);
}

/* ---- Inputs ---- */
.input {
    width: 100%;
    padding: 0.75rem 1rem;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-family: var(--font);
    font-size: 1rem;
    outline: none;
    transition: border-color var(--transition);
}

.input:focus {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.input::placeholder {
    color: var(--text-muted);
}

.input-error {
    border-color: #ef4444 !important;
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.15) !important;
    animation: shake 0.4s ease;
}

.input-code {
    width: 120px;
    padding: 0.5rem 0.75rem;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: var(--font);
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 2px;
    text-align: center;
    outline: none;
}
.input-code:focus {
    border-color: var(--accent-primary);
}

/* ---- Form ---- */
.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

/* ---- Cards ---- */
.form-card, .result-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    padding: 2rem;
}

/* ---- Loading ---- */
.loading-screen, .error-screen {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    gap: 1rem;
    text-align: center;
    padding: 2rem;
}

.loader {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border-color);
    border-top-color: var(--accent-primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.error-icon {
    font-size: 3rem;
    margin-bottom: 0.5rem;
}

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem 1rem;
    text-align: center;
    color: var(--text-muted);
}

.empty-icon {
    font-size: 2.5rem;
    margin-bottom: 0.75rem;
}

/* ---- Live dot ---- */
.live-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    background: #22c55e;
    border-radius: 50%;
    animation: pulse-dot 2s ease infinite;
}

/* ---- Toggle ---- */
.toggle-group {
    display: flex;
    gap: 0.5rem;
}

.toggle-btn {
    flex: 1;
    padding: 0.75rem 1rem;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    font-family: var(--font);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    transition: all var(--transition);
}

.toggle-btn.active {
    background: rgba(37, 99, 235, 0.15);
    border-color: var(--accent-primary);
    color: var(--text-primary);
}

.toggle-btn:hover:not(.active) {
    border-color: var(--border-active);
}

/* ---- Theme grid ---- */
.theme-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.5rem;
}

.theme-btn {
    padding: 0.75rem;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    font-family: var(--font);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: all var(--transition);
}

.theme-btn.active {
    background: rgba(37, 99, 235, 0.15);
    border-color: var(--accent-primary);
    color: var(--text-primary);
}

.theme-btn:hover:not(.active) {
    border-color: var(--border-active);
}

.theme-icon {
    font-size: 1.2rem;
}

/* ---- QR ---- */
.qr-box {
    background: white;
    border-radius: var(--radius-lg);
    padding: 1rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.qr-box svg {
    display: block;
}

/* ---- Modal ---- */
.modal {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
}

.modal-content {
    position: relative;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    padding: 2rem;
    max-width: 400px;
    width: 90%;
    text-align: center;
}

.modal-content.settings-modal {
    max-width: 860px;
    text-align: left;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-content.qr-modal {
    max-width: 480px;
}

/* ---- Gradient text ---- */
.gradient-text {
    background: var(--gradient-glow);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* ---- Create page ---- */
.create-page {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: calc(100vh - 60px);
    padding: 2rem 1rem;
}

.create-container {
    max-width: 480px;
    width: 100%;
}

.page-title {
    font-size: 1.75rem;
    font-weight: 800;
    text-align: center;
    margin-bottom: 0.25rem;
}

.page-subtitle {
    text-align: center;
    color: var(--text-secondary);
    margin-bottom: 2rem;
}

.event-code-display {
    text-align: center;
    margin-bottom: 1.5rem;
}

.code-big {
    font-size: 2.5rem;
    font-weight: 900;
    letter-spacing: 8px;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.qr-container {
    text-align: center;
    margin-bottom: 1.5rem;
}

.qr-hint {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 0.5rem;
}

.result-actions {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

/* ---- Animations ---- */
@keyframes spin {
    to { transform: rotate(360deg); }
}

@keyframes pulse-dot {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes slideUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes glowPulse {
    0%, 100% { box-shadow: 0 0 5px rgba(37, 99, 235, 0.2); }
    50% { box-shadow: 0 0 25px rgba(37, 99, 235, 0.4); }
}

@keyframes newQuestion {
    0% {
        opacity: 0;
        transform: scale(0.95) translateY(-10px);
        box-shadow: 0 0 30px rgba(37, 99, 235, 0.5);
    }
    50% {
        box-shadow: 0 0 15px rgba(37, 99, 235, 0.3);
    }
    100% {
        opacity: 1;
        transform: scale(1) translateY(0);
        box-shadow: none;
    }
}

/* ---- Responsive ---- */
@media (max-width: 640px) {
    .nav {
        padding: 0.75rem 1rem;
    }
    .form-card, .result-card {
        padding: 1.5rem;
    }
    .page-title {
        font-size: 1.4rem;
    }
    .code-big {
        font-size: 2rem;
    }
}

/* ---- Footer ---- */
.footer {
    padding: 3rem 1.5rem;
    text-align: center;
    border-top: 1px solid var(--border-color);
}

.footer-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-muted);
}

.footer-content .logo-icon {
    font-size: 2rem;
}

.footer-content p {
    font-size: 0.85rem;
}

/* ============================================
   Home Screen – Simple entry point
   ============================================ */

.home-screen {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 2rem 1rem;
}

.home-card {
    max-width: 400px;
    width: 100%;
    animation: fadeIn 0.5s ease;
}

.home-logo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.6rem;
    font-weight: 900;
    font-size: 2rem;
    margin-bottom: 2.5rem;
}

.home-logo .logo-icon {
    font-size: 2.2rem;
}

.home-section {
    margin-bottom: 0;
}

.home-section h2 {
    font-size: 1.1rem;
    font-weight: 700;
    text-align: center;
    margin-bottom: 0.25rem;
}

.home-hint {
    font-size: 0.85rem;
    color: var(--text-secondary);
    text-align: center;
    margin-bottom: 1rem;
}

.join-form {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.input-code-big {
    text-align: center;
    font-size: 1.5rem;
    font-weight: 800;
    letter-spacing: 6px;
    padding: 1rem;
    text-transform: uppercase;
    border-radius: var(--radius-lg);
}

.input-code-big::placeholder {
    font-size: 1rem;
    font-weight: 600;
    letter-spacing: 3px;
}

.form-error {
    color: #ef4444;
    font-size: 0.85rem;
    text-align: center;
    margin-top: 0.5rem;
}

.home-divider {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin: 1.5rem 0;
    color: var(--text-muted);
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.home-divider::before,
.home-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border-color);
}

