/* ════════════════════════════════════════════════════════════════════════
   Anket (2026-10-22) — çat balonu + müzakirə kartı + pəncərələr (assets/js/poll.js).
   Tətbiqdə eynidir: lib/widgets/poll_card.dart (vurğu rəngi #22A55B hər ikisində).
   ════════════════════════════════════════════════════════════════════════ */
:root {
    --poll-accent: #22A55B;
    --poll-track: rgba(0, 0, 0, .12);
    --poll-sheet-bg: #f2f2f7;
    --poll-box-bg: #ffffff;
    --poll-line: rgba(0, 0, 0, .08);
}

html[data-theme="dark"] {
    --poll-track: rgba(255, 255, 255, .16);
    --poll-sheet-bg: #111111;
    --poll-box-bg: #1c1c1e;
    --poll-line: rgba(255, 255, 255, .08);
}

/* ── Kart ─────────────────────────────────────────────────────────────── */
.fz-poll {
    width: 300px;
    max-width: 100%;
    color: inherit;
}

.post-body .fz-poll {
    width: 100%;
    max-width: 520px;
}

.fz-poll-q {
    font-size: 16px;
    font-weight: 700;
    line-height: 1.3;
    word-break: break-word;
}

.fz-poll-hint {
    display: flex;
    align-items: center;
    gap: 6px;
    margin: 4px 0 6px;
    font-size: 12.5px;
    opacity: .7;
}

.fz-poll-hint .fe {
    font-size: 14px;
}

.fz-poll-opts {
    display: flex;
    flex-direction: column;
}

.fz-poll-opt {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    width: 100%;
    margin: 0;
    padding: 9px 0 7px;
    border: 0;
    background: none;
    color: inherit;
    font: inherit;
    text-align: left;
    cursor: pointer;
}

.fz-poll.is-busy .fz-poll-opt {
    cursor: progress;
}

.fz-poll-check {
    flex: 0 0 22px;
    width: 22px;
    height: 22px;
    margin-top: 1px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid currentColor;
    border-radius: 50%;
    opacity: .55;
    transition: background .15s, border-color .15s, opacity .15s;
}

.fz-poll-check .fe {
    font-size: 13px;
    color: #fff;
    opacity: 0;
}

.fz-poll-opt.is-me .fz-poll-check {
    background: var(--poll-accent);
    border-color: var(--poll-accent);
    opacity: 1;
}

.fz-poll-opt.is-me .fz-poll-check .fe {
    opacity: 1;
}

.fz-poll-body {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 7px;
}

.fz-poll-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.fz-poll-text {
    flex: 1;
    min-width: 0;
    font-size: 15px;
    line-height: 1.3;
    word-break: break-word;
}

.fz-poll-count {
    flex: 0 0 auto;
    font-size: 14px;
    font-variant-numeric: tabular-nums;
}

.fz-poll-faces {
    display: flex;
    flex: 0 0 auto;
}

.fz-poll-face {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    object-fit: cover;
    border: 1.5px solid var(--poll-box-bg);
}

.fz-poll-face + .fz-poll-face {
    margin-left: -7px;
}

.fz-poll-face.is-initials,
.fz-poll-voter-av.is-initials {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #8e8e93;
    color: #fff;
    font-size: 8px;
    font-weight: 700;
}

.fz-poll-bar {
    display: block;
    height: 6px;
    border-radius: 3px;
    background: var(--poll-track);
    overflow: hidden;
}

.fz-poll-bar span {
    display: block;
    height: 100%;
    border-radius: 3px;
    background: var(--poll-accent);
    transition: width .3s ease;
}

.fz-poll-show {
    display: block;
    width: 100%;
    margin: 8px 0 0;
    padding: 11px 0 3px;
    border: 0;
    border-top: 1px solid var(--poll-line);
    background: none;
    color: var(--poll-accent);
    font: inherit;
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
}

.fz-poll-show:disabled {
    color: inherit;
    opacity: .45;
    cursor: default;
}

/* Çat balonunda: saat «Səsləri göstər» xəttinin ÜSTÜNDƏ (WhatsApp kimi). `.fz-poll`
   display:contents olur ki, onun uşaqları və saat eyni flex sütununda sıralansın. */
.chat-bubble-poll {
    display: flex;
    flex-direction: column;
    width: 300px;
    max-width: 100%;
}

.chat-bubble-poll .fz-poll {
    display: contents;
}

.chat-bubble-poll .chat-msg-time {
    order: 1;
    align-self: flex-end;
}

.chat-bubble-poll .fz-poll-show {
    order: 2;
    width: calc(100% + 20px);
    margin: 6px -10px -4px;
}

/* ── Pəncərə ──────────────────────────────────────────────────────────── */
body.fz-poll-open {
    overflow: hidden;
}

.fz-poll-overlay {
    position: fixed;
    inset: 0;
    z-index: 100000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    background: rgba(0, 0, 0, .45);
    opacity: 0;
    transition: opacity .2s;
}

.fz-poll-overlay.is-in {
    opacity: 1;
}

.fz-poll-sheet {
    display: flex;
    flex-direction: column;
    width: 440px;
    max-width: 100%;
    max-height: min(680px, calc(100vh - 32px));
    border-radius: 16px;
    background: var(--poll-sheet-bg);
    color: var(--color-text-primary);
    overflow: hidden;
    transform: translateY(12px);
    transition: transform .2s;
}

