:root {
    --primary: #6366f1;
    /* Indigo */
    --primary-hover: #4f46e5;
    --background: #0f172a;
    /* Slate 900 */
    --surface: #1e293b;
    /* Slate 800 */
    --text: #f8fafc;
    --text-muted: #94a3b8;
    --success: #10b981;
    --danger: #ef4444;
    --glass: rgba(30, 41, 59, 0.7);
    --radius: 12px;
}

* {
    box-sizing: border_box;
    margin: 0;
    padding: 0;
    font-family: 'Inter', system-ui, sans-serif;
}

body {
    background-color: var(--background);
    color: var(--text);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes float {
    0% {
        transform: translateY(0px);
    }

    50% {
        transform: translateY(-10px);
    }

    100% {
        transform: translateY(0px);
    }
}

/* Utility Classes */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem;
}

.text-center {
    text-align: center;
}

.text-primary {
    color: var(--primary);
}

.text-xs {
    font-size: 0.75rem;
}

.btn {
    padding: 0.75rem 1.5rem;
    border-radius: var(--radius);
    border: none;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    text-decoration: none;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--primary-hover));
    color: white;
    box-shadow: 0 4px 6px -1px rgba(99, 102, 241, 0.4);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 15px -3px rgba(99, 102, 241, 0.5);
}

.btn-secondary {
    background: var(--surface);
    color: var(--text);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.1);
}

/* Auth Page */
.auth-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: radial-gradient(circle at top right, #312e81, transparent 40%),
        radial-gradient(circle at bottom left, #1e1b4b, transparent 40%);
    padding: 1rem;
}

.app-footer {
    margin-top: 2rem;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.85rem;
    line-height: 1.6;
    animation: fadeIn 1s ease-out;
}

.app-footer strong {
    color: var(--text);
    font-weight: 600;
}

.app-footer a {
    color: var(--text-muted);
    text-decoration: none;
    border-bottom: 1px dashed rgba(255, 255, 255, 0.2);
    transition: all 0.2s;
}

.app-footer a:hover {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

.auth-card {
    background: var(--glass);
    backdrop-filter: blur(12px);
    padding: 3rem;
    border-radius: 24px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    width: 100%;
    max-width: 450px;
    animation: fadeIn 0.8s ease-out;
}

.auth-title {
    font-size: 2rem;
    margin-bottom: 2rem;
    font-weight: 800;
    background: linear-gradient(to right, #818cf8, #c084fc);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.auth-logo {
    width: 450px;
    max-width: 100%;
    height: auto;
    margin-bottom: 1rem;
    display: block;
    margin-left: auto;
    margin-right: auto;
}

.input-group {
    margin-bottom: 1.5rem;
}

.input-label {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--text-muted);
    font-size: 0.875rem;
}

.form-input {
    width: 100%;
    padding: 0.875rem;
    border-radius: var(--radius);
    background: rgba(15, 23, 42, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--text);
    transition: all 0.2s;
}

.form-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.2);
}

/* Dashboard Layout */
.dashboard-grid {
    display: grid;
    grid-template-columns: 250px 1fr;
    min-height: 100vh;
}

.sidebar {
    background: var(--surface);
    border-right: 1px solid rgba(255, 255, 255, 0.05);
    padding: 2rem;
}

.main-content {
    padding: 2rem;
    background: var(--background);
    overflow-y: auto;
}

.nav-link {
    display: flex;
    align-items: center;
    padding: 1rem;
    color: var(--text-muted);
    text-decoration: none;
    border-radius: var(--radius);
    margin-bottom: 0.5rem;
    transition: all 0.2s;
}

.nav-link:hover,
.nav-link.active {
    background: rgba(99, 102, 241, 0.1);
    color: var(--primary);
}

/* Cards */
.card {
    background: var(--surface);
    border-radius: 16px;
    padding: 1.5rem;
    border: 1px solid rgba(255, 255, 255, 0.05);
    margin-bottom: 1.5rem;
}

.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: linear-gradient(145deg, var(--surface), rgba(30, 41, 59, 0.4));
    padding: 1.5rem;
    border-radius: 16px;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.stat-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--text);
    margin: 0.5rem 0;
}

.stat-label {
    color: var(--text-muted);
    font-size: 0.875rem;
}

