/* Arnone Cognitive — SAAU Platform CSS */
:root {
  --navy: #0d2137;
  --navy-mid: #1a3451;
  --verde: #1a7a4a;
  --verde-claro: #22a85f;
  --verde-glow: rgba(26,122,74,.15);
  --cinza-bg: #f0f2f5;
  --cinza-card: #ffffff;
  --borda: #dde3ea;
  --texto: #1a1a2e;
  --texto-sub: #64748b;
  --sidebar-w: 240px;
  --header-h: 60px;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(0,0,0,.08), 0 4px 16px rgba(0,0,0,.04);
  --shadow-md: 0 4px 24px rgba(13,33,55,.12);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Inter', 'Segoe UI', system-ui, sans-serif;
  background: var(--cinza-bg);
  color: var(--texto);
  line-height: 1.6;
  font-size: 14px;
}

/* ── SCROLLBAR ── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #ccd0d9; border-radius: 3px; }

/* ── LOGIN ── */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background: linear-gradient(135deg, var(--navy) 0%, #1a3451 60%, #0f4a2e 100%);
}
.login-card {
  background: white;
  border-radius: 20px;
  padding: 2.5rem 2.8rem;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 20px 60px rgba(0,0,0,.3);
}
.login-logo { text-align: center; margin-bottom: 1.8rem; }
.login-logo h1 { font-size: 1.5rem; color: var(--navy); font-weight: 800; }
.login-logo p { color: var(--verde); font-size: .82rem; font-weight: 600; letter-spacing: .05em; text-transform: uppercase; }
.login-logo .badge-saau {
  display: inline-block; margin-top: .4rem;
  background: var(--verde-glow); color: var(--verde);
  border: 1px solid var(--verde); border-radius: 20px;
  padding: .2rem .8rem; font-size: .72rem; font-weight: 700;
}

/* ── OVERLAY MOBILE ── */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 99;
  backdrop-filter: blur(2px);
}
.sidebar-overlay.show { display: block; }

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

/* ── SIDEBAR ── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--navy);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  overflow-y: auto;
  transition: transform .25s ease;
}
.sidebar-logo {
  padding: 1.2rem 1.4rem;
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.sidebar-logo h2 { color: white; font-size: .95rem; font-weight: 800; }
.sidebar-logo span { color: var(--verde-claro); font-size: .72rem; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; }
.sidebar-perfil {
  padding: 1rem 1.4rem;
  border-bottom: 1px solid rgba(255,255,255,.08);
  display: flex; align-items: center; gap: .6rem;
}
.sidebar-perfil .avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--verde); display: flex; align-items: center;
  justify-content: center; font-weight: 700; color: white; font-size: .85rem; flex-shrink: 0;
}
.sidebar-perfil .info p { color: white; font-size: .82rem; font-weight: 600; line-height: 1.2; }
.sidebar-perfil .info span { color: rgba(255,255,255,.5); font-size: .72rem; }
nav.sidebar-nav { flex: 1; padding: .8rem 0; }
.nav-section { padding: .4rem 1.4rem .2rem; }
.nav-section span { color: rgba(255,255,255,.35); font-size: .68rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.nav-link {
  display: flex; align-items: center; gap: .6rem;
  padding: .65rem 1.4rem;
  color: rgba(255,255,255,.7);
  text-decoration: none; font-size: .9rem;
  transition: all .15s;
  border-left: 3px solid transparent;
  min-height: 44px;
}
.nav-link:hover, .nav-link.active {
  color: white;
  background: rgba(255,255,255,.07);
  border-left-color: var(--verde-claro);
}
.nav-link .icon { font-size: 1rem; width: 18px; text-align: center; }
.sidebar-footer {
  padding: 1rem 1.4rem;
  border-top: 1px solid rgba(255,255,255,.08);
}
.sidebar-footer a {
  color: rgba(255,255,255,.4); font-size: .82rem; text-decoration: none;
  display: flex; align-items: center; gap: .4rem;
  min-height: 44px;
}
.sidebar-footer a:hover { color: rgba(255,255,255,.7); }

/* ── HAMBURGER ── */
.hamburger {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  padding: .5rem;
  background: none;
  border: none;
  cursor: pointer;
  flex-shrink: 0;
  min-width: 44px; min-height: 44px;
}
.hamburger span {
  display: block;
  width: 22px; height: 2px;
  background: var(--navy);
  border-radius: 2px;
  transition: all .2s;
}

