/* =====================================================================
   Tema ispirato a SAP Business One (look & feel)
   Override di Bootstrap per riprodurre l'estetica del gestionale B1.
   ===================================================================== */

:root {
    --b1-titlebar: #354a5f;       /* barra titolo scura */
    --b1-blue: #0a6ed1;           /* blu principale (azioni) */
    --b1-blue-dark: #085caf;
    --b1-title-grad-1: #5a8bbd;   /* barra titolo dei pannelli */
    --b1-title-grad-2: #3a6ea5;
    --b1-bg: #e9eef3;             /* sfondo area di lavoro */
    --b1-panel: #ffffff;
    --b1-border: #b8c4d0;
    --b1-border-soft: #d3dde6;
    --b1-grid-head: #dfe7ef;
    --b1-row-sel: #cfe3f7;
    --b1-row-alt: #f4f7fa;
    --b1-text: #32363a;
    --b1-muted: #6a7888;
    --b1-toolbar-1: #f2f6fa;
    --b1-toolbar-2: #dde6ef;
    --b1-menu: #f7f9fb;
}

* { box-sizing: border-box; }

body {
    background: var(--b1-bg);
    color: var(--b1-text);
    font-family: "72", "Segoe UI", Arial, Helvetica, sans-serif;
    font-size: 12px;
}

/* ---------- Struttura applicazione ---------- */
.b1-app { display: flex; flex-direction: column; height: 100vh; overflow: hidden; }

