/* ─────────────────────────────────────────────────────────────
   RFI Coordination Hub — Shell CSS
   Dark theme default, html.light overrides at bottom
───────────────────────────────────────────────────────────── */
@keyframes rfi-fadein { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

:root {
  --bg:         #0f1117;
  --surface:    #1a1d27;
  --surface2:   #232635;
  --border:     #2e3147;
  --text:       #e2e4ef;
  --text-muted: #8890aa;
  --accent:     #4f7eff;
  --accent2:    #7c3aed;
  --success:    #22c55e;
  --warn:       #f59e0b;
  --danger:     #ef4444;
  --info:       #38bdf8;
  --sidebar-w:  240px;
  --topbar-h:   52px;
  --radius:     8px;
  --font:       -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; scroll-behavior: smooth; }
body { font-family: var(--font); background: var(--bg); color: var(--text); min-height: 100vh; }

a { color: var(--accent); text-decoration: none; }
button { cursor: pointer; font-family: inherit; }

/* ── Layout ─────────────────────────────────────────────── */
#app { display: flex; flex-direction: column; min-height: 100vh; }

/* Topbar */
.topbar {
  position: fixed; top: 0; left: 0; right: 0; height: var(--topbar-h);
  background: var(--surface); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; padding: 0 1rem; gap: 1rem;
  z-index: 200;
}
.topbar-brand { font-weight: 700; font-size: 1rem; color: var(--accent); flex: 1; }
.topbar-brand small { font-size: .7rem; color: var(--text-muted); font-weight: 400; margin-left: .4rem; }
.topbar-meta { display: flex; align-items: center; gap: .75rem; font-size: .8rem; color: var(--text-muted); }
.topbar-user { color: var(--text); font-weight: 600; }
.topbar-role { background: var(--surface2); border-radius: 4px; padding: 2px 6px; font-size: .7rem; }
.topbar-btn {
  background: var(--surface2); border: 1px solid var(--border); color: var(--text);
  border-radius: var(--radius); padding: .3rem .75rem; font-size: .8rem; cursor: pointer;
}
.topbar-btn:hover { background: var(--border); }

/* Sidebar */
.sidebar {
  position: fixed; top: var(--topbar-h); left: 0; bottom: 0;
  width: var(--sidebar-w); background: var(--surface);
  border-right: 1px solid var(--border); overflow-y: auto;
  padding: 1rem 0; z-index: 100;
}
.sidebar-section { margin-bottom: .5rem; }
.section-label {
  font-size: .65rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase;
  color: var(--text-muted); padding: .5rem 1rem .25rem;
}
.nav-item {
  display: flex; align-items: center; gap: .6rem;
  padding: .55rem 1rem; font-size: .875rem; color: var(--text-muted);
  border-radius: 0; cursor: pointer; width: 100%;
  transition: background .15s, color .15s;
}
.nav-item:hover  { background: var(--surface2); color: var(--text); }
.nav-item.active { background: var(--surface2); color: var(--accent); font-weight: 600; border-left: 3px solid var(--accent); }
.nav-icon { font-size: 1rem; width: 1.2rem; text-align: center; }

/* Main content */
.main-content {
  margin-top: var(--topbar-h);
  margin-left: var(--sidebar-w);
  padding: 1.5rem;
  min-height: calc(100vh - var(--topbar-h));
}

/* SharePoint status badge */
.sp-badge { font-size: .75rem; font-weight: 600; padding: 3px 8px; border-radius: 12px; }
.sp-badge--connected { background: rgba(34,197,94,.15); color: var(--success); }
.sp-badge--offline   { background: rgba(239,68,68,.12); color: var(--danger); }

/* ── Login page ──────────────────────────────────────────── */
.login-page {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: var(--bg);
}
.login-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 2.5rem 2rem; width: 360px;
}
.login-title { font-size: 1.4rem; font-weight: 700; color: var(--accent); margin-bottom: .25rem; }
.login-sub   { font-size: .8rem; color: var(--text-muted); margin-bottom: 2rem; }
.form-group  { margin-bottom: 1rem; }
.form-group label { display: block; font-size: .8rem; color: var(--text-muted); margin-bottom: .35rem; }
.form-group input {
  width: 100%; padding: .6rem .75rem; background: var(--surface2);
  border: 1px solid var(--border); border-radius: var(--radius);
  color: var(--text); font-size: .9rem; outline: none;
}
.form-group input:focus { border-color: var(--accent); }
.btn-primary {
  width: 100%; padding: .7rem; background: var(--accent); color: #fff;
  border: none; border-radius: var(--radius); font-size: .95rem; font-weight: 600;
  cursor: pointer; transition: opacity .15s;
}
.btn-primary:hover { opacity: .88; }
.btn-primary:disabled { opacity: .5; cursor: not-allowed; }
.login-error { color: var(--danger); font-size: .8rem; margin-top: .75rem; min-height: 1.2rem; }

