/* ============================================
   TOWN HALL VOTING PORTAL — CSS
   ============================================ */

:root {
    --th-brand: #c9a227;
    --th-brand-dark: #b8942a;
    --th-brand-glow: rgba(201, 162, 39, 0.15);
    --th-bg: #0d0d1a;
    --th-surface: #1a1a2e;
    --th-surface-light: #222240;
    --th-border: rgba(255, 255, 255, 0.08);
    --th-text: #e0e0e0;
    --th-text-muted: #888;
    --th-success: #28a745;
    --th-danger: #dc3545;
    --th-radius: 12px;
}

/* ============================================
   Single Poll Page
   ============================================ */

.townhall-single-page {
    max-width: 700px;
    margin: 0 auto;
    padding: 30px 20px 60px;
}

.townhall-back-bar {
    margin-bottom: 20px;
}

.back-link {
    color: var(--th-text-muted);
    text-decoration: none;
    font-size: 0.9rem;
    transition: color 0.2s;
}

.back-link:hover {
    color: var(--th-brand);
}

.townhall-page-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: var(--th-brand-glow);
    color: var(--th-brand);
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 0.82rem;
    font-weight: 600;
    letter-spacing: 0.03em;
    margin-bottom: 20px;
}

/* ============================================
   Poll Widget (Core voting UI)
   ============================================ */

.townhall-poll-widget {
    background: var(--th-surface);
    border: 1px solid var(--th-border);
    border-radius: var(--th-radius);
    overflow: hidden;
    position: relative;
}

.townhall-poll-widget::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, transparent, var(--th-brand), transparent);
}

.townhall-poll-widget.ended {
    opacity: 0.9;
}

/* — Poll Header — */
.poll-widget-header {
    padding: 28px 28px 0;
}

.poll-status-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.poll-status-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.poll-status-badge.active {
    background: rgba(40, 167, 69, 0.15);
    color: var(--th-success);
}

.poll-status-badge.ended {
    background: rgba(220, 53, 69, 0.15);
    color: var(--th-danger);
}

.poll-status-badge.scheduled {
    background: rgba(240, 173, 78, 0.15);
    color: #f0ad4e;
}

/* Pulse dot */
.pulse-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--th-success);
    display: inline-block;
    animation: pulse-live 1.5s ease-in-out infinite;
}

@keyframes pulse-live {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.5; transform: scale(0.7); }
}

.poll-deadline {
    font-size: 0.8rem;
    color: var(--th-text-muted);
}

.poll-widget-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: #fff;
    margin: 0 0 10px;
    line-height: 1.3;
    letter-spacing: -0.01em;
}

.poll-widget-description {
    color: var(--th-text-muted);
    font-size: 0.92rem;
    line-height: 1.6;
    margin: 0 0 16px;
}

.poll-widget-stats {
    display: flex;
    align-items: center;
    gap: 16px;
    font-size: 0.85rem;
    color: var(--th-text-muted);
    padding-bottom: 20px;
    border-bottom: 1px solid var(--th-border);
}

.poll-widget-stats strong {
    color: var(--th-brand);
}

.poll-user-voted {
    color: var(--th-success);
    font-weight: 600;
}

/* — Options List — */
.poll-vote-form {
    padding: 24px 28px 28px;
}

.poll-options-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 20px;
}

.poll-option {
    display: block;
    position: relative;
    background: var(--th-surface-light);
    border: 2px solid var(--th-border);
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.25s ease;
    overflow: hidden;
}

.poll-option:hover {
    border-color: rgba(201, 162, 39, 0.3);
    background: rgba(201, 162, 39, 0.05);
}

.poll-option.selected {
    border-color: var(--th-brand);
    background: rgba(201, 162, 39, 0.08);
}

.poll-option input[type="radio"],
.poll-option input[type="checkbox"] {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.option-content {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 16px 18px;
    position: relative;
    z-index: 1;
}

/* Custom radio/checkbox */
.option-input {
    flex-shrink: 0;
}

.custom-radio,
.custom-checkbox {
    display: block;
    width: 22px;
    height: 22px;
    border: 2px solid var(--th-border);
    transition: all 0.2s;
}

.custom-radio {
    border-radius: 50%;
}

.custom-checkbox {
    border-radius: 5px;
}

.poll-option.selected .custom-radio,
.poll-option.selected .custom-checkbox {
    border-color: var(--th-brand);
    background: var(--th-brand);
}

.poll-option.selected .custom-radio::after {
    content: '';
    display: block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--th-bg);
    margin: 5px auto;
}

.poll-option.selected .custom-checkbox::after {
    content: '✓';
    display: block;
    color: var(--th-bg);
    font-size: 14px;
    font-weight: 700;
    text-align: center;
    line-height: 18px;
}

/* Option text */
.option-text {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.option-label {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--th-text);
}

.option-desc {
    font-size: 0.8rem;
    color: var(--th-text-muted);
}

/* Result display */
.option-result {
    display: none;
    flex-direction: column;
    align-items: flex-end;
    flex-shrink: 0;
    min-width: 60px;
}

.option-result.visible {
    display: flex;
}

.result-pct {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--th-brand);
}

