/* ═══════════════════════════════════════════════════════════════════════
   KI-FABRIK  –  Complete Redesign  2026
   Design: Deep Navy + Electric Blue  ·  Font: Outfit + JetBrains Mono
═══════════════════════════════════════════════════════════════════════ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg-base:    #080d14;
  --bg-surface: #0d1520;
  --bg-card:    #111d2e;
  --bg-card-2:  #162035;
  --bg-hover:   #1a2840;
  --border:     #1e3050;
  --border-2:   #243a5a;
  --blue:       #3b82f6;
  --cyan:       #06b6d4;
  --purple:     #8b5cf6;
  --green:      #22c55e;
  --yellow:     #f59e0b;
  --red:        #ef4444;
  --orange:     #f97316;
  --text-1:     #f0f6ff;
  --text-2:     #a8c0df;
  --text-3:     #6b85a8;
  --sidebar-w:  240px;
  --sidebar-w-c:64px;
  --r-sm: 8px; --r-md: 12px; --r-lg: 16px;
}

html { font-size: 15px; }
body { font-family: 'Outfit', system-ui, sans-serif; background: var(--bg-base); color: var(--text-1); min-height: 100vh; overflow-x: hidden; line-height: 1.5; }

/* Background */
.bg-gradient { position: fixed; inset: 0; pointer-events: none; z-index: 0;
  background: radial-gradient(ellipse 70% 50% at 20% 10%, rgba(59,130,246,0.07) 0%, transparent 60%),
              radial-gradient(ellipse 50% 40% at 80% 80%, rgba(139,92,246,0.05) 0%, transparent 60%); }

/* Layout */
.shell { display: flex; min-height: 100vh; position: relative; z-index: 1; }

/* ── SIDEBAR ── */
.sidebar {
  width: var(--sidebar-w); background: var(--bg-surface); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; position: fixed; top: 0; left: 0; bottom: 0;
  z-index: 100; transition: width .25s ease, transform .25s ease; overflow: hidden;
}
.sidebar.collapsed { width: var(--sidebar-w-c); }

.sidebar-logo {
  display: flex; align-items: center; gap: 12px; padding: 18px 14px 16px;
  border-bottom: 1px solid var(--border); min-height: 64px; flex-shrink: 0;
}
.logo-mark {
  width: 34px; height: 34px; background: linear-gradient(135deg, var(--blue) 0%, var(--cyan) 100%);
  border-radius: var(--r-md); display: flex; align-items: center; justify-content: center;
  font-size: 16px; flex-shrink: 0; box-shadow: 0 0 16px rgba(59,130,246,.4);
}
.logo-text { font-size: 15px; font-weight: 700; color: var(--text-1); white-space: nowrap; }
.logo-text span { color: var(--blue); }
.sidebar.collapsed .logo-text { display: none; }

.sidebar-nav { flex: 1; overflow-y: auto; overflow-x: hidden; padding: 10px 0; }
.sidebar-nav::-webkit-scrollbar { width: 3px; }
.sidebar-nav::-webkit-scrollbar-thumb { background: var(--border-2); border-radius: 3px; }

.nav-group { margin-bottom: 2px; }
.nav-group-label {
  font-size: 10px; font-weight: 700; letter-spacing: .1em; color: var(--text-3);
  text-transform: uppercase; padding: 10px 14px 3px; white-space: nowrap;
}
.sidebar.collapsed .nav-group-label { visibility: hidden; height: 0; padding: 0; }

.nav-item {
  display: flex; align-items: center; gap: 10px; padding: 9px 14px;
  color: var(--text-2); text-decoration: none; font-size: 13.5px; font-weight: 400;
  cursor: pointer; transition: background .15s, color .15s; white-space: nowrap; position: relative;
}
.nav-item:hover { background: var(--bg-hover); color: var(--text-1); }
.nav-item.active { color: var(--blue); background: rgba(59,130,246,.1); font-weight: 600; }
.nav-item.active::before {
  content: ''; position: absolute; left: 0; top: 0; bottom: 0;
  width: 3px; background: var(--blue); border-radius: 0 2px 2px 0;
}
.nav-icon { width: 20px; height: 20px; display: flex; align-items: center; justify-content: center; font-size: 15px; flex-shrink: 0; }
.nav-label { flex: 1; }
.sidebar.collapsed .nav-label { display: none; }
.sidebar.collapsed .nav-item { justify-content: center; padding: 10px; }
.sidebar.collapsed .nav-item::before { display: none; }
.sidebar.collapsed .nav-item.active { background: rgba(59,130,246,.15); border-radius: var(--r-sm); margin: 0 8px; }

