/* Material Design Variables */
:root {
    --primary-color: #1976d2;
    --primary-dark: #1565c0;
    --primary-light: #42a5f5;
    --secondary-color: #ffc107;
    --secondary-dark: #ff8f00;
    --secondary-light: #fff350;
    --surface-color: #ffffff;
    --background-color: #f5f5f5;
    --error-color: #d32f2f;
    --success-color: #388e3c;
    --warning-color: #f57c00;
    --info-color: #0288d1;
    --text-primary: #212121;
    --text-secondary: #757575;
    --text-disabled: #bdbdbd;
    --divider-color: #e0e0e0;
    
    /* Shadows */
    --shadow-1: 0 1px 3px rgba(0,0,0,0.12), 0 1px 2px rgba(0,0,0,0.24);
    --shadow-2: 0 3px 6px rgba(0,0,0,0.16), 0 3px 6px rgba(0,0,0,0.23);
    --shadow-3: 0 10px 20px rgba(0,0,0,0.19), 0 6px 6px rgba(0,0,0,0.23);
    --shadow-4: 0 14px 28px rgba(0,0,0,0.25), 0 10px 10px rgba(0,0,0,0.22);
    --shadow-5: 0 19px 38px rgba(0,0,0,0.30), 0 15px 12px rgba(0,0,0,0.22);
    
    /* Border radius */
    --border-radius-sm: 4px;
    --border-radius-md: 8px;
    --border-radius-lg: 16px;
    --border-radius-xl: 24px;
    
    /* Transitions */
    --transition-fast: 0.15s cubic-bezier(0.4, 0.0, 0.2, 1);
    --transition-normal: 0.3s cubic-bezier(0.4, 0.0, 0.2, 1);
    --transition-slow: 0.5s cubic-bezier(0.4, 0.0, 0.2, 1);
}

/* Base Styles */
* {
    box-sizing: border-box;
}

