/* ============================================================
   Apollo TI — Network Access Control
   Design System · Light Premium Corporate
   v1.0 · 2026-06-02
   ============================================================ */

:root {
  /* Brand — azul Apollo (#003fb2 → #0a55e3) em escala oklch */
  --brand-50:  oklch(0.972 0.018 262);
  --brand-100: oklch(0.935 0.045 262);
  --brand-200: oklch(0.880 0.080 262);
  --brand-300: oklch(0.790 0.120 262);
  --brand-400: oklch(0.660 0.165 262);
  --brand-500: oklch(0.560 0.198 261);
  --brand-600: #0a55e3;
  --brand-700: #003fb2;
  --brand-800: oklch(0.360 0.150 263);
  --brand-900: oklch(0.285 0.105 264);

  --brand:        var(--brand-700);
  --brand-accent: var(--brand-600);

  /* Neutros levemente frios */
  --bg:            oklch(0.984 0.0035 255);
  --surface:       #ffffff;
  --surface-2:     oklch(0.976 0.004 255);
  --surface-3:     oklch(0.962 0.005 255);
  --border:        oklch(0.922 0.005 255);
  --border-strong: oklch(0.872 0.007 255);

  --text:       oklch(0.245 0.018 262);
  --text-2:     oklch(0.450 0.014 262);
  --text-3:     oklch(0.600 0.011 262);
  --text-faint: oklch(0.720 0.008 262);
  --on-brand:   #ffffff;

  /* Status */
  --ok:          oklch(0.585 0.135 152);
  --ok-bg:       oklch(0.955 0.038 152);
  --ok-border:   oklch(0.880 0.070 152);
  --warn:        oklch(0.660 0.130 70);
  --warn-bg:     oklch(0.960 0.055 80);
  --warn-border: oklch(0.880 0.090 75);
  --danger:        oklch(0.560 0.180 26);
  --danger-bg:     oklch(0.958 0.035 26);
  --danger-border: oklch(0.880 0.080 26);
  --info:    var(--brand-600);
  --info-bg: var(--brand-50);

  /* Tipografia */
  --font-ui:   "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-mono: "JetBrains Mono", "SF Mono", ui-monospace, monospace;

  /* Raio */
  --r-xs:  7px;
  --r-sm:  10px;
  --r:     13px;
  --r-lg:  17px;
  --r-xl:  22px;
  --r-pill: 999px;

  /* Sombras */
  --sh-xs: 0 1px 2px oklch(0.4 0.05 262 / 0.06);
  --sh-sm: 0 1px 3px oklch(0.4 0.05 262 / 0.07), 0 1px 2px oklch(0.4 0.05 262 / 0.04);
  --sh:    0 4px 14px oklch(0.4 0.05 262 / 0.07), 0 1px 3px oklch(0.4 0.05 262 / 0.05);
  --sh-lg: 0 12px 34px oklch(0.4 0.05 262 / 0.10), 0 4px 12px oklch(0.4 0.05 262 / 0.06);
  --sh-xl: 0 28px 64px oklch(0.35 0.06 262 / 0.18), 0 8px 22px oklch(0.35 0.06 262 / 0.10);
  --ring:  0 0 0 3px oklch(0.560 0.198 261 / 0.22);

  /* Layout */
  --sidebar-w: 264px;
  --sidebar-rail-w: 76px;
  --header-h:  66px;

  /* Densidade — defaults para "regular" (evita FOUC sem data-density) */
  --gap:      22px;
  --row-pad:  15px;
  --card-pad: 24px;
}

/* Densidade */
[data-density="compact"] { --gap: 16px; --row-pad: 11px; --card-pad: 18px; }
[data-density="regular"] { --gap: 22px; --row-pad: 15px; --card-pad: 24px; }
[data-density="comfy"]   { --gap: 28px; --row-pad: 19px; --card-pad: 30px; }

/* ---- Reset mínimo ---- */
*, *::before, *::after { box-sizing: border-box; }

/* Compatibilidade com app.js que usa classList.add('hidden') */
.hidden { display: none !important; }

