/* ===== Global Styles ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

html {
    scroll-behavior: smooth;
    overflow-x: hidden;
}

body {
    font-family: 'Heebo', sans-serif;
    overscroll-behavior: none;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* RTL Adjustments */
[dir="rtl"] {
    text-align: right;
}

/* Safe area for bottom nav on iOS */
.safe-bottom {
    padding-bottom: env(safe-area-inset-bottom, 0);
}

/* Page transitions */
.page {
    display: none;
    animation: fadeIn 0.35s ease-out;
}

.page.active {
    display: block;
}

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

@keyframes slideUp {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
}

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

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

@keyframes confetti {
    0% { transform: translateY(0) rotate(0deg); opacity: 1; }
    100% { transform: translateY(-100px) rotate(720deg); opacity: 0; }
}

@keyframes popIn {
    0% { transform: scale(0.8); opacity: 0; }
    70% { transform: scale(1.05); }
    100% { transform: scale(1); opacity: 1; }
}

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

@keyframes glow {
    0%, 100% { box-shadow: 0 0 5px rgba(108, 99, 255, 0.2); }
    50% { box-shadow: 0 0 20px rgba(108, 99, 255, 0.4); }
}

@keyframes float {
    0%, 100% { transform: translateY(0px); }
    50% { transform: translateY(-6px); }
}

@keyframes shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

@keyframes scoreCount {
    from { transform: scale(0.5); opacity: 0; }
    50% { transform: scale(1.2); }
    to { transform: scale(1); opacity: 1; }
}

/* Scrollbar Hide */
.scrollbar-hide::-webkit-scrollbar { display: none; }
.scrollbar-hide { -ms-overflow-style: none; scrollbar-width: none; }

/* Navigation Styles */
.nav-btn {
    color: #9CA3AF;
    position: relative;
}

.nav-btn.active {
    color: #1B3A5C;
}

.nav-btn.active::after {
    content: '';
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 24px;
    height: 3px;
    background: #1B3A5C;
    border-radius: 0 0 4px 4px;
}

/* Toast */
#toast {
    transition: all 0.4s cubic-bezier(0.68, -0.55, 0.27, 1.55);
}

#toast.show {
    transform: translateY(0) !important;
    opacity: 1 !important;
    pointer-events: auto;
}

/* Input Focus Styles */
input:focus, textarea:focus, select:focus {
    outline: none;
}

/* Custom checkbox */
input[type="checkbox"] {
    cursor: pointer;
}

/* Button active states for mobile */
button:active:not(:disabled) {
    transform: scale(0.97);
    transition: transform 0.1s;
}

