/**
 * RESPONSIVE.CSS - Sistema Gestione Tornei Scacchi
 * v1.1 - 28/01/2026
 *
 * IMPORTANTE: Questo file contiene SOLO modifiche per mobile e tablet.
 * Il desktop (1024px+) rimane INVARIATO - tutti gli stili usano max-width.
 *
 * Breakpoints:
 * - Tablet: max-width 1023px
 * - Mobile: max-width 767px
 * - Mobile Small: max-width 480px
 */

/* ==================================
   CSS VARIABLES
   ================================== */
:root {
    --breakpoint-sm: 576px;
    --breakpoint-md: 768px;
    --breakpoint-lg: 1024px;
    --breakpoint-xl: 1280px;
}

/* ==================================
   1. SMOOTH SCROLL & TRANSIZIONI
   ================================== */
html {
    scroll-behavior: smooth;
}

/* Transizioni globali per elementi interattivi */
a,
button,
.btn,
.card,
.tab,
.quick-action,
.torneo-card,
input,
select,
textarea {
    transition: all 0.2s ease;
}

/* Animazione fade-in per contenuto */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.card,
.tournament-card,
.tornei-list-card,
.alert {
    animation: fadeIn 0.3s ease;
}

/* Animazione per badge e notifiche */
@keyframes pulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.05);
    }
}

.badge-count,
.iscritti-count {
    animation: pulse 2s ease-in-out infinite;
}

/* ==================================
   2. SCROLL-TO-TOP BUTTON
   ================================== */
.scroll-to-top {
    position: fixed;
    bottom: 100px;
    right: 20px;
    width: 48px;
    height: 48px;
    background: linear-gradient(135deg, #3498db, #2980b9);
    color: white;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    box-shadow: 0 4px 15px rgba(52, 152, 219, 0.4);
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px);
    transition: all 0.3s ease;
    z-index: 999;
}

.scroll-to-top.visible {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.scroll-to-top:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(52, 152, 219, 0.5);
}

.scroll-to-top:active {
    transform: translateY(0);
}

@media (max-width: 767px) {
    .scroll-to-top {
        bottom: 90px;
        right: 15px;
        width: 44px;
        height: 44px;
    }
}

/* ==================================
   3. STICKY TABS
   ================================== */
.tabs {
    position: sticky;
    top: 0;
    z-index: 100;
    background: white;
    padding-top: 10px;
    margin-top: -10px;
    box-shadow: 0 2px 10px rgba(0,0,0,0);
    transition: box-shadow 0.3s ease;
}

.tabs.sticky-shadow {
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

/* ==================================
   4. TOAST NOTIFICATIONS
   ================================== */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
}

.toast {
    background: white;
    border-radius: 12px;
    padding: 16px 20px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.15);
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 300px;
    max-width: 400px;
    transform: translateX(120%);
    transition: transform 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    pointer-events: auto;
    border-left: 4px solid #3498db;
}

.toast.show {
    transform: translateX(0);
}

.toast.toast-success {
    border-left-color: #27ae60;
}

.toast.toast-error {
    border-left-color: #e74c3c;
}

.toast.toast-warning {
    border-left-color: #f39c12;
}

.toast-icon {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    flex-shrink: 0;
}

.toast-success .toast-icon {
    background: #d4edda;
    color: #27ae60;
}

.toast-error .toast-icon {
    background: #f8d7da;
    color: #e74c3c;
}

.toast-warning .toast-icon {
    background: #fff3cd;
    color: #f39c12;
}

.toast-info .toast-icon {
    background: #d1ecf1;
    color: #3498db;
}

.toast-content {
    flex: 1;
}

.toast-title {
    font-weight: 600;
    font-size: 0.95rem;
    color: #2d3748;
    margin-bottom: 2px;
}

.toast-message {
    font-size: 0.85rem;
    color: #718096;
}

.toast-close {
    background: none;
    border: none;
    color: #a0aec0;
    cursor: pointer;
    font-size: 18px;
    padding: 4px;
    line-height: 1;
    transition: color 0.2s;
}

.toast-close:hover {
    color: #4a5568;
}

/* Progress bar per auto-dismiss */
.toast-progress {
    position: absolute;
    bottom: 0;
    left: 0;
    height: 3px;
    background: currentColor;
    opacity: 0.3;
    border-radius: 0 0 0 12px;
    animation: toastProgress 4s linear forwards;
}

@keyframes toastProgress {
    from {
        width: 100%;
    }
    to {
        width: 0%;
    }
}

