:root {
    --dark-blue: #2c3e50;
    --sidebar-bg: #1a252f;
    --accent-blue: #3498db;
    --success-green: #2ecc71;
    --danger-red: #e74c3c;
    --warning-yellow: #f1c40f;
    --ig-color: #E1306C;
}

body {
    font-family: 'Segoe UI', sans-serif;
    margin: 0;
    display: flex;
    height: 100vh;
    background: #f4f6f9;
    color: #333;
    overflow: hidden;
}

/* Sidebar */
.sidebar {
    width: 260px;
    flex-shrink: 0;
    background: var(--dark-blue);
    color: white;
    display: flex;
    flex-direction: column;
    box-shadow: 2px 0 10px rgba(0, 0, 0, 0.1);
    z-index: 10;
}

.sidebar-header {
    padding: 20px;
    background: var(--sidebar-bg);
    text-align: center;
    border-bottom: 1px solid #34495e;
    min-height: 80px;
    display: flex;
    align-items: center;
}

.menu {
    list-style: none;
    padding: 0;
    margin: 20px 0;
    flex-grow: 1;
    overflow-y: auto;
}

.menu li {
    padding: 15px 25px;
    cursor: pointer;
    transition: 0.2s;
    border-left: 4px solid transparent;
    font-size: 0.95em;
}

.menu li:hover {
    background: #34495e;
}

.menu li.active {
    background: var(--accent-blue);
    border-left-color: white;
    font-weight: bold;
}

.planning-tab {
    color: #9b59b6;
    font-weight: bold;
    border-top: 1px solid #34495e;
    margin-top: 20px;
}

.president-tab {
    color: #f1c40f;
    font-weight: bold;
    border-top: 1px solid #34495e;
    margin-top: 5px;
}

/* Main */
.main-content {
    flex: 1;
    min-width: 0;
    padding: 30px;
    overflow-y: auto;
    position: relative;
}

.dashboard-card {
    background: white;
    padding: 30px;
    border-radius: 12px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
    margin-bottom: 30px;
}

h2 {
    margin: 0 0 20px 0;
    color: var(--dark-blue);
    border-bottom: 2px solid #eee;
    padding-bottom: 15px;
}

h3 {
    color: var(--dark-blue);
}

.header-flex {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    flex-wrap: wrap;
    gap: 10px;
}

.sezione {
    display: none;
}

.sezione.attiva {
    display: block;
}

/* Buttons & Inputs */
.toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    gap: 10px;
    flex-wrap: wrap;
}