/* Leaderboard rank badges */
.rank-1 { 
    background: linear-gradient(135deg, #FFD700, #FFA500) !important;
    box-shadow: 0 2px 10px rgba(255, 215, 0, 0.4);
}
.rank-2 { 
    background: linear-gradient(135deg, #C0C0C0, #A8A8A8) !important;
    box-shadow: 0 2px 10px rgba(192, 192, 192, 0.4);
}
.rank-3 { 
    background: linear-gradient(135deg, #CD7F32, #B8860B) !important;
    box-shadow: 0 2px 10px rgba(205, 127, 50, 0.4);
}

/* Difficulty indicators */
.diff-1 { color: #C9A84C; }
.diff-2 { color: #4CAF50; }
.diff-3 { color: #FFC107; }
.diff-4 { color: #FF9800; }
.diff-5 { color: #F44336; }

/* Admin tab styles */
.admin-tab.active {
    background: #1B3A5C !important;
    color: white !important;
}

/* Draft card styles */
.draft-card {
    background: white;
    border-radius: 16px;
    padding: 16px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
    border: 1px solid #f0f0f0;
    transition: all 0.2s;
}

.draft-card:hover {
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.draft-card.selected {
    border-color: #1B3A5C;
    background: #F8F7FF;
}

/* Quiz manage card */
.quiz-manage-card {
    background: white;
    border-radius: 16px;
    padding: 16px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
    border: 1px solid #f0f0f0;
}

/* Skeleton loading */
.skeleton {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: 8px;
}

/* Accessible Focus Styles */
*:focus-visible {
    outline: 3px solid #1B3A5C;
    outline-offset: 2px;
    border-radius: 4px;
}

/* High contrast mode */
@media (prefers-contrast: high) {
    body { background: white; color: black; }
    .bg-primary { background: #0000CC !important; }
    button { border: 2px solid currentColor; }
}

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

/* Mobile-specific adjustments */
@media (max-width: 640px) {
    .max-w-lg {
        max-width: 100%;
    }
}

/* Landscape mode adjustments */
@media (orientation: landscape) and (max-height: 500px) {
    #bottom-nav { display: none; }
    #main-content { padding-bottom: 0; }
}

/* ===== Podium Styles ===== */
.podium-container {
    display: flex;
    align-items: flex-end;
    justify-content: center;
    gap: 8px;
    padding: 20px 16px 10px;
    margin-bottom: 20px;
}

.podium-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    animation: popIn 0.5s ease-out;
}

.podium-item:nth-child(1) { animation-delay: 0.2s; }
.podium-item:nth-child(2) { animation-delay: 0s; }
.podium-item:nth-child(3) { animation-delay: 0.4s; }

.podium-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 18px;
    color: white;
    margin-bottom: 6px;
    position: relative;
}

.podium-avatar.gold { 
    width: 56px; height: 56px; font-size: 20px;
    background: linear-gradient(135deg, #FFD700, #FFA500);
    box-shadow: 0 4px 15px rgba(255, 215, 0, 0.5);
}
.podium-avatar.silver { 
    background: linear-gradient(135deg, #C0C0C0, #A8A8A8);
    box-shadow: 0 4px 15px rgba(192, 192, 192, 0.4);
}
.podium-avatar.bronze { 
    background: linear-gradient(135deg, #CD7F32, #B8860B);
    box-shadow: 0 4px 15px rgba(205, 127, 50, 0.4);
}

.podium-medal {
    position: absolute;
    bottom: -6px;
    right: -6px;
    font-size: 20px;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.2));
}

.podium-name {
    font-size: 12px;
    font-weight: 600;
    color: #374151;
    text-align: center;
    max-width: 80px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    margin-bottom: 4px;
}

.podium-score {
    font-size: 14px;
    font-weight: 800;
    margin-bottom: 6px;
}

.podium-score.gold { color: #FFA500; }
.podium-score.silver { color: #A8A8A8; }
.podium-score.bronze { color: #B8860B; }

.podium-bar {
    width: 72px;
    border-radius: 12px 12px 0 0;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding-top: 8px;
    font-size: 20px;
    font-weight: 800;
    color: white;
}

.podium-bar.gold { 
    height: 100px; 
    background: linear-gradient(180deg, #FFD700, #FFA500);
}
.podium-bar.silver { 
    height: 75px; 
    background: linear-gradient(180deg, #C0C0C0, #A8A8A8);
}
.podium-bar.bronze { 
    height: 55px; 
    background: linear-gradient(180deg, #CD7F32, #B8860B);
}

/* ===== Confetti explosion ===== */
.confetti-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 100;
    overflow: hidden;
}

.confetti-piece {
    position: absolute;
    width: 10px;
    height: 10px;
    top: -10px;
    opacity: 0;
    animation: confettiFall 3s ease-out forwards;
}

@keyframes confettiFall {
    0% { transform: translateY(0) rotate(0deg); opacity: 1; }
    100% { transform: translateY(100vh) rotate(720deg); opacity: 0; }
}

/* ===== Ripple effect ===== */
.ripple {
    position: relative;
    overflow: hidden;
}

.ripple::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    background: rgba(255,255,255,0.3);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    transition: width 0.3s, height 0.3s;
}

.ripple:active::after {
    width: 300px;
    height: 300px;
}

/* ===== Score Animation ===== */
.score-animate {
    animation: scoreCount 0.6s cubic-bezier(0.68, -0.55, 0.27, 1.55);
}

/* ===== Pull to Refresh Indicator ===== */
.pull-indicator {
    position: absolute;
    top: -40px;
    left: 50%;
    transform: translateX(-50%);
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: white;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.3s;
    z-index: 10;
}

/* ===== Notification badge ===== */
.notification-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #B5432A;
    color: white;
    font-size: 10px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid white;
    animation: popIn 0.3s ease-out;
}

/* ===== Empty state ===== */
.empty-state {
    text-align: center;
    padding: 40px 20px;
}

.empty-state .empty-icon {
    font-size: 48px;
    margin-bottom: 12px;
    animation: float 3s ease-in-out infinite;
}

.empty-state .empty-title {
    font-size: 16px;
    font-weight: 600;
    color: #374151;
    margin-bottom: 4px;
}

.empty-state .empty-text {
    font-size: 13px;
    color: #9CA3AF;
}