.fz-poll-overlay.is-in .fz-poll-sheet {
    transform: none;
}

.fz-poll-sheet-head {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    padding: 14px 16px;
}

.fz-poll-sheet-head > :last-child {
    justify-self: end;
}

.fz-poll-sheet-title {
    font-size: 16px;
    font-weight: 700;
}

.fz-poll-link {
    justify-self: start;
    padding: 0;
    border: 0;
    background: none;
    color: var(--color-text-primary);
    font: inherit;
    font-size: 15px;
    cursor: pointer;
}

.fz-poll-send {
    color: var(--poll-accent);
    font-weight: 600;
}

.fz-poll-send:disabled {
    color: var(--color-text-secondary);
    opacity: .6;
    cursor: default;
}

.fz-poll-sheet-body {
    flex: 1;
    overflow-y: auto;
    padding: 4px 16px 20px;
}

.fz-poll-label {
    margin: 14px 4px 6px;
    font-size: 12.5px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: .02em;
    color: var(--color-text-secondary);
}

.fz-poll-group {
    margin-bottom: 18px;
    border-radius: 12px;
    background: var(--poll-box-bg);
    overflow: hidden;
}

.fz-poll-field-row + .fz-poll-field-row,
.fz-poll-switch + .fz-poll-switch {
    border-top: 1px solid var(--poll-line);
}

input.fz-poll-input {
    display: block;
    width: 100%;
    height: 48px;
    line-height: normal;
    margin: 0;
    padding: 0 14px;
    border: 0;
    border-radius: 0;
    background: transparent;
    color: var(--color-text-primary);
    font-size: 15px;
}

input.fz-poll-input:focus {
    outline: none;
}

.fz-poll-switch {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin: 0;
    padding: 12px 14px;
    font-size: 15px;
    cursor: pointer;
}

.fz-poll-switch input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.fz-poll-switch i {
    position: relative;
    flex: 0 0 46px;
    height: 28px;
    border-radius: 14px;
    background: var(--poll-track);
    transition: background .2s;
}

.fz-poll-switch i::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 1px 3px rgba(0, 0, 0, .25);
    transition: transform .2s;
}

.fz-poll-switch input:checked + i {
    background: var(--poll-accent);
}

.fz-poll-switch input:checked + i::after {
    transform: translateX(18px);
}

.fz-poll-switch input:focus-visible + i {
    outline: 2px solid var(--poll-accent);
    outline-offset: 2px;
}

.fz-poll-error {
    display: none;
    margin: 8px 0 0;
    padding: 10px 12px;
    border-radius: 10px;
    background: rgba(229, 37, 42, .12);
    color: #e5252a;
    font-size: 13.5px;
}

/* Səslər siyahısı */
.fz-poll-box {
    margin-top: 14px;
    border-radius: 12px;
    background: var(--poll-box-bg);
    overflow: hidden;
}

.fz-poll-box-q {
    padding: 14px;
    font-size: 17px;
    font-weight: 700;
    word-break: break-word;
}

.fz-poll-box-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 13px 14px;
    font-size: 16px;
    font-weight: 700;
}

.fz-poll-box-head span:first-child {
    word-break: break-word;
}

.fz-poll-box-count {
    flex: 0 0 auto;
    font-size: 14px;
    font-weight: 500;
    color: var(--color-text-secondary);
}

.fz-poll-voter {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 14px;
    border-top: 1px solid var(--poll-line);
}

.fz-poll-voter-av {
    flex: 0 0 34px;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    object-fit: cover;
}

.fz-poll-voter-av.is-initials {
    font-size: 12px;
}

.fz-poll-voter-name {
    flex: 1;
    min-width: 0;
    font-size: 15px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.fz-poll-voter-date {
    flex: 0 0 auto;
    font-size: 12.5px;
    color: var(--color-text-secondary);
}

.fz-poll-note {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 12px;
    font-size: 13px;
    color: var(--color-text-secondary);
}

.fz-poll-loading,
.fz-poll-empty {
    padding: 40px 0;
    text-align: center;
    color: var(--color-text-secondary);
}

.fz-poll-loading .fe {
    font-size: 22px;
    animation: fz-poll-spin 1s linear infinite;
    display: inline-block;
}

@keyframes fz-poll-spin {
    to { transform: rotate(360deg); }
}

.fz-poll-toast {
    position: fixed;
    left: 50%;
    bottom: 24px;
    z-index: 100001;
    transform: translateX(-50%);
    padding: 10px 16px;
    border-radius: 10px;
    background: rgba(0, 0, 0, .85);
    color: #fff;
    font-size: 14px;
    transition: opacity .3s;
}

.fz-poll-toast.is-out {
    opacity: 0;
}

/* Mobil: pəncərə aşağıdan açılır */
@media (max-width: 600px) {
    .fz-poll-overlay {
        align-items: flex-end;
        padding: 0;
    }

    .fz-poll-sheet {
        width: 100%;
        max-height: 92vh;
        border-radius: 16px 16px 0 0;
    }

    .fz-poll {
        width: 100%;
        min-width: 220px;
    }
}
