/**
 * Frontend: style sondaży (wszystkie typy wykresów).
 */

.sp-poll-wrap {
    padding: 30px 20px;
    margin: 20px 0;
    box-sizing: border-box;
    position: relative;
}
.sp-poll-wrap *, .sp-poll-wrap *::before, .sp-poll-wrap *::after {
    box-sizing: border-box;
}
.sp-poll-title {
    font-size: 28px;
    font-weight: 700;
    margin: 0 0 8px;
    line-height: 1.2;
}

/* ============= Zakładki (tabs) ============= */
.sp-tabs-nav {
    display: flex;
    justify-content: center;
    gap: 12px;
    margin: 20px 0 24px;
    flex-wrap: wrap;
}
.sp-tab-btn {
    padding: 12px 28px;
    border-radius: 6px;
    border: 2px solid transparent;
    background: #e0e0e0;
    color: #333;
    cursor: pointer;
    font-weight: 600;
    font-size: 15px;
    transition: all .2s ease;
    font-family: inherit;
}
.sp-tab-btn:hover {
    background: #d0d0d0;
}
.sp-tab-btn.active {
    background: #c94c4c;
    color: #fff;
    border-color: #c94c4c;
}
.sp-tab-btn.active.blue {
    background: #58b4e8;
    border-color: #58b4e8;
}
.sp-tab-panel {
    animation: spTabFade .3s ease;
}
@keyframes spTabFade {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
}
.sp-poll-question {
    background-color: #25467E;
    color: #fff;
    padding: 14px 20px;
    border-radius: 6px;
    font-weight: 600;
    font-size: 17px;
    text-align: center;
    margin: 18px auto 22px;
    max-width: 800px;
}
.sp-poll-subtitle {
    font-size: 15px;
    opacity: .75;
    margin-bottom: 22px;
    font-style: italic;
}
.sp-poll-error {
    color: #c94c4c;
    padding: 12px;
    border-left: 4px solid #c94c4c;
    background: #fff5f5;
}

/* ============= Wykres poziomy ============= */
.sp-chart-horizontal { max-width: 900px; margin: 0 auto; }
.sp-row {
    display: grid;
    grid-template-columns: 80px 220px 1fr 80px;
    gap: 12px;
    align-items: center;
    margin-bottom: 10px;
    min-height: 44px;
}
.sp-row-image img {
    width: 110px;
    height: 50px;
    object-fit: contain;
    border-radius: 6px;
    background: #fff;
}
.sp-row-label {
    font-weight: 600;
    font-size: 15px;
    text-align: right;
}
.sp-row-label.sp-bold { font-weight: 800; font-size: 17px; }
.sp-row-bar-wrap {
    height: 38px;
    position: relative;
    background: transparent;
}
.sp-row-bar {
    height: 100%;
    border-radius: 6px;
    width: 0;
    transition: width var(--anim-dur, 1200ms) cubic-bezier(.22,1,.36,1);
}
.sp-row-value {
    font-weight: 700;
    font-size: 18px;
    opacity: 0;
    transition: opacity 400ms ease;
}
.sp-poll-wrap.animate .sp-row-value { opacity: 1; }

/* ============= Wykres pionowy ============= */
.sp-chart-vertical {
    display: flex;
    justify-content: space-around;
    align-items: flex-end;
    gap: 20px;
    padding: 40px 20px 0;
    min-height: 180px;
    max-width: 900px;
    margin: 0 auto;
}
.sp-vcol {
    display: flex;
    flex-direction: column;
    align-items: center;
    flex: 1;
    max-width: 140px;
}
.sp-vcol-value {
    font-weight: 700;
    font-size: 24px;
    margin-bottom: 12px;
    opacity: 0;
    transition: opacity 400ms ease;
    min-height: 30px;
}
.sp-poll-wrap.animate .sp-vcol-value { opacity: 1; }
.sp-vcol-bar-wrap {
    width: 100%;
    display: flex;
    align-items: flex-end;
}
.sp-vcol-bar {
    width: 100%;
    border-radius: 16px 16px 0 0;
    height: 0;
    transition: height var(--anim-dur, 1200ms) cubic-bezier(.22,1,.36,1);
    min-height: 0;
}
.sp-vcol-label {
    margin-top: 12px;
    text-align: center;
    font-size: 14px;
    font-weight: 600;
    line-height: 1.3;
    min-height: 40px;
    display: flex;
    align-items: flex-start;
    justify-content: center;
}
.sp-vcol-label.sp-bold { font-weight: 800; font-size: 16px; }

