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

:root {
    /* VoteMark brand: navy + red (from votermark-brand.png) */
    --navy-dark:   #041444;
    --brand:       #0b2566;
    --brand-dark:  #061a4a;
    --brand-mid:   #04347c;
    --brand-light: #eaf0fb;
    --accent:      #e30523;
    --accent-dark: #b8041c;
    --success:     #10b981;
    --danger:      #e30523;
    --text:        #0e1a3a;
    --text-muted:  #5b6784;
    --border:      #dfe5f1;
    --bg:          #f5f8fd;
    --card-bg:     #ffffff;
    --radius:      12px;
    --shadow:      0 1px 3px rgba(0,0,0,.08), 0 4px 16px rgba(0,0,0,.06);
}

html, body { height: 100%; font-family: 'Inter', system-ui, sans-serif; background: var(--bg); color: var(--text); }

a { color: inherit; text-decoration: none; }

/* ===== NAV ===== */
.vm-nav {
    position: sticky; top: 0; z-index: 100;
    background: #fff; border-bottom: 3px solid var(--accent);
    box-shadow: 0 1px 3px rgba(0,0,0,.06);
}
.vm-nav-inner {
    max-width: 1100px; margin: 0 auto;
    display: flex; align-items: center; justify-content: space-between;
    padding: 0 1.5rem; height: 64px;
}
.vm-nav-brand { display: flex; align-items: center; flex-shrink: 0; }
.vm-logo { display: block; height: 38px; width: auto; }
@media (max-width: 640px) {
    .vm-nav-inner { padding: 0 1rem; }
    .vm-logo { height: 28px; }
    .vm-nav-links { gap: .75rem; }
    .vm-nav-links > .nav-link:first-child { display: none; }   /* "Polls" - same as the logo link */
}
.vm-nav-links { display: flex; align-items: center; gap: 1.25rem; }
.nav-link { color: var(--text-muted); font-size: .9rem; font-weight: 500; transition: color .15s; white-space: nowrap; }
.nav-link:hover { color: var(--brand); }
.nav-user-menu { display: flex; align-items: center; gap: .75rem; }
.nav-username { font-size: .875rem; font-weight: 600; color: var(--text); }
.nav-link-logout { color: var(--danger); }

/* ===== MAIN ===== */
.vm-main { max-width: 1100px; margin: 0 auto; padding: 2rem 1.5rem 4rem; }

