/* ============================================================
   Entreponte / Ponte — design tokens
   Paleta oficial: Roxo #6F42C1, Verde Neon #C6FF00, Preto #0D0D0D,
   Cinza Claro #E6E6E6, Branco #FFFFFF (Identidade Visual Ponte)
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@500;600;700&family=Inter:wght@400;500;600&family=IBM+Plex+Mono:wght@400;500&display=swap');

:root {
  /* marca */
  --roxo: #6F42C1;
  --roxo-escuro: #4E2E8A;
  --verde-neon: #C6FF00;
  --preto: #0D0D0D;
  --cinza-claro: #E6E6E6;
  --branco: #FFFFFF;

  /* superfícies (tema claro = padrão) */
  --bg: #F4F3F8;
  --bg-office: #EDEBF6;
  --surface: #FFFFFF;
  --surface-raised: #FFFFFF;
  --border: #DDD9EC;
  --ink: #1A1625;
  --ink-soft: #5B5570;
  --ink-faint: #8A84A0;

  /* semântico (status de agente) */
  --status-idle-bg: #EDEDF2;
  --status-idle-fg: #5B5570;
  --status-working-bg: #EAFBC8;
  --status-working-fg: #4C6B00;
  --status-waiting-bg: #FCEFD7;
  --status-waiting-fg: #93600B;
  --status-blocked-bg: #FCE3E0;
  --status-blocked-fg: #A8321F;
  --status-error-bg: #F8D7DA;
  --status-error-fg: #842029;
  --status-offline-bg: #E9E9EE;
  --status-offline-fg: #8A84A0;

  --accent: var(--roxo);
  --accent-contrast: var(--branco);
  --accent-2: var(--verde-neon);

  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 22px;

  --shadow-desk: 0 1px 2px rgba(13,13,13,0.04), 0 8px 20px -12px rgba(111,66,193,0.25);
  --shadow-pop: 0 20px 40px -16px rgba(13,13,13,0.35);

  --font-display: 'Space Grotesk', 'Segoe UI', system-ui, sans-serif;
  --font-body: 'Inter', 'Segoe UI', system-ui, sans-serif;
  --font-mono: 'IBM Plex Mono', 'SFMono-Regular', Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0D0D0D;
    --bg-office: #16121F;
    --surface: #1B1626;
    --surface-raised: #221C31;
    --border: #322A45;
    --ink: #F2F0F8;
    --ink-soft: #B8B2CC;
    --ink-faint: #7C7594;

    --status-idle-bg: #262032;
    --status-idle-fg: #B8B2CC;
    --status-working-bg: #2C3B00;
    --status-working-fg: #C6FF00;
    --status-waiting-bg: #3D2E0C;
    --status-waiting-fg: #F3B94F;
    --status-blocked-bg: #3B1714;
    --status-blocked-fg: #FF8A7A;
    --status-error-bg: #3B1416;
    --status-error-fg: #FF8A93;
    --status-offline-bg: #221E2C;
    --status-offline-fg: #7C7594;

    --shadow-desk: 0 1px 2px rgba(0,0,0,0.4), 0 8px 24px -12px rgba(198,255,0,0.08);
    --shadow-pop: 0 20px 50px -16px rgba(0,0,0,0.7);
  }
}

:root[data-theme="dark"] {
  --bg: #0D0D0D;
  --bg-office: #16121F;
  --surface: #1B1626;
  --surface-raised: #221C31;
  --border: #322A45;
  --ink: #F2F0F8;
  --ink-soft: #B8B2CC;
  --ink-faint: #7C7594;

  --status-idle-bg: #262032;
  --status-idle-fg: #B8B2CC;
  --status-working-bg: #2C3B00;
  --status-working-fg: #C6FF00;
  --status-waiting-bg: #3D2E0C;
  --status-waiting-fg: #F3B94F;
  --status-blocked-bg: #3B1714;
  --status-blocked-fg: #FF8A7A;
  --status-error-bg: #3B1416;
  --status-error-fg: #FF8A93;
  --status-offline-bg: #221E2C;
  --status-offline-fg: #7C7594;

  --shadow-desk: 0 1px 2px rgba(0,0,0,0.4), 0 8px 24px -12px rgba(198,255,0,0.08);
  --shadow-pop: 0 20px 50px -16px rgba(0,0,0,0.7);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
}
#root { min-height: 100%; }

