/* ============================================================
   voter.css — styles specific to the voter-facing ballot pages
   ============================================================ */

/* Prevent text selection and screenshot-friendly copy */
body.voter-layout * {
    user-select: none;
    -webkit-user-select: none;
}
body.voter-layout {
    overflow-x: hidden;
    min-height: 100vh;
}
body.voter-layout.kiosk-flow-page,
body.voter-layout.kiosk-enter-page {
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}
html:has(body.voter-layout.kiosk-flow-page),
html:has(body.voter-layout.kiosk-enter-page) {
    overflow-y: auto;
    height: auto;
}

/* Allow selecting the code input field */
body.voter-layout input[type="text"],
body.voter-layout input[type="password"] {
    user-select: text;
    -webkit-user-select: text;
}

.voter-layout .kiosk-main {
    min-height: calc(100vh - 44px);
    display: flex;
    align-items: flex-start;
    justify-content: center;
}
.voter-layout .kiosk-footer-text {
    font-size: 0.9rem;
    color: #4e5963;
    letter-spacing: 0.02em;
}
.kiosk-master-page .kiosk-master-hero {
    background: #ffffff;
}
.kiosk-master-page .kiosk-open-count {
    font-size: 0.9rem;
    letter-spacing: 0.02em;
}
.kiosk-master-page .kiosk-election-card {
    transition: transform 0.12s ease, box-shadow 0.12s ease;
}
.kiosk-master-page .kiosk-election-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.08) !important;
}
.kiosk-master-page .kiosk-election-title {
    line-height: 1.25;
}
.kiosk-enter-page .kiosk-main {
    align-items: center;
}

.kiosk-flow-page .kiosk-main {
    align-items: flex-start;
    display: block;
    min-height: auto;
    overflow: visible;
    padding-bottom: 2rem;
}

.voter-layout #voter_code {
    border: 2px solid #1f4f7a;
    border-radius: 10px;
}

.voter-layout #voter_code:focus {
    border-color: #0d3f6c;
    box-shadow: 0 0 0 0.15rem rgba(13, 63, 108, 0.2);
}

/* Large touch-friendly form checks for tablets */
.voter-layout .form-check-input {
    width: 1.4em;
    height: 1.4em;
    margin-top: 0.2em;
    cursor: pointer;
}
.voter-layout .form-check-label {
    font-size: 1rem;
    padding-left: 0.4rem;
    cursor: pointer;
}

/* Large icon-style candidate tiles for category ballots */
.candidate-grid {
    display: flex;
    flex-wrap: nowrap;
    overflow-x: auto;
    gap: 16px;
    padding-bottom: 10px;
    justify-content: flex-start;
}
.candidate-tile {
    border: 3px solid #cddbd6;
    border-radius: 16px;
    background: #fff;
    padding: 16px 12px;
    text-align: center;
    cursor: pointer;
    transition: border-color 0.15s ease, background-color 0.15s ease;
    min-width: 220px;
    max-width: 220px;
    flex: 0 0 220px;
    position: relative;
}
.candidate-tile:hover {
    border-color: #7a9d96;
}
.candidate-check {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}
.candidate-avatar {
    width: 100%;
    height: 170px;
    border-radius: 10px;
    object-fit: contain;
    background: #f5f7f6;
    margin: 0 auto 12px;
    display: block;
}
.candidate-avatar-fallback {
    background: #d9e6e1;
}
.candidate-name {
    font-size: 1.12rem;
    font-weight: 700;
    line-height: 1.3;
    color: #1a2c38;
}
.candidate-tile.is-selected {
    border-color: #167743;
    background: #eaf8f0;
}
.candidate-tile.is-selected::before {
    content: "";
    position: absolute;
    top: 8px;
    right: 8px;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: #198754;
}
.candidate-tile.is-selected::after {
    content: "";
    position: absolute;
    top: 16px;
    right: 16px;
    width: 8px;
    height: 4px;
    border-left: 2px solid #fff;
    border-bottom: 2px solid #fff;
    transform: rotate(-45deg);
}
.candidate-tile.is-disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Default kiosk ballot grid: avoid edge clipping on wider screens */
.kiosk-flow-page .category-step .candidate-grid {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 14px;
    overflow: visible;
    padding-bottom: 0;
}
.kiosk-flow-page .category-step .candidate-tile {
    min-width: 0;
    max-width: none;
    flex: initial;
    width: 100%;
}

