/* ===================================
   GESTIONALE CVPC - MOBILE RESPONSIVE
   Ottimizzato per consultazione smartphone
   =================================== */

/* === MOBILE FIRST: Base per tutti i dispositivi === */

/* Viewport e touch optimization */
@media (max-width: 768px) {
    /* Disabilita highlight touch su iOS */
    * {
        -webkit-tap-highlight-color: transparent;
    }
    
    /* Scroll smooth */
    html {
        scroll-behavior: smooth;
    }
    
    body {
        font-size: 15px;
        -webkit-text-size-adjust: 100%;
    }
}

/* === HEADER MOBILE === */
@media (max-width: 768px) {
    .header {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        z-index: 1000;
        padding: 10px 15px;
        background: linear-gradient(135deg, #1e3a8a 0%, #3b82f6 100%);
        box-shadow: 0 2px 10px rgba(0,0,0,0.2);
    }
    
    .header h1 {
        font-size: 15px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        max-width: 200px;
    }
    
    .header h1 i {
        font-size: 18px;
    }
    
    .header-right {
        gap: 10px;
    }
    
    .header-right span {
        display: none;
    }
    
    .header-right .btn {
        padding: 8px 12px;
        font-size: 14px;
    }
    
    .menu-toggle {
        display: flex !important;
        align-items: center;
        justify-content: center;
        width: 40px;
        height: 40px;
        background: rgba(255,255,255,0.1);
        border-radius: 8px;
        font-size: 20px;
    }
}

/* === SIDEBAR MOBILE (Bottom Sheet Style) === */
@media (max-width: 768px) {
    .sidebar {
        position: fixed !important;
        bottom: 0 !important;
        left: 0 !important;
        right: 0 !important;
        top: auto !important;
        height: auto !important;
        width: 100% !important;
        max-height: 70vh;
        transform: translateY(100%) !important;
        transition: transform 0.3s ease !important;
        border-radius: 20px 20px 0 0;
        box-shadow: 0 -4px 20px rgba(0,0,0,0.2);
        z-index: 1001;
        overflow-y: auto;
        padding-bottom: env(safe-area-inset-bottom, 20px);
    }
    
    .sidebar.active,
    .sidebar.show {
        transform: translateY(0) !important;
    }
    
    .sidebar-menu {
        padding: 20px 15px;
    }
    
    /* Handle per drag */
    .sidebar::before {
        content: '';
        display: block;
        width: 40px;
        height: 5px;
        background: #d1d5db;
        border-radius: 3px;
        margin: 10px auto 15px;
    }
    
    .menu-item {
        padding: 14px 16px;
        margin-bottom: 4px;
        border-radius: 12px;
        font-size: 15px;
        display: flex;
        align-items: center;
        gap: 12px;
    }
    
    .menu-item i {
        width: 24px;
        text-align: center;
        font-size: 18px;
    }
    
    .menu-section-title {
        font-size: 11px;
        padding: 15px 16px 8px;
        text-transform: uppercase;
        letter-spacing: 1px;
        color: #6b7280;
    }
    
    .menu-separator {
        margin: 10px 0;
        border-color: #e5e7eb;
    }
    
    /* Overlay scuro */
    .sidebar-overlay {
        display: block !important;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0,0,0,0.5);
        z-index: 1000;
        opacity: 0;
        visibility: hidden;
        transition: all 0.3s;
        pointer-events: none;
    }
    
    .sidebar-overlay.active,
    .sidebar-overlay.show {
        opacity: 1;
        visibility: visible;
        pointer-events: auto;
    }
}

/* === CONTENUTO PRINCIPALE MOBILE === */
@media (max-width: 768px) {
    .main-content {
        margin-left: 0 !important;
        margin-top: 60px;
        padding: 15px;
        padding-bottom: 80px;
        width: 100% !important;
        max-width: 100% !important;
        box-sizing: border-box;
    }
    
    .tab-content {
        width: 100% !important;
        max-width: 100% !important;
        padding: 0 !important;
        margin: 0 !important;
        box-sizing: border-box;
    }
    
    .page-header {
        display: flex;
        flex-direction: column;
        align-items: stretch !important;
        gap: 12px;
        margin-bottom: 15px;
        width: 100%;
    }
    
    .page-header h2 {
        font-size: 18px;
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 10px;
        text-align: center;
    }
    
    .page-header h2 i {
        font-size: 20px;
    }
    
    .header-actions {
        display: grid !important;
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 8px !important;
        width: 100% !important;
    }
    
    .header-actions .btn {
        width: 100% !important;
        justify-content: center;
        font-size: 12px;
        padding: 10px 8px;
    }
}

