/* Modern Reset & Variables */
:root {
    --primary-color: #6366f1;
    /* Indigo 500 */
    --primary-hover: #4f46e5;
    /* Indigo 600 */
    --secondary-color: #0ea5e9;
    /* Sky 500 */
    --accent-color: #ec4899;
    /* Pink 500 */
    --bg-dark: #0f172a;
    /* Slate 900 */
    --bg-card: rgba(30, 41, 59, 0.6);
    /* Slate 800 with high transparency */
    --text-main: #f8fafc;
    /* Slate 50 */
    --text-muted: #94a3b8;
    /* Slate 400 */
    --glass-border: rgba(255, 255, 255, 0.08);
    --glass-highlight: rgba(255, 255, 255, 0.15);
    --shadow-lg: 0 10px 30px -10px rgba(0, 0, 0, 0.6);
    --shadow-glow: 0 0 20px rgba(99, 102, 241, 0.3);
    --font-main: 'Inter', sans-serif;
    --transition-speed: 0.3s;
    --ease-out-back: cubic-bezier(0.34, 1.56, 0.64, 1);
}

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

body {
    font-family: var(--font-main);
    background-color: var(--bg-dark);
    color: var(--text-main);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
    /* Dynamic Background */
    background: radial-gradient(circle at top left, rgba(99, 102, 241, 0.15), transparent 40%),
        radial-gradient(circle at bottom right, rgba(236, 72, 153, 0.15), transparent 40%),
        #0f172a;
    background-attachment: fixed;
}

/* Typography */
h1,
h2,
h3,
h4,
h5,
h6 {
    font-weight: 800;
    line-height: 1.1;
    margin-bottom: 1rem;
    color: var(--text-main);
    letter-spacing: -0.025em;
}

h1 {
    font-size: 4rem;
    background: linear-gradient(to right, #fff, #94a3b8);
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    text-shadow: 0 2px 10px rgba(255, 255, 255, 0.1);
}

h2 {
    font-size: 2.5rem;
}

p {
    margin-bottom: 1.5rem;
    color: var(--text-muted);
    font-size: 1.1rem;
}

a {
    text-decoration: none;
    color: var(--primary-color);
    transition: all var(--transition-speed);
    position: relative;
}

/* Layout & Container */
.container {
    max-width: 1280px;
    margin: 0 auto;
    padding: 0 2rem;
}

/* Navbar with Glassmorphism */
.navbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem 2rem;
    position: sticky;
    top: 1rem;
    z-index: 100;
    border-radius: 1rem;
    margin: 0 1rem;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--glass-border);
    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.1);
    animation: slideDown 0.8s var(--ease-out-back);
    gap: 2rem;
    /* Force minimum space between Logo and Links */
}

.logo {
    font-size: 1.5rem;
    font-weight: 900;
    background: linear-gradient(135deg, var(--secondary-color), var(--primary-color));
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    letter-spacing: -0.05em;
    margin-right: auto;
    /* Push nav-links to the right explicitly */
    padding-right: 1rem;
    /* Extra safety buffer */
}

.nav-links {
    display: flex;
    gap: 2.5rem;
    align-items: center;
}

.nav-links a:not(.btn) {
    color: var(--text-muted);
    font-weight: 500;
    font-size: 0.95rem;
}

.nav-links a:not(.btn):hover {
    color: var(--text-main);
    text-shadow: 0 0 10px rgba(255, 255, 255, 0.3);
}

/* Buttons with Glow Effects */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.75rem 1.75rem;
    border-radius: 0.75rem;
    font-weight: 600;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border: none;
    font-size: 1rem;
    letter-spacing: 0.01em;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-hover));
    color: white;
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.2);
    position: relative;
    overflow: hidden;
}

.btn-primary::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transition: 0.5s;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(99, 102, 241, 0.5);
}

.btn-primary:hover::before {
    left: 100%;
}

.btn-outline {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--glass-border);
    color: var(--text-main);
}

.btn-outline:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: var(--primary-color);
    transform: translateY(-2px);
}