/* ===== BUTTONS ===== */
.btn {
    display: inline-flex; align-items: center; justify-content: center;
    padding: .55rem 1.25rem; border-radius: 8px; font-size: .9rem;
    font-weight: 600; border: 2px solid transparent; cursor: pointer;
    transition: background .15s, border-color .15s, color .15s, transform .1s;
    text-decoration: none;
}
.btn:active { transform: scale(.98); }
.btn-primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn-primary:hover { background: var(--accent-dark); border-color: var(--accent-dark); color: #fff; }
.btn-outline { background: transparent; color: var(--brand); border-color: var(--brand); }
.btn-outline:hover { background: var(--brand-light); }
.btn-block { width: 100%; margin-top: .5rem; }
.btn-lg { padding: .75rem 1.75rem; font-size: 1rem; }
.btn-sm { padding: .35rem .85rem; font-size: .82rem; }
.btn:disabled { opacity: .55; cursor: not-allowed; }

/* ===== ALERTS ===== */
.alert { padding: .75rem 1rem; border-radius: 8px; font-size: .88rem; margin-bottom: 1rem; }
.alert-danger  { background: #fef2f2; color: #b91c1c; border: 1px solid #fecaca; }
.alert-success { background: #f0fdf4; color: #166534; border: 1px solid #bbf7d0; }

/* ===== AUTH PAGES ===== */
.auth-page {
    min-height: calc(100vh - 67px); display: flex;
    align-items: center; justify-content: center; padding: 2rem 1rem;
}
.auth-card {
    background: var(--card-bg); border-radius: var(--radius);
    box-shadow: var(--shadow); padding: 2.5rem; width: 100%; max-width: 420px;
}
.auth-logo { display: flex; align-items: center; margin-bottom: 1.5rem; }
.auth-logo .vm-logo { height: 40px; }
.auth-card h2 { font-size: 1.4rem; font-weight: 700; margin-bottom: 1.25rem; }
.auth-sub { color: var(--text-muted); font-size: .9rem; margin-bottom: 1.25rem; margin-top: -.75rem; }
.auth-links { margin-top: 1.25rem; text-align: center; font-size: .875rem; color: var(--text-muted); display: flex; gap: .5rem; justify-content: center; flex-wrap: wrap; }
.auth-links a { color: var(--brand); font-weight: 600; }

/* ===== FORMS ===== */
.form-group { margin-bottom: 1rem; }
.form-group label { display: block; font-size: .875rem; font-weight: 600; margin-bottom: .35rem; color: var(--text); }
.form-group .optional { font-weight: 400; color: var(--text-muted); }
.form-control {
    width: 100%; padding: .55rem .85rem; border: 1.5px solid var(--border);
    border-radius: 8px; font-size: .9rem; background: #fff; color: var(--text);
    transition: border-color .15s; font-family: inherit;
}
.form-control:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(11,37,102,.14); }
textarea.form-control { resize: vertical; }
.validation-message { font-size: .8rem; color: var(--danger); margin-top: .25rem; }

/* ===== HOME HERO ===== */
.home-hero {
    background: linear-gradient(135deg, var(--navy-dark) 0%, var(--brand) 55%, var(--brand-mid) 100%);
    border-bottom: 4px solid var(--accent);
    color: #fff; border-radius: var(--radius); padding: 3rem 2.5rem;
    margin-bottom: 2.5rem; text-align: center;
}
.home-hero h1 { font-size: 2.25rem; font-weight: 800; margin-bottom: .75rem; }
.home-hero p { font-size: 1.05rem; opacity: .9; margin-bottom: 1.75rem; max-width: 500px; margin-left: auto; margin-right: auto; }
.home-hero .btn { margin: .25rem .35rem; }
.home-hero .btn-outline { border-color: rgba(255,255,255,.7); color: #fff; }
.home-hero .btn-outline:hover { background: rgba(255,255,255,.15); }

/* ===== BANNER CAROUSEL ===== */
.vm-carousel {
    position: relative; margin-bottom: 1.5rem; overflow: hidden;
    border-radius: var(--radius); box-shadow: var(--shadow);
    background: #020308;
}
.vm-carousel-track { position: relative; aspect-ratio: 1536 / 156; }
.vm-slide { position: absolute; inset: 0; opacity: 0; transition: opacity .8s ease; pointer-events: none; }
.vm-slide.active { opacity: 1; pointer-events: auto; }
.vm-slide img { display: block; width: 100%; height: 100%; object-fit: cover; user-select: none; }
.vm-carousel-btn {
    position: absolute; top: 50%; transform: translateY(-50%);
    width: 34px; height: 34px; border-radius: 50%; border: 1px solid rgba(255,255,255,.35);
    background: rgba(4,20,68,.55); color: #fff; font-size: 1.4rem; line-height: 1;
    display: flex; align-items: center; justify-content: center; padding: 0 0 3px;
    cursor: pointer; opacity: 0; transition: opacity .2s, background .15s;
}
.vm-carousel-btn.prev { left: .6rem; }
.vm-carousel-btn.next { right: .6rem; }
.vm-carousel:hover .vm-carousel-btn, .vm-carousel-btn:focus-visible { opacity: 1; }
.vm-carousel-btn:hover { background: var(--accent); border-color: var(--accent); }
.vm-carousel-dots {
    position: absolute; left: 0; right: 0; bottom: .4rem;
    display: flex; justify-content: center; gap: .4rem;
}
.vm-dot {
    width: 8px; height: 8px; padding: 0; border-radius: 50%; cursor: pointer;
    border: 1px solid rgba(255,255,255,.7); background: rgba(255,255,255,.25);
    transition: background .2s, transform .2s;
}
.vm-dot.active { background: var(--accent); border-color: var(--accent); transform: scale(1.25); }
.vm-carousel-btn:focus-visible, .vm-dot:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
@media (max-width: 640px) {
    .vm-carousel-btn { display: none; }
    .vm-carousel-dots { bottom: .2rem; }
}
@media (prefers-reduced-motion: reduce) { .vm-slide { transition: none; } }

/* ===== POLLS GRID ===== */
.section-title { font-size: 1.25rem; font-weight: 700; margin-bottom: 1.25rem; }
.polls-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 1.25rem; }
.poll-card {
    display: flex; flex-direction: column;
    background: var(--card-bg); border-radius: var(--radius);
    border: 1.5px solid var(--border); box-shadow: var(--shadow);
    transition: border-color .15s, box-shadow .15s, transform .15s;
    overflow: hidden; cursor: pointer;
}
.poll-card:hover { border-color: var(--brand); box-shadow: 0 4px 20px rgba(11,37,102,.18); transform: translateY(-2px); }
.poll-card-body { padding: 1.25rem; flex: 1; }
.poll-title { font-size: 1rem; font-weight: 700; margin-bottom: .5rem; color: var(--text); }
.poll-description { font-size: .875rem; color: var(--text-muted); margin-bottom: .75rem; line-height: 1.5; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.poll-meta { display: flex; gap: .75rem; font-size: .8rem; flex-wrap: wrap; }
.poll-choices-count { background: var(--brand-light); color: var(--brand); padding: .2rem .6rem; border-radius: 20px; font-weight: 600; }
.poll-expires { background: #fef9c3; color: #854d0e; padding: .2rem .6rem; border-radius: 20px; font-weight: 600; }
.poll-card-footer {
    padding: .75rem 1.25rem; background: var(--bg); border-top: 1px solid var(--border);
    display: flex; justify-content: space-between; align-items: center;
    font-size: .825rem; color: var(--brand); font-weight: 600;
}
.poll-author { color: var(--text-muted); font-weight: 400; }
.poll-card-mini-results { padding: .75rem 1.25rem; border-top: 1px solid var(--border); background: #fafafa; }
.mini-results-label { display: block; font-size: .68rem; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; color: var(--brand); margin-bottom: .45rem; }
.mini-result-row { display: flex; align-items: center; gap: .5rem; margin-bottom: .3rem; }
.mini-result-row:last-child { margin-bottom: 0; }
.mini-result-choice { font-size: .78rem; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 110px; flex-shrink: 0; }
.mini-result-bar-wrap { flex: 1; background: #e5e7eb; border-radius: 99px; height: 6px; overflow: hidden; }
.mini-result-bar { height: 100%; background: #10b981; border-radius: 99px; min-width: 2px; transition: width .3s; }
.mini-result-pct { font-size: .75rem; font-weight: 700; color: #10b981; width: 36px; text-align: right; flex-shrink: 0; }

/* ===== EMPTY / LOADING ===== */
.empty-state { text-align: center; padding: 4rem 2rem; color: var(--text-muted); }
.empty-icon { font-size: 3.5rem; margin-bottom: 1rem; }
.empty-state h3 { font-size: 1.2rem; font-weight: 700; color: var(--text); margin-bottom: .5rem; }
.empty-state p { margin-bottom: 1.25rem; }
.loading-polls { display: flex; align-items: center; gap: .75rem; padding: 3rem; justify-content: center; color: var(--text-muted); }
.spinner {
    width: 22px; height: 22px; border: 3px solid var(--border);
    border-top-color: var(--brand); border-radius: 50%;
    animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== POLL DETAIL ===== */
.poll-detail { max-width: 860px; margin: 0 auto; }
.back-link { display: inline-flex; align-items: center; gap: .4rem; color: var(--text-muted); font-size: .875rem; margin-bottom: 1.25rem; font-weight: 500; }
.back-link:hover { color: var(--brand); }
.poll-detail-title { font-size: 1.75rem; font-weight: 800; margin-bottom: .75rem; }
.poll-detail-desc { color: var(--text-muted); font-size: 1rem; margin-bottom: 1rem; line-height: 1.6; }
.poll-expires-badge { display: inline-block; background: #fef9c3; color: #854d0e; padding: .3rem .85rem; border-radius: 20px; font-size: .82rem; font-weight: 600; margin-bottom: 1.5rem; }

/* Vote section */
.vote-section { background: var(--card-bg); border-radius: var(--radius); border: 1.5px solid var(--border); padding: 1.75rem; margin-bottom: 2rem; }
.vote-section h2 { font-size: 1.1rem; font-weight: 700; margin-bottom: 1.25rem; }
.choices-list { display: flex; flex-direction: column; gap: .65rem; margin-bottom: 1.25rem; }
.choice-option {
    display: flex; align-items: center; gap: .85rem;
    padding: .85rem 1rem; border-radius: 9px; border: 1.5px solid var(--border);
    cursor: pointer; transition: border-color .15s, background .15s;
}
.choice-option:hover { border-color: var(--brand); background: var(--brand-light); }
.choice-option.selected { border-color: var(--brand); background: var(--brand-light); }
.choice-option input[type=radio] { accent-color: var(--brand); width: 18px; height: 18px; }
.choice-text { font-size: .95rem; font-weight: 500; }
.btn-vote { padding: .65rem 2rem; font-size: 1rem; }
.voted-badge { display: inline-flex; align-items: center; gap: .5rem; background: #f0fdf4; color: #166534; border: 1px solid #bbf7d0; padding: .6rem 1.1rem; border-radius: 8px; font-weight: 600; font-size: .9rem; margin-bottom: 2rem; }
.guest-email-section { margin: 1.25rem 0 1rem; padding: 1rem 1.25rem; background: var(--brand-light); border: 1px solid #c9d6ee; border-radius: 8px; }
.guest-integrity-msg { font-size: .875rem; color: #6b7280; margin: 0 0 .65rem; }
.field-error { font-size: .8rem; color: var(--danger, #dc2626); margin-top: .3rem; }

/* Results */
.results-section h2 { font-size: 1.2rem; font-weight: 700; margin-bottom: 1.25rem; }
.results-panels { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; }
@media (max-width: 700px) { .results-panels { grid-template-columns: 1fr; } }
.results-panel { background: var(--card-bg); border-radius: var(--radius); border: 1.5px solid var(--border); padding: 1.5rem; }
.results-panel-header { display: flex; align-items: center; gap: .5rem; font-weight: 700; font-size: .95rem; margin-bottom: 1.25rem; }
.registered-header { color: var(--brand); }
.public-header { color: var(--success); }
.panel-icon { font-size: 1.1rem; }
.vote-total { margin-left: auto; font-size: .8rem; font-weight: 500; color: var(--text-muted); }
.no-votes { color: var(--text-muted); font-size: .875rem; text-align: center; padding: 1.5rem 0; }

.result-row { margin-bottom: .85rem; }
.result-label { font-size: .875rem; font-weight: 600; display: block; margin-bottom: .3rem; }
.result-bar-wrap { background: var(--bg); border-radius: 20px; height: 10px; overflow: hidden; margin-bottom: .25rem; }
.result-bar { height: 100%; border-radius: 20px; transition: width .4s ease; }
.registered-bar { background: var(--brand); }
.public-bar { background: var(--success); }
.result-pct { font-size: .875rem; font-weight: 700; color: var(--text); }
.result-count { font-size: .8rem; color: var(--text-muted); margin-left: .35rem; }
.results-chart { margin-top: 1.25rem; }

/* ===== CREATE POLL ===== */
.settings-page { display: flex; justify-content: center; padding: 2rem 0; }
.settings-card { background: var(--card-bg); border-radius: var(--radius); border: 1.5px solid var(--border); box-shadow: var(--shadow); padding: 2.25rem; width: 100%; max-width: 520px; }
.settings-card h1 { font-size: 1.5rem; font-weight: 800; margin-bottom: 1.75rem; }
.settings-section h2 { font-size: 1.05rem; font-weight: 700; margin-bottom: .25rem; }
.settings-sub { font-size: .875rem; color: var(--text-muted); margin-bottom: 1rem; }
.settings-divider { border: none; border-top: 1.5px solid var(--border); margin: 2rem 0; }
.create-poll-page { display: flex; justify-content: center; padding: 1rem 0; }
.create-poll-card { background: var(--card-bg); border-radius: var(--radius); border: 1.5px solid var(--border); box-shadow: var(--shadow); padding: 2.25rem; width: 100%; max-width: 580px; }
.create-poll-card h1 { font-size: 1.5rem; font-weight: 800; margin-bottom: 1.5rem; }
.choice-input-row { display: flex; align-items: center; gap: .5rem; margin-bottom: .5rem; }
.choice-num { width: 24px; text-align: right; font-size: .8rem; color: var(--text-muted); font-weight: 600; flex-shrink: 0; }
.btn-remove-choice { background: none; border: none; color: var(--danger); cursor: pointer; font-size: 1rem; padding: .2rem .4rem; border-radius: 4px; }
.btn-remove-choice:hover { background: #fef2f2; }
.add-choice-btn { margin-top: .35rem; }

/* ===== BLAZOR ERROR UI ===== */
#blazor-error-ui {
    display: none; position: fixed; bottom: 0; left: 0; right: 0;
    background: #fef2f2; color: #991b1b; padding: .75rem 1.5rem;
    font-size: .875rem; z-index: 9999; text-align: center;
}
#blazor-error-ui .reload { color: var(--brand); font-weight: 600; margin-left: .5rem; }
#blazor-error-ui .dismiss { float: right; cursor: pointer; }

/* validation */
.valid.modified:not([type=checkbox]) { outline: 1px solid #26b050; }
.invalid { outline: 1px solid var(--danger); }
