/* 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;
}


/* 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: #2f3c4c;
    /* 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: #1a56db;
}

/* 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: 10px;
    background-color: #4ec491;
    color: #fff;
    cursor: pointer;
    transition: all 0.2s ease;
}

.msa-vote-btn:hover {
    background-color: #3fae82;
    transform: translateY(-1px);
}


/* Voting page container */
.msa-vote-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    width: 100%;
    background: linear-gradient(180deg, #eef8f3 0%, #f7faf8 400px, #f7faf8 100%);
    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: 10px;
    background: #4ec491;
    color: #fff;
    cursor: pointer;
    transition: all 0.2s ease;
}

.msa-vote-btn:hover {
    background: #3fae82;
    transform: translateY(-1px);
}

/* 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: #f7faf8;
    --msa-card-bg: #ffffff;
    --msa-accent: #4ec491;
    --msa-accent-dark: #3fae82;
    --msa-urgent: #f70300;
    --msa-text: #2f3c4c;
    --msa-text-dim: #566476;
    --msa-border: #e2e8f0;
}

.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: var(--msa-accent);
    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 var(--msa-border);
    border-radius: 15px;
    width: 260px;
    padding: 30px 20px;
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: center;
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.05);
}

.msa-candidate-card:hover {
    transform: translateY(-5px);
    border-color: var(--msa-accent);
}

/* 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 var(--msa-border);
    background-color: #f1f5f9;
    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 var(--msa-border);
    border-radius: 5px;
    font-size: 0.8rem;
    font-weight: bold;
    color: var(--msa-text-dim);
    transition: 0.3s;
}

/* Confirm Button */
.msa-action-area {
    text-align: center;
}

.msa-confirm-btn {
    background: var(--msa-urgent);
    color: white;
    border: none;
    padding: 18px 60px;
    font-size: 1.1rem;
    font-weight: bold;
    border-radius: 10px;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(247, 3, 0, 0.2);
    transition: 0.2s ease;
}

.msa-confirm-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(247, 3, 0, 0.28);
}

/* 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 var(--msa-border);
    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 {
    --msa-r-bg: #f7faf8;
    --msa-r-card-bg: #ffffff;
    --msa-r-border: #e2e8f0;
    --msa-r-accent: #4ec491;
    --msa-r-urgent: #f70300;
    --msa-r-text: #2f3c4c;
    --msa-r-text-dim: #566476;
    --winner: #16a34a;
    --danger: #dc2626;
}

.msa-dashboard {
    background: var(--msa-r-bg);
    color: var(--msa-r-text);
    padding: 20px;
    border-radius: 16px;
    font-family: 'Inter', -apple-system, sans-serif;
    max-width: 1100px;
    margin: auto;
    border: 1px solid var(--msa-r-border);
    box-shadow: 0 2px 12px rgba(15, 23, 42, 0.06);
}

.msa-top-bar {
    display: flex;
    flex-direction: column;
    gap: 15px;
    border-bottom: 2px solid var(--msa-r-border);
    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(--msa-r-card-bg);
    border: 1px solid var(--msa-r-border);
    border-radius: 15px;
    padding: 20px;
    position: relative;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.05);
}

.msa-card::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
    background: var(--msa-r-accent);
}

.msa-pos-name {
    font-size: 1.1rem;
    font-weight: 700;
    text-transform: uppercase;
    margin-bottom: 20px;
    color: var(--msa-r-accent);
    display: flex;
    justify-content: space-between;
    flex-wrap: wrap;
}

/* 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: #eef2f7;
    height: 10px;
    border-radius: 5px;
}

.msa-bar-fill {
    height: 100%;
    background: var(--msa-r-accent);
    border-radius: 5px;
}

/* 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(1, 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: 10px 14px;
    background: #ecfdf3;
    color: #166534;
    border: 1px solid #bbf7d0;
    border-radius: 6px;
    font-weight: 700;
    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;
}











/* Candidate photo — circular, results page */
.msa-result-candidate-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.msa-result-photo {
    width: 32px !important;
    height: 32px !important;
    max-width: 32px !important;
    border-radius: 50% !important;
    object-fit: cover !important;
    object-position: center top;
    flex-shrink: 0;
    border: 2px solid rgba(255, 255, 255, 0.15);
    background: #1a202c;
    display: block;
}

.msa-result-photo.msa-photo-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 700;
    color: #94a3b8;
    background: #263041;
}

.msa-result-photo-lg {
    width: 56px !important;
    height: 56px !important;
    max-width: 56px !important;
    border-radius: 50% !important;
    object-fit: cover !important;
    object-position: center top;
    border: 2px solid rgba(255, 255, 255, 0.15);
    background: #1a202c;
    flex-shrink: 0;
    display: block;
}

@media (max-width: 480px) {
    .msa-result-photo {
        width: 26px !important;
        height: 26px !important;
        max-width: 26px !important;
    }

    .msa-result-photo-lg {
        width: 44px !important;
        height: 44px !important;
        max-width: 44px !important;
    }

    .msa-result-candidate-row {
        gap: 8px;
    }
}



.msa-candidate-columns {
    display: flex;
    gap: 12px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.msa-candidate-column {
    flex: 1 1 0;
    min-width: 100px;
    text-align: center;
    border-top: 4px solid var(--msa-r-accent);
    padding-top: 10px;
}

.msa-candidate-column-name {
    font-size: 0.85rem;
    font-weight: 700;
    text-transform: uppercase;
    margin-top: 8px;
    color: var(--msa-r-text);
    word-break: break-word;
}

.msa-candidate-column-percent {
    font-size: 1.4rem;
    font-weight: 800;
    margin-top: 4px;
}

.msa-segmented-bar {
    display: flex;
    width: 100%;
    height: 22px;
    border-radius: 6px;
    overflow: hidden;
    background: #eef2f7;
    position: relative;
    margin-bottom: 14px;
    border: 1px solid var(--msa-r-border);
}

.msa-bar-segment {
    height: 100%;
    transition: flex-basis 0.4s ease;
}

.msa-bar-50-marker {
    position: absolute;
    left: 50%;
    top: -4px;
    bottom: -4px;
    width: 2px;
    background: #1e293b;
}

.msa-candidate-votes-row {
    margin-bottom: 0;
}

.msa-candidate-votes {
    flex: 1 1 0;
    min-width: 100px;
    text-align: center;
    font-size: 0.85rem;
    color: var(--msa-r-text-dim);
}

@media (max-width: 480px) {
    .msa-candidate-column-name {
        font-size: 0.7rem;
    }

    .msa-candidate-column-percent {
        font-size: 1.1rem;
    }
}