@media (max-width: 767px) {
    .toast-container {
        top: auto;
        bottom: 100px;
        right: 10px;
        left: 10px;
    }

    .toast {
        min-width: auto;
        max-width: none;
    }
}

/* ==================================
   PAIRING TABLE: DESKTOP vs MOBILE STATS
   ================================== */
/* Desktop (default): nascondi info mobile, mostra nome con ELO */
.mobile-info {
    display: none;
}

.player-name {
    display: inline;
}

.desktop-elo {
    display: inline;
}

/* ==================================
   FIX: PULSANTI FORM TORNEO (troppo grandi)
   ================================== */
.tournament-card .form-actions {
    flex-direction: row;
    flex-wrap: wrap;
    gap: 12px;
}

.tournament-card .form-actions .btn {
    padding: 10px 20px;
    font-size: 0.9rem;
    flex: 0 0 auto;
    width: auto;
}

.tournament-card .form-actions .btn svg {
    width: 16px;
    height: 16px;
}

@media (max-width: 767px) {
    .tournament-card .form-actions {
        flex-direction: column;
    }

    .tournament-card .form-actions .btn {
        width: 100%;
        justify-content: center;
    }
}

/* ==================================
   HAMBURGER MENU (nascosto di default)
   ================================== */
.hamburger {
    display: none;
    flex-direction: column;
    gap: 5px;
    cursor: pointer;
    padding: 10px;
    z-index: 1001;
}

.hamburger span {
    width: 25px;
    height: 3px;
    background: white;
    transition: all 0.3s ease;
    border-radius: 2px;
}

.hamburger.active span:nth-child(1) {
    transform: rotate(45deg) translate(6px, 6px);
}

.hamburger.active span:nth-child(2) {
    opacity: 0;
}

.hamburger.active span:nth-child(3) {
    transform: rotate(-45deg) translate(6px, -6px);
}

/* ==================================
   BOTTOM NAVIGATION (nascosta di default)
   ================================== */
.bottom-nav {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: white;
    box-shadow: 0 -2px 10px rgba(0,0,0,0.1);
    z-index: 1000;
    padding: 8px 0;
    padding-bottom: calc(8px + env(safe-area-inset-bottom));
}

.bottom-nav a {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 8px 4px;
    color: #666;
    text-decoration: none;
    font-size: 0.7rem;
    transition: color 0.2s;
}

.bottom-nav a.active,
.bottom-nav a:hover {
    color: #3498db;
}

.bottom-nav a .nav-icon {
    font-size: 1.25rem;
    margin-bottom: 4px;
}

/* ==================================
   TABLET (max 1023px)
   ================================== */
@media (max-width: 1023px) {
    /* Container */
    .container {
        padding: 0 1.5rem;
        margin: 1.5rem auto;
    }

    /* Header */
    .header {
        padding: 0.75rem 1.5rem;
    }

    .header h1 {
        font-size: 1.2rem;
    }

    .header nav a {
        margin-left: 0.75rem;
        padding: 0.5rem 0.8rem;
        font-size: 0.85rem;
    }

    /* Cards */
    .card-body {
        padding: 1.25rem;
    }

    .card-header {
        padding: 0.875rem 1.25rem;
    }

    /* Tabelle: scroll orizzontale */
    .table-responsive {
        width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        margin-bottom: 1rem;
    }

    .table-responsive table {
        min-width: 600px;
    }

    /* Hero section */
    .hero-section {
        padding: 40px 30px;
    }

    .hero-section h1 {
        font-size: 32px;
    }

    /* Stats row */
    .stats-row {
        grid-template-columns: repeat(2, 1fr);
    }

    /* Quick actions */
    .quick-actions {
        grid-template-columns: repeat(3, 1fr);
    }

    /* Torneo header */
    .torneo-header {
        padding: 20px 24px;
    }

    .torneo-header h1 {
        font-size: 1.5rem;
    }

    .torneo-header .info-grid {
        gap: 24px;
    }

    .torneo-header .info-value {
        font-size: 1.25rem;
    }

    /* Form rows */
    .form-row.cols-4 {
        grid-template-columns: repeat(2, 1fr);
    }

    /* Tournament card form */
    .tournament-card > .card-header {
        padding: 20px 24px;
    }

    .tournament-card > .card-body {
        padding: 24px;
    }

    /* Pairing table */
    .pairing-table .col-bianco,
    .pairing-table .col-nero {
        width: 25%;
    }

    /* Welcome bar */
    .welcome-bar {
        padding: 20px;
    }

    .welcome-bar h2 {
        font-size: 20px;
    }

    /* Visibility section */
    .visibility-section {
        padding: 16px 20px;
    }
}

