/**
 * RAXE Ensemble Voting Visualization Styles
 * Cyberpunk aesthetic with animated voting display
 */

/* ===== Voting Visualization Container ===== */
.voting-viz {
    background: var(--bg-secondary);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-xl);
    margin-top: var(--spacing-xl);
    overflow: hidden;
    display: none; /* Hidden until results are shown */
}

.voting-viz.active {
    display: block;
    animation: fadeSlideIn 0.4s ease-out;
}

@keyframes fadeSlideIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ===== Voting Header ===== */
.voting-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--spacing-lg);
    border-bottom: 1px solid var(--border-primary);
    background: rgba(0, 0, 0, 0.2);
}

.voting-title {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 700;
    color: var(--text-primary);
    font-size: 1rem;
}

.voting-title svg {
    color: var(--accent-primary);
}

.voting-badge {
    background: rgba(139, 92, 246, 0.1);
    border: 1px solid rgba(139, 92, 246, 0.3);
    color: #a78bfa;
    padding: 4px 10px;
    border-radius: 100px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* ===== Comparison Banner ===== */
.voting-comparison-banner {
    padding: var(--spacing-md) var(--spacing-lg);
    border-bottom: 1px solid var(--border-primary);
    animation: fadeSlideIn 0.3s ease-out;
}

.voting-comparison-banner.disagree {
    background: linear-gradient(135deg, rgba(245, 158, 11, 0.1), rgba(239, 68, 68, 0.05));
    border-left: 3px solid #f59e0b;
}

.voting-comparison-banner.agree {
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.1), rgba(16, 185, 129, 0.05));
    border-left: 3px solid #10b981;
}

.comparison-content {
    display: flex;
    align-items: flex-start;
    gap: 12px;
}

.comparison-icon {
    flex-shrink: 0;
    margin-top: 2px;
}

.voting-comparison-banner.disagree .comparison-icon {
    color: #f59e0b;
}

.voting-comparison-banner.agree .comparison-icon {
    color: #10b981;
}

.comparison-text {
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 0.8125rem;
    line-height: 1.5;
}

.comparison-text strong {
    color: var(--text-primary);
    font-size: 0.875rem;
}

.comparison-text span {
    color: var(--text-secondary);
}

.comparison-text code {
    background: var(--bg-tertiary);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.75rem;
    color: var(--accent-primary);
}

.decision-tag {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.decision-tag.threat {
    background: rgba(239, 68, 68, 0.2);
    color: #f87171;
}

.decision-tag.safe {
    background: rgba(16, 185, 129, 0.2);
    color: #34d399;
}

.decision-tag.review {
    background: rgba(245, 158, 11, 0.2);
    color: #fbbf24;
}

.comparison-note {
    margin-top: var(--spacing-sm);
    padding-left: 32px;
    font-size: 0.75rem;
    color: var(--text-muted);
    font-style: italic;
}

/* ===== Preset Selector ===== */
.preset-selector {
    padding: var(--spacing-md) var(--spacing-lg);
    border-bottom: 1px solid var(--border-primary);
    background: rgba(0, 0, 0, 0.1);
}

.preset-label {
    display: block;
    font-size: 0.75rem;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: var(--spacing-sm);
}

.preset-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.preset-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    font-size: 0.8125rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.preset-btn:hover {
    background: var(--bg-card);
    border-color: var(--text-muted);
    color: var(--text-primary);
}

.preset-btn.active {
    background: rgba(139, 92, 246, 0.15);
    border-color: var(--accent-primary);
    color: var(--accent-primary);
    box-shadow: 0 0 20px rgba(139, 92, 246, 0.2);
}

.preset-btn svg {
    width: 14px;
    height: 14px;
}

.preset-btn .preset-icon {
    font-size: 1rem;
    line-height: 1;
}

/* ===== Head Votes Grid ===== */
.votes-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: var(--spacing-md);
    padding: var(--spacing-lg);
}

@media (max-width: 900px) {
    .votes-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 600px) {
    .votes-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 400px) {
    .votes-grid {
        grid-template-columns: 1fr;
    }
}

/* ===== Individual Vote Card ===== */
.vote-card {
    background: var(--bg-card);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-lg);
    padding: var(--spacing-md);
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.vote-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--border-primary);
    transition: background 0.3s ease;
}

