/* Container for the single candidate logic */
.msa-single-view {
    display: flex;
    flex-direction: column;
    align-items: center;
    /* This centers the children horizontally */
    width: 100%;
    margin-bottom: 40px;
}

/* Wrapper to ensure the card itself doesn't stretch */
.msa-single-candidate-wrapper {
    display: flex;
    justify-content: center;
    width: 100%;
    margin-bottom: 30px;
}

/* Ensure the card has a fixed width or auto-width that centers */
.msa-single-view .msa-candidate-card {
    width: 280px;
    /* Adjust to match your grid card width */
    margin: 0;
    /* Remove side margins so flex handles centering */
}

/* Ensure buttons are centered and proportional */
.msa-decision-row {
    display: flex;
    justify-content: center;
    gap: 20px;
    width: 100%;
    max-width: 600px;
    /* Width of both buttons combined */
}

.msa-binary-option {
    flex: 1;
    /* Makes both buttons equal width */
    max-width: 280px;
}

/* Photo fix - ensure the image doesn't break if URL is empty */
.msa-photo-wrapper img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
    display: block;
}



/* Container to center everything on screen */
.msa-vote-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    width: 100%;
    background-color: #4ec491;
    /* Green background for the voting page */
    font-family: Arial, sans-serif;
}

/* Card style for voting and welcome screens */
.msa-vote-card {
    background-color: #fff;
    color: #333;
    padding: 40px 30px;
    border-radius: 12px;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.2);
    max-width: 450px;
    width: 90%;
    text-align: center;
    margin: 20px auto;
}

/* Specific Responsive Fix for Voter Verification */
@media screen and (max-width: 480px) {
    .msa-vote-welcome-title {
        font-size: 2rem !important;
        /* Scale down the 'Voter Verification' text */
    }

    .msa-vote-card {
        padding: 25px 20px !important;
        /* Tighten padding for more screen space */
    }

    /* Fix the Token Input to prevent it from bleeding out of the card */
    #msa-token-form input[name="token"] {
        font-size: 1.2rem !important;
        /* Smaller font on mobile */
        letter-spacing: 2px !important;
        /* Tighter spacing so 6 digits fit */
        width: 100% !important;
        max-width: 250px;
        padding: 10px !important;
    }

    .msa-vote-btn {
        width: 100%;
        /* Make the 'Continue' button easy to tap */
        font-size: 1.1rem;
    }
}


/* Welcome screen title */
.msa-vote-welcome-title {
    font-size: 3rem;
    margin-bottom: 20px;
    color: #F70300;
    /* Optional: red accent */
}

/* Welcome screen paragraph */
.msa-vote-welcome-text {
    font-size: 1.2rem;
    margin-bottom: 30px;
    color: #333;
}

/* Voting position title */
.msa-position-title {
    font-size: 2.5rem;
    margin-bottom: 20px;
    color: #4ec491;
}

/* Single candidate name (yes/no type) */
.msa-single-candidate-name {
    font-size: 1.5rem;
    margin-bottom: 15px;
}

/* Each candidate option */
.msa-candidate-option {
    display: block;
    font-size: 1.2rem;
    margin: 10px 0;
    cursor: pointer;
}

/* Voting buttons */
.msa-vote-btn {
    font-size: 1.2rem;
    padding: 12px 30px;
    border: none;
    border-radius: 8px;
    background-color: #F70300;
    color: #fff;
    cursor: pointer;
    transition: background-color 0.2s;
}

.msa-vote-btn:hover {
    background-color: #773800;
}



/* Voting page container */
.msa-vote-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    width: 100%;
    background: linear-gradient(135deg, #4ec491, #3a9d88);
    font-family: 'Arial', sans-serif;
    padding: 20px;
}

/* Voting card */
.msa-vote-card {
    background: #fff;
    border-radius: 15px;
    padding: 40px 30px;
    max-width: 600px;
    width: 100%;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
    text-align: center;
}

.msa-vote-card h2 {
    font-size: 2.5rem;
    margin-bottom: 25px;
    color: #333;
}

/* Single candidate name */
.msa-single-candidate-name {
    font-size: 1.5rem;
    margin-bottom: 20px;
    color: #555;
}

/* Candidate options as cards */
.msa-candidate-option {
    display: block;
    border: 2px solid #ddd;
    border-radius: 10px;
    padding: 15px 20px;
    margin: 10px 0;
    cursor: pointer;
    font-size: 1.2rem;
    transition: all 0.2s ease;
    background-color: #f9f9f9;
}

.msa-candidate-option:hover {
    border-color: #4ec491;
    background-color: #e0f7ef;
}

/* Hide default radio buttons */
.msa-candidate-option input[type="radio"] {
    display: none;
}

