/* ==========================================================================
   1. VARIABILI GLOBALI (Tema Minimal / Bacco)
   ========================================================================== */
:root {
    /* Palette Vigneti / Natura */
    --primary: #2e5a3a;       /* Verde vigna scuro */
    --primary-hover: #244a31; /* Verde più scuro per hover */
    --secondary: #7a5b33;     /* Terra / marrone vigneto */
    --accent: #c7a23a;        /* Oro paglierino (grappolo/sole) */
    background: var(--surface);
    border-bottom: 1px solid var(--border-light);
    /* Sfondi e Superfici - tonalità naturali, meno grigio neutro */
    --bg-body: #eef4ea;       /* morbido verde-paglia chiaro */
    --surface: #f9f8f6;       /* superficie calda, quasi panna */
    --border-light: #e2e6e0;

    /* Testi */
    --text-main: #263227;     /* verde scuro quasi nero */
    --text-muted: #6b6b57;
    
    /* Forme e Ombre (Minimal design) */
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --shadow-soft: 0 4px 20px rgba(38,50,39,0.06);
    --shadow-hover: 0 8px 24px rgba(38,50,39,0.12);
}

/* ==========================================================================
   2. RESET & BASE
   ========================================================================== */
*, *::before, *::after {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    color: var(--text-main);
    background-color: var(--bg-body);
    min-height: 100vh;
    line-height: 1.5;
}

a {
    color: var(--primary);
    text-decoration: none;
    transition: color 0.2s ease;
}

a:hover {
    color: var(--secondary);
}

/* ==========================================================================
   3. BOTTONI & INPUTS (Stile Professionale e Proporzionato)
   ========================================================================== */
button, 
.btn,
.bacco-login__submit,
.hide-show-btn,
.filter-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: fit-content; /* Il bottone si adatta al testo, non prende tutta la pagina */
    padding: 10px 24px;
    font-size: 0.95rem;
    font-weight: 600;
    color: #fff;
    background-color: var(--primary);
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 2px 6px rgba(46, 90, 58, 0.12);
}

button:hover,
.bacco-login__submit:hover {
    background-color: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: var(--shadow-hover);
}

.filter-button {
    margin-right: 8px;
    background-color: #fff;
    color: var(--text-main);
    border: 1px solid var(--border-light);
    box-shadow: none;
}

.filter-button:hover {
    background-color: var(--bg-body);
    border-color: var(--text-muted);
}

/* Restituiamo una larghezza intera SOLO al bottone di login dentro la card */
.bacco-login__submit {
    width: 100%; 
    padding: 14px 24px;
    font-size: 1rem;
    border-radius: var(--radius-md);
    margin-top: 10px;
}

input:is([type="text"], [type="email"], [type="password"]) {
    width: 100%;
    min-height: 46px; /* Altezza elegante, non più 54px enormi */
    padding: 12px 16px;
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
    font-size: 0.95rem;
    background: #fff;
    color: var(--text-main);
    transition: all 0.2s ease;
}

input:is([type="text"], [type="email"], [type="password"]):focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(46, 90, 58, 0.08);
}

label, .form-group span, .bacco-login__field span {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 4px;
    display: block;
}

/* ==========================================================================
   4. HEADER & NAVIGAZIONE GLOBALE
   ========================================================================== */
.bacco-site-header {
    position: sticky;
    top: 0;
    z-index: 1000;
    background: var(--surface);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border-bottom: 1px solid var(--border-light);
}

