/* =====================================================
   Sistema Gestione Rinnovi - Stili CSS Personalizzati
   File: /data/vhosts/dotcomwa.it/app/assets/css/style.css
   Versione: 2.5 - Mobile Header Overlay Fix
   PALETTE DOTCOM: Grigio #4b4b4d + Verde #9ab943
   PALETTE MALDEV: Rosa #ea265a
   
   CHANGELOG v2.5:
   - Fix header mobile si nasconde quando sidebar aperta
   - Previene sovrapposizione header su menu mobile
   ===================================================== */

/* Import Google Fonts - Montserrat */
@import url('https://fonts.googleapis.com/css2?family=Montserrat:wght@400;500;600;700&display=swap');

/* Reset e Base */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary: #9ab943;
    --primary-dark: #7a9535;
    --secondary: #4b4b4d;
    --secondary-light: #6b6b6d;
    --maldev: #ea265a;
    --maldev-light: #f8cdd8;
    --success: #9ab943;
    --danger: #dc2626;
    --warning: #f59e0b;
    --light: #f8fafc;
    --dark: #2d2d2f;
    --border: #e2e8f0;
    --text: #334155;
    --text-light: #64748b;
}

body {
    font-family: 'Montserrat', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 15px;
    font-weight: 400;
    line-height: 1.6;
    color: var(--text);
    background: var(--light);
}

/* =====================================================
   MOBILE HEADER & HAMBURGER MENU
   ===================================================== */

.mobile-header {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 60px;
    background: var(--secondary);
    color: white;
    z-index: 1000;
    padding: 0 15px;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

.hamburger-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
    display: flex;
    flex-direction: column;
    gap: 5px;
    transition: transform 0.3s ease;
}

.hamburger-btn span {
    display: block;
    width: 25px;
    height: 3px;
    background: white;
    border-radius: 3px;
    transition: all 0.3s ease;
}

.hamburger-btn.active span:nth-child(1) {
    transform: rotate(45deg) translate(7px, 7px);
}

.hamburger-btn.active span:nth-child(2) {
    opacity: 0;
}

.hamburger-btn.active span:nth-child(3) {
    transform: rotate(-45deg) translate(7px, -7px);
}

.mobile-logo img {
    height: 30px;
    width: auto;
}

.mobile-user {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--primary);
    color: var(--dark);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 13px;
    text-transform: uppercase;
}

.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 998;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.sidebar-overlay.active {
    display: block;
    opacity: 1;
}

.sidebar-close {
    display: none; /* Nascosto su desktop */
    position: absolute;
    top: 15px;
    right: 15px;
    background: transparent;
    border: none;
    color: white;
    cursor: pointer;
    padding: 5px;
    z-index: 10;
    transition: transform 0.2s ease;
}

.sidebar-close:hover {
    transform: rotate(90deg);
}

.sidebar-close svg {
    display: block;
}

/* Mostra pulsante X SOLO su mobile */
@media (max-width: 576px) {
    .sidebar-close {
        display: block;
    }
}

/* Layout */
.wrapper {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: 250px;
    background: var(--secondary);
    color: white;
    padding: 0;
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    overflow-y: auto;
    transition: transform 0.3s ease;
    z-index: 999;
}

.sidebar-header {
    padding: 30px 20px 20px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    text-align: center;
}

.sidebar-header .logo {
    display: block;
    margin: 0 auto 15px;
    max-width: 140px;
    height: auto;
}

.sidebar-header h2 {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 5px;
    color: white;
}

.sidebar-header p {
    font-size: 12px;
    font-weight: 400;
    color: rgba(255,255,255,0.7);
}

.sidebar-nav {
    margin-top: 20px;
    padding: 0 0 100px 0; /* Padding bottom per non essere coperto dal footer fisso */
}

.sidebar-nav a {
    display: block;
    padding: 14px 20px;
    color: rgba(255,255,255,0.8);
    text-decoration: none;
    transition: all 0.2s;
    font-weight: 500;
    font-size: 14px;
}

.sidebar-nav a:hover {
    background: var(--secondary-light);
    color: white;
    padding-left: 25px;
}

.sidebar-nav a.active {
    background: var(--primary);
    color: var(--dark);
    font-weight: 600;
    border-left: 4px solid var(--dark);
}

