/* ==========================================================================
   Sport Widget - Frontend Styles
   ========================================================================== */

/* Ticker wrapper */
.sw-widget {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 13px;
    line-height: 1.3;
    box-sizing: border-box;
}

/* Placeholder iniziale: invisibile, zero spazio, zero CLS */
.sw-widget.sw-placeholder {
    display: none;
}

/* Skeleton: altezza fissa (non usato di default, tenuto per eventuale riuso) */
.sw-widget.sw-loading {
    min-height: 76px;
}

/* Fade-in: contenuto arriva nascosto e appare morbidamente */
.sw-widget.sw-fade-hidden {
    opacity: 0;
    max-height: 0;
    overflow: hidden;
    transition: opacity 0.35s ease, max-height 0.35s ease;
}

.sw-widget.sw-fade-in {
    opacity: 1;
    max-height: 200px; /* ampio margine, il contenuto reale è ~80px */
    transition: opacity 0.35s ease, max-height 0.35s ease;
}

/* Fade-out quando le partite finiscono */
.sw-widget.sw-fade-out {
    opacity: 0;
    max-height: 0;
    overflow: hidden;
    transition: opacity 0.3s ease, max-height 0.3s ease;
}

/* Empty state: nessuno spazio */
.sw-widget.sw-empty-state {
    display: none;
}

.sw-widget *,
.sw-widget *::before,
.sw-widget *::after {
    box-sizing: border-box;
}

/* Live Scores - Ticker horizontal */
.sw-live-scores {
    background: transparent;
    border-radius: 0;
    overflow: visible;
    padding: 0;
    display: flex;
    align-items: center;
    gap: 0;
    position: relative;
}

/* Arrow buttons */
.sw-arrow {
    display: none;
    align-items: center;
    justify-content: center;
    width: 32px;
    min-height: 60px;
    background: #1a1d23;
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #94a3b8;
    cursor: pointer;
    flex-shrink: 0;
    padding: 0;
    transition: all 0.2s ease;
    z-index: 2;
}

.sw-arrow--left {
    border-radius: 8px 0 0 8px;
}

.sw-arrow--right {
    border-radius: 0 8px 8px 0;
}

.sw-arrow:hover {
    background: #2a2d36;
    color: #fff;
}

.sw-arrow.sw-arrow--visible {
    display: flex;
}

.sw-arrow:active {
    background: #333;
}

.sw-ticker-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    -ms-overflow-style: none;
    flex: 1;
    scroll-behavior: smooth;
    cursor: grab;
}

.sw-ticker-wrapper:active {
    cursor: grabbing;
}

.sw-ticker-wrapper::-webkit-scrollbar {
    display: none;
}

.sw-ticker-track {
    display: flex;
    gap: 10px;
    padding: 6px 8px;
    min-width: min-content;
}

/* Single match card - PILL style */
.sw-match {
    flex-shrink: 0;
    background: #22252d;
    padding: 10px 14px;
    min-width: 135px;
    border-radius: 10px;
    transition: background 0.2s ease, transform 0.15s ease;
    display: flex;
    align-items: center;
    gap: 10px;
    border: 1px solid rgba(255, 255, 255, 0.06);
}

.sw-match:hover {
    background: #2a2d36;
    transform: translateY(-1px);
}

.sw-match--live {
    border-top: 2px solid #e74c3c;
}

.sw-match--upcoming {
    border-top: 2px solid #3498db;
}

.sw-match--finished {
    border-top: 2px solid #555;
}

