/* =========================================================================
   Formular Casa Verde / AFM - baterii
   Paletă: #16A34A (primary) / #14532D (dark) / #DCFCE7 (light) / #F0FDF4 (bg)
   #17231B (text) / #FACC15 (accent solar, folosit rar)
   ========================================================================= */

.cv-form-wrap {
    --cv-primary: #16A34A;
    --cv-primary-dark: #14532D;
    --cv-light: #DCFCE7;
    --cv-bg-soft: #F0FDF4;
    --cv-text: #17231B;
    --cv-accent: #FACC15;
    --cv-white: #FFFFFF;
    --cv-border: #E2E8DE;

    font-family: 'Open Sans', Inter, system-ui, sans-serif;
    color: var(--cv-text);
    max-width: 720px;
    margin: 0 auto;
    overflow-x: hidden; /* FIX: plasă de siguranță - nu lasă niciun overflow intern să împingă pagina */
}

.cv-form-wrap h2,
.cv-form-wrap h3 {
    font-family: 'Montserrat', 'Open Sans', sans-serif;
    color: var(--cv-primary-dark);
    font-weight: 700;
    line-height: 1.25;
}

.cv-form-wrap h2 { font-size: 1.7rem; margin: 0 0 6px; }
.cv-form-wrap h3 { font-size: 1.15rem; margin: 0 0 14px; }

.cv-subtitle {
    color: #4B5A4E;
    font-size: .95rem;
    margin: 0 0 28px;
    line-height: 1.55;
}

/* --- card container reutilizat pe toate etapele --- */
.cv-card {
    background: var(--cv-white);
    border: 1px solid var(--cv-border);
    border-radius: 10px;
    padding: 28px 26px;
    box-shadow: 0 2px 10px rgba(20, 83, 45, 0.06);
    overflow-x: hidden; /* FIX: plasă de siguranță suplimentară la nivel de card */
}

/* --- progres etape (indicator sus) --- */
.cv-steps {
    display: flex;
    gap: 8px;
    margin-bottom: 22px;
}
.cv-steps .cv-step-dot {
    flex: 1;
    height: 5px;
    border-radius: 3px;
    background: var(--cv-border);
}
.cv-steps .cv-step-dot.done { background: var(--cv-primary); }