::selection { background: var(--verde-neon); color: var(--preto); }

button { font-family: inherit; }
a { color: inherit; }

.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }

/* ---------- login ---------- */
.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background:
    radial-gradient(circle at 20% 20%, rgba(198,255,0,0.10), transparent 45%),
    radial-gradient(circle at 80% 0%, rgba(111,66,193,0.18), transparent 50%),
    var(--bg);
}
.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 32px 28px;
  box-shadow: var(--shadow-pop);
}
.login-brand { display: flex; align-items: center; gap: 10px; margin-bottom: 22px; }
.login-brand .dot { width: 12px; height: 12px; border-radius: 50%; background: var(--verde-neon); box-shadow: 0 0 0 4px rgba(198,255,0,0.15); }
.login-brand span { font-family: var(--font-display); font-weight: 700; font-size: 15px; letter-spacing: 0.02em; }
.login-card h1 { font-family: var(--font-display); font-size: 22px; margin: 0 0 6px; text-wrap: balance; }
.login-card p { color: var(--ink-soft); font-size: 14px; line-height: 1.5; margin: 0 0 20px; }
.login-card input {
  width: 100%; padding: 11px 14px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--bg); color: var(--ink);
  font-size: 14px; margin-bottom: 12px;
}
.login-card input:focus { outline: 2px solid var(--roxo); outline-offset: 1px; }
.login-card button.primary {
  width: 100%; padding: 11px 14px; border-radius: var(--radius-sm); border: none;
  background: var(--roxo); color: var(--branco); font-weight: 600; font-size: 14px;
  cursor: pointer; transition: filter 0.15s ease;
}
.login-card button.primary:hover { filter: brightness(1.08); }
.login-card button.primary:disabled { opacity: 0.6; cursor: default; }
.login-note { font-size: 12.5px; color: var(--ink-faint); margin-top: 14px; line-height: 1.5; }
.login-status { font-size: 13px; margin-top: 12px; padding: 10px 12px; border-radius: var(--radius-sm); }
.login-status.ok { background: var(--status-working-bg); color: var(--status-working-fg); }
.login-status.err { background: var(--status-error-bg); color: var(--status-error-fg); }

/* ---------- app shell ---------- */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
  width: 220px; flex-shrink: 0;
  background: var(--preto); color: var(--cinza-claro);
  display: flex; flex-direction: column;
  padding: 20px 14px;
}
.sidebar .brand { display: flex; align-items: center; gap: 9px; padding: 0 8px 24px; }
.sidebar .brand .dot { width: 11px; height: 11px; border-radius: 50%; background: var(--verde-neon); }
.sidebar .brand span { font-family: var(--font-display); font-weight: 700; font-size: 14.5px; color: var(--branco); }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: var(--radius-sm);
  color: var(--cinza-claro); font-size: 13.5px; font-weight: 500;
  cursor: pointer; margin-bottom: 2px; border: none; background: none; width: 100%; text-align: left;
}
.nav-item:hover { background: rgba(255,255,255,0.06); }
.nav-item.active { background: var(--roxo); color: var(--branco); }
.nav-item .badge {
  margin-left: auto; background: var(--verde-neon); color: var(--preto);
  font-size: 11px; font-weight: 700; border-radius: 999px; padding: 1px 7px;
}
.sidebar-foot { margin-top: auto; padding-top: 16px; border-top: 1px solid rgba(255,255,255,0.08); }
.sidebar-foot .user-email { font-size: 12px; color: var(--ink-faint); word-break: break-all; margin-bottom: 8px; }
.sidebar-foot button { background: none; border: none; color: var(--cinza-claro); font-size: 12.5px; cursor: pointer; padding: 6px 0; }
.sidebar-foot button:hover { color: var(--verde-neon); }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 26px; border-bottom: 1px solid var(--border); background: var(--surface);
}
.topbar h1 { font-family: var(--font-display); font-size: 19px; margin: 0; }
.topbar .sub { font-size: 12.5px; color: var(--ink-faint); margin-top: 2px; }
.conn-pill {
  display: inline-flex; align-items: center; gap: 6px; font-size: 12px;
  padding: 5px 10px; border-radius: 999px; background: var(--status-idle-bg); color: var(--status-idle-fg);
}
.conn-pill.live { background: var(--status-working-bg); color: var(--status-working-fg); }
.conn-pill .dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }

