/* ============================================================
   GE.CCO.FIN. - assets/css/gecofin.css
   ============================================================ */

:root {
    --sidebar-w:      240px;
    --topbar-h:       56px;
    --bg:             #f1ede8;
    --bg-card:        #ffffff;
    --border:         #ddd8d0;
    --text:           #1c1c2e;
    --text-muted:     #6b6b7e;
    --accent:         #c0392b;
    --accent-dark:    #96281b;
    --accent2:        #e67e22;
    --sidebar-bg:     #181828;
    --sidebar-text:   rgba(255,255,255,.72);
    --sidebar-active: #ffffff;
    --topbar-bg:      #ffffff;
    --radius:         10px;
    --radius-sm:      6px;
    --shadow:         0 2px 12px rgba(0,0,0,.07);
    --shadow-md:      0 4px 24px rgba(0,0,0,.10);
}

/* ============================================================
   RESET & BASE
   ============================================================ */
*, *::before, *::after { box-sizing: border-box; }

body {
    margin: 0;
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    font-size: .9rem;
    background: var(--bg);
    color: var(--text);
    overflow-x: hidden;
}

a { color: var(--accent); }
a:hover { color: var(--accent-dark); }

/* ============================================================
   SIDEBAR
   ============================================================ */
.sidebar {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    width: var(--sidebar-w);
    background: var(--sidebar-bg);
    display: flex;
    flex-direction: column;
    z-index: 200;
    transition: transform .25s ease;
    overflow: hidden;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 18px 20px;
    border-bottom: 1px solid rgba(255,255,255,.07);
    flex-shrink: 0;
}
.brand-dot {
    width: 10px; height: 10px;
    background: var(--accent);
    border-radius: 50%;
    flex-shrink: 0;
}
.brand-name {
    font-size: 1.1rem;
    font-weight: 700;
    color: #fff;
    letter-spacing: -.3px;
    line-height: 1;
}
.brand-sub {
    font-size: .62rem;
    color: rgba(255,255,255,.35);
    text-transform: uppercase;
    letter-spacing: 1.2px;
    margin-top: 3px;
}

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 10px 0 16px;
}
.sidebar-nav::-webkit-scrollbar { width: 3px; }
.sidebar-nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,.12); border-radius: 2px; }

.nav-section {
    font-size: .6rem;
    text-transform: uppercase;
    letter-spacing: 1.4px;
    color: rgba(255,255,255,.28);
    padding: 16px 20px 4px;
    font-weight: 600;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 20px;
    color: var(--sidebar-text);
    text-decoration: none;
    font-size: .84rem;
    border-left: 3px solid transparent;
    transition: background .15s, color .15s, border-color .15s;
}
.nav-item:hover {
    background: rgba(255,255,255,.05);
    color: #fff;
    text-decoration: none;
    border-left-color: rgba(255,255,255,.2);
}
.nav-item.active {
    background: rgba(255,255,255,.08);
    color: var(--sidebar-active);
    border-left-color: var(--accent);
    font-weight: 500;
}
.nav-item i {
    font-size: .95rem;
    opacity: .8;
    width: 18px;
    text-align: center;
    flex-shrink: 0;
}
.nav-item.active i { opacity: 1; }

.sidebar-footer {
    padding: 14px 20px;
    border-top: 1px solid rgba(255,255,255,.07);
    flex-shrink: 0;
}
.user-chip {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
}
.user-avatar {
    width: 34px; height: 34px;
    background: var(--accent);
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: .72rem;
    font-weight: 700;
    color: #fff;
    flex-shrink: 0;
    letter-spacing: .5px;
}
.user-info { min-width: 0; }
.user-name {
    font-size: .82rem;
    color: rgba(255,255,255,.82);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.2;
}
.user-role {
    font-size: .65rem;
    color: rgba(255,255,255,.35);
    margin-top: 1px;
}
.sidebar-footer-links {
    display: flex;
    gap: 14px;
}
.footer-link {
    font-size: .75rem;
    color: rgba(255,255,255,.3);
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 4px;
    transition: color .15s;
}
.footer-link:hover { color: rgba(255,255,255,.7); text-decoration: none; }

/* ============================================================
   OVERLAY MOBILE
   ============================================================ */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.5);
    z-index: 190;
}

/* ============================================================
   MAIN WRAPPER
   ============================================================ */
.main-wrapper {
    margin-left: var(--sidebar-w);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    transition: margin-left .25s ease;
}

