/* ==============================================
   EASYVACANZE - RESPONSIVE BACKOFFICE
   Mobile/Tablet Optimizations
   ============================================== */

/* Mobile Menu Toggle Button */
.navbar-toggler {
    display: none !important;
}

@media (max-width: 991px) {
    .navbar-toggler {
        display: inline-flex !important;
    }
}

.navbar-toggler:hover i {
    color: #006194 !important;
}

/* Mobile Sidebar Menu */
.mobile-sidebar-menu {
    position: fixed;
    top: 0;
    left: -280px;
    width: 280px;
    height: 100vh;
    background: #fff;
    box-shadow: 4px 0 24px rgba(0,0,0,0.15);
    z-index: 1100;
    transition: left 0.3s ease;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    display: none;
}

@media (max-width: 991px) {
    .mobile-sidebar-menu {
        display: block;
    }
}

.mobile-sidebar-menu.show {
    left: 0;
}

.mobile-sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid #e7e7e7;
    background: #f8f9fa;
}

.mobile-sidebar-header .btn-icon {
    padding: 0.25rem;
    color: #697a8d;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.mobile-sidebar-header .btn-icon:hover {
    color: #006194;
}

.mobile-sidebar-content {
    padding: 1rem 0;
}

.mobile-sidebar-content .navbar-nav {
    padding: 0 0.75rem;
    flex-direction: column !important;
    align-items: stretch !important;
    width: 100%;
}

.mobile-sidebar-content .nav-item {
    margin-bottom: 0.25rem;
    width: 100%;
}

.mobile-sidebar-content .nav-link {
    display: flex !important;
    align-items: center;
    padding: 0.75rem 1rem;
    color: #697a8d;
    text-decoration: none;
    border-radius: 6px;
    transition: all 0.2s;
    font-weight: 500;
    width: 100%;
    flex-direction: row !important;
}

.mobile-sidebar-content .nav-link i:first-child {
    font-size: 1.25rem;
    width: 24px;
    margin-right: 0.75rem;
}

.mobile-sidebar-content .nav-link .bx-chevron-down {
    font-size: 1rem;
    transition: transform 0.3s;
}

.mobile-sidebar-content .nav-link.active {
    background: #006194;
    color: #fff;
}

.mobile-sidebar-content .nav-link:hover {
    background: #f1f1f2;
    color: #006194;
}

.mobile-sidebar-content .nav-link.active:hover {
    background: #006194;
    color: #fff;
}

.mobile-sidebar-content .mobile-dropdown-toggle.expanded .bx-chevron-down {
    transform: rotate(180deg);
}

.mobile-sidebar-content .mobile-submenu {
    list-style: none;
    padding: 0;
    margin: 0.25rem 0 0.5rem 2.5rem;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
}

.mobile-sidebar-content .mobile-submenu.show {
    max-height: 500px;
}

.mobile-sidebar-content .mobile-submenu li {
    margin-bottom: 0.25rem;
}

.mobile-sidebar-content .mobile-submenu a {
    display: flex;
    align-items: center;
    padding: 0.625rem 1rem;
    color: #697a8d;
    text-decoration: none;
    border-radius: 4px;
    font-size: 0.9375rem;
    transition: all 0.2s;
}

.mobile-sidebar-content .mobile-submenu a i {
    font-size: 1.125rem;
    width: 20px;
    margin-right: 0.75rem;
}

.mobile-sidebar-content .mobile-submenu a:hover {
    background: #f8f9fa;
    color: #006194;
}

.mobile-menu-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 1050;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s, visibility 0.3s;
    display: none;
}

@media (max-width: 991px) {
    .mobile-menu-overlay {
        display: block;
    }
}

.mobile-menu-overlay.show {
    opacity: 1;
    visibility: visible;
}

