/**
Theme Name: APP Falchi & Partners
Author: AF Project di Benzi Filippo
Author URI: https://afproject.eu/
Description: Tema custom per il portale Falchi & Partners
Version: 1.0.0
License: GNU General Public License v2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
Text Domain: app-falchi-partners
Template: astra
*/

/* ===== VARIABLES CSS ===== */
:root {
    --primary-color: #1a365d;
    --secondary-color: #2d3748;
    --accent-color: #e53e3e;
    --success-color: #38a169;
    --warning-color: #dd6b20;
    --text-color: #2d3748;
    --light-gray: #f7fafc;
    --border-color: #e2e8f0;
    --white: #ffffff;
    --shadow: 0 2px 10px rgba(0,0,0,0.05);
    --shadow-hover: 0 4px 20px rgba(0,0,0,0.1);
    --border-radius: 10px;
    --transition: all 0.3s ease;
}

/* ===== RESET & BASE STYLES ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: var(--light-gray);
    color: var(--text-color);
    line-height: 1.6;
}

/* ===== LAYOUT MOBILE ===== */
.app-container {
   
    margin: 0 auto;
    min-height: 100vh;
    background: var(--white);
    box-shadow: 0 0 20px rgba(0,0,0,0.1);
    position: relative;
    padding-bottom: 70px;
}

/* ===== HEADER ===== */
.header {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: var(--white);
    padding: 25px 15px;
    text-align: center;
    position: relative;
}

.logo {
    max-width: 200px;
    height: auto;
    margin-bottom: 10px;
}

.logo-text {
    font-weight: bold;
    font-size: 1.6rem;
    margin-bottom: 10px;
}

.user-info {
    display: flex;
    justify-content: space-between;
    font-size: 1rem;
    margin-top: 15px;
}

.user-name {
    font-size: 1rem;
    margin-top: 5px;
}

.back-btn {
    position: absolute;
    left: 15px;
    top: 25px;
    background: none;
    border: none;
    color: var(--white);
    font-size: 1.2rem;
    cursor: pointer;
    padding: 5px 10px;
}

/* ===== BOTTOM BAR ===== */
.bottom-bar {
    position: fixed;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    max-width: 400px;
    background-color: var(--white);
    padding: 15px;
    border-top: 2px solid var(--primary-color);
    box-shadow: 0 -2px 10px rgba(0,0,0,0.1);
    z-index: 1000;
}

.back-bar-btn {
    background-color: var(--primary-color);
    color: var(--white);
    border: none;
    border-radius: 8px;
    padding: 15px;
    width: 100%;
    font-size: 1.1rem;
    font-weight: bold;
    cursor: pointer;
    transition: var(--transition);
}

.back-bar-btn:hover {
    background-color: var(--secondary-color);
    transform: translateY(-2px);
}

#page-home .bottom-bar {
    display: none;
}

/* ===== MAIN CONTENT ===== */
.main-card {
    background-color: var(--white);
    margin: 15px;
    border-radius: var(--border-radius);
    padding: 20px;
    box-shadow: var(--shadow);
}

.section-title {
    color: var(--primary-color);
    margin-bottom: 15px;
    font-size: 1.3rem;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 8px;
}

/* ===== BUTTONS ===== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 20px;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: bold;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
    text-align: center;
}

.btn-primary {
    background-color: var(--primary-color);
    color: var(--white);
}

.btn-secondary {
    background-color: var(--light-gray);
    color: var(--text-color);
    border: 1px solid var(--border-color);
}

.btn-danger {
    background-color: var(--accent-color);
    color: var(--white);
}

.btn-success {
    background-color: var(--success-color);
    color: var(--white);
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-hover);
}

/* ===== HOME BUTTONS ===== */
.home-btn {
    background-color: var(--primary-color);
    color: var(--white);
    border: none;
    border-radius: 8px;
    padding: 20px;
    width: 100%;
    font-size: 1.2rem;
    font-weight: bold;
    margin-bottom: 15px;
    cursor: pointer;
    transition: var(--transition);
    text-align: left;
    position: relative;
    padding-left: 60px;
}

.home-btn i {
    position: absolute;
    left: 20px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 1.4rem;
}