.result-count {
    font-size: 0.72rem;
    color: var(--th-text-muted);
}

/* Result bar */
.option-bar {
    display: none;
    height: 4px;
    background: rgba(255, 255, 255, 0.04);
    position: relative;
    margin-top: -2px;
}

.option-bar.visible {
    display: block;
}

.option-bar-fill {
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: var(--pct);
    background: linear-gradient(90deg, var(--th-brand), var(--th-brand-dark));
    border-radius: 0 4px 4px 0;
    transition: width 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

.poll-option.selected .option-bar-fill {
    background: linear-gradient(90deg, var(--th-brand), #e6c248);
}

/* — Vote Button — */
.poll-vote-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 14px 24px;
    background: linear-gradient(135deg, var(--th-brand), var(--th-brand-dark));
    color: var(--th-bg);
    border: none;
    border-radius: 10px;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s;
    letter-spacing: 0.02em;
}

.poll-vote-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(201, 162, 39, 0.3);
}

.poll-vote-btn:active {
    transform: translateY(0);
}

.poll-vote-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.poll-vote-btn.loading {
    pointer-events: none;
    opacity: 0.7;
}

.poll-login-btn {
    display: block;
    text-align: center;
    padding: 14px 24px;
    background: var(--th-surface-light);
    border: 1px solid var(--th-border);
    border-radius: 10px;
    color: var(--th-brand);
    text-decoration: none;
    font-weight: 600;
    transition: all 0.2s;
}

.poll-login-btn:hover {
    border-color: var(--th-brand);
    background: rgba(201, 162, 39, 0.08);
    color: var(--th-brand);
}

.poll-ended-msg,
.poll-voted-msg {
    text-align: center;
    padding: 14px;
    border-radius: 10px;
    font-size: 0.9rem;
    font-weight: 500;
}

.poll-ended-msg {
    background: rgba(220, 53, 69, 0.08);
    color: var(--th-text-muted);
    border: 1px solid rgba(220, 53, 69, 0.15);
}

.poll-voted-msg {
    background: rgba(40, 167, 69, 0.08);
    color: var(--th-success);
    border: 1px solid rgba(40, 167, 69, 0.15);
}

/* — Share Bar — */
.poll-share-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 28px;
    border-top: 1px solid var(--th-border);
    background: rgba(0, 0, 0, 0.15);
}

.share-label {
    font-size: 0.82rem;
    color: var(--th-text-muted);
}

.poll-share-bar .share-buttons {
    display: flex;
    gap: 8px;
}

.poll-share-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 8px;
    border: 1px solid var(--th-border);
    background: var(--th-surface-light);
    color: var(--th-text-muted);
    cursor: pointer;
    transition: all 0.2s;
}

.poll-share-btn:hover {
    border-color: var(--th-brand);
    color: var(--th-brand);
    background: rgba(201, 162, 39, 0.08);
}

/* ============================================
   Poll Info Section (single page)
   ============================================ */

.townhall-poll-info {
    margin-top: 24px;
    background: var(--th-surface);
    border: 1px solid var(--th-border);
    border-radius: var(--th-radius);
    padding: 24px 28px;
}

.info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 20px;
}

.info-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.info-label {
    font-size: 0.75rem;
    color: var(--th-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.info-value {
    font-size: 0.95rem;
    color: var(--th-text);
    font-weight: 500;
}

/* ============================================
   Other Polls Section
   ============================================ */

.townhall-other-polls {
    margin-top: 40px;
    padding-top: 30px;
    border-top: 1px solid var(--th-border);
}

.other-polls-title {
    font-size: 1.1rem;
    color: var(--th-brand);
    font-weight: 700;
    margin: 0 0 20px;
}

.other-polls-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 16px;
}

.other-poll-card {
    background: var(--th-surface);
    border: 1px solid var(--th-border);
    border-radius: 10px;
    padding: 18px;
    text-decoration: none;
    transition: all 0.25s;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.other-poll-card:hover {
    border-color: rgba(201, 162, 39, 0.2);
    transform: translateY(-3px);
}

.other-poll-status {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--th-text-muted);
}

.status-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    display: inline-block;
}

.status-dot.active {
    background: var(--th-success);
}

.status-dot.ended {
    background: var(--th-danger);
}

.status-dot.scheduled {
    background: #f0ad4e;
}

.voted-badge {
    font-size: 0.7rem;
    background: rgba(40, 167, 69, 0.15);
    color: var(--th-success);
    padding: 1px 6px;
    border-radius: 8px;
    margin-left: auto;
}

.other-poll-card h4 {
    font-size: 0.95rem;
    color: #fff;
    margin: 0;
    line-height: 1.3;
}

.other-poll-card p {
    font-size: 0.82rem;
    color: var(--th-text-muted);
    margin: 0;
    line-height: 1.5;
}

.other-poll-voters {
    font-size: 0.78rem;
    color: var(--th-text-muted);
    margin-top: auto;
}

/* ============================================
   Polls List / Archive
   ============================================ */

.townhall-archive-page {
    max-width: 1000px;
    margin: 0 auto;
    padding: 30px 20px 60px;
}

