/* --- 1. Global Reset & Theme Variables --- */
:root {
    /* Deep Cosmic Background Palette */
    --bg-start: #060918;     /* Deep black-blue */
    --bg-mid: #10152e;       /* Navy transition */
    --bg-end: #0a0e21;       /* Darkest indigo */
    
    --card-bg: rgba(255, 255, 255, 0.03); /* Subtle glass effect */
    --card-border: rgba(255, 255, 255, 0.08);
    
    /* Neon Colors (High Contrast) */
    --primary: #ff2e63;      /* Vibrant Pink */
    --secondary: #00ffa3;    /* Neon Green */
    --accent: #08d9d6;       /* Cyan */
    --warning: #f1c40f;      /* Gold */
    --danger: #e74c3c;       /* Red */
    
    /* Text Colors */
    --text-main: #ffffff;    /* Pure White */
    --text-dim: #b0b3b8;     /* Soft Silver */
    --text-muted: #7d8590;   /* Muted Gray */
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Inter', sans-serif;
    color: var(--text-main);
    line-height: 1.6;
    min-height: 100vh;
    background: linear-gradient(160deg, var(--bg-start) 0%, var(--bg-mid) 50%, var(--bg-end) 100%);
    background-attachment: fixed;
    -webkit-font-smoothing: antialiased;
}

a {
    text-decoration: none;
    color: inherit;
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}

img {
    max-width: 100%;
    height: auto;
}

/* --- 2. Typography & Headers --- */
h1, h2, h3 {
    text-shadow: 0 2px 10px rgba(0,0,0,0.4);
    color: var(--text-main);
    margin-bottom: 15px;
}

/* --- 2b. Shared Theme Background Overlay ---
   The background IMAGE itself is rendered by sidebar.php's body::before rule
   (pre-existing, driven by theme_engine.js.php, includes the Ken Burns/pulse/
   gradient-pan animations). This is only the color tint layer on top of it —
   a #dynamic-bg-layer image div used to be defined here too, but that duplicated
   body::before and showed the same background image twice, at different zoom
   levels, on every page that rendered it. */
#dynamic-bg-overlay {
    position: fixed; top: -50px; left: -50px; right: -50px; bottom: -150px;
    background: var(--bg-overlay, rgba(0,0,0,0));
    z-index: 2; pointer-events: none; transition: background-color 0.5s ease-in-out;
}

/* --- 3. Main Layout Containers --- */
#main {
    position: relative;
    z-index: 10;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    padding: 40px 20px;
    margin-top: 50px;
    width: 100%;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    animation: fadeIn 0.8s ease-out;
}

.dashboard-container, .glass-card, .form-container { 
    width: 100%; 
    max-width: 1100px; 
}

/* --- 4. Sidebar Styles --- */
.sidebar {
    height: 100vh;
    width: 280px;
    position: fixed;
    z-index: 1001;
    top: 0;
    left: -280px; 
    background-color: rgba(10, 14, 33, 0.95);
    backdrop-filter: blur(10px);
    transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 10px 0 30px rgba(0,0,0,0.5);
    display: flex;
    flex-direction: column;
    border-right: 2px solid var(--primary);
    overflow-y: auto; /* Allow scrolling if menu is long */
}

.sidebar.active { left: 0; }

