/* ── Robin Dashboard — CSS ── */

html, [data-bs-theme="dark"] {
  --bg-light:      #1a1a2e;
  --bg-panel:      #16213e;
  --bg-sidebar:    #0d1b2a;
  --bg-elevated:   #1e2d45;
  --bg-input:      #0f1923;
  --text-main:     #e0e0e0;
  --text-muted:    #8899aa;
  --accent:        #00d4aa;
  --accent-hover:  #00b894;
  --accent-muted:  rgba(0,212,170,0.15);
  --accent-text:   #0d1b2a;
  --green:         #26a69a;
  --red:           #ef5350;
  --yellow:        #e8b84b;
  --purple:        #b794f4;
  --border:        #1e2d3d;
  --shadow:        0 2px 8px rgba(0,0,0,0.4);
  --shadow-lg:     0 4px 20px rgba(0,0,0,0.6);
  --radius:        8px;
  --radius-lg:     12px;
}

[data-bs-theme="light"] {
  --bg-light:      #f0f4f8;
  --bg-panel:      #ffffff;
  --bg-sidebar:    #1a2940;
  --bg-elevated:   #ffffff;
  --bg-input:      #f7fafc;
  --text-main:     #1a202c;
  --text-muted:    #718096;
  --accent:        #00a688;
  --accent-hover:  #008f75;
  --accent-muted:  rgba(0,166,136,0.12);
  --accent-text:   #ffffff;
  --green:         #00897b;
  --red:           #e53935;
  --yellow:        #c8932a;
  --purple:        #805ad5;
  --border:        #e2e8f0;
  --shadow:        0 1px 4px rgba(0,0,0,0.08);
  --shadow-lg:     0 4px 16px rgba(0,0,0,0.12);
  --radius:        8px;
  --radius-lg:     12px;
}

* { box-sizing: border-box; }
body {
  background-color: var(--bg-light);
  color: var(--text-main);
  font-family: 'Segoe UI', system-ui, sans-serif;
  margin: 0; overflow-x: hidden;
  transition: background-color 0.3s, color 0.3s;
}

/* ── SIDEBAR ── */
.sidebar {
  width: 240px; min-width: 240px;
  height: 100vh;
  background-color: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  box-shadow: 2px 0 8px rgba(0,0,0,0.3);
  display: flex; flex-direction: column;
  z-index: 1000;
  transition: width 0.3s ease, min-width 0.3s ease;
  overflow: hidden;
  flex-shrink: 0;
  position: sticky; top: 0;
}
.sidebar.collapsed { width: 64px; min-width: 64px; }

