/* ============================================================
   Maninho Criativos — Admin Panel CRM
   Dark SaaS · Linear/Vercel/Railway style
   1 cor de acento · grid de 8px · bordas neutras
   ============================================================ */

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

:root {
  /* ---- Acento (único) ---- */
  --accent:        #0070f3;
  --accent-hover:  #1a85ff;
  --accent-press:  #0061d6;
  --accent-soft:   rgba(0, 112, 243, 0.14);
  --accent-ring:   rgba(0, 112, 243, 0.40);

  /* ---- Superfícies (near-black, escalonadas) ---- */
  --bg:            #0a0a0a;
  --surface-1:     #0f0f10;
  --surface-2:     #141415;
  --surface-3:     #1a1a1c;
  --surface-4:     #202022;

  /* ---- Bordas neutras ---- */
  --border:        rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.14);
  --border-faint:  rgba(255, 255, 255, 0.05);

  /* ---- Texto ---- */
  --text:          #ededed;
  --text-2:        #a0a0a8;
  --text-3:        #6c6c74;
  --text-on-accent: #ffffff;

  /* ---- Semânticas ---- */
  --green:         #30a46c;
  --green-soft:    rgba(48, 164, 108, 0.14);
  --amber:         #e0a30a;
  --amber-soft:    rgba(224, 163, 10, 0.14);
  --red:           #e5484d;
  --red-soft:      rgba(229, 72, 77, 0.14);
  --violet:        #8e6cf0;
  --violet-soft:   rgba(142, 108, 240, 0.14);

  /* ---- Espaçamento: grid de 8px ---- */
  --s-1: 4px;
  --s-2: 8px;
  --s-3: 12px;
  --s-4: 16px;
  --s-5: 24px;
  --s-6: 32px;
  --s-7: 48px;
  --s-8: 64px;

  /* ---- Raio ---- */
  --r-sm: 6px;
  --r-md: 8px;
  --r-lg: 12px;
  --r-full: 999px;

  /* ---- Alturas de controle ---- */
  --h-sm: 28px;
  --h-md: 34px;
  --h-lg: 38px;

  /* ---- Sombras ---- */
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.4);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.45);
  --shadow-lg: 0 12px 40px rgba(0,0,0,0.55);

  /* ---- Densidade (confortável = padrão) ---- */
  --gutter:     24px;
  --card-pad:   20px;
  --row-h:      52px;
  --stack:      16px;
  --sidebar-w:  248px;

  --font: 'Poppins', system-ui, -apple-system, sans-serif;
}

/* ---- Modo compacto (opcional) ---- */
[data-density="compact"] {
  --gutter:    16px;
  --card-pad:  14px;
  --row-h:     40px;
  --stack:     10px;
  --sidebar-w: 224px;
}

/* ============================================================
   Reset + base
   ============================================================ */
* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

#app { height: 100%; }

::selection { background: var(--accent-soft); color: #fff; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.10);
  border-radius: var(--r-full);
  border: 2px solid transparent;
  background-clip: padding-box;
}
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.18); background-clip: padding-box; }

button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, textarea, select { font-family: inherit; }
a { color: inherit; text-decoration: none; }

/* ============================================================
   Tipografia utilitária
   ============================================================ */
.t-display { font-size: 28px; font-weight: 600; letter-spacing: -0.02em; line-height: 1.15; }
.t-h1      { font-size: 20px; font-weight: 600; letter-spacing: -0.015em; }
.t-h2      { font-size: 15px; font-weight: 600; letter-spacing: -0.01em; }
.t-body    { font-size: 14px; font-weight: 400; }
.t-sm      { font-size: 13px; font-weight: 400; }
.t-xs      { font-size: 12px; font-weight: 400; }
.t-mono    { font-variant-numeric: tabular-nums; font-feature-settings: "tnum"; }
.t-muted   { color: var(--text-2); }
.t-faint   { color: var(--text-3); }
.t-label   { font-size: 11px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-3); }