/* ============================================================
   TOPBAR
   ============================================================ */
.topbar {
    height: var(--topbar-h);
    background: var(--topbar-bg);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    position: sticky;
    top: 0;
    z-index: 100;
    flex-shrink: 0;
}
.topbar-left {
    display: flex;
    align-items: center;
    gap: 14px;
}
.topbar-title {
    font-size: .98rem;
    font-weight: 600;
    margin: 0;
    color: var(--text);
}
.topbar-right {
    display: flex;
    align-items: center;
    gap: 10px;
}
.topbar-date {
    font-size: .75rem;
    color: var(--text-muted);
}

.btn-hamburger {
    background: none;
    border: none;
    font-size: 1.35rem;
    color: var(--text);
    cursor: pointer;
    padding: 2px 6px;
    display: none;
    line-height: 1;
    border-radius: var(--radius-sm);
    transition: background .15s;
}
.btn-hamburger:hover { background: #f0ece6; }

.btn-icon {
    background: transparent;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    width: 34px; height: 34px;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer;
    color: var(--text-muted);
    position: relative;
    transition: border-color .15s, color .15s;
    flex-shrink: 0;
}
.btn-icon:hover { border-color: var(--accent); color: var(--accent); }

.notif-badge {
    position: absolute;
    top: -5px; right: -5px;
    background: var(--accent);
    color: #fff;
    border-radius: 50%;
    width: 16px; height: 16px;
    font-size: .58rem;
    display: flex; align-items: center; justify-content: center;
    font-weight: 700;
    border: 2px solid #fff;
}

/* ============================================================
   PAGE CONTENT
   ============================================================ */
.page-content { padding: 24px; flex: 1; }

/* ============================================================
   KPI CARD
   ============================================================ */
.kpi-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px 20px;
    position: relative;
    overflow: hidden;
    transition: box-shadow .2s, transform .2s;
    height: 100%;
}
.kpi-card:hover { box-shadow: var(--shadow); transform: translateY(-2px); }
.kpi-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 3px;
    background: var(--kpi-color, var(--accent));
}
.kpi-icon {
    width: 38px; height: 38px;
    border-radius: 9px;
    background: var(--kpi-bg, #fdecea);
    color: var(--kpi-color, var(--accent));
    display: flex; align-items: center; justify-content: center;
    font-size: 1rem;
    margin-bottom: 10px;
}
.kpi-value {
    font-size: 1.7rem;
    font-weight: 700;
    line-height: 1;
    color: var(--text);
    margin-bottom: 4px;
}
.kpi-label {
    font-size: .68rem;
    text-transform: uppercase;
    letter-spacing: .7px;
    color: var(--text-muted);
    font-weight: 500;
}

/* ============================================================
   CHART CARD
   ============================================================ */
.chart-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    height: 100%;
}
.chart-card-title {
    font-size: .88rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.chart-badge {
    font-size: .68rem;
    background: #f0ece6;
    color: var(--text-muted);
    border-radius: 20px;
    padding: 2px 10px;
    font-weight: 400;
}

/* ============================================================
   TABLE CARD
   ============================================================ */
.table-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}
.table-card-header {
    padding: 14px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 10px;
}
.table-card-title {
    font-size: .9rem;
    font-weight: 600;
    margin: 0;
    color: var(--text);
}

/* ============================================================
   STATO BADGE
   ============================================================ */
.stato-dot {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: .74rem;
    font-weight: 500;
    padding: 3px 9px;
    border-radius: 20px;
    white-space: nowrap;
}

/* ============================================================
   PROGRESS BAR CUSTOM
   ============================================================ */
.progress-sm {
    height: 6px;
    border-radius: 3px;
    background: #ede9e3;
    overflow: hidden;
}
.progress-sm-bar {
    height: 100%;
    border-radius: 3px;
    background: linear-gradient(90deg, var(--accent), var(--accent2));
    transition: width .4s ease;
}

/* ============================================================
   IMPORT DROPZONE
   ============================================================ */
.import-dropzone {
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: 52px 24px;
    text-align: center;
    cursor: pointer;
    transition: border-color .2s, background .2s;
    background: #faf7f3;
}
.import-dropzone:hover,
.import-dropzone.dragover {
    border-color: var(--accent);
    background: #fef5f4;
}
.import-dropzone .drop-icon {
    font-size: 3rem;
    color: var(--accent);
    display: block;
    margin-bottom: 12px;
}