.sidebar-footer {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 250px;
    padding: 20px;
    border-top: 1px solid rgba(255,255,255,0.1);
    background: var(--dark);
    z-index: 1000;
}

.sidebar-footer p {
    margin-bottom: 10px;
    font-size: 13px;
}

.sidebar-footer a {
    color: var(--primary);
    text-decoration: none;
    font-weight: 600;
    transition: color 0.2s;
}

.sidebar-footer a:hover {
    color: white;
}

/* Main Content */
.main-content {
    flex: 1;
    margin-left: 250px;
    padding: 30px;
    min-height: 100vh;
    width: calc(100% - 250px);
    transition: margin-left 0.3s ease;
}

.page-header {
    margin-bottom: 30px;
}

.page-header h1 {
    font-size: 28px;
    font-weight: 700;
    margin-bottom: 5px;
    color: var(--secondary);
}

.page-header p {
    color: var(--text-light);
    font-weight: 400;
}

/* Cards */
.card {
    background: white;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    padding: 20px;
    margin-bottom: 20px;
    overflow: visible;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 2px solid var(--primary);
}

.card-header h3 {
    font-size: 18px;
    font-weight: 600;
    color: var(--secondary);
}

.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
}

.stat-card {
    background: white;
    border-radius: 8px;
    padding: 25px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.08);
    border-top: 3px solid var(--primary);
    transition: transform 0.2s, box-shadow 0.2s;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.12);
}

.stat-card .label {
    font-size: 12px;
    color: var(--text-light);
    text-transform: uppercase;
    font-weight: 600;
    letter-spacing: 0.5px;
    margin-bottom: 10px;
}

.stat-card .value {
    font-size: 32px;
    font-weight: 700;
    color: var(--primary);
}

/* Buttons */
.btn {
    display: inline-block;
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    font-family: 'Montserrat', sans-serif;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.2s;
}

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

.btn-primary:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

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

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

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

.btn-secondary:hover {
    background: var(--secondary-light);
}

.btn-small {
    padding: 6px 14px;
    font-size: 13px;
}

.btn-block {
    display: block;
    width: 100%;
}

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

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

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 10px 12px;
    border: 2px solid var(--border);
    border-radius: 6px;
    font-size: 14px;
    font-family: 'Montserrat', sans-serif;
    transition: border-color 0.2s;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary);
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
}

/* Tables */
.table {
    width: 100%;
    border-collapse: collapse;
    background: white;
}

.table th,
.table td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.table th {
    background: var(--light);
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    color: var(--secondary);
    letter-spacing: 0.5px;
}

.table tr:hover {
    background: #f0fde4;
}

/* Badges */
.badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
}

.badge-success {
    background: #e8f5d1;
    color: #7a9535;
}

.badge-warning {
    background: #fef3c7;
    color: #f59e0b;
}

.badge-danger {
    background: #fee2e2;
    color: var(--danger);
}

.badge-info {
    background: #e5e5e6;
    color: var(--secondary);
}

/* Badge Maldev - Colore aggiornato */
.badge-maldev {
    background: var(--maldev-light);
    color: var(--maldev);
}

/* Badge Note - Stile per contatore note progetti */
.badge-note {
    background: #dbeafe;
    color: #1e40af;
    padding: 5px 12px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
    text-decoration: none;
    display: inline-block;
    transition: all 0.2s;
}

.badge-note:hover {
    background: #bfdbfe;
    color: #1e3a8a;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(30, 64, 175, 0.2);
}

/* Alerts */
.alert {
    padding: 15px;
    border-radius: 6px;
    margin-bottom: 20px;
    font-weight: 500;
}

.alert-success {
    background: #e8f5d1;
    color: #5a7328;
    border-left: 4px solid var(--primary);
}

.alert-error {
    background: #fee2e2;
    color: var(--danger);
    border-left: 4px solid var(--danger);
}

.alert-info {
    background: #e5e5e6;
    color: var(--secondary);
    border-left: 4px solid var(--secondary);
}

/* Login Page */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: linear-gradient(135deg, var(--secondary) 0%, var(--dark) 100%);
}

.login-container {
    width: 100%;
    max-width: 400px;
    padding: 20px;
}

.login-box {
    background: white;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.3);
    padding: 40px;
    border-top: 4px solid var(--primary);
}

.login-header {
    text-align: center;
    margin-bottom: 30px;
}