/* Vote states */
.vote-card.vote-threat::before {
    background: linear-gradient(90deg, #ef4444, #f87171);
}

.vote-card.vote-threat {
    border-color: rgba(239, 68, 68, 0.4);
    box-shadow: 0 0 20px rgba(239, 68, 68, 0.15);
}

.vote-card.vote-safe::before {
    background: linear-gradient(90deg, #10b981, #34d399);
}

.vote-card.vote-safe {
    border-color: rgba(16, 185, 129, 0.4);
    box-shadow: 0 0 20px rgba(16, 185, 129, 0.15);
}

.vote-card.vote-abstain::before {
    background: linear-gradient(90deg, #f59e0b, #fbbf24);
}

.vote-card.vote-abstain {
    border-color: rgba(245, 158, 11, 0.4);
    box-shadow: 0 0 20px rgba(245, 158, 11, 0.15);
}

/* Card header */
.vote-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--spacing-sm);
}

.vote-head-name {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.vote-head-icon {
    width: 18px;
    height: 18px;
    color: var(--text-muted);
}

/* Vote indicator */
.vote-indicator {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 12px;
    border-radius: var(--radius-md);
    font-size: 0.8125rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: var(--spacing-sm);
    transition: all 0.3s ease;
}

.vote-indicator.threat {
    background: rgba(239, 68, 68, 0.15);
    color: #f87171;
    border: 1px solid rgba(239, 68, 68, 0.3);
}

.vote-indicator.safe {
    background: rgba(16, 185, 129, 0.15);
    color: #34d399;
    border: 1px solid rgba(16, 185, 129, 0.3);
}

.vote-indicator.abstain {
    background: rgba(245, 158, 11, 0.15);
    color: #fbbf24;
    border: 1px solid rgba(245, 158, 11, 0.3);
}

.vote-indicator svg {
    width: 14px;
    height: 14px;
}

/* Confidence bar */
.vote-confidence {
    margin-bottom: var(--spacing-sm);
}

.confidence-label {
    display: flex;
    justify-content: space-between;
    font-size: 0.6875rem;
    color: var(--text-muted);
    margin-bottom: 4px;
}

.confidence-bar {
    height: 4px;
    background: var(--bg-tertiary);
    border-radius: 2px;
    overflow: hidden;
}

.confidence-fill {
    height: 100%;
    border-radius: 2px;
    transition: width 0.5s ease;
    background: var(--text-muted);
}

.vote-card.vote-threat .confidence-fill {
    background: linear-gradient(90deg, #ef4444, #f87171);
}

.vote-card.vote-safe .confidence-fill {
    background: linear-gradient(90deg, #10b981, #34d399);
}

.vote-card.vote-abstain .confidence-fill {
    background: linear-gradient(90deg, #f59e0b, #fbbf24);
}

/* Weight bar */
.vote-weight {
    margin-top: var(--spacing-sm);
    padding-top: var(--spacing-sm);
    border-top: 1px solid var(--border-primary);
}

.weight-label {
    display: flex;
    justify-content: space-between;
    font-size: 0.6875rem;
    color: var(--text-muted);
    margin-bottom: 4px;
}

.weight-bar {
    height: 6px;
    background: var(--bg-tertiary);
    border-radius: 3px;
    overflow: hidden;
}

.weight-fill {
    height: 100%;
    border-radius: 3px;
    transition: width 0.5s ease;
    background: linear-gradient(90deg, var(--accent-primary), var(--accent-secondary));
}

/* Vote reason tooltip */
.vote-reason {
    font-size: 0.6875rem;
    color: var(--text-muted);
    margin-top: var(--spacing-xs);
    line-height: 1.4;
    opacity: 0.8;
}

/* ===== Calculation Section ===== */
.voting-calculation {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--spacing-lg);
    padding: var(--spacing-lg);
    border-top: 1px solid var(--border-primary);
    background: rgba(0, 0, 0, 0.1);
}

@media (max-width: 700px) {
    .voting-calculation {
        grid-template-columns: 1fr;
    }
}

.calc-section {
    background: var(--bg-card);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-lg);
    padding: var(--spacing-md);
}

.calc-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: var(--spacing-md);
}

.calc-title svg {
    width: 16px;
    height: 16px;
    color: var(--accent-primary);
}

/* Weighted scores */
.weighted-scores {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm);
}

.score-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
}

.score-label {
    font-size: 0.8125rem;
    font-weight: 500;
}

.score-label.threat {
    color: #f87171;
}

.score-label.safe {
    color: #34d399;
}

.score-label.abstain {
    color: #fbbf24;
}

.score-value {
    font-size: 0.875rem;
    font-weight: 700;
    font-family: var(--font-mono);
    color: var(--text-primary);
}

.score-heads {
    font-size: 0.6875rem;
    color: var(--text-muted);
    margin-top: 2px;
}

/* Ratio display */
.ratio-display {
    margin-top: var(--spacing-md);
    padding: var(--spacing-md);
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
    text-align: center;
}

.ratio-label {
    font-size: 0.75rem;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}

.ratio-value {
    font-size: 1.5rem;
    font-weight: 900;
    font-family: var(--font-mono);
    color: var(--text-primary);
}

.ratio-threshold {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 4px;
}

.ratio-threshold.met {
    color: #34d399;
}

.ratio-threshold.not-met {
    color: #f87171;
}