.sidebar-footer { padding: 10px; border-top: 1px solid var(--border); flex-shrink: 0; }
.sidebar-collapse-btn {
  display: flex; align-items: center; gap: 8px; width: 100%; padding: 7px 10px;
  background: transparent; border: 1px solid var(--border); border-radius: var(--r-sm);
  color: var(--text-3); font-size: 12px; cursor: pointer; transition: all .15s;
}
.sidebar-collapse-btn:hover { background: var(--bg-hover); color: var(--text-2); }
.sidebar.collapsed .btn-label { display: none; }
.sidebar.collapsed .sidebar-collapse-btn { justify-content: center; padding: 7px; }

/* ── MAIN ── */
.main { flex: 1; margin-left: var(--sidebar-w); display: flex; flex-direction: column; min-height: 100vh; transition: margin-left .25s ease; }
.sidebar.collapsed ~ .main { margin-left: var(--sidebar-w-c); }

.topbar {
  height: 64px; background: var(--bg-surface); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; padding: 0 24px; gap: 16px;
  position: sticky; top: 0; z-index: 50; flex-shrink: 0;
}
.topbar-title { flex: 1; }
.topbar-title h1 { font-size: 17px; font-weight: 600; }
.topbar-title p  { font-size: 12px; color: var(--text-3); }
.topbar-actions  { display: flex; align-items: center; gap: 8px; }

/* Status dots */
.status-cluster { display: flex; align-items: center; gap: 6px; }
.status-dot {
  display: flex; align-items: center; gap: 5px; font-size: 11px; color: var(--text-3);
  padding: 4px 9px; background: var(--bg-card); border: 1px solid var(--border); border-radius: 999px;
}
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--text-3); }
.dot.green  { background: var(--green);  box-shadow: 0 0 6px var(--green); }
.dot.yellow { background: var(--yellow); box-shadow: 0 0 6px var(--yellow); }
.dot.red    { background: var(--red);    box-shadow: 0 0 6px var(--red); }

.page-content { flex: 1; padding: 24px; max-width: 1400px; width: 100%; }