/* Selected candidate */
.msa-candidate-option.selected {
    border-color: #4ec491;
    background-color: #d4f0e6;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

/* Next button */
.msa-vote-btn {
    font-size: 1.2rem;
    padding: 12px 30px;
    border: none;
    border-radius: 8px;
    background: #F70300;
    color: #fff;
    cursor: pointer;
    transition: all 0.2s ease;
}

.msa-vote-btn:hover {
    background: #d40000;
    transform: translateY(-2px);
}

/* Responsive */
@media (max-width: 768px) {
    .msa-vote-card {
        padding: 30px 20px;
    }

    .msa-vote-card h2 {
        font-size: 2rem;
    }

    .msa-candidate-option {
        font-size: 1rem;
    }

    .msa-vote-btn {
        width: 100%;
    }

    #msa-index-form {
        display: flex;
        flex-direction: column; /* Force vertical stack on mobile */
        gap: 15px;             /* This creates the gap between input and button */
        align-items: center;
    }

    #msa-index-form input[type="text"] {
        width: 100%;           /* Full width for easier typing */
        padding: 12px;
        box-sizing: border-box;
    }

    .msa-vote-btn {
        width: 100%;           /* Full width button on mobile */
    }
}

/* Desktop layout: keep them side-by-side */




/* Progress bar container */
.msa-progress-bar {
    width: 100%;
    height: 12px;
    background-color: #e0e0e0;
    border-radius: 6px;
    margin-bottom: 25px;
    overflow: hidden;
}

/* Progress fill */
.msa-progress-fill {
    height: 100%;
    background-color: #F70300;
    /* Matches button color */
    width: 0;
    border-radius: 6px;
    transition: width 0.4s ease-in-out;
}





:root {
    --msa-bg: #1a202c;
    --msa-card-bg: #2d3748;
    --msa-accent: #48bb78;
    --msa-text: #ffffff;
    --msa-text-dim: #a0aec0;
}

.msa-election-ui {
    max-width: 1000px;
    margin: 40px auto;
    font-family: 'Inter', system-ui, sans-serif;
    color: var(--msa-text);
    padding: 20px;
}

/* Progress Bar */
.msa-progress-container {
    width: 100%;
    height: 6px;
    background: #4a5568;
    border-radius: 10px;
    margin-bottom: 40px;
    overflow: hidden;
}

.msa-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #38b2ac, #48bb78);
    transition: width 0.5s ease;
}

/* Header */
.msa-vote-header {
    text-align: center;
    margin-bottom: 50px;
}

.msa-position-title {
    font-size: 1.8rem;
    letter-spacing: 2px;
    margin-bottom: 10px;
}

.msa-instruction {
    color: var(--msa-text-dim);
    font-size: 0.9rem;
}

/* Grid Layout */
.msa-candidates-grid {
    display: flex;
    justify-content: center;
    gap: 25px;
    flex-wrap: wrap;
    margin-bottom: 50px;
}

/* Candidate Card */
.msa-candidate-card {
    position: relative;
    background: var(--msa-card-bg);
    border: 2px solid transparent;
    border-radius: 15px;
    width: 260px;
    padding: 30px 20px;
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: center;
}

.msa-candidate-card:hover {
    transform: translateY(-5px);
    border-color: #4a5568;
}

/* Hide Radio Button */
.msa-candidate-card input[type="radio"] {
    position: absolute;
    opacity: 0;
}

/* Selected State */
.msa-candidate-card input[type="radio"]:checked+.msa-card-content {
    color: var(--msa-text);
}

.msa-candidate-card input[type="radio"]:checked~.msa-card-content .msa-photo-wrapper {
    border-color: var(--msa-accent);
    box-shadow: 0 0 15px rgba(72, 187, 120, 0.4);
}

.msa-candidate-card input[type="radio"]:checked~.msa-card-content .msa-select-badge {
    background: var(--msa-accent);
    color: white;
}

.msa-candidate-card:has(input:checked) {
    border-color: var(--msa-accent);
    background: rgba(72, 187, 120, 0.05);
}

/* Photos */
.msa-photo-wrapper {
    width: 140px;
    height: 140px;
    margin: 0 auto 20px;
    border-radius: 10px;
    overflow: hidden;
    border: 3px solid #4a5568;
    background-color: #1a202c;
    /* prevents visible gaps */
    display: flex;
    align-items: center;
    justify-content: center;
}



.msa-candidate-name {
    font-size: 1.2rem;
    font-weight: 700;
    margin-bottom: 20px;
    text-transform: uppercase;
}

.msa-select-badge {
    display: inline-block;
    padding: 8px 24px;
    border: 1px solid #4a5568;
    border-radius: 5px;
    font-size: 0.8rem;
    font-weight: bold;
    transition: 0.3s;
}

/* Confirm Button */
.msa-action-area {
    text-align: center;
}

.msa-confirm-btn {
    background: linear-gradient(135deg, #48bb78 0%, #38a169 100%);
    color: white;
    border: none;
    padding: 18px 60px;
    font-size: 1.1rem;
    font-weight: bold;
    border-radius: 8px;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
    transition: 0.3s;
}

.msa-confirm-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 20px rgba(72, 187, 120, 0.4);
}

/* Negative Option Styling */
.msa-negation-card .msa-no-photo {
    display: flex;
    align-items: center;
    justify-content: center;
    background: #2d3748;
    font-size: 3rem;
    color: #e53e3e;
}