/* ==================================
   MOBILE (max 767px)
   ================================== */
@media (max-width: 767px) {
    /* Container */
    .container {
        padding: 0 1rem;
        margin: 1rem auto;
        padding-bottom: 80px; /* Spazio per bottom nav */
    }

    /* Header */
    .header {
        padding: 0.75rem 1rem;
        flex-wrap: wrap;
    }

    .header h1 {
        font-size: 1.1rem;
        flex: 1;
    }

    /* Mostra hamburger */
    .hamburger {
        display: flex;
    }

    /* Navigazione mobile */
    .header nav {
        display: none;
        position: fixed;
        top: 60px;
        left: 0;
        right: 0;
        bottom: 0;
        background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
        flex-direction: column;
        padding: 20px;
        z-index: 1000;
        overflow-y: auto;
    }

    .header nav.active {
        display: flex;
    }

    .header nav a {
        margin: 0;
        padding: 15px;
        border-bottom: 1px solid rgba(255,255,255,0.1);
        font-size: 1rem;
        text-align: center;
    }

    .header nav a:last-child {
        border-bottom: none;
    }

    /* Bottom navigation visibile */
    .bottom-nav {
        display: flex;
    }

    /* Cards */
    .card {
        border-radius: 8px;
        margin-bottom: 1rem;
    }

    .card-header {
        padding: 0.75rem 1rem;
        flex-direction: column;
        gap: 10px;
        text-align: center;
    }

    .card-body {
        padding: 1rem;
    }

    /* Tabelle */
    .table th,
    .table td {
        padding: 0.5rem;
        font-size: 0.8rem;
    }

    .table-sm th,
    .table-sm td {
        padding: 0.35rem 0.5rem;
        font-size: 0.75rem;
    }

    /* Nascondi colonne meno importanti */
    .table-classifica .col-rating,
    .table-classifica .col-buchholz,
    .table-classifica .col-sonneborn,
    .classifica-table .spareggio:nth-child(n+4) {
        display: none;
    }

    /* Pairing table su mobile - LAYOUT COMPATTO CON INFO INLINE */
    .pairing-table {
        font-size: 0.8rem;
        table-layout: fixed;
    }

    /* Nascondi colonne punti su mobile (mostrati inline) */
    .pairing-table .col-punti,
    .pairing-table th:nth-child(3),
    .pairing-table td:nth-child(3),
    .pairing-table th:nth-child(5),
    .pairing-table td:nth-child(5) {
        display: none !important;
    }

    /* Mobile: mostra info compatta, nascondi ELO desktop */
    .pairing-table .desktop-elo {
        display: none !important;
    }

    .pairing-table .mobile-info {
        display: block !important;
        font-weight: 600;
        color: #3498db;
        font-size: 0.7rem;
        margin-bottom: 1px;
    }

    .pairing-table .mobile-info small {
        font-weight: normal;
        color: #718096;
        font-size: 0.65rem;
    }

    .pairing-table .mobile-info .titolo {
        font-size: 0.65rem;
    }

    .pairing-table .player-name {
        display: block !important;
    }

    /* Nascondi titolo nel nome (già mostrato in mobile-info) */
    .pairing-table .player-name .titolo {
        display: none !important;
    }

    .pairing-table .tavolo {
        width: 24px;
        min-width: 24px;
        text-align: center;
        padding: 4px 2px;
        font-weight: 600;
        font-size: 0.75rem;
    }

    .pairing-table .col-bianco,
    .pairing-table .col-nero {
        width: 38%;
        word-break: break-word;
        line-height: 1.2;
        padding: 4px 3px;
        font-size: 0.75rem;
    }

    .pairing-table .risultato {
        width: 60px;
        min-width: 60px;
        max-width: 60px;
        text-align: center;
        padding: 4px 2px;
    }

    /* Select risultato compatta ma leggibile */
    .pairing-table select,
    .pairing-table .risultato select {
        width: 58px;
        max-width: 58px;
        padding: 8px 2px;
        font-size: 0.8rem;
        font-weight: 600;
        border-radius: 4px;
        border: 1px solid #3498db;
        background: white;
        text-align: center;
    }

    /* Titolo scacchistico piu piccolo */
    .pairing-table .titolo {
        font-size: 0.7rem;
        margin-right: 2px;
    }

    /* Celle piu compatte */
    .pairing-table th,
    .pairing-table td {
        padding: 8px 4px;
        vertical-align: middle;
    }

    /* Forms */
    .form-group input,
    .form-group select,
    .form-group textarea {
        font-size: 16px; /* Previene zoom su iOS */
    }

    .form-inline {
        flex-direction: column;
        gap: 0.75rem;
    }

    .form-inline .form-group {
        width: 100%;
    }

    .form-row,
    .form-row.cols-2,
    .form-row.cols-3,
    .form-row.cols-4 {
        grid-template-columns: 1fr;
    }

    /* Tournament form */
    .tournament-card {
        border-radius: 12px;
    }

    .tournament-card > .card-header {
        padding: 16px 20px;
    }

    .tournament-card > .card-header h2 {
        font-size: 1.25rem;
    }

    .tournament-card > .card-body {
        padding: 20px;
    }

    .tournament-card .form-section {
        margin-bottom: 24px;
        padding-bottom: 20px;
    }

    .section-header {
        margin-bottom: 16px;
    }

    .tournament-card .form-actions {
        flex-direction: column;
        gap: 10px;
        margin-top: 24px;
        padding-top: 20px;
    }

    .tournament-card .btn {
        width: 100%;
        justify-content: center;
    }

    /* Toggle group */
    .toggle-group {
        padding: 14px 16px;
    }

    .toggle-label {
        font-size: 0.9rem;
    }

    /* Buttons */
    .btn {
        min-height: 44px;
        padding: 0.75rem 1.25rem;
    }

    .btn-group {
        display: flex;
        flex-direction: column;
        gap: 8px;
    }

    .btn-group .btn {
        width: 100%;
    }

    /* Tabs */
    .tabs {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        flex-wrap: nowrap;
        gap: 0;
    }

    .tabs::-webkit-scrollbar {
        display: none;
    }

    .tab {
        flex: none;
        min-width: auto;
        padding: 0.6rem 1rem;
        font-size: 0.85rem;
        white-space: nowrap;
    }

    /* Hero section */
    .hero-section {
        padding: 30px 20px;
        border-radius: 12px;
    }

    .hero-section h1 {
        font-size: 26px;
    }

    .hero-section .subtitle {
        font-size: 15px;
    }

    .hero-features {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }

    .hero-feature {
        padding: 12px 14px;
        flex-direction: column;
        text-align: center;
        gap: 8px;
    }

    .hero-buttons {
        flex-direction: column;
        gap: 10px;
    }

    .hero-buttons .btn {
        width: 100%;
        text-align: center;
    }

    /* Welcome bar */
    .welcome-bar {
        padding: 20px;
        flex-direction: column;
        text-align: center;
    }

    .welcome-bar h2 {
        font-size: 18px;
    }

    .welcome-bar .btn-new-torneo {
        width: 100%;
        justify-content: center;
    }

    /* Stats row */
    .stats-row {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }

    .stat-card {
        padding: 15px;
    }

    .stat-card .stat-value {
        font-size: 24px;
    }

    .stat-card .stat-label {
        font-size: 11px;
    }

    /* Quick actions */
    .quick-actions {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }

    .quick-action {
        padding: 15px 10px;
    }

    .quick-action-icon {
        font-size: 24px;
        margin-bottom: 8px;
    }

    .quick-action span {
        font-size: 12px;
    }

    /* Torneo cards */
    .torneo-card {
        flex-direction: column;
        align-items: flex-start;
        gap: 15px;
        padding: 15px;
    }

    .torneo-card .btn-gestisci {
        width: 100%;
        text-align: center;
    }

    .torneo-card-meta {
        flex-wrap: wrap;
        gap: 10px;
    }

    /* Torneo header */
    .torneo-header {
        padding: 20px;
        border-radius: 12px;
    }

    .torneo-header h1 {
        font-size: 1.3rem;
    }

    .torneo-header .info-grid {
        gap: 16px;
        flex-wrap: wrap;
        justify-content: center;
    }

    .torneo-header .info-item {
        min-width: 70px;
    }

    .torneo-header .info-value {
        font-size: 1.1rem;
    }

    .torneo-header .info-label {
        font-size: 0.65rem;
    }

    .torneo-header .actions {
        flex-direction: column;
        width: 100%;
    }

    .torneo-header .btn {
        width: 100%;
        text-align: center;
        justify-content: center;
    }

    /* Visibility section */
    .visibility-section {
        padding: 15px;
    }

    .visibility-section .section-header-vis {
        flex-direction: column;
        gap: 12px;
    }

    /* Public header */
    .public-header {
        padding: 15px;
        border-radius: 8px;
    }

    .public-header h1 {
        font-size: 1.2rem;
    }

    .public-header .info {
        font-size: 0.85rem;
        display: flex;
        flex-direction: column;
        gap: 8px;
        align-items: flex-start;
    }

    .btn-iscrizione {
        width: 100%;
        text-align: center;
        display: block;
    }

    /* Badge */
    .badge {
        font-size: 0.7rem;
        padding: 0.15rem 0.4rem;
    }

    /* Tornei list card */
    .tornei-list-card > .card-header {
        flex-direction: column;
        gap: 12px;
        text-align: center;
        padding: 16px 20px;
    }

    .tornei-list-card > .card-header h2 {
        font-size: 1.1rem;
    }

    .tornei-list-card .btn-add {
        width: 100%;
        justify-content: center;
    }

    /* Table modern su mobile */
    .table-modern th,
    .table-modern td {
        padding: 12px 10px;
        font-size: 0.85rem;
    }

    /* Nascondi colonne */
    .table-modern th:nth-child(3),
    .table-modern td:nth-child(3),
    .table-modern th:nth-child(4),
    .table-modern td:nth-child(4) {
        display: none;
    }

    .azioni-cell {
        flex-direction: column;
        gap: 4px;
    }

    /* Public tornei section */
    .public-tornei-section {
        padding: 20px;
    }

    .public-torneo-row {
        flex-direction: column;
        gap: 12px;
        align-items: flex-start;
        padding: 15px 0;
    }

    .public-torneo-row > div:last-child {
        width: 100%;
        justify-content: space-between;
    }

    /* Alerts */
    .alert {
        padding: 0.75rem;
        font-size: 0.9rem;
    }

    /* Impersonation bar */
    div[style*="impersonificando"] {
        flex-direction: column;
        gap: 10px;
        text-align: center;
    }

    /* Admin mode bar */
    div[style*="Admin:"] {
        flex-direction: column;
        gap: 10px;
        text-align: center;
    }

    /* Row e colonne */
    .row {
        margin: 0;
    }

    .col, .col-2, .col-3, .col-4, .col-6, .col-8 {
        flex: 0 0 100%;
        padding: 0;
        margin-bottom: 1rem;
    }

    /* Progress bar */
    .progress {
        height: 16px;
    }

    .progress-bar {
        font-size: 0.7rem;
    }

    /* Login form */
    .row.justify-content-center .col-6 {
        flex: 0 0 100%;
        max-width: 100%;
    }

    /* Modal / Dialog (slide-up) */
    .modal-overlay,
    [class*="modal"] {
        padding: 0;
    }

    .modal,
    [class*="modal-content"] {
        max-width: 100%;
        max-height: 90vh;
        border-radius: 20px 20px 0 0;
        margin: auto 0 0 0;
    }

    /* Bye dropdown */
    .bye-dropdown-content {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        top: auto;
        border-radius: 20px 20px 0 0;
        padding: 10px 0;
        box-shadow: 0 -4px 20px rgba(0,0,0,0.2);
    }

    .bye-dropdown-content button {
        padding: 15px 20px;
        font-size: 1rem;
    }

    /* Risultato buttons */
    .risultato-btn {
        min-width: 44px;
        min-height: 44px;
        padding: 10px;
        font-size: 0.9rem;
    }
}