/* ── BUTTONS ── */
.btn { display: inline-flex; align-items: center; gap: 7px; padding: 8px 16px; border-radius: var(--r-sm); font-size: 13px; font-weight: 500; cursor: pointer; border: none; transition: all .15s; white-space: nowrap; font-family: inherit; }
.btn-primary { background: var(--blue); color: white; }
.btn-primary:hover { background: #2563eb; transform: translateY(-1px); box-shadow: 0 4px 12px rgba(59,130,246,.4); }
.btn-secondary { background: var(--bg-card-2); color: var(--text-2); border: 1px solid var(--border-2); }
.btn-secondary:hover { background: var(--bg-hover); color: var(--text-1); }
.btn-ghost { background: transparent; color: var(--text-2); border: 1px solid var(--border); }
.btn-ghost:hover { background: var(--bg-card); color: var(--text-1); }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ── CARDS ── */
.card { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--r-lg); padding: 20px; }
.card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.card-title { font-size: 14px; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.card-icon { width: 28px; height: 28px; background: var(--bg-card-2); border-radius: var(--r-sm); display: flex; align-items: center; justify-content: center; font-size: 14px; }

/* ── KPI CARDS ── */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; margin-bottom: 24px; }
.kpi-card {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--r-lg);
  padding: 18px; position: relative; overflow: hidden; transition: border-color .2s, transform .2s;
}
.kpi-card:hover { border-color: var(--border-2); transform: translateY(-2px); }
.kpi-card::before { content: ''; position: absolute; top: 0; left: 0; right: 0; height: 2px; }
.kpi-blue::before   { background: linear-gradient(90deg, var(--blue), var(--cyan)); }
.kpi-green::before  { background: linear-gradient(90deg, var(--green), #34d399); }
.kpi-purple::before { background: linear-gradient(90deg, var(--purple), #a78bfa); }
.kpi-orange::before { background: linear-gradient(90deg, var(--orange), #fbbf24); }
.kpi-cyan::before   { background: linear-gradient(90deg, var(--cyan), #67e8f9); }
.kpi-value { font-family: 'JetBrains Mono', monospace; font-size: 26px; font-weight: 700; color: var(--text-1); line-height: 1; margin-bottom: 6px; }
.kpi-label { font-size: 11px; color: var(--text-3); }

/* ── SERVICE CARDS ── */
.services-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(195px, 1fr)); gap: 12px; }
.service-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--r-md); padding: 14px 16px; display: flex; align-items: center; gap: 12px; transition: border-color .2s; }
.service-card:hover { border-color: var(--border-2); }
.service-icon { width: 36px; height: 36px; border-radius: var(--r-sm); display: flex; align-items: center; justify-content: center; font-size: 17px; flex-shrink: 0; }
.service-icon.blue   { background: rgba(59,130,246,.15); }
.service-icon.green  { background: rgba(34,197,94,.12); }
.service-icon.purple { background: rgba(139,92,246,.12); }
.service-icon.cyan   { background: rgba(6,182,212,.12); }
.service-icon.orange { background: rgba(249,115,22,.12); }
.service-name  { font-size: 13px; font-weight: 600; }
.service-url   { font-size: 11px; color: var(--text-3); font-family: 'JetBrains Mono', monospace; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.service-status { font-size: 11px; margin-top: 4px; display: flex; align-items: center; gap: 4px; }
.service-status.online { color: var(--green); }
.service-status.offline { color: var(--red); }
.service-status.unknown { color: var(--text-3); }

/* ── ACTION CARDS ── */
.actions-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px; margin-bottom: 24px; }
.action-card {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--r-lg);
  padding: 20px; cursor: pointer; transition: all .2s; text-decoration: none; display: block;
}
.action-card:hover { border-color: var(--blue); background: rgba(59,130,246,.05); transform: translateY(-3px); box-shadow: 0 8px 24px rgba(59,130,246,.12); }
.action-emoji { font-size: 26px; margin-bottom: 10px; display: block; }
.action-title { font-size: 14px; font-weight: 600; margin-bottom: 4px; }
.action-desc  { font-size: 12px; color: var(--text-3); line-height: 1.4; }

/* ── FORMS ── */
.input, .select, .textarea {
  width: 100%; background: var(--bg-base); border: 1px solid var(--border-2);
  border-radius: var(--r-sm); color: var(--text-1); font-family: inherit;
  font-size: 14px; padding: 10px 12px; transition: border-color .15s; outline: none;
}
.input:focus, .select:focus, .textarea:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(59,130,246,.12); }
.textarea { min-height: 100px; resize: vertical; line-height: 1.5; }
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: 13px; font-weight: 500; color: var(--text-2); margin-bottom: 6px; }

/* ── CODE & RESULTS ── */
.code-block {
  background: #060c16; border: 1px solid var(--border); border-radius: var(--r-md);
  padding: 16px; font-family: 'JetBrains Mono', monospace; font-size: 12px;
  color: #9fd6ff; white-space: pre-wrap; word-break: break-all;
  line-height: 1.6; overflow-x: auto; max-height: 400px; overflow-y: auto;
}
.result-box {
  background: var(--bg-base); border: 1px solid var(--border); border-radius: var(--r-md);
  padding: 16px; font-size: 13px; color: var(--text-2); line-height: 1.7;
  min-height: 80px; white-space: pre-wrap;
}

/* ── BADGES ── */
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 3px 8px; border-radius: 999px; font-size: 11px; font-weight: 500; }
.badge-blue   { background: rgba(59,130,246,.15); color: #60a5fa; border: 1px solid rgba(59,130,246,.25); }
.badge-green  { background: rgba(34,197,94,.1);   color: #4ade80; border: 1px solid rgba(34,197,94,.25); }
.badge-yellow { background: rgba(245,158,11,.1);  color: #fbbf24; border: 1px solid rgba(245,158,11,.25); }
.badge-red    { background: rgba(239,68,68,.1);   color: #f87171; border: 1px solid rgba(239,68,68,.25); }
.badge-purple { background: rgba(139,92,246,.1);  color: #a78bfa; border: 1px solid rgba(139,92,246,.25); }

/* ── TABLES ── */
.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.data-table th { text-align: left; padding: 10px 12px; color: var(--text-3); font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; border-bottom: 1px solid var(--border); }
.data-table td { padding: 10px 12px; border-bottom: 1px solid rgba(30,48,80,.5); color: var(--text-2); vertical-align: middle; }
.data-table tr:hover td { background: rgba(59,130,246,.03); }

/* ── SECTIONS ── */
.section { margin-bottom: 28px; }
.section-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.section-title { font-size: 15px; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.section-title::before { content: ''; width: 3px; height: 18px; background: var(--blue); border-radius: 2px; }

/* ── GRIDS ── */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }
.grid-auto { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }

/* ── TABS ── */
.tabs { display: flex; gap: 2px; background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--r-md); padding: 3px; margin-bottom: 20px; }
.tab-btn { flex: 1; padding: 7px 12px; background: transparent; border: none; color: var(--text-3); font-size: 13px; font-weight: 500; cursor: pointer; border-radius: var(--r-sm); transition: all .15s; font-family: inherit; }
.tab-btn.active { background: var(--blue); color: white; }
.tab-btn:hover:not(.active) { background: var(--bg-hover); color: var(--text-2); }

/* ── MISC ── */
.spinner { width: 20px; height: 20px; border: 2px solid var(--border); border-top-color: var(--blue); border-radius: 50%; animation: spin .8s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }
.loading-state { display: flex; align-items: center; justify-content: center; gap: 12px; padding: 40px; color: var(--text-3); }
.alert { padding: 12px 16px; border-radius: var(--r-md); font-size: 13px; display: flex; gap: 10px; align-items: flex-start; margin-bottom: 16px; }
.alert-info    { background: rgba(59,130,246,.08); border: 1px solid rgba(59,130,246,.2); color: #93c5fd; }
.alert-success { background: rgba(34,197,94,.08);  border: 1px solid rgba(34,197,94,.2);  color: #86efac; }
.alert-warning { background: rgba(245,158,11,.08); border: 1px solid rgba(245,158,11,.2); color: #fcd34d; }
.alert-danger  { background: rgba(239,68,68,.08);  border: 1px solid rgba(239,68,68,.2);  color: #fca5a5; }
.progress-bar { height: 4px; background: var(--border); border-radius: 2px; overflow: hidden; }
.progress-fill { height: 100%; border-radius: 2px; background: linear-gradient(90deg, var(--blue), var(--cyan)); transition: width .5s ease; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .7; } }
.mono { font-family: 'JetBrains Mono', monospace; }
.text-muted { color: var(--text-3); }
.text-sm { font-size: 12px; }
.divider { height: 1px; background: var(--border); margin: 20px 0; }
.flex-center { display: flex; align-items: center; }
.gap-2 { gap: 8px; }
hr { border: none; border-top: 1px solid var(--border); margin: 20px 0; }

/* ── PIPELINE STEPS ── */
.pipeline-steps { display: flex; gap: 0; }
.pipeline-step { flex: 1; background: var(--bg-card); border: 1px solid var(--border); border-radius: 0; padding: 12px 14px; position: relative; }
.pipeline-step:first-child { border-radius: var(--r-md) 0 0 var(--r-md); }
.pipeline-step:last-child  { border-radius: 0 var(--r-md) var(--r-md) 0; }
.pipeline-step + .pipeline-step { border-left: none; }
.pipeline-step.done     { border-top: 2px solid var(--green); }
.pipeline-step.running  { border-top: 2px solid var(--blue); animation: pulse 1.5s ease infinite; }
.pipeline-step.pending  { border-top: 2px solid var(--border); }
.pipeline-step.error    { border-top: 2px solid var(--red); }
.ps-agent  { font-size: 11px; font-weight: 700; color: var(--text-3); text-transform: uppercase; letter-spacing: .06em; }
.ps-status { font-size: 11px; margin-top: 4px; }
.ps-status.done    { color: var(--green); }
.ps-status.running { color: var(--blue); }
.ps-status.error   { color: var(--red); }
.ps-time   { font-family: 'JetBrains Mono', monospace; font-size: 10px; color: var(--text-3); margin-top: 2px; }

/* ── MOBILE ── */
.mobile-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.7); z-index: 90; }
.mobile-menu-btn { display: none; background: transparent; border: 1px solid var(--border); border-radius: var(--r-sm); padding: 7px; color: var(--text-2); cursor: pointer; font-size: 18px; }

@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.mobile-open { transform: translateX(0); width: var(--sidebar-w) !important; }
  .sidebar.mobile-open ~ .mobile-overlay { display: block; }
  .main { margin-left: 0 !important; }
  .page-content { padding: 16px; }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .actions-grid { grid-template-columns: repeat(2, 1fr); }
  .pipeline-steps { flex-direction: column; }
  .pipeline-step { border-radius: var(--r-sm) !important; border-left: 1px solid var(--border) !important; }
  .pipeline-step.done { border-left: 3px solid var(--green) !important; }
  .pipeline-step.running { border-left: 3px solid var(--blue) !important; }
  .topbar-actions .status-cluster { display: none; }
  .mobile-menu-btn { display: block; }
}

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-2); border-radius: 3px; }