/* === STAT CARDS MOBILE - Design Card Leggibili === */
@media (max-width: 768px) {
    .stats-grid {
        display: grid !important;
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 10px !important;
        margin-bottom: 20px;
        width: 100% !important;
    }
    
    .stat-card {
        background: white;
        border-radius: 16px;
        padding: 15px !important;
        display: flex;
        flex-direction: column;
        align-items: center;
        text-align: center;
        box-shadow: 0 2px 8px rgba(0,0,0,0.08);
        border-left: none;
        border-top: 4px solid var(--primary);
        width: 100% !important;
        margin: 0 !important;
        box-sizing: border-box;
    }
    
    .stat-card:nth-child(1) { border-top-color: #3b82f6; }
    .stat-card:nth-child(2) { border-top-color: #10b981; }
    .stat-card:nth-child(3) { border-top-color: #f59e0b; }
    .stat-card:nth-child(4) { border-top-color: #8b5cf6; }
    
    .stat-icon {
        width: 40px !important;
        height: 40px !important;
        border-radius: 12px;
        font-size: 16px !important;
        margin-bottom: 10px;
    }
    
    .stat-value {
        font-size: 20px !important;
        font-weight: 700;
        color: #1f2937;
        line-height: 1.2;
    }
    
    .stat-label {
        font-size: 11px !important;
        color: #6b7280;
        margin-top: 4px;
    }
}

/* Stat cards su smartphone molto piccoli - 1 colonna */
@media (max-width: 380px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }
    
    .stat-card {
        flex-direction: row;
        text-align: left;
        padding: 12px 15px;
        gap: 15px;
    }
    
    .stat-icon {
        margin-bottom: 0;
        flex-shrink: 0;
    }
    
    .stat-info {
        flex: 1;
    }
    
    .stat-value {
        font-size: 22px;
    }
}

/* === CARDS MOBILE === */
@media (max-width: 768px) {
    .card {
        border-radius: 16px;
        margin-bottom: 15px;
        box-shadow: 0 2px 8px rgba(0,0,0,0.08);
        overflow: hidden;
    }
    
    .card-header {
        padding: 15px;
        font-size: 15px;
    }
    
    .card-header h3 {
        font-size: 16px;
        display: flex;
        align-items: center;
        gap: 10px;
    }
    
    .card-body {
        padding: 15px;
    }
}

/* === TABELLE MOBILE - Versione Card/Lista === */
@media (max-width: 768px) {
    /* Container scroll orizzontale */
    .table-container {
        margin: 0 -15px;
        padding: 0;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    /* Indicatore scroll */
    .table-container::after {
        content: '→ scorri';
        position: absolute;
        right: 10px;
        top: 50%;
        transform: translateY(-50%);
        font-size: 11px;
        color: #9ca3af;
        pointer-events: none;
        opacity: 0.7;
    }
    
    .data-table {
        font-size: 13px;
        min-width: 100%;
    }
    
    .data-table th {
        padding: 12px 10px;
        font-size: 11px;
        text-transform: uppercase;
        letter-spacing: 0.5px;
        white-space: nowrap;
        position: sticky;
        top: 0;
        background: #f9fafb;
        z-index: 10;
    }
    
    .data-table td {
        padding: 12px 10px;
        vertical-align: middle;
    }
    
    /* Prima colonna sticky */
    .data-table th:first-child,
    .data-table td:first-child {
        position: sticky;
        left: 0;
        background: white;
        z-index: 5;
        box-shadow: 2px 0 5px rgba(0,0,0,0.05);
    }
    
    .data-table th:first-child {
        background: #f9fafb;
        z-index: 15;
    }
    
    /* Azioni compatte */
    .data-table .btn-sm {
        padding: 6px 8px;
        font-size: 12px;
    }
    
    .data-table .btn-sm i {
        margin: 0;
    }
    
    .data-table .btn-sm span {
        display: none;
    }
}

/* === TABELLE MOBILE CARD VIEW (per liste principali) === */
@media (max-width: 600px) {
    /* Trasforma tabella in card list */
    .mobile-card-view thead {
        display: none;
    }
    
    .mobile-card-view tbody {
        display: flex;
        flex-direction: column;
        gap: 10px;
        padding: 10px;
    }
    
    .mobile-card-view tr {
        display: block;
        background: white;
        border-radius: 12px;
        padding: 15px;
        box-shadow: 0 2px 6px rgba(0,0,0,0.08);
        border-left: 4px solid #3b82f6;
    }
    
    .mobile-card-view td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 6px 0;
        border: none;
    }
    
    .mobile-card-view td::before {
        content: attr(data-label);
        font-weight: 600;
        color: #6b7280;
        font-size: 12px;
        text-transform: uppercase;
    }
    
    .mobile-card-view td:first-child {
        font-size: 16px;
        font-weight: 600;
        color: #1f2937;
        border-bottom: 1px solid #f3f4f6;
        padding-bottom: 10px;
        margin-bottom: 5px;
    }
    
    .mobile-card-view td:first-child::before {
        display: none;
    }
    
    .mobile-card-view td:last-child {
        justify-content: flex-end;
        gap: 8px;
        padding-top: 10px;
        border-top: 1px solid #f3f4f6;
        margin-top: 5px;
    }
    
    .mobile-card-view td:last-child::before {
        display: none;
    }
}

/* === FORM MOBILE === */
@media (max-width: 768px) {
    .form-row {
        display: flex;
        flex-direction: column;
        gap: 15px;
    }
    
    .form-group {
        margin-bottom: 15px;
    }
    
    .form-group label {
        font-size: 13px;
        font-weight: 600;
        color: #374151;
        margin-bottom: 6px;
        display: block;
    }
    
    .form-control {
        width: 100%;
        padding: 14px 16px;
        font-size: 16px; /* Previene zoom su iOS */
        border: 2px solid #e5e7eb;
        border-radius: 12px;
        background: white;
        transition: all 0.2s;
    }
    
    .form-control:focus {
        border-color: #3b82f6;
        box-shadow: 0 0 0 4px rgba(59,130,246,0.1);
    }
    
    select.form-control {
        appearance: none;
        background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%236b7280' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10l-5 5z'/%3E%3C/svg%3E");
        background-repeat: no-repeat;
        background-position: right 15px center;
        padding-right: 40px;
    }
    
    textarea.form-control {
        min-height: 100px;
        resize: vertical;
    }
    
    /* Checkbox e radio */
    .form-check {
        display: flex;
        align-items: center;
        gap: 10px;
        padding: 12px 0;
    }
    
    .form-check input[type="checkbox"],
    .form-check input[type="radio"] {
        width: 22px;
        height: 22px;
        flex-shrink: 0;
    }
}

/* === BOTTONI MOBILE === */
@media (max-width: 768px) {
    .btn {
        padding: 12px 20px;
        font-size: 14px;
        border-radius: 12px;
        font-weight: 600;
        min-height: 48px; /* Touch target size */
        display: inline-flex;
        align-items: center;
        justify-content: center;
        gap: 8px;
    }
    
    .btn-sm {
        padding: 10px 14px;
        font-size: 13px;
        min-height: 40px;
        border-radius: 10px;
    }
    
    .btn i {
        font-size: 16px;
    }
    
    /* Bottoni full width in certi contesti */
    .btn-block-mobile {
        width: 100%;
    }
}

/* === MODAL MOBILE === */
@media (max-width: 768px) {
    .modal-content {
        width: 100%;
        max-width: 100%;
        height: 100%;
        max-height: 100%;
        margin: 0;
        border-radius: 0;
        display: flex;
        flex-direction: column;
    }
    
    .modal-header {
        padding: 15px 20px;
        border-radius: 0;
        flex-shrink: 0;
        position: sticky;
        top: 0;
        z-index: 10;
    }
    
    .modal-header h3 {
        font-size: 18px;
    }
    
    .modal-close {
        width: 40px;
        height: 40px;
        font-size: 24px;
    }
    
    .modal-body {
        flex: 1;
        overflow-y: auto;
        padding: 20px;
        -webkit-overflow-scrolling: touch;
    }
    
    .modal-footer {
        flex-shrink: 0;
        padding: 15px 20px;
        padding-bottom: calc(15px + env(safe-area-inset-bottom, 0px));
        gap: 10px;
        flex-wrap: wrap;
        border-top: 1px solid #e5e7eb;
    }
    
    .modal-footer .btn {
        flex: 1;
        min-width: 120px;
    }
}

/* === TAB MOBILE === */
@media (max-width: 768px) {
    .tabs {
        display: flex;
        gap: 5px;
        overflow-x: auto;
        padding: 5px;
        margin: -5px -15px 15px;
        padding: 5px 15px;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }
    
    .tabs::-webkit-scrollbar {
        display: none;
    }
    
    .tab {
        flex-shrink: 0;
        padding: 10px 16px;
        font-size: 13px;
        border-radius: 20px;
        white-space: nowrap;
        background: #f3f4f6;
        border: none;
    }
    
    .tab.active {
        background: #3b82f6;
        color: white;
    }
}

/* === ALERT MOBILE === */
@media (max-width: 768px) {
    .alert {
        padding: 12px 15px;
        border-radius: 12px;
        font-size: 14px;
        margin-bottom: 15px;
    }
    
    .alert i {
        font-size: 18px;
    }
}

/* === BADGE MOBILE === */
@media (max-width: 768px) {
    .badge {
        padding: 5px 10px;
        font-size: 11px;
        border-radius: 6px;
    }
}

/* === TOAST MOBILE === */
@media (max-width: 768px) {
    .toast-container {
        bottom: 80px;
        left: 15px;
        right: 15px;
        top: auto;
    }
    
    .toast {
        width: 100%;
        max-width: 100%;
        border-radius: 12px;
        padding: 15px 20px;
        font-size: 14px;
    }
}

/* === QUICK ACTIONS MOBILE (FAB) === */
@media (max-width: 768px) {
    .quick-action-fab {
        position: fixed;
        bottom: 20px;
        right: 20px;
        width: 56px;
        height: 56px;
        border-radius: 50%;
        background: #3b82f6;
        color: white;
        border: none;
        box-shadow: 0 4px 15px rgba(59,130,246,0.4);
        font-size: 24px;
        display: flex;
        align-items: center;
        justify-content: center;
        z-index: 100;
        transition: transform 0.2s;
    }
    
    .quick-action-fab:active {
        transform: scale(0.95);
    }
}

/* === SEARCH BAR MOBILE === */
@media (max-width: 768px) {
    .search-container {
        margin-bottom: 15px;
    }
    
    .search-input {
        width: 100%;
        padding: 14px 20px 14px 45px;
        font-size: 16px;
        border: 2px solid #e5e7eb;
        border-radius: 25px;
        background: white;
    }
    
    .search-icon {
        position: absolute;
        left: 18px;
        top: 50%;
        transform: translateY(-50%);
        color: #9ca3af;
    }
}

/* === FILTRI MOBILE === */
@media (max-width: 768px) {
    .filters-row {
        display: flex;
        gap: 8px;
        overflow-x: auto;
        padding: 5px 0;
        margin-bottom: 15px;
        -webkit-overflow-scrolling: touch;
    }
    
    .filter-btn {
        flex-shrink: 0;
        padding: 8px 16px;
        border-radius: 20px;
        font-size: 13px;
        background: #f3f4f6;
        border: 1px solid #e5e7eb;
        white-space: nowrap;
    }
    
    .filter-btn.active {
        background: #3b82f6;
        color: white;
        border-color: #3b82f6;
    }
}

/* === LOADING MOBILE === */
@media (max-width: 768px) {
    .loading-overlay {
        backdrop-filter: blur(4px);
    }
    
    .loading-spinner {
        width: 50px;
        height: 50px;
    }
    
    .loading-text {
        font-size: 14px;
        margin-top: 15px;
    }
}

/* === EMPTY STATE MOBILE === */
@media (max-width: 768px) {
    .empty-state {
        padding: 40px 20px;
        text-align: center;
    }
    
    .empty-state i {
        font-size: 48px;
        color: #d1d5db;
        margin-bottom: 15px;
    }
    
    .empty-state h4 {
        font-size: 16px;
        color: #6b7280;
        margin-bottom: 8px;
    }
    
    .empty-state p {
        font-size: 14px;
        color: #9ca3af;
    }
}

/* === DASHBOARD SPECIFIC MOBILE === */
@media (max-width: 768px) {
    /* Alert dashboard */
    #dashboardAlerts .alert {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }
    
    #dashboardAlerts .alert .btn {
        width: 100%;
    }
    
    /* Grafici */
    .chart-container {
        height: 250px;
        margin-bottom: 20px;
    }
    
    /* Attività recenti come lista */
    .activity-item {
        padding: 12px 0;
        border-bottom: 1px solid #f3f4f6;
    }
    
    .activity-item:last-child {
        border-bottom: none;
    }
}

/* === VOLONTARI/SOCI LIST MOBILE === */
@media (max-width: 768px) {
    .person-card {
        display: flex;
        align-items: center;
        gap: 15px;
        padding: 15px;
        background: white;
        border-radius: 12px;
        margin-bottom: 10px;
        box-shadow: 0 2px 6px rgba(0,0,0,0.05);
    }
    
    .person-avatar {
        width: 50px;
        height: 50px;
        border-radius: 50%;
        background: #e0e7ff;
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 20px;
        color: #3b82f6;
        flex-shrink: 0;
    }
    
    .person-info {
        flex: 1;
        min-width: 0;
    }
    
    .person-name {
        font-weight: 600;
        font-size: 15px;
        color: #1f2937;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    
    .person-detail {
        font-size: 13px;
        color: #6b7280;
        margin-top: 2px;
    }
    
    .person-actions {
        display: flex;
        gap: 8px;
    }
}

/* === UTILITY CLASSES MOBILE === */
@media (max-width: 768px) {
    .hide-mobile {
        display: none !important;
    }
    
    .show-mobile {
        display: block !important;
    }
    
    .text-center-mobile {
        text-align: center;
    }
    
    .mt-mobile-0 {
        margin-top: 0 !important;
    }
    
    .p-mobile-0 {
        padding: 0 !important;
    }
    
    .full-width-mobile {
        width: 100% !important;
    }
}

/* === LANDSCAPE MODE PHONE === */
@media (max-width: 896px) and (orientation: landscape) {
    .modal-content {
        height: 100vh;
        max-height: 100vh;
    }
    
    .sidebar {
        max-height: 60vh;
    }
    
    .stats-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

/* === SAFE AREA (iPhone X+) === */
@supports (padding: env(safe-area-inset-bottom)) {
    @media (max-width: 768px) {
        .main-content {
            padding-bottom: calc(80px + env(safe-area-inset-bottom));
        }
        
        .sidebar {
            padding-bottom: env(safe-area-inset-bottom);
        }
        
        .modal-footer {
            padding-bottom: calc(15px + env(safe-area-inset-bottom));
        }
        
        .quick-action-fab {
            bottom: calc(20px + env(safe-area-inset-bottom));
        }
    }
}

/* === PRINT HIDE === */
@media print {
    .sidebar,
    .header,
    .quick-action-fab,
    .modal {
        display: none !important;
    }
    
    .main-content {
        margin: 0 !important;
        padding: 0 !important;
    }
}

/* === SEZIONE AMMINISTRAZIONE MOBILE === */
@media (max-width: 768px) {
    /* Page header fiscale */
    #fiscale .page-header,
    #rendiconti .page-header,
    #ricevuteDonazioni .page-header {
        display: flex;
        flex-direction: column;
        align-items: stretch;
        gap: 15px;
    }
    
    #fiscale .page-header h2,
    #rendiconti .page-header h2,
    #ricevuteDonazioni .page-header h2 {
        text-align: center;
        font-size: 18px;
    }
    
    /* Header azioni - griglia flessibile */
    #fiscale .header-actions,
    #rendiconti .header-actions,
    #ricevuteDonazioni .header-actions {
        display: grid !important;
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 8px !important;
        width: 100% !important;
    }
    
    #fiscale .header-actions .btn,
    #rendiconti .header-actions .btn,
    #ricevuteDonazioni .header-actions .btn {
        font-size: 11px !important;
        padding: 10px 6px !important;
        white-space: nowrap;
        min-width: 0;
        width: 100%;
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 4px;
    }
    
    #fiscale .header-actions .btn i,
    #rendiconti .header-actions .btn i,
    #ricevuteDonazioni .header-actions .btn i {
        margin-right: 2px;
        font-size: 12px;
    }
    
    /* Nascondo testo pulsanti su mobile piccolo */
    #fiscale .header-actions .btn span,
    #rendiconti .header-actions .btn span,
    #ricevuteDonazioni .header-actions .btn span {
        display: none;
    }
    
    /* Select anno a larghezza piena */
    #fiscale .header-actions select,
    #selectAnnoFiscale {
        width: 100% !important;
        grid-column: span 2 !important;
        margin-bottom: 5px;
        font-size: 14px;
        padding: 10px;
    }
    
    /* Stats fiscali - 2 colonne centrate */
    #fiscale .stats-grid,
    #rendiconti .stats-grid,
    #ricevuteDonazioni .stats-grid {
        display: grid !important;
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 10px !important;
        width: 100% !important;
        margin: 0 0 20px 0 !important;
    }
    
    #fiscale .stat-card,
    #rendiconti .stat-card,
    #ricevuteDonazioni .stat-card {
        padding: 12px !important;
        margin: 0 !important;
        width: 100% !important;
    }
    
    #fiscale .stat-value,
    #rendiconti .stat-value,
    #ricevuteDonazioni .stat-value {
        font-size: 16px !important;
    }
    
    #fiscale .stat-label,
    #rendiconti .stat-label,
    #ricevuteDonazioni .stat-label {
        font-size: 10px !important;
    }
    
    #fiscale .stat-icon,
    #rendiconti .stat-icon,
    #ricevuteDonazioni .stat-icon {
        width: 36px !important;
        height: 36px !important;
        font-size: 14px !important;
    }
    
    /* Filtri prima nota - colonna */
    #fiscale .card .form-row {
        flex-direction: column !important;
        gap: 10px;
    }
    
    #fiscale .card .form-row .form-group {
        width: 100% !important;
        margin-bottom: 0 !important;
    }
    
    /* Grafici fiscali in colonna */
    .grafici-fiscali-container {
        display: flex !important;
        flex-direction: column !important;
        gap: 15px !important;
        margin-bottom: 20px;
    }
    
    .grafici-fiscali-container .card {
        width: 100% !important;
    }
    
    .chart-container {
        height: 200px !important;
        min-height: 200px;
    }
    
    /* Card a larghezza piena */
    #fiscale .card,
    #rendiconti .card,
    #ricevuteDonazioni .card {
        width: 100% !important;
        margin-left: 0 !important;
        margin-right: 0 !important;
    }
    
    /* Tabella prima nota scroll */
    #fiscale .table-responsive,
    #fiscale .card-body {
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch;
    }
    
    #fiscale .data-table th,
    #fiscale .data-table td {
        padding: 8px 6px !important;
        font-size: 11px !important;
        white-space: nowrap;
    }
}

