/* Global Styles */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;600;700&display=swap');

:root {
    --bg-color: #0f172a;
    --surface-color: #1e293b;
    --primary-color: #8b5cf6;
    --primary-hover: #7c3aed;
    --text-color: #f8fafc;
    --text-muted: #94a3b8;
    --border-color: #334155;
    --success-color: #10b981;
    --gold-color: #fbbf24;
    --glass-bg: rgba(30, 41, 59, 0.7);
    --glass-border: rgba(255, 255, 255, 0.1);
}

:root[data-theme="light"] {
    --bg-color: #f0f9ff;
    --surface-color: #ffffff;
    --primary-color: #7c3aed;
    --primary-hover: #6d28d9;
    --text-color: #0f172a;
    --text-muted: #475569;
    --border-color: #cbd5e1;
    --glass-bg: rgba(255, 255, 255, 0.75);
    --glass-border: rgba(0, 0, 0, 0.1);
}

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

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    line-height: 1.6;
    min-height: 100vh;
    background-image:
        radial-gradient(at 0% 0%, rgba(139, 92, 246, 0.15) 0px, transparent 50%),
        radial-gradient(at 100% 0%, rgba(56, 189, 248, 0.15) 0px, transparent 50%);
    background-attachment: fixed;
}

a {
    text-decoration: none;
    color: inherit;
    transition: color 0.2s;
}

ul {
    list-style: none;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

/* Header */
header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 0;
    margin-bottom: 40px;
    border-bottom: 1px solid var(--border-color);
}

.logo {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-color);
    display: flex;
    align-items: center;
    gap: 10px;
}

.logo span {
    color: var(--primary-color);
}

.nav-links a {
    color: var(--text-muted);
    font-weight: 500;
    margin-left: 20px;
}

.nav-links a:hover,
.nav-links a.active {
    color: var(--primary-color);
}

.btn {
    display: inline-block;
    padding: 10px 20px;
    background-color: var(--primary-color);
    color: white;
    border-radius: 8px;
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn:hover {
    background-color: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(139, 92, 246, 0.3);
}

.btn-secondary {
    background-color: var(--surface-color);
    border: 1px solid var(--border-color);
}

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

.btn-danger {
    background-color: #ef4444;
}

.btn-danger:hover {
    background-color: #dc2626;
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3);
}

/* Cards & Layout */
.grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 24px;
    margin-bottom: 40px;
}

.card {
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    padding: 24px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

.card h2 {
    font-size: 1.25rem;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 10px;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 12px;
}

/* Tables */
.table-wrapper {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.95rem;
}

th {
    text-align: left;
    padding: 12px;
    color: var(--text-muted);
    font-weight: 600;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

td {
    padding: 14px 12px;
    border-bottom: 1px solid var(--border-color);
}

tr:last-child td {
    border-bottom: none;
}

.rank {
    font-weight: 700;
    color: var(--primary-color);
    width: 30px;
}

.team-name {
    font-weight: 600;
    color: var(--text-color);
}

.points {
    font-weight: 700;
    text-align: right;
}

.stat {
    text-align: center;
    color: var(--text-muted);
}

/* Leaderboard custom styles */
/* 1st Place - Gold transparent */
.rank-1 td {
    background: linear-gradient(90deg, rgba(251, 191, 36, 0.2) 0%, transparent 100%);
    border-left: 3px solid var(--gold-color);
}

/* 2nd Place - Green transparent */
.rank-2 td {
    background: linear-gradient(90deg, rgba(16, 185, 129, 0.2) 0%, transparent 100%);
    border-left: 3px solid var(--success-color);
}

/* 3rd Place - Green slightly more transparent */
.rank-3 td {
    background: linear-gradient(90deg, rgba(16, 185, 129, 0.1) 0%, transparent 100%);
    border-left: 3px solid rgba(16, 185, 129, 0.5);
}

/* Second to last - Red transparent */
.rank-second-last td {
    background: linear-gradient(90deg, rgba(239, 68, 68, 0.1) 0%, transparent 100%);
    border-left: 3px solid rgba(239, 68, 68, 0.5);
}

/* Last - Red less transparent (more intense) */
.rank-last td {
    background: linear-gradient(90deg, rgba(239, 68, 68, 0.2) 0%, transparent 100%);
    border-left: 3px solid #ef4444;
}

.winner-badge {
    color: var(--gold-color);
    margin-right: 6px;
}

/* Dashboard specific */
.admin-actions {
    display: flex;
    gap: 10px;
    margin-top: 20px;
}

.form-group {
    margin-bottom: 16px;
}

label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: var(--text-muted);
}

input,
select {
    width: 100%;
    padding: 10px 14px;
    background-color: var(--bg-color);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-color);
    font-family: inherit;
    transition: border-color 0.2s;
}

input:focus,
select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.2);
}

/* Login Page */
.login-container {
    min-height: 80vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.login-card {
    width: 100%;
    max-width: 400px;
}

.alert {
    padding: 12px;
    border-radius: 8px;
    margin-bottom: 16px;
    font-size: 0.9rem;
}

.alert-error {
    background-color: rgba(239, 68, 68, 0.1);
    color: #fca5a5;
    border: 1px solid rgba(239, 68, 68, 0.2);
}

/* Responsive */
/* Mobile Menu Button */
.menu-toggle {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    padding: 10px;
    z-index: 1002;
    /* Higher than nav */
}

.menu-toggle .bar {
    display: block;
    width: 25px;
    height: 3px;
    margin: 5px auto;
    background-color: var(--text-color);
    transition: all 0.3s ease-in-out;
}

.menu-toggle.active .bar:nth-child(2) {
    opacity: 0;
}

.menu-toggle.active .bar:nth-child(1) {
    transform: translateY(8px) rotate(45deg);
}

.menu-toggle.active .bar:nth-child(3) {
    transform: translateY(-8px) rotate(-45deg);
}

/* Responsive */
@media (max-width: 768px) {
    .grid {
        grid-template-columns: 1fr;
    }

    .menu-toggle {
        display: block !important;
    }

    .menu-toggle .bar {
        background-color: var(--text-color);
    }

    .nav-links {
        position: fixed;
        top: 0;
        right: -100%;
        width: 280px;
        height: 100vh;

        background: rgba(30, 41, 59, 0.98);
        /* Fallback */
        backdrop-filter: blur(20px);
        -webkit-backdrop-filter: blur(20px);

        border-left: 1px solid var(--border-color);
        box-shadow: -10px 0 30px rgba(0, 0, 0, 0.5);

        display: flex !important;
        /* Force flex */
        flex-direction: column;
        justify-content: center;
        align-items: center;
        gap: 25px !important;

        transition: right 0.4s cubic-bezier(0.2, 0.8, 0.2, 1);
        z-index: 1001;
        padding: 40px;
    }

    /* Light mode adjustment */
    :root[data-theme="light"] .nav-links {
        background: rgba(255, 255, 255, 0.98);
    }

    .nav-links.mobile-active {
        right: 0;
    }

    .nav-links a {
        margin: 0;
        font-size: 1.15rem;
        font-weight: 600;
        text-transform: uppercase;
        letter-spacing: 0.05em;
        width: 100%;
        text-align: center;
        padding: 10px 0;
        border-bottom: 2px solid transparent;
        transition: all 0.2s ease;
    }

    .nav-links a:hover,
    .nav-links a.active {
        color: var(--primary-color);
        transform: scale(1.05);
    }

    .header-right {
        gap: 15px;
    }
}