.view { flex: 1; padding: 24px 26px 90px; overflow-y: auto; }

/* ---------- office floor ---------- */
.office-floor {
  background: var(--bg-office);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 26px;
  background-image: radial-gradient(circle, rgba(111,66,193,0.10) 1px, transparent 1px);
  background-size: 22px 22px;
}
.desks-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 18px;
}
.desk {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px;
  box-shadow: var(--shadow-desk);
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
  position: relative;
}
.desk:hover { transform: translateY(-2px); }
.desk::before {
  content: ""; position: absolute; top: 0; left: 16px; right: 16px; height: 4px;
  border-radius: 0 0 4px 4px; background: var(--roxo); opacity: 0.35;
}
.desk[data-status="working"]::before { background: var(--status-working-fg); opacity: 0.9; }
.desk[data-status="waiting_approval"]::before { background: var(--status-waiting-fg); opacity: 0.9; }
.desk[data-status="blocked"]::before,
.desk[data-status="error"]::before { background: var(--status-blocked-fg); opacity: 0.9; }

.desk-avatar {
  width: 46px; height: 46px; border-radius: 12px;
  background: linear-gradient(135deg, var(--roxo), var(--roxo-escuro));
  display: flex; align-items: center; justify-content: center;
  color: var(--branco); font-family: var(--font-display); font-weight: 700; font-size: 16px;
  margin-bottom: 12px;
}
.desk-name { font-family: var(--font-display); font-weight: 600; font-size: 14.5px; text-wrap: balance; }
.desk-role { font-size: 11.5px; color: var(--ink-faint); margin: 3px 0 10px; line-height: 1.4; }
.status-pill {
  display: inline-flex; align-items: center; gap: 6px; font-size: 11.5px; font-weight: 600;
  padding: 4px 9px; border-radius: 999px;
}
.status-pill .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.status-pill.idle { background: var(--status-idle-bg); color: var(--status-idle-fg); }
.status-pill.working { background: var(--status-working-bg); color: var(--status-working-fg); }
.status-pill.waiting_approval { background: var(--status-waiting-bg); color: var(--status-waiting-fg); }
.status-pill.blocked { background: var(--status-blocked-bg); color: var(--status-blocked-fg); }
.status-pill.error { background: var(--status-error-bg); color: var(--status-error-fg); }
.status-pill.offline { background: var(--status-offline-bg); color: var(--status-offline-fg); }
.desk-msg { font-size: 12px; color: var(--ink-soft); margin-top: 9px; line-height: 1.4; min-height: 17px; }

/* ---------- desk drawer (agent detail) ---------- */
.drawer-overlay {
  position: fixed; inset: 0; background: rgba(13,13,13,0.45); z-index: 40;
  display: flex; justify-content: flex-end;
}
.drawer {
  width: 100%; max-width: 380px; background: var(--surface); height: 100%;
  padding: 24px; overflow-y: auto; box-shadow: var(--shadow-pop);
}
.drawer-close { background: none; border: none; color: var(--ink-faint); font-size: 20px; cursor: pointer; float: right; }
.drawer h2 { font-family: var(--font-display); font-size: 19px; margin: 4px 0 2px; }
.drawer .role { color: var(--ink-faint); font-size: 13px; margin-bottom: 16px; }
.drawer .field { margin-bottom: 14px; }
.drawer .field label { display: block; font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--ink-faint); margin-bottom: 4px; }
.drawer .field .val { font-size: 13.5px; }