.home-btn.emergency {
    background-color: var(--accent-color);
}

.home-btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-hover);
}

/* ===== GRIDS ===== */
.security-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
    margin-top: 20px;
}

.documents-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
    margin-top: 20px;
}

.attestati-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
    margin-top: 15px;
}

/* ===== CARDS & ITEMS ===== */
.security-item, .doc-item, .attestato-type {
    background-color: var(--white);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 18px;
    cursor: pointer;
    transition: var(--transition);
    position: relative;
    padding-left: 60px;
    width: 100%;
    min-height: 60px;
    display: flex;
    align-items: center;
}

.security-item i, .doc-item i, .attestato-type i {
    position: absolute;
    left: 20px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 1.3rem;
    color: var(--primary-color);
}

.security-item:hover, .doc-item:hover, .attestato-type:hover {
    border-color: var(--primary-color);
    transform: translateY(-2px);
}

.doc-item {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: var(--white);
    text-align: center;
    font-weight: bold;
    padding: 25px 15px;
    min-height: 80px;
    justify-content: center;
}

.doc-item i {
    color: var(--white);
}

/* ===== DOCUMENT CARDS ===== */
.document-card {
    background: var(--light-gray);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 15px;
    transition: var(--transition);
}

.document-card:hover {
    border-color: var(--primary-color);
    transform: translateY(-2px);
    box-shadow: var(--shadow-hover);
}

.document-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 10px;
}

.document-title {
    font-weight: bold;
    color: var(--primary-color);
    font-size: 1.1rem;
    margin-bottom: 5px;
}

.document-client {
    color: var(--secondary-color);
    font-weight: 500;
    margin-bottom: 5px;
}

.document-meta {
    display: flex;
    gap: 15px;
    font-size: 0.9rem;
    color: #666;
    margin-bottom: 10px;
    flex-wrap: wrap;
}

.document-actions {
    display: flex;
    gap: 10px;
    margin-top: 15px;
    align-items: center;
}

/* ===== STATUS BADGES ===== */
.status-badge {
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: bold;
    text-transform: uppercase;
}

.status-scaduto {
    background: #fed7d7;
    color: #c53030;
}

.status-inscadenza {
    background: #feebc8;
    color: #dd6b20;
}

.status-attivo {
    background: #c6f6d5;
    color: #276749;
}

/* ===== FORMS ===== */
.form-group {
    margin-bottom: 20px;
}

.form-label {
    display: block;
    margin-bottom: 8px;
    font-weight: bold;
    color: var(--primary-color);
}

.form-input, .form-select, .form-textarea {
    width: 100%;
    padding: 12px 15px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 1rem;
    transition: var(--transition);
    background: var(--white);
}

.form-input:focus, .form-select:focus, .form-textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(26, 54, 93, 0.1);
}

.form-textarea {
    resize: vertical;
    min-height: 80px;
}

/* ===== FILE UPLOAD ===== */
.file-input-wrapper {
    position: relative;
    overflow: hidden;
    display: inline-block;
    width: 100%;
}

.file-input-wrapper input[type=file] {
    position: absolute;
    left: 0;
    top: 0;
    opacity: 0;
    width: 100%;
    height: 100%;
    cursor: pointer;
}

.file-input-display {
    padding: 20px;
    border: 2px dashed var(--border-color);
    border-radius: 8px;
    text-align: center;
    background: var(--light-gray);
    transition: var(--transition);
    cursor: pointer;
}

.file-input-wrapper:hover .file-input-display {
    border-color: var(--primary-color);
    background: #f0f4f8;
}

.file-name {
    margin-top: 10px;
    font-size: 0.9rem;
    color: var(--secondary-color);
    font-weight: 500;
}

/* ===== FILTERS ===== */
.filters-section {
    background: var(--white);
    border-radius: var(--border-radius);
    padding: 20px;
    margin-bottom: 25px;
    box-shadow: var(--shadow);
}

.filters-title {
    color: var(--primary-color);
    margin-bottom: 15px;
    font-size: 1.2rem;
    display: flex;
    align-items: center;
    gap: 10px;
}

.filters-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
    margin-bottom: 15px;
}

