/* ==================== CSS VARIABLES ==================== */
:root {
    /* Primary Colors - Official Election Blue Theme */
    --primary-dark: #0d1b4c;
    --primary: #1a237e;
    --primary-light: #3949ab;
    --primary-lighter: #5c6bc0;
    
    /* Accent Colors */
    --accent: #2196f3;
    --accent-light: #64b5f6;
    
    /* Status Colors */
    --success: #4caf50;
    --success-light: #81c784;
    --warning: #ff9800;
    --error: #f44336;
    
    /* Neutral Colors */
    --white: #ffffff;
    --gray-50: #fafafa;
    --gray-100: #f5f5f5;
    --gray-200: #eeeeee;
    --gray-300: #e0e0e0;
    --gray-400: #bdbdbd;
    --gray-500: #9e9e9e;
    --gray-600: #757575;
    --gray-700: #616161;
    --gray-800: #424242;
    --gray-900: #212121;
    
    /* Shadows */
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.12), 0 1px 2px rgba(0,0,0,0.24);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.1), 0 2px 4px rgba(0,0,0,0.06);
    --shadow-lg: 0 10px 25px rgba(0,0,0,0.15), 0 5px 10px rgba(0,0,0,0.05);
    --shadow-xl: 0 20px 40px rgba(0,0,0,0.2);
    
    /* Border Radius */
    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;
    
    /* Transitions */
    --transition-fast: 0.15s ease;
    --transition-normal: 0.3s ease;
    --transition-slow: 0.5s ease;
}

/* ==================== RESET & BASE ==================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: 'Roboto', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 50%, var(--primary-light) 100%);
    min-height: 100vh;
    color: var(--gray-800);
    line-height: 1.6;
}

/* ==================== CONTAINER ==================== */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ==================== HEADER ==================== */
.header {
    background: var(--white);
    border-radius: var(--radius-lg);
    padding: 15px 25px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: var(--shadow-lg);
    margin-bottom: 30px;
}

.logo-section {
    display: flex;
    align-items: center;
    gap: 15px;
}

.emblem {
    font-size: 2.5rem;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.title-section h1 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary);
    letter-spacing: -0.5px;
}

.subtitle {
    font-size: 0.875rem;
    color: var(--gray-600);
    font-weight: 400;
}

.voter-info {
    display: flex;
    align-items: center;
    gap: 15px;
}

.voter-badge {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--gray-100);
    padding: 8px 15px;
    border-radius: var(--radius-md);
    font-weight: 500;
    color: var(--gray-700);
}

.badge-icon {
    font-size: 1.25rem;
}

/* ==================== BUTTONS ==================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 24px;
    border: none;
    border-radius: var(--radius-md);
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-normal);
    text-decoration: none;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
    color: var(--white);
    box-shadow: var(--shadow-md);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.btn-secondary {
    background: var(--gray-200);
    color: var(--gray-700);
}

.btn-secondary:hover {
    background: var(--gray-300);
}

.btn-success {
    background: linear-gradient(135deg, var(--success) 0%, var(--success-light) 100%);
    color: var(--white);
}

.btn-success:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

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

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

.btn-sm {
    padding: 8px 16px;
    font-size: 0.875rem;
}

.btn-vote {
    background: linear-gradient(135deg, var(--success) 0%, #2e7d32 100%);
    color: var(--white);
    font-weight: 600;
    padding: 12px 30px;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
}

.btn-vote:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 20px rgba(76, 175, 80, 0.4);
}

/* ==================== LOGIN PAGE ==================== */
.login-container {
    flex: 1;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 30px;
    align-items: start;
}

.login-card {
    background: var(--white);
    border-radius: var(--radius-xl);
    padding: 40px;
    box-shadow: var(--shadow-xl);
}

.card-header {
    text-align: center;
    margin-bottom: 30px;
}