.voter-layout .ballot-section .card-header {
    font-size: 1.2rem;
    padding-top: .9rem;
    padding-bottom: .9rem;
}

.category-step-nav {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 14px;
    position: sticky;
    bottom: 0;
    z-index: 20;
    background: #f8f9fa;
    padding: 0.75rem 0;
    margin-top: 1rem;
    border-top: 1px solid #dee2e6;
}

.nav-arrow-btn {
    border: 0;
    border-radius: 14px;
    min-height: 62px;
    font-size: 1.05rem;
    font-weight: 700;
    padding: 0 18px;
}

.nav-arrow-prev {
    background: #e7ecea;
    color: #234;
    min-width: 170px;
}

.nav-arrow-next {
    position: relative;
    color: #fff;
    background: #198754;
    min-width: 210px;
    text-align: left;
    padding-right: 56px;
}

.nav-arrow-next::after {
    content: "";
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    width: 0;
    height: 0;
    border-top: 13px solid transparent;
    border-bottom: 13px solid transparent;
    border-left: 18px solid #fff;
}

.nav-arrow-btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.selection-confirm-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
    gap: 10px;
}
.selection-confirm-card {
    border: 1px solid #dbe6e2;
    border-radius: 10px;
    padding: 8px;
    text-align: center;
    background: #fff;
}
.selection-confirm-card img {
    width: 100%;
    height: 100px;
    object-fit: contain;
    border-radius: 8px;
    background: #f5f7f6;
    margin-bottom: 6px;
}
.selection-confirm-name {
    font-size: .85rem;
    font-weight: 700;
}