/* ==================================
   MOBILE SMALL (max 480px)
   ================================== */
@media (max-width: 480px) {
    .container {
        padding: 0 0.75rem;
    }

    .header h1 {
        font-size: 1rem;
    }

    /* Hero ancora più compatto */
    .hero-section h1 {
        font-size: 22px;
    }

    .hero-features {
        grid-template-columns: 1fr;
    }

    /* Stats in 2 colonne più strette */
    .stats-row {
        gap: 8px;
    }

    .stat-card {
        padding: 12px;
    }

    .stat-card .stat-value {
        font-size: 20px;
    }

    /* Quick actions */
    .quick-actions {
        grid-template-columns: repeat(2, 1fr);
    }

    /* Torneo header */
    .torneo-header .info-grid {
        gap: 12px;
    }

    .torneo-header .info-item {
        min-width: 60px;
    }

    /* Tabelle ancora più compatte */
    .table th,
    .table td {
        padding: 0.4rem;
        font-size: 0.75rem;
    }

    .pairing-table {
        font-size: 0.75rem;
    }

    /* Cards */
    .card-header,
    .card-body {
        padding: 0.75rem;
    }

    /* Come funziona - grid a 1 colonna */
    div[style*="grid-template-columns: repeat(auto-fit, minmax(220px"] {
        grid-template-columns: 1fr !important;
    }
}

