/* ==========================================
   RESPONSIVE MOBILE - GESTIONALE LABORATORIO
   ========================================== */

/* ===== TABLET & MEDIUM DEVICES (max-width: 992px) ===== */
@media (max-width: 992px) {
    /* Layout generale */
    .container-fluid {
        padding-left: 1rem;
        padding-right: 1rem;
    }
    
    /* Tabelle - Forza scroll orizzontale */
    .table-responsive {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    .table {
        font-size: 0.875rem;
        min-width: 600px;
    }
    
    /* Row spacing */
    .row.g-3 > * {
        margin-bottom: 0.75rem;
    }
}

/* ===== SMARTPHONE & SMALL DEVICES (max-width: 768px) ===== */
@media (max-width: 768px) {
    /* LISTE E CARD */
    
    /* Lista clienti/fornitori - Card view */
    .list-group-item {
        padding: 0.75rem !important;
        font-size: 0.875rem;
    }
    
    /* Forza layout verticale per flex items */
    .d-flex.justify-content-between {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 0.5rem;
    }
    
    /* HEADER PAGINE */
    .page-header,
    .mb-4 > .row {
        text-align: center;
    }
    
    .page-header .btn-group,
    .page-header .btn {
        width: 100%;
        margin: 0.25rem 0 !important;
    }
    
    /* FORM */
    
    /* Label più compatte */
    .form-label {
        font-size: 0.875rem;
        margin-bottom: 0.375rem;
        font-weight: 600;
    }
    
    /* Input group - Stack verticalmente su mobile */
    .input-group {
        flex-wrap: wrap;
    }
    
    .input-group > .btn {
        margin-top: 0.5rem;
        width: 100%;
    }
    
    /* MODALI */
    .modal-dialog {
        margin: 0.5rem;
        max-width: calc(100% - 1rem);
    }
    
    .modal-body {
        padding: 1rem;
    }
    
    .modal-header,
    .modal-footer {
        padding: 0.75rem 1rem;
    }
    
    .modal-footer .btn {
        padding: 0.5rem 1rem;
        font-size: 0.875rem;
    }
    
    /* DASHBOARD */
    
    /* KPI Cards - Stack verticalmente */
    .kpi-card {
        margin-bottom: 1rem;
    }
    
    .kpi-card h3 {
        font-size: 1.5rem !important;
    }
    
    .kpi-card h6 {
        font-size: 0.8rem !important;
    }
    
    /* Grafici responsive */
    .chart-container {
        position: relative;
        height: 250px !important;
        width: 100% !important;
    }
    
    /* TABELLE RESPONSIVE */
    
    /* Tabelle - Hide colonne non essenziali */
    .table-responsive table {
        font-size: 0.8125rem;
    }
    
    .table-responsive th,
    .table-responsive td {
        padding: 0.5rem 0.375rem;
        white-space: nowrap;
    }
    
    /* Nascondi colonne secondarie su mobile */
    .table .d-none-mobile,
    .table th.d-none-mobile,
    .table td.d-none-mobile {
        display: none !important;
    }
    
    /* FILTRI E RICERCA */
    
    /* Form filtri - Full width */
    form .col-md-3,
    form .col-md-4,
    form .col-md-6 {
        width: 100%;
        margin-bottom: 0.75rem;
    }
    
    /* Search bar */
    .search-wrapper {
        width: 100% !important;
        margin-bottom: 1rem;
    }
    
    /* BOTTONI AZIONI */
    
    /* Bottoni azioni lista - Più compatti */
    .action-buttons {
        display: flex;
        flex-wrap: wrap;
        gap: 0.25rem;
    }
    
    .action-buttons .btn-sm {
        padding: 0.25rem 0.5rem;
        font-size: 0.75rem;
    }
    
    /* Dropdown actions */
    .btn-group {
        width: 100%;
    }
    
    .btn-group .dropdown-toggle {
        width: 100%;
    }
    
    /* BADGE E LABEL */
    .badge {
        font-size: 0.7rem;
        padding: 0.25rem 0.5rem;
    }
    
    /* ALERT */
    .alert {
        padding: 0.75rem;
        font-size: 0.875rem;
    }
    
    .alert i {
        font-size: 0.9rem;
    }
    
    /* PAGINATION */
    .pagination {
        font-size: 0.8125rem;
        flex-wrap: wrap;
        justify-content: center;
    }
    
    .page-item {
        margin: 0.125rem;
    }
    
    /* SCHEDE DETTAGLIO */
    
    /* Info cliente/intervento */
    .info-row {
        margin-bottom: 0.75rem;
    }
    
    .info-label {
        font-size: 0.75rem;
        font-weight: 600;
        text-transform: uppercase;
        color: #6c757d;
        margin-bottom: 0.25rem;
    }
    
    .info-value {
        font-size: 0.9rem;
    }
}

/* ===== EXTRA SMALL DEVICES (max-width: 576px) ===== */
@media (max-width: 576px) {
    /* LAYOUT ULTRA COMPATTO */
    
    body {
        font-size: 0.875rem;
    }
    
    .container,
    .container-fluid {
        padding-left: 0.5rem;
        padding-right: 0.5rem;
    }
    
    /* CARD */
    .card {
        margin-bottom: 0.75rem;
        border-radius: 0.5rem;
    }
    
    .card-body {
        padding: 0.75rem !important;
    }
    
    .card-header {
        padding: 0.5rem 0.75rem !important;
        font-size: 0.875rem;
    }
    
    /* TITOLI */
    h1,
    .h1 {
        font-size: 1.25rem !important;
    }
    
    h2,
    .h2 {
        font-size: 1.15rem !important;
    }
    
    h3,
    .h3,
    h4,
    .h4 {
        font-size: 1rem !important;
    }
    
    h5,
    .h5,
    h6,
    .h6 {
        font-size: 0.9rem !important;
    }
    
    /* BOTTONI */
    .btn {
        font-size: 0.8125rem;
        padding: 0.4rem 0.75rem;
    }
    
    .btn-lg {
        font-size: 0.9375rem;
        padding: 0.5rem 1rem;
    }
    
    .btn-sm {
        font-size: 0.75rem;
        padding: 0.25rem 0.5rem;
    }
    
    /* Bottoni full-width su mobile */
    .btn-block-mobile {
        width: 100%;
        margin: 0.25rem 0;
    }
    
    /* FORM */
    .form-control,
    .form-select {
        font-size: 0.875rem;
        padding: 0.5rem 0.75rem;
    }
    
    textarea.form-control {
        min-height: 80px;
    }
    
    /* TABELLE */
    .table {
        font-size: 0.75rem;
    }
    
    .table th,
    .table td {
        padding: 0.375rem 0.25rem;
    }
    
    /* LISTE */
    .list-group-item {
        padding: 0.5rem !important;
    }
    
    .list-group-item small {
        font-size: 0.7rem;
    }
    
    /* MODAL */
    .modal-content {
        border-radius: 0.5rem;
    }
    
    .modal-title {
        font-size: 1rem;
    }
    
    .modal-body {
        padding: 0.75rem;
    }
    
    /* DROPDOWN */
    .dropdown-menu {
        font-size: 0.8125rem;
        min-width: 180px;
    }
    
    .dropdown-item {
        padding: 0.4rem 0.75rem;
    }
    
    /* STAT CARDS */
    .stat-card {
        padding: 0.75rem !important;
        min-height: 85px;
    }
    
    .stat-number {
        font-size: 1.25rem;
    }
    
    .stat-label {
        font-size: 0.7rem;
    }
    
    .stat-icon {
        font-size: 1.15rem !important;
    }
    
    /* ICONE */
    .fa-2x {
        font-size: 1.5rem !important;
    }
    
    .fa-3x {
        font-size: 2rem !important;
    }
    
    /* SPACING */
    .mb-4 {
        margin-bottom: 1rem !important;
    }
    
    .mb-5 {
        margin-bottom: 1.5rem !important;
    }
    
    .mt-4 {
        margin-top: 1rem !important;
    }
    
    .mt-5 {
        margin-top: 1.5rem !important;
    }
}

/* ===== LANDSCAPE MODE - SMALL DEVICES ===== */
@media (max-height: 500px) and (orientation: landscape) {
    /* Riduci padding verticale in landscape */
    body {
        padding-top: 0.5rem;
        padding-bottom: 0.5rem;
    }
    
    .card-body {
        padding: 0.5rem !important;
    }
    
    .modal-dialog {
        margin: 0.25rem;
    }
    
    .modal-body {
        max-height: 60vh;
        overflow-y: auto;
    }
}

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

/* Visibilità responsive */
@media (max-width: 768px) {
    .hide-mobile {
        display: none !important;
    }
}

@media (min-width: 769px) {
    .show-mobile-only {
        display: none !important;
    }
}

/* Text truncate mobile */
@media (max-width: 576px) {
    .text-truncate-mobile {
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
}

/* Stack flex su mobile */
@media (max-width: 768px) {
    .flex-stack-mobile {
        flex-direction: column !important;
    }
    
    .flex-stack-mobile > * {
        width: 100% !important;
        margin-bottom: 0.5rem;
    }
}