.btn-sm {
    padding: 0.5rem 1.25rem;
    font-size: 0.9rem;
}

/* Navbar Responsive Tweaks */
@media (max-width: 1024px) {
    .navbar {
        padding: 1rem 1.5rem;
    }

    .nav-links {
        gap: 1.5rem;
    }
}

/* Cards & Containers */
.form-container,
.hero-card,
.election-card,
.candidate-card,
.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--glass-border);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    box-shadow: var(--shadow-lg);
    border-radius: 1.5rem;
    position: relative;
    overflow: hidden;
}

/* Add a subtle shine effect to cards */
.form-container::after,
.hero-card::after,
.election-card::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--glass-highlight), transparent);
}

.form-container {
    max-width: 480px;
    margin: 6rem auto;
    padding: 3rem;
    animation: fadeInUp 0.8s var(--ease-out-back);
}

/* Inputs */
.form-group {
    margin-bottom: 1.75rem;
}

.form-label {
    display: block;
    margin-bottom: 0.75rem;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-muted);
    margin-left: 0.25rem;
}

.form-control {
    width: 100%;
    padding: 1rem 1.25rem;
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid var(--glass-border);
    border-radius: 0.75rem;
    color: var(--text-main);
    font-family: var(--font-main);
    transition: all 0.3s ease;
    font-size: 1rem;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary-color);
    background: rgba(15, 23, 42, 0.8);
    box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.15);
    transform: translateY(-1px);
}

/* Hero Section */
.hero {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8rem 0;
    gap: 4rem;
    position: relative;
}

.hero-content {
    flex: 1;
    animation: fadeInLeft 1s var(--ease-out-back);
}

.hero-title span {
    background: linear-gradient(to right, var(--secondary-color), var(--primary-color));
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    position: relative;
}

.hero-image {
    flex: 1;
    display: flex;
    justify-content: center;
    position: relative;
    animation: fadeInRight 1s var(--ease-out-back);
}

.hero-card {
    padding: 2.5rem;
    transform: perspective(1000px) rotateY(-5deg) rotateX(5deg);
    transition: transform 0.5s ease;
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: linear-gradient(145deg, rgba(30, 41, 59, 0.9), rgba(15, 23, 42, 0.95));
}

.hero-card:hover {
    transform: perspective(1000px) rotateY(0deg) rotateX(0deg) translateY(-10px);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.5);
}