html, body {
  margin: 0; padding: 0; height: 100%;
  font-family: var(--font-ui);
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

#root { height: 100%; }

::selection { background: var(--brand-200); color: var(--brand-900); }

h1, h2, h3, h4 { margin: 0; letter-spacing: -0.02em; }
p { margin: 0; }
button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; }

/* ---- Scrollbar refinada ---- */
*::-webkit-scrollbar { width: 11px; height: 11px; }
*::-webkit-scrollbar-thumb {
  background: oklch(0.85 0.01 262);
  border-radius: 999px;
  border: 3px solid transparent;
  background-clip: padding-box;
}
*::-webkit-scrollbar-thumb:hover {
  background: oklch(0.78 0.02 262);
  background-clip: padding-box;
  border: 3px solid transparent;
}
*::-webkit-scrollbar-track { background: transparent; }

/* ---- Material Symbols ---- */
.msym {
  font-family: "Material Symbols Outlined";
  font-weight: normal; font-style: normal;
  line-height: 1; letter-spacing: normal; text-transform: none;
  display: inline-block; white-space: nowrap; direction: ltr;
  font-feature-settings: "liga";
  -webkit-font-smoothing: antialiased;
  font-variation-settings: "FILL" 0, "wght" 400, "GRAD" 0, "opsz" 24;
  user-select: none;
}
.msym.fill { font-variation-settings: "FILL" 1, "wght" 500, "GRAD" 0, "opsz" 24; }

/* ---- Tipografia utilitária ---- */
.mono { font-family: var(--font-mono); font-feature-settings: "zero" 1; }
.tnum { font-variant-numeric: tabular-nums; }
.mac  { font-family: var(--font-mono); font-size: 12.5px; letter-spacing: -0.02em; color: var(--text-2); }
.mac-vendor { font-size: 10.5px; color: var(--text-faint); margin-top: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 160px; }

/* ---- Botões ---- */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  border: 1px solid transparent;
  border-radius: var(--r-sm);
  font-size: 13.5px; font-weight: 600; letter-spacing: -0.01em;
  padding: 0 16px; height: 40px;
  transition: all .16s ease;
  white-space: nowrap; text-decoration: none; cursor: pointer;
}
.btn .msym { font-size: 19px; }
.btn-primary {
  background: var(--brand-700); color: var(--on-brand);
  box-shadow: var(--sh-sm), inset 0 1px 0 oklch(1 0 0 / 0.18);
}
.btn-primary:hover  { background: var(--brand-800); transform: translateY(-1px); box-shadow: var(--sh); }
.btn-primary:active { transform: translateY(0); }
.btn-ghost  { background: var(--surface);   color: var(--text);   border-color: var(--border-strong); }
.btn-ghost:hover  { background: var(--surface-2); border-color: var(--text-faint); }
.btn-subtle { background: var(--surface-2); color: var(--text-2); }
.btn-subtle:hover { background: var(--surface-3); color: var(--text); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { filter: brightness(0.94); }
.btn-sm { height: 34px; padding: 0 12px; font-size: 12.5px; border-radius: var(--r-xs); }
.btn:disabled { opacity: .55; cursor: not-allowed; transform: none !important; }

/* ---- Cards ---- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-sm);
}

/* ---- Inputs ---- */
.field-label {
  font-size: 12.5px; font-weight: 600; color: var(--text-2);
  margin-bottom: 7px; display: block; letter-spacing: -0.01em;
}
.input, .select-native {
  width: 100%; height: 42px;
  border: 1px solid var(--border-strong);
  border-radius: var(--r-sm);
  background: var(--surface);
  padding: 0 13px; font-size: 14px; color: var(--text);
  transition: border-color .14s, box-shadow .14s;
}
textarea.input { height: auto; padding: 11px 13px; resize: vertical; line-height: 1.5; }
.input:focus, .select-native:focus {
  outline: none; border-color: var(--brand-500); box-shadow: var(--ring);
}
.input::placeholder { color: var(--text-faint); }

/* ---- Badges ---- */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 12px; font-weight: 600; letter-spacing: -0.005em;
  padding: 4px 10px; border-radius: var(--r-pill);
  border: 1px solid transparent; white-space: nowrap;
}
.badge .dot { width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0; }
.badge-ok      { background: var(--ok-bg);     color: var(--ok);     border-color: var(--ok-border); }
.badge-warn    { background: var(--warn-bg);   color: oklch(0.5 0.13 70); border-color: var(--warn-border); }
.badge-danger  { background: var(--danger-bg); color: var(--danger); border-color: var(--danger-border); }
.badge-info    { background: var(--brand-50);  color: var(--brand-700); border-color: var(--brand-200); }
.badge-neutral { background: var(--surface-3); color: var(--text-3); border-color: var(--border); }