/* Tablet Portrait e inferiore (max-width: 991px) */
@media (max-width: 991px) {
    /* Prevent body scroll when menu is open */
    body.mobile-menu-open {
        overflow: hidden;
    }
    
    /* Sidebar sempre collassata su tablet/mobile */
    .layout-menu {
        transform: translateX(-100%) !important;
        width: 260px;
    }
    
    .layout-menu.show {
        transform: translateX(0) !important;
        box-shadow: 0 4px 20px rgba(0,0,0,0.3);
    }
    
    /* Overlay per chiudere menu su mobile */
    .layout-overlay {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: rgba(0,0,0,0.5);
        z-index: 9;
        display: none;
    }
    
    .layout-overlay.active {
        display: block;
    }
    
    /* Content prende full width */
    .layout-page {
        width: 100% !important;
        padding-left: 0 !important;
    }
    
    /* Header navbar responsive */
    .layout-navbar {
        padding: 0.5rem 1rem !important;
    }
    
    .navbar-nav {
        flex-direction: row !important;
        gap: 0.5rem;
    }
    
    /* Tabelle responsive con scroll orizzontale */
    .table-responsive {
        display: block;
        width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    .table {
        min-width: 800px;
    }
    
    /* Cards stack verticalmente */
    .row > [class*="col-"] {
        padding-left: 0.75rem !important;
        padding-right: 0.75rem !important;
    }
    
    /* Bottoni più larghi e touch-friendly */
    .btn {
        padding: 0.75rem 1.25rem !important;
        min-height: 44px;
    }
    
    .btn-sm {
        min-height: 38px;
        padding: 0.5rem 1rem !important;
    }
    
    /* Form inputs più grandi */
    .form-control,
    .form-select {
        font-size: 16px !important; /* Previene zoom su iOS */
        min-height: 44px;
        padding: 0.75rem 1rem !important;
    }
    
    /* Modali full-screen su mobile */
    .modal-dialog {
        margin: 0;
        max-width: 100%;
        height: 100vh;
    }
    
    .modal-content {
        height: 100vh;
        border-radius: 0;
    }
    
    /* Dropdown menu responsive */
    .dropdown-menu {
        max-width: calc(100vw - 2rem);
    }
    
    /* Stats cards responsive */
    .card-statistics .statistics-body {
        flex-direction: column;
        align-items: flex-start !important;
    }
    
    /* Kanban board responsive */
    .kanban-board {
        flex-direction: column !important;
    }
    
    .kanban-column {
        width: 100% !important;
        margin-bottom: 1rem;
    }
    
    /* Calendar responsive */
    .fc-toolbar {
        flex-direction: column !important;
        gap: 0.5rem;
    }
    
    .fc-toolbar-chunk {
        width: 100%;
        justify-content: center;
    }
    
    /* Breadcrumb nascosto su mobile */
    .breadcrumb {
        font-size: 0.875rem;
    }
    
    /* Avatar e immagini */
    .avatar-xl {
        width: 3.5rem !important;
        height: 3.5rem !important;
    }
    
    /* Nascondi colonne non essenziali tabelle */
    .d-none-mobile {
        display: none !important;
    }
    
    /* Footer sticky */
    .content-footer {
        padding: 1rem !important;
    }
}

/* Tablet - nascondi colonne secondarie */
@media (max-width: 991px) {
    /* Nascondi colonne non essenziali nelle tabelle */
    table th:nth-child(6),
    table td:nth-child(6) {
        display: none; /* Notti */
    }
}

/* Mobile Portrait (max-width: 575px) */
@media (max-width: 575px) {
    /* Navbar compatta su mobile */
    .layout-navbar {
        padding: 0.5rem 1rem !important;
    }
    
    #mobileMenuToggle {
        padding: 0.5rem;
    }
    
    /* Mobile sidebar più stretta su portrait */
    .mobile-sidebar-menu {
        width: 260px;
        left: -260px;
    }
    
    .mobile-sidebar-header {
        padding: 0.875rem 1rem;
    }
    
    .mobile-sidebar-header img {
        height: 30px !important;
    }
    
    /* User dropdown più compatto */
    .navbar-dropdown .avatar {
        width: 32px;
        height: 32px;
    }
    
    .navbar-dropdown .avatar-initial {
        font-size: 0.875rem;
    }
    
    /* Nascondi più colonne su mobile */
    table th:nth-child(3),
    table td:nth-child(3),
    table th:nth-child(5),
    table td:nth-child(5),
    table th:nth-child(6),
    table td:nth-child(6) {
        display: none; /* Ospite, Check-out, Notti */
    }
    
    /* Riduci font tabelle */
    .table {
        font-size: 0.8rem;
    }
    
    .table th,
    .table td {
        padding: 0.5rem 0.25rem !important;
    }
    
    /* Badge più piccoli */
    .badge {
        font-size: 0.7rem;
        padding: 0.25rem 0.5rem;
    }
    
    /* Padding ridotto container */
    .container-xxl,
    .container-fluid {
        padding-left: 1rem !important;
        padding-right: 1rem !important;
    }
    
    /* Card padding ridotto */
    .card {
        margin-bottom: 1rem;
    }
    
    .card-body {
        padding: 1rem !important;
    }
    
    .card-header {
        padding: 0.75rem 1rem !important;
    }
    
    /* Typography responsive */
    h1, .h1 {
        font-size: 1.75rem !important;
    }
    
    h2, .h2 {
        font-size: 1.5rem !important;
    }
    
    h3, .h3 {
        font-size: 1.25rem !important;
    }
    
    h4, .h4 {
        font-size: 1.125rem !important;
    }
    
    /* Bottoni full-width su mobile */
    .btn-mobile-block {
        display: block;
        width: 100%;
        margin-bottom: 0.5rem;
    }
    
    /* Form layout stack verticale */
    .row.g-3 > [class*="col-"] {
        margin-bottom: 1rem;
    }
    
    /* Actions buttons responsive */
    .btn-group {
        flex-direction: column;
        width: 100%;
    }
    
    .btn-group > .btn {
        width: 100%;
        margin-bottom: 0.5rem;
    }
    
    /* Stats cards full-width */
    [class*="col-xl-"],
    [class*="col-lg-"],
    [class*="col-md-"] {
        flex: 0 0 100%;
        max-width: 100%;
    }
    
    /* Pagination responsive */
    .pagination {
        justify-content: center;
        flex-wrap: wrap;
        gap: 0.25rem;
    }
    
    .page-item {
        margin: 0 !important;
    }
    
    /* Filtri collassabili */
    .filter-section {
        margin-bottom: 1rem;
    }
    
    .filter-toggle {
        display: block;
        width: 100%;
        text-align: left;
        padding: 0.75rem;
        background: #f8f9fa;
        border: 1px solid #dee2e6;
        border-radius: 0.375rem;
        cursor: pointer;
    }
    
    .filter-content {
        display: none;
        padding: 1rem;
        border: 1px solid #dee2e6;
        border-top: none;
        border-radius: 0 0 0.375rem 0.375rem;
    }
    
    .filter-content.show {
        display: block;
    }
    
    /* Datepicker responsive */
    .flatpickr-calendar {
        width: 100% !important;
        max-width: calc(100vw - 2rem);
    }
    
    /* Select2 dropdown responsive */
    .select2-container {
        width: 100% !important;
    }
    
    .select2-dropdown {
        max-width: calc(100vw - 2rem);
    }
}