/* Animations */
@keyframes slideDown {
    from {
        transform: translateY(-100%);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

@keyframes fadeInUp {
    from {
        transform: translateY(40px);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

@keyframes fadeInLeft {
    from {
        transform: translateX(-50px);
        opacity: 0;
    }

    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes fadeInRight {
    from {
        transform: translateX(50px);
        opacity: 0;
    }

    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes float {

    0%,
    100% {
        transform: translateY(0px);
    }

    50% {
        transform: translateY(-20px);
    }
}

/* Footer */
footer {
    margin-top: auto;
    padding: 3rem 0;
    text-align: center;
    border-top: 1px solid var(--glass-border);
    color: var(--text-muted);
    background: rgba(15, 23, 42, 0.3);
    backdrop-filter: blur(10px);
}

/* Utilities */
.text-center {
    text-align: center;
}

.mb-4 {
    margin-bottom: 1.5rem;
}

.mt-4 {
    margin-top: 1.5rem;
}

/* Dashboard Grid Enhancements */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 2rem;
    margin-top: 3rem;
}

.election-card {
    padding: 2rem;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.election-card:hover {
    transform: translateY(-10px) scale(1.02);
    border-color: var(--primary-color);
    box-shadow: 0 20px 40px -10px rgba(99, 102, 241, 0.2);
}

/* Candidate Cards */
.candidate-card {
    border-radius: 1.5rem;
    transition: all 0.3s ease;
}

.candidate-card:hover {
    transform: translateY(-8px);
    box-shadow: 0 15px 30px rgba(0, 0, 0, 0.4);
}

.candidate-card.selected {
    border-color: var(--secondary-color);
    box-shadow: 0 0 0 2px var(--secondary-color), 0 15px 30px rgba(14, 165, 233, 0.2);
}

/* Admin Sidebar */
.sidebar {
    background: rgba(15, 23, 42, 0.9);
    backdrop-filter: blur(20px);
    border-right: 1px solid var(--glass-border);
}

.sidebar-link {
    border-radius: 0.75rem;
    margin-bottom: 0.75rem;
    font-weight: 500;
}

.sidebar-link:hover,
.sidebar-link.active {
    background: linear-gradient(90deg, rgba(99, 102, 241, 0.1), transparent);
    color: var(--primary-color);
    padding-left: 1.25rem;
    /* Slide effect */
}

/* --- Mobile Responsiveness & UX Improvements --- */

@media (max-width: 992px) {
    h1 {
        font-size: 3rem;
    }

    .hero {
        padding: 6rem 0;
        gap: 2rem;
    }

    .container {
        padding: 0 1.5rem;
    }
}

@media (max-width: 768px) {

    /* Typography Adjustments */
    h1 {
        font-size: 2.5rem;
    }

    h2 {
        font-size: 2rem;
    }

    p {
        font-size: 1rem;
    }

    /* Navbar Mobile Layout */
    .navbar {
        flex-direction: column;
        padding: 1rem;
        gap: 1rem;
    }

    .nav-links {
        width: 100%;
        justify-content: center;
        gap: 1.5rem;
        flex-wrap: wrap;
    }

    /* Hero Section Mobile */
    .hero {
        flex-direction: column;
        text-align: center;
        padding: 4rem 0;
    }

    .hero-content {
        order: 1;
        /* Text comes first */
    }

    .hero-image {
        order: 2;
        width: 100%;
        margin-top: 2rem;
    }

    .hero-card {
        transform: none !important;
        /* Disable 3D tilt on mobile for better performance */
        margin: 0 auto;
        max-width: 350px;
    }

    .hero-title br {
        display: none;
        /* Remove line breaks in title on mobile */
    }

    /* Form Adjustments */
    .form-container {
        margin: 2rem auto;
        padding: 1.5rem;
        width: 100%;
    }

    /* Dashboard & Grid Adjustments */
    .dashboard-grid,
    .candidate-grid,
    .stats-grid {
        grid-template-columns: 1fr;
        /* Single column on mobile */
        gap: 1.5rem;
    }

    /* Admin Layout Mobile */
    .admin-layout {
        grid-template-columns: 1fr;
    }

    .sidebar {
        display: none;
        /* Hide sidebar on mobile for now (would need hamburger menu in real app) */
    }

    /* Add a mobile nav for admin if needed, or just stack */
    .main-content {
        padding: 1rem;
    }
}

@media (max-width: 480px) {
    .navbar {
        padding: 0.75rem;
    }

    .logo {
        font-size: 1.25rem;
    }

    .btn {
        padding: 0.6rem 1.2rem;
        font-size: 0.9rem;
    }

    .hero {
        padding: 3rem 0;
    }

    h1 {
        font-size: 2rem;
    }

    .nav-links {
        gap: 1rem;
    }

    .nav-links a {
        font-size: 0.9rem;
    }
}

/* Alert / Flash Messages */
.alert {
    padding: 1rem;
    margin-bottom: 1.5rem;
    border-radius: 0.75rem;
    font-weight: 500;
    font-size: 0.95rem;
    display: flex;
    align-items: center;
    animation: slideDown 0.5s ease-out;
}

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

.alert-success {
    background: rgba(34, 197, 94, 0.15);
    border: 1px solid rgba(34, 197, 94, 0.3);
    color: #86efac;
}

.alert-warning {
    background: rgba(234, 179, 8, 0.15);
    border: 1px solid rgba(234, 179, 8, 0.3);
    color: #fde047;
}

.alert-info {
    background: rgba(59, 130, 246, 0.15);
    border: 1px solid rgba(59, 130, 246, 0.3);
    color: #93c5fd;
}