/* ===== Variabili brand ===== */
:root {
    --brand-primary: #1a3a5c;
    --brand-secondary: #c5a44e;
    --brand-light: #f8f9fa;
    --brand-dark: #0d1b2a;
}

/* ===== Generali ===== */
body {
    background-color: var(--brand-light);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* ===== Navbar ===== */
.navbar-brand {
    font-weight: 700;
    letter-spacing: 0.5px;
}

.navbar {
    background-color: var(--brand-primary) !important;
}

/* ===== Login ===== */
.card {
    border-radius: 12px;
}

.btn-primary {
    background-color: var(--brand-primary);
    border-color: var(--brand-primary);
}

.btn-primary:hover {
    background-color: var(--brand-dark);
    border-color: var(--brand-dark);
}

.text-primary {
    color: var(--brand-primary) !important;
}

/* ===== Configuratore Layout ===== */
.configuratore-form {
    max-height: calc(100vh - 80px);
    overflow-y: auto;
}

.riepilogo-sticky {
    position: sticky;
    top: 76px;
    max-height: calc(100vh - 90px);
    overflow-y: auto;
}

/* ===== Accordion personalizzato ===== */
.accordion-button:not(.collapsed) {
    background-color: rgba(26, 58, 92, 0.08);
    color: var(--brand-primary);
    font-weight: 600;
}

.accordion-button:focus {
    box-shadow: 0 0 0 0.2rem rgba(26, 58, 92, 0.25);
}

.accordion-button .badge {
    font-size: 0.7rem;
}

/* ===== Badge prezzo ===== */
.badge-prezzo {
    font-size: 0.75rem;
    font-weight: 600;
    padding: 3px 8px;
    border-radius: 4px;
    background-color: #e8f4e8;
    color: #2e7d32;
    white-space: nowrap;
}

.badge-prezzo.supplemento {
    background-color: #fff3e0;
    color: #e65100;
}

.badge-prezzo.incluso {
    background-color: #e3f2fd;
    color: #1565c0;
}

.badge-prezzo.sconto {
    background-color: #fce4ec;
    color: #c62828;
}

/* ===== Riepilogo ===== */
.riepilogo-card {
    border: 2px solid var(--brand-primary);
    border-radius: 12px;
}

.riepilogo-card .card-header {
    background-color: var(--brand-primary);
    color: white;
    border-radius: 10px 10px 0 0;
    font-weight: 600;
}

.riepilogo-riga {
    display: flex;
    justify-content: space-between;
    padding: 4px 0;
    font-size: 0.9rem;
}

.riepilogo-riga.totale {
    font-size: 1.1rem;
    font-weight: 700;
    border-top: 2px solid var(--brand-primary);
    padding-top: 8px;
    margin-top: 4px;
    color: var(--brand-primary);
}

.riepilogo-riga .etichetta {
    color: #555;
}

.riepilogo-riga .valore {
    font-weight: 600;
    text-align: right;
}

/* ===== Riepilogo Mobile ===== */
.riepilogo-mobile {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--brand-primary);
    color: white;
    padding: 10px 16px;
    z-index: 1030;
    display: none;
    box-shadow: 0 -2px 10px rgba(0,0,0,0.2);
}

.riepilogo-mobile .totale-mobile {
    font-size: 1.2rem;
    font-weight: 700;
}

/* ===== Form ===== */
.form-label {
    font-weight: 500;
    font-size: 0.875rem;
    margin-bottom: 0.25rem;
}

.form-select, .form-control {
    font-size: 0.9rem;
}

select.form-select option:disabled {
    color: #999;
}