.filter-group {
    display: flex;
    flex-direction: column;
}

.filter-label {
    font-weight: bold;
    color: var(--secondary-color);
    margin-bottom: 5px;
    font-size: 0.9rem;
}

.filter-select {
    padding: 10px 12px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 0.9rem;
    background: var(--white);
    cursor: pointer;
}

.filter-select:focus {
    outline: none;
    border-color: var(--primary-color);
}

.filter-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    padding-top: 15px;
    border-top: 1px solid var(--border-color);
}

.filter-btn {
    padding: 8px 16px;
    border: none;
    border-radius: 6px;
    font-size: 0.9rem;
    cursor: pointer;
    transition: var(--transition);
}

.filter-btn.apply {
    background: var(--primary-color);
    color: var(--white);
}

.filter-btn.reset {
    background: var(--light-gray);
    color: var(--text-color);
    border: 1px solid var(--border-color);
}

.filter-btn:hover {
    transform: translateY(-1px);
}

/* ===== ACTIVE FILTERS ===== */
.active-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 15px;
}

.filter-tag {
    background: var(--primary-color);
    color: var(--white);
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 0.8rem;
    display: flex;
    align-items: center;
    gap: 5px;
}

.filter-tag .remove {
    background: none;
    border: none;
    color: var(--white);
    cursor: pointer;
    padding: 0;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    transition: var(--transition);
}

.filter-tag .remove:hover {
    background: rgba(255,255,255,0.2);
}

/* ===== MODALS ===== */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0,0,0,0.5);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    padding: 20px;
}

.modal {
    background-color: var(--white);
    border-radius: var(--border-radius);
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
    animation: modalAppear 0.3s ease;
}

@keyframes modalAppear {
    from {
        opacity: 0;
        transform: scale(0.9) translateY(-20px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.modal-header {
    padding: 20px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--light-gray);
    border-radius: var(--border-radius) var(--border-radius) 0 0;
}

.modal-title {
    font-size: 1.3rem;
    color: var(--primary-color);
    margin: 0;
    font-weight: bold;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-color);
    padding: 5px;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: var(--transition);
}

.modal-close:hover {
    background: rgba(0,0,0,0.1);
}

.modal-body {
    padding: 25px;
}

.modal-footer {
    padding: 20px;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
    gap: 15px;
    background: var(--light-gray);
    border-radius: 0 0 var(--border-radius) var(--border-radius);
}

/* ===== ALERTS ===== */
.alert {
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 20px;
    border: 1px solid;
}

.alert-success {
    background: #d4edda;
    color: #155724;
    border-color: #c3e6cb;
}

.alert-error {
    background: #f8d7da;
    color: #721c24;
    border-color: #f5c6cb;
}

.alert-warning {
    background: #fff3cd;
    color: #856404;
    border-color: #ffeaa7;
}

/* ===== EMPTY STATES ===== */
.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: #718096;
}

.empty-state i {
    font-size: 3rem;
    margin-bottom: 15px;
    color: var(--border-color);
}

.empty-state h3 {
    margin-bottom: 10px;
    color: var(--secondary-color);
}

/* ===== TABLES ===== */
.workers-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 10px;
}

.workers-table th {
    background-color: var(--primary-color);
    color: var(--white);
    text-align: left;
    padding: 10px;
    font-size: 0.9rem;
}

.workers-table td {
    padding: 10px;
    border-bottom: 1px solid var(--border-color);
}

/* ===== UTILITY CLASSES ===== */
.hidden {
    display: none !important;
}

.text-center {
    text-align: center;
}

.text-right {
    text-align: right;
}

.mb-0 {
    margin-bottom: 0;
}

.mt-20 {
    margin-top: 20px;
}

.p-0 {
    padding: 0;
}

/* Aggiungi al file style.css */
.desktop-back-btn {
    position: absolute;
    left: 20px;
    top: 50%;
    transform: translateY(-50%);
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 6px;
    padding: 8px 15px;
    cursor: pointer;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 5px;
}

.desktop-back-btn:hover {
    background: var(--secondary-color);
}

/* Assicurati che l'header desktop abbia position relative */
.header.desktop-only {
    position: relative;
}