.icon-circle {
    width: 80px;
    height: 80px;
    background: linear-gradient(135deg, var(--primary-light) 0%, var(--primary) 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 20px;
    box-shadow: var(--shadow-lg);
}

.login-icon {
    font-size: 2.5rem;
}

.card-header h2 {
    font-size: 1.75rem;
    color: var(--gray-900);
    margin-bottom: 8px;
}

.card-header p {
    color: var(--gray-600);
}

.login-form {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.form-group label {
    font-weight: 500;
    color: var(--gray-700);
}

.input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.input-icon {
    position: absolute;
    left: 15px;
    font-size: 1.25rem;
    pointer-events: none;
}

.input-wrapper input {
    width: 100%;
    padding: 15px 15px 15px 50px;
    border: 2px solid var(--gray-300);
    border-radius: var(--radius-md);
    font-size: 1rem;
    transition: all var(--transition-normal);
}

.input-wrapper input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(26, 35, 126, 0.1);
}

.input-wrapper input::placeholder {
    color: var(--gray-400);
}

.hint {
    font-size: 0.8rem;
    color: var(--gray-500);
}

.error-message {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 15px;
    background: #ffebee;
    border: 1px solid #ffcdd2;
    border-radius: var(--radius-md);
    color: var(--error);
}

.error-message.hidden {
    display: none;
}

.card-footer {
    margin-top: 20px;
    text-align: center;
}

.security-note {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    color: var(--gray-600);
    font-size: 0.875rem;
}

/* ==================== INFO SECTION ==================== */
.info-section {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.info-card {
    background: rgba(255, 255, 255, 0.95);
    border-radius: var(--radius-lg);
    padding: 25px;
    box-shadow: var(--shadow-md);
}

.info-card h3 {
    font-size: 1.1rem;
    color: var(--primary);
    margin-bottom: 15px;
}

.info-card ul, .info-card ol {
    padding-left: 20px;
    color: var(--gray-700);
}

.info-card li {
    margin-bottom: 8px;
}

.demo-info {
    background: linear-gradient(135deg, #e3f2fd 0%, #bbdefb 100%);
    border: 2px solid var(--accent);
}

.demo-ids {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 10px;
}

.demo-ids code {
    background: var(--white);
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    font-family: 'Consolas', monospace;
    font-size: 0.875rem;
    color: var(--primary);
    border: 1px solid var(--accent-light);
}

/* ==================== EVM MACHINE ==================== */
.evm-container {
    flex: 1;
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 30px;
    align-items: start;
}

.evm-machine {
    background: linear-gradient(180deg, #e8e8e8 0%, #d0d0d0 100%);
    border-radius: var(--radius-xl);
    padding: 0;
    box-shadow: var(--shadow-xl), inset 0 2px 0 rgba(255,255,255,0.5);
    border: 3px solid #888;
    overflow: hidden;
}

.evm-header {
    background: linear-gradient(180deg, var(--primary) 0%, var(--primary-dark) 100%);
    padding: 20px;
    text-align: center;
    color: var(--white);
}

.evm-title {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
    margin-bottom: 10px;
}

.evm-title h2 {
    font-size: 1.25rem;
    letter-spacing: 2px;
}

.evm-light {
    width: 12px;
    height: 12px;
    background: #4caf50;
    border-radius: 50%;
    box-shadow: 0 0 10px #4caf50, 0 0 20px #4caf50;
    animation: blink 1.5s ease-in-out infinite;
}

@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.evm-instruction {
    font-size: 0.875rem;
    opacity: 0.9;
}

.candidates-list {
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 2px;
    background: var(--gray-100);
}

.candidate-row {
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: center;
    background: var(--white);
    border: 2px solid var(--gray-300);
    border-radius: 0;
    overflow: hidden;
    transition: all var(--transition-fast);
}

.candidate-row:hover {
    border-color: var(--primary-light);
    box-shadow: var(--shadow-md);
}

.candidate-info {
    display: flex;
    align-items: center;
    gap: 20px;
    padding: 20px;
}

.candidate-serial {
    width: 40px;
    height: 40px;
    background: var(--primary);
    color: var(--white);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1.1rem;
}

.candidate-symbol {
    font-size: 2.5rem;
    width: 60px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--gray-100);
    border-radius: var(--radius-md);
    border: 2px solid var(--gray-300);
}

.candidate-details h4 {
    font-size: 1.1rem;
    color: var(--gray-900);
    margin-bottom: 4px;
}

.candidate-details p {
    font-size: 0.875rem;
    color: var(--gray-600);
}

.vote-button-container {
    padding: 20px;
    background: var(--gray-100);
    border-left: 3px solid var(--gray-300);
}

.evm-footer {
    background: var(--gray-200);
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-top: 2px solid var(--gray-300);
}

.evm-status {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.875rem;
    color: var(--gray-700);
}

.status-light {
    width: 10px;
    height: 10px;
    background: var(--gray-400);
    border-radius: 50%;
}

.status-light.active {
    background: var(--success);
    box-shadow: 0 0 8px var(--success);
}

.evm-serial {
    font-size: 0.75rem;
    color: var(--gray-500);
    font-family: 'Consolas', monospace;
}

.ballot-info {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.warning-card {
    background: #fff3e0;
    border: 2px solid var(--warning);
}

.warning-card h3 {
    color: #e65100;
}

/* ==================== MODAL ==================== */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(5px);
}

.modal-overlay.hidden {
    display: none;
}

.modal {
    background: var(--white);
    border-radius: var(--radius-xl);
    width: 90%;
    max-width: 450px;
    box-shadow: var(--shadow-xl);
    animation: modalSlide 0.3s ease;
}

@keyframes modalSlide {
    from {
        opacity: 0;
        transform: translateY(-30px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.modal-header {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
    color: var(--white);
    padding: 20px 25px;
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
}

.modal-header h3 {
    font-size: 1.25rem;
}

.modal-body {
    padding: 30px;
    text-align: center;
}

.selected-candidate {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 20px;
    background: var(--gray-100);
    padding: 20px;
    border-radius: var(--radius-lg);
    margin-bottom: 20px;
}

.selected-candidate .candidate-symbol {
    font-size: 3rem;
}

.selected-candidate .candidate-details h4 {
    font-size: 1.25rem;
}

.confirm-text {
    font-size: 1.1rem;
    color: var(--gray-700);
    margin-bottom: 10px;
}

.warning-text {
    font-size: 0.875rem;
    color: var(--warning);
}

.modal-footer {
    padding: 20px 30px;
    background: var(--gray-50);
    border-radius: 0 0 var(--radius-xl) var(--radius-xl);
    display: flex;
    justify-content: flex-end;
    gap: 15px;
}

/* ==================== THANK YOU PAGE ==================== */
.thankyou-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 30px;
    padding: 40px 0;
}

.thankyou-card {
    background: var(--white);
    border-radius: var(--radius-xl);
    padding: 50px;
    text-align: center;
    box-shadow: var(--shadow-xl);
    max-width: 500px;
    width: 100%;
}

.success-animation {
    margin-bottom: 30px;
}

.checkmark-circle {
    width: 100px;
    height: 100px;
    background: linear-gradient(135deg, var(--success) 0%, var(--success-light) 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto;
    animation: scaleIn 0.5s ease;
    box-shadow: 0 10px 30px rgba(76, 175, 80, 0.3);
}

@keyframes scaleIn {
    from {
        transform: scale(0);
    }
    to {
        transform: scale(1);
    }
}

.checkmark {
    width: 40px;
    height: 20px;
    border-left: 5px solid var(--white);
    border-bottom: 5px solid var(--white);
    transform: rotate(-45deg);
    animation: checkDraw 0.3s ease 0.3s both;
}

@keyframes checkDraw {
    from {
        opacity: 0;
        transform: rotate(-45deg) scale(0);
    }
    to {
        opacity: 1;
        transform: rotate(-45deg) scale(1);
    }
}

.thankyou-title {
    font-size: 2rem;
    color: var(--success);
    margin-bottom: 15px;
}

.thankyou-message {
    color: var(--gray-600);
    margin-bottom: 30px;
}

.vote-receipt {
    background: var(--gray-50);
    border: 2px dashed var(--gray-300);
    border-radius: var(--radius-lg);
    overflow: hidden;
    text-align: left;
    margin-bottom: 30px;
}

.receipt-header {
    background: var(--primary);
    color: var(--white);
    padding: 15px 20px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.receipt-icon {
    font-size: 1.5rem;
}

.receipt-header h3 {
    font-size: 1rem;
}

.receipt-body {
    padding: 20px;
}

.receipt-row {
    display: flex;
    justify-content: space-between;
    padding: 10px 0;
    border-bottom: 1px solid var(--gray-200);
}

.receipt-row:last-child {
    border-bottom: none;
}

.receipt-label {
    color: var(--gray-600);
}

.receipt-value {
    font-weight: 500;
    color: var(--gray-800);
}

.status-success {
    color: var(--success);
}

.thankyou-actions {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.action-text {
    color: var(--gray-500);
    font-size: 0.875rem;
}

.democracy-section {
    max-width: 500px;
    width: 100%;
}

.democracy-card {
    background: rgba(255, 255, 255, 0.9);
    border-radius: var(--radius-lg);
    padding: 30px;
    text-align: center;
}

.democracy-icon {
    font-size: 3rem;
    margin-bottom: 15px;
    display: block;
}

.democracy-card h3 {
    color: var(--primary);
    margin-bottom: 10px;
}

.democracy-card p {
    color: var(--gray-600);
}

/* ==================== RESULTS PAGE ==================== */
.results-container {
    flex: 1;
}

.results-header {
    background: var(--white);
    border-radius: var(--radius-lg);
    padding: 25px;
    display: flex;
    align-items: center;
    gap: 20px;
    margin-bottom: 30px;
    box-shadow: var(--shadow-md);
}

.results-header h2 {
    flex: 1;
    color: var(--primary);
}

.last-updated {
    color: var(--gray-500);
    font-size: 0.875rem;
}

.total-votes-card {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
    border-radius: var(--radius-lg);
    padding: 30px;
    display: flex;
    align-items: center;
    gap: 20px;
    margin-bottom: 30px;
    color: var(--white);
    box-shadow: var(--shadow-lg);
}

.total-votes-icon {
    font-size: 3rem;
}

.total-label {
    display: block;
    font-size: 0.875rem;
    opacity: 0.9;
    margin-bottom: 5px;
}

.total-count {
    font-size: 2.5rem;
    font-weight: 700;
}

.results-chart {
    background: var(--white);
    border-radius: var(--radius-lg);
    padding: 30px;
    margin-bottom: 30px;
    box-shadow: var(--shadow-md);
}

.result-bar-container {
    margin-bottom: 25px;
}

.result-bar-container:last-child {
    margin-bottom: 0;
}

.result-candidate {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 10px;
}

.result-rank {
    font-weight: 700;
    color: var(--gray-500);
    min-width: 30px;
}

.result-symbol {
    font-size: 1.5rem;
}

.result-info {
    flex: 1;
}

.result-name {
    font-weight: 600;
    color: var(--gray-800);
    display: block;
}

.result-party {
    font-size: 0.8rem;
    color: var(--gray-500);
}

.result-bar-wrapper {
    display: flex;
    align-items: center;
    gap: 15px;
}

.result-bar {
    height: 35px;
    background: linear-gradient(90deg, var(--primary) 0%, var(--primary-light) 100%);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    padding: 0 15px;
    min-width: 80px;
    transition: width 0.5s ease;
}

.result-votes {
    color: var(--white);
    font-weight: 500;
    font-size: 0.875rem;
    white-space: nowrap;
}

.result-percentage {
    font-weight: 700;
    color: var(--primary);
    min-width: 60px;
}

.results-table-container {
    background: var(--white);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-md);
}

.results-table {
    width: 100%;
    border-collapse: collapse;
}

.results-table th,
.results-table td {
    padding: 15px 20px;
    text-align: left;
}

.results-table th {
    background: var(--primary);
    color: var(--white);
    font-weight: 500;
}

.results-table tr:nth-child(even) {
    background: var(--gray-50);
}

.results-table tr.leading {
    background: #e8f5e9;
}

.rank-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: var(--gray-200);
    font-weight: 700;
    font-size: 0.875rem;
}

.rank-badge.gold {
    background: linear-gradient(135deg, #ffd700 0%, #ffb300 100%);
    color: var(--white);
}

.rank-badge.silver {
    background: linear-gradient(135deg, #e0e0e0 0%, #bdbdbd 100%);
}

.rank-badge.bronze {
    background: linear-gradient(135deg, #cd7f32 0%, #a0522d 100%);
    color: var(--white);
}

.candidate-cell {
    display: flex;
    align-items: center;
    gap: 10px;
}

.candidate-cell .symbol {
    font-size: 1.25rem;
}

.percentage-cell {
    display: flex;
    align-items: center;
    gap: 10px;
}

.mini-bar {
    height: 8px;
    background: var(--primary);
    border-radius: 4px;
    max-width: 100px;
}

/* ==================== LOADING SPINNER ==================== */
.loading {
    text-align: center;
    padding: 40px;
    color: var(--gray-500);
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid var(--gray-200);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 15px;
}

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

/* ==================== FOOTER ==================== */
.footer {
    background: rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-lg);
    padding: 20px;
    text-align: center;
    margin-top: auto;
    color: rgba(255, 255, 255, 0.8);
}

.footer-note {
    font-size: 0.8rem;
    opacity: 0.7;
}

/* ==================== UTILITIES ==================== */
.hidden {
    display: none !important;
}

/* ==================== RESPONSIVE DESIGN ==================== */
@media (max-width: 900px) {
    .login-container,
    .evm-container {
        grid-template-columns: 1fr;
    }

    .header {
        flex-direction: column;
        gap: 15px;
        text-align: center;
    }

    .logo-section {
        flex-direction: column;
    }

    .candidate-row {
        grid-template-columns: 1fr;
    }

    .vote-button-container {
        border-left: none;
        border-top: 3px solid var(--gray-300);
        display: flex;
        justify-content: center;
    }

    .results-header {
        flex-direction: column;
        text-align: center;
    }

    .results-table {
        font-size: 0.875rem;
    }

    .results-table th,
    .results-table td {
        padding: 10px;
    }
}

@media (max-width: 480px) {
    .container {
        padding: 10px;
    }

    .login-card,
    .thankyou-card {
        padding: 25px;
    }

    .modal {
        width: 95%;
        margin: 10px;
    }

    .candidate-info {
        flex-wrap: wrap;
        gap: 10px;
    }

    .total-votes-card {
        flex-direction: column;
        text-align: center;
    }
}