.sidebar-brand {
  display: flex; align-items: center; gap: 12px;
  padding: 18px 16px; border-bottom: 1px solid var(--border);
  min-height: 64px;
}
.brand-icon {
  width: 34px; height: 34px; border-radius: var(--radius);
  background: var(--accent); color: var(--accent-text);
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 1rem; flex-shrink: 0;
}
.brand-text { overflow: hidden; white-space: nowrap; }
.brand-text strong { display: block; font-size: 0.95rem; color: #e0e0e0; }
.brand-text small { color: #8899aa; font-size: 0.7rem; }

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

.nav-section-label {
  font-size: 0.62rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.1em; color: #556677;
  padding: 14px 10px 4px; white-space: nowrap;
  transition: opacity 0.2s, height 0.2s;
}
.sidebar.collapsed .nav-section-label { opacity: 0; height: 0; padding: 0; margin: 0; overflow: hidden; }

.nav-link {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: var(--radius);
  color: #8899aa; font-size: 0.85rem; font-weight: 500;
  text-decoration: none; cursor: pointer;
  border: none; background: none; width: 100%; text-align: left;
  margin-bottom: 1px; transition: background 0.15s, color 0.15s;
  white-space: nowrap;
}
.nav-link i { font-size: 1rem; flex-shrink: 0; width: 18px; text-align: center; }
.nav-link .nav-text { overflow: hidden; flex: 1; }
.nav-link:hover { background: var(--accent-muted); color: var(--accent); }
.nav-link.active {
  background: var(--accent-muted); color: var(--accent);
  font-weight: 600;
  border-left: 3px solid var(--accent);
  padding-left: 7px;
}
.nav-link .badge { font-size: 0.58rem; margin-left: auto; flex-shrink: 0; }

.sidebar-footer {
  padding: 8px; border-top: 1px solid var(--border);
}
.sidebar-toggle {
  width: 100%; background: none; border: none; color: #556677;
  padding: 8px; border-radius: var(--radius); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: color 0.2s, background 0.2s;
}
.sidebar-toggle:hover { color: var(--text-main); background: rgba(255,255,255,0.04); }

/* ── MAIN ── */
#app-shell {
  display: flex;
  width: 100%;
  height: 100vh;
  overflow: hidden;
}
.main-content {
  flex: 1;
  min-width: 0;
  min-height: 100vh;
  display: flex; flex-direction: column;
  transition: margin-left 0.3s ease;
  overflow-y: auto;
}
.main-content.expanded { margin-left: 0; }

/* ── TOPBAR ── */
.topbar {
  background: var(--bg-panel);
  height: 58px; padding: 0 24px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  position: sticky; top: 0; z-index: 100;
  box-shadow: var(--shadow);
}
.topbar-left h2 { margin: 0; font-size: 1rem; font-weight: 600; }
.topbar-left small { color: var(--text-muted); font-size: 0.72rem; }
.topbar-right { display: flex; align-items: center; gap: 8px; }

.ws-badge { display: flex; align-items: center; gap: 5px; font-size: 0.72rem; color: var(--text-muted); padding: 0 4px; }
.ws-dot { width: 7px; height: 7px; border-radius: 50%; background: #556677; transition: background 0.3s; }
.ws-dot.online { background: var(--accent); box-shadow: 0 0 6px rgba(0,212,170,0.5); }

.btn-icon {
  background: none; border: 1px solid var(--border);
  border-radius: var(--radius); color: var(--text-muted);
  padding: 5px 9px; cursor: pointer; font-size: 0.9rem;
  transition: border-color 0.2s, color 0.2s;
  line-height: 1.4;
}
.btn-icon:hover { border-color: var(--accent); color: var(--accent); }

/* ── PAGE ── */
.page-content { flex: 1; padding: 24px; }
.section { display: none; }
.section.active { display: block; }

/* ── KPI ── */
.kpi-card {
  background: var(--bg-panel); border-radius: var(--radius-lg);
  border: 1px solid var(--border); padding: 18px 20px;
  box-shadow: var(--shadow);
  transition: transform 0.15s, box-shadow 0.15s;
}
.kpi-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.kpi-title {
  color: var(--text-muted); font-size: 0.72rem;
  text-transform: uppercase; font-weight: 700;
  letter-spacing: 0.07em; margin-bottom: 8px;
}
.kpi-value { font-size: 1.65rem; font-weight: 700; line-height: 1; color: var(--text-main); }
.kpi-sub { font-size: 0.75rem; color: var(--text-muted); margin-top: 5px; }
.kpi-border-accent { border-left: 3px solid var(--accent); }
.kpi-border-green  { border-left: 3px solid var(--green); }
.kpi-border-red    { border-left: 3px solid var(--red); }
.kpi-border-yellow { border-left: 3px solid var(--yellow); }
.kpi-border-purple { border-left: 3px solid var(--purple); }

/* ── PANELS ── */
.dashboard-panel {
  background: var(--bg-panel); border-radius: var(--radius-lg);
  border: 1px solid var(--border); padding: 20px;
  box-shadow: var(--shadow);
}
.panel-title {
  font-size: 0.78rem; font-weight: 700; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 0.07em;
  margin-bottom: 16px; display: flex; align-items: center; gap: 8px;
}
.panel-title i { color: var(--accent); }

/* ── TABLES ── */
.table { color: var(--text-main); font-size: 0.85rem; }
.table th {
  color: var(--text-muted); font-weight: 700; font-size: 0.7rem;
  text-transform: uppercase; letter-spacing: 0.07em;
  border-color: var(--border); padding: 10px 12px; background: transparent;
}
.table td { vertical-align: middle; border-color: var(--border); padding: 9px 12px; }
.table-hover tbody tr:hover { background: var(--accent-muted) !important; }
[data-bs-theme="dark"] .table-striped > tbody > tr:nth-of-type(odd) > * {
  background-color: rgba(255,255,255,0.02); color: var(--text-main);
}

/* ── BADGES ── */
.badge-ok     { font-size: 0.68rem; font-weight: 600; padding: 3px 8px; border-radius: 20px; background: rgba(38,166,154,0.15); color: var(--green); border: 1px solid rgba(38,166,154,0.3); }
.badge-warn   { font-size: 0.68rem; font-weight: 600; padding: 3px 8px; border-radius: 20px; background: rgba(232,184,75,0.15); color: var(--yellow); border: 1px solid rgba(232,184,75,0.3); }
.badge-err    { font-size: 0.68rem; font-weight: 600; padding: 3px 8px; border-radius: 20px; background: rgba(239,83,80,0.15); color: var(--red); border: 1px solid rgba(239,83,80,0.3); }
.badge-idle   { font-size: 0.68rem; font-weight: 600; padding: 3px 8px; border-radius: 20px; background: rgba(136,153,170,0.1); color: var(--text-muted); border: 1px solid var(--border); }
.badge-accent { font-size: 0.68rem; font-weight: 600; padding: 3px 8px; border-radius: 20px; background: var(--accent-muted); color: var(--accent); border: 1px solid rgba(0,212,170,0.3); }

/* ── TEXT ── */
.t-green  { color: var(--green) !important; }
.t-red    { color: var(--red) !important; }
.t-yellow { color: var(--yellow) !important; }
.t-purple { color: var(--purple) !important; }
.t-accent { color: var(--accent) !important; }
.t-muted  { color: var(--text-muted) !important; }

/* ── PIPELINE PILLS ── */
.pipeline-pill {
  display: flex; align-items: center; gap: 10px;
  background: var(--bg-elevated); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 10px 14px; font-size: 0.82rem;
}
.pill-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.pill-label { color: var(--text-muted); flex: 1; }
.pill-status { font-weight: 600; }

/* ── EMPTY / ERROR ── */
.empty-state { text-align: center; padding: 48px 24px; color: var(--text-muted); }
.empty-state i { font-size: 2.2rem; margin-bottom: 12px; display: block; opacity: 0.3; }
.empty-state p { font-size: 0.85rem; margin: 0; }
.load-row { display: flex; align-items: center; gap: 8px; padding: 24px; color: var(--text-muted); font-size: 0.85rem; }

/* ── LOGIN ── */
#login-page {
  min-height: 100vh; display: flex;
  align-items: center; justify-content: center;
  background: var(--bg-light);
}
.login-card {
  background: var(--bg-panel); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 40px;
  width: 100%; max-width: 400px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.4);
}
.login-brand { text-align: center; margin-bottom: 32px; }
.login-logo {
  width: 52px; height: 52px; background: var(--accent);
  border-radius: var(--radius-lg); display: inline-flex;
  align-items: center; justify-content: center;
  font-size: 1.5rem; font-weight: 800; color: var(--accent-text);
  margin-bottom: 12px;
}
.login-brand h1 { font-size: 1.2rem; font-weight: 700; margin: 0; }
.login-brand p { color: var(--text-muted); font-size: 0.82rem; margin: 4px 0 0; }
.form-label { color: var(--text-muted); font-size: 0.75rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 6px; display: block; }
.form-control {
  background: var(--bg-input); border: 1px solid var(--border);
  border-radius: var(--radius); color: var(--text-main);
  padding: 10px 14px; font-size: 0.9rem; width: 100%;
  transition: border-color 0.2s;
}
.form-control:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-muted); }
.form-control::placeholder { color: #556677; }
.btn-primary-robin, .btn-login {
  width: 100%; background: var(--accent); border: none;
  border-radius: var(--radius); color: var(--accent-text);
  font-weight: 700; padding: 11px; font-size: 0.95rem;
  cursor: pointer; transition: opacity 0.2s, transform 0.15s;
}
.btn-primary-robin:hover, .btn-login:hover { opacity: 0.9; transform: translateY(-1px); }
.btn-primary-robin:disabled, .btn-login:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
.login-error {
  background: rgba(239,83,80,0.1); border: 1px solid rgba(239,83,80,0.3);
  color: var(--red); border-radius: var(--radius);
  padding: 10px 14px; font-size: 0.83rem; margin-bottom: 16px; display: none;
}

/* ── FORMS ── */
.form-select {
  background-color: var(--bg-input); border: 1px solid var(--border);
  border-radius: var(--radius); color: var(--text-main);
  padding: 8px 12px; font-size: 0.875rem;
}
.form-check-input:checked { background-color: var(--accent); border-color: var(--accent); }

/* ── SPINNER ── */
.spinner-sm { width: 14px; height: 14px; border-width: 2px; }

/* ── SCROLLBAR ── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* ── TABS ── */
.section-tabs {
  display: flex; gap: 0; flex-wrap: wrap;
  border-bottom: 1px solid var(--border);
  margin-bottom: 20px;
}
.tab-btn {
  background: none; border: none; border-bottom: 2px solid transparent;
  color: var(--text-muted); font-size: 0.83rem; font-weight: 500;
  padding: 9px 18px; cursor: pointer; margin-bottom: -1px;
  transition: color 0.15s, border-color 0.15s;
  white-space: nowrap;
}
.tab-btn:hover { color: var(--text-main); }
.tab-btn.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }
.tab-pane { display: none; }
.tab-pane.active { display: block; }