/* Review page cards */
.review-candidate-row {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-start;
    gap: 14px;
}
.review-candidate-card {
    flex: 0 0 210px;
    max-width: 210px;
    border: 1px solid #dbe6e2;
    border-radius: 12px;
    background: #fff;
    padding: 10px;
    text-align: center;
}
.review-candidate-photo {
    width: 100%;
    height: 145px;
    object-fit: cover;
    border-radius: 8px;
    background: #f5f7f6;
    display: block;
    margin-bottom: 8px;
}
.review-candidate-photo-empty {
    display: flex;
    align-items: center;
    justify-content: center;
    color: #6f7f8e;
    font-size: .9rem;
}
.review-candidate-name {
    font-weight: 700;
    color: #1b2e3a;
    font-size: .95rem;
    line-height: 1.25;
}
.review-page {
    width: 100%;
}
.review-page.review-fixed-layout {
    display: flex;
    flex-direction: column;
    min-height: auto;
    overflow: visible;
}
.review-page.review-fixed-layout .review-groups {
    flex: 1;
    overflow: visible;
    padding-right: 4px;
}
.review-page.review-fixed-layout .review-actions {
    margin-top: 10px;
    padding-top: 8px;
    border-top: 1px solid #dfe8e5;
    background: #f8fbfa;
    position: sticky;
    bottom: 0;
}
.review-category-section {
    background: #f8fbfa;
    border: 1px solid #d7e4df;
    border-radius: 12px;
    padding: 10px 12px 12px;
    display: flex;
    flex-direction: column;
    align-items: center;
}
.review-category-title {
    font-weight: 800;
    color: #0f3e68;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 6px;
    width: 100%;
    justify-content: center;
}
.review-info-card {
    border: 1px solid #f4deb4;
    background: #fff7e6;
    color: #5f4717;
    border-radius: 12px;
    padding: 10px 12px;
}
.review-actions {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.selection-rule {
    font-size: .95rem;
    color: #1d4f76;
}

/* Category selection counter badge */
.cat-counter {
    font-size: 0.8rem;
    min-width: 120px;
    text-align: center;
}
.cat-counter.complete  { background-color: #198754 !important; }
.cat-counter.over      { background-color: #dc3545 !important; }
.cat-counter.partial   { background-color: #0d6efd !important; }

/* Confirmation check mark */
.confirm-check {
    color: #198754;
    font-size: 5rem;
    line-height: 1;
}

/* Tablet landscape / small laptop stabilization */
@media (min-width: 769px) and (max-width: 1100px) {
    .voter-layout .container.kiosk-main {
        max-width: 100% !important;
        padding-left: 14px !important;
        padding-right: 14px !important;
    }

    .kiosk-flow-page .category-step .candidate-grid {
        display: grid;
        grid-template-columns: repeat(4, minmax(0, 1fr));
        gap: 12px;
        overflow: visible;
        padding-bottom: 0;
    }

    .kiosk-flow-page .category-step .candidate-tile {
        min-width: 0;
        max-width: none;
        flex: initial;
        width: 100%;
        padding: 10px 8px;
    }

    .candidate-avatar {
        height: 120px;
        margin-bottom: 8px;
    }

    .candidate-name {
        font-size: .92rem;
        line-height: 1.2;
    }

    .category-step-nav {
        gap: 10px;
        flex-wrap: wrap;
    }

    .nav-arrow-btn {
        min-height: 50px;
        font-size: .95rem;
        padding: 0 14px;
    }

    .nav-arrow-prev {
        min-width: 130px;
    }

    .nav-arrow-next {
        min-width: 165px;
        padding-right: 44px;
    }
}

@media (max-width: 900px) {
    .review-candidate-card {
        flex: 0 0 170px;
        max-width: 170px;
    }
    .review-candidate-photo {
        height: 125px;
    }
}

/* ============================================================
   Mobile-only responsive stabilization (no logic changes)
   ============================================================ */
@media (max-width: 768px) {
    .voter-layout .container.kiosk-main {
        padding-left: 10px !important;
        padding-right: 10px !important;
    }

    .voter-layout .card {
        border-radius: 10px;
    }

    .voter-layout .ballot-section .card-header {
        font-size: 1rem;
        padding: .7rem .75rem;
    }

    .selection-rule {
        font-size: .9rem;
    }
    .kiosk-master-page .kiosk-open-count {
        width: 100%;
        text-align: center;
    }

    .kiosk-flow-page .category-step .candidate-grid {
        gap: 10px;
        justify-content: flex-start;
        padding-bottom: 8px;
        grid-template-columns: repeat(3, minmax(0, 1fr));
        overflow: visible;
    }

    .kiosk-flow-page .category-step .candidate-tile {
        min-width: 168px;
        max-width: 168px;
        flex: 0 0 168px;
        padding: 10px 8px;
        border-width: 2px;
        border-radius: 12px;
        min-width: 0;
        max-width: none;
        flex: initial;
        width: 100%;
    }

    .candidate-avatar {
        height: 110px;
        margin-bottom: 8px;
    }

    .candidate-name {
        font-size: .92rem;
        line-height: 1.2;
    }

    .candidate-tile.is-selected::before {
        width: 22px;
        height: 22px;
        top: 6px;
        right: 6px;
    }

    .candidate-tile.is-selected::after {
        top: 12px;
        right: 12px;
    }

    .category-step-nav {
        gap: 8px;
    }

    .nav-arrow-btn {
        min-height: 48px;
        font-size: .98rem;
        padding: 0 12px;
        border-radius: 10px;
    }

    .nav-arrow-prev {
        min-width: 120px;
    }

    .nav-arrow-next {
        min-width: 150px;
        padding-right: 42px;
    }

    .nav-arrow-next::after {
        border-top-width: 10px;
        border-bottom-width: 10px;
        border-left-width: 14px;
        right: 10px;
    }

    .selection-confirm-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 8px;
    }

    .selection-confirm-card img {
        height: 86px;
        object-fit: cover;
    }

    .review-candidate-row {
        justify-content: center;
        gap: 10px;
    }

    .review-candidate-card {
        flex: 0 0 46%;
        max-width: 46%;
        min-width: 140px;
        padding: 8px;
    }

    .review-candidate-photo {
        height: 105px;
    }

    .review-candidate-name {
        font-size: .88rem;
    }

    .review-category-section {
        width: 100%;
        padding: 8px 8px 10px;
    }
    .review-page.review-fixed-layout {
        height: calc(100vh - 120px);
    }
    .review-page.review-fixed-layout .review-actions {
        padding-top: 6px;
    }
}

@media (max-width: 480px) {
    .voter-layout .kiosk-main {
        min-height: auto;
    }

    .voter-layout h1.h5 {
        font-size: 1rem;
    }

    .voter-layout #voter_code {
        min-height: 52px;
        font-size: 1.1rem;
    }

    .kiosk-flow-page .category-step .candidate-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .kiosk-flow-page .category-step .candidate-tile {
        min-width: 0;
        max-width: none;
        flex: initial;
    }

    .candidate-avatar {
        height: 98px;
    }

    .candidate-name {
        font-size: .86rem;
    }

    .nav-arrow-prev {
        min-width: 108px;
    }

    .nav-arrow-next {
        min-width: 136px;
    }

    .review-candidate-card {
        flex: 0 0 48%;
        max-width: 48%;
        min-width: 0;
    }
}

@media (max-width: 430px) {
    .voter-layout .container.kiosk-main {
        padding-left: 8px !important;
        padding-right: 8px !important;
    }

    .voter-layout .ballot-section .card-header {
        font-size: .94rem;
        padding: .6rem .65rem;
    }

    .cat-counter {
        min-width: 96px;
        font-size: .72rem;
    }

    .kiosk-flow-page .category-step .candidate-grid {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 8px;
        justify-content: stretch;
        overflow: visible;
        padding-bottom: 0;
    }

    .kiosk-flow-page .category-step .candidate-tile {
        min-width: 0;
        max-width: none;
        flex: initial;
        width: 100%;
        padding: 8px 6px;
        border-radius: 10px;
    }

    .candidate-avatar {
        height: 88px;
        border-radius: 7px;
        margin-bottom: 6px;
    }

    .candidate-name {
        font-size: .82rem;
        line-height: 1.15;
    }

    .voter-layout .ballot-section .card-body {
        padding: .65rem .55rem .75rem;
    }

    .voter-layout .ballot-section p {
        margin-bottom: .45rem;
    }

    .category-step-nav {
        gap: 6px;
    }

    .nav-arrow-btn {
        min-height: 44px;
        font-size: .92rem;
        padding: 0 10px;
        border-radius: 9px;
    }

    .nav-arrow-prev {
        min-width: 96px;
    }

    .nav-arrow-next {
        min-width: 126px;
        padding-right: 34px;
    }

    .nav-arrow-next::after {
        border-top-width: 8px;
        border-bottom-width: 8px;
        border-left-width: 11px;
        right: 8px;
    }
}

@media (max-width: 390px) {
    .kiosk-flow-page .category-step .candidate-grid {
        gap: 6px;
    }

    .kiosk-flow-page .category-step .candidate-tile {
        padding: 7px 5px;
    }

    .candidate-avatar {
        height: 78px;
    }

    .candidate-name {
        font-size: .74rem;
    }
}

/* Admin kiosk preview (uses same ballot as voter flow) */
.ballot-preview-notice {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: .65rem;
    margin-bottom: 1rem;
    padding: .65rem .85rem;
    border-radius: 10px;
    background: #fff7e8;
    border: 1px solid #f1d39a;
    color: #6b4e12;
    font-size: .88rem;
    font-weight: 600;
}
.ballot-preview-notice a {
    color: #00305f;
    font-weight: 800;
    text-decoration: none;
}
.ballot-preview-notice a:hover {
    text-decoration: underline;
}
.ballot-preview-complete {
    border-radius: 12px;
    font-weight: 600;
}