.bacco-site-header__inner {
    max-width: 1240px;
    margin: 0 auto;
    padding: 14px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.bacco-site-header__brand {
    color: var(--primary);
    font-size: 1.4rem;
    font-weight: 800;
    letter-spacing: -0.5px;
}

.bacco-site-header__nav {
    display: flex;
    gap: 16px;
    overflow-x: auto;
    scrollbar-width: none; /* Nasconde scrollbar su desktop per look minimal */
}

.bacco-site-header__nav::-webkit-scrollbar {
    display: none;
}

.bacco-site-header__link {
    color: var(--text-muted);
    font-weight: 500;
    font-size: 0.95rem;
    padding: 4px 0;
    border-bottom: 2px solid transparent;
}

.bacco-site-header__link.is-active,
.bacco-site-header__link:hover {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

/* ==========================================================================
   5. STRUTTURA PAGINE INTERNE (Dashboard, Tabelle, ecc.)
   ========================================================================== */
.bacco-page {
    max-width: 1240px;
    margin: 32px auto;
    padding: 0 20px;
}

.bacco-page__header {
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border-light);
}

.bacco-page__title {
    margin: 0;
    font-size: 1.8rem;
    color: var(--text-main);
    font-weight: 700;
}

.bacco-page__subtitle {
    margin: 4px 0 0;
    color: var(--text-muted);
    font-size: 1rem;
}

.bacco-page__content {
    background: var(--surface);
    border-radius: var(--radius-md);
    padding: 24px;
    box-shadow: var(--shadow-soft);
    border: 1px solid var(--border-light);
}

/* ==========================================================================
   Dashboard / Grafici - Spaziatura e leggibilità
   ========================================================================== */
/* Main wrapper della dashboard - applica sfondo a tema */
.bacco-page-section {
    background-color: var(--bg-body) !important;
    min-height: 100vh;
}

.bacco-page-section__inner {
    max-width: 1240px;
    margin: 0 auto;
    padding: 20px;
}

/* Contenitore generico usato nelle pagine per separare blocchi
    Usato nel markup per raggruppare grafici, tabelle e pulsanti. */
.box { margin-bottom: 28px; padding: 12px; background: #f5f3f0; border-radius: var(--radius-md); }

/* Cartelle grafiche: padding interno e min-height per evitare elementi troppo vicini */
.chart-container { padding: 14px; background: transparent; border-radius: var(--radius-md); }
.chart { min-height: 320px; padding: 8px; }
.content { background: #f5f3f0; border-radius: var(--radius-md); padding: 12px; }

/* Bottoni di mostra/nascondi e filtri: separazione dal grafico */
.hide-show-btn { margin-bottom: 14px; }

/* Dashboard-only overrides: riducono spazi e altezza grafici per evitare grandi aree vuote */
.bacco-page-section .box { margin-bottom: 14px; }
.bacco-page-section .chart { min-height: 220px; }
.bacco-page-section .hide-show-btn { margin-bottom: 8px; }

/* Header e menu in tema natura */
.bacco-site-header { background: var(--surface); border-bottom: 1px solid var(--border-light); }

/* ==========================================================================
   6. AREA AUTH & LOGIN (Pulita, Bianca e Fine)
   ========================================================================== */
body.bacco-login-page {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    background-color: var(--bg-body);
}

.bacco-login-page .bacco-site-header { display: none; }
.bacco-login-page .bacco-page { width: 100%; margin: auto; padding: 20px; }

/* Il contenitore centrale del login */
.page-shell,
.bacco-login {
    display: grid;
    grid-template-columns: 1.2fr 1fr;
    max-width: 1000px;
    background: var(--surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-soft);
    border: 1px solid var(--border-light);
    overflow: hidden;
    margin: 0 auto;
}

/* La parte grafica: Semplificata, solo accenno di colore o immagine */
.hero,
.bacco-login__hero {
    background: linear-gradient(135deg, var(--primary), #521c23);
    padding: 48px;
    color: #fff;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.hero__eyebrow,
.bacco-login__eyebrow {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 2px;
    opacity: 0.8;
    margin-bottom: 16px;
}

.hero h1,
.bacco-login__title {
    margin: 0 0 16px;
    font-size: 2.8rem;
    line-height: 1.1;
    font-weight: 800;
}

.hero p,
.bacco-login__copy {
    opacity: 0.9;
    font-size: 1.05rem;
    max-width: 400px;
}

/* Il pannello del form */
.container,
.bacco-login__panel {
    padding: 48px 40px;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.container h2,
.bacco-login__panel-title {
    margin: 0 0 8px;
    font-size: 1.6rem;
    color: var(--text-main);
}

.container .subtitle,
.bacco-login__panel-text {
    margin: 0 0 32px;
    color: var(--text-muted);
    font-size: 0.95rem;
}

form, .bacco-login__form {
    display: grid;
    gap: 20px;
}

.form-group, .bacco-login__field {
    display: block;
}

/* ==========================================================================
   7. UTILITIES & MESSAGGI
   ========================================================================== */
.message {
    margin: 16px 0;
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    border-left: 4px solid transparent;
}

.message.success {
    background: #f0fdf4;
    color: #166534;
    border-left-color: #22c55e;
}

.message.error {
    background: #fef2f2;
    color: #991b1b;
    border-left-color: #ef4444;
}

/* ==========================================================================
   8. MEDIA QUERIES (Mobile e Tablet)
   ========================================================================== */
@media (max-width: 860px) {
    .page-shell,
    .bacco-login {
        display: flex;
        flex-direction: column;
    }

    /* Ordine visivo: Form sopra, grafica sotto (o nascosta) */
    .container,
    .bacco-login__panel {
        order: 1;
        padding: 32px 24px;
    }

    .hero,
    .bacco-login__hero {
        order: 2;
        padding: 32px 24px;
        text-align: center;
    }

    .hero h1,
    .bacco-login__title {
        font-size: 2rem;
    }

    .bacco-page {
        margin: 20px auto;
    }

    .bacco-page__content {
        padding: 16px;
    }
}