/* Touch-friendly enhancements */
@media (hover: none) and (pointer: coarse) {
    /* Aumenta area touch per tutti i link e bottoni */
    a, button, .btn, .nav-link {
        min-height: 44px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }
    
    /* Rimuovi hover effects su touch devices */
    .btn:hover,
    .nav-link:hover,
    .dropdown-item:hover {
        transform: none !important;
    }
    
    /* Feedback visivo su tap */
    .btn:active,
    .nav-link:active {
        transform: scale(0.98);
        transition: transform 0.1s;
    }
}

/* Landscape mobile (max-height: 500px in landscape) */
@media (max-height: 500px) and (orientation: landscape) {
    .layout-navbar {
        padding: 0.25rem 1rem !important;
    }
    
    .modal-dialog {
        margin: 0.5rem;
    }
    
    /* Riduci padding verticale */
    .py-4 {
        padding-top: 1rem !important;
        padding-bottom: 1rem !important;
    }
}

/* Dark mode responsive adjustments */
@media (prefers-color-scheme: dark) {
    .filter-toggle {
        background: #2b2c40;
        border-color: #434968;
        color: #c3c6d4;
    }
    
    .filter-content {
        background: #2b2c40;
        border-color: #434968;
    }
}

/* Print styles */
@media print {
    .layout-menu,
    .layout-navbar,
    .btn,
    .pagination,
    .d-print-none {
        display: none !important;
    }
    
    .layout-page {
        width: 100% !important;
        padding: 0 !important;
    }
    
    .card {
        break-inside: avoid;
    }
}

/* Colori di avvisi, etichette, testi e pulsanti: dal 44a sono in ev-admin.css (prima erano imposti qui con !important). */