/* ===== DESKTOP STYLES ===== */
@media (min-width: 1024px) {
    body {
        max-width: 100%;
        padding-bottom: 0;
        display: flex;
        min-height: 100vh;
        box-shadow: none;
        background: var(--light-gray);
    }

    .app-container {
        display: flex;
        width: 100%;
        min-height: 100vh;
        max-width: none;
        box-shadow: none;
        padding-bottom: 0;
    }

    /* SIDEBAR */
    .sidebar {
        width: 280px;
        background: linear-gradient(180deg, var(--primary-color), var(--secondary-color));
        color: var(--white);
        padding: 30px 20px;
        position: fixed;
        height: 100vh;
        left: 0;
        top: 0;
        overflow-y: auto;
    }

    .sidebar-logo {
        max-width: 200px;
        margin-bottom: 40px;
        display: block;
    }

    .user-welcome {
        margin-bottom: 30px;
        padding-bottom: 20px;
        border-bottom: 1px solid rgba(255,255,255,0.2);
    }

    .user-welcome .user-name {
        font-size: 1.1rem;
        font-weight: bold;
    }

    .user-welcome .user-role {
        font-size: 0.9rem;
        opacity: 0.8;
    }

    .nav-menu {
        display: flex;
        flex-direction: column;
        gap: 8px;
    }

    .nav-item-desktop {
        padding: 15px 20px;
        border-radius: 8px;
        cursor: pointer;
        transition: var(--transition);
        display: flex;
        align-items: center;
        gap: 12px;
        font-size: 1rem;
        color: var(--white);
        text-decoration: none;
    }

    .nav-item-desktop:hover {
        background-color: rgba(255,255,255,0.1);
        transform: translateX(5px);
    }

    .nav-item-desktop.active {
        background-color: var(--accent-color);
    }

    .nav-item-desktop i {
        font-size: 1.2rem;
        width: 20px;
        text-align: center;
    }

    /* MAIN CONTENT */
    .main-content {
        flex: 1;
        margin-left: 280px;
        background-color: var(--light-gray);
        min-height: 100vh;
    }

    /* HEADER DESKTOP */
    .header {
        background: var(--white);
        color: var(--text-color);
        padding: 20px 40px;
        text-align: left;
        box-shadow: var(--shadow);
        position: relative;
    }

    .header .logo-text {
        color: var(--primary-color);
        font-size: 1.8rem;
        margin-bottom: 0;
    }

    /* CONTENT GRID */
    .content-grid {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 30px;
        padding: 30px;
    }

    .documents-container {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 30px;
    }

    .main-card {
        margin: 0;
        height: fit-content;
    }

    /* HOME BUTTONS GRID */
    .home-buttons-grid {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 20px;
        margin-top: 20px;
    }

    .home-btn {
        margin-bottom: 0;
        min-height: 120px;
        display: flex;
        flex-direction: column;
        justify-content: center;
        align-items: center;
        text-align: center;
        padding: 20px;
    }

    .home-btn i {
        position: static;
        transform: none;
        margin-bottom: 10px;
        font-size: 2rem;
    }

    /* GRIDS DESKTOP */
    .security-grid {
        grid-template-columns: 1fr 1fr;
        gap: 20px;
    }

    .security-item {
        min-height: 100px;
        padding: 25px 20px 25px 70px;
        display: flex;
        align-items: center;
    }

    .security-item i {
        font-size: 1.5rem;
        left: 25px;
    }

    .documents-grid {
        grid-template-columns: 1fr 1fr 1fr 1fr;
        gap: 20px;
    }

    .doc-item {
        min-height: 120px;
        padding: 30px 15px;
    }

    .attestati-grid {
        grid-template-columns: 1fr 1fr 1fr;
        gap: 15px;
    }

    .attestato-type {
        min-height: 80px;
        padding: 25px 15px;
    }

    /* HIDE MOBILE ELEMENTS */
    .bottom-bar, .back-btn, .user-info, .mobile-only {
        display: none !important;
    }

    .desktop-only {
        display: block !important;
    }
}

/* ===== MOBILE ONLY ===== */
@media (max-width: 1023px) {
    .desktop-only {
        display: none !important;
    }
    
    .mobile-only {
        display: block;
    }
}