body {
    font-family: 'Roboto', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background-color: var(--background-color);
    color: var(--text-primary);
    line-height: 1.6;
    margin: 0;
    padding: 0;
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Typography */
h1, h2, h3, h4, h5, h6 {
    font-weight: 500;
    line-height: 1.2;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

h1 { font-size: 2.5rem; font-weight: 300; }
h2 { font-size: 2rem; font-weight: 400; }
h3 { font-size: 1.75rem; }
h4 { font-size: 1.5rem; }
h5 { font-size: 1.25rem; }
h6 { font-size: 1rem; }

p {
    margin-bottom: 1rem;
    color: var(--text-secondary);
}

/* Material Design Components */
.material-card {
    background: var(--surface-color);
    border-radius: var(--border-radius-md);
    box-shadow: var(--shadow-1);
    transition: box-shadow var(--transition-normal);
    border: none;
    overflow: hidden;
}

.material-card:hover {
    box-shadow: var(--shadow-2);
}

.material-card.elevated {
    box-shadow: var(--shadow-3);
}

.material-card.elevated:hover {
    box-shadow: var(--shadow-4);
}

/* Buttons */
.btn {
    border-radius: var(--border-radius-sm);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 12px 24px;
    border: none;
    cursor: pointer;
    transition: all var(--transition-normal);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    font-size: 0.875rem;
    min-height: 48px;
    position: relative;
    overflow: hidden;
}

.btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: currentColor;
    opacity: 0;
    transition: opacity var(--transition-fast);
}

.btn:hover::before {
    opacity: 0.08;
}

.btn:focus::before {
    opacity: 0.12;
}

.btn:active::before {
    opacity: 0.16;
}

.btn-primary {
    background-color: var(--primary-color);
    color: white;
    box-shadow: var(--shadow-1);
}

.btn-primary:hover {
    background-color: var(--primary-dark);
    box-shadow: var(--shadow-2);
    color: white;
}

.btn-secondary {
    background-color: var(--secondary-color);
    color: var(--text-primary);
    box-shadow: var(--shadow-1);
}

.btn-secondary:hover {
    background-color: var(--secondary-dark);
    box-shadow: var(--shadow-2);
    color: white;
}

.btn-success {
    background-color: var(--success-color);
    color: white;
    box-shadow: var(--shadow-1);
}

.btn-success:hover {
    background-color: #2e7d32;
    box-shadow: var(--shadow-2);
    color: white;
}

.btn-warning {
    background-color: var(--warning-color);
    color: white;
    box-shadow: var(--shadow-1);
}

.btn-warning:hover {
    background-color: #ef6c00;
    box-shadow: var(--shadow-2);
    color: white;
}

.btn-danger {
    background-color: var(--error-color);
    color: white;
    box-shadow: var(--shadow-1);
}

.btn-danger:hover {
    background-color: #c62828;
    box-shadow: var(--shadow-2);
    color: white;
}

.btn-outline-primary {
    background-color: transparent;
    color: var(--primary-color);
    border: 2px solid var(--primary-color);
    box-shadow: none;
}

.btn-outline-primary:hover {
    background-color: var(--primary-color);
    color: white;
}

.btn-outline-secondary {
    background-color: transparent;
    color: var(--text-secondary);
    border: 2px solid var(--divider-color);
    box-shadow: none;
}

.btn-outline-secondary:hover {
    background-color: var(--text-secondary);
    color: white;
}

.btn-fab {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    padding: 0;
    box-shadow: var(--shadow-3);
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 1000;
}

.btn-fab:hover {
    box-shadow: var(--shadow-4);
}

/* Form Controls */
.form-control {
    border: none;
    border-bottom: 2px solid var(--divider-color);
    border-radius: 0;
    padding: 12px 0;
    background: transparent;
    font-size: 1rem;
    transition: border-color var(--transition-normal);
    box-shadow: none;
}

.form-control:focus {
    border-bottom-color: var(--primary-color);
    box-shadow: none;
    outline: none;
}

.form-label {
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 8px;
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.form-floating {
    position: relative;
}

.form-floating > .form-control {
    padding: 24px 12px 8px;
    border: 1px solid var(--divider-color);
    border-radius: var(--border-radius-sm);
    background: var(--surface-color);
}

.form-floating > label {
    position: absolute;
    top: 0;
    left: 12px;
    height: 100%;
    padding: 16px 0;
    pointer-events: none;
    border: none;
    transform-origin: 0 0;
    transition: all var(--transition-normal);
    color: var(--text-secondary);
    font-size: 1rem;
}

.form-floating > .form-control:focus ~ label,
.form-floating > .form-control:not(:placeholder-shown) ~ label {
    transform: scale(0.75) translateY(-0.5rem);
    color: var(--primary-color);
}

/* Navigation */
.navbar {
    background-color: var(--primary-color);
    box-shadow: var(--shadow-2);
    padding: 0;
    min-height: 64px;
}

.navbar-brand {
    font-weight: 500;
    font-size: 1.25rem;
    color: white !important;
    padding: 16px 0;
    display: flex;
    align-items: center;
}

.navbar-nav .nav-link {
    color: rgba(255, 255, 255, 0.87) !important;
    font-weight: 500;
    padding: 20px 16px !important;
    transition: all var(--transition-normal);
    position: relative;
}

.navbar-nav .nav-link:hover {
    color: white !important;
    background-color: rgba(255, 255, 255, 0.08);
}

.navbar-nav .nav-link.active {
    color: white !important;
    background-color: rgba(255, 255, 255, 0.12);
}

.navbar-toggler {
    border: none;
    padding: 4px 8px;
}

.navbar-toggler:focus {
    box-shadow: none;
}

/* Cards */
.card {
    background: var(--surface-color);
    border-radius: var(--border-radius-md);
    box-shadow: var(--shadow-1);
    border: none;
    overflow: hidden;
    transition: all var(--transition-normal);
}

.card:hover {
    box-shadow: var(--shadow-2);
}

.card-header {
    background-color: var(--surface-color);
    border-bottom: 1px solid var(--divider-color);
    padding: 24px;
    font-weight: 500;
    color: var(--text-primary);
}

.card-body {
    padding: 24px;
}

.card-title {
    font-weight: 500;
    margin-bottom: 16px;
    color: var(--text-primary);
}

.card-text {
    color: var(--text-secondary);
    margin-bottom: 16px;
}

/* Candidate Cards */
.candidate-card {
    cursor: pointer;
    transition: all var(--transition-normal);
    border: 2px solid transparent;
    position: relative;
    overflow: hidden;
}

.candidate-card:hover {
    box-shadow: var(--shadow-3);
    transform: translateY(-4px);
}

.candidate-card.selected {
    border-color: var(--primary-color);
    box-shadow: var(--shadow-3);
    transform: translateY(-4px);
}

.candidate-card.selected::after {
    content: '✓';
    position: absolute;
    top: 12px;
    right: 12px;
    background: var(--primary-color);
    color: white;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 18px;
}

.candidate-image-wrapper {
    height: 240px;               /* fixed box height */
    width: 100%;
    display: flex;               /* flexbox to center */
    justify-content: center;     /* horizontal center */
    align-items: center;         /* vertical center */
    background: #f8f9fa;         /* optional: background filler */
    overflow: hidden;
}

.candidate-image {
    max-height: 100%;
    max-width: 100%;
    object-fit: contain;         /* no cropping, keeps full image */
}
.candidate-card:hover .candidate-image {
    transform: scale(1.05);
}

/* Alerts */
.alert {
    border-radius: var(--border-radius-md);
    border: none;
    padding: 16px 24px;
    margin-bottom: 24px;
    box-shadow: var(--shadow-1);
}

.alert-success {
    background-color: #e8f5e8;
    color: var(--success-color);
    border-left: 4px solid var(--success-color);
}

.alert-info {
    background-color: #e3f2fd;
    color: var(--info-color);
    border-left: 4px solid var(--info-color);
}

.alert-warning {
    background-color: #fff3e0;
    color: var(--warning-color);
    border-left: 4px solid var(--warning-color);
}

.alert-danger {
    background-color: #ffebee;
    color: var(--error-color);
    border-left: 4px solid var(--error-color);
}

.alert-heading {
    font-weight: 500;
    margin-bottom: 8px;
}

/* Tables */
.table {
    background: var(--surface-color);
    border-radius: var(--border-radius-md);
    overflow: hidden;
    box-shadow: var(--shadow-1);
}

.table th {
    background-color: #fafafa;
    font-weight: 500;
    color: var(--text-primary);
    border-bottom: 1px solid var(--divider-color);
    padding: 16px;
}

.table td {
    padding: 16px;
    border-bottom: 1px solid var(--divider-color);
    color: var(--text-secondary);
}

.table-striped tbody tr:nth-of-type(odd) {
    background-color: rgba(0, 0, 0, 0.02);
}

/* Badges */
.badge {
    font-weight: 500;
    padding: 6px 12px;
    border-radius: var(--border-radius-lg);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.bg-success {
    background-color: var(--success-color) !important;
}

.bg-info {
    background-color: var(--info-color) !important;
}

.bg-warning {
    background-color: var(--warning-color) !important;
}

.bg-secondary {
    background-color: var(--text-secondary) !important;
}

/* Progress */
.progress {
    height: 8px;
    border-radius: var(--border-radius-sm);
    background-color: var(--divider-color);
    overflow: hidden;
}

.progress-bar {
    background-color: var(--primary-color);
    transition: width var(--transition-normal);
}

/* Countdown */
.countdown {
    font-size: 2.5rem;
    font-weight: 300;
    color: var(--primary-color);
    font-family: 'Roboto Mono', monospace;
    text-align: center;
    padding: 24px;
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    border-radius: var(--border-radius-lg);
    margin: 24px 0;
    box-shadow: var(--shadow-1);
}

/* Sticky Submit Bar */
.sticky-submit {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--surface-color);
    padding: 16px 0;
    box-shadow: var(--shadow-3);
    z-index: 1000;
    border-top: 1px solid var(--divider-color);
}

/* Footer */
footer {
    background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary-color) 100%);
    color: white;
    padding: 48px 0 24px;
    margin-top: 64px;
}