.townhall-polls-list {
    max-width: 1000px;
    margin: 0 auto;
}

.townhall-list-header {
    text-align: center;
    padding: 40px 20px;
    background: linear-gradient(135deg, var(--th-surface) 0%, rgba(201, 162, 39, 0.05) 100%);
    border-radius: var(--th-radius);
    border: 1px solid var(--th-border);
    margin-bottom: 30px;
    position: relative;
    overflow: hidden;
}

.townhall-list-header::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, transparent, var(--th-brand), transparent);
}

.townhall-list-title {
    font-size: 1.8rem;
    font-weight: 700;
    color: #fff;
    margin: 0 0 8px;
    letter-spacing: -0.01em;
}

.townhall-list-subtitle {
    color: var(--th-text-muted);
    font-size: 1rem;
    margin: 0;
}

.townhall-polls-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
}

.townhall-poll-card {
    background: var(--th-surface);
    border: 1px solid var(--th-border);
    border-radius: var(--th-radius);
    padding: 24px;
    text-decoration: none;
    transition: all 0.3s;
    display: flex;
    flex-direction: column;
    gap: 10px;
    position: relative;
    overflow: hidden;
}

.townhall-poll-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
}

.townhall-poll-card.active::before {
    background: var(--th-success);
}

.townhall-poll-card.ended::before {
    background: var(--th-danger);
}

.townhall-poll-card.scheduled::before {
    background: #f0ad4e;
}

.townhall-poll-card:hover {
    border-color: rgba(201, 162, 39, 0.2);
    transform: translateY(-4px);
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.3);
}

.poll-card-status {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.78rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--th-text-muted);
}

.poll-card-status .voted-badge {
    margin-left: auto;
}

.poll-card-title {
    font-size: 1.15rem;
    font-weight: 700;
    color: #fff;
    margin: 0;
    line-height: 1.3;
}

.poll-card-desc {
    font-size: 0.88rem;
    color: var(--th-text-muted);
    margin: 0;
    line-height: 1.5;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.poll-card-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: auto;
    padding-top: 12px;
    border-top: 1px solid var(--th-border);
    font-size: 0.8rem;
    color: var(--th-text-muted);
}

.poll-card-deadline {
    color: #f0ad4e;
}

/* ============================================
   Empty State
   ============================================ */

.townhall-empty {
    text-align: center;
    padding: 60px 20px;
    background: var(--th-surface);
    border: 1px dashed var(--th-border);
    border-radius: var(--th-radius);
}

.townhall-empty p {
    color: var(--th-text-muted);
    font-size: 1rem;
}

/* ============================================
   Toast Notification
   ============================================ */

.townhall-toast {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: var(--th-surface);
    border: 1px solid var(--th-border);
    border-radius: 10px;
    padding: 14px 24px;
    color: var(--th-text);
    font-size: 0.9rem;
    font-weight: 500;
    z-index: 10000;
    opacity: 0;
    transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.4);
    max-width: 400px;
    text-align: center;
}

.townhall-toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.townhall-toast.success {
    border-color: rgba(40, 167, 69, 0.3);
}

.townhall-toast.error {
    border-color: rgba(220, 53, 69, 0.3);
}

/* ============================================
   Vote Success Animation
   ============================================ */

@keyframes vote-check {
    0% { transform: scale(0) rotate(-45deg); opacity: 0; }
    50% { transform: scale(1.2) rotate(0deg); opacity: 1; }
    100% { transform: scale(1) rotate(0deg); opacity: 1; }
}

.poll-vote-btn.success {
    background: var(--th-success);
    pointer-events: none;
}

.poll-vote-btn.success svg {
    animation: vote-check 0.5s ease forwards;
}

/* ============================================
   Responsive
   ============================================ */

@media (max-width: 768px) {
    .townhall-single-page {
        padding: 20px 16px 40px;
    }
    
    .poll-widget-header {
        padding: 22px 20px 0;
    }
    
    .poll-vote-form {
        padding: 20px;
    }
    
    .poll-share-bar {
        padding: 14px 20px;
        flex-direction: column;
        gap: 10px;
    }
    
    .poll-widget-title {
        font-size: 1.3rem;
    }
    
    .option-content {
        padding: 14px;
        gap: 10px;
    }
    
    .townhall-poll-info {
        padding: 20px;
    }
    
    .info-grid {
        grid-template-columns: 1fr 1fr;
        gap: 16px;
    }
    
    .other-polls-grid {
        grid-template-columns: 1fr;
    }
    
    .townhall-polls-grid {
        grid-template-columns: 1fr;
    }
    
    .townhall-list-header {
        padding: 30px 16px;
    }
    
    .townhall-list-title {
        font-size: 1.4rem;
    }
}

@media (max-width: 480px) {
    .poll-status-bar {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }
    
    .poll-widget-title {
        font-size: 1.15rem;
    }
    
    .option-content {
        padding: 12px;
    }
    
    .option-label {
        font-size: 0.88rem;
    }
    
    .result-pct {
        font-size: 0.95rem;
    }
    
    .poll-widget-stats {
        flex-direction: column;
        align-items: flex-start;
        gap: 6px;
    }
}