/* ============================================================
   Focus
   ============================================================ */
:focus-visible {
  outline: 2px solid var(--accent-ring);
  outline-offset: 1px;
  border-radius: var(--r-sm);
}

/* ============================================================
   SHELL LAYOUT
   ============================================================ */
.app-shell {
  display: flex;
  height: 100%;
  overflow: hidden;
}

.app-sidebar {
  width: var(--sidebar-w);
  background: var(--surface-1);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  padding: var(--s-4);
  gap: var(--s-4);
  flex-shrink: 0;
}

.app-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
}

.app-topbar {
  height: 64px;
  background: var(--surface-1);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--gutter);
  flex-shrink: 0;
  position: sticky;
  top: 0;
  z-index: 50;
  gap: var(--s-4);
}

.topbar-title {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.topbar-title h1 {
  font-size: 20px;
  font-weight: 600;
}

.topbar-subtitle {
  font-size: 13px;
  color: var(--text-2);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  margin-left: auto;
}

.app-scroll {
  flex: 1;
  overflow-y: auto;
  padding: var(--gutter);
}

.app-bottomnav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 100;
  height: 58px;
  background: color-mix(in srgb, var(--surface-1) 94%, transparent);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom);
}

/* ============================================================
   SIDEBAR NAV
   ============================================================ */
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  padding-bottom: var(--s-4);
  border-bottom: 1px solid var(--border);
}

.sidebar-brand-icon {
  width: 30px;
  height: 30px;
  border-radius: var(--r-md);
  background: var(--accent);
  color: var(--text-on-accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
  flex-shrink: 0;
}

.sidebar-brand-text {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.sidebar-brand-name {
  font-size: 13px;
  font-weight: 600;
}

.sidebar-brand-site {
  font-size: 11px;
  color: var(--text-2);
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.sidebar-nav-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-3);
  padding: var(--s-3) 0;
  margin-top: var(--s-3);
}

.nav-item {
  height: var(--h-lg);
  display: flex;
  align-items: center;
  gap: var(--s-3);
  padding: 0 var(--s-3);
  border-radius: var(--r-md);
  color: var(--text-2);
  font-weight: 500;
  transition: all 0.12s;
  position: relative;
  cursor: pointer;
  white-space: nowrap;
}

.nav-item:hover {
  background: var(--surface-3);
  color: var(--text);
}

.nav-item.active {
  background: var(--surface-3);
  color: var(--text);
}

.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 25%;
  bottom: 25%;
  width: 3px;
  border-radius: 0 var(--r-md) var(--r-md) 0;
  background: var(--accent);
}

.nav-item svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.nav-badge {
  margin-left: auto;
  min-width: 18px;
  height: 18px;
  padding: 0 4px;
  border-radius: var(--r-full);
  background: var(--accent);
  color: var(--text-on-accent);
  font-size: 10px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.sidebar-spacer {
  flex: 1;
}

.sidebar-footer {
  border-top: 1px solid var(--border);
  padding-top: var(--s-4);
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.sidebar-footer-item {
  height: var(--h-lg);
  display: flex;
  align-items: center;
  gap: var(--s-3);
  padding: 0 var(--s-3);
  border-radius: var(--r-md);
  color: var(--text-3);
  font-weight: 500;
  transition: all 0.12s;
  cursor: pointer;
}

.sidebar-footer-item:hover {
  background: var(--surface-3);
  color: var(--text-2);
}

.sidebar-footer-item svg {
  width: 16px;
  height: 16px;
}

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s-2);
  border-radius: var(--r-md);
  font-weight: 500;
  transition: all 0.12s;
  cursor: pointer;
  white-space: nowrap;
  border: none;
  background: none;
  color: inherit;
  font-family: inherit;
}

.btn-primary {
  height: var(--h-md);
  padding: 0 var(--s-4);
  background: var(--accent);
  color: var(--text-on-accent);
  font-weight: 600;
}

.btn-primary:hover {
  background: var(--accent-hover);
  box-shadow: 0 0 0 3px var(--accent-ring);
}

