/* ═══════════════════════════════════════════════════
   Catalogo e Preventivi — Stile catalogo pubblico
   Navbar, filtri, griglia, modale dettaglio, carrello
   ═══════════════════════════════════════════════════ */

/* ── Navbar pubblica ── */
.pub-navbar {
    position: fixed; top: 0; left: 0; right: 0; height: 60px;
    background: var(--surface); border-bottom: 1px solid var(--border);
    z-index: 100; box-shadow: var(--shadow-sm);
}
.pub-navbar-inner {
    max-width: 1280px; margin: 0 auto; height: 100%;
    display: flex; align-items: center; gap: 16px; padding: 0 20px;
}
.pub-navbar-brand {
    display: flex; align-items: center; gap: 10px;
    text-decoration: none; color: var(--text); flex-shrink: 0;
}
.pub-navbar-brand:hover { text-decoration: none; }
.pub-navbar-logo { height: 36px; width: auto; object-fit: contain; }
.pub-navbar-title { font-size: 1rem; font-weight: 600; white-space: nowrap; }

/* ── Barra ricerca navbar ── */
.pub-navbar-search {
    flex: 1; max-width: 480px; position: relative;
}
.pub-input-ricerca {
    width: 100%; padding: 8px 12px 8px 36px;
    border: 1px solid var(--border); border-radius: var(--radius);
    font-size: 0.875rem; background: var(--bg);
    transition: border-color 0.15s, box-shadow 0.15s;
}
.pub-input-ricerca:focus {
    outline: none; border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light); background: var(--surface);
}
.pub-search-icon {
    position: absolute; left: 10px; top: 50%; transform: translateY(-50%);
    color: var(--text-muted); pointer-events: none;
}

/* ── Selettore lingua ── */
.lang-selector { position: relative; }
.lang-btn {
    background: none; border: 1px solid var(--border); cursor: pointer;
    font-size: 1.25rem; padding: 4px 8px; border-radius: var(--radius-sm);
    line-height: 1; transition: border-color 0.15s;
}
.lang-btn:hover { border-color: var(--primary); }
.lang-dropdown {
    display: none; position: absolute; top: 100%; right: 0; margin-top: 6px;
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius-sm); box-shadow: var(--shadow-md);
    min-width: 140px; z-index: 1000; overflow: hidden;
}
.lang-selector.open .lang-dropdown { display: block; }
.lang-option {
    display: flex; align-items: center; gap: 8px; padding: 8px 14px;
    font-size: 0.8125rem; color: var(--text); text-decoration: none;
    transition: background 0.15s;
}
.lang-option:hover { background: var(--border-light); }
.lang-option.active { font-weight: 600; color: var(--primary); }
.lang-flag { display: inline-flex; align-items: center; line-height: 1; }
.lang-flag-svg { width: 22px; height: 16px; border-radius: 2px; box-shadow: 0 0 0 1px rgba(0,0,0,.12); vertical-align: middle; flex-shrink: 0; }
.lang-flag-text {
    display: inline-block; font-size: 0.7rem; font-weight: 700; letter-spacing: 0.5px;
    background: var(--border); color: var(--text-muted); padding: 2px 5px;
    border-radius: 3px; line-height: 1.2;
}

/* ── Bottone carrello navbar ── */
.pub-btn-carrello {
    position: relative; background: none; border: none; cursor: pointer;
    color: var(--text); padding: 6px; border-radius: var(--radius-sm);
    transition: background 0.15s;
}
.pub-btn-carrello:hover { background: var(--border-light); }
.pub-badge-carrello {
    position: absolute; top: -2px; right: -6px;
    background: var(--primary); color: #fff;
    font-size: 0.6875rem; font-weight: 600;
    min-width: 18px; height: 18px; line-height: 18px;
    border-radius: 9px; text-align: center; padding: 0 4px;
}
.pub-badge-carrello:empty, .pub-badge-carrello[data-count="0"] { display: none; }

