/* ============================================================
   Frontend - Dettaglio Torneo
   ============================================================ */

/* Tournament header */
.tournament-header {
    margin-bottom: 24px;
}

.tournament-header h1 {
    font-size: 1.6rem;
    font-weight: 700;
    margin-bottom: 4px;
}

.tournament-header-meta {
    display: flex;
    gap: 16px;
    color: var(--gray-500);
    font-size: 0.9rem;
    flex-wrap: wrap;
}

/* Sticky tabs */
.tournament-tabs-sticky {
    position: sticky;
    top: 64px;
    z-index: 100;
    background: var(--gray-100);
    padding-top: 8px;
}

/* Tab content panels */
.tab-panel {
    display: none;
}

.tab-panel.active {
    display: block;
}

/* Standings */
.standings-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(500px, 1fr));
    gap: 24px;
}

.standings-section-title {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

/* === QUICK ACTIONS: salto rapido al girone === */
.quick-groups {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 20px;
    padding: 12px 16px;
    background: var(--white);
    border-radius: var(--radius-sm);
    border: 1px solid var(--gray-200);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    scrollbar-color: transparent transparent;
    cursor: grab;
    user-select: none;
    -webkit-user-select: none;
}

.quick-groups:hover,
.quick-groups:active,
.quick-groups.dragging {
    cursor: grabbing;
    scrollbar-color: var(--gray-300) transparent;
}

.quick-groups::-webkit-scrollbar {
    height: 4px;
}
.quick-groups::-webkit-scrollbar-track {
    background: transparent;
}
.quick-groups::-webkit-scrollbar-thumb {
    background: transparent;
    border-radius: 4px;
    transition: background 0.2s ease;
}
.quick-groups:hover::-webkit-scrollbar-thumb,
.quick-groups:active::-webkit-scrollbar-thumb,
.quick-groups.dragging::-webkit-scrollbar-thumb {
    background: var(--gray-300);
}

.quick-groups-label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--gray-600);
    white-space: nowrap;
    flex-shrink: 0;
}

.quick-groups-list {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}

.quick-group-btn {
    display: inline-flex;
    align-items: center;
    padding: 6px 16px;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--primary);
    background: var(--primary-light);
    border-radius: 20px;
    text-decoration: none;
    white-space: nowrap;
    transition: all 0.15s ease;
    cursor: pointer;
    border: none;
}

.quick-group-btn:hover {
    background: var(--primary);
    color: #fff;
}

.quick-group-btn:active {
    transform: scale(0.96);
}

/* Group matches (shared with admin - see style.css for base styles) */

/* Participanti tab */
.participants-table-controls {
    display: flex;
    gap: 12px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.participant-row {
    cursor: pointer;
}

.participant-row:hover td {
    background: var(--primary-light) !important;
}

.participant-sort-icon {
    cursor: pointer;
    user-select: none;
    font-size: 0.8rem;
    margin-left: 4px;
}

.participant-actions a {
    font-size: 0.85rem;
}

/* Points modal frontend - Modern style */
.points-modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.45);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 9999;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.points-modal-overlay.active {
    display: flex;
}

.points-modal-box {
    background: #fff;
    border-radius: var(--radius);
    max-width: 640px;
    width: 100%;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 12px 40px rgba(0,0,0,0.15), 0 4px 12px rgba(0,0,0,0.08);
    border: 1px solid rgba(255,255,255,0.3);
}

.points-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    border-bottom: 1px solid var(--gray-200);
    background: linear-gradient(135deg, var(--primary-light) 0%, #fff 100%);
    border-radius: var(--radius) var(--radius) 0 0;
    position: relative;
}

/* .points-modal-header::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
    background: linear-gradient(180deg, var(--primary) 0%, var(--primary-dark) 100%);
    border-radius: 4px 0 0 0;
} */


.points-modal-title-wrap{
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    align-items: center;
}

.points-modal-header h3 {
    font-size: 1.15rem;
    font-weight: 700;
    margin: 0;
    color: var(--gray-800);
    display: flex;
    align-items: center;
    gap: 8px;
}

/* .points-modal-header h3::before {
    content: '\f0cb';
    font-family: 'FontAwesome';
    font-weight: 900;
    font-size: 0.9rem;
    color: var(--primary);
} */

.points-modal-subtitle {
    font-size: 0.82rem;
    color: var(--gray-600);
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-top: 2px;
    background: var(--gray-100);
    padding: 3px 12px;
    border-radius: 20px;
    font-weight: 500;
}