footer a {
    color: rgba(255, 255, 255, 0.87);
    text-decoration: none;
    transition: color var(--transition-normal);
}

footer a:hover {
    color: var(--secondary-light);
}

footer .p {
    color: var(--surface-color);
}

/* Admin Sidebar */
.admin-sidebar {
    background: var(--surface-color);
    border-radius: var(--border-radius-md);
    box-shadow: var(--shadow-1);
    overflow: hidden;
}

.list-group-item {
    border: none;
    padding: 16px 24px;
    color: var(--text-secondary);
    transition: all var(--transition-normal);
    border-left: 4px solid transparent;
}

.list-group-item:hover {
    background-color: rgba(25, 118, 210, 0.04);
    color: var(--primary-color);
}

.list-group-item.active {
    background-color: rgba(25, 118, 210, 0.08);
    color: var(--primary-color);
    border-left-color: var(--primary-color);
    font-weight: 500;
}

/* Statistics Cards */
.stat-card {
    text-align: center;
    padding: 32px 24px;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-light) 100%);
    color: white;
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-2);
    transition: transform var(--transition-normal);
}

.stat-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-3);
}

.stat-number {
    font-size: 3rem;
    font-weight: 300;
    margin-bottom: 8px;
    display: block;
}

.stat-label {
    font-size: 0.875rem;
    opacity: 0.9;
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* Loading Animation */
.loading {
    display: inline-block;
    width: 24px;
    height: 24px;
    border: 3px solid rgba(25, 118, 210, 0.3);
    border-radius: 50%;
    border-top-color: var(--primary-color);
    animation: spin 1s ease-in-out infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

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

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

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

/* Responsive Design */
@media (max-width: 768px) {
    .container {
        padding-left: 16px;
        padding-right: 16px;
    }
    
    .card-body {
        padding: 16px;
    }
    
    .card-header {
        padding: 16px;
    }
    
    .candidate-image {
        height: 200px;
    }
    
    .countdown {
        font-size: 2rem;
        padding: 16px;
    }
    
    .stat-number {
        font-size: 2.5rem;
    }
    
    h1 { font-size: 2rem; }
    h2 { font-size: 1.75rem; }
    h3 { font-size: 1.5rem; }
    
    .btn-fab {
        bottom: 16px;
        right: 16px;
        width: 48px;
        height: 48px;
    }
    
    .sticky-submit {
        padding: 12px 0;
    }
}

@media (max-width: 576px) {
    .navbar-brand {
        font-size: 1.1rem;
    }
    
    .candidate-image {
        height: 160px;
    }
    
    .countdown {
        font-size: 1.5rem;
        padding: 12px;
    }
    
    .card-body {
        padding: 12px;
    }
    
    .card-header {
        padding: 12px;
    }
}

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

/* Focus styles for accessibility */
.btn:focus,
.form-control:focus,
.nav-link:focus {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    :root {
        --shadow-1: 0 0 0 1px rgba(0,0,0,0.5);
        --shadow-2: 0 0 0 2px rgba(0,0,0,0.5);
        --shadow-3: 0 0 0 3px rgba(0,0,0,0.5);
    }
}

/* Print styles */
@media print {
    .navbar,
    .sticky-submit,
    .btn-fab,
    footer {
        display: none !important;
    }
    
    .card {
        box-shadow: none !important;
        border: 1px solid #000 !important;
    }
}