/* Colors taken from the logo (static/housing_poll/logo.svg) */
:root {
    --brand-900: #0a4339;
    --brand: #0e5a4c;
    --brand-500: #1f9a72;
    --brand-100: #d5ede3;
    --brand-50: #eef7f3;
    --accent: #ffb23e;

    --page-bg: #f3f6f5;
    --surface: #ffffff;
    --border: #dbe3e0;
    --border-strong: #c7d2ce;
    --text: #1c2a26;
    --text-muted: #5d6d68;

    --info: #2f7fb0;
    --success: #1f9a72;
    --warning: #c98400;
    --danger: #b42318;

    --radius: .75rem;
    --radius-sm: .5rem;
    --shadow-sm: 0 1px 2px rgba(16, 40, 34, .05);
    --focus-ring: 0 0 0 .2rem rgba(31, 154, 114, .25);
}

body {
    background-color: var(--page-bg);
    color: var(--text);
    -webkit-font-smoothing: antialiased;
}

a {
    color: var(--brand);
}
a:hover {
    color: var(--brand-900);
}

.site-container {
    max-width: 760px;
}


/* ---------- Header ---------- */

.site-header {
    padding: 2rem 0 2.25rem;
    background: linear-gradient(135deg, var(--brand-900) 0%, var(--brand) 45%, var(--brand-500) 100%);
    color: #fff;
}

.site-brand {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.site-logo {
    flex-shrink: 0;
    width: 56px;
    height: 56px;
    border-radius: 19%;    /* matches the rounded corners inside the SVG */
    box-shadow: 0 0 0 2px rgba(255, 255, 255, .25), 0 6px 16px rgba(0, 0, 0, .18);
}

.site-kicker {
    margin: 0 0 .125rem;
    font-size: .8125rem;
    font-weight: 600;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: var(--accent);
}

.site-title {
    margin: 0;
    font-size: 1.5rem;
    font-weight: 600;
    line-height: 1.25;
}

.site-intro {
    margin: 1.25rem 0 0;
    max-width: 60ch;
    color: rgba(255, 255, 255, .88);
}

@media (min-width: 768px) {
    .site-header {
        padding: 2.5rem 0 2.75rem;
    }
    .site-title {
        font-size: 1.75rem;
    }
}


/* ---------- Page content ---------- */

.content {
    padding-top: 1.5rem;
    padding-bottom: 7rem;    /* room for the fixed action bar */
}


/* ---------- Notices ---------- */

.notice {
    --notice-color: var(--text-muted);
    display: flex;
    gap: .875rem;
    margin-bottom: 1rem;
    padding: 1rem 1.25rem;
    background-color: var(--surface);
    border: 1px solid var(--border);
    border-left: 4px solid var(--notice-color);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
}
.notice-icon {
    flex-shrink: 0;
    margin-top: .2rem;
    font-size: 1.25rem;
    color: var(--notice-color);
}
.notice-body {
    min-width: 0;
}
.notice-body p {
    margin-bottom: .5rem;
}
.notice-body > :last-child {
    margin-bottom: 0;
}
.notice-title {
    font-weight: 600;
    margin-bottom: .25rem !important;
}
.notice-info    { --notice-color: var(--info); }
.notice-success { --notice-color: var(--success); }
.notice-brand   { --notice-color: var(--brand); }
.notice-warning { --notice-color: var(--warning); }
.notice-danger  { --notice-color: var(--danger); }

.notice-link {
    display: inline-block;
    max-width: 100%;
    margin-bottom: .5rem;
    padding: .375rem .75rem;
    background-color: var(--brand-50);
    border: 1px solid var(--brand-100);
    border-radius: var(--radius-sm);
    font-family: var(--bs-font-monospace, monospace);
    font-size: .875rem;
    color: var(--brand);
    text-decoration: none;
    overflow-wrap: anywhere;    /* long URLs wrap on narrow screens instead of overflowing */
}
.notice-link:hover {
    color: var(--brand-900);
    text-decoration: underline;
}


/* ---------- Form sections (crispy Fieldsets) ---------- */

.poll-form {
    counter-reset: section;
    margin-top: 1.5rem;
}

/* Only the top-level layout fieldsets; widgets render their own nested fieldsets */
.poll-form > fieldset {
    counter-increment: section;
    margin-bottom: 1.25rem;
    padding: 1.25rem 1.25rem .5rem;
    background-color: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
}

.poll-form > fieldset > legend {
    display: flex;
    align-items: center;
    gap: .625rem;
    margin-bottom: 1.25rem;
    padding-bottom: .875rem;
    border-bottom: 1px solid var(--border);
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--brand);
}
.poll-form > fieldset > legend::before {
    content: counter(section);
    display: inline-flex;
    flex-shrink: 0;
    align-items: center;
    justify-content: center;
    width: 1.75rem;
    height: 1.75rem;
    border-radius: 50%;
    background-color: var(--brand-50);
    font-size: .875rem;
    font-weight: 700;
}

@media (min-width: 768px) {
    .poll-form > fieldset {
        padding: 1.5rem 1.75rem .75rem;
    }
}


/* ---------- Form controls ---------- */

.form-label {
    margin-bottom: .375rem;
    font-weight: 500;
}

.asteriskField {
    margin-left: .125rem;
    font-weight: 600;
    color: var(--danger);
}

.form-text {
    color: var(--text-muted);
}

/* Introduction below a section legend that applies to several fields */
.section-help {
    margin: -.25rem 0 1.25rem;
}

.form-control,
.form-select,
.input-group-text {
    border-color: var(--border-strong);
    border-radius: var(--radius-sm);
}

.form-control:focus,
.form-select:focus {
    border-color: var(--brand-500);
    box-shadow: var(--focus-ring);
}