/* Modals */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(5px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-content {
    background: var(--surface);
    padding: 2rem;
    border-radius: 24px;
    width: 90%;
    max-width: 500px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    animation: fadeIn 0.3s ease-out;
}

/* Table */
.modern-table {
    width: 100%;
    border-collapse: collapse;
}

.modern-table th,
.modern-table td {
    padding: 1rem;
    text-align: left;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.modern-table th {
    color: var(--text-muted);
    font-weight: 500;
}

/* Skeletons */
.skeleton {
    background: linear-gradient(90deg, var(--surface) 25%, #2d3748 50%, var(--surface) 75%);
    background-size: 200% 100%;
    animation: loading 1.5s infinite;
    border-radius: 6px;
}

@keyframes loading {
    0% {
        background-position: 200% 0;
    }

    100% {
        background-position: -200% 0;
    }
}

.alert {
    padding: 1rem;
    border-radius: var(--radius);
    margin-bottom: 1rem;
    font-size: 0.9rem;
    display: none;
}

.alert-error {
    background: rgba(239, 68, 68, 0.2);
    color: #fca5a5;
    border: 1px solid #ef4444;
}

.alert-success {
    background: rgba(16, 185, 129, 0.2);
    color: #6ee7b7;
    border: 1px solid #10b981;
}

.hidden {
    display: none;
}

/* Responsive Design */
@media (max-width: 768px) {
    .dashboard-grid {
        grid-template-columns: minmax(0, 1fr);
        /* Critical: prevents grid blowing out */
        width: 100%;
        overflow-x: hidden;
    }

    .sidebar {
        border-right: none;
        border-bottom: 1px solid rgba(255, 255, 255, 0.05);
        padding: 1rem 0;
        /* Remove horizontal padding from container so nav touches edges */
        width: 100%;
        width: 100vw;
        /* Force viewport width */
    }

    .sidebar h2 {
        font-size: 1.5rem;
        margin-bottom: 1rem !important;
        text-align: center;
        padding: 0 1rem;
        /* Add padding back to title */
    }

    .sidebar nav {
        display: flex;
        flex-wrap: nowrap !important;
        gap: 0.5rem;
        overflow-x: auto !important;
        padding: 0.5rem 1rem;
        width: 100%;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        align-items: center;
        min-height: 50px;
        /* Ensure visibility */
    }

    .sidebar nav::-webkit-scrollbar {
        display: none;
    }

    .nav-link {
        flex: 0 0 auto;
        white-space: nowrap;
        padding: 0.5rem 1rem;
        font-size: 0.85rem;
        margin-bottom: 0;
        background: rgba(255, 255, 255, 0.05);
        border: 1px solid rgba(255, 255, 255, 0.1);
        border-radius: 99px;
        /* Pill shape */
        margin-right: 0.5rem;
    }

    .main-content {
        padding: 1rem;
    }

    .container {
        padding: 0;
    }

    .stat-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    .card {
        padding: 1rem;
    }

    /* Making tables responsive */
    .table-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .modern-table {
        min-width: 600px;
        /* Force scroll on small screens */
    }

    .auth-card {
        padding: 1.5rem;
        margin: 1rem;
    }

    .auth-title {
        font-size: 1.75rem;
    }

    /* Better Modal on Mobile */
    .modal-content {
        width: 95% !important;
        padding: 1.5rem !important;
        margin: 1rem auto;
    }

    /* Neon Buttons text size on mobile */
    .btn-neon {
        font-size: 0.8rem !important;
        padding: 0.8rem 0.5rem !important;
    }

    /* Force Nav Scroll */
    .sidebar {
        width: 100%;
        overflow: hidden;
        /* Prevent sidebar itself from scroll, only nav */
    }

    .sidebar nav {
        display: flex;
        flex-wrap: nowrap !important;
        gap: 0.75rem;
        overflow-x: auto !important;
        padding-bottom: 1rem;
        width: 100%;
        mask-image: linear-gradient(to right, black 85%, transparent 100%);
        -webkit-mask-image: linear-gradient(to right, black 85%, transparent 100%);
    }

    .nav-link {
        flex: 0 0 auto;
        /* Don't grow, don't shrink, auto basis */
        white-space: nowrap;
        margin-right: 0.5rem;
    }
}

/* Raffle Progress Bar & Cards */
.raffle-card {
    background: var(--surface);
    border-radius: 20px;
    padding: 1.5rem;
    position: relative;
    border: 1px solid rgba(255, 255, 255, 0.1);
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.progress-container {
    width: 100%;
    height: 10px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 5px;
    margin-top: 5px;
    margin-bottom: 5px;
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    border-radius: 5px;
    transition: width 0.6s ease-out;
}

.blink-anim {
    animation: blink 1s infinite;
}

@keyframes blink {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.5;
    }
}