/* Responsive */
@media (max-width: 600px) {
    .msa-candidate-card {
        width: 100%;
    }
}


/* Single Candidate Special Styling */
.msa-single-view {
    max-width: 500px;
    margin: 0 auto 40px;
    text-align: center;
}

.msa-photo-wrapper.large {
    width: 200px;
    height: 200px;
    margin-bottom: 25px;
}

/* Decision Row (Yes/No Buttons) */
.msa-decision-row {
    display: flex;
    gap: 20px;
    justify-content: center;
    margin-top: 30px;
}

.msa-binary-option {
    flex: 1;
    cursor: pointer;
}

.msa-binary-option input {
    position: absolute;
    opacity: 0;
}

.msa-binary-box {
    padding: 20px;
    background: var(--msa-card-bg);
    border: 2px solid #4a5568;
    font-weight: bold;
    font-size: 1.2rem;
    transition: all 0.3s ease;
    color: var(--msa-text-dim);
}

/* Yes Styling */
.msa-yes input:checked+.msa-binary-box {
    background: rgba(72, 187, 120, 0.2);
    border-color: #48bb78;
    color: #48bb78;
    box-shadow: 0 0 15px rgba(72, 187, 120, 0.3);
}

/* No Styling */
.msa-no input:checked+.msa-binary-box {
    background: rgba(229, 62, 62, 0.2);
    border-color: #e53e3e;
    color: #e53e3e;
    box-shadow: 0 0 15px rgba(229, 62, 62, 0.3);
}

.msa-binary-box:hover {
    border-color: #718096;
    transform: translateY(-2px);
}






:root {
    --glass: rgba(15, 23, 42, 0.85);
    --accent: #38bdf8;
    --winner: #10b981;
    --danger: #ef4444;
    --text-main: #f8fafc;
}

.msa-dashboard {
    background: radial-gradient(circle at top left, #1e293b, #0f172a);
    color: var(--text-main);
    padding: 20px;
    /* Reduced for mobile */
    border-radius: 20px;
    font-family: 'Inter', -apple-system, sans-serif;
    max-width: 1100px;
    margin: auto;
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
}

.msa-top-bar {
    display: flex;
    flex-direction: column;
    /* Stack header on mobile */
    gap: 15px;
    border-bottom: 2px solid var(--accent);
    padding-bottom: 15px;
    margin-bottom: 30px;
}

.msa-live-tag {
    display: inline-block;
    background: var(--danger);
    color: white;
    padding: 5px 15px;
    font-weight: 800;
    font-size: 12px;
    border-radius: 4px;
    letter-spacing: 2px;
    animation: pulse 1.5s infinite;
    width: fit-content;
}

/* Responsive Grid: 1 column on mobile, scales up automatically */
.msa-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 20px;
}

.msa-card {
    background: var(--glass);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 15px;
    padding: 20px;
    position: relative;
    overflow: hidden;
}

.msa-card::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
    background: var(--accent);
}

.msa-pos-name {
    font-size: 1.1rem;
    font-weight: 700;
    text-transform: uppercase;
    margin-bottom: 20px;
    color: var(--accent);
    display: flex;
    justify-content: space-between;
    flex-wrap: wrap;
    /* Wraps ID on small screens */
}

/* Bar UI for Multi-Candidate */
.msa-bar-container {
    margin-bottom: 15px;
}

.msa-bar-info {
    display: flex;
    justify-content: space-between;
    margin-bottom: 5px;
    font-size: 0.85rem;
}

.msa-bar-rail {
    background: rgba(255, 255, 255, 0.1);
    height: 10px;
    border-radius: 5px;
}

.msa-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, #0ea5e9, #38bdf8);
    border-radius: 5px;
    box-shadow: 0 0 10px rgba(56, 189, 248, 0.5);
}

/* Chart UI: Stack on mobile, side-by-side on desktop */
.msa-chart-flex {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    text-align: center;
}

.msa-chart-area {
    width: 150px;
    height: 150px;
}

.msa-stats {
    flex: 1;
}

/* TABLET & DESKTOP ADJUSTMENTS */
@media (min-width: 768px) {
    .msa-dashboard {
        padding: 40px;
    }

    .msa-top-bar {
        flex-direction: row;
        justify-content: space-between;
        align-items: flex-end;
    }

    .msa-grid {
        grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    }

    .msa-chart-flex {
        flex-direction: row;
        text-align: left;
    }

    .msa-chart-area {
        width: 120px;
        height: 120px;
    }
}

@keyframes pulse {
    0% {
        opacity: 1;
    }

    50% {
        opacity: 0.4;
    }

    100% {
        opacity: 1;
    }
}


.msa-winner-badge {
    margin: 10px 0;
    padding: 8px 12px;
    background: #111827;
    color: #fff;
    border-radius: 6px;
    font-weight: 600;
    text-align: center;
}

.msa-notice.success {
    background: #e6fffa;
    border-left: 4px solid #0d9488;
    padding: 12px;
    margin-bottom: 15px;
    font-weight: 500;
}


.msa-confirm-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background-color: #cccccc !important;
    border-color: #999999 !important;
}