/* ===== Decision Rules ===== */
.rules-list {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm);
}

.rule-item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 10px 12px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
    border-left: 3px solid var(--border-primary);
    transition: all 0.3s ease;
}

.rule-item.passed {
    border-left-color: #10b981;
}

.rule-item.failed {
    border-left-color: var(--text-muted);
    opacity: 0.6;
}

.rule-item.deciding {
    border-left-color: var(--accent-primary);
    background: rgba(139, 92, 246, 0.1);
    box-shadow: 0 0 15px rgba(139, 92, 246, 0.2);
}

.rule-icon {
    flex-shrink: 0;
    width: 18px;
    height: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    font-size: 0.75rem;
}

.rule-item.passed .rule-icon {
    background: rgba(16, 185, 129, 0.2);
    color: #34d399;
}

.rule-item.failed .rule-icon {
    background: rgba(100, 100, 100, 0.2);
    color: var(--text-muted);
}

.rule-item.deciding .rule-icon {
    background: rgba(139, 92, 246, 0.2);
    color: var(--accent-primary);
}

.rule-content {
    flex: 1;
    min-width: 0;
}

.rule-name {
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 2px;
}

.rule-item.failed .rule-name {
    color: var(--text-secondary);
}

.rule-details {
    font-size: 0.6875rem;
    color: var(--text-muted);
    line-height: 1.4;
}

/* ===== Final Decision ===== */
.voting-decision {
    padding: var(--spacing-lg);
    border-top: 1px solid var(--border-primary);
    text-align: center;
}

.decision-box {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    padding: 16px 32px;
    border-radius: var(--radius-xl);
    font-size: 1.125rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 1px;
    animation: pulseGlow 2s ease-in-out infinite;
}

.decision-box.threat {
    background: linear-gradient(135deg, rgba(239, 68, 68, 0.2), rgba(239, 68, 68, 0.1));
    border: 2px solid rgba(239, 68, 68, 0.5);
    color: #f87171;
    box-shadow: 0 0 30px rgba(239, 68, 68, 0.3);
}

.decision-box.safe {
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.2), rgba(16, 185, 129, 0.1));
    border: 2px solid rgba(16, 185, 129, 0.5);
    color: #34d399;
    box-shadow: 0 0 30px rgba(16, 185, 129, 0.3);
}

.decision-box.review {
    background: linear-gradient(135deg, rgba(245, 158, 11, 0.2), rgba(245, 158, 11, 0.1));
    border: 2px solid rgba(245, 158, 11, 0.5);
    color: #fbbf24;
    box-shadow: 0 0 30px rgba(245, 158, 11, 0.3);
}

.decision-box svg {
    width: 24px;
    height: 24px;
}

@keyframes pulseGlow {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.85;
    }
}

.decision-rule {
    margin-top: var(--spacing-md);
    font-size: 0.8125rem;
    color: var(--text-tertiary);
}

.decision-rule strong {
    color: var(--text-secondary);
}

/* ===== Animations ===== */
.vote-card {
    animation: cardFadeIn 0.3s ease-out;
    animation-fill-mode: both;
}

.vote-card:nth-child(1) { animation-delay: 0.05s; }
.vote-card:nth-child(2) { animation-delay: 0.1s; }
.vote-card:nth-child(3) { animation-delay: 0.15s; }
.vote-card:nth-child(4) { animation-delay: 0.2s; }
.vote-card:nth-child(5) { animation-delay: 0.25s; }

@keyframes cardFadeIn {
    from {
        opacity: 0;
        transform: translateY(10px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.rule-item {
    animation: ruleFadeIn 0.2s ease-out;
    animation-fill-mode: both;
}

.rule-item:nth-child(1) { animation-delay: 0.3s; }
.rule-item:nth-child(2) { animation-delay: 0.35s; }
.rule-item:nth-child(3) { animation-delay: 0.4s; }
.rule-item:nth-child(4) { animation-delay: 0.45s; }
.rule-item:nth-child(5) { animation-delay: 0.5s; }
.rule-item:nth-child(6) { animation-delay: 0.55s; }

@keyframes ruleFadeIn {
    from {
        opacity: 0;
        transform: translateX(-10px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.decision-box {
    animation: decisionPop 0.4s ease-out 0.6s;
    animation-fill-mode: both;
}

@keyframes decisionPop {
    0% {
        opacity: 0;
        transform: scale(0.8);
    }
    70% {
        transform: scale(1.05);
    }
    100% {
        opacity: 1;
        transform: scale(1);
    }
}

/* ===== Preset transition ===== */
.voting-viz.transitioning .vote-card,
.voting-viz.transitioning .rule-item,
.voting-viz.transitioning .decision-box {
    animation: none;
}

.voting-viz.transitioning .vote-card {
    transition: all 0.3s ease;
}