/* ── SUB-NAV (Team etc.) ── */
.sub-nav {
  display: flex; flex-direction: column; gap: 2px;
  border-right: 1px solid var(--border); padding-right: 12px; min-width: 160px;
}
.sub-nav-btn {
  background: none; border: none; border-radius: var(--radius);
  color: var(--text-muted); font-size: 0.82rem; text-align: left;
  padding: 8px 12px; cursor: pointer; transition: background 0.15s, color 0.15s;
}
.sub-nav-btn:hover { background: var(--accent-muted); color: var(--text-main); }
.sub-nav-btn.active { background: var(--accent-muted); color: var(--accent); font-weight: 600; }

/* ── ACTION FEEDBACK ── */
.inline-feedback {
  font-size: 0.8rem; padding: 6px 12px; border-radius: var(--radius);
  margin-top: 8px; display: none;
}
.inline-feedback.success { background: rgba(38,166,154,0.15); color: var(--green); border: 1px solid rgba(38,166,154,0.3); }
.inline-feedback.error   { background: rgba(239,83,80,0.12); color: var(--red); border: 1px solid rgba(239,83,80,0.3); }

/* ── PROGRESS BAR ── */
.progress-bar-robin {
  height: 6px; background: var(--border); border-radius: 3px; overflow: hidden;
}
.progress-bar-robin .fill { height: 100%; background: var(--accent); border-radius: 3px; transition: width 0.4s; }

/* ── RESPONSIVE ── */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); width: 240px !important; }
  .sidebar.mobile-open { transform: translateX(0); box-shadow: 0 0 0 100vw rgba(0,0,0,0.5); }
  .main-content { margin-left: 0 !important; }
  .topbar { padding: 0 16px; }
  .page-content { padding: 16px; }
}