/* ============= Bar left (ujemne — oś zero pośrodku) ============= */
.sp-chart-bar-left {
    position: relative;
    max-width: 900px;
    margin: 0 auto;
    padding: 10px 0;
}
.sp-bl-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
    min-height: 44px;
}
.sp-bl-row .sp-row-image {
    flex: 0 0 60px;
    display: flex;
    justify-content: center;
}
.sp-bl-row .sp-row-image img {
    width: 56px;
    height: 56px;
    object-fit: contain;
    border-radius: 6px;
    background: #fff;
    padding: 2px;
}
.sp-bl-row .sp-row-label {
    flex: 0 0 140px;
    font-weight: 600;
    text-align: right;
    font-size: 14px;
    line-height: 1.2;
}
.sp-bl-bar-wrap {
    flex: 1;
    position: relative;
    height: 38px;
    min-width: 100px;
}
.sp-bl-row .sp-row-value {
    flex: 0 0 55px;
    font-weight: 700;
    font-size: 18px;
    opacity: 0;
    transition: opacity 400ms;
}
.sp-poll-wrap.animate .sp-bl-row .sp-row-value { opacity: 1; }
/* Oś zero w środku */
.sp-bl-bar-wrap::before {
    content: '';
    position: absolute;
    left: 50%;
    top: 0;
    bottom: 0;
    width: 2px;
    background: rgba(0,0,0,.25);
    transform: translateX(-50%);
    z-index: 1;
}
.sp-bl-bar {
    position: absolute;
    top: 0;
    height: 100%;
    border-radius: 6px;
    width: 0;
    z-index: 2;
}
.sp-poll-wrap.animate .sp-bl-bar {
    transition: width var(--anim-dur, 1200ms) cubic-bezier(.4,0,.2,1);
}
/* Dodatnie — rosną od osi w prawo */
.sp-bl-bar.sp-bl-pos {
    left: 50%;
    border-radius: 0 6px 6px 0;
}
/* Ujemne — rosną od osi w lewo */
.sp-bl-bar.sp-bl-neg {
    right: 50%;
    border-radius: 6px 0 0 6px;
}
.sp-val-neg { font-weight: 700; color: #c94c4c !important; }

/* ============= Diverging (podzielony) ============= */
.sp-chart-diverging {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    gap: 20px;
    max-width: 1100px;
    margin: 0 auto;
    align-items: start;
}
.sp-div-side h3.sp-div-title {
    font-size: 20px;
    margin: 0 0 16px;
    text-align: center;
}
.sp-div-divider {
    width: 2px;
    background: rgba(0,0,0,.25);
    min-height: 100%;
}
.sp-div-row {
    display: grid;
    grid-template-columns: 80px 140px 1fr 80px;
    gap: 8px;
    align-items: center;
    margin-bottom: 10px;
    min-height: 44px;
}
.sp-div-bar-wrap { display: flex; }
.sp-div-bar-wrap-neg { justify-content: flex-end; }
.sp-div-bar {
    height: 38px;
    border-radius: 6px;
    width: 0;
    transition: width var(--anim-dur, 1200ms) cubic-bezier(.22,1,.36,1);
}
.sp-div-neg { border-radius: 6px 0 0 6px; }

/* ============= Pie / Donut (SVG) ============= */
.sp-poll-chart-container {
    width: 100%;
    max-width: 900px;
    margin: 0 auto;
}
.sp-svg-chart {
    display: block;
    width: 100%;
    max-width: 360px;
    height: auto;
    margin: 0 auto 20px;
    overflow: visible;
}
.sp-pie-slice {
    transform-origin: 200px 200px;
    transform: scale(0);
    opacity: 0;
}
.sp-poll-wrap.animate .sp-pie-slice {
    animation-name: spPieGrow;
    animation-duration: 1s;
    animation-timing-function: cubic-bezier(.22,1,.36,1);
    animation-fill-mode: forwards;
    animation-delay: 0ms;
}
.sp-poll-wrap:not(.animate) .sp-pie-slice {
    transform: scale(1);
    opacity: 1;
}
.sp-pie-label {
    pointer-events: none;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    opacity: 0;
    transform-origin: center;
    transform: scale(0.5);
}
.sp-poll-wrap.animate .sp-pie-label {
    animation-name: spFadeIn;
    animation-duration: 0.5s;
    animation-timing-function: ease;
    animation-fill-mode: forwards;
    animation-delay: 0ms;
}
.sp-poll-wrap:not(.animate) .sp-pie-label {
    opacity: 1;
    transform: scale(1);
}
@keyframes spPieGrow {
    0% {
        transform: scale(0) rotate(-90deg);
        opacity: 0;
    }
    50% {
        opacity: 1;
    }
    100% {
        transform: scale(1) rotate(0deg);
        opacity: 1;
    }
}
@keyframes spFadeIn {
    0% { 
        opacity: 0;
        transform: scale(0.5);
    }
    100% { 
        opacity: 1;
        transform: scale(1);
    }
}
.sp-center-logo {
    pointer-events: none;
}
.sp-chartjs-wrap {
    position: relative;
    width: 100%;
    max-width: 560px;
    margin: 0 auto 20px;
}
.sp-chartjs-wrap canvas {
    display: block;
    width: 100%;
    height: auto;
    max-height: 560px;
}
.sp-legend-inline {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 16px;
    margin-top: 24px;
}
.sp-legend-item {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 15px;
    font-weight: 600;
}
.sp-legend-color {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    display: inline-block;
}

/* ============= Tabela z wykresem ============= */
.sp-table-chart {
    width: 100%;
    border-collapse: collapse;
    max-width: 900px;
    margin: 0 auto;
    font-size: 15px;
}
.sp-table-chart th, .sp-table-chart td {
    padding: 10px 8px;
    border-bottom: 1px solid rgba(0,0,0,.1);
    vertical-align: middle;
}
.sp-table-chart th {
    font-weight: 700;
    text-align: left;
}
.sp-tbl-img {
    width: 40px;
    height: 40px;
    object-fit: cover;
    border-radius: 4px;
}
.sp-tbl-bar-wrap {
    height: 28px;
    display: flex;
    position: relative;
}
.sp-tbl-bar {
    height: 100%;
    border-radius: 4px;
    width: 0;
    transition: width var(--anim-dur, 1200ms) cubic-bezier(.22,1,.36,1);
}
.sp-tbl-neg { border-radius: 4px 0 0 4px; margin-left: auto; }
.sp-tbl-bar.sp-tbl-neg {
    /* ujemne - szerokość liczona od prawej */
}
.sp-bold { font-weight: 800; }

/* ============= Legenda ============= */
.sp-legend {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 18px;
    margin: 28px auto 0;
    max-width: 1000px;
    padding: 0 20px;
}

/* ============= Stopka (przypisy) ============= */
.sp-poll-footer {
    max-width: 900px;
    margin: 22px auto 0;
    padding: 14px 20px;
    background: rgba(0,0,0,.04);
    border-radius: 6px;
    font-size: 13px;
    line-height: 1.6;
	display: flex;
	justify-content: space-between;
}
.sp-footer-block { margin-bottom: 4px; }
.sp-footer-block:last-child { margin-bottom: 0; }

/* ============= Przyciski CTA ============= */
.sp-poll-cta {
    display: flex;
    justify-content: center;
    gap: 18px;
    margin: 26px auto 0;
    flex-wrap: wrap;
}
.sp-cta-btn {
    display: inline-block;
    padding: 14px 34px;
    color: #fff !important;
    border-radius: 8px;
    text-decoration: none;
    font-weight: 700;
    font-size: 16px;
    transition: transform .15s, box-shadow .15s;
    box-shadow: 0 2px 6px rgba(0,0,0,.15);
}
.sp-cta-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(0,0,0,.25);
}