.btn-group {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.btn {
    padding: 8px 15px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    color: white;
    font-weight: 600;
    font-size: 0.85em;
    transition: 0.2s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn-sm {
    padding: 5px 10px;
    font-size: 0.8em;
}

.btn-blu {
    background: var(--accent-blue);
}

.btn-verde {
    background: var(--success-green);
}

.btn-arancio {
    background: #e67e22;
}

.btn-rosso {
    background: var(--danger-red);
}

.btn-add {
    background: #cbd5e0;
    color: #2c3e50;
    padding: 4px 10px;
    border-radius: 4px;
    float: right;
    font-weight: bold;
}

.btn-add:hover {
    background: var(--accent-blue);
    color: white;
}

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

.close-btn {
    background-color: var(--danger-red);
    color: white;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    font-size: 18px;
    font-weight: bold;
    margin-left: 20px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
    transition: 0.2s;
}

.close-btn:hover {
    transform: scale(1.1);
    background-color: #c0392b;
}

.search-bar {
    padding: 10px 15px;
    width: 300px;
    max-width: 100%;
    border: 1px solid #ddd;
    border-radius: 8px;
    outline: none;
}

.input-std {
    padding: 8px 12px;
    border-radius: 6px;
    border: 1px solid #ddd;
    width: 100%;
    box-sizing: border-box;
    font-family: inherit;
    margin-top: 4px;
    color: #333;
    font-size: 16px;
    /* <-- AGGIUNTO: Impedisce l'auto-zoom su iPhone */
    max-width: 100%;
    /* <-- AGGIUNTO: Impedisce al campo di sbordare */
}

.input-std:disabled {
    background-color: #f5f5f5;
    color: #777;
    cursor: not-allowed;
    border-color: #eee;
}

/* Tabelle */
.table-responsive {
    overflow-x: auto;
    width: 100%;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th {
    background: #f8f9fa;
    color: #7f8c8d;
    padding: 12px 15px;
    text-align: left;
    font-size: 0.8em;
    text-transform: uppercase;
    border-bottom: 2px solid #eee;
}

td {
    padding: 12px 15px;
    border-bottom: 1px solid #f1f1f1;
    font-size: 0.95em;
    vertical-align: middle;
}

.th-sort {
    cursor: pointer;
    user-select: none;
}

tr:hover {
    background: #f9fbff;
}

.table-sm th,
.table-sm td {
    padding: 8px 10px;
    font-size: 0.9em;
}

.text-truncate {
    max-width: 200px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: inline-block;
    vertical-align: middle;
    color: #7f8c8d;
    font-style: italic;
}

/* Quote Cards */
.quote-config-container {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
}

.quote-card-modern {
    background: white;
    border: 1px solid #ddd;
    border-radius: 12px;
    padding: 20px;
    min-width: 180px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.03);
    border-top: 5px solid var(--accent-blue);
    text-align: center;
}

.quote-card-modern h4 {
    margin: 0 0 10px 0;
    color: var(--dark-blue);
    font-size: 1.1em;
}

.quote-card-modern .price {
    font-size: 1.8em;
    font-weight: bold;
    color: var(--success-green);
    margin-bottom: 15px;
}

/* Eventi Planning & Note Direttivo */
.eventi-container {
    display: flex;
    gap: 15px;
    overflow-x: auto;
    padding: 10px 0;
}

.mese-column {
    background: #edf2f7;
    border-radius: 8px;
    padding: 15px;
    min-width: 240px;
    min-height: 150px;
    flex-shrink: 0;
    border: 2px dashed transparent;
}

.mese-column h4 {
    color: var(--dark-blue);
    margin: 0 0 10px 0;
    border-bottom: 1px solid #cbd5e0;
    padding-bottom: 5px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.mese-column.drag-over {
    border-color: var(--accent-blue);
    background: #e1f0fa;
}

.event-card {
    background: white;
    padding: 12px;
    border-radius: 6px;
    margin-bottom: 8px;
    cursor: pointer;
    border-left: 5px solid #ccc;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    transition: 0.2s;
    font-weight: bold;
}

.event-card:hover {
    transform: scale(1.02);
}

.event-card.bozza {
    border-left-color: #bdc3c7;
    border-style: dashed;
}

.event-card.ufficiale {
    border-left-color: var(--success-green);
}

.note-card {
    background: white;
    padding: 15px;
    border-left: 4px solid var(--warning-yellow);
    border-radius: 8px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
}

/* Badges & Colors (MODIFICATI) */
.badge {
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.75em;
    font-weight: bold;
    color: white;
    display: inline-block;
    text-decoration: none;
}

.badge-pagato {
    background: var(--success-green);
}

.badge-attesa {
    background: var(--warning-yellow);
    color: #333;
}

.badge-scaduto {
    background: var(--danger-red);
}

.badge-carica {
    background: #edf2f7;
    color: #4a5568;
    border: 1px solid #cbd5e0;
}

.badge-ig {
    background: var(--ig-color);
    cursor: pointer;
}

/* Cariche */
.badge-presidente {
    background: #f1c40f;
    color: #333;
}

/* Oro */
.badge-vice {
    background: #bdc3c7;
    color: #333;
}

/* Argento */
.badge-direttivo {
    background: #d35400;
    color: white;
}

/* Rame/Bronzo */
.badge-socio {
    background: var(--accent-blue);
    color: white;
}

/* Azzurro */
.badge-esterno {
    background: #e67e22;
    color: white;
}

/* Arancione */

/* Tipi Evento */
.badge-tipo-foto {
    background: #f1c40f;
    color: #333;
}

/* Giallo */
.badge-tipo-social {
    background: #2ecc71;
    color: white;
}

/* Verde */
.badge-tipo-mix {
    background: var(--accent-blue);
    color: white;
}

/* Azzurro */

.inaff-0 {
    background-color: #95a5a6;
    color: white;
}

.inaff-ok {
    background-color: #2ecc71;
    color: white;
}

.inaff-low {
    background-color: #f1c40f;
    color: #333;
}

.inaff-med {
    background-color: #e67e22;
    color: white;
}

.inaff-high {
    background-color: #e74c3c;
    color: white;
}

.text-success {
    color: var(--success-green) !important;
    font-weight: bold;
}

.text-danger {
    color: var(--danger-red) !important;
    font-weight: bold;
}

/* Cassa & Admin */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 20px;
}

.stat-card {
    background: white;
    padding: 20px;
    border-radius: 12px;
    text-align: center;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.05);
}

.stat-card.dark {
    background: var(--dark-blue);
    color: white;
}

.cassa-flex {
    display: flex;
    gap: 20px;
    align-items: flex-start;
}

.cassa-main {
    flex: 2;
    min-width: 300px;
}

/* Grafico Cassa Sticky (MODIFICATO) */
.cassa-side {
    flex: 1;
    min-width: 300px;
    position: sticky;
    top: 30px;
    background: white;
    padding: 20px;
    border-radius: 12px;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.05);
    display: flex;
    flex-direction: column;
    align-items: center;
}