/* ---- Animações ---- */
@keyframes fadeUp   { from { opacity: 0; transform: translateY(8px); }  to { opacity: 1; transform: translateY(0); } }
@keyframes fadeIn   { from { opacity: 0; }                               to { opacity: 1; } }
@keyframes pop      { from { opacity: 0; transform: scale(.96) translateY(6px); } to { opacity: 1; transform: scale(1) translateY(0); } }
@keyframes shimmer  { 0% { background-position: -400px 0; } 100% { background-position: 400px 0; } }
@keyframes pulseDot { 0%,100% { opacity: 1; } 50% { opacity: .35; } }
@keyframes spin     { to { transform: rotate(360deg); } }
@keyframes sweep    { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }
@keyframes slideDown { from { transform: translateY(-100%); } to { transform: translateY(0); } }

/* ---- Componentes utilitários ---- */
.live-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--ok);
  box-shadow: 0 0 0 0 oklch(0.585 0.135 152 / .5);
  animation: pulseDot 1.8s ease-in-out infinite;
  display: inline-block; flex-shrink: 0;
}

.skeleton {
  background: linear-gradient(90deg, var(--surface-3) 25%, var(--surface-2) 37%, var(--surface-3) 63%);
  background-size: 800px 100%;
  animation: shimmer 1.4s linear infinite;
  border-radius: 7px;
}

.spinner {
  width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid oklch(1 0 0 / 0.35); border-top-color: #fff;
  animation: spin .7s linear infinite;
  display: inline-block; flex-shrink: 0;
}

.hoverable { transition: background .13s; }
.hoverable:hover { background: var(--surface-2); }

/* ---- Modal backdrop ---- */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 8000;
  background: oklch(0.25 0.04 262 / 0.42);
  backdrop-filter: blur(3px);
  display: flex; align-items: center; justify-content: center; padding: 24px;
  animation: fadeIn .18s ease;
}
.modal-box {
  background: var(--surface); border-radius: var(--r-xl);
  box-shadow: var(--sh-xl); border: 1px solid var(--border);
  max-width: calc(100% - 48px); max-height: 92vh; overflow-y: auto;
  animation: pop .24s cubic-bezier(.2,.9,.3,1.15);
}

/* ---- Toast ---- */
#toast-container {
  position: fixed; top: 18px; right: 18px; z-index: 9000;
  display: flex; flex-direction: column; gap: 10px;
  pointer-events: none;
}
.toast-item {
  display: flex; align-items: center; gap: 10px;
  color: #fff; padding: 12px 16px;
  border-radius: var(--r-sm); box-shadow: var(--sh-lg);
  font-size: 13.5px; font-weight: 600;
  min-width: 240px; max-width: 380px;
  animation: pop .26s cubic-bezier(.2,.9,.3,1.2);
  pointer-events: auto;
}
.toast-success { background: var(--ok); }
.toast-error   { background: var(--danger); }
.toast-info    { background: var(--brand-700); }

/* ---- Shell ---- */
#app-shell {
  display: flex; height: 100%;
  background: var(--bg);
}

#sidebar {
  width: var(--sidebar-w); flex-shrink: 0;
  display: flex; flex-direction: column;
  background: var(--surface);
  border-right: 1px solid var(--border);
  transition: width .2s;
}
#sidebar.rail { width: var(--sidebar-rail-w); }

#sidebar-logo {
  height: var(--header-h);
  display: flex; align-items: center;
  padding: 0 20px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
#sidebar.rail #sidebar-logo { justify-content: center; padding: 0; }