/* Match row (home / away) */
.sw-match-teams {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.sw-match-row {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 3px 0;
}

.sw-match-row:first-child {
    padding-bottom: 4px;
}

/* Minute centered between rows */
.sw-match-minute {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    min-width: 32px;
}

/* Team logo */
.sw-team-logo {
    width: 16px;
    height: 16px;
    object-fit: contain;
    flex-shrink: 0;
    border-radius: 2px;
}

/* Team name */
.sw-team-name {
    color: #e0e0e0;
    font-weight: 600;
    font-size: 12px;
    letter-spacing: 0.5px;
    flex: 1;
    white-space: nowrap;
}

/* Score */
.sw-score {
    color: #ffffff;
    font-weight: 700;
    font-size: 13px;
    min-width: 14px;
    text-align: center;
    margin-left: 12px;
}

/* Minute indicator */
.sw-minute {
    color: #888;
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
    text-align: center;
}

.sw-minute--live {
    color: #e74c3c;
    font-size: 13px;
    font-weight: 700;
    animation: sw-pulse 1.5s ease-in-out infinite;
}

@keyframes sw-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

/* Skeleton loading shimmer */
.sw-match--skeleton {
    pointer-events: none;
}

.sw-skeleton-bar {
    display: inline-block;
    height: 10px;
    background: linear-gradient(90deg, #2a2d36 25%, #3a3d46 50%, #2a2d36 75%);
    background-size: 200% 100%;
    animation: sw-shimmer 1.5s ease-in-out infinite;
    border-radius: 4px;
}

.sw-skeleton-bar--score {
    width: 14px;
    height: 12px;
    margin-left: auto;
}

@keyframes sw-shimmer {
    0%   { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

.sw-loading .sw-match--skeleton {
    border-top: 2px solid #333;
}

/* Empty state */
.sw-empty {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 16px 20px;
    color: #888;
    font-size: 13px;
    background: #1a1d23;
}

.sw-empty-icon {
    font-size: 18px;
}

.sw-empty-text {
    font-style: italic;
}

/* ==========================================================================
   Upcoming Widget Styles
   ========================================================================== */

.sw-upcoming {
    background: #1a1d23;
    border-radius: 6px;
    overflow: hidden;
    padding: 12px;
}

.sw-upcoming-league {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 0 4px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    margin-bottom: 6px;
}

.sw-league-flag {
    width: 16px;
    height: 12px;
    object-fit: contain;
}

.sw-league-name {
    color: #888;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.sw-upcoming-match {
    padding: 8px 4px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.sw-upcoming-match:last-child {
    border-bottom: none;
}

.sw-upcoming-match-teams {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.sw-upcoming-team {
    display: flex;
    align-items: center;
    gap: 6px;
    color: #e0e0e0;
    font-size: 12px;
    font-weight: 500;
}

.sw-upcoming-time {
    color: #3498db;
    font-weight: 700;
    font-size: 13px;
    min-width: 40px;
    text-align: center;
    background: rgba(52, 152, 219, 0.1);
    padding: 2px 8px;
    border-radius: 4px;
}

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

@media (max-width: 768px) {
    .sw-arrow {
        display: none !important;
        width: 0 !important;
        height: 0 !important;
        overflow: hidden !important;
        padding: 0 !important;
        margin: 0 !important;
        border: none !important;
        position: absolute !important;
        visibility: hidden !important;
    }

    .sw-arrow.sw-arrow--visible {
        display: none !important;
    }

    .sw-live-scores {
        gap: 0;
    }

    .sw-ticker-track {
        gap: 10px;
        padding: 6px 10px;
    }

    .sw-match {
        min-width: 120px;
        padding: 10px 12px;
        border-radius: 10px;
    }

    .sw-team-name {
        font-size: 11px;
    }
}

/* ==========================================================================
   Debug Banner
   ========================================================================== */
.sw-debug-banner {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 99999;
    background: #1a1a2e;
    color: #e0e0e0;
    text-align: center;
    padding: 6px 12px;
    font-size: 12px;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    border-top: 2px solid #f39c12;
    letter-spacing: 0.5px;
}

/* ==========================================================================
   Popup Dettaglio Partita
   ========================================================================== */
.sw-popup-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 100000;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    display: flex;
    align-items: center;
    justify-content: center;
    animation: sw-overlay-in 0.25s ease;
}

.sw-popup-overlay.sw-popup--closing {
    animation: sw-overlay-out 0.25s ease forwards;
}

@keyframes sw-overlay-in {
    from { opacity: 0; }
    to   { opacity: 1; }
}
@keyframes sw-overlay-out {
    from { opacity: 1; }
    to   { opacity: 0; }
}

.sw-popup {
    background: #1a1d23;
    border-radius: 16px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    width: 90%;
    max-width: 440px;
    max-height: 85vh;
    overflow-y: auto;
    position: relative;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    animation: sw-popup-in 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    scrollbar-width: thin;
    scrollbar-color: #333 transparent;
}

.sw-popup--closing .sw-popup {
    animation: sw-popup-out 0.25s ease forwards;
}

@keyframes sw-popup-in {
    from { opacity: 0; transform: scale(0.9) translateY(30px); }
    to   { opacity: 1; transform: scale(1) translateY(0); }
}
@keyframes sw-popup-out {
    from { opacity: 1; transform: scale(1) translateY(0); }
    to   { opacity: 0; transform: scale(0.9) translateY(30px); }
}

.sw-popup-close {
    position: absolute;
    top: 12px;
    right: 14px;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: none;
    background: rgba(255, 255, 255, 0.08);
    color: #94a3b8;
    font-size: 20px;
    line-height: 30px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
    z-index: 10;
    padding: 0;
}

.sw-popup-close:hover {
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
}

/* Loading */
.sw-popup-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
}

.sw-popup-spinner {
    width: 36px;
    height: 36px;
    border: 3px solid rgba(255, 255, 255, 0.1);
    border-top-color: #e74c3c;
    border-radius: 50%;
    animation: sw-spin 0.7s linear infinite;
}

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

.sw-popup-error {
    text-align: center;
    padding: 40px 20px;
    color: #e74c3c;
    font-size: 14px;
}

/* Match Header */
.sw-popup-header {
    padding: 28px 24px 20px;
    text-align: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.sw-popup-league {
    color: #94a3b8;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    margin-bottom: 16px;
}

.sw-popup-teams {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
}

.sw-popup-team {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    flex: 1;
    min-width: 0;
}

.sw-popup-team-logo {
    width: 48px;
    height: 48px;
    object-fit: contain;
    border-radius: 6px;
}

.sw-popup-team-name {
    color: #e0e0e0;
    font-weight: 700;
    font-size: 13px;
    text-align: center;
    word-break: break-word;
}

.sw-popup-score {
    font-size: 32px;
    font-weight: 800;
    color: #fff;
    min-width: 90px;
    text-align: center;
    letter-spacing: 2px;
    flex-shrink: 0;
}

.sw-popup-time {
    font-size: 28px;
    font-weight: 700;
    color: #3498db;
    min-width: 80px;
    text-align: center;
    flex-shrink: 0;
    background: rgba(52, 152, 219, 0.1);
    padding: 6px 14px;
    border-radius: 10px;
}

/* Body pre-match */
.sw-popup-body {
    padding: 20px 24px 24px;
}

.sw-popup-info-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 10px;
    margin-bottom: 8px;
}

.sw-popup-info-icon {
    font-size: 18px;
    flex-shrink: 0;
}

.sw-popup-info-text {
    color: #cbd5e1;
    font-size: 14px;
    font-weight: 500;
}

/* Body live/finished */
.sw-popup-status {
    text-align: center;
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 1px;
    padding: 6px 14px;
    border-radius: 8px;
    display: inline-block;
    margin-bottom: 16px;
}

.sw-popup-status--live {
    color: #e74c3c;
    background: rgba(231, 76, 60, 0.12);
    animation: sw-pulse 1.5s ease-in-out infinite;
}

.sw-popup-status--finished {
    color: #94a3b8;
    background: rgba(148, 163, 184, 0.1);
}

.sw-popup-body--live {
    text-align: center;
}

.sw-popup-section {
    text-align: left;
    margin-bottom: 16px;
}

.sw-popup-section:last-child {
    margin-bottom: 0;
}

.sw-popup-section-title {
    color: #94a3b8;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 8px;
    padding-bottom: 6px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.sw-popup-incidents {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.sw-popup-incident {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.02);
    transition: background 0.15s;
}

.sw-popup-incident:hover {
    background: rgba(255, 255, 255, 0.05);
}

.sw-popup-incident--home {
    justify-content: flex-start;
}

.sw-popup-incident--away {
    justify-content: flex-end;
}

.sw-popup-inc-time {
    color: #94a3b8;
    font-size: 12px;
    font-weight: 600;
    min-width: 28px;
    flex-shrink: 0;
}

.sw-popup-inc-name {
    color: #e0e0e0;
    font-size: 13px;
    font-weight: 500;
}

.sw-popup-no-incidents {
    color: #64748b;
    font-size: 13px;
    font-style: italic;
    padding: 16px 0;
}

/* Footer + CTA */
.sw-popup-footer {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 14px 20px 18px;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.sw-popup-cta {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    background: rgba(231, 76, 60, 0.10);
    color: #e0e0e0;
    font-size: 12px;
    font-weight: 600;
    border-radius: 24px;
    text-decoration: none;
    letter-spacing: 0.2px;
    transition: all 0.2s;
    white-space: nowrap;
    border: 1px solid rgba(231, 76, 60, 0.15);
}

.sw-popup-cta:hover {
    background: rgba(231, 76, 60, 0.20);
    color: #fff;
    border-color: rgba(231, 76, 60, 0.3);
}

.sw-popup-cta:active {
    transform: none;
}

.sw-popup-cta-text {
    line-height: 1.3;
}

.sw-popup-cta-logo {
    height: 16px;
    width: auto;
    flex-shrink: 0;
    margin-left: 2px;
}

/* Responsive popup */
@media (max-width: 480px) {
    .sw-popup {
        width: 95%;
        border-radius: 12px;
    }

    .sw-popup-team-logo {
        width: 36px;
        height: 36px;
    }

    .sw-popup-score {
        font-size: 26px;
        min-width: 70px;
    }

    .sw-popup-time {
        font-size: 22px;
    }

    .sw-popup-team-name {
        font-size: 12px;
    }

    .sw-popup-header {
        padding: 20px 16px 16px;
    }

    .sw-popup-body {
        padding: 16px;
    }
}