.login-header h1 {
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 5px;
    color: var(--secondary);
}

.login-header p {
    color: var(--text-light);
    font-size: 14px;
    font-weight: 400;
}

.login-form {
    margin-bottom: 20px;
}

.login-footer {
    text-align: center;
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid var(--border);
}

.login-footer small {
    color: var(--text-light);
}

/* Utilities */
.text-right {
    text-align: right;
}

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

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

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

.mb-20 {
    margin-bottom: 20px;
}

.flex {
    display: flex;
}

.flex-between {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.gap-10 {
    gap: 10px;
}

/* =====================================================
   RESPONSIVE DESIGN
   ===================================================== */

/* Tablet */
@media (max-width: 768px) {
    .sidebar {
        width: 220px;
    }
    
    .main-content {
        margin-left: 220px;
        padding: 20px;
    }
    
    .card-grid {
        grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    }
    
    .page-header h1 {
        font-size: 24px;
    }
}

/* Mobile */
@media (max-width: 576px) {
    /* Mostra mobile header */
    .mobile-header {
        display: flex;
    }
    
    /* Mostra pulsante chiusura sidebar */
    .sidebar-close {
        display: block;
    }
    
    /* Sidebar nascosta di default su mobile */
    .sidebar {
        transform: translateX(-100%);
        width: 280px;
        max-width: 85vw;
    }
    
    /* Sidebar aperta */
    .sidebar.active {
        transform: translateX(0);
    }
    
    /* Main content a tutta larghezza */
    .main-content {
        margin-left: 0;
        padding: 120px 15px 20px 15px; /* Aumentato a 120px per non coprire titoli */
        width: 100%;
    }
    
    /* Sidebar nav - padding normale */
    .sidebar-nav {
        padding-bottom: 20px; /* Padding normale - footer scorre con il menu */
    }
    
    /* Sidebar footer NON fisso su mobile - scorre con il menu */
    .sidebar-footer {
        position: relative; /* Era fixed - ora scorre */
        width: 100%;
        max-width: 100%;
        bottom: auto;
        left: auto;
    }
    
    /* INPUT FIX iOS - Font-size 16px per prevenire zoom */
    .form-group input,
    .form-group select,
    .form-group textarea {
        font-size: 16px !important; /* CRITICO per iOS */
        padding: 12px; /* Padding maggiore per touch */
    }
    
    /* Cards stack su mobile */
    .card-grid {
        grid-template-columns: 1fr;
        gap: 15px;
    }
    
    .stat-card {
        padding: 20px;
    }
    
    .stat-card .value {
        font-size: 28px;
    }
    
    /* Page header ridotto */
    .page-header {
        margin-bottom: 20px;
    }
    
    .page-header h1 {
        font-size: 22px;
    }
    
    /* Cards con meno padding */
    .card {
        padding: 15px;
    }
    
    /* Form a colonna singola */
    .form-row {
        grid-template-columns: 1fr;
        gap: 15px;
    }
    
    /* Bottoni full width su mobile */
    .btn {
        width: 100%;
        text-align: center;
    }
    
    /* Tabelle scrollabili */
    .table-responsive {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    .table {
        font-size: 13px;
    }
    
    .table th,
    .table td {
        padding: 8px;
        font-size: 12px;
    }
}

/* Extra small devices */
@media (max-width: 375px) {
    .main-content {
        padding: 70px 10px 15px 10px;
    }
    
    .page-header h1 {
        font-size: 20px;
    }
    
    .stat-card .value {
        font-size: 24px;
    }
}

/* =====================================================
   MOBILE HEADER FIX - v2.5
   Nasconde header mobile quando sidebar aperta
   ===================================================== */
@media (max-width: 576px) {
    
    /* Header mobile si nasconde quando menu aperto */
    body.menu-open .mobile-header {
        transform: translateY(-100%);
        opacity: 0;
    }
    
    /* Transizione smooth header mobile */
    .mobile-header {
        transition: transform 0.3s ease, opacity 0.3s ease;
    }
    
    /* Sidebar inizia da top quando header nascosto */
    body.menu-open .sidebar {
        top: 0;
        height: 100vh;
    }
    
    /* Z-index corretto */
    .sidebar.active {
        z-index: 1000;
    }
    
    .mobile-header {
        z-index: 999; /* Più basso della sidebar attiva */
    }
}