.btn-primary:active {
  background: var(--accent-press);
}

.btn-primary.large {
  height: var(--h-lg);
  padding: 0 var(--s-5);
  font-size: 15px;
}

.btn-secondary {
  height: var(--h-md);
  padding: 0 var(--s-4);
  background: var(--surface-3);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  background: var(--surface-4);
}

.btn-ghost {
  height: var(--h-md);
  padding: 0 var(--s-3);
  color: var(--text-2);
}

.btn-ghost:hover {
  color: var(--text);
  background: var(--surface-3);
}

.btn-danger {
  height: var(--h-md);
  padding: 0 var(--s-3);
  color: var(--red);
  background: transparent;
  border: 1px solid transparent;
}

.btn-danger:hover {
  background: var(--red-soft);
  border-color: rgba(229, 72, 77, 0.2);
}

.btn-icon {
  width: var(--h-md);
  height: var(--h-md);
  padding: 0;
  background: var(--surface-3);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  color: var(--text-2);
}

.btn-icon:hover {
  background: var(--surface-4);
  border-color: var(--border-strong);
}

.btn.full {
  width: 100%;
}

.btn-outline {
  height: var(--h-md);
  padding: 0 var(--s-4);
  border: 1px dashed var(--border);
  color: var(--text-2);
  background: transparent;
}

.btn-outline:hover {
  border-color: var(--border-strong);
  color: var(--text);
}

/* ============================================================
   INPUTS
   ============================================================ */
.input, .textarea, .select {
  width: 100%;
  height: var(--h-md);
  padding: 0 var(--s-3);
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  color: var(--text);
  font-size: 14px;
  transition: border-color 0.12s, box-shadow 0.12s;
}

.input:focus, .textarea:focus, .select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.textarea {
  height: auto;
  min-height: 80px;
  padding: var(--s-2);
  resize: vertical;
}

.input::placeholder {
  color: var(--text-3);
}

.input-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.input-wrap svg {
  position: absolute;
  left: var(--s-3);
  width: 16px;
  height: 16px;
  color: var(--text-3);
  pointer-events: none;
}

.input-wrap .input {
  padding-left: 34px;
}

/* ============================================================
   CARDS
   ============================================================ */
.card {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--card-pad);
  transition: border-color 0.12s;
}

.card:hover {
  border-color: var(--border-strong);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--s-4);
  padding-bottom: var(--s-3);
  border-bottom: 1px solid var(--border-faint);
}

.card-header h3 {
  font-size: 15px;
  font-weight: 600;
}

.card-header-actions {
  display: flex;
  align-items: center;
  gap: var(--s-2);
}

/* ============================================================
   BADGES & STATUS
   ============================================================ */
.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  height: 22px;
  padding: 0 var(--s-3);
  border-radius: var(--r-full);
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
  border: 1px solid transparent;
}

.badge.blue   { background: var(--accent-soft); color: var(--accent); border-color: rgba(0, 112, 243, 0.2); }
.badge.green  { background: var(--green-soft); color: var(--green); border-color: rgba(48, 164, 108, 0.2); }
.badge.amber  { background: var(--amber-soft); color: var(--amber); border-color: rgba(224, 163, 10, 0.2); }
.badge.red    { background: var(--red-soft); color: var(--red); border-color: rgba(229, 72, 77, 0.2); }
.badge.violet { background: var(--violet-soft); color: var(--violet); border-color: rgba(142, 108, 240, 0.2); }

.badge-dot {
  width: 6px;
  height: 6px;
  border-radius: var(--r-full);
  background: currentColor;
  flex-shrink: 0;
}

/* ============================================================
   TABS
   ============================================================ */
.tabs {
  display: flex;
  gap: var(--s-2);
  background: var(--surface-1);
  padding: var(--s-2);
  border-radius: var(--r-md);
  height: var(--h-sm);
  -ms-overflow-style: none;
  scrollbar-width: none;
  overflow-x: auto;
}