/* ── Menu utente navbar ── */
.pub-user-menu { position: relative; }
.pub-btn-user {
    display: flex; align-items: center; gap: 6px; background: none; border: none;
    cursor: pointer; color: var(--text); padding: 6px 10px; border-radius: var(--radius-sm);
    font-size: 0.8125rem; transition: background 0.15s;
}
.pub-btn-user:hover { background: var(--border-light); }
.pub-user-name { max-width: 120px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pub-user-dropdown {
    display: none; position: absolute; right: 0; top: 100%; margin-top: 4px;
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
    box-shadow: var(--shadow-lg); min-width: 180px; z-index: 200; overflow: hidden;
}
.pub-user-menu.open .pub-user-dropdown { display: block; }
.pub-user-dropdown a {
    display: block; padding: 10px 16px; font-size: 0.8125rem; color: var(--text);
    text-decoration: none; transition: background 0.15s;
}
.pub-user-dropdown a:hover { background: var(--border-light); }
.pub-btn-accedi {
    font-size: 0.8125rem; color: var(--primary); text-decoration: none;
    padding: 6px 12px; border: 1px solid var(--primary); border-radius: var(--radius-sm);
    transition: background 0.15s, color 0.15s; white-space: nowrap;
}
.pub-btn-accedi:hover { background: var(--primary); color: #fff; text-decoration: none; }

/* ── Toggle filtri mobile ── */
.pub-btn-filtri-mobile {
    display: none; background: none; border: none; cursor: pointer;
    color: var(--text); padding: 6px; border-radius: var(--radius-sm);
}

/* ── Contenuto principale ── */
.pub-content { padding-top: 60px; min-height: calc(100vh - 60px); }

/* ── Banner indicazione IVA esclusa ── */
.iva-banner {
    position: sticky; top: 60px; z-index: 97;
    background: var(--info-light); color: var(--info);
    text-align: center; padding: 6px 16px;
    font-size: 0.75rem; font-weight: 500;
    border-bottom: 1px solid #bae6fd;
    letter-spacing: 0.02em;
}
.iva-banner svg { vertical-align: -2px; margin-right: 4px; }
/* Se il banner impersonificazione è presente, sposta il banner IVA sotto */
.has-impersona .iva-banner { top: 92px; }

/* ── Footer pubblico ── */
.pub-footer {
    text-align: center; padding: 20px; font-size: 0.8125rem;
    color: var(--text-muted); border-top: 1px solid var(--border);
}

/* ── Banner impersonificazione cliente ── */
.impersona-cliente-banner {
    background: #f59e0b; color: #1e1e2d; padding: 8px 16px;
    font-size: 0.8125rem; position: sticky; top: 60px; z-index: 99;
}
.impersona-cliente-inner {
    display: flex; align-items: center; gap: 8px; max-width: 1280px;
    margin: 0 auto; flex-wrap: wrap;
}
.impersona-cliente-inner svg { flex-shrink: 0; }
.impersona-cliente-esci {
    margin-left: auto; padding: 4px 12px; background: rgba(0,0,0,0.15);
    color: #1e1e2d; border-radius: var(--radius-sm); text-decoration: none;
    font-size: 0.75rem; font-weight: 600; transition: background 0.15s;
}
.impersona-cliente-esci:hover { background: rgba(0,0,0,0.25); text-decoration: none; }

/* ── Layout catalogo (filtri + griglia) ── */
.catalogo-container {
    display: flex; max-width: 1280px; margin: 0 auto; padding: 20px; gap: 24px;
}

/* ── Sidebar filtri ── */
.catalogo-filtri {
    width: 240px; flex-shrink: 0;
    background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow-sm);
    padding: 16px; height: fit-content; position: sticky; top: 80px;
}
.filtri-header {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 16px;
}
.filtri-header h3 { font-size: 0.9375rem; font-weight: 600; }
.filtro-gruppo { margin-bottom: 16px; }
.filtro-gruppo label {
    display: block; font-size: 0.75rem; font-weight: 600;
    text-transform: uppercase; letter-spacing: 0.03em;
    color: var(--text-secondary); margin-bottom: 6px;
}
.filtro-gruppo select {
    width: 100%; padding: 7px 10px; border: 1px solid var(--border);
    border-radius: var(--radius-sm); font-size: 0.8125rem;
    background: var(--surface); color: var(--text);
}
.filtro-gruppo select:focus {
    outline: none; border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}
.catalogo-filtri-overlay { display: none; }

/* ── Area principale catalogo ── */
.catalogo-main { flex: 1; min-width: 0; }
.catalogo-info {
    font-size: 0.8125rem; color: var(--text-secondary); margin-bottom: 16px;
}

/* ── Griglia prodotti ── */
.catalogo-griglia {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px;
}

/* ── Card prodotto ── */
.prodotto-card {
    background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow-sm);
    overflow: hidden; cursor: pointer; transition: box-shadow 0.2s, transform 0.2s;
    display: flex; flex-direction: column;
}
.prodotto-card:hover { box-shadow: var(--shadow-lg); transform: translateY(-2px); }
.prodotto-card-img {
    aspect-ratio: 1; overflow: hidden; background: var(--border-light);
    display: flex; align-items: center; justify-content: center;
}
.prodotto-card-img img { width: 100%; height: 100%; object-fit: cover; }
.prodotto-card-placeholder {
    color: var(--text-muted); font-size: 0.8125rem;
    display: flex; align-items: center; justify-content: center;
    width: 100%; height: 100%;
}
.prodotto-card-body { padding: 12px; flex: 1; display: flex; flex-direction: column; }
.prodotto-card-codice {
    font-size: 0.6875rem; color: var(--text-muted); font-family: var(--font-mono);
    margin-bottom: 2px;
}
.prodotto-card-nome {
    font-size: 0.875rem; font-weight: 500; color: var(--text);
    line-height: 1.3; margin-bottom: 8px;
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
    overflow: hidden;
}
.prodotto-card-footer {
    display: flex; align-items: center; justify-content: space-between; margin-top: auto;
}
.prodotto-card-prezzo { font-size: 1rem; font-weight: 700; color: var(--primary); }
.prodotto-card-prezzo.no-prezzo { font-size: 0.8125rem; font-weight: 400; color: var(--text-muted); }
.prodotto-card-btn {
    background: var(--primary); color: #fff; border: none; border-radius: var(--radius-sm);
    padding: 6px 10px; font-size: 0.75rem; font-weight: 500; cursor: pointer;
    transition: background 0.15s; white-space: nowrap;
}
.prodotto-card-btn:hover { background: var(--primary-dark); }