/* ============================================================
   PAGE LOADER
   ============================================================ */
.page-loader {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(255,255,255,.55);
    z-index: 9999;
    align-items: center;
    justify-content: center;
}
.page-loader.show { display: flex; }

/* ============================================================
   FORM
   ============================================================ */
.form-label {
    font-size: .82rem;
    font-weight: 500;
    color: var(--text);
    margin-bottom: 4px;
}
.form-control,
.form-select {
    font-size: .85rem;
    border-color: var(--border);
    border-radius: var(--radius-sm);
}
.form-control:focus,
.form-select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 .2rem rgba(192,57,43,.15);
}
.form-text { font-size: .75rem; }

/* ============================================================
   BOTTONI
   ============================================================ */
.btn-primary { background-color: var(--accent); border-color: var(--accent); }
.btn-primary:hover,
.btn-primary:focus { background-color: var(--accent-dark); border-color: var(--accent-dark); }
.btn-outline-primary { color: var(--accent); border-color: var(--accent); }
.btn-outline-primary:hover { background-color: var(--accent); border-color: var(--accent); }

/* ============================================================
   WBS TREE
   ============================================================ */
.wbs-tree { list-style: none; padding: 0; margin: 0; }
.wbs-node {
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    margin-bottom: 6px;
    background: var(--bg-card);
}
.wbs-node-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    cursor: pointer;
    user-select: none;
}
.wbs-node-children {
    padding: 4px 14px 10px 32px;
    border-top: 1px solid var(--border);
}
.wbs-level-1 { border-left: 3px solid var(--accent); }
.wbs-level-2 { border-left: 3px solid var(--accent2); }
.wbs-level-3 { border-left: 3px solid #2980b9; }

/* ============================================================
   UTILITIES
   ============================================================ */
.fw-500 { font-weight: 500; }
.fw-600 { font-weight: 600; }
.cursor-pointer { cursor: pointer; }

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 991.98px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); box-shadow: var(--shadow-md); }
    .sidebar-overlay.show { display: block; }
    .main-wrapper { margin-left: 0; }
    .btn-hamburger { display: block; }
}
@media (max-width: 767.98px) {
    .page-content { padding: 16px; }
    .kpi-value    { font-size: 1.4rem; }
    .topbar       { padding: 0 14px; }
    .topbar-date  { display: none; }
}
@media (max-width: 575.98px) {
    .table-card-header { flex-direction: column; align-items: flex-start; }
}

/* ============================================================
   SELECT2 — override minimi colori brand GE.CO.FIN.
   Il tema bootstrap-5 gestisce tutto il resto.
   ============================================================ */

/* Focus e open: bordo rosso */
.select2-container--bootstrap-5.select2-container--focus .select2-selection,
.select2-container--bootstrap-5.select2-container--open  .select2-selection {
    border-color: var(--accent) !important;
    box-shadow: 0 0 0 .2rem rgba(192,57,43,.15) !important;
}

/* Hover opzione */
.select2-container--bootstrap-5 .select2-results__option--highlighted {
    background-color: rgba(192,57,43,.10) !important;
    color: var(--accent) !important;
}

/* Opzione selezionata */
.select2-container--bootstrap-5 .select2-results__option[aria-selected=true] {
    background-color: var(--accent) !important;
    color: #fff !important;
}

/* ============================================================
   SELECT2 — larghezze e fix visualizzazione
   ============================================================ */

/* La select originale viene nascosta da Select2 via display:none
   ma con width:auto può collassare a 0 — larghezza minima di sicurezza */
.gf-select { min-width: 120px; }

/* Il container Select2 deve rispettare la larghezza impostata */
.select2-container {
    min-width: 120px;
}

/* Allineamento verticale nella toolbar flex */
.select2-container--bootstrap-5 .select2-selection--single {
    height: 31px !important;
    padding-top: 4px !important;
    padding-bottom: 4px !important;
    font-size: .85rem !important;
    border-color: var(--border) !important;
    border-radius: var(--radius-sm) !important;
}

/* Freccia */
.select2-container--bootstrap-5 .select2-selection--single .select2-selection__arrow {
    height: 29px !important;
}

/* Testo selezionato: no overflow */
.select2-container--bootstrap-5 .select2-selection--single .select2-selection__rendered {
    line-height: 23px !important;
    padding-right: 20px !important;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