/* ===== RESPONSIVE ADJUSTMENTS ===== */
@media (max-width: 380px) {
    .documents-grid {
        grid-template-columns: 1fr;
    }
    
    .attestati-grid {
        grid-template-columns: 1fr 1fr;
    }
    
    .logo {
        max-width: 150px;
    }
    
    .filters-grid {
        grid-template-columns: 1fr;
    }
}

/* ===== PAGE TRANSITIONS ===== */
.page {
    display: none;
    animation: pageFadeIn 0.3s ease;
}

.page.active {
    display: block;
}

@keyframes pageFadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ===== PRINT STYLES ===== */
@media print {
    .bottom-bar, .sidebar, .header .back-btn {
        display: none !important;
    }
    
    body {
        background: white;
        box-shadow: none;
    }
    
    .main-card {
        box-shadow: none;
        border: 1px solid #ccc;
    }
}


/* HEADER MOBILE COMPATTO - VERSIONE FINALE */
.header-mobile-compact {
    background: #2c3e50;
    color: white;
    padding: 14px 18px 12px 18px; /* Più padding sopra e sotto */
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    box-sizing: border-box;
    padding-top: max(14px, env(safe-area-inset-top));
    padding-left: max(18px, env(safe-area-inset-left));
    padding-right: max(18px, env(safe-area-inset-right));
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.header-top-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px; /* Più spazio tra le righe */
}

.header-left {
    display: flex;
    align-items: center;
}

.mobile-logo {
    height: 42px; /* Logo più grande */
    width: auto;
}

/* HAMBURGER CICCIOTTO SENZA SFONDO */
.hamburger-menu {
    display: flex;
    flex-direction: column;
    gap: 6px; /* Più spazio tra le linee */
    cursor: pointer;
    padding: 12px 8px; /* Padding mantenuto per area click */
    border-radius: 6px;
    transition: background 0.3s;
    /* RIMOSSO: background: rgba(255,255,255,0.1); */
}

.hamburger-menu:hover {
    background: rgba(255,255,255,0.1); /* Solo su hover */
}

.hamburger-line {
    width: 28px; /* Ancora più largo */
    height: 3px;
    background: white;
    border-radius: 3px;
    transition: all 0.3s ease;
}

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

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

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

/* SECONDA RIGA HEADER */
.header-bottom-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 14px; /* Testo leggermente più grande */
}