/* ==================================
   UTILITY CLASSES
   ================================== */

/* Nascosto su mobile, visibile su tablet+ */
@media (max-width: 767px) {
    .hide-mobile {
        display: none !important;
    }
}

/* Nascosto su tablet, visibile su mobile e desktop */
@media (max-width: 1023px) and (min-width: 768px) {
    .hide-tablet {
        display: none !important;
    }
}

/* Visibile SOLO su mobile */
.show-mobile {
    display: none !important;
}

@media (max-width: 767px) {
    .show-mobile {
        display: block !important;
    }

    .show-mobile-flex {
        display: flex !important;
    }

    .show-mobile-inline {
        display: inline !important;
    }
}

/* Visibile SOLO su tablet */
.show-tablet {
    display: none !important;
}

@media (max-width: 1023px) and (min-width: 768px) {
    .show-tablet {
        display: block !important;
    }
}

/* Text utilities per mobile */
@media (max-width: 767px) {
    .text-center-mobile {
        text-align: center !important;
    }

    .full-width-mobile {
        width: 100% !important;
    }

    .stack-mobile {
        flex-direction: column !important;
    }

    .p-compact-mobile {
        padding: 10px !important;
    }

    .gap-sm-mobile {
        gap: 8px !important;
    }
}

/* ==================================
   TOUCH & ACCESSIBILITY
   ================================== */