/* Stili grafici desktop */
.grafici-fiscali-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 20px;
    margin-bottom: 20px;
}

.chart-container {
    height: 300px;
}

/* === RENDICONTI MOBILE === */
@media (max-width: 768px) {
    #rendiconti .page-header {
        flex-direction: column;
        align-items: stretch;
    }
    
    #rendiconti .header-actions {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
    }
    
    /* Alert RUNTS più compatto */
    #rendiconti .alert {
        font-size: 12px;
        padding: 10px;
    }
    
    #rendiconti .alert i {
        font-size: 16px;
    }
    
    /* Card tipi rendiconto */
    #rendiconti .card {
        margin-bottom: 12px;
    }
    
    #rendiconti .card-header {
        padding: 12px;
    }
    
    #rendiconti .card-body {
        padding: 12px;
    }
    
    /* Tabs rendiconto scorrevoli */
    #rendiconti .tabs-nav {
        display: flex;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        gap: 5px;
        padding-bottom: 5px;
        margin-bottom: 15px;
    }
    
    #rendiconti .tabs-nav .tab-btn {
        flex-shrink: 0;
        padding: 8px 12px;
        font-size: 12px;
        white-space: nowrap;
    }
}

/* === RICEVUTE DONAZIONI MOBILE === */
@media (max-width: 768px) {
    #ricevuteDonazioni .header-actions {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
    }
    
    #ricevuteDonazioni .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
    }
}

