/* ==========================================================================
   Design System: SaaS Concursos (Dark Mode, Premium, Glassmorphism)
   ========================================================================== */

:root {
    --bg-dark: #0f172a; /* Slate 900 */
    --bg-darker: #020617;
    --surface-glass: rgba(30, 41, 59, 0.7);
    --surface-border: rgba(255, 255, 255, 0.1);
    
    --primary: #3b82f6; /* Blue 500 */
    --primary-glow: rgba(59, 130, 246, 0.5);
    --secondary: #8b5cf6; /* Violet 500 */
    
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    
    --font-sans: 'Inter', sans-serif;
    --font-display: 'Outfit', sans-serif;
}

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

body {
    background-color: var(--bg-darker);
    color: var(--text-main);
    font-family: var(--font-sans);
    min-height: 100vh;
    overflow-x: hidden;
    /* Soft gradient background */
    background-image: radial-gradient(circle at 15% 50%, rgba(59, 130, 246, 0.08), transparent 25%),
                      radial-gradient(circle at 85% 30%, rgba(139, 92, 246, 0.08), transparent 25%);
}

#app-container {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* ================== Header ================== */
.glass-header {
    background: var(--surface-glass);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--surface-border);
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 100;
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.avatar-ring {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    padding: 2px;
    box-shadow: 0 0 15px var(--primary-glow);
}

.avatar-ring img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--bg-dark);
}

.level-title {
    font-family: var(--font-display);
    font-size: 1.1rem;
    margin-bottom: 4px;
}

.rank-name {
    color: var(--primary);
    font-weight: 900;
}

/* XP Bar */
.xp-bar-container {
    width: 150px;
    height: 8px;
    background: rgba(255,255,255,0.1);
    border-radius: 10px;
    overflow: hidden;
    margin-bottom: 2px;
}

.xp-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), #60a5fa);
    border-radius: 10px;
    transition: width 0.8s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 0 10px var(--primary-glow);
}