/* Touch-friendly: minimo 44x44px per elementi interattivi (Apple HIG) */
@media (max-width: 767px) {
    a.touch-target,
    button.touch-target,
    .clickable,
    input[type="checkbox"],
    input[type="radio"] {
        min-height: 44px;
        min-width: 44px;
    }

    /* Link in liste */
    .list-item a,
    .nav-list a {
        display: block;
        padding: 12px 15px;
    }
}

/* Disabilitare effetti hover su touch devices */
@media (hover: none) {
    .btn:hover,
    .card:hover,
    .torneo-card:hover,
    .quick-action:hover {
        transform: none;
        box-shadow: inherit;
    }
}

/* Safe area per iPhone X+ */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
    @media (max-width: 767px) {
        .container {
            padding-bottom: calc(80px + env(safe-area-inset-bottom));
        }
    }
}

/* ==================================
   PRINT STYLES
   ================================== */
@media print {
    .header,
    .hamburger,
    .bottom-nav,
    .btn,
    .form-actions,
    nav {
        display: none !important;
    }

    .container {
        padding: 0;
        margin: 0;
        max-width: 100%;
    }

    .card {
        box-shadow: none;
        border: 1px solid #ddd;
        break-inside: avoid;
    }

    .table {
        font-size: 10pt;
    }
}

/* ==================================
   SCROLL INDICATOR PER TABELLE
   ================================== */
@media (max-width: 767px) {
    .table-responsive {
        position: relative;
    }

    .table-responsive::after {
        content: 'Scorri per vedere tutto';
        display: block;
        text-align: center;
        font-size: 0.7rem;
        color: #888;
        padding: 8px;
        background: linear-gradient(to right, transparent, #f8f9fa 20%, #f8f9fa 80%, transparent);
    }

    /* Nascondi indicatore se tabella non overflow */
    .table-responsive:not(.has-scroll)::after {
        display: none;
    }
}

/* ==================================
   LANDSCAPE MODE
   ================================== */
@media (max-width: 767px) and (orientation: landscape) {
    .hero-section {
        padding: 20px;
    }

    .hero-section h1 {
        font-size: 24px;
    }

    .hero-features {
        grid-template-columns: repeat(4, 1fr);
    }

    .stats-row {
        grid-template-columns: repeat(4, 1fr);
    }

    .container {
        padding-bottom: 60px;
    }

    .bottom-nav {
        padding: 4px 0;
    }

    .bottom-nav a {
        padding: 4px;
        font-size: 0.65rem;
    }

    .bottom-nav a .nav-icon {
        font-size: 1rem;
    }
}