/* === LIBRI SOCIALI MOBILE === */
@media (max-width: 768px) {
    #librisociali .tabs-nav {
        display: flex;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        gap: 5px;
        padding-bottom: 10px;
    }
    
    #librisociali .tabs-nav .tab-btn {
        flex-shrink: 0;
        padding: 10px 14px;
        font-size: 12px;
        white-space: nowrap;
        border-radius: 20px;
    }
    
    #librisociali .header-actions {
        display: flex;
        flex-wrap: wrap;
        gap: 8px;
    }
    
    #librisociali .header-actions .btn {
        flex: 1;
        min-width: 140px;
        font-size: 12px;
    }
}

/* === CONSIGLIO DIRETTIVO MOBILE === */
@media (max-width: 768px) {
    #consiglio .tabs-nav {
        display: flex;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        gap: 5px;
        margin-bottom: 15px;
    }
    
    #consiglio .tabs-nav .tab-btn {
        flex-shrink: 0;
        padding: 10px 14px;
        font-size: 12px;
        white-space: nowrap;
    }
    
    /* Card membri consiglio */
    #consiglio .person-card,
    #consiglioCards .card {
        padding: 12px;
    }
    
    #consiglioCards {
        display: grid;
        grid-template-columns: 1fr;
        gap: 10px;
    }
}