/* ── MAIN CONTENT ── */
.main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-width: 0;
}
.topbar {
  height: var(--header-h);
  background: white;
  border-bottom: 1px solid var(--borda);
  display: flex; align-items: center;
  padding: 0 1.8rem;
  gap: .8rem;
  justify-content: space-between;
  position: sticky; top: 0; z-index: 50;
}
.topbar-title {
  font-size: 1rem; font-weight: 700; color: var(--navy);
  flex: 1; min-width: 0;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.topbar-right { display: flex; align-items: center; gap: .6rem; flex-shrink: 0; }
.badge-perfil {
  padding: .25rem .7rem; border-radius: 20px;
  font-size: .72rem; font-weight: 700; color: white;
  text-transform: uppercase; letter-spacing: .04em;
  white-space: nowrap;
}
.topbar-hora { white-space: nowrap; }
.page-content { padding: 1.6rem; flex: 1; }

/* ── CARDS / KPIs ── */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px,1fr)); gap: 1rem; margin-bottom: 1.4rem; }
.kpi-card {
  background: white; border-radius: var(--radius);
  padding: 1.2rem 1.4rem;
  box-shadow: var(--shadow);
  border: 1px solid var(--borda);
  display: flex; flex-direction: column; gap: .2rem;
}
.kpi-card .kpi-label { font-size: .72rem; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--texto-sub); }
.kpi-card .kpi-value { font-size: 1.9rem; font-weight: 800; color: var(--navy); line-height: 1.1; }
.kpi-card .kpi-sub { font-size: .75rem; color: var(--texto-sub); }
.kpi-card.destaque { border-color: var(--verde); border-left-width: 4px; }
.kpi-card.destaque .kpi-value { color: var(--verde); }

/* ── GRIDS ── */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin-bottom: 1rem; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 1rem; }

/* ── CARD ── */
.card {
  background: white; border-radius: var(--radius);
  border: 1px solid var(--borda); box-shadow: var(--shadow);
  overflow: hidden;
}
.card-header {
  padding: 1rem 1.4rem;
  border-bottom: 1px solid var(--borda);
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: .5rem;
}
.card-header h3 { font-size: .9rem; font-weight: 700; color: var(--navy); }
.card-body { padding: 1.2rem 1.4rem; }

