/* Life Organizer - Stili Globali e Tema Dark */
:root {
    --bg-primary: #0f0f23;
    --bg-secondary: #1a1a2e;
    --bg-card: #242440;
    --bg-hover: #2d2d44;
    --text-primary: #e8eaf6;
    --text-secondary: #b0b3c1;
    --accent: #667eea;
    --accent-hover: #5a67d8;
    --success: #10b981;
    --danger: #ef4444;
    --border: #33334d;
    --border-light: #44445f;
}

* {
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
    margin: 0;
    padding: 0;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
}

/* Header */
header {
    background: linear-gradient(135deg, var(--accent), #764ba2);
    padding: 1.5rem;
    box-shadow: 0 4px 20px rgba(0,0,0,0.3);
}

header h1 {
    margin: 0 0 1rem 0;
    font-size: 1.8rem;
    font-weight: 700;
    letter-spacing: -0.025em;
}

/* Navbar */
nav {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
}

nav a {
    color: var(--text-primary);
    text-decoration: none;
    padding: 0.5rem 1rem;
    border-radius: 8px;
    font-weight: 500;
    transition: all 0.2s ease;
    background: rgba(255,255,255,0.1);
    backdrop-filter: blur(10px);
}

nav a:hover {
    background: rgba(255,255,255,0.2);
    transform: translateY(-1px);
}

/* Main */
main {
    max-width: 1200px;
    margin: 2rem auto;
    padding: 0 1.5rem;
}

/* Section */
section {
    background: var(--bg-card);
    padding: 2rem;
    margin-bottom: 2rem;
    border-radius: 12px;
    border: 1px solid var(--border);
    box-shadow: 0 8px 32px rgba(0,0,0,0.2);
}

section h2 {
    color: var(--text-primary);
    margin: 0 0 1.5rem 0;
    font-size: 1.4rem;
    font-weight: 600;
    border-bottom: 2px solid var(--border-light);
    padding-bottom: 0.5rem;
}

section h3 {
    color: var(--text-secondary);
    font-size: 1.1rem;
    margin: 1.5rem 0 0.75rem 0;
}

/* Form */
form {
    display: grid;
    gap: 1.25rem;
    max-width: 600px;
}

label {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    font-weight: 500;
    color: var(--text-secondary);
    font-size: 0.95rem;
}

input, textarea, select {
    padding: 0.875rem 1rem;
    border: 1px solid var(--border-light);
    border-radius: 8px;
    font-size: 1rem;
    background: var(--bg-secondary);
    color: var(--text-primary);
    transition: all 0.2s ease;
}

input:focus, textarea:focus, select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
    background: var(--bg-card);
}

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

/* Option style (dropdown) */
option {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

/* Buttons */
button {
    background: linear-gradient(135deg, var(--accent), var(--accent-hover));
    color: white;
    border: none;
    padding: 1rem 2rem;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    font-size: 1rem;
    transition: all 0.2s ease;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
}

button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
}

button:active {
    transform: translateY(0);
}

/* Home: summary cards */
#home-summary {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
gap: 1.5rem;
margin-top: 1rem;
}

.summary-card {
    background: linear-gradient(135deg, var(--accent), var(--accent-hover));
    padding: 2rem;
    border-radius: 12px;
    text-align: center;
    color: white;
}

.summary-card h3 {
    font-size: 2.5rem;
    margin: 0 0 0.5rem 0;
    font-weight: 700;
    color: white;
    border: none;
}

.summary-card p {
    margin: 0;
    opacity: 0.9;
}

/* Responsive */
@media (max-width: 768px) {
    main {
        padding: 0 1rem;
        margin: 1rem auto;
    }
    nav {
        flex-direction: column;
    }
    section {
        padding: 1.25rem;
    }
}

/* =========================================
 *   RESPONSIVE DESIGN (Smartphone & Tablet)
 *   ========================================= */

/* 1. Protezione globale per TUTTI gli input e le textarea */
input, select, textarea {
    max-width: 100%; /* Non potranno mai sbordare fuori dallo schermo */
    box-sizing: border-box; /* Calcola bordi e padding dentro la larghezza totale */
}

/* Stile per la classe attiva nel menu */
.active-nav {
    font-weight: bold;
    text-decoration: underline;
    color: var(--accent);
}

/* 2. Layout dell'Header */
.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap; /* Permette agli elementi di andare a capo se non c'è spazio */
    padding: 0 1rem;
}