#sidebar-nav {
  flex: 1; padding: 14px 12px;
  overflow-y: auto;
}
#sidebar.rail #sidebar-nav { padding: 12px; }

.nav-section-label {
  font-size: 10.5px; font-weight: 700;
  letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--text-faint);
  padding: 16px 12px 7px;
}

.nav-item {
  display: flex; align-items: center; gap: 12px;
  width: 100%; padding: 10px 12px;
  border-radius: var(--r-sm); border: none;
  margin-bottom: 2px; position: relative;
  background: transparent; color: var(--text-2);
  font-size: 13.5px; font-weight: 600;
  cursor: pointer; transition: background .13s, color .13s;
  text-align: left;
}
.nav-item:hover { background: var(--surface-2); }
.nav-item.active {
  background: var(--brand-50); color: var(--brand-700); font-weight: 700;
}
.nav-item.active::before {
  content: "";
  position: absolute; left: 0; top: 50%; transform: translateY(-50%);
  width: 3px; height: 18px; border-radius: 999px;
  background: var(--brand-600);
}
.nav-item.soon { opacity: 0.5; cursor: default; }
.nav-item.soon:hover { background: transparent; }
#sidebar.rail .nav-item { justify-content: center; padding: 11px 0; }

#sidebar-footer {
  padding: 14px 16px;
  border-top: 1px solid var(--border);
  display: flex; align-items: center; gap: 11px;
  flex-shrink: 0;
}
#sidebar.rail #sidebar-footer { justify-content: center; padding: 12px; }

.sidebar-avatar {
  width: 36px; height: 36px; border-radius: 10px;
  background: linear-gradient(135deg, var(--brand-600), var(--brand-700));
  color: #fff; display: grid; place-items: center;
  font-size: 13px; font-weight: 700; flex-shrink: 0;
}

/* ---- Main area ---- */
#main-area {
  flex: 1; display: flex; flex-direction: column; min-width: 0;
}

#app-header {
  height: var(--header-h); flex-shrink: 0;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 26px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

#breadcrumb {
  display: flex; align-items: center; gap: 8px;
  font-size: 13px; color: var(--text-3);
}
#breadcrumb .tenant-name { font-weight: 600; }
#breadcrumb .page-label  { font-weight: 700; color: var(--text); }

#header-actions { display: flex; align-items: center; gap: 14px; }

.notif-btn {
  width: 40px; height: 40px; border-radius: 10px;
  border: 1px solid var(--border); background: var(--surface);
  color: var(--text-2); display: grid; place-items: center;
  position: relative; cursor: pointer;
}
.notif-dot {
  position: absolute; top: 8px; right: 9px;
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--danger); border: 1.5px solid var(--surface);
}

.header-divider { width: 1px; height: 26px; background: var(--border); }

.header-avatar {
  width: 34px; height: 34px; border-radius: 9px;
  background: linear-gradient(135deg, var(--brand-600), var(--brand-700));
  color: #fff; display: grid; place-items: center;
  font-size: 12.5px; font-weight: 700;
}

/* Role switcher dropdown */
.role-switcher { position: relative; }
.role-dropdown {
  position: absolute; top: 44px; right: 0; z-index: 60;
  width: 230px; background: var(--surface);
  border-radius: var(--r); box-shadow: var(--sh-lg);
  border: 1px solid var(--border); padding: 6px;
  animation: pop .15s ease;
}
.role-dropdown-label {
  font-size: 10.5px; font-weight: 700;
  letter-spacing: 0.05em; text-transform: uppercase;
  color: var(--text-faint); padding: 8px 10px 5px;
}
.role-option {
  display: flex; align-items: center; gap: 10px;
  width: 100%; padding: 10px 11px; border-radius: 9px;
  border: none; text-align: left; cursor: pointer;
  background: transparent; color: var(--text);
  font-size: 13.5px; font-weight: 600; font-family: inherit;
  transition: background .13s;
}
.role-option:hover { background: var(--surface-2); }
.role-option.active { background: var(--brand-50); color: var(--brand-700); }

/* ---- Page content ---- */
#page-content-area {
  flex: 1; overflow-y: auto;
  padding: 26px 30px 40px;
}
.page-inner { max-width: 1320px; margin: 0 auto; }

