/* public/css/_responsive.css */

/* La X di chiusura sidebar deve comparire solo su mobile */
#sidebar .sidebar-mobile-close {
    display: none;
}

/* Tablet large */
@media (max-width: 1280px) {
    .main-content {
        padding: 18px;
    }

    .main-header h1,
    .page-header h1 {
        font-size: 1.6rem;
    }

    .modal-layout-columns {
        flex-direction: column;
        align-items: stretch;
    }

    .form-column,
    .notes-column {
        width: 100%;
        max-width: 100%;
        flex: 0 0 auto;
    }

    .notes-column {
        margin-top: 1rem;
    }

    .notes-column .log-entries-container {
        max-height: none;
    }
}

/* Tablet */
@media (max-width: 1024px) {
    .main-content {
        padding: 14px;
    }

    .main-header,
    .page-header {
        margin-bottom: 14px;
        gap: 10px;
        flex-wrap: wrap;
    }

    .header-title-group {
        width: 100%;
        gap: 10px;
    }

    .header-actions {
        width: 100%;
        justify-content: flex-end;
        gap: 8px;
        margin-left: auto;
    }

    .data-container-wrapper {
        padding: 2px;
    }

    #filters {
        gap: 12px;
        padding: 14px;
        grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
    }
}

/* Mobile */
@media (max-width: 900px) {
    body {
        overflow: auto;
    }

    html,
    body,
    #root,
    .dashboard-layout,
    .main-content {
        max-width: 100%;
        overflow-x: hidden;
    }

    .main-content > * {
        min-width: 0;
        max-width: 100%;
    }

    #root {
        height: auto;
        min-height: 100dvh;
    }

    .dashboard-layout {
        min-height: 100dvh;
    }

    .desktop-sidebar-container {
        display: none;
    }

    /* Sidebar mobile (pagine con Layout) */
    #sidebar {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        width: min(86vw, 320px) !important;
        max-width: 320px;
        height: 100dvh;
        margin-left: 0 !important;
        transform: translateX(-100%);
        transition: transform 0.25s ease;
        z-index: 1200;
        box-shadow: 0 0 30px rgba(0, 0, 0, 0.45);
    }

    #sidebar:not(.collapsed) {
        transform: translateX(0);
    }

    #sidebar.collapsed {
        transform: translateX(-100%);
    }

    #sidebar .sidebar-mobile-close {
        display: inline-flex;
    }

    #sidebar.collapsed .sidebar-mobile-close {
        display: none;
    }

    .main-content {
        min-height: 100dvh;
        height: auto;
        padding: 12px;
        overflow-y: auto;
        overflow-x: hidden;
    }

    .main-header h1,
    .page-header h1 {
        font-size: clamp(1.1rem, 5vw, 1.45rem);
    }

    .main-header {
        flex-wrap: nowrap;
        align-items: center;
    }

    .main-header.mobile-auto-hide {
        position: sticky;
        top: 0;
        z-index: 60;
        background: var(--data-container-bg);
        transition: max-height 0.2s ease, opacity 0.16s ease, margin-bottom 0.2s ease, transform 0.2s ease;
        max-height: 120px;
        overflow: hidden;
    }

    .main-header.mobile-auto-hide.is-hidden {
        max-height: 0;
        margin-bottom: 0;
        opacity: 0;
        pointer-events: none;
        transform: translateY(-6px);
    }

    .header-title-group {
        width: auto;
        min-width: 0;
        flex: 1 1 auto;
        justify-content: flex-start;
        align-items: center;
        flex-wrap: nowrap;
    }

    .header-title-group h1 {
        min-width: 0;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .header-actions {
        width: auto;
        flex: 0 0 auto;
        justify-content: flex-end;
        margin-left: auto;
    }

    .header-actions .btn {
        width: auto;
    }

    .header-quick-btn {
        width: 40px;
        height: 34px;
        justify-content: center;
        padding: 0 !important;
    }

    .header-quick-btn .header-quick-label {
        display: none;
    }

    .data-container-wrapper {
        padding: 0;
        border-radius: 0;
    }

    .data-container {
        border-radius: 0;
    }

    .tools-grid-layout,
    .tool-grid,
    .test-plan-grid,
    .test-plan-brand-picker-grid,
    .test-plan-brand-items-grid {
        grid-template-columns: 1fr;
    }

    .table-tabs {
        overflow-x: visible;
        overflow-y: visible;
        white-space: normal;
        flex-wrap: wrap;
        justify-content: flex-start;
    }

    #filters {
        position: static;
        top: auto;
        grid-template-columns: 1fr;
        gap: 10px;
        padding: 12px;
    }

    .log-strumenti-filters {
        flex-wrap: wrap;
        overflow: visible;
    }

    .log-strumenti-filters .filter-group,
    .log-strumenti-filters.is-compact .filter-group {
        min-width: min(100%, 240px);
    }

    /* Tabelle in modalità card su mobile */
    .data-table {
        width: 100% !important;
        min-width: 100% !important;
        table-layout: fixed;
    }

    .data-table thead {
        display: none;
    }

    .data-table tbody tr {
        display: block;
        padding: 10px 12px;
        border-bottom: 1px solid var(--surface-dark-border);
    }

    .data-table tbody td {
        display: grid;
        grid-template-columns: minmax(90px, 130px) 1fr;
        align-items: start;
        gap: 12px;
        padding: 8px 0;
        border-bottom: 1px solid rgba(255, 255, 255, 0.05);
        text-align: left;
    }

    .data-table tbody td:last-child {
        border-bottom: none;
    }

    .data-table tbody td::before {
        content: attr(data-label);
        color: var(--secondary-text-color-dark);
        font-size: 0.82em;
        font-weight: 600;
    }

    .data-table .actions-cell,
    .data-table td.actions-cell,
    .data-table td[data-label="Azioni"] {
        display: none !important;
    }

    .data-table .note-cell {
        white-space: pre-wrap;
        overflow-wrap: anywhere;
    }

    .data-table td,
    .data-table th {
        overflow-wrap: anywhere;
        word-break: break-word;
    }

    .table-wrapper::-webkit-scrollbar {
        display: none;
    }

    .table-wrapper {
        overflow-x: hidden !important;
        scrollbar-width: none;
        -ms-overflow-style: none;
    }

    .page-section,
    .data-container-wrapper,
    .data-container,
    .table-wrapper {
        height: auto;
        max-height: none;
    }

    /* Menu mobile dashboard: versione laterale in continuita' con la sidebar desktop */
    .mobile-menu-overlay {
        position: fixed;
        inset: 0;
        z-index: 1300;
        background: rgba(0, 0, 0, 0.55);
        display: flex;
        align-items: stretch;
        justify-content: flex-start;
        padding: 0;
    }

    .mobile-menu-content {
        width: min(88vw, 340px);
        height: 100dvh;
        margin-right: auto;
        display: flex;
        flex-direction: column;
        background-image: var(--sidebar-bg-gradient);
        background-color: var(--sidebar-bg-color, var(--data-container-bg));
        border-right: 1px solid var(--surface-dark-border);
        box-shadow: 0 12px 36px rgba(0, 0, 0, 0.4);
        animation: mobile-menu-slide-in 0.2s ease-out;
    }

    @keyframes mobile-menu-slide-in {
        from {
            transform: translateX(-100%);
            opacity: 0.85;
        }
        to {
            transform: translateX(0);
            opacity: 1;
        }
    }

    .mobile-menu-title-row {
        width: 100%;
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 8px;
    }

    .mobile-menu-title-row h2 {
        margin: 0;
    }

    .mobile-menu-content .sidebar-nav {
        padding: 16px;
        overflow-y: auto;
    }

    .mobile-menu-content .sidebar-actions {
        margin-bottom: 16px;
    }

    .mobile-menu-content .sidebar-actions .btn {
        width: 100%;
        justify-content: flex-start;
    }

    .mobile-menu-content .sidebar-actions .btn.active {
        border-color: var(--accent-color);
    }

    .mobile-menu-content .sidebar-footer {
        margin-top: auto;
        padding-top: 12px;
        border-top: 1px solid var(--surface-dark-border);
    }

    .mobile-menu-close {
        width: 36px;
        height: 36px;
        padding: 0;
        justify-content: center !important;
    }

    .mobile-menu-user {
        display: flex;
        align-items: center;
        padding: 8px 0 0;
    }

    .mobile-menu-user-name {
        font-weight: 700;
        color: var(--primary-text-color-dark);
    }

    .mobile-menu-content .badge {
        margin-left: auto;
    }

    body.theme-msdos .mobile-menu-content {
        background: #000 !important;
        border: 3px double var(--accent-color);
        box-shadow: none;
    }

    body.theme-msdos .mobile-menu-content .sidebar-header,
    body.theme-msdos .mobile-menu-content .sidebar-footer {
        border-color: var(--accent-color);
    }

    body.theme-windows98 .mobile-menu-content {
        background: var(--surface-bg);
        border: 1px solid;
        border-color: var(--surface-border-light) var(--surface-border-dark) var(--surface-border-dark) var(--surface-border-light);
        box-shadow: none;
    }

    body.theme-windowsxp .mobile-menu-content {
        background-color: var(--surface-glass);
        border: 1px solid;
        border-color: var(--surface-border-light) var(--surface-border-dark) var(--surface-border-dark) var(--surface-border-light);
        box-shadow:
            inset 0 1px 0 #ffffff,
            inset 0 -1px 0 #d6d9e2,
            0 6px 14px rgba(0, 0, 0, 0.18);
    }
}

/* Small phones */
@media (max-width: 480px) {
    .main-content {
        padding: 10px;
    }

    .header-actions {
        gap: 6px;
    }

    .header-actions {
        justify-content: flex-end;
    }

    .header-actions .btn {
        width: auto;
        justify-content: center;
    }

    .header-quick-btn {
        width: 36px !important;
        height: 32px !important;
    }

    .data-table tbody td {
        grid-template-columns: 1fr;
        gap: 6px;
    }

    .data-table tbody td::before {
        font-size: 0.78em;
    }
}