.user-name-compact {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(255,255,255,0.1);
    padding: 8px 14px; /* Più padding */
    border-radius: 18px; /* Border-radius più arrotondato */
    font-weight: 500;
    max-width: 60%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.user-name-compact i {
    font-size: 13px;
    opacity: 0.9;
}

.organigramma-link-compact {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(255,255,255,0.15);
    padding: 8px 14px; /* Più padding */
    border-radius: 18px; /* Border-radius più arrotondato */
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: 500;
    -webkit-tap-highlight-color: rgba(255,255,255,0.2);
}

.organigramma-link-compact:hover {
    background: rgba(255,255,255,0.25);
    transform: translateY(-1px);
}

.organigramma-link-compact i {
    font-size: 13px;
}



/* RESTA INVARIATO IL MENU A TENDINA */
.mobile-menu-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 2000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

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

.mobile-menu-sidebar {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    width: 85%;
    max-width: 300px;
    background: white;
    transform: translateX(100%);
    transition: transform 0.3s ease;
    display: flex;
    flex-direction: column;
    box-shadow: -2px 0 20px rgba(0,0,0,0.1);
}

.mobile-menu-overlay.active .mobile-menu-sidebar {
    transform: translateX(0);
}

/* HEADER DEL MENU */
.menu-header {
    background: #2c3e50;
    color: white;
    padding: 20px;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
}

.user-avatar i {
    font-size: 40px;
    color: rgba(255,255,255,0.9);
}

.user-details {
    flex: 1;
}

.user-name {
    font-weight: 600;
    font-size: 16px;
    margin-bottom: 4px;
}

.user-email {
    font-size: 12px;
    opacity: 0.8;
}

.menu-close-btn {
    background: none;
    border: none;
    color: white;
    font-size: 20px;
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    transition: background 0.3s;
}

.menu-close-btn:hover {
    background: rgba(255,255,255,0.1);
}

/* MENU ITEMS */
.menu-items {
    flex: 1;
    padding: 20px 0;
    overflow-y: auto;
}

.menu-item {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 15px 20px;
    color: #2c3e50;
    text-decoration: none;
    transition: all 0.3s ease;
    border-left: 4px solid transparent;
}

.menu-item:hover {
    background: #f8f9fa;
    border-left-color: #3498db;
    color: #3498db;
}

.menu-item i {
    width: 20px;
    text-align: center;
    font-size: 18px;
}

.menu-item span {
    font-weight: 500;
    font-size: 15px;
}

.menu-divider {
    height: 1px;
    background: #e9ecef;
    margin: 10px 20px;
}

.logout-item {
    color: #e74c3c;
}

.logout-item:hover {
    background: #fff5f5;
    border-left-color: #e74c3c;
    color: #e74c3c;
}

/* RESPONSIVE */
@media (max-width: 480px) {

/* AGGIORNA IL CONTENUTO PRINCIPALE */
.main-content {
    margin-top: 145px; /* Ancora più sicuro */
    margin-top: max(145px, calc(145px + env(safe-area-inset-top)));
}
    .header-mobile-compact {
        padding: 24px 15px 22px 15px;
    }
    
    .mobile-logo {
        height: 38px;
    }
    
    .hamburger-menu {
        padding: 10px 6px;
    }
    
    .hamburger-line {
        width: 26px;
    }
    
    .header-bottom-row {
        font-size: 13px;
    }
    
    .user-name-compact,
    .organigramma-link-compact {
        padding: 7px 12px;
    }
    
    .main-content {
        margin-top: 130px;
    }
}



/* PULSANTE GALLEGGIANTE */
.floating-back-btn {
    bottom: 25px;
    background: #2c3e50;
    color: white;
    border: none;
    padding: 14px 28px;
    border-radius: 30px;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(0,0,0,0.3);
    z-index: 1000;
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 600;
    font-size: 15px;
    transition: all 0.3s ease;
}

.floating-back-btn:hover {
    background: #34495e;
    box-shadow: 0 6px 25px rgba(0,0,0,0.4);
}

.floating-back-btn.hidden {
    display: none;
}


@media (max-width: 768px) {
    .floating-back-btn {
        bottom: 20px;
        padding: 12px 24px;
        font-size: 14px;
        margin: 0 auto;
    }
}



.content-wrapper {
    flex: 1;
    padding: 30px;
    margin: 0 auto;
    width: 100%;
    box-sizing: border-box;
}

/* BOTTOM BACK BAR MOBILE */
.bottom-back-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: #f7fafc;
    padding: 15px 20px;
    box-shadow: 0 -2px 15px rgba(0,0,0,0.2);
    z-index: 999;
    width:100%;
    padding-bottom: max(15px, env(safe-area-inset-bottom));
}

.bottom-back-bar.visible {
    transform: translateY(0);
}

.bottom-back-btn {
    background: #1a365d;opacity:0.8;
    color: white;
    border: none;
    border-radius: 25px;
    padding: 14px 20px;
    width: 100%;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    transition: all 0.3s ease;
}

.bottom-back-btn:hover {
    background: #1a365d;opacity:1;
    transform: translateY(-2px);
}

.bottom-back-btn:active {
    transform: translateY(0);
}

.bottom-back-btn:disabled {
    background: #95a5a6 !important;
    cursor: not-allowed !important;
    transform: none !important;
    box-shadow: none !important;
    opacity: 0.6;
}

.bottom-back-btn:disabled:hover {
    background: #95a5a6 !important;
    transform: none !important;
    box-shadow: none !important;
}

/* Compensa la presenza della bottom bar nel contenuto */
@media (max-width: 1023px) {
    .content-wrapper {
        padding-bottom: 80px;
    }
}

/* Nascondi il floating button su mobile se c'è la bottom bar */
@media (max-width: 768px) {
    .floating-back-btn {
        display: none !important;
    }
}