/* ---- Page head ---- */
.page-head {
  display: flex; align-items: flex-end;
  justify-content: space-between; gap: 20px;
  margin-bottom: 24px; flex-wrap: wrap;
}
.page-head-title { font-size: 26px; font-weight: 800; letter-spacing: -0.03em; }
.page-head-sub   { margin-top: 6px; font-size: 14px; color: var(--text-3); }
.page-head-actions { display: flex; gap: 10px; align-items: center; }

/* ---- Empty state ---- */
.empty-state {
  text-align: center; padding: 60px 20px; color: var(--text-3);
}
.empty-state-icon {
  width: 64px; height: 64px; border-radius: 18px;
  background: var(--surface-2); border: 1px solid var(--border);
  display: grid; place-items: center; margin: 0 auto 16px;
}

/* ---- Tabela ---- */
table { width: 100%; border-collapse: collapse; }
th {
  text-align: left; font-size: 11px; font-weight: 700;
  letter-spacing: 0.04em; text-transform: uppercase;
  color: var(--text-faint); padding: 12px 18px;
  background: var(--surface-2);
}
th.right, td.right { text-align: right; }
td { padding: var(--row-pad) 18px; border-top: 1px solid var(--border); }
tr.hoverable td { transition: background .13s; }
tr.hoverable:hover td { background: var(--surface-2); }

/* ---- Paginação ---- */
.pagination {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px; border-top: 1px solid var(--border);
  font-size: 12.5px; color: var(--text-3);
}
.pagination-pages { display: flex; gap: 5px; align-items: center; }
.page-btn {
  width: 34px; height: 34px; border-radius: var(--r-xs);
  font-size: 13px; font-weight: 600; border: 1px solid transparent;
  background: transparent; color: var(--text-2); cursor: pointer;
  font-family: inherit;
}
.page-btn.active {
  border-color: var(--brand-600); background: var(--brand-50); color: var(--brand-700);
}
.page-btn:disabled { opacity: .4; cursor: not-allowed; }

/* ---- ActionMenu ---- */
.action-menu { position: relative; display: inline-block; }
.action-trigger {
  width: 34px; height: 34px; border-radius: 9px;
  border: 1px solid transparent; background: transparent;
  color: var(--text-2); display: grid; place-items: center; cursor: pointer;
}
.action-trigger:hover { background: var(--surface-3); }
.action-trigger.open  { background: var(--surface-3); }
.action-dropdown {
  position: absolute; right: 0; z-index: 50;
  min-width: 196px; background: var(--surface);
  border-radius: var(--r); box-shadow: var(--sh-lg);
  border: 1px solid var(--border); padding: 6px;
  animation: pop .15s ease;
}
.action-dropdown-item {
  display: flex; align-items: center; gap: 10px;
  width: 100%; padding: 9px 11px; border-radius: 9px;
  border: none; text-align: left; background: transparent;
  font-size: 13.5px; font-weight: 600; color: var(--text);
  cursor: pointer; font-family: inherit; transition: background .1s;
}
.action-dropdown-item:hover { background: var(--surface-2); }
.action-dropdown-item.danger { color: var(--danger); }
.action-dropdown-item.danger:hover { background: var(--danger-bg); }
.action-divider { height: 1px; background: var(--border); margin: 5px 4px; }

/* ---- Rate limit banner ---- */
#rate-limit-banner {
  position: fixed; top: 0; left: 0; right: 0; z-index: 500;
  background: oklch(0.55 0.13 60);
  color: #fff; padding: 10px 24px;
  display: flex; align-items: center; justify-content: space-between;
  font-size: 13.5px; font-weight: 600;
  animation: slideDown .3s ease;
}

/* ---- Meter (CPU/RAM/disponibilidade) ---- */
.meter-track {
  height: 8px; background: var(--surface-3);
  border-radius: 999px; overflow: hidden; width: 100%;
}
.meter-fill {
  height: 100%; border-radius: 999px;
  transition: width .6s cubic-bezier(.2,.8,.2,1);
}

/* ---- Reduced motion ---- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