/* === PROTOCOLLO MOBILE === */
@media (max-width: 768px) {
    #protocollo .header-actions {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
    }
    
    #protocollo .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* === SCADENZIARIO MOBILE === */
@media (max-width: 768px) {
    #scadenziario .header-actions {
        display: flex;
        flex-wrap: wrap;
        gap: 8px;
    }
    
    #scadenziario .header-actions .btn {
        flex: 1;
        min-width: 120px;
        font-size: 12px;
    }
    
    /* Calendario compatto */
    #scadenziario .calendar-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
}

/* === GDPR MOBILE === */
@media (max-width: 768px) {
    #gdpr .tabs-nav {
        display: flex;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        gap: 5px;
        margin-bottom: 15px;
    }
    
    #gdpr .tabs-nav .tab-btn {
        flex-shrink: 0;
        font-size: 11px;
        padding: 8px 12px;
    }
    
    #gdpr .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
    }
}

/* === IMPOSTAZIONI MOBILE === */
@media (max-width: 768px) {
    #impostazioni .tabs-nav {
        display: flex;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        gap: 5px;
    }
    
    #impostazioni .tabs-nav .tab-btn {
        flex-shrink: 0;
        font-size: 12px;
        padding: 10px 14px;
    }
    
    /* Form impostazioni */
    #impostazioni .form-row {
        flex-direction: column;
    }
    
    #impostazioni .form-group {
        width: 100%;
    }
}