/* ── TABLE ── */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.tbl { width: 100%; border-collapse: collapse; font-size: .83rem; min-width: 500px; }
table.tbl th {
  background: var(--cinza-bg); color: var(--texto-sub);
  padding: .55rem 1rem; text-align: left;
  font-size: .7rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em;
  border-bottom: 1px solid var(--borda);
  white-space: nowrap;
}
table.tbl td {
  padding: .7rem 1rem; border-bottom: 1px solid #f0f2f5;
  color: var(--texto);
}
table.tbl tr:last-child td { border-bottom: none; }
table.tbl tr:hover td { background: #fafbfc; }

/* ── TIER BADGES ── */
.tier { display: inline-block; padding: .2rem .6rem; border-radius: 6px; font-size: .7rem; font-weight: 700; }
.tier-A { background: #fff3cd; color: #856404; }
.tier-B { background: #d1ecf1; color: #0c5460; }
.tier-C { background: #f8f9fa; color: #6c757d; border: 1px solid #dee2e6; }

/* ── STATUS BADGES ── */
.status-badge {
  display: inline-flex; align-items: center; gap: .3rem;
  padding: .2rem .65rem; border-radius: 20px;
  font-size: .72rem; font-weight: 600;
  white-space: nowrap;
}
.s-nao_contatado { background: #f1f3f5; color: #6c757d; }
.s-contatado { background: #e7f1ff; color: #1864ab; }
.s-reuniao_agendada { background: #fff4e6; color: #e67700; }
.s-diagnostico_ativo { background: #f3f0ff; color: #6741d9; }
.s-proposta_enviada { background: #ebfbee; color: #2b8a3e; }
.s-contrato_assinado { background: #d3f9d8; color: #1a7a4a; font-weight: 700; }
.s-perdido { background: #fff5f5; color: #c92a2a; }

/* ── AGENTE MONITOR ── */
.agente-card {
  background: var(--navy); border-radius: var(--radius);
  padding: 1.2rem 1.4rem; color: white;
  border: 1px solid rgba(255,255,255,.1);
}
.agente-card .agente-nome { font-size: .8rem; font-weight: 700; color: var(--verde-claro); text-transform: uppercase; letter-spacing: .06em; }
.agente-card .agente-status { font-size: 1.1rem; font-weight: 700; margin: .3rem 0; }
.agente-card .agente-desc { font-size: .78rem; color: rgba(255,255,255,.6); }
.pulse {
  display: inline-block; width: 8px; height: 8px;
  border-radius: 50%; background: var(--verde-claro);
  animation: pulse 2s infinite;
}
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .3; } }

/* ── UPLOAD AREA ── */
.upload-zone {
  border: 2px dashed var(--borda);
  border-radius: var(--radius); padding: 3rem 2rem;
  text-align: center; cursor: pointer;
  transition: all .2s; background: #fafbfc;
}
.upload-zone:hover, .upload-zone.drag-over {
  border-color: var(--verde); background: var(--verde-glow);
}
.upload-zone .upload-icon { font-size: 2.5rem; margin-bottom: .8rem; }
.upload-zone p { color: var(--texto-sub); font-size: .88rem; }
.upload-zone strong { color: var(--verde); }

/* ── FORMS ── */
.form-group { margin-bottom: 1rem; }
.form-label { display: block; font-size: .8rem; font-weight: 600; color: var(--texto); margin-bottom: .35rem; }
.form-control {
  width: 100%; padding: .65rem .85rem;
  border: 1px solid var(--borda); border-radius: 8px;
  font-size: .95rem; color: var(--texto);
  background: white; transition: border-color .15s;
  outline: none;
  -webkit-appearance: none;
}
.form-control:focus { border-color: var(--verde); box-shadow: 0 0 0 3px var(--verde-glow); }
select.form-control { cursor: pointer; }

/* ── BUTTONS ── */
.btn {
  display: inline-flex; align-items: center; gap: .4rem;
  padding: .6rem 1.2rem; border-radius: 8px;
  font-size: .85rem; font-weight: 600; cursor: pointer;
  border: 1px solid transparent; text-decoration: none;
  transition: all .15s; min-height: 40px;
  touch-action: manipulation;
}
.btn-primary { background: var(--verde); color: white; }
.btn-primary:hover { background: var(--verde-claro); }
.btn-navy { background: var(--navy); color: white; }
.btn-navy:hover { background: var(--navy-mid); }
.btn-outline { background: white; color: var(--texto); border-color: var(--borda); }
.btn-outline:hover { border-color: var(--verde); color: var(--verde); }
.btn-sm { padding: .38rem .85rem; font-size: .78rem; min-height: 36px; }
.btn-danger { background: #dc3545; color: white; }
.btn-danger:hover { background: #c82333; }

/* ── PROGRESS / LOG ── */
.log-terminal {
  background: #0d1117; border-radius: var(--radius);
  padding: 1rem 1.2rem; font-family: 'Fira Mono', monospace;
  font-size: .78rem; color: #7ee787; max-height: 280px;
  overflow-y: auto; line-height: 1.8;
}
.log-line { display: flex; gap: .5rem; }
.log-ts { color: #8b949e; flex-shrink: 0; }
.log-ok { color: #7ee787; }
.log-warn { color: #d29922; }
.log-err { color: #f85149; }

/* ── ALERTAS ── */
.alert { padding: .85rem 1.1rem; border-radius: 8px; margin-bottom: 1rem; font-size: .85rem; }
.alert-danger { background: #fff5f5; border: 1px solid #ffc9c9; color: #c92a2a; }
.alert-success { background: #ebfbee; border: 1px solid #8ce99a; color: #2b8a3e; }
.alert-info { background: #e7f5ff; border: 1px solid #74c0fc; color: #1864ab; }
.alert-warning { background: #fff9db; border: 1px solid #ffd43b; color: #856404; }

/* ── PIPELINE ROWS ── */
.empresa-row {
  display: grid;
  grid-template-columns: 2fr 80px 1fr 1fr 120px 80px;
  gap: .8rem; align-items: center;
  padding: .75rem 1rem;
  border-bottom: 1px solid #f0f2f5;
}
.empresa-row:hover { background: #fafbfc; }
.empresa-nome { font-weight: 600; color: var(--navy); font-size: .85rem; }
.empresa-fat { font-size: .75rem; color: var(--texto-sub); margin-top: .1rem; }
.empresa-dor { font-size: .78rem; color: var(--texto-sub); }

/* ── RESULTADO DIAGNÓSTICO ── */
.resultado-embed {
  border: none; width: 100%; height: 700px;
  border-radius: var(--radius); overflow: hidden;
}

/* ── DIVIDER ── */
.divider { border: none; border-top: 1px solid var(--borda); margin: 1.2rem 0; }

/* ── TOOLTIP ── */
[data-tooltip] { position: relative; cursor: help; }
[data-tooltip]:hover::after {
  content: attr(data-tooltip);
  position: absolute; bottom: 125%; left: 50%; transform: translateX(-50%);
  background: var(--navy); color: white; padding: .3rem .7rem;
  border-radius: 6px; font-size: .72rem; white-space: nowrap; z-index: 200;
}

/* ── SPINNER ── */
.spinner {
  width: 20px; height: 20px; border: 3px solid var(--borda);
  border-top-color: var(--verde); border-radius: 50%;
  animation: spin .8s linear infinite; display: inline-block;
  flex-shrink: 0;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── ADMIN ── */
.perfil-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: .3rem; }


/* ═══════════════════════════════════════
   RESPONSIVO — TABLET (≤ 1024px)
═══════════════════════════════════════ */
@media (max-width: 1024px) {
  .grid-3 { grid-template-columns: 1fr 1fr; }
  .kpi-grid { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
  .topbar-hora { display: none; }
}


/* ═══════════════════════════════════════
   RESPONSIVO — MOBILE (≤ 768px)
═══════════════════════════════════════ */
@media (max-width: 768px) {

  /* Sidebar vira drawer off-canvas */
  .sidebar {
    transform: translateX(-100%);
    box-shadow: none;
  }
  .sidebar.open {
    transform: translateX(0);
    box-shadow: 4px 0 24px rgba(0,0,0,.3);
  }

  /* Main content ocupa toda a largura */
  .main-content {
    margin-left: 0;
  }

  /* Topbar mobile */
  .topbar {
    padding: 0 1rem;
    gap: .6rem;
  }
  .topbar-title {
    font-size: .88rem;
  }

  /* Mostra hamburger */
  .hamburger {
    display: flex;
  }

  /* Page content com padding menor */
  .page-content {
    padding: 1rem;
  }

  /* Grids empilham */
  .grid-2 { grid-template-columns: 1fr; }
  .grid-3 { grid-template-columns: 1fr; }

  /* KPIs: 2 colunas no mobile */
  .kpi-grid {
    grid-template-columns: 1fr 1fr;
    gap: .7rem;
  }
  .kpi-card {
    padding: 1rem;
  }
  .kpi-card .kpi-value {
    font-size: 1.5rem;
  }
  .kpi-card .kpi-label {
    font-size: .65rem;
  }

  /* Login card */
  .login-card {
    padding: 2rem 1.5rem;
    border-radius: 16px;
  }

  /* Upload zone menor */
  .upload-zone {
    padding: 1.8rem 1rem;
  }
  .upload-zone .upload-icon { font-size: 2rem; }

  /* Pipeline rows viram cards empilhados */
  .empresa-row {
    grid-template-columns: 1fr 1fr;
    gap: .5rem;
    padding: .8rem 1rem;
  }

  /* Iframe resultado menor */
  .resultado-embed {
    height: 500px;
  }

  /* Badge de perfil ocultado se sobrar pouco espaço */
  .badge-perfil {
    font-size: .65rem;
    padding: .2rem .5rem;
  }

  /* Agente cards no dashboard com padding menor */
  .agente-card {
    padding: 1rem;
  }
  .agente-card .agente-status {
    font-size: .95rem;
  }

  /* Botões full-width quando dentro de form */
  form .btn-primary[style*="width:100%"] {
    padding: .75rem 1rem;
    font-size: .95rem;
  }

  /* Card header empilha em telas estreitas */
  .card-header {
    flex-direction: column;
    align-items: flex-start;
  }
  .card-header .btn { align-self: flex-end; margin-top: -.5rem; }
}


/* ═══════════════════════════════════════
   RESPONSIVO — MOBILE PEQUENO (≤ 480px)
═══════════════════════════════════════ */
@media (max-width: 480px) {

  body { font-size: 13px; }

  /* KPIs em coluna única em telas muito pequenas */
  .kpi-grid { grid-template-columns: 1fr; }
  .kpi-card .kpi-value { font-size: 1.7rem; }

  /* Topbar título encurta mais */
  .topbar-title { font-size: .8rem; }

  /* Badge perfil oculto em telas muito pequenas */
  .badge-perfil { display: none; }

  /* Pipeline rows em coluna única */
  .empresa-row { grid-template-columns: 1fr; }

  /* Iframe menor */
  .resultado-embed { height: 420px; }

  /* Form control maior para toque */
  .form-control { font-size: 1rem; padding: .7rem .9rem; }

  /* Alerta menor */
  .alert { font-size: .8rem; padding: .75rem .9rem; }

  /* Sidebar mais estreita em mobile pequeno */
  .sidebar { width: 85vw; max-width: 300px; }

  /* Card body com padding menor */
  .card-body { padding: 1rem; }
  .card-header { padding: .9rem 1rem; }
}