#main-header nav {
display: flex;
gap: 1rem;
align-items: center;
flex-wrap: wrap;
width: 100%;
}

/* Nascondiamo l'hamburger di default (su PC) */
.hamburger-btn {
    display: none;
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-size: 1.8rem;
    cursor: pointer;
    padding: 0.5rem;
}

/* 3. COSA SUCCEDE SU SCHERMI PICCOLI (Meno di 768px di larghezza) */
@media (max-width: 768px) {

    /* L'header diventa una striscia fissa in alto */
    #main-header {
    padding: 0.5rem;
    position: sticky; /* Rimane in alto mentre scorri la pagina */
    top: 0;
    z-index: 1000;
    box-shadow: 0 4px 10px rgba(0,0,0,0.1);
    }

    .header-content h1 {
        font-size: 1.2rem;
        margin: 0;
    }

    /* Mostriamo il bottone Hamburger */
    .hamburger-btn {
        display: block;
    }

    /* Trasformiamo il menu orizzontale in un menu a tendina verticale e NASCOSTO */
    #main-header nav {
    display: none; /* Nascosto di default */
    flex-direction: column;
    width: 100%;
    margin-top: 1rem;
    background: var(--bg-card);
    padding: 1rem 0;
    border-radius: 8px;
    }

    /* Quando clicchi l'hamburger, JS aggiunge la classe .open che lo fa apparire */
    #main-header nav.open {
    display: flex;
    }

    /* I link del menu da smartphone saranno larghi, comodi da cliccare col dito */
    #main-header nav a, #btn-logout {
    width: 100%;
    text-align: center;
    padding: 0.8rem 0;
    border-bottom: 1px solid var(--border);
    margin: 0 !important; /* Rimuove il margin-left di logout */
    border-radius: 0;
    }

    /* Aggiustamenti per i layout a griglia che si rompevano */
    .input-grid {
        grid-template-columns: 1fr; /* Mette gli input uno sotto l'altro su mobile */
    }

    /* Rimpicciolisce un po' i font grandi delle dashboard */
    .macro-dashboard {
        flex-direction: column;
        padding: 1rem;
    }
    /* ======== CORREZIONI RESPONSIVE PER TUTTE LE PAGINE ======== */

    /* 1. Forza tutte le card a prendere il 100% dello spazio e toglie margini eccessivi */
    .container {
        padding: 10px; /* Riduce i margini laterali vuoti su mobile */
        overflow-x: hidden; /* Taglia via brutalmente qualsiasi cosa cerchi di uscire di lato */
    }

    /* 2. Le griglie affiancate diventano incolonnate (es. Diet, One-time expenses) */
    .diet-grid,
    .expenses-grid,
    .relationships-grid {
        grid-template-columns: 1fr !important;
        gap: 1rem;
    }

    /* 3. Immagini fluide (non possono mai essere più larghe dello schermo) */
    img {
        max-width: 100% !important;
        height: auto !important;
    }

    /* 4. Le tabelle delle spese: si adattano permettendo lo scroll orizzontale SOLO sulla tabella */
    /* Se hai un div attorno alla tabella, questo lo renderà scrollabile */
    table {
        display: block;
        width: 100%;
        overflow-x: auto;
        white-space: nowrap; /* Evita che il testo delle celle si accavalli male */
    }

    /* 5. Le finestre modali (come il Login o i Pop-up) che escono dallo schermo */
    #auth-overlay > div {
    width: 90% !important; /* Invece di 350px fissi */
    padding: 1.5rem !important;
    }

    /* 6. I bottoni affiancati vengono incolonnati */
    .btn-group,
    .actions-row {
        display: flex;
        flex-direction: column;
        gap: 0.5rem;
        width: 100%;
    }

    .btn {
        width: 100%; /* I bottoni prendono tutta la larghezza per esser premuti meglio col pollice */
        margin-bottom: 5px;
    }

    /* 7. Forza i testi lunghi ad andare a capo (es. link lunghi nel diario) */
    p, span, div {
        word-wrap: break-word;
        overflow-wrap: break-word;
    }

}
/* Container per rendere scrollabili tabelle larghe su mobile */
.table-responsive {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch; /* Rende lo scroll fluido su iPhone */
    margin-bottom: 1rem;
}

/* Rimuovi questo pezzo se lo avevi aggiunto prima, perché la regola sopra è molto più pulita */
/*
 * table {
 *  display: block;
 *  width: 100%;
 *  overflow-x: auto;
 * }
 */