/* === GESTIONE UTENTI MOBILE === */
@media (max-width: 768px) {
    #gestioneUtenti .header-actions {
        width: 100%;
    }
    
    #gestioneUtenti .header-actions .btn {
        width: 100%;
    }
    
    /* Tabella utenti come card */
    #usersTableBody tr {
        display: flex;
        flex-direction: column;
        background: white;
        margin-bottom: 10px;
        border-radius: 12px;
        padding: 12px;
        box-shadow: 0 2px 6px rgba(0,0,0,0.05);
    }
    
    #usersTableBody td {
        display: flex;
        justify-content: space-between;
        padding: 6px 0;
        border: none;
    }
    
    #usersTableBody td::before {
        content: attr(data-label);
        font-weight: 600;
        color: #6b7280;
        font-size: 11px;
    }
}

/* === MODAL AMMINISTRAZIONE MOBILE === */
@media (max-width: 768px) {
    /* Modal movimento fiscale */
    #movimentoModal .modal-content,
    #importBancaModal .modal-content,
    #rendicontoModal .modal-content {
        max-height: 95vh;
    }
    
    #movimentoModal .form-row,
    #importBancaModal .form-row {
        flex-direction: column;
    }
    
    #movimentoModal .form-group,
    #importBancaModal .form-group {
        width: 100%;
    }
    
    /* Categorie movimento più leggibili */
    #movimentoModal select option {
        padding: 10px;
    }
}

/* === PULSANTI AZIONE COMPATTI SU MOBILE === */
@media (max-width: 480px) {
    .header-actions .btn span.btn-text {
        display: none;
    }
    
    .header-actions .btn {
        padding: 10px 12px;
    }
    
    .header-actions .btn i {
        margin: 0;
    }
}

/* === FIX OVERFLOW GENERALE === */
@media (max-width: 768px) {
    .tab-content {
        overflow-x: hidden;
    }
    
    .card-body {
        overflow-x: auto;
    }
    
    /* Previeni scroll orizzontale pagina */
    body, html {
        overflow-x: hidden;
    }
}

/* === ASSEMBLEE SOCIALI MOBILE === */
@media (max-width: 768px) {
    #assemblee .tabs-nav {
        display: flex;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        gap: 5px;
        margin-bottom: 15px;
        padding-bottom: 5px;
    }
    
    #assemblee .tabs-nav .tab-btn {
        flex-shrink: 0;
        padding: 10px 14px;
        font-size: 11px;
        white-space: nowrap;
        border-radius: 20px;
    }
    
    #assemblee .tabs-nav .tab-btn i {
        margin-right: 5px;
    }
    
    /* Card prossima assemblea */
    #assemblee .mandato-card,
    #assembleeTabPanoramica > .card:first-of-type {
        padding: 15px !important;
        border-radius: 12px;
    }
    
    #assembleeTabPanoramica > .card .card-body {
        padding: 15px;
    }
    
    #assembleeTabPanoramica > .card h3 {
        font-size: 16px !important;
    }
    
    #assembleeTabPanoramica [style*="font-size:42px"] {
        font-size: 28px !important;
    }
    
    /* Info quorum in colonna */
    #assemblee [style*="grid-template-columns: repeat(auto-fit"] {
        display: flex !important;
        flex-direction: column !important;
        gap: 12px !important;
    }
    
    #assemblee [style*="grid-template-columns: repeat(auto-fit"] > div {
        width: 100% !important;
    }
    
    /* Header actions assemblee */
    #assemblee .header-actions {
        display: grid !important;
        grid-template-columns: 1fr 1fr !important;
        gap: 8px !important;
    }
    
    #assemblee .header-actions .btn {
        font-size: 11px !important;
        padding: 10px 8px !important;
    }
    
    #assemblee .header-actions .btn span {
        display: none;
    }
    
    /* Filtri assemblee */
    #assembleeTabConvocazioni .card-header {
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 10px;
    }
    
    #assembleeTabConvocazioni .card-header > div {
        display: flex;
        gap: 8px;
    }
    
    #assembleeTabConvocazioni .card-header select {
        flex: 1;
        font-size: 12px;
        padding: 8px;
    }
    
    /* Tabelle assemblee scroll */
    #assemblee .data-table {
        min-width: 600px;
    }
    
    #assemblee .card-body {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    /* Stat cards assemblee */
    #assemblee .stats-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 8px !important;
    }
}