/* ── Modale (stili base per pagine pubbliche) ── */
.modal-overlay {
    display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.5);
    z-index: 1000; align-items: center; justify-content: center; padding: 20px;
}
.modal-overlay.open { display: flex; }
.modal {
    background: var(--surface); border-radius: var(--radius-lg);
    max-width: 560px; width: 100%; max-height: 85vh; overflow-y: auto;
    box-shadow: var(--shadow-lg);
}
.modal-lg { max-width: 720px; }
.modal-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 16px 20px; border-bottom: 1px solid var(--border);
}
.modal-header h3 { font-size: 1rem; font-weight: 600; }
.modal-close {
    background: none; border: none; cursor: pointer; color: var(--text-muted);
    padding: 4px; border-radius: var(--radius-sm); transition: color 0.15s;
}
.modal-close:hover { color: var(--text); }
.modal-body { padding: 20px; }

/* ── Modale dettaglio prodotto ── */
.dettaglio-layout { display: flex; gap: 24px; }
.dettaglio-gallery { flex: 0 0 320px; }
.dettaglio-gallery-main {
    width: 100%; aspect-ratio: 1; border-radius: var(--radius);
    overflow: hidden; background: var(--border-light); margin-bottom: 8px;
}
.dettaglio-gallery-main img { width: 100%; height: 100%; object-fit: cover; }
.dettaglio-gallery-thumbs { display: flex; gap: 6px; flex-wrap: wrap; }
.dettaglio-gallery-thumb {
    width: 56px; height: 56px; border-radius: var(--radius-sm);
    overflow: hidden; cursor: pointer; border: 2px solid transparent;
    transition: border-color 0.15s;
}
.dettaglio-gallery-thumb.active { border-color: var(--primary); }
.dettaglio-gallery-thumb img { width: 100%; height: 100%; object-fit: cover; }
.dettaglio-info { flex: 1; }
.dettaglio-codice {
    font-size: 0.8125rem; color: var(--text-muted); font-family: var(--font-mono);
    margin-bottom: 8px;
}
.dettaglio-descrizione {
    font-size: 0.875rem; color: var(--text-secondary); line-height: 1.5;
    margin-bottom: 16px;
}
.dettaglio-prezzo {
    font-size: 1.5rem; font-weight: 700; color: var(--primary); margin-bottom: 20px;
}
.dettaglio-ragg { margin-bottom: 16px; }
.dettaglio-ragg-item {
    font-size: 0.8125rem; color: var(--text-secondary); margin-bottom: 4px;
}
.dettaglio-ragg-item strong { color: var(--text); }