.sidebar-header {
    text-align: center;
    padding: 35px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.nav-avatar {
    width: 90px;
    height: 90px;
    border-radius: 50%;
    border: 3px solid var(--primary);
    margin-bottom: 15px;
    object-fit: cover;
    box-shadow: 0 0 15px rgba(233, 69, 96, 0.3);
}

.role-badge {
    background: rgba(255, 255, 255, 0.1);
    color: var(--warning);
    font-size: 10px;
    padding: 3px 10px;
    border-radius: 12px;
    font-weight: bold;
    letter-spacing: 1px;
}

.sidebar a {
    padding: 16px 25px;
    font-size: 15px;
    color: var(--text-dim) !important;
    display: block;
    border-left: 4px solid transparent;
}

.sidebar a:hover {
    background: rgba(255, 46, 99, 0.1);
    color: var(--primary) !important;
    padding-left: 35px;
}

.active-link {
    background: rgba(255, 46, 99, 0.15) !important;
    border-left: 4px solid var(--primary) !important;
    color: var(--primary) !important;
    font-weight: 700;
}

.section-title {
    font-size: 11px;
    color: var(--primary);
    padding: 25px 25px 10px;
    text-transform: uppercase;
    letter-spacing: 3px;
    font-weight: 900;
    opacity: 0.8;
}

.openbtn {
    position: fixed;
    top: 15px; left: 15px;
    z-index: 1002;
    background: var(--card-bg);
    backdrop-filter: blur(5px);
    border: 1px solid var(--card-border);
    color: white;
    padding: 10px 15px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 18px;
    transition: 0.3s;
}

.openbtn:hover { background: var(--primary); }

/* --- 5. Forms & Inputs (The Fixes) --- */
form {
    width: 100%;
}

label {
    display: block;
    margin-bottom: 5px;
    color: var(--text-dim);
    font-size: 14px;
    font-weight: 600;
}

input[type="text"], 
input[type="password"], 
input[type="datetime-local"], 
select, 
input[type="file"] {
    width: 100%;
    padding: 12px 15px;
    margin-bottom: 20px;
    background: rgba(15, 52, 96, 0.5); /* Matching dark theme */
    border: 1px solid var(--card-border);
    color: var(--text-main);
    border-radius: 8px;
    font-family: inherit;
    font-size: 14px;
    transition: 0.3s;
    box-sizing: border-box; /* Crucial for keeping inputs inside forms */
}

input:focus, select:focus {
    border-color: var(--primary);
    outline: none;
    box-shadow: 0 0 10px rgba(255, 46, 99, 0.2);
    background: rgba(15, 52, 96, 0.8);
}

/* --- 6. Tables --- */
table {
    width: 100%;
    border-collapse: collapse;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 12px;
    overflow: hidden; /* Keeps rounded corners */
}

th {
    background: rgba(15, 52, 96, 0.6);
    color: var(--primary) !important;
    letter-spacing: 1px;
    font-weight: 800;
    text-transform: uppercase;
    font-size: 12px;
    padding: 15px;
    text-align: left;
}

td {
    padding: 15px;
    border-bottom: 1px solid rgba(255,255,255,0.05);
    vertical-align: middle;
}

tr:hover { background: rgba(255, 255, 255, 0.03); }

/* --- 7. Cards & Glassmorphism --- */
.glass-card, .form-container, .login-card {
    background: var(--card-bg);
    backdrop-filter: blur(20px);
    border: 1px solid var(--card-border);
    border-radius: 20px;
    padding: 30px;
    width: 100%;
    box-shadow: 0 15px 35px rgba(0,0,0,0.3);
    margin-bottom: 20px;
}

.stat-card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 20px;
    padding: 25px;
    text-align: center;
    transition: all 0.3s ease;
}

.stat-card:hover {
    transform: translateY(-8px);
    background: rgba(255, 255, 255, 0.08);
    box-shadow: 0 15px 30px rgba(0,0,0,0.5);
}

/* --- 8. Buttons --- */
button, .btn-pro, .btn-vote, .btn-enter {
    background: var(--primary);
    color: white !important;
    padding: 12px 20px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 700;
    transition: all 0.3s ease;
    text-transform: uppercase;
    text-align: center;
    display: inline-block;
    font-size: 14px;
    box-sizing: border-box;
}

button:hover, .btn-pro:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 15px rgba(255, 46, 99, 0.4);
}

.btn-danger { background: var(--danger); }
.btn-danger:hover { box-shadow: 0 8px 15px rgba(231, 76, 60, 0.4); }

.btn-outline {
    background: transparent;
    border: 2px solid var(--accent);
    color: var(--accent) !important;
}

.btn-outline:hover {
    background: var(--accent);
    color: #000 !important;
}

/* --- 9. Alerts / Messages --- */
.alert, p[style*="color: cyan"], p[style*="color:#4df1a1"], p[style*="color: #4df1a1"] {
    background: rgba(0, 255, 163, 0.1);
    color: var(--secondary) !important;
    padding: 15px;
    border-radius: 8px;
    border: 1px solid var(--secondary);
    text-align: center;
    font-weight: bold;
    margin-bottom: 20px;
}

.alert-error, p[style*="color: #e94560"], p[style*="color: #ff4d4d"] {
    background: rgba(233, 69, 96, 0.1);
    color: var(--primary) !important;
    padding: 15px;
    border-radius: 8px;
    border: 1px solid var(--primary);
    text-align: center;
    font-weight: bold;
    margin-bottom: 20px;
}

/* --- 10. Animations --- */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(15px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes pulse-glow {
    0% { box-shadow: 0 0 0 0 rgba(255, 46, 99, 0.7); }
    70% { box-shadow: 0 0 0 15px rgba(255, 46, 99, 0); }
    100% { box-shadow: 0 0 0 0 rgba(255, 46, 99, 0); }
}

/* --- 11. Responsive Logic --- */
@media screen and (min-width: 992px) {
    #main { margin-left: 280px; width: calc(100% - 280px); }
    .sidebar { left: 0; }
    .openbtn { display: none; } /* Hide hamburger menu on desktop */
}

@media (max-width: 991px) {
    .sidebar { width: 260px; left: -260px; }
    .sidebar.active { left: 0; }
    #main { margin-left: 0 !important; width: 100%; padding-top: 70px; }

    /* Make tables responsive on mobile */
    table { display: block; overflow-x: auto; white-space: nowrap; }
}

@media (max-width: 768px) {
    #main { padding: 25px 14px; }
    h1 { font-size: 1.6rem; }
    h2 { font-size: 1.35rem; }
    h3 { font-size: 1.15rem; }
}

@media (max-width: 480px) {
    #main { padding: 16px 10px; margin-top: 0; }
    .sidebar { width: 85vw; left: -85vw; }
    h1 { font-size: 1.35rem; }
    h2 { font-size: 1.15rem; }
    h3 { font-size: 1rem; }
}