/* Reset generale */
* { box-sizing: border-box; margin: 0; padding: 0; font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; }
body { overflow: hidden; background-color: #f1f5f9; }

/* Header App */
.app-header { background: #0f172a; color: white; padding: 15px 30px; display: flex; justify-content: space-between; align-items: center; height: 60px; }
.app-header h1 { font-size: 20px; font-weight: 700; letter-spacing: 0.5px; }
#btn-pdf { background: #1d4ed8; color: white; border: none; padding: 10px 18px; border-radius: 8px; cursor: pointer; font-weight: bold; font-size: 14px; transition: 0.2s; }
#btn-pdf:hover { background: #1e40af; }

/* Layout 50/50 dello schermo */
.split-container { display: flex; height: calc(100vh - 60px); width: 100vw; }

/* Metà Sinistra: Form di Compilazione */
.form-half { width: 50vw; height: 100%; overflow-y: auto; background: #f8fafc; border-right: 2px solid #cbd5e1; position: relative; transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1); }
.form-content { padding: 40px; max-width: 750px; margin: 0 auto; }

/* Contenitori delle sezioni (Rettangoli ad angoli smussati) */
.section-card { background: white; border-radius: 12px; padding: 25px; margin-bottom: 25px; box-shadow: 0 2px 8px rgba(15, 23, 42, 0.04); border: 1px solid #e2e8f0; }
.form-content h2 { font-size: 15px; color: #1e293b; margin-bottom: 20px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; }

/* Campi di Input e Aree di Testo (Angoli Smussati) */
.form-group { margin-bottom: 15px; }
.form-group label { display: block; font-size: 12px; font-weight: 600; margin-bottom: 6px; color: #475569; }
.form-group input, .form-group textarea { width: 100%; padding: 12px; border: 1px solid #cbd5e1; border-radius: 10px; font-size: 14px; background: #fdfdfd; transition: border-color 0.2s, box-shadow 0.2s; color: #0f172a; }
.form-group input:focus, .form-group textarea:focus { border-color: #1d4ed8; box-shadow: 0 0 0 3px rgba(29, 78, 216, 0.15); outline: none; background: white; }

/* BOX CONSIGLI UTILI (User-friendly e Moderno) */
.tips-box { display: flex; gap: 12px; background: #eff6ff; border: 1px solid #bfdbfe; border-radius: 10px; padding: 15px; margin-top: 10px; align-items: flex-start; }
.tips-box i { color: #1d4ed8; font-size: 16px; margin-top: 2px; }
.tips-box p { font-size: 12.5px; color: #1e40af; line-height: 1.5; }
.tips-box strong { color: #1d4ed8; }

/* Bottoni e blocchi esperienze nel Form */
.exp-input-box { background: #f1f5f9; padding: 20px; border: 1px solid #e2e8f0; border-radius: 10px; margin-bottom: 15px; }
.btn-outline { width: 100%; padding: 12px; background: white; border: 2px dashed #cbd5e1; color: #475569; font-weight: bold; border-radius: 10px; cursor: pointer; transition: 0.2s; font-size: 14px; }
.btn-outline:hover { border-color: #1d4ed8; color: #1d4ed8; background: #eff6ff; }
.btn-delete { background: #ef4444; color: white; border: none; padding: 8px 14px; border-radius: 8px; cursor: pointer; font-size: 12px; margin-top: 5px; font-weight: 600; }
.btn-delete:hover { background: #dc2626; }

/* Metà Destra: Anteprima CV */
.preview-half { 
    width: 50vw; 
    height: 100%; 
    overflow-y: auto; 
    background: #475569; 
    display: flex; 
    justify-content: center; 
    align-items: flex-start; /* CRUCIALE: Permette al foglio bianco di allungarsi verso il basso senza limiti */
    padding: 40px; 
    position: relative; 
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1); 
}

/* --- STILE DEL FOGLIO A4 (Illusioni di Fogli Multipli e Salto Pagina) --- */
.a4-page { 
    width: 210mm; 
    min-height: 297mm; 
    height: max-content; /* Cresce insieme al testo */
    background-color: white; 
    box-shadow: 0 10px 25px rgba(0,0,0,0.3); 
    position: relative;
    overflow: visible; 
}

/* La griglia principale è un flusso continuo */
.cv-grid { 
    display: flex; 
    align-items: stretch; /* Fa allungare le colonne sempre alla stessa altezza */
    min-height: 297mm; 
    height: max-content; /* Cresce insieme al testo */
    position: relative;
}

/* IL TRUCCO MAGICO E DEFINITIVO: Proietta una fascia grigia scura (lo stesso colore dello sfondo) ogni 297mm.
   Questa fascia 'coprirà' il testo che cerca di uscire e creerà l'illusione di bordi separati.
   Funziona solo nel browser, non nel PDF. */
.cv-grid::after {
    content: "";
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    pointer-events: none; /* Permette di cliccare il testo sotto senza bloccarlo */
    background-image: repeating-linear-gradient(
        to bottom,
        transparent 0mm,
        transparent 292mm,
        #475569 292mm, /* Colore scuro dell'anteprima */
        #475569 297mm  /* Crea una fascia scura di 5mm che simula lo stacco tra due fogli */
    );
    z-index: 50;
}

/* Colonna Bianca CV (68%) */
.cv-main { width: 68%; background-color: white; padding: 15mm 10mm 15mm 15mm; }
.cv-name { font-size: 30px; font-weight: 800; color: #0f172a; text-transform: uppercase; letter-spacing: 0.5px; line-height: 1.1; }
.cv-title { font-size: 16px; color: #1d4ed8; font-weight: 600; margin-top: 6px; margin-bottom: 25px; }

.cv-section { margin-bottom: 25px; }
.cv-section-title { font-size: 13px; text-transform: uppercase; color: #0f172a; border-bottom: 2px solid #e2e8f0; padding-bottom: 4px; margin-bottom: 12px; font-weight: 700; letter-spacing: 0.5px; }
.cv-text { font-size: 12px; color: #334155; line-height: 1.5; text-align: justify; }

/* Design Esperienze CV */
.cv-exp-block { margin-bottom: 15px; }
.cv-exp-top { display: flex; justify-content: space-between; align-items: baseline; }
.cv-exp-role { font-weight: bold; font-size: 14px; color: #1d4ed8; }
.cv-exp-date { font-size: 11px; color: #64748b; font-weight: bold; }
.cv-exp-company { font-size: 13px; color: #0f172a; font-weight: bold; margin-bottom: 4px; }
.cv-exp-desc { font-size: 12px; color: #475569; line-height: 1.5; padding-left: 15px; }

/* Colonna Grigia CV (32%) */
.cv-sidebar { width: 32%; background-color: #f8fafc; padding: 15mm 15mm 15mm 10mm; border-left: 1px solid #e2e8f0; display: flex; flex-direction: column; }
.cv-side-section { margin-bottom: 25px; }
.cv-side-title { font-size: 12px; text-transform: uppercase; color: #0f172a; font-weight: 700; border-bottom: 1px solid #cbd5e1; padding-bottom: 4px; margin-bottom: 12px; letter-spacing: 0.5px; }
.cv-list { list-style: none; }
.cv-list li { font-size: 11px; color: #475569; margin-bottom: 10px; display: flex; align-items: center; gap: 8px; }
.cv-list i { color: #1d4ed8; width: 12px; text-align: center; }
.cv-skill-list { list-style: square; padding-left: 15px; font-size: 11.5px; color: #475569; line-height: 1.8; }
.cv-privacy { margin-top: auto; font-size: 8px; color: #94a3b8; text-align: justify; line-height: 1.3; }

/* --- BOTTONI SCHERMO INTERO --- */
#btn-fullscreen-form, #btn-fullscreen {
    position: absolute; top: 20px; right: 20px; background: #1e293b; color: white; border: none; width: 44px; height: 44px; border-radius: 50%; cursor: pointer; font-size: 16px; display: flex; align-items: center; justify-content: center; box-shadow: 0 4px 10px rgba(0,0,0,0.2); transition: 0.2s; z-index: 100;
}
#btn-fullscreen-form:hover, #btn-fullscreen:hover { background: #1d4ed8; transform: scale(1.1); }

/* Modalità Focus Attive */
.form-half.fullscreen-active { position: fixed; top: 0; left: 0; width: 100vw; height: 100vh; z-index: 1000; background: #f8fafc; }
.preview-half.fullscreen-active { position: fixed; top: 0; left: 0; width: 100vw; height: 100vh; z-index: 1000; background: #334155; }


/* --- OTTIMIZZAZIONE STAMPA E MULTI-PAGINA (NATIVA BROWSER) --- */
@media print {
    /* Impone le dimensioni standard del foglio A4 */
    @page {
        size: A4 portrait;
        margin: 0;
    }

    /* Forza il browser a stampare i colori di sfondo */
    body {
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
        background-color: white;
    }

    /* Nasconde l'interfaccia dell'app, i bottoni e le 'finte' strisce grigie di separazione */
    .app-header, .form-half, #btn-fullscreen, #btn-fullscreen-form, .tips-box, .cv-grid::after {
        display: none !important;
    }

    /* Rende il CV a tutto schermo per formattare la pagina per la stampa nativa */
    .split-container, .preview-half {
        display: block;
        width: 100%;
        height: auto;
        overflow: visible;
        background: none;
        padding: 0;
    }

    .a4-page {
        width: 100%;
        height: auto;
        box-shadow: none;
        margin: 0;
    }

    /* TRUCCO FAUX COLUMNS: Colora lo sfondo della griglia principale fino a fine pagina */
    .cv-grid {
        display: block; /* Disattiva Flexbox per la stampa nativa, che fatica a gestire i salti pagina */
        min-height: 100vh; 
        background: linear-gradient(to right, white 0%, white 68%, #f8fafc 68%, #f8fafc 100%);
    }

    .cv-main {
        width: 68%;
        float: left;
        background: transparent;
    }

    .cv-sidebar {
        width: 32%;
        float: right;
        background: transparent;
        border-left: none; /* Rimosso per far emergere il background parent */
    }

    /* Impedisce ai blocchi esperienza di tagliarsi a metà pagina */
    .cv-exp-block {
        page-break-inside: avoid;
        break-inside: avoid;
    }

    /* Pulisce l'allineamento a fine documento */
    .cv-grid::after {
        content: "";
        display: table;
        clear: both;
    }
}