/* === EMERGENZE MOBILE === */
@media (max-width: 768px) {
    #emergenze .tabs-nav {
        display: flex;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        gap: 5px;
        margin-bottom: 15px;
    }
    
    #emergenze .tabs-nav .tab-btn {
        flex-shrink: 0;
        padding: 10px 14px;
        font-size: 11px;
        white-space: nowrap;
    }
    
    #emergenze .header-actions {
        display: grid !important;
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 8px !important;
    }
    
    #emergenze .header-actions .btn {
        font-size: 11px;
        padding: 10px 8px;
    }
    
    #emergenze .header-actions .btn span {
        display: none;
    }
    
    /* Stats emergenze */
    #emergenze .stats-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 8px !important;
    }
    
    /* Card emergenza attiva */
    #emergenze [style*="background:linear-gradient"] {
        padding: 15px !important;
        border-radius: 12px !important;
    }
    
    #emergenze [style*="background:linear-gradient"] h3 {
        font-size: 16px !important;
    }
    
    /* Form emergenza */
    #emergenzaModal .form-row {
        flex-direction: column !important;
    }
    
    #emergenzaModal .form-group {
        width: 100% !important;
    }
    
    /* Tabella presenze */
    #emergenze .data-table {
        min-width: 500px;
    }
}

/* === BANDI E OPPORTUNITÀ MOBILE === */
@media (max-width: 768px) {
    #bandi .header-actions {
        display: grid !important;
        grid-template-columns: 1fr !important;
        gap: 8px !important;
    }
    
    #bandi .header-actions .btn {
        width: 100%;
        justify-content: center;
    }
    
    /* Stats bandi */
    #bandi .stats-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 8px !important;
    }
    
    /* Filtri bandi */
    #bandi .card-header {
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 10px;
    }
    
    #bandi .card-header .form-row,
    #bandi .card-header > div {
        display: flex;
        flex-direction: column;
        gap: 8px;
        width: 100%;
    }
    
    #bandi .card-header select,
    #bandi .card-header .form-control {
        width: 100% !important;
        font-size: 14px;
    }
    
    /* Tabs bandi */
    #bandi .tabs {
        display: flex;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        gap: 5px;
        margin-bottom: 15px;
    }
    
    #bandi .tabs .tab {
        flex-shrink: 0;
        padding: 10px 14px;
        font-size: 12px;
        white-space: nowrap;
    }
    
    /* Tabelle bandi scroll */
    #bandi .data-table {
        min-width: 700px;
    }
    
    #bandi .card-body {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    /* Badge scadenza */
    #bandi .badge {
        font-size: 10px;
        padding: 3px 6px;
    }
}

/* === FORMAZIONE MOBILE === */
@media (max-width: 768px) {
    #formazione .tabs-nav {
        display: flex;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        gap: 5px;
        margin-bottom: 15px;
    }
    
    #formazione .tabs-nav .tab-btn {
        flex-shrink: 0;
        padding: 10px 14px;
        font-size: 11px;
        white-space: nowrap;
    }
    
    #formazione .header-actions {
        display: grid !important;
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 8px !important;
    }
    
    #formazione .stats-grid {
        grid-template-columns: repeat(2, 1fr) !important;
    }
}

/* === CONVENZIONI MOBILE === */
@media (max-width: 768px) {
    #convenzioni .header-actions {
        display: grid !important;
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 8px !important;
    }
    
    #convenzioni .stats-grid {
        grid-template-columns: repeat(2, 1fr) !important;
    }
    
    #convenzioni .data-table {
        min-width: 600px;
    }
}

/* === RIMBORSI MOBILE === */
@media (max-width: 768px) {
    #rimborsi .header-actions {
        display: grid !important;
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 8px !important;
    }
    
    #rimborsi .stats-grid {
        grid-template-columns: repeat(2, 1fr) !important;
    }
    
    #rimborsi .tabs {
        display: flex;
        overflow-x: auto;
        gap: 5px;
    }
    
    #rimborsi .tabs .tab {
        flex-shrink: 0;
        font-size: 12px;
    }
}

/* === MODAL ASSEMBLEA/VERBALE MOBILE === */
@media (max-width: 768px) {
    #assembleaModal .modal-content,
    #verbaleAssembleaModal .modal-content,
    #foglioFirmeModal .modal-content {
        width: 100% !important;
        max-width: 100% !important;
        height: 100% !important;
        max-height: 100% !important;
        border-radius: 0 !important;
        margin: 0 !important;
    }
    
    #assembleaModal .modal-body,
    #verbaleAssembleaModal .modal-body {
        padding: 15px;
    }
    
    #assembleaModal .form-row,
    #verbaleAssembleaModal .form-row {
        flex-direction: column !important;
    }
    
    #assembleaModal .form-group,
    #verbaleAssembleaModal .form-group {
        width: 100% !important;
    }
    
    #assembleaModal .modal-footer,
    #verbaleAssembleaModal .modal-footer {
        flex-wrap: wrap !important;
        gap: 8px !important;
        padding: 15px !important;
    }
    
    #assembleaModal .modal-footer .btn,
    #verbaleAssembleaModal .modal-footer .btn {
        flex: 1 1 45%;
        font-size: 12px;
        padding: 10px;
    }
    
    /* Sezione presenze verbale */
    #verbaleAssembleaModal [style*="background:#f0f9ff"],
    #verbaleAssembleaModal [style*="background:#fefce8"],
    #verbaleAssembleaModal [style*="background:#ecfdf5"] {
        padding: 12px !important;
        border-radius: 8px !important;
    }
    
    /* Container delibere */
    #vaDelibereContainer .form-group {
        margin-bottom: 12px;
    }
    
    #vaDelibereContainer textarea {
        font-size: 14px;
    }
}