/* ── Giacenza articolo (clienti registrati) ── */
.dettaglio-giacenza {
    font-size: 0.875rem; font-weight: 600; margin-bottom: 16px; padding: 6px 12px;
    border-radius: 6px; display: inline-block;
}
.dettaglio-giacenza.disponibile { color: #15803d; background: #f0fdf4; }
.dettaglio-giacenza.esaurito { color: #dc2626; background: #fef2f2; }

/* ── Documenti tecnici nella modale ── */
.dettaglio-docs { margin-bottom: 16px; padding: 12px; background: #f9fafb; border-radius: 6px; }
.dettaglio-docs-titolo { font-size: 0.8125rem; font-weight: 600; color: var(--text); margin-bottom: 8px; }
.dettaglio-doc-link {
    display: block; font-size: 0.8125rem; color: var(--primary); text-decoration: none;
    padding: 4px 0; line-height: 1.5;
}
.dettaglio-doc-link:hover { text-decoration: underline; }
.dettaglio-doc-link svg { vertical-align: -2px; color: #dc2626; }

/* ── Link documentazione nei filtri ── */
.filtro-doc-link { border-top: 1px solid var(--border-light); padding-top: 12px; margin-top: 8px; }
.catalogo-link-doc {
    display: flex; align-items: center; gap: 6px; color: var(--primary);
    text-decoration: none; font-size: 0.8125rem; font-weight: 500;
}
.catalogo-link-doc:hover { text-decoration: underline; }
.catalogo-link-doc svg { color: #dc2626; flex-shrink: 0; }
.catalogo-doc-count {
    background: var(--primary); color: #fff; font-size: 0.6875rem;
    padding: 0 6px; border-radius: 10px; margin-left: auto;
}

.dettaglio-aggiungi { display: flex; align-items: center; gap: 12px; }
.dettaglio-qta {
    display: flex; align-items: center; gap: 0; border: 1px solid var(--border);
    border-radius: var(--radius-sm); overflow: hidden;
}
.dettaglio-qta button {
    background: var(--border-light); border: none; width: 32px; height: 32px;
    cursor: pointer; font-size: 1rem; color: var(--text); transition: background 0.15s;
}
.dettaglio-qta button:hover { background: var(--border); }
.dettaglio-qta input {
    width: 48px; height: 32px; border: none; text-align: center;
    font-size: 0.875rem; background: var(--surface);
}
.dettaglio-qta input:focus { outline: none; }

/* ── Paginazione ── */
.paginazione { display: flex; gap: 4px; justify-content: center; padding: 20px 0; flex-wrap: wrap; }
.paginazione button {
    min-width: 36px; height: 36px; border: 1px solid var(--border);
    border-radius: var(--radius-sm); background: var(--surface);
    cursor: pointer; font-size: 0.8125rem; color: var(--text);
    transition: background 0.15s, border-color 0.15s;
}
.paginazione button:hover { background: var(--border-light); }
.paginazione button.active {
    background: var(--primary); color: #fff; border-color: var(--primary);
}
.paginazione button:disabled { opacity: 0.4; cursor: not-allowed; }

/* ── Drawer carrello ── */
.carrello-overlay {
    display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.4); z-index: 200;
}
.carrello-overlay.open { display: block; }
.carrello-drawer {
    position: fixed; top: 0; right: -380px; width: 380px; height: 100vh;
    background: var(--surface); z-index: 201; box-shadow: var(--shadow-lg);
    display: flex; flex-direction: column;
    transition: right 0.3s ease;
}
.carrello-drawer.open { right: 0; }
.carrello-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 16px 20px; border-bottom: 1px solid var(--border);
}
.carrello-header h3 { font-size: 1rem; font-weight: 600; }
.carrello-body { flex: 1; overflow-y: auto; padding: 16px 20px; }
.carrello-footer {
    padding: 16px 20px; border-top: 1px solid var(--border);
}
.carrello-totale {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 12px; font-size: 1rem;
}
.carrello-totale strong { font-size: 1.125rem; color: var(--primary); }
.carrello-iva-nota {
    display: block; text-align: right; font-size: 0.7rem;
    color: var(--text-muted); margin: -8px 0 10px;
}
.btn-block { width: 100%; justify-content: center; }

/* ── Item carrello ── */
.carrello-item {
    display: flex; gap: 12px; padding: 12px 0;
    border-bottom: 1px solid var(--border-light);
}
.carrello-item-img {
    width: 56px; height: 56px; border-radius: var(--radius-sm);
    overflow: hidden; background: var(--border-light); flex-shrink: 0;
}
.carrello-item-img img { width: 100%; height: 100%; object-fit: cover; }
.carrello-item-info { flex: 1; min-width: 0; }
.carrello-item-nome {
    font-size: 0.8125rem; font-weight: 500; color: var(--text);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.carrello-item-prezzo { font-size: 0.75rem; color: var(--text-secondary); margin-top: 2px; }
.carrello-item-azioni { display: flex; align-items: center; gap: 6px; margin-top: 6px; }
.carrello-item-qta {
    display: flex; align-items: center; gap: 0;
    border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden;
}
.carrello-item-qta button {
    background: var(--border-light); border: none; width: 24px; height: 24px;
    cursor: pointer; font-size: 0.8125rem; color: var(--text);
}
.carrello-item-qta button:hover { background: var(--border); }
.carrello-item-qta span {
    width: 32px; height: 24px; display: flex; align-items: center; justify-content: center;
    font-size: 0.8125rem; background: var(--surface);
}
.carrello-item-rimuovi {
    background: none; border: none; color: var(--text-muted); cursor: pointer;
    padding: 2px; font-size: 0.75rem; transition: color 0.15s;
}
.carrello-item-rimuovi:hover { color: var(--danger); }
.carrello-item-totale {
    font-size: 0.8125rem; font-weight: 600; color: var(--text);
    text-align: right; flex-shrink: 0; align-self: center;
}
.carrello-svuota {
    display: block; width: 100%; margin-top: 8px; padding: 6px;
    background: none; border: 1px solid var(--border); border-radius: var(--radius-sm);
    color: var(--text-muted); font-size: 0.75rem; cursor: pointer;
    transition: color 0.15s, border-color 0.15s;
}
.carrello-svuota:hover { color: var(--danger); border-color: var(--danger); }

/* ── Responsive ── */
@media (max-width: 768px) {
    .pub-navbar-title { display: none; }
    .pub-navbar-search { max-width: none; }
    .pub-btn-filtri-mobile { display: block; }
    .pub-user-name { display: none; }

    .catalogo-container { flex-direction: column; padding: 12px; gap: 0; }
    .catalogo-filtri {
        position: fixed; top: 0; left: -280px; width: 280px; height: 100vh;
        z-index: 150; border-radius: 0; overflow-y: auto;
        transition: left 0.3s ease;
    }
    .catalogo-filtri.open { left: 0; }
    .catalogo-filtri-overlay {
        position: fixed; inset: 0; background: rgba(0,0,0,0.4); z-index: 149;
    }
    .catalogo-filtri-overlay.open { display: block; }

    .catalogo-griglia { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 10px; }
    .prodotto-card-body { padding: 8px; }
    .prodotto-card-prezzo { font-size: 0.875rem; }
    .prodotto-card-btn { padding: 5px 8px; font-size: 0.6875rem; }

    .carrello-drawer { width: 100%; right: -100%; }

    .dettaglio-layout { flex-direction: column; }
    .dettaglio-gallery { flex: none; }
}