/* Sezione con prezzo inline */
.opzione-con-prezzo {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* ===== Responsive ===== */
@media (max-width: 991.98px) {
    .riepilogo-sticky {
        position: static;
        max-height: none;
    }

    .riepilogo-mobile {
        display: flex;
        justify-content: space-between;
        align-items: center;
    }

    main.container-fluid {
        padding-bottom: 70px;
    }
}

@media (min-width: 992px) {
    .riepilogo-mobile {
        display: none !important;
    }
}

/* ===== Spinner di caricamento listino ===== */
.caricamento-listino {
    text-align: center;
    padding: 3rem;
}

.caricamento-listino .spinner-border {
    width: 3rem;
    height: 3rem;
}

/* ===== Utilità ===== */
.cursor-pointer {
    cursor: pointer;
}

.text-brand {
    color: var(--brand-primary);
}

.bg-brand {
    background-color: var(--brand-primary);
}

.border-brand {
    border-color: var(--brand-primary) !important;
}

/* ===== Area Admin ===== */
.area-admin {
    max-width: 1400px;
}

.nav-admin .nav-link {
    color: var(--brand-primary);
    font-weight: 500;
    font-size: 0.9rem;
}

.nav-admin .nav-link.active {
    color: var(--brand-primary);
    border-color: var(--brand-primary);
    font-weight: 600;
}

/* Tabella admin */
.table-admin {
    font-size: 0.875rem;
}

.table-admin thead {
    background-color: var(--brand-light);
    position: sticky;
    top: 0;
    z-index: 1;
}

.table-admin thead th {
    font-weight: 600;
    color: var(--brand-primary);
    border-bottom: 2px solid var(--brand-primary);
    padding: 8px 12px;
    white-space: nowrap;
}

.table-admin tbody td {
    padding: 8px 12px;
    vertical-align: middle;
}

.riga-hover:hover {
    background-color: rgba(26, 58, 92, 0.04);
}

/* Card statistiche dashboard */
.stat-card {
    border: none;
    border-radius: 10px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    transition: transform 0.15s;
}

.stat-card:hover {
    transform: translateY(-2px);
}

.stat-card .stat-icona {
    width: 48px;
    height: 48px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
}

.stat-card .stat-valore {
    font-size: 1.8rem;
    font-weight: 700;
    line-height: 1;
    color: var(--brand-dark);
}

.stat-card .stat-etichetta {
    font-size: 0.8rem;
    color: #888;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Editor listino */
.listino-card {
    border: 1px solid #dee2e6;
    border-radius: 10px;
    transition: box-shadow 0.15s;
    cursor: pointer;
}

.listino-card:hover {
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.listino-card .card-body {
    padding: 1rem;
}

.listino-card .sezione-icona {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
}

/* Editor JSON */
.editor-json textarea {
    font-family: 'Cascadia Code', 'Fira Code', 'Consolas', monospace;
    font-size: 0.8rem;
    line-height: 1.5;
    tab-size: 2;
    min-height: 400px;
    resize: vertical;
}

.editor-json .validazione-ok {
    color: #198754;
    font-size: 0.8rem;
}

.editor-json .validazione-errore {
    color: #dc3545;
    font-size: 0.8rem;
}

/* Editor tabellare */
.editor-tabella input,
.editor-tabella select {
    font-size: 0.8rem;
    padding: 4px 8px;
}

.editor-tabella .riga-nuova {
    background-color: #f0fff0;
}

.editor-tabella .riga-modificata {
    background-color: #fffff0;
}

/* Editor tabellare universale */
.editor-tabellare-universale input.campo-editor {
    font-size: 0.8rem;
    padding: 3px 8px;
}

.editor-tabellare-universale input.campo-prezzo {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.editor-tabellare-universale .campo-singolo-wrapper {
    display: inline-block;
    margin-bottom: 0.5rem;
    margin-right: 1rem;
    min-width: 150px;
}

/* Tabella hover righe */
.table-hover-editor tbody tr:hover {
    background-color: rgba(26, 58, 92, 0.04);
}

.table-hover-editor thead th {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--brand-primary);
    background-color: var(--brand-light);
}

.table-hover-editor td {
    padding: 2px 4px;
    vertical-align: middle;
}

.table-hover-editor td input {
    border: 1px solid transparent;
    background: transparent;
    transition: border-color 0.15s;
}

.table-hover-editor td input:focus {
    border-color: var(--brand-primary);
    background: #fff;
}

/* Note/badge informativo */
.nota-listino {
    background: #e3f2fd;
    border-left: 3px solid #1976d2;
    padding: 6px 10px;
    border-radius: 0 4px 4px 0;
    color: #1565c0;
}

/* Accordion nested - livelli visivi */
.accordion-nested .accordion-item {
    border: 1px solid #dee2e6;
    margin-bottom: 2px;
    border-radius: 6px !important;
    overflow: hidden;
}

.accordion-nested .accordion-button {
    padding: 8px 14px;
    font-size: 0.875rem;
    font-weight: 500;
}

.accordion-nested .accordion-body {
    padding: 10px 14px;
}

/* Livello 1 */
.accordion-btn-livello-1 {
    font-size: 0.85rem;
    background: rgba(26, 58, 92, 0.03);
}

.accordion-btn-livello-1:not(.collapsed) {
    background: rgba(26, 58, 92, 0.08);
    color: var(--brand-primary);
    font-weight: 600;
}

/* Livello 2 */
.accordion-btn-livello-2 {
    font-size: 0.82rem;
    background: rgba(111, 66, 193, 0.03);
}

.accordion-btn-livello-2:not(.collapsed) {
    background: rgba(111, 66, 193, 0.08);
    color: #6f42c1;
    font-weight: 600;
}

/* Livello 3+ */
.accordion-btn-livello-3 {
    font-size: 0.8rem;
    background: rgba(25, 135, 84, 0.03);
}

.accordion-btn-livello-3:not(.collapsed) {
    background: rgba(25, 135, 84, 0.08);
    color: #198754;
    font-weight: 600;
}

/* Griglia campi */
.griglia-campi label {
    font-size: 0.75rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Tabella editor wrapper */
.tabella-editor-wrapper {
    border: 1px solid #dee2e6;
    border-radius: 6px;
    padding: 8px;
    background: #fafafa;
}

/* Preview JSON */
#preview-json pre {
    font-family: 'Cascadia Code', 'Fira Code', 'Consolas', monospace;
}

/* Lista semplice */
.lista-semplice .input-group {
    max-width: 400px;
}

/* Dropdown navbar admin */
.dropdown-menu-dark .dropdown-item:hover {
    background-color: rgba(197, 164, 78, 0.2);
}

/* Badge stato */
.badge {
    font-size: 0.75rem;
    text-transform: capitalize;
}
