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

:root {
  --primary: #172033; 
  --primary-hover: #27344d;
  --accent: #f47b20; 
  --accent-hover: #d96512;
  --bg-app: #f5f7fb;
  --bg-surface: #ffffff;
  --text-main: #111827;
  --text-muted: #475569;
  --border: #d8e0ec;
  --border-focus: #cbd5e1;
  --accent-soft: #fff3ea;
  --danger: #ef4444;
  --success: #10b981;
  --radius-md: 8px;
  --radius-lg: 10px;
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  --sidebar-width: 280px;
  --sidebar-collapsed-width: 72px;
  --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body { font-family: 'Inter', sans-serif; background-color: var(--bg-app); color: var(--text-main); -webkit-font-smoothing: antialiased; display: flex; min-height: 100vh; line-height: 1.5; letter-spacing: 0; }

.app-layout { display: flex; width: 100%; }

/* Sidebar - Agora nasce encurtado e com espaçamento corrigido */
.sidebar {
  width: var(--sidebar-width); background-color: var(--bg-surface); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; transition: var(--transition); position: relative; z-index: 10; box-shadow: 1px 0 0 rgba(15, 23, 42, .02);
}
.sidebar.collapsed { width: var(--sidebar-collapsed-width); }
.sidebar.collapsed:hover { width: var(--sidebar-width); box-shadow: 18px 0 40px rgba(15, 23, 42, .08); }

.brand {
  height: 72px; display: flex; align-items: center; padding: 0 26px; border-bottom: 1px solid var(--border);
  text-decoration: none; color: var(--text-main); overflow: hidden; white-space: nowrap; gap: 16px; /* Gap resolve o esmagamento do logo */
}
.brand .logo-slot { flex-shrink: 0; display: flex; align-items: center; }
.brand img { height: 32px; border-radius: 4px; }
.brand .logo-text { display: flex; flex-direction: column; line-height: 1.2; }
.brand .logo-text strong { font-size: 15px; font-weight: 700; letter-spacing: 0; }
.brand .logo-text small { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

.main-nav { flex: 1; padding: 20px 12px; display: flex; flex-direction: column; gap: 8px; }
.main-nav a {
  min-height: 46px; display: flex; align-items: center; gap: 14px; padding: 10px 14px; text-decoration: none; color: var(--text-muted);
  border-radius: var(--radius-md); font-weight: 600; font-size: 14px; transition: var(--transition); overflow: hidden; white-space: nowrap;
}
/* Margem do ícone aumentada para não colar no texto */
.main-nav a i, .main-nav a svg { width: 21px; height: 21px; flex-shrink: 0; }
.main-nav a:hover, .main-nav a.active { background-color: var(--accent-soft); color: var(--accent-hover); }
.main-nav a.active { box-shadow: inset 3px 0 0 var(--accent); }

.sidebar-user { padding: 16px 16px 10px; border-top: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; overflow: hidden; white-space: nowrap; }
.sidebar-user a { display: flex; align-items: center; gap: 14px; text-decoration: none; color: var(--text-main); font-size: 14px; font-weight: 500; }
.sidebar-user a i, .sidebar-user a svg { color: var(--text-muted); flex-shrink: 0; width: 21px; height: 21px; }
.sidebar-footer { padding: 0 18px 16px; color: var(--text-muted); font-size: 11px; line-height: 1.35; min-height: 34px; }
.sidebar.collapsed .sidebar-footer span { display: none; }
.sidebar.collapsed:hover .brand .logo-text,
.sidebar.collapsed:hover .main-nav a span,
.sidebar.collapsed:hover .sidebar-user span,
.sidebar.collapsed:hover .sidebar-footer span { display: initial; }
.sidebar.collapsed:hover .sidebar-user { flex-direction: row; justify-content: space-between; gap: 0; }
.sidebar.collapsed:hover .sidebar-user a { gap: 14px; }
.icon-logout { background: none; border: none; color: var(--text-muted); cursor: pointer; transition: var(--transition); display: flex; align-items: center; justify-content: center; }
.icon-logout:hover { color: var(--danger); }

.sidebar-toggle {
  position: absolute; top: 20px; right: -14px; width: 28px; height: 28px; background: var(--bg-surface);
  border: 1px solid var(--border); border-radius: 50%; display: flex; align-items: center; justify-content: center;
  cursor: pointer; color: var(--text-muted); transition: var(--transition); z-index: 20; box-shadow: var(--shadow-sm);
}
.sidebar-toggle i { transition: transform 0.3s ease; }
.sidebar-toggle:hover { color: var(--primary); border-color: var(--text-muted); }

.sidebar.collapsed .brand .logo-text, .sidebar.collapsed .main-nav a span, .sidebar.collapsed .sidebar-user span { display: none; }
.sidebar.collapsed .sidebar-user { justify-content: center; flex-direction: column; gap: 12px; }
.sidebar.collapsed .sidebar-user a { gap: 0; }
.sidebar.collapsed:hover .brand .logo-text { display: flex; }
.sidebar.collapsed:hover .main-nav a span,
.sidebar.collapsed:hover .sidebar-user span,
.sidebar.collapsed:hover .sidebar-footer span { display: initial; }
.sidebar.collapsed:hover .sidebar-user { flex-direction: row; justify-content: space-between; gap: 0; }
.sidebar.collapsed:hover .sidebar-user a { gap: 14px; }
/* Seta do toggle vira quando colapsado */
.sidebar.collapsed .sidebar-toggle i { transform: rotate(180deg); }

/* Main Area */
.app-frame { flex: 1; display: flex; flex-direction: column; overflow: hidden; }
.topbar { min-height: 68px; background-color: rgba(255,255,255,.94); backdrop-filter: blur(12px); border-bottom: 1px solid var(--border); display: flex; align-items: center; padding: 0 32px; justify-content: space-between; }
.topbar .eyebrow { font-size: 12px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; display: block;}
.topbar strong { font-size: 16px; font-weight: 600; color: var(--text-main); }
.shell { padding: 30px 32px 40px; flex: 1; overflow-y: auto; width: 100%; max-width: none; }

/* Typography & Layouts */
.page-head { margin-bottom: 18px; display: flex; justify-content: space-between; align-items: flex-end; gap: 24px; animation: fadeIn 0.25s ease; }
.page-head h1 { font-size: 28px; line-height: 1.15; font-weight: 800; color: var(--primary); margin-bottom: 6px; letter-spacing: 0; }
.page-head p { color: var(--text-muted); font-size: 14px; max-width: 860px; line-height: 1.45; }
h2 { font-size: 16px; font-weight: 750; margin-bottom: 12px; color: var(--primary); }
.section-gap { margin-top: 26px; }
.grid-two { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 18px; animation: fadeIn 0.25s ease; }

/* Filtros Avançados */
.advanced-filters {
  display: grid; grid-template-columns: repeat(6, minmax(160px, 1fr)); gap: 12px;
  background: var(--bg-surface); padding: 14px;
  border: 1px solid var(--border); border-top: 0; border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}
.filter-actions { grid-column: 1 / -1; display: flex; justify-content: flex-end; gap: 10px; margin-top: 2px; padding-top: 12px; border-top: 1px solid var(--border); }
.filter-wide { grid-column: 1 / -1; }
.filter-panel {
  background: transparent;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  margin-bottom: 14px;
  overflow: visible;
}
.filter-panel summary {
  min-height: 46px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 14px;
  cursor: pointer;
  list-style: none;
  color: var(--primary);
  font-weight: 750;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: 0 8px 22px rgba(15, 23, 42, .035);
}
.filter-panel[open] summary { border-radius: var(--radius-lg) var(--radius-lg) 0 0; border-bottom-color: transparent; }
.filter-panel summary::-webkit-details-marker { display: none; }
.filter-panel summary span { display: flex; align-items: center; gap: 10px; font-size: 14px; }
.filter-panel summary svg { width: 18px; height: 18px; color: var(--accent); }
.filter-panel summary small,
.filter-panel summary strong {
  padding: 5px 9px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-hover);
  font-size: 12px;
  font-weight: 750;
}
.input-icon { position: relative; }
.input-icon svg {
  position: absolute;
  left: 13px;
  top: 50%;
  width: 18px;
  height: 18px;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
}
.input-icon input { padding-left: 42px; }

/* Forms & Inputs */
.inline-form {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 16px;
  margin-bottom: 26px;
  background: var(--bg-surface);
  padding: 22px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  box-shadow: 0 10px 24px rgba(15, 23, 42, .035);
}
.inline-form button { justify-self: start; }
input, select, textarea {
  height: 40px; padding: 0 12px; border: 1px solid var(--border); border-radius: var(--radius-md); font-family: inherit;
  font-size: 14px; color: var(--text-main); background: var(--bg-surface); transition: var(--transition); outline: none; width: 100%;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(244, 123, 32, 0.13); }
label { display: block; font-size: 12px; font-weight: 750; margin-bottom: 6px; color: #263246; }

/* Componentes visuais */
.table-container { background: var(--bg-surface); border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: auto; box-shadow: 0 12px 28px rgba(15, 23, 42, .04); animation: fadeIn 0.25s ease; }
table { width: 100%; border-collapse: collapse; text-align: left; font-size: 13px; min-width: 920px; }
th { background-color: #f7f9fc; padding: 11px 14px; font-weight: 800; color: #344258; border-bottom: 1px solid var(--border); font-size: 11px; text-transform: uppercase; letter-spacing: .03em; white-space: nowrap; }
td { padding: 13px 14px; border-bottom: 1px solid var(--border); color: var(--text-main); vertical-align: middle; line-height: 1.4; }
tr:last-child td { border-bottom: none; }
tbody tr:hover { background-color: #f1f5f9; }

button, .table-action { min-height: 38px; padding: 0 14px; border: none; border-radius: var(--radius-md); font-family: inherit; font-size: 13px; font-weight: 750; cursor: pointer; background-color: var(--accent); color: #fff; transition: var(--transition); display: inline-flex; align-items: center; justify-content: center; text-decoration: none; gap: 8px; }
button svg, .table-action svg { width: 16px; height: 16px; flex-shrink: 0; }
button:hover, .table-action:hover { background-color: var(--accent-hover); }
button.ghost, .table-action.ghost { background-color: transparent; color: var(--text-main); border: 1px solid var(--border); }
button.ghost:hover, .table-action.ghost:hover { background-color: #f1f5f9; }

.pill { background: #f1f5f9; color: #475569; padding: 5px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; display: inline-block; margin: 3px; line-height: 1.2; }
.badge { padding: 4px 8px; border-radius: 4px; font-size: 12px; font-weight: 600; display: inline-block; }
.badge.green { background: #dcfce7; color: #166534; }
.badge.amber { background: #fef3c7; color: #92400e; }
.error { background: #fee2e2; color: #991b1b; padding: 12px 16px; border-radius: var(--radius-md); margin-bottom: 16px; font-size: 14px; border-left: 4px solid var(--danger); }
.hint { color: var(--text-muted); font-size: 13px; margin-top: 4px; }

code { font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace; }

.metrics { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 14px; margin-bottom: 18px; }
.metrics article { background: var(--bg-surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 18px; box-shadow: 0 10px 24px rgba(15, 23, 42, .035); }
.metrics article span { display: block; font-size: 30px; line-height: 1; font-weight: 820; margin-top: 6px; color: var(--primary); }
.metrics article strong { color: #334155; font-size: 13px; font-weight: 750; }

.docs-panel, .grid-two > div { background: var(--bg-surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 18px; box-shadow: 0 10px 24px rgba(15, 23, 42, .035); }
.docs-grid { display: grid; grid-template-columns: 1fr; gap: 10px; margin-top: 18px; }
pre { overflow: auto; padding: 18px; border-radius: var(--radius-md); background: #0f172a; color: #f8fafc; line-height: 1.55; }
.api-reference-item {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: #fff;
  overflow: hidden;
}
.api-reference-item summary {
  min-height: 48px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 14px;
  cursor: pointer;
  list-style: none;
  font-weight: 750;
}
.api-reference-item summary::-webkit-details-marker { display: none; }
.api-reference-item summary span {
  min-width: 48px;
  text-align: center;
  border-radius: 999px;
  padding: 4px 8px;
  background: var(--accent-soft);
  color: var(--accent-hover);
  font-size: 11px;
}
.api-reference-item pre { margin: 0 14px 12px; }
.api-reference-item .hint { padding: 0 14px 14px; }

@media (max-width: 900px) {
  .app-layout { display: block; }
  .sidebar, .sidebar.collapsed { width: 100%; position: relative; }
  .main-nav { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
  .sidebar.collapsed .brand .logo-text, .sidebar.collapsed .main-nav a span, .sidebar.collapsed .sidebar-user span, .sidebar.collapsed .sidebar-footer span { display: initial; }
  .shell { padding: 24px; }
  .topbar { padding: 0 24px; }
}

.form-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: 0 12px 28px rgba(15, 23, 42, .04);
  margin-bottom: 18px;
}
.form-card-head {
  min-height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
}
.form-card-head h2 { margin: 0 0 2px; font-size: 16px; }
.form-card-head p { margin: 0; color: var(--text-muted); font-size: 13px; }
.compact-form {
  display: grid;
  grid-template-columns: repeat(4, minmax(180px, 1fr));
  gap: 12px;
  padding: 16px 18px 18px;
}
.compact-form label { margin: 0; }
.compact-form input,
.compact-form select { margin-top: 6px; }
.compact-form .form-actions {
  grid-column: 1 / -1;
  display: flex;
  justify-content: flex-start;
  padding-top: 4px;
}
.compact-form .form-actions.split {
  justify-content: space-between;
  align-items: center;
}
.compact-form .form-wide { grid-column: 1 / -1; }
.check {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  color: var(--text-main);
  font-weight: 600;
}
.check input[type="checkbox"] {
  width: 16px;
  height: 16px;
  margin: 0;
  accent-color: var(--accent);
}
.permission-box {
  grid-column: 1 / -1;
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px;
}
.permission-box > strong {
  display: block;
  margin-bottom: 12px;
  color: var(--text-muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .03em;
}
.permission-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 10px;
}
.permission-root {
  grid-column: 1 / -1;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}
.permission-option {
  min-height: 38px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 8px 10px;
  color: var(--text-muted);
}
.api-key-form { grid-template-columns: minmax(320px, 520px) auto; align-items: end; }
.api-key-form .form-actions { grid-column: auto; padding-top: 0; }
.nps-form { grid-template-columns: 1.2fr .8fr .8fr; }
.nps-workspace { grid-template-columns: minmax(0, 1.1fr) minmax(360px, .9fr); }
.integration-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.65fr) minmax(360px, .75fr);
  gap: 18px;
  align-items: start;
}
.integration-layout > div {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px;
  box-shadow: 0 10px 24px rgba(15, 23, 42, .035);
}
.integration-sync-panel .table-container table { min-width: 900px; }
.sync-check-cell {
  width: 88px;
  text-align: center;
}
.sync-checkbox {
  width: 18px;
  height: 18px;
  margin: 0;
  accent-color: var(--accent);
}
.integration-side-panel pre {
  padding: 12px;
  font-size: 12px;
  white-space: pre-wrap;
  word-break: break-word;
}

@media (min-width: 1300px) {
  .shell { padding-left: 36px; padding-right: 36px; }
  .agent-form { grid-template-columns: 1.15fr 1fr 1fr .85fr .85fr .85fr .9fr 1.2fr; align-items: end; }
  .agent-form .form-actions { grid-column: auto; padding-top: 0; }
  .user-form { grid-template-columns: 1fr 1fr .7fr; }
}

@media (max-width: 1200px) {
  .advanced-filters { grid-template-columns: repeat(3, minmax(180px, 1fr)); }
  .compact-form, .nps-form, .api-key-form { grid-template-columns: repeat(2, minmax(180px, 1fr)); }
  .nps-workspace, .integration-layout { grid-template-columns: 1fr; }
}

/* NPS Preview Panel */
.nps-preview-box { border: 1px solid var(--border); border-radius: var(--radius-lg); background: #f8fafc; padding: 32px; display: flex; flex-direction: column; align-items: center; text-align: center; justify-content: center; height: 100%; box-shadow: inset 0 2px 4px 0 rgb(0 0 0 / 0.02); }
.nps-stars { color: #cbd5e1; font-size: 32px; letter-spacing: 8px; margin: 16px 0; }
.nps-stars.active { color: #fbbf24; }

@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

body.centered {
  display: grid;
  place-items: center;
  padding: 32px;
  background:
    radial-gradient(circle at 18% 20%, rgba(244, 123, 32, 0.16), transparent 28%),
    linear-gradient(135deg, #f8fafc 0%, #eef2f7 52%, #fff7ed 100%);
}

.login-shell {
  width: min(1080px, 100%);
  min-height: 640px;
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(360px, .95fr);
  overflow: hidden;
  background: rgba(255, 255, 255, .94);
  border: 1px solid rgba(226, 232, 240, .92);
  border-radius: 18px;
  box-shadow: 0 24px 70px rgba(15, 23, 42, .14);
}

.login-hero {
  padding: 48px;
  color: #fff;
  background:
    linear-gradient(135deg, rgba(23, 32, 51, .96), rgba(39, 52, 77, .92)),
    linear-gradient(45deg, rgba(244, 123, 32, .82), transparent 54%);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 34px;
}

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 54px;
}

.brand-mark {
  width: 56px;
  height: 56px;
  display: inline-grid;
  place-items: center;
  border-radius: 14px;
  background: var(--accent);
  color: #fff;
  font-weight: 800;
  letter-spacing: 0;
  box-shadow: 0 14px 30px rgba(244, 123, 32, .3);
}

.login-hero h1 {
  max-width: 560px;
  font-size: clamp(34px, 5vw, 56px);
  line-height: 1.02;
  letter-spacing: 0;
  margin-bottom: 18px;
}

.login-hero p {
  max-width: 560px;
  color: rgba(255,255,255,.78);
  font-size: 16px;
  line-height: 1.6;
}

.login-insights {
  display: grid;
  gap: 14px;
}

.login-insights article {
  padding: 18px;
  border: 1px solid rgba(255,255,255,.18);
  border-radius: 12px;
  background: rgba(255,255,255,.08);
  backdrop-filter: blur(10px);
}

.login-insights strong,
.login-insights span {
  display: block;
}

.login-insights strong {
  margin-bottom: 6px;
}

.login-insights span {
  color: rgba(255,255,255,.72);
  line-height: 1.5;
}

.login-card-wrap {
  display: grid;
  align-items: center;
  padding: 46px;
  background: #fff;
}

.auth-panel {
  width: 100%;
  display: grid;
  gap: 18px;
}

.auth-panel[hidden] {
  display: none;
}

.auth-panel h1 {
  font-size: 28px;
  line-height: 1.15;
  color: var(--primary);
  letter-spacing: 0;
}

.auth-panel .hint {
  margin: -8px 0 6px;
  font-size: 14px;
  line-height: 1.55;
}

.auth-panel label {
  margin-bottom: 0;
}

.auth-panel input {
  margin-top: 8px;
}

.step-badge {
  width: fit-content;
  padding: 6px 10px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-hover);
  font-size: 12px;
  font-weight: 750;
}

.method-list {
  display: grid;
  gap: 12px;
}

.auth-method-button {
  width: 100%;
  justify-content: flex-start;
  min-height: 52px;
  background: #fff;
  color: var(--text-main);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}

.auth-method-button:hover {
  background: var(--accent-soft);
  color: var(--accent-hover);
  border-color: rgba(244, 123, 32, .35);
}

.auth-method-button.disabled,
.auth-method-button:disabled {
  opacity: .55;
  cursor: not-allowed;
  background: #f8fafc;
}

@media (max-width: 860px) {
  body.centered {
    padding: 0;
    place-items: stretch;
  }

  .login-shell {
    min-height: 100vh;
    grid-template-columns: 1fr;
    border-radius: 0;
  }

  .login-hero {
    padding: 32px 24px;
  }

  .brand-lockup {
    margin-bottom: 32px;
  }

  .login-card-wrap {
    padding: 32px 24px 42px;
  }
}