.input-group-text {
    min-width: 2.75rem;
    justify-content: center;
    background-color: var(--brand-50);
    color: var(--text-muted);
}

.form-check-input:checked {
    background-color: var(--brand);
    border-color: var(--brand);
}
.form-check-input:focus {
    border-color: var(--brand-500);
    box-shadow: var(--focus-ring);
}

.invalid-feedback p {
    margin-bottom: 0;
}
.invalid-feedback strong {
    font-weight: 500;
}


/* ---------- Buttons ---------- */

.btn {
    border-radius: var(--radius-sm);
    font-weight: 500;
}

.btn-brand {
    color: #fff;
    background-color: var(--brand);
    border-color: var(--brand);
}
.btn-brand:hover,
.btn-brand:active {
    color: #fff;
    background-color: var(--brand-900);
    border-color: var(--brand-900);
}
.btn-brand:focus,
.btn-outline-brand:focus {
    box-shadow: var(--focus-ring);
}

.btn-outline-brand {
    color: var(--brand);
    background-color: var(--surface);
    border-color: var(--brand);
}
.btn-outline-brand:hover,
.btn-outline-brand:active {
    color: var(--brand-900);
    background-color: var(--brand-50);
    border-color: var(--brand-900);
}


/* ---------- Utility bills ---------- */

.bill-list .list-group-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .75rem;
    border-color: var(--border);
}
.bill-list .list-group-item:first-child {
    border-top-left-radius: var(--radius-sm);
    border-top-right-radius: var(--radius-sm);
}
.bill-list .list-group-item:last-child {
    border-bottom-left-radius: var(--radius-sm);
    border-bottom-right-radius: var(--radius-sm);
}

.bill-link {
    display: inline-flex;
    align-items: center;
    gap: .5rem;
    min-width: 0;
    text-decoration: none;
    overflow-wrap: anywhere;
}
.bill-link:hover span {
    text-decoration: underline;
}

.bill-empty {
    color: var(--text-muted);
    font-style: italic;
}

@media (max-width: 575.98px) {
    .visually-hidden-sm {
        display: none;
    }
}


/* ---------- Action bar (fixed at the bottom, part of the swapped form) ---------- */

.action-bar {
    position: fixed;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 1030;
    background-color: rgba(255, 255, 255, .94);
    border-top: 1px solid var(--border);
    box-shadow: 0 -4px 16px rgba(16, 40, 34, .06);
    -webkit-backdrop-filter: blur(8px);
            backdrop-filter: blur(8px);
}

.action-bar-inner {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .5rem 1rem;
    padding-top: .75rem;
    padding-bottom: .75rem;
}

.action-bar-status {
    flex: 1 1 100%;
    min-width: 0;
    font-size: .875rem;
    color: var(--text-muted);
}
.action-bar-status .is-success { color: var(--success); font-weight: 500; }
.action-bar-status .is-error   { color: var(--danger);  font-weight: 500; }

.action-bar-buttons {
    display: flex;
    flex: 1 1 100%;
    gap: .5rem;
}
.action-bar-buttons .btn {
    flex: 1 1 0;
    padding-right: .5rem;
    padding-left: .5rem;
    white-space: nowrap;
}

/* Both labels must fit side by side on small phones */
@media (max-width: 575.98px) {
    .action-bar-buttons .btn-icon {
        display: none;
    }
}

@media (min-width: 576px) {
    .action-bar-status {
        flex-basis: 0;
    }
    .action-bar-buttons {
        flex: 0 0 auto;
    }
    .action-bar-buttons .btn {
        flex: 0 0 auto;
        padding-right: 1rem;
        padding-left: 1rem;
    }
}


/* ---------- Status card (e.g. unknown token) ---------- */

.status-card {
    padding: 2.5rem 1.5rem;
    background-color: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    text-align: center;
}
.status-card-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 4rem;
    height: 4rem;
    margin-bottom: 1rem;
    border-radius: 50%;
    background-color: #fdecea;
    font-size: 1.75rem;
    color: var(--danger);
}
.status-card-icon.is-success {
    background-color: var(--brand-50);
    color: var(--success);
}
.status-card-title {
    margin-bottom: .75rem;
    font-size: 1.375rem;
    font-weight: 600;
}
.status-card-hint {
    margin: 1.5rem auto 0;
    padding-top: 1.25rem;
    max-width: 40ch;
    border-top: 1px solid var(--border);
    font-size: .875rem;
    color: var(--text-muted);
}


/* ---------- Submission confirmation modal (see poll.html) ---------- */

#submitted-modal .modal-content {
    border: 0;
    border-radius: var(--radius);
    box-shadow: 0 16px 48px rgba(16, 40, 34, .2);
}
#submitted-modal .modal-body {
    padding: 2rem 1.75rem 1rem;
    text-align: center;
}
#submitted-modal .modal-footer {
    justify-content: center;
    padding: 0 1.75rem 1.75rem;
    border-top: 0;
}
#submitted-modal .modal-footer .btn {
    min-width: 10rem;
}


/* ---------- Loading overlay (see _base.html) ---------- */

/* Full-page overlay blocking the mouse while htmx requests run */
#loading-overlay {
    position: fixed;
    inset: 0;
    z-index: 2000;    /* above the fixed action bar */
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: rgba(243, 246, 245, .65);
    cursor: wait;
    visibility: hidden;
    opacity: 0;
}

#loading-overlay .spinner-border {
    width: 3rem;
    height: 3rem;
    color: var(--brand-500);
}

/* Appear with a short delay, so quick validations don't flicker and a click that
   triggered a focusout validation (e.g. on the save button) still reaches its target */
#loading-overlay.htmx-request {
    visibility: visible;
    opacity: 1;
    transition: visibility 0s .2s, opacity .15s .2s;
}