/* ── Cards ───────────────────────────────────────────────── */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1.25rem;
}
.card-title { font-size: .8rem; text-transform: uppercase; letter-spacing: .06em;
  color: var(--text-muted); margin-bottom: 1rem; font-weight: 600; }

/* ── KPI strip ───────────────────────────────────────────── */
.kpi-strip { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: .75rem; margin-bottom: 1.5rem; }
.kpi-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem; }
.kpi-label { font-size: .75rem; color: var(--text-muted); margin-bottom: .35rem; }
.kpi-value { font-size: 1.75rem; font-weight: 700; color: var(--text); line-height: 1; }
.kpi-card.kpi-warn  .kpi-value { color: var(--warn); }
.kpi-card.kpi-error .kpi-value { color: var(--danger); }
.kpi-card.kpi-ok    .kpi-value { color: var(--success); }

/* ── Buttons ─────────────────────────────────────────────── */
.btn { padding: .5rem 1rem; border-radius: var(--radius); font-size: .85rem; font-weight: 600; border: 1px solid transparent; cursor: pointer; }
.btn-sm { padding: .3rem .7rem; font-size: .78rem; }
.btn-primary-sm { background: var(--accent); color: #fff; border: none; border-radius: 6px; padding: .35rem .8rem; font-size: .8rem; font-weight: 600; cursor: pointer; }
.btn-outline { background: transparent; border: 1px solid var(--border); color: var(--text); }
.btn-outline:hover { border-color: var(--accent); color: var(--accent); }
.btn-danger { background: var(--danger); color: #fff; border: none; }
.btn-success { background: var(--success); color: #fff; border: none; }

.action-bar { display: flex; gap: .5rem; flex-wrap: wrap; margin-bottom: 1rem; }

/* ── Badges ──────────────────────────────────────────────── */
.badge { display: inline-block; padding: 2px 8px; border-radius: 12px; font-size: .7rem; font-weight: 700; color: #fff; }
.badge--active    { background: var(--success); }
.badge--completed { background: var(--info); }
.badge--failed    { background: var(--danger); }
.badge--cancelled { background: var(--text-muted); }
.badge--pending   { background: var(--warn); }

/* ── Tables ──────────────────────────────────────────────── */
.audit-tbl { width: 100%; border-collapse: collapse; font-size: .82rem; }
.audit-tbl th { background: var(--surface2); padding: .5rem .75rem; text-align: left; font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; color: var(--text-muted); }
.audit-tbl td { padding: .5rem .75rem; border-bottom: 1px solid var(--border); }
.audit-tbl tr:hover td { background: var(--surface2); }

/* ── Empty state ─────────────────────────────────────────── */
.empty-msg { color: var(--text-muted); font-size: .85rem; padding: 2rem; text-align: center; }

/* ── Page heading ────────────────────────────────────────── */
.page-title { font-size: 1.3rem; font-weight: 700; margin-bottom: .25rem; }
.page-sub   { font-size: .85rem; color: var(--text-muted); margin-bottom: 1.25rem; }

/* ── Print mode ──────────────────────────────────────────── */
@media print {
  .sidebar, .topbar, .action-bar, .topbar-btn { display: none !important; }
  .main-content { margin: 0; padding: 1cm; }
  .page-section { display: block !important; }
  body { color: #000; background: #fff; }
  .card { border: 1px solid #ccc; break-inside: avoid; }
}

/* ── Mobile ───────────────────────────────────────────────── */
@media (max-width: 768px) {
  :root { --sidebar-w: 0px; }
  .sidebar { transform: translateX(-240px); transition: transform .25s; }
  .sidebar.open { transform: none; width: 240px; }
  .main-content { margin-left: 0; padding: 1rem; }
  .kpi-strip { grid-template-columns: repeat(2, 1fr); }
}

/* ── Light theme ─────────────────────────────────────────── */
html.light {
  --bg:         #f4f5fa;
  --surface:    #ffffff;
  --surface2:   #eef0f8;
  --border:     #dde0ef;
  --text:       #1a1d27;
  --text-muted: #64748b;
}