/* === MODAL EMERGENZA MOBILE === */
@media (max-width: 768px) {
    #emergenzaModal .modal-content,
    #presenzaEmergenzaModal .modal-content {
        width: 100% !important;
        max-width: 100% !important;
        height: 100% !important;
        max-height: 100% !important;
        border-radius: 0 !important;
    }
    
    #emergenzaModal .form-row {
        flex-direction: column !important;
    }
    
    #emergenzaModal .form-group {
        width: 100% !important;
    }
    
    /* Lista presenze compatta */
    #presenzeEmergenzaContainer {
        max-height: 300px;
        overflow-y: auto;
    }
    
    #presenzeEmergenzaContainer .presenza-item {
        padding: 10px;
        font-size: 13px;
    }
}

/* === CARD GRADIENT MOBILE (Mandato, Prossima Assemblea, ecc) === */
@media (max-width: 768px) {
    [style*="background:linear-gradient"][style*="color:white"] {
        border-radius: 12px !important;
    }
    
    .mandato-card .card-body,
    [class*="card"][style*="background:linear-gradient"] .card-body {
        padding: 15px !important;
    }
    
    /* Countdown grande */
    [style*="font-size:42px"],
    [style*="font-size: 42px"] {
        font-size: 28px !important;
    }
    
    /* Info sotto countdown */
    [style*="display:flex"][style*="gap:30px"] {
        flex-direction: column !important;
        gap: 8px !important;
    }
}

/* === ALERT BOX MOBILE === */
@media (max-width: 768px) {
    .alert {
        padding: 12px 15px;
        font-size: 13px;
        border-radius: 10px;
    }
    
    .alert i {
        font-size: 16px;
    }
    
    .alert strong {
        display: block;
        margin-bottom: 3px;
    }
}

/* === BADGE MOBILE === */
@media (max-width: 768px) {
    .badge {
        font-size: 10px;
        padding: 4px 8px;
        border-radius: 6px;
    }
}

/* === TABS GENERICI MOBILE === */
@media (max-width: 768px) {
    .tabs,
    .tabs-nav {
        display: flex !important;
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch;
        gap: 5px;
        padding-bottom: 5px;
        margin-bottom: 15px;
        scrollbar-width: none;
    }
    
    .tabs::-webkit-scrollbar,
    .tabs-nav::-webkit-scrollbar {
        display: none;
    }
    
    .tab,
    .tab-btn {
        flex-shrink: 0;
        padding: 10px 14px;
        font-size: 12px;
        white-space: nowrap;
        border-radius: 20px;
    }
    
    .tab i,
    .tab-btn i {
        margin-right: 5px;
        font-size: 12px;
    }
}

/* === CARD HEADER CON FILTRI MOBILE === */
@media (max-width: 768px) {
    .card-header {
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 10px;
    }
    
    .card-header h3 {
        font-size: 15px;
        margin-bottom: 5px;
    }
    
    .card-header > div:last-child {
        display: flex;
        flex-wrap: wrap;
        gap: 8px;
    }
    
    .card-header select,
    .card-header input[type="text"],
    .card-header input[type="date"] {
        flex: 1;
        min-width: 120px;
        font-size: 13px;
        padding: 8px 10px;
    }
}

/* === BOTTONI ICONA COMPATTI === */
@media (max-width: 768px) {
    .btn-icon,
    .btn.btn-sm.btn-icon {
        width: 36px !important;
        height: 36px !important;
        padding: 0 !important;
        display: inline-flex !important;
        align-items: center !important;
        justify-content: center !important;
    }
    
    .btn-icon i {
        margin: 0 !important;
        font-size: 14px !important;
    }
}

/* === FIX SPECIFICI TABELLE NUOVI MODULI === */
@media (max-width: 768px) {
    /* Tabelle con molte colonne - scroll obbligatorio */
    #assembleeTableBody,
    #verbaliAssembleeTableBody,
    #storicoAssembleeTableBody,
    #emergenzeTableBody,
    #presenzeTableBody,
    #bandiTableBody,
    #bandiSalvatiTableBody {
        font-size: 12px;
    }
    
    #assembleeTableBody td,
    #verbaliAssembleeTableBody td,
    #emergenzeTableBody td,
    #bandiTableBody td {
        padding: 8px 6px;
        white-space: nowrap;
    }
    
    /* Pulsanti azioni in tabella più piccoli */
    #assembleeTableBody .btn-sm,
    #emergenzeTableBody .btn-sm,
    #bandiTableBody .btn-sm {
        padding: 5px 7px;
        font-size: 11px;
    }
}

/* === LANDSCAPE MOBILE === */
@media (max-width: 768px) and (orientation: landscape) {
    .modal-content {
        max-height: 100vh;
    }
    
    .modal-body {
        max-height: calc(100vh - 130px);
    }
    
    .stats-grid {
        grid-template-columns: repeat(4, 1fr) !important;
    }
    
    .header-actions {
        grid-template-columns: repeat(4, 1fr) !important;
    }
}

/* === SMALL PHONES (< 380px) === */
@media (max-width: 380px) {
    .page-header h2 {
        font-size: 16px;
    }
    
    .header-actions {
        grid-template-columns: 1fr !important;
    }
    
    .stats-grid {
        grid-template-columns: 1fr !important;
    }
    
    .stat-card {
        flex-direction: row !important;
        text-align: left !important;
        padding: 12px !important;
    }
    
    .stat-icon {
        margin-bottom: 0 !important;
        margin-right: 12px;
    }
    
    .modal-footer {
        flex-direction: column;
    }
    
    .modal-footer .btn {
        width: 100% !important;
    }
    
    .tabs-nav,
    .tabs {
        gap: 3px;
    }
    
    .tab,
    .tab-btn {
        padding: 8px 10px;
        font-size: 11px;
    }
}