/* ---------- approvals ---------- */
.approvals-list { display: flex; flex-direction: column; gap: 14px; max-width: 720px; }
.approval-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md);
  padding: 18px 20px; box-shadow: var(--shadow-desk);
}
.approval-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.approval-title { font-family: var(--font-display); font-weight: 600; font-size: 15px; text-wrap: balance; }
.approval-meta { font-size: 12px; color: var(--ink-faint); margin-top: 3px; }
.approval-summary { font-size: 13.5px; color: var(--ink-soft); line-height: 1.55; margin: 12px 0 16px; }
.approval-actions { display: flex; gap: 10px; }
.btn { border: none; border-radius: var(--radius-sm); padding: 9px 16px; font-size: 13px; font-weight: 600; cursor: pointer; transition: filter 0.15s ease; }
.btn:disabled { opacity: 0.5; cursor: default; }
.btn.approve { background: var(--verde-neon); color: var(--preto); }
.btn.approve:hover:not(:disabled) { filter: brightness(0.95); }
.btn.reject { background: transparent; border: 1px solid var(--status-blocked-fg); color: var(--status-blocked-fg); }
.btn.reject:hover:not(:disabled) { background: var(--status-blocked-bg); }
.empty-state { text-align: center; padding: 60px 20px; color: var(--ink-faint); }
.empty-state .big { font-size: 34px; margin-bottom: 10px; }
.decided-badge { font-size: 11.5px; font-weight: 600; padding: 4px 9px; border-radius: 999px; }
.decided-badge.approved { background: var(--status-working-bg); color: var(--status-working-fg); }
.decided-badge.rejected { background: var(--status-blocked-bg); color: var(--status-blocked-fg); }

/* ---------- mobile ---------- */
.mobile-topbar { display: none; }
@media (max-width: 860px) {
  .sidebar { display: none; }
  .mobile-topbar {
    display: flex; align-items: center; justify-content: space-between;
    padding: 14px 18px; background: var(--preto); color: var(--branco);
  }
  .mobile-topbar .brand { display: flex; align-items: center; gap: 8px; }
  .mobile-topbar .brand .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--verde-neon); }
  .mobile-topbar .brand span { font-family: var(--font-display); font-weight: 700; font-size: 14px; }
  .topbar { padding: 14px 16px; flex-wrap: wrap; gap: 8px; }
  .view { padding: 16px 16px 100px; }
  .desks-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
  .desk { padding: 12px; }
  .office-floor { padding: 14px; }

  .mobile-tabbar {
    display: flex; position: fixed; bottom: 0; left: 0; right: 0; z-index: 30;
    background: var(--surface); border-top: 1px solid var(--border);
    padding: 8px 6px calc(8px + env(safe-area-inset-bottom));
  }
  .mobile-tabbar button {
    flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px;
    background: none; border: none; color: var(--ink-faint); font-size: 10.5px; font-weight: 600;
    padding: 6px 0; cursor: pointer; position: relative;
  }
  .mobile-tabbar button.active { color: var(--roxo); }
  .mobile-tabbar button .ic { font-size: 18px; }
  .mobile-tabbar button .badge {
    position: absolute; top: 0; right: 22%; background: var(--verde-neon); color: var(--preto);
    font-size: 9.5px; font-weight: 700; border-radius: 999px; padding: 0px 5px;
  }
  .drawer { max-width: 100%; }
}
@media (min-width: 861px) { .mobile-tabbar { display: none; } }