.b1-titlebar {
    background: var(--b1-titlebar);
    color: #fff;
    height: 34px;
    display: flex; align-items: center; justify-content: space-between;
    padding: 0 12px;
    flex-shrink: 0;
}
.b1-titlebar .b1-product { font-weight: 700; letter-spacing: .2px; display: flex; align-items: center; gap: 8px; }
.b1-titlebar .b1-product i { color: #7fb1e0; }
.b1-titlebar .b1-user { display: flex; align-items: center; gap: 12px; font-size: 11.5px; }
.b1-titlebar .b1-user form { margin: 0; }
.b1-titlebar .b1-logout {
    background: transparent; border: 1px solid #5c7b95; color: #fff;
    border-radius: 3px; padding: 2px 8px; font-size: 11px; cursor: pointer;
}
.b1-titlebar .b1-logout:hover { background: #46607a; }

/* ---------- Barra dei menu ---------- */
.b1-menubar {
    background: var(--b1-menu);
    border-bottom: 1px solid var(--b1-border);
    height: 26px; display: flex; align-items: stretch;
    padding: 0 4px; flex-shrink: 0;
}
.b1-menubar .dropdown > button {
    background: transparent; border: none; color: var(--b1-text);
    padding: 0 10px; font-size: 12px; height: 100%; cursor: pointer;
}
.b1-menubar .dropdown > button:hover { background: #d8e6f5; }
.b1-menubar .dropdown-menu { font-size: 12px; border-radius: 0; border: 1px solid var(--b1-border); }
.b1-menubar .dropdown-item { padding: 4px 14px; }

/* ---------- Toolbar icone ---------- */
.b1-toolbar {
    background: linear-gradient(180deg, var(--b1-toolbar-1), var(--b1-toolbar-2));
    border-bottom: 1px solid var(--b1-border);
    height: 36px; display: flex; align-items: center; gap: 2px;
    padding: 0 8px; flex-shrink: 0;
}
.b1-toolbar a, .b1-toolbar button {
    width: 28px; height: 28px; border: 1px solid transparent; border-radius: 3px;
    display: inline-flex; align-items: center; justify-content: center;
    color: #3a4b5c; font-size: 15px; text-decoration: none; background: transparent; cursor: pointer;
}
.b1-toolbar a:hover, .b1-toolbar button:hover { border-color: #9bb6cf; background: #eaf2fb; }
.b1-toolbar .sep { width: 1px; height: 20px; background: var(--b1-border); margin: 0 5px; }

/* ---------- Corpo: tree + contenuto ---------- */
.b1-body { flex: 1; display: flex; min-height: 0; }

.b1-tree {
    width: 232px; flex-shrink: 0; background: var(--b1-panel);
    border-right: 1px solid var(--b1-border); overflow-y: auto;
}
.b1-tree-head {
    background: linear-gradient(180deg, var(--b1-title-grad-1), var(--b1-title-grad-2));
    color: #fff; font-weight: 700; padding: 6px 10px; font-size: 12px;
    display: flex; align-items: center; gap: 6px;
}
.b1-tree details { border-bottom: 1px solid #eef2f6; }
.b1-tree summary {
    list-style: none; cursor: pointer; padding: 5px 10px; font-weight: 600;
    display: flex; align-items: center; gap: 7px; color: #2a3a4a;
}
.b1-tree summary::-webkit-details-marker { display: none; }
.b1-tree summary::before {
    content: "\2212"; /* minus */ width: 12px; text-align: center; color: var(--b1-muted); font-weight: 700;
}
.b1-tree details:not([open]) summary::before { content: "+"; }
.b1-tree summary:hover { background: #eef4fb; }
.b1-tree .b1-leaf {
    display: flex; align-items: center; gap: 8px; padding: 4px 10px 4px 28px;
    color: var(--b1-text); text-decoration: none; font-size: 12px;
}
.b1-tree .b1-leaf i { color: #d4a017; font-size: 13px; } /* icone "documento" giallo B1 */
.b1-tree .b1-leaf:hover { background: #eaf2fb; }
.b1-tree .b1-leaf.active { background: var(--b1-row-sel); }
.b1-tree .b1-leaf.cassa i { color: #16a34a; }

.b1-content { flex: 1; overflow: auto; padding: 14px 16px; min-width: 0; }
.b1-page-title { font-size: 15px; font-weight: 700; color: #2a3a4a; margin: 0 0 12px; padding-bottom: 6px; border-bottom: 1px solid var(--b1-border-soft); }

/* ---------- Status bar ---------- */
.b1-statusbar {
    background: var(--b1-titlebar); color: #cdd8e2; height: 24px;
    display: flex; align-items: center; justify-content: space-between;
    padding: 0 12px; font-size: 11px; flex-shrink: 0;
}

/* ---------- Pannelli (card -> form B1) ---------- */
.card {
    background: var(--b1-panel); border: 1px solid var(--b1-border);
    border-radius: 3px; box-shadow: none; margin-bottom: 12px;
}
.card-header {
    background: linear-gradient(180deg, var(--b1-title-grad-1), var(--b1-title-grad-2));
    color: #fff; font-weight: 700; font-size: 12px; border: none;
    border-radius: 0 !important; padding: 5px 10px;
}
.card-body { padding: 12px; }

/* ---------- Form ---------- */
.form-label { font-size: 11.5px; color: #4a5b6c; margin-bottom: 2px; font-weight: 600; }
.form-control, .form-select {
    font-size: 12px; border: 1px solid var(--b1-border); border-radius: 2px;
    padding: 3px 6px; min-height: 28px; background: #fff; color: var(--b1-text);
}
.form-control:focus, .form-select:focus {
    border-color: var(--b1-blue); box-shadow: 0 0 0 2px rgba(10,110,209,.15);
}
.form-control-color { padding: 2px; }
textarea.form-control { min-height: 60px; }

/* ---------- Pulsanti B1 ---------- */
.btn {
    font-size: 12px; border-radius: 2px; padding: 4px 12px; font-weight: 600;
    border: 1px solid var(--b1-border);
}
.btn-primary { background: var(--b1-blue); border-color: var(--b1-blue-dark); color: #fff; }
.btn-primary:hover { background: var(--b1-blue-dark); border-color: var(--b1-blue-dark); }
.btn-success { background: #2e7d32; border-color: #1b5e20; }
.btn-success:hover { background: #1b5e20; }
.btn-danger { background: #c62828; border-color: #a31515; }
.btn-light, .btn-outline-secondary {
    background: linear-gradient(180deg, #fbfdff, #e7eef5); color: #33485c; border-color: var(--b1-border);
}
.btn-light:hover, .btn-outline-secondary:hover { background: #dfeaf4; }
.btn-outline-primary { color: var(--b1-blue); border-color: var(--b1-blue); }
.btn-outline-primary:hover { background: var(--b1-blue); color: #fff; }
.btn-outline-dark { color: #33485c; border-color: var(--b1-border); background: linear-gradient(180deg,#fbfdff,#e7eef5); }
.btn-sm { padding: 2px 8px; font-size: 11px; }
.btn-lg { padding: 8px 16px; font-size: 14px; }

/* ---------- Tabelle / griglie B1 ---------- */
.table { font-size: 12px; color: var(--b1-text); margin-bottom: 0; }
.table > thead > tr > th {
    background: var(--b1-grid-head); color: #2f3e4d; font-weight: 700;
    border-bottom: 1px solid var(--b1-border); border-top: 1px solid var(--b1-border);
    padding: 5px 8px; white-space: nowrap;
}
.table > tbody > tr > td { padding: 4px 8px; border-color: var(--b1-border-soft); vertical-align: middle; }
.table-hover > tbody > tr:hover > td { background: #eaf2fb; }
.table-striped > tbody > tr:nth-of-type(odd) > td { background: var(--b1-row-alt); }
.card .table-responsive { border-top: none; }

/* ---------- Badge ---------- */
.badge { font-size: 10.5px; font-weight: 600; border-radius: 2px; }

/* ---------- Tile statistiche (stile cockpit B1) ---------- */
.stat-card {
    background: var(--b1-panel); border: 1px solid var(--b1-border); border-radius: 3px;
    padding: 12px 14px; display: flex; align-items: center; gap: 12px; height: 100%;
}
.stat-icon { width: 42px; height: 42px; border-radius: 4px; display: flex; align-items: center; justify-content: center; font-size: 1.25rem; }
.stat-value { font-size: 1.15rem; font-weight: 700; line-height: 1.1; color: #2a3a4a; }
.stat-label { color: var(--b1-muted); font-size: .78rem; }

/* ---------- Tabs (configuratore) ---------- */
.nav-tabs { border-bottom: 1px solid var(--b1-border); }
.nav-tabs .nav-link { font-size: 12px; color: #4a5b6c; border-radius: 0; padding: 6px 14px; }
.nav-tabs .nav-link.active { color: var(--b1-blue); border-color: var(--b1-border) var(--b1-border) #fff; font-weight: 700; }

/* ---------- Alert ---------- */
.alert { font-size: 12px; border-radius: 2px; padding: 8px 12px; }

/* ---------- Login B1 ---------- */
.auth-body {
    min-height: 100vh; display: flex; align-items: center; justify-content: center;
    background: linear-gradient(135deg, #46607a, #2c3e50);
    padding: 20px;
}
.auth-card {
    background: #fff; border: 1px solid var(--b1-border); border-radius: 4px;
    width: 100%; max-width: 380px; box-shadow: 0 12px 36px rgba(0,0,0,.35); overflow: hidden;
}
.auth-brand {
    background: var(--b1-titlebar); color: #fff; font-size: 1.05rem; font-weight: 700;
    text-align: left; padding: 12px 18px; margin: 0;
}
.auth-brand i { color: #7fb1e0; }
.auth-title { font-size: 1rem; padding: 0; margin: 0 0 14px; }
.auth-card form, .auth-card .alert, .auth-card .auth-title { margin-left: 18px; margin-right: 18px; }
.auth-card form { padding-bottom: 18px; }

/* ---------- Mobile ---------- */
@media (max-width: 820px) {
    .b1-tree { position: fixed; left: -232px; z-index: 1050; height: calc(100vh - 120px); transition: left .2s; }
    .b1-tree.open { left: 0; }
    .b1-content { padding: 10px; }
}