@media (max-width: 800px) {
    .cassa-flex {
        flex-direction: column;
    }

    .cassa-side {
        position: relative;
        top: 0;
        width: auto;
    }
}

.admin-box.danger {
    border-left: 5px solid var(--danger-red);
}

.admin-box.full {
    grid-column: 1 / -1;
}

.table-admin {
    font-size: 0.9em;
    margin-top: 15px;
}

/* Modal General */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(3px);
}

.modal-content {
    background: white;
    margin: 4% auto;
    padding: 30px;
    width: 90%;
    max-width: 900px;
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    max-height: 90vh;
    overflow-y: auto;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 2px solid #eee;
    padding-bottom: 10px;
    margin-bottom: 20px;
}

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

.info-box div {
    padding: 5px 0;
}

.info-box b {
    color: var(--dark-blue);
    font-weight: 700;
}

/* Stile del Pulsante Hamburger (Nascosto su PC) */
#menu-toggle {
    display: none;
    background: var(--dark-blue);
    color: white;
    padding: 10px 15px;
    font-size: 1.2em;
    font-weight: bold;
    cursor: pointer;
    border-radius: 6px;
    margin-bottom: 20px;
    text-align: center;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

/* Regole per Smartphone e Tablet (schermi stretti) */
@media (max-width: 900px) {

    /* 1. Allarghiamo la visuale togliendo i margini enormi del PC */
    .main-content {
        padding: 15px !important;
    }

    .dashboard-card {
        padding: 15px !important;
    }

    /* 2. Mostriamo il tasto Hamburger */
    #menu-toggle {
        display: block;
    }

    /* 3. Nascondiamo il menu laterale fuori dallo schermo (a sinistra) */
    .sidebar {
        position: fixed;
        left: -300px;
        top: 0;
        height: 100vh;
        transition: left 0.3s ease;
        /* Effetto scivolamento */
        box-shadow: 5px 0 15px rgba(0, 0, 0, 0.5);
    }

    /* 4. Classe che aggiungeremo col JS per far entrare il menu */
    .sidebar.open {
        left: 0;
    }

    /* 5. Aggiustiamo i form di Login/Registrazione per riempire lo schermo */
    #form-registrazione,
    #form-accesso {
        padding: 25px !important;
        width: 85% !important;
        max-width: 350px !important;
        box-sizing: border-box !important;
        margin: 0 auto !important;
    }
}

.admin-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
    align-items: stretch;
}

.admin-box {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    min-height: 150px;
}

/* BOTTOM NAVIGATION BAR (Stile Instagram) */
.bottom-nav {
    display: none;
    /* Nascosta di default su PC */
}

@media (max-width: 900px) {
    .bottom-nav {
        display: flex;
        position: fixed;
        bottom: 0;
        left: 0;
        width: 100%;
        background: white;
        box-shadow: 0 -4px 15px rgba(0, 0, 0, 0.05);
        justify-content: space-around;
        padding: 10px 0 20px 0;
        /* Padding extra per la barra home di iPhone */
        z-index: 9999;
        border-top: 1px solid #f1f1f1;
    }

    .b-nav-item {
        text-align: center;
        color: #bdc3c7;
        cursor: pointer;
        flex: 1;
        transition: 0.2s;
    }

    .b-nav-item.active {
        color: var(--accent-blue);
    }

    .b-nav-item.active #nav-profile-pic {
        border: 2px solid var(--accent-blue);
        background: white;
    }

    #nav-profile-pic {
        border: 2px solid transparent;
        transition: 0.2s;
    }

    /* Facciamo spazio in fondo alla pagina per non coprire il testo con la barra */
    .main-content {
        padding-bottom: 100px !important;
    }

    /* Il menu hamburger di default sparisce, lo governa lo script.js in base ai permessi */
    #menu-toggle {
        display: none;
    }
}