/* --- inputuri --- */
.cv-field { margin-bottom: 18px; }
.cv-field label {
    display: block;
    font-size: .85rem;
    font-weight: 600;
    color: var(--cv-primary-dark);
    margin-bottom: 6px;
}
.cv-field input[type="text"],
.cv-field input[type="email"],
.cv-field input[type="tel"],
.cv-field input[type="number"],
.cv-field select {
    width: 100%;
    box-sizing: border-box;
    padding: 12px 14px;
    border: 1px solid #C9D6C9;
    border-radius: 8px;
    font-size: .98rem;
    font-family: inherit;
    color: var(--cv-text);
    background: var(--cv-white);
    transition: border-color .15s ease;
}
.cv-field input:focus,
.cv-field select:focus {
    outline: none;
    border-color: var(--cv-primary);
    box-shadow: 0 0 0 3px rgba(22, 163, 74, 0.15);
}
.cv-field .cv-hint { font-size: .78rem; color: #6B7A6E; margin-top: 5px; }
.cv-field .cv-error { font-size: .8rem; color: #B91C1C; margin-top: 5px; display: none; }
.cv-field.has-error input { border-color: #B91C1C; }
.cv-field.has-error .cv-error { display: block; }

/* --- selector tip sistem (retrofit / Huawei) --- */
.cv-system-toggle { display: flex; gap: 10px; }
.cv-system-opt {
    flex: 1;
    padding: 12px 10px;
    border: 1px solid #C9D6C9;
    border-radius: 8px;
    background: var(--cv-white);
    color: var(--cv-text);
    font-family: inherit;
    font-weight: 600;
    font-size: .9rem;
    cursor: pointer;
    transition: all .15s ease;
}
.cv-system-opt:hover { border-color: var(--cv-primary); }
.cv-system-opt.active {
    background: var(--cv-primary);
    border-color: var(--cv-primary);
    color: #fff;
}

/* --- butoane --- */
.cv-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 13px 26px;
    border-radius: 8px;
    border: 0;
    font-family: 'Montserrat', sans-serif;
    font-weight: 600;
    font-size: .95rem;
    cursor: pointer;
    transition: background-color .15s ease, transform .05s ease;
    text-decoration: none;
}
.cv-btn-primary { background: var(--cv-primary); color: #fff; }
.cv-btn-primary:hover { background: #128a3e; }
.cv-btn-primary:active { transform: translateY(1px); }
.cv-btn-primary:disabled { background: #9CC9AC; cursor: not-allowed; }
.cv-btn-outline {
    background: transparent;
    color: var(--cv-primary-dark);
    border: 1px solid var(--cv-primary);
}
.cv-btn-outline:hover { background: var(--cv-light); }
.cv-btn-whatsapp { background: #14532D; color: #fff; }
.cv-btn-whatsapp:hover { background: #0f3f22; }
.cv-btn-block { width: 100%; }

/* --- mesaj duplicate (lead existent) --- */
.cv-duplicate-box {
    background: var(--cv-bg-soft);
    border: 1px solid var(--cv-light);
    border-radius: 10px;
    padding: 20px;
    margin-top: 18px;
}
.cv-duplicate-box p { margin: 0 0 14px; font-size: .93rem; line-height: 1.5; }
.cv-duplicate-actions { display: flex; gap: 10px; flex-wrap: wrap; }

/* =========================================================================
   ETAPA 2 - calculator + scor vizual
   ========================================================================= */
.cv-score-wrap {
    display: flex;
    align-items: center;
    gap: 26px;
    background: var(--cv-bg-soft);
    border-radius: 10px;
    padding: 20px 24px;
    margin: 20px 0 26px;
}
.cv-score-ring { position: relative; width: 108px; height: 108px; flex: none; }
.cv-score-ring svg { transform: rotate(-90deg); }
.cv-score-ring .cv-score-track { fill: none; stroke: var(--cv-light); stroke-width: 10; }
.cv-score-ring .cv-score-value {
    fill: none;
    stroke: var(--cv-primary);
    stroke-width: 10;
    stroke-linecap: round;
    transition: stroke-dashoffset .3s ease, stroke .3s ease;
}
.cv-score-number {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}
.cv-score-number .n { font-size: 1.5rem; font-weight: 800; color: var(--cv-primary-dark); line-height: 1; }
.cv-score-number .d { font-size: .68rem; color: #6B7A6E; margin-top: 2px; }
.cv-score-legend { font-size: .88rem; color: #345236; line-height: 1.5; }
.cv-score-legend strong { color: var(--cv-primary-dark); }

.cv-slider-field { margin-bottom: 24px; }
.cv-slider-field .cv-slider-top {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 8px;
}
.cv-slider-field label { font-weight: 600; font-size: .9rem; color: var(--cv-primary-dark); }
.cv-slider-field .cv-slider-val {
    font-family: 'Montserrat', sans-serif;
    font-weight: 700;
    font-size: 1.05rem;
    color: var(--cv-primary);
}
.cv-slider-field input[type="range"] {
    width: 100%;
    height: 6px;
    border-radius: 3px;
    background: var(--cv-light);
    appearance: none;
    -webkit-appearance: none;
}
.cv-slider-field input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 22px; height: 22px;
    border-radius: 50%;
    background: var(--cv-primary);
    border: 3px solid #fff;
    box-shadow: 0 1px 4px rgba(0,0,0,.25);
    cursor: pointer;
}
.cv-slider-field input[type="range"]::-moz-range-thumb {
    width: 22px; height: 22px;
    border-radius: 50%;
    background: var(--cv-primary);
    border: 3px solid #fff;
    box-shadow: 0 1px 4px rgba(0,0,0,.25);
    cursor: pointer;
}
.cv-slider-range { display: flex; justify-content: space-between; font-size: .74rem; color: #8CA08F; margin-top: 4px; }

.cv-breakdown { margin-top: 4px; border-top: 1px solid var(--cv-border); padding-top: 14px; }
.cv-breakdown .row {
    display: flex; justify-content: space-between;
    padding: 7px 0; font-size: .89rem; border-bottom: 1px dashed var(--cv-border);
}
.cv-breakdown .row:last-child { border-bottom: 0; }
.cv-breakdown .row strong { font-variant-numeric: tabular-nums; color: var(--cv-primary-dark); }
.cv-warn {
    background: #FEF9E7;
    border: 1px solid var(--cv-accent);
    border-radius: 8px;
    padding: 12px 16px;
    font-size: .88rem;
    margin-top: 16px;
}

/* =========================================================================
   ETAPA 3 - documente + banner magic link
   ========================================================================= */
.cv-link-banner {
    background: var(--cv-primary-dark);
    color: #fff;
    border-radius: 10px;
    padding: 16px 20px;
    margin-bottom: 24px;
    display: flex;
    align-items: center;
    gap: 14px;
    flex-wrap: wrap;
}
.cv-link-banner .cv-link-text { flex: 1; min-width: 220px; }
.cv-link-banner .cv-link-text p { margin: 0 0 6px; font-size: .82rem; color: #C9E8D2; }
.cv-link-banner input[type="text"] {
    width: 100%;
    box-sizing: border-box;
    background: rgba(255,255,255,.1);
    border: 1px solid rgba(255,255,255,.25);
    color: #fff;
    border-radius: 6px;
    padding: 8px 10px;
    font-size: .82rem;
}
.cv-link-banner .cv-btn-copy {
    background: var(--cv-primary);
    color: #fff;
    border: 0;
    border-radius: 6px;
    padding: 9px 16px;
    font-size: .84rem;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
}
.cv-link-banner .cv-btn-copy:hover { background: #128a3e; }

.cv-progress-bar-wrap { margin-bottom: 26px; }
.cv-progress-bar-wrap .top { display: flex; justify-content: space-between; font-size: .85rem; margin-bottom: 6px; color: #4B5A4E; }
.cv-progress-bar-wrap .bar { height: 10px; border-radius: 5px; background: var(--cv-light); overflow: hidden; }
.cv-progress-bar-wrap .bar .fill { height: 100%; background: var(--cv-primary); border-radius: 5px; transition: width .3s ease; }

.cv-docs-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr); /* FIX: era "1fr" - fara minmax(0,...) track-ul se latea dupa numele lungi de fisiere */
    gap: 14px;
}

/* --- cardul unei rubrici de document (poate conține 0..n fișiere) --- */
.cv-doc-card {
    border: 1px solid var(--cv-border);
    border-radius: 10px;
    padding: 16px 18px;
    background: var(--cv-white);
    transition: opacity .15s ease;
    min-width: 0; /* FIX: item de grid - fara asta poate ignora shrink-ul chiar daca track-ul are minmax(0,1fr) */
}
.cv-doc-card.is-uploaded { border-color: var(--cv-primary); background: var(--cv-bg-soft); }
.cv-doc-card.is-loading { opacity: .6; pointer-events: none; }

/* rândul de sus: iconiță tip document + denumire/descriere + status - totul pe flex,
   cu min-width:0 pe zona de text ca să funcționeze ellipsis-ul, indiferent cât de lung e textul */
.cv-doc-header {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    min-width: 0; /* FIX: acelasi motiv - continua lantul de shrink pana la text */
}
.cv-doc-type-icon {
    flex: none;
    width: 36px;
    height: 36px;
    border-radius: 8px;
    background: var(--cv-light);
    color: var(--cv-primary-dark);
    display: flex;
    align-items: center;
    justify-content: center;
}
.cv-doc-info {
    flex: 1 1 auto;
    min-width: 0; /* obligatoriu: fără asta flex-item-ul nu se strânge sub conținut și textul iese din card */
}
.cv-doc-info .name {
    font-weight: 700;
    font-size: .93rem;
    color: var(--cv-primary-dark);
    margin: 0 0 2px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.cv-doc-info .desc {
    font-size: .8rem;
    color: #6B7A6E;
    margin: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.cv-doc-status {
    flex: none;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: .74rem;
    font-weight: 700;
    padding: 4px 9px;
    border-radius: 20px;
    white-space: nowrap;
}
.cv-doc-status svg { flex: none; }
.cv-doc-status.lipsa { background: #FEF2F2; color: #B91C1C; }
.cv-doc-status.optional { background: #F1F5F9; color: #64748B; }
.cv-doc-status.ok { background: var(--cv-light); color: var(--cv-primary-dark); }

/* --- lista fișierelor deja încărcate pentru rubrica respectivă --- */
.cv-doc-files {
    list-style: none;
    margin: 12px 0 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 0; /* FIX: acelasi motiv - continua lantul de shrink */
}
.cv-doc-file {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0; /* la fel, necesar pentru ca ellipsis-ul de pe nume să funcționeze într-un flex container */
    padding: 7px 9px;
    border: 1px solid var(--cv-border);
    border-radius: 8px;
    background: var(--cv-white);
}
.cv-file-icon {
    flex: none;
    color: #6B7A6E;
    display: flex;
}
.cv-file-name {
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    overflow-wrap: anywhere; /* FIX: plasă de siguranță suplimentară dacă ellipsis-ul nu prinde undeva */
    font-size: .84rem;
    color: var(--cv-text);
}
.cv-doc-file .cv-icon-btn {
    flex: none;
}

/* --- acțiunea de upload (label peste input file ascuns) --- */
.cv-doc-actions {
    margin-top: 12px;
}
.cv-btn-upload {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    border: 1px dashed #C9D6C9;
    background: transparent;
    color: var(--cv-primary-dark);
    border-radius: 7px;
    padding: 8px 12px;
    font-size: .82rem;
    font-weight: 600;
    cursor: pointer;
    transition: background-color .15s ease, border-color .15s ease;
}
.cv-btn-upload:hover { background: var(--cv-bg-soft); border-color: var(--cv-primary); }
.cv-btn-upload input[type="file"] {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* --- butoane iconiță (descarcă / șterge), refolosite și în lista de fișiere --- */
.cv-icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--cv-border);
    background: #fff;
    border-radius: 7px;
    width: 30px;
    height: 30px;
    cursor: pointer;
    color: var(--cv-primary-dark);
    text-decoration: none;
}
.cv-icon-btn:hover { background: var(--cv-bg-soft); }
.cv-icon-btn.danger { color: #B91C1C; }
.cv-icon-btn.danger:hover { background: #FEF2F2; }

.cv-all-done {
    text-align: center;
    padding: 30px 20px;
    background: var(--cv-bg-soft);
    border-radius: 10px;
    margin-top: 20px;
}
.cv-all-done .icon {
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 8px;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--cv-light);
    color: var(--cv-primary-dark);
}

.cv-toast {
    position: fixed;
    bottom: 22px; left: 50%;
    transform: translateX(-50%) translateY(10px);
    background: var(--cv-primary-dark);
    color: #fff;
    padding: 12px 20px;
    border-radius: 8px;
    font-size: .88rem;
    opacity: 0;
    pointer-events: none;
    transition: opacity .2s ease, transform .2s ease;
    z-index: 999;
}
.cv-toast.show { opacity: 1; transform: translateX(-50%) translateY(0); pointer-events: auto; }
.cv-toast.error { background: #B91C1C; }

@media (min-width: 640px) {
    .cv-docs-grid { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); } /* FIX: era "1fr 1fr" */
}

@media (max-width: 480px) {
    .cv-card { padding: 20px 16px; }
    .cv-score-wrap { flex-direction: column; text-align: center; }
    .cv-duplicate-actions { flex-direction: column; }
    .cv-duplicate-actions .cv-btn { width: 100%; }
}