/* ================================================================
   VisionX — enterprise design language (Fiori-inspired)
   Clean, dense, professional. Light/dark via Bootstrap 5.3 themes.
   ================================================================ */

:root {
    --ix-sidebar-width: 248px;
    --ix-topbar-height: 52px;
    --ix-radius: 8px;
    --ix-shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .10);
    --ix-brand: #0a6ed1;            /* Fiori-like action blue */
    --ix-brand-dark: #0854a0;
    --ix-good: #107e3e;
    --ix-warn: #e9730c;
    --ix-crit: #bb0000;
    --ix-sidebar-bg: #1d2733;
    --ix-sidebar-fg: #c3ccd8;
}

body { font-size: .875rem; background: var(--bs-body-bg); }
[data-bs-theme="dark"] body { --ix-shadow: 0 1px 3px rgba(0,0,0,.4); }

/* ---------- Shell layout ---------- */
.ix-shell { display: flex; min-height: 100vh; }
.ix-sidebar {
    width: var(--ix-sidebar-width);
    background: var(--ix-sidebar-bg);
    color: var(--ix-sidebar-fg);
    flex-shrink: 0;
    display: flex; flex-direction: column;
    position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.ix-brand {
    display: flex; align-items: center; gap: .55rem;
    padding: .9rem 1rem; font-size: 1rem; color: #fff;
    border-bottom: 1px solid rgba(255,255,255,.08);
}
.ix-brand i { color: #4db1ff; font-size: 1.2rem; }
.ix-nav { padding: .5rem 0 2rem; }
.ix-nav-heading {
    padding: .9rem 1rem .3rem; font-size: .68rem; letter-spacing: .08em;
    text-transform: uppercase; color: #7d8899;
}
.ix-nav-link {
    display: flex; align-items: center; gap: .6rem;
    padding: .45rem 1rem; color: var(--ix-sidebar-fg);
    text-decoration: none; font-size: .84rem; border-left: 3px solid transparent;
}
.ix-nav-link i { font-size: .95rem; width: 1.1rem; text-align: center; }
.ix-nav-link:hover { background: rgba(255,255,255,.06); color: #fff; }
.ix-nav-link.active { background: rgba(77,177,255,.12); color: #fff; border-left-color: #4db1ff; }

.ix-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.ix-topbar {
    height: var(--ix-topbar-height);
    display: flex; align-items: center; gap: 1rem;
    padding: 0 1rem;
    background: var(--bs-body-bg);
    border-bottom: 1px solid var(--bs-border-color);
    position: sticky; top: 0; z-index: 1020;
}
.ix-search { position: relative; flex: 1; max-width: 480px; }
.ix-search i { position: absolute; left: .6rem; top: 50%; transform: translateY(-50%); color: var(--bs-secondary-color); }
.ix-search input { padding-left: 2rem; }
.ix-topbar-right { display: flex; align-items: center; gap: .5rem; margin-left: auto; }
.ix-content { padding: 1.1rem 1.25rem 3rem; }

/* ---------- Cards / widgets ---------- */
.ix-card {
    background: var(--bs-body-bg);
    border: 1px solid var(--bs-border-color);
    border-radius: var(--ix-radius);
    box-shadow: var(--ix-shadow);
    height: 100%;
}
.ix-card .ix-card-header {
    display: flex; justify-content: space-between; align-items: center;
    padding: .6rem .85rem; border-bottom: 1px solid var(--bs-border-color);
    font-weight: 600; font-size: .8rem;
}
.ix-card .ix-card-body { padding: .85rem; }

/* KPI card */
.ix-kpi-value { font-size: 1.45rem; font-weight: 700; line-height: 1.15; letter-spacing: -.01em; }
.ix-kpi-label { font-size: .74rem; color: var(--bs-secondary-color); text-transform: uppercase; letter-spacing: .04em; }
.ix-kpi-delta { font-size: .78rem; font-weight: 600; }
.ix-kpi-delta.up { color: var(--ix-good); }
.ix-kpi-delta.down { color: var(--ix-crit); }
.ix-kpi-target { font-size: .72rem; color: var(--bs-secondary-color); }
.ix-status-strip { width: 4px; align-self: stretch; border-radius: 4px; }
.ix-status-strip.good { background: var(--ix-good); }
.ix-status-strip.warning { background: var(--ix-warn); }
.ix-status-strip.critical { background: var(--ix-crit); }
.ix-status-strip.neutral { background: var(--bs-border-color); }

/* Widget grid (12-col CSS grid, responsive) */
.ix-grid { display: grid; grid-template-columns: repeat(12, 1fr); gap: .8rem; grid-auto-rows: 88px; }
.ix-grid > .ix-widget { grid-column: span var(--w, 3); grid-row: span var(--h, 2); min-width: 0; }
@media (max-width: 1199px) { .ix-grid > .ix-widget { grid-column: span max(var(--w, 3), 6) !important; } }
@media (max-width: 767px)  { .ix-grid > .ix-widget { grid-column: 1 / -1 !important; } }
.ix-widget .ix-card { display: flex; flex-direction: column; }
.ix-widget .ix-card-body { flex: 1; overflow: auto; position: relative; }
.ix-widget canvas { max-height: 100%; }

/* Tables */
.ix-table { font-size: .8rem; margin-bottom: 0; }
.ix-table th { font-size: .7rem; text-transform: uppercase; letter-spacing: .04em; color: var(--bs-secondary-color); white-space: nowrap; }
.ix-table td.num, .ix-table th.num { text-align: right; font-variant-numeric: tabular-nums; }

/* States */
.ix-state { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .4rem; padding: 1.4rem; color: var(--bs-secondary-color); text-align: center; min-height: 100px; }
.ix-state i { font-size: 1.4rem; opacity: .6; }
.ix-state.error { color: var(--ix-crit); }

/* Severity badges */
.badge.sev-CRITICAL { background: var(--ix-crit); }
.badge.sev-HIGH { background: #d9480f; }
.badge.sev-MEDIUM { background: var(--ix-warn); }
.badge.sev-LOW { background: #6c757d; }
.badge.sev-INFO { background: var(--ix-brand); }

/* Freshness */
.ix-freshness { font-size: .72rem; display: inline-flex; align-items: center; gap: .3rem; }
.ix-freshness .dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.ix-freshness .dot.fresh { background: var(--ix-good); }
.ix-freshness .dot.aging { background: var(--ix-warn); }
.ix-freshness .dot.stale, .ix-freshness .dot.never { background: var(--ix-crit); }

/* AI */
.ix-ai-bubble { border-radius: var(--ix-radius); padding: .75rem .9rem; margin-bottom: .6rem; max-width: 90%; white-space: pre-wrap; }
.ix-ai-bubble.user { background: var(--ix-brand); color: #fff; margin-left: auto; }
.ix-ai-bubble.assistant { background: var(--bs-secondary-bg); }
.ix-ai-evidence { font-size: .72rem; color: var(--bs-secondary-color); border-top: 1px dashed var(--bs-border-color); margin-top: .5rem; padding-top: .4rem; }
.ix-ai-badge { background: linear-gradient(135deg, #7b2ff7, #0a6ed1); color: #fff; font-size: .68rem; padding: .15rem .5rem; border-radius: 99px; }

/* Login */
.ix-login { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(160deg, #12202f, #1d3a57); }
.ix-login-card { width: 100%; max-width: 400px; }

/* Mobile sidebar */
@media (max-width: 991px) {
    .ix-sidebar { position: fixed; z-index: 1040; left: calc(-1 * var(--ix-sidebar-width)); transition: left .2s ease; }
    .ix-sidebar.open { left: 0; }
    .ix-burger { font-size: 1.3rem; color: var(--bs-body-color); }
}

/* Misc */
.ix-page-title { font-size: 1.1rem; font-weight: 700; margin: 0; }
.ix-page-sub { font-size: .78rem; color: var(--bs-secondary-color); }
.ix-filterbar { display: flex; flex-wrap: wrap; gap: .5rem; align-items: end; margin-bottom: 1rem; }
.ix-filterbar .form-label { font-size: .7rem; margin-bottom: .15rem; color: var(--bs-secondary-color); }
a { color: var(--ix-brand); }
.btn-primary { --bs-btn-bg: var(--ix-brand); --bs-btn-border-color: var(--ix-brand); --bs-btn-hover-bg: var(--ix-brand-dark); --bs-btn-hover-border-color: var(--ix-brand-dark); }