.points-modal-close-btn {
    background: var(--gray-100);
    border: none;
    font-size: 1.2rem;
    cursor: pointer;
    color: var(--gray-500);
    transition: all 0.2s ease;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.points-modal-close-btn:hover {
    background: var(--gray-200);
    color: var(--gray-800);
    transform: rotate(90deg);
}

.points-modal-close-btn:active {
    transform: rotate(90deg) scale(0.92);
}

/* Drag handle: visibile solo su mobile (< 992px) */
.modal-drag-handle {
    display: none;
}

.points-modal-body {
    padding: 0;
}

.points-modal-body .team-td .team-name-container{
    display: flex;
    flex-direction: column;
        align-items: flex-start;
}
.points-modal-body .team-td .team-name-dash{
    display: none;
}


.points-modal-body .standings-table {
    border-collapse: separate;
    border-spacing: 0;
}

.points-modal-body .standings-table thead th {
    background: var(--gray-100);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    color: var(--gray-600);
    padding: 10px 12px;
    font-weight: 700;
}

.points-modal-body .standings-table thead th:first-child {
    border-radius: 0;
}

.points-modal-body .standings-table thead th:last-child {
    border-radius: 0;
}

.points-modal-body .standings-table tbody tr {
    transition: background 0.15s ease;
}

.points-modal-body .standings-table tbody tr:hover td {
    background: var(--primary-light);
}

.points-modal-body .standings-table tbody td {
    padding: 10px 12px;
    font-size: 0.88rem;
        line-height: 1.2;
    border-bottom: none;
    vertical-align: middle;
         border-bottom: 1px solid var(--gray-200);
}

.points-modal-body .standings-table tbody tr:last-child td {
    border-bottom: none;
}

/* Colonna punti badge */
.points-modal-body .standings-table td.punti-col strong {
    font-size: 1.1rem;
    font-weight: 700;
    line-height: 1;
}


/* Colori punti */
.points-modal-body .standings-table tr:has(.punti-loss) td.punti-col strong {
    color: var(--danger);
}

.points-modal-body .standings-table tr:has(.punti-win) td.punti-col strong {
    color: var(--success);
}



/* Numerazione riga */
.points-modal-body .standings-table tbody tr {
   
}


/* Numerazione riga */
.points-modal-body .standings-table tbody td:first-child {
    font-weight: 700;
    color: var(--gray-400);
    font-size: 0.8rem;
    width: 36px;
    text-align: center;
}

/* Nome avversario */
.points-modal-body .standings-table tbody td:nth-child(2) {
    font-weight: 600;
    color: var(--gray-800);
}

/* Risultato badge */
.points-modal-body .standings-table tbody td:nth-child(3) {
    font-weight: 600;
}

.points-modal-body .standings-table tbody td:nth-child(4) {
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--gray-700);
}