/* ============= Responsywność ============= */
@media (max-width: 768px) {
    .sp-row, .sp-bl-row, .sp-div-row {
        grid-template-columns: 60px 120px 1fr 60px;
        gap: 6px;
    }
    .sp-row-label { font-size: 13px; }
    .sp-row-value, .sp-vcol-value { font-size: 14px; }
    .sp-poll-title { font-size: 22px; }
    .sp-poll-question { font-size: 14px; padding: 12px 14px; }
    .sp-chart-diverging { grid-template-columns: 1fr; }
    .sp-div-divider { display: none; }
    .sp-chart-vertical { min-height: 280px; gap: 10px; }
    .sp-bl-bar-wrap::before { opacity: .5; }
}
@media (max-width: 480px) {
    .sp-row, .sp-bl-row, .sp-div-row {
        grid-template-columns: 40px 100px 1fr 50px;
    }
    .sp-row-image img, .sp-bl-row .sp-row-image img {
        width: 40px; height: 40px;
    }
    .sp-row-label { font-size: 11px; }
    .sp-row-value { font-size: 12px; }
    .sp-bl-bar-wrap::before { display: none; }
}

/* Placeholder do sortowania */
.sp-item-placeholder {
    background: #f0f0f1;
    border: 2px dashed #999;
    height: 60px;
    margin-bottom: 8px;
    border-radius: 6px;
}