.tabs::-webkit-scrollbar { display: none; }

.tab-item {
  height: 24px;
  padding: 0 var(--s-3);
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--text-2);
  font-weight: 500;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.12s;
  white-space: nowrap;
  flex-shrink: 0;
}

.tab-item:hover {
  color: var(--text);
}

.tab-item.active {
  background: var(--surface-4);
  color: var(--text);
}

/* ============================================================
   GRIDS & RESPONSIVE
   ============================================================ */
.grid-kpi        { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--stack); }
.grid-analytics  { display: grid; grid-template-columns: 1.3fr 1fr; gap: var(--stack); }
.grid-links      { display: grid; grid-template-columns: 1fr 300px; gap: var(--stack); align-items: start; }
.grid-portfolio  { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--stack); }
.grid-lead-detail{ display: grid; grid-template-columns: 320px 1fr; gap: var(--stack); align-items: start; }
.grid-form-2     { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }

/* Tabela leads */
.leads-header {
  display: grid;
  grid-template-columns: 2.4fr 1.3fr 1fr 1fr 0.9fr 40px;
  height: 42px;
  align-items: center;
  padding: 0 var(--s-4);
  background: var(--surface-1);
  border-bottom: 1px solid var(--border);
}

.lead-row {
  display: grid;
  grid-template-columns: 2.4fr 1.3fr 1fr 1fr 0.9fr 40px;
  height: var(--row-h);
  align-items: center;
  padding: 0 var(--s-4);
  border-bottom: 1px solid var(--border-faint);
  cursor: pointer;
  transition: background 0.12s;
}

.lead-row:hover {
  background: var(--surface-3);
}

.lead-row:last-child {
  border-bottom: none;
}

/* ---- Breakpoints ---- */
@media (max-width: 1100px) {
  .grid-kpi { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 1000px) {
  .grid-portfolio { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 860px) {
  .app-sidebar { display: none !important; }
  .app-bottomnav { display: flex; }
  .app-scroll { padding-bottom: 64px; overflow-x: hidden; }

  .grid-analytics  { grid-template-columns: minmax(0, 1fr); }
  .grid-links      { grid-template-columns: minmax(0, 1fr); }
  .grid-lead-detail { grid-template-columns: minmax(0, 1fr); }

  .sticky-side { position: static !important; top: auto !important; }
}

@media (max-width: 680px) {
  .leads-header { display: none !important; }
  .lead-row {
    grid-template-columns: minmax(0, 1fr) auto !important;
    grid-template-areas: "lead status" "lead value" "lead date" !important;
    align-items: start !important;
    padding: var(--s-3) var(--s-4) !important;
    row-gap: 3px;
    column-gap: var(--s-3);
  }
  .lc-lead   { grid-area: lead; align-self: center; }
  .lc-source { display: none !important; }
  .lc-status { grid-area: status; justify-self: end; }
  .lc-value  { grid-area: value; justify-self: end; }
  .lc-date   { grid-area: date; justify-self: end; }
  .lc-chev   { display: none !important; }
}

@media (max-width: 560px) {
  .grid-kpi       { grid-template-columns: minmax(0, 1fr); }
  .grid-portfolio { grid-template-columns: minmax(0, 1fr); }
  .grid-form-2    { grid-template-columns: minmax(0, 1fr); }
  .app-topbar { height: auto !important; min-height: 58px; padding-top: 10px !important; padding-bottom: 10px !important; }
}

/* ============================================================
   UTILITIES
   ============================================================ */
.gap-stack { gap: var(--stack); }
.gap-gutter { gap: var(--gutter); }
.p-gutter { padding: var(--gutter); }
.p-card { padding: var(--card-pad); }

.flex { display: flex; }
.flex-col { display: flex; flex-direction: column; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }

.w-full { width: 100%; }
.h-full { height: 100%; }

.hidden { display: none !important; }
.sticky { position: sticky; }

.text-left { text-align: left; }
.text-right { text-align: right; }
.text-center { text-align: center; }