.points-modal-loading {
    text-align: center;
    padding: 50px 0;
    color: var(--gray-500);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

.points-modal-loading::before {
    content: '';
    width: 32px;
    height: 32px;
    border: 3px solid var(--gray-200);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: points-spin 0.8s linear infinite;
}

@keyframes points-spin {
    to { transform: rotate(360deg); }
}

/* Punti breakdown */
.punti-breakdown-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.punti-breakdown-item {
    display: flex;
    justify-content: space-between;
    padding: 6px 0;
    border-bottom: 1px solid var(--gray-200);
    font-size: 0.9rem;
}

.punti-breakdown-label {
    color: var(--gray-600);
}

.punti-breakdown-value {
    font-weight: 700;
}

/* Punti modal table extras */
.punti-win {
    color: var(--success);
    font-weight: 700;
    align-items: center;
    gap: 4px;
}

.punti-win::before {
    content: '\f00c';
    font-family: 'FontAwesome';
    font-weight: 900;
    font-size: 0.65rem;
      margin-right: 10px;
}

.punti-loss {
    color: var(--danger);
    font-weight: 500;
    align-items: center;
    gap: 4px;
}

.punti-loss::before {
    content: '\f00d';
    font-family: 'FontAwesome';
    font-weight: 900;
    font-size: 0.65rem;
      margin-right: 10px;
}


.punti-loss,
.punti-win {

    position: relative;
    padding-left: 20px!important    ;

    &:before{
        position: absolute;
        top: 50%;
        left: 0;
        transform: translateY(-50%);
        
    font-size: 1rem;
    }

}

.punti-bonus {
    font-size: 0.82rem;
    font-weight: 500;
    color: var(--gray-700);
}

.punti-bonus .bonus-badge {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
}

/* Testo bonus raw (descrittivo, non numerico) */
.punti-bonus:not(:has(.bonus-badge)) {
    font-size: 0.78rem;
    color: var(--gray-600);
    line-height: 1.4;
}

.punti-bonus .bonus-badge.bonus-positive {
    background: #e6f4ea;
    color: var(--success);
}

.punti-bonus .bonus-badge.bonus-negative {
    background: #fce8e6;
    color: var(--danger);
}

.punti-bonus .bonus-badge.bonus-neutral {
    background: var(--gray-100);
    color: var(--gray-600);
}

/* Responsive */
@media (max-width: 768px) {
    .standings-grid {
        grid-template-columns: 1fr;
    }

    .tournament-header h1 {
        font-size: 1.3rem;
    }
}

/* === MOBILE: Tabella gironi compatta e collassabile === */
@media (max-width: 991px) {
    .standings-table.mobile-compact tbody tr {
        cursor: pointer;
        transition: background 0.15s ease;
    }

    .standings-table.mobile-compact tbody tr:hover {
        background: var(--primary-light);
    }

    .standings-table.mobile-compact tbody tr.expanded {
        background: #e8f0fe;
        border-bottom: none;
    }

    .standings-table.mobile-compact tbody tr.standings-detail-row {
        display: none;
    }

    .standings-table.mobile-compact tbody tr.standings-detail-row.expanded {
        display: table-row;
    }

    .standings-table.mobile-compact tbody tr.standings-detail-row td {
        padding: 12px 16px 16px;
        background: var(--gray-100);
        border-bottom: 2px solid var(--primary);
    }

    .standings-detail-grid {
        display: grid;
        grid-template-columns: repeat(3, 1fr);
        gap: 8px 12px;
    }

    .standings-detail-item {
        display: flex;
        flex-direction: column;
        gap: 1px;
    }

    .standings-detail-item .detail-label {
        font-size: 0.65rem;
        text-transform: uppercase;
        letter-spacing: 0.3px;
        color: var(--gray-500);
        font-weight: 600;
    }

    .standings-detail-item .detail-value {
        font-size: 0.95rem;
        font-weight: 700;
        color: var(--gray-800);
    }

    /* Legenda significati */
    .standings-detail-legend {
        margin-top: 12px;
        padding-top: 10px;
        border-top: 1px dashed var(--gray-300);
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 4px 12px;
    }
    .standings-detail-legend-item {
        display: flex;
        align-items: center;
        gap: 4px;
        font-size: 0.68rem;
        color: var(--gray-600);
    }
    .standings-detail-legend-item .legend-abbr {
        font-weight: 500;
        color: var(--gray-700);
        background: var(--gray-200);
        padding: 1px 5px;
        border-radius: 3px;
        font-size: 0.62rem;
    }
    .standings-detail-legend-item .legend-meaning {
        color: var(--gray-500);
            font-weight: 500;
    }

    /* Colonna expand separata */
    .standings-table.mobile-compact thead .standings-expand-th {
        width: 36px;
        min-width: 36px;
        max-width: 36px;
        padding: 4px 2px !important;
        text-align: center;
    }
    .standings-table.mobile-compact tbody .standings-expand-td {
        width: 36px;
        min-width: 36px;
        max-width: 36px;
        padding: 4px 2px !important;
        text-align: center;
        vertical-align: middle;
    }

    /* Icona expand: pillola blu */
    .standings-expand-icon {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        width: 22px;
        height: 22px;
        font-size: 0.65rem;
        color: #fff;
        background-color: var(--primary);
        border-radius: 50%;
        transition: background-color 0.2s ease;
        line-height: 1;
    }
    tr.expanded .standings-expand-icon {
        background-color: var(--primary-dark);
    }

    /* Partecipante più leggibile su mobile */
    .standings-table.mobile-compact td:nth-child(2) {
        font-weight: 600;
        font-size: 0.95rem;
    }

    /* Posizione più visibile */
    .standings-table.mobile-compact td:nth-child(1) {
        font-size: 1rem;
        font-weight: 800;
        width: 36px;
        min-width: 36px;
        padding-inline: 8px;
    }

    /* Celle più compatte su mobile */
    .standings-table.mobile-compact td {
        padding: 10px 6px;
        font-size: 0.85rem;
    }

    .standings-table.mobile-compact th {
        padding: 10px 6px;
        font-size: 0.7rem;
    }

    /* === Tabs scrollabili orizzontalmente === */
    /* swipe a sinistra/destra per vedere tutti i tab */
    .tabs {
        flex-wrap: nowrap;
        overflow-x: auto;
        overflow-y: hidden;
        -webkit-overflow-scrolling: touch;
        gap: 0;
        margin-bottom: 16px;
        padding-bottom: 4px;
        scrollbar-width: thin;
        scrollbar-color: transparent transparent;
        cursor: grab;
        user-select: none;
        -webkit-user-select: none;
    }

    .tabs:hover,
    .tabs:active,
    .tabs.dragging {
        cursor: grabbing;
        scrollbar-color: var(--gray-300) transparent;
    }

    .tabs::-webkit-scrollbar {
        height: 4px;
    }
    .tabs::-webkit-scrollbar-track {
        background: transparent;
    }
    .tabs::-webkit-scrollbar-thumb {
        background: transparent;
        border-radius: 4px;
        transition: background 0.2s ease;
    }
    .tabs:hover::-webkit-scrollbar-thumb,
    .tabs:active::-webkit-scrollbar-thumb,
    .tabs.dragging::-webkit-scrollbar-thumb {
        background: var(--gray-300);
    }

    .tab {
        padding: 10px 16px;
        font-size: 0.8rem;
        white-space: nowrap;
        flex-shrink: 0;
    }

    .tab i {
        margin-right: 4px;
        font-size: 0.75rem;
    }

    /* === Quick actions: su mobile padding/font ridotti === */
    .quick-groups {
        padding: 10px 14px;
        margin-bottom: 16px;
    }

    .quick-groups-label {
        font-size: 0.8rem;
    }

    .quick-group-btn {
        padding: 6px 14px;
        font-size: 0.8rem;
    }

    .quick-group-btn:active {
        transform: scale(0.96);
    }

    /* === Partecipanti: vista compatta mobile === */
    #participantsTable thead th:nth-child(2),
    #participantsTable tbody td:nth-child(2) {
        display: none;
    }

    /* Per singolare nascondi Partite e Vittorie (colonne 5 e 6) */
    #participantsTable thead th:nth-child(n+5),
    #participantsTable tbody td:nth-child(n+5) {
        display: none;
    }

    #participantsTable tbody tr {
        cursor: pointer;
        transition: background 0.15s ease;
    }

    #participantsTable tbody tr:hover {
        background: var(--primary-light);
    }

    #participantsTable tbody tr.expanded {
        background: #e8f0fe;
    }

    #participantsTable tbody tr.participant-detail-row {
        display: none;
    }

    #participantsTable tbody tr.participant-detail-row[style*="table-row"] {
        display: table-row !important;
    }

    #participantsTable tbody tr.participant-detail-row td {
        padding: 10px 14px 14px;
        background: #f8f9fa;
        border-bottom: 2px solid var(--gray-300);
    }

    .participant-detail-grid {
        display: flex;
        flex-direction: column;
        gap: 8px;
    }

    .participant-detail-block {
        display: flex;
        flex-direction: column;
        gap: 2px;
    }

    .participant-detail-block .detail-label {
        font-size: 0.65rem;
        text-transform: uppercase;
        letter-spacing: 0.3px;
        color: var(--gray-500);
        font-weight: 600;
    }

    .participant-detail-block .detail-value {
        font-size: 0.9rem;
        color: var(--gray-800);
    }

    .participant-detail-block .detail-value a {
        word-break: break-all;
    }

    /* Celle piÃ¹ compatte */
    #participantsTable td,
    #participantsTable th {
        padding: 10px 8px;
        font-size: 0.8rem;
    }

    #participantsTable td:first-child {
        font-weight: 600;
    }

    /* === Modale punti: responsive === */
    .points-modal-overlay {
        padding: 10px;
        align-items: flex-end;
    }

    .points-modal-overlay.active .points-modal-box {
        transform: translateY(0);
        opacity: 1;
    }

    .points-modal-box {
        max-width: 100%;
        max-height: 85vh;
        border-radius: var(--radius) var(--radius) 0 0;
        transform: translateY(100%);
        opacity: 0;
        transition: transform 0.4s cubic-bezier(0.32, 0.72, 0, 1), opacity 0.3s ease;
    }

    /* Drag handle */
    .modal-drag-handle {
        position: absolute;
        top: 0;
        left: 0;
        right: 0;
        height: 28px;
        display: flex;
        align-items: center;
        justify-content: center;
        cursor: grab;
        user-select: none;
        -webkit-user-select: none;
        touch-action: none;
    }

    .modal-drag-handle:active {
        cursor: grabbing;
    }

    .modal-drag-handle span {
        display: block;
        width: 36px;
        height: 4px;
        background: var(--gray-300);
        border-radius: 2px;
        transition: background 0.2s ease, width 0.2s ease;
    }

    .modal-drag-handle:hover span,
    .modal-drag-handle:active span {
        background: var(--gray-400);
        width: 40px;
    }

    .points-modal-header:active {
        cursor: grabbing;
    }

    .points-modal-header h3 {
        font-size: 1rem;
    }

    .points-modal-header h3::before {
        content: '\f0cb';
        font-family: 'FontAwesome';
        font-weight: 900;
        font-size: 0.85rem;
        color: var(--primary);
    }

    .points-modal-close-btn {
        width: 32px;
        height: 32px;
        font-size: 1rem;
        background: var(--gray-100);
    }

    .points-modal-close-btn:active {
        transform: rotate(90deg) scale(0.92);
        background: var(--gray-200);
    }

    .points-modal-subtitle {
        font-size: 0.75rem;
        padding: 2px 10px;
    }

    .points-modal-body {
        padding: 0;
    }

    /* Scrollbar carina nel body del modale */
    .points-modal-body {
        scrollbar-width: thin;
        scrollbar-color: transparent transparent;
        transition: scrollbar-color 0.2s ease;
    }
    .points-modal-body:hover,
    .points-modal-body:active,
    .points-modal-body.dragging-scroll {
        scrollbar-color: var(--gray-300) transparent;
    }
    .points-modal-body::-webkit-scrollbar {
        width: 4px;
    }
    .points-modal-body::-webkit-scrollbar-track {
        background: transparent;
    }
    .points-modal-body::-webkit-scrollbar-thumb {
        background: transparent;
        border-radius: 4px;
        transition: background 0.2s ease;
    }
    .points-modal-body:hover::-webkit-scrollbar-thumb,
    .points-modal-body:active::-webkit-scrollbar-thumb,
    .points-modal-body.dragging-scroll::-webkit-scrollbar-thumb {
        background: var(--gray-300);
    }

    /* Wrapper tabella: niente scroll nÃ© drag */
    .points-modal-table-wrap {
        overflow-x: visible;
        margin: 0;
        padding: 0;
        cursor: default;
        user-select: auto;
        -webkit-user-select: auto;
    }
    .points-modal-table-wrap:hover,
    .points-modal-table-wrap:active,
    .points-modal-table-wrap.dragging {
        cursor: default;
    }

    /* Colonna Risultato: solo icona su mobile */
    .points-modal-body .standings-table td:nth-child(3) {
        font-size: 0;
        line-height: 0;
        width: 28px;
        min-width: 28px;
        text-align: center;
        padding: 5px 2px !important;
    }
    .points-modal-body .standings-table td:nth-child(3).punti-win::before {
        font-size: 1.1rem;
        line-height: 1;
        color: var(--success);
    }
    .points-modal-body .standings-table td:nth-child(3).punti-loss::before {
        font-size: 1.1rem;
        line-height: 1;
        color: var(--danger);
    }

    /* Riduci font th per guadagnare spazio */
    .points-modal-body .standings-table thead th {
        font-size: 0.55rem;
        padding: 4px 3px;
        letter-spacing: 0.2px;
    }

    .points-modal-body .standings-table tbody td{
            padding: 4px 3px;
    }

    .points-modal-body .team-td .team-name-container{
        padding: 0;
    }

    .standings-table th:nth-child(1),
    .points-modal-body .standings-table tbody td:first-child
    {
        width: 30px;
    }


    .punti-loss,
.punti-win {

    position: relative;
    padding-left: 0px!important    ;

    &:before{
        position: static;
        margin-right: 0;
        
    font-size: 1rem;
    }

}

    /* Nascondi colonna azione (edit) nel modale su mobile */
    .points-modal-body .standings-table th.points-action-col,
    .points-modal-body .standings-table td.points-action-col {
        display: none;
    }

    /* Celle più compatte nel modale */
    .points-modal-body .standings-table th,
    .points-modal-body .standings-table td {
        padding: 8px 10px;
        font-size: 0.8rem;
    }



}