.xp-text {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* Header Stats */
.header-stats {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.stat-badge {
    background: rgba(255,255,255,0.05);
    padding: 0.5rem 1rem;
    border-radius: 20px;
    border: 1px solid var(--surface-border);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 700;
    font-family: var(--font-display);
}

.stat-badge.flame {
    color: var(--warning);
    text-shadow: 0 0 10px rgba(245, 158, 11, 0.5);
}

#exam-select {
    background: var(--bg-dark);
    color: white;
    border: 1px solid var(--surface-border);
    padding: 0.5rem 1rem;
    border-radius: 8px;
    outline: none;
    font-family: var(--font-sans);
    cursor: pointer;
}

/* ================== Main Arena ================== */
.question-arena {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    position: relative;
}

/* Empty State / Start */
.empty-state {
    text-align: center;
    position: relative;
}

.pulse-ring {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 200px;
    height: 200px;
    border-radius: 50%;
    background: radial-gradient(circle, var(--primary-glow) 0%, transparent 70%);
    animation: pulse 3s infinite;
    z-index: -1;
}

@keyframes pulse {
    0% { transform: translate(-50%, -50%) scale(0.8); opacity: 0.5; }
    50% { transform: translate(-50%, -50%) scale(1.2); opacity: 0.1; }
    100% { transform: translate(-50%, -50%) scale(0.8); opacity: 0.5; }
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: white;
    border: none;
    padding: 1rem 2rem;
    font-size: 1.2rem;
    font-family: var(--font-display);
    font-weight: 700;
    border-radius: 30px;
    cursor: pointer;
    box-shadow: 0 10px 20px rgba(59, 130, 246, 0.3);
    transition: transform 0.2s, box-shadow 0.2s;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.btn-primary:hover {
    transform: translateY(-3px);
    box-shadow: 0 15px 25px rgba(139, 92, 246, 0.4);
}

.subtitle {
    margin-top: 1rem;
    color: var(--text-muted);
}

/* Cards (Tinder Style) */
.deck-container {
    width: 100%;
    max-width: 600px;
    position: relative;
    perspective: 1000px;
    min-height: 350px;
}

.question-card {
    background: var(--surface-glass);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--surface-border);
    border-radius: 24px;
    padding: 2.5rem 2rem;
    width: 100%;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    
    /* Animation base */
    position: relative;
    transition: transform 0.4s cubic-bezier(0.2, 0.8, 0.2, 1), opacity 0.4s;
    transform-origin: 50% 100%;
}

.topic-badge {
    display: inline-block;
    background: rgba(255,255,255,0.1);
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 1.5rem;
    color: #cbd5e1;
}

.statement {
    font-size: 1.25rem;
    line-height: 1.6;
    font-weight: 500;
    margin-bottom: 2rem;
}

/* Action Controls */
.action-controls {
    display: flex;
    gap: 2rem;
    margin-top: 2rem;
    z-index: 10;
}

.btn-action {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    border: none;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    background: var(--surface-glass);
    color: white;
    border: 2px solid transparent;
    box-shadow: 0 10px 25px rgba(0,0,0,0.3);
}

.btn-action span {
    font-size: 0.75rem;
    margin-top: 4px;
    font-family: var(--font-sans);
    text-transform: uppercase;
    font-weight: 700;
}

.btn-swipe-left {
    color: var(--danger);
}
.btn-swipe-left:hover {
    border-color: var(--danger);
    transform: scale(1.1) rotate(-5deg);
    box-shadow: 0 10px 25px rgba(239, 68, 68, 0.3);
}

.btn-swipe-right {
    color: var(--success);
}
.btn-swipe-right:hover {
    border-color: var(--success);
    transform: scale(1.1) rotate(5deg);
    box-shadow: 0 10px 25px rgba(16, 185, 129, 0.3);
}

/* Feedback Overlay */
.glass-panel {
    background: rgba(15, 23, 42, 0.85);
    backdrop-filter: blur(20px);
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    border-radius: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    z-index: 50;
    animation: fadeIn 0.3s ease;
}

.feedback-content {
    text-align: center;
    width: 100%;
}

.feedback-content h2 {
    font-family: var(--font-display);
    font-size: 2rem;
    margin-bottom: 0.5rem;
}

.feedback-content.correct h2 { color: var(--success); }
.feedback-content.wrong h2 { color: var(--danger); }

.xp-gain {
    font-size: 1.5rem;
    font-weight: 900;
    color: var(--primary);
    text-shadow: 0 0 15px var(--primary-glow);
    margin-bottom: 1.5rem;
}

.combo-alert {
    display: inline-block;
    background: linear-gradient(90deg, #f59e0b, #ef4444);
    padding: 4px 12px;
    border-radius: 20px;
    font-weight: bold;
    margin-bottom: 1rem;
    animation: popIn 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.explanation-box {
    background: rgba(0,0,0,0.3);
    border-radius: 12px;
    padding: 1.5rem;
    margin-bottom: 2rem;
    text-align: left;
    border-left: 4px solid var(--primary);
    max-height: 200px;
    overflow-y: auto;
}

.explanation-box h4 {
    margin-bottom: 0.5rem;
    color: var(--text-muted);
}

/* Utils */
.hidden { display: none !important; }

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes popIn { 
    0% { transform: scale(0.5); opacity: 0; }
    80% { transform: scale(1.1); }
    100% { transform: scale(1); opacity: 1; }
}

/* Animações JS Classes */
.swipe-left-anim {
    transform: translateX(-150%) rotate(-15deg) !important;
    opacity: 0 !important;
}
.swipe-right-anim {
    transform: translateX(150%) rotate(15deg) !important;
    opacity: 0 !important;
}

/* ================== Auth & Ranking (Fase 5) ================== */
.auth-container {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: calc(100vh - 100px);
    width: 100%;
}
.auth-box {
    width: 100%;
    max-width: 450px;
    position: relative !important;
    display: block !important;
    padding: 2.5rem !important;
}
.auth-box h2 {
    font-family: var(--font-display);
    font-size: 2rem;
    margin-bottom: 0.5rem;
}
.auth-form {
    margin-top: 2rem;
    text-align: left;
}
.form-group {
    margin-bottom: 1.8rem;
    position: relative;
}
.form-group label {
    display: block;
    margin-bottom: 0.6rem;
    color: #94a3b8;
    font-weight: 500;
    font-size: 0.95rem;
    letter-spacing: 0.5px;
    transition: color 0.3s ease;
}
.form-group input {
    width: 100%;
    padding: 1rem 1.2rem;
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 12px;
    color: #f8fafc;
    font-size: 1.05rem;
    outline: none;
    transition: all 0.3s ease;
    box-shadow: inset 0 2px 5px rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(8px);
}
.form-group input:focus {
    background: rgba(30, 41, 59, 0.9);
    border-color: var(--primary);
    box-shadow: 0 0 15px rgba(16, 185, 129, 0.3), inset 0 2px 5px rgba(0, 0, 0, 0.1);
    transform: translateY(-2px);
}
.form-group input:focus + label,
.form-group input:focus-within ~ label {
    color: var(--primary);
}
.w-100 { width: 100%; justify-content: center; }
.auth-footer { margin-top: 1.5rem; color: var(--text-muted); }
.auth-footer a { color: var(--primary); text-decoration: none; font-weight: bold; }
.auth-footer a:hover { text-decoration: underline; }

/* Ranking List */
.ranking-list { display: flex; flex-direction: column; gap: 1rem; }
.ranking-item {
    display: flex;
    align-items: center;
    padding: 1rem 1.5rem;
    background: rgba(255,255,255,0.03);
    border-radius: 16px;
    border: 1px solid rgba(255,255,255,0.05);
}
.ranking-item:hover { background: rgba(255,255,255,0.05); }
.rank-position { font-size: 1.5rem; font-weight: 900; width: 50px; text-align: center; }
.rank-user { display: flex; align-items: center; gap: 1rem; flex: 1; }
.rank-user img { width: 45px; height: 45px; border-radius: 50%; }
.user-details h4 { margin: 0; font-size: 1.1rem; }
.user-details span { font-size: 0.8rem; color: var(--text-muted); }
.rank-score { text-align: right; }
.xp-val { font-weight: 900; color: var(--primary); font-size: 1.2rem; }
.best-streak { font-size: 0.75rem; color: var(--warning); margin-top: 2px; }
.top-3 { background: rgba(255, 215, 0, 0.05); border-color: rgba(255, 215, 0, 0.2); }

/* ================== Filtros & Responsividade ================== */
.custom-select {
    background: rgba(15, 23, 42, 0.7);
    border: 1px solid var(--surface-border);
    border-radius: 8px;
    color: white;
    padding: 8px 12px;
    font-weight: 600;
    cursor: pointer;
    font-size: 0.9rem;
    outline: none;
}
.custom-select option {
    background-color: #0f172a;
    color: white;
}

@media (max-width: 768px) {
    .glass-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
        padding: 1rem;
    }
    
    .header-stats {
        width: 100%;
        flex-wrap: wrap;
        justify-content: flex-start;
    }
    
    .exam-selector {
        width: 100%;
        display: flex;
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .custom-select {
        width: 100%;
    }

    .main-arena {
        padding: 1rem;
    }
    
    .card {
        padding: 1.5rem;
        width: 100%;
        height: 60vh;
    }

    .home-grid {
        grid-template-columns: 1fr !important;
        gap: 1rem !important;
    }
}
