/* ==========================================================================
   styles.css — Design system base do CRM Personnalité
   Identidade: verde escuro + dourado/champagne + branco + cinza neutro.
   Estilo: premium, elegante, minimalista, executivo. Nunca "planilha".
   ========================================================================== */

:root {
  /* Paleta de marca */
  --color-green-900: #0a2e24;
  --color-green-800: #0b3b2e;
  --color-green-700: #114937;
  --color-green-600: #16593f;
  --color-green-100: #e5efe9;
  --color-green-50: #f2f7f4;

  --color-gold-600: #a9822f;
  --color-gold-500: #c6a15b;
  --color-gold-400: #d8b876;
  --color-gold-100: #f6eeda;
  --color-gold-50: #fbf7ef;

  --color-white: #ffffff;
  --color-gray-900: #1c2320;
  --color-gray-700: #3f4744;
  --color-gray-500: #6b7280;
  --color-gray-300: #d3d8d5;
  --color-gray-200: #e6e9e7;
  --color-gray-100: #f4f6f5;
  --color-gray-50: #fafbfa;

  --color-danger: #b3392c;
  --color-danger-bg: #fbeae7;
  --color-warning: #b3800f;
  --color-warning-bg: #fbf1dd;
  --color-success: #1e7a4f;
  --color-success-bg: #e6f4ec;
  --color-info: #2a5f8f;
  --color-info-bg: #e8f1fa;

  /* Superfícies */
  --surface-bg: var(--color-gray-50);
  --surface-card: var(--color-white);
  --surface-sidebar: linear-gradient(180deg, var(--color-green-900) 0%, var(--color-green-800) 100%);
  --surface-border: var(--color-gray-200);

  /* Tipografia */
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --font-serif-display: 'Fraunces', Georgia, 'Times New Roman', serif;

  /* Espaçamento / raio */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-pill: 999px;
  --shadow-sm: 0 1px 2px rgba(11, 59, 46, 0.06), 0 1px 1px rgba(11, 59, 46, 0.04);
  --shadow-md: 0 4px 14px rgba(11, 59, 46, 0.10);
  --shadow-lg: 0 12px 32px rgba(11, 59, 46, 0.16);

  --sidebar-width: 248px;
  --topbar-height: 64px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --surface-bg: #10231c;
    --surface-card: #17332a;
    --surface-border: #24483a;
    --color-gray-900: #eef3f0;
    --color-gray-700: #c7d3cd;
    --color-gray-500: #9fb0a8;
    --color-gray-100: #1c3a2f;
  }
}
:root[data-theme="dark"] {
  --surface-bg: #10231c;
  --surface-card: #17332a;
  --surface-border: #24483a;
  --color-gray-900: #eef3f0;
  --color-gray-700: #c7d3cd;
  --color-gray-500: #9fb0a8;
  --color-gray-100: #1c3a2f;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font-sans);
  background: var(--surface-bg);
  color: var(--color-gray-900);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4 { font-family: var(--font-serif-display); font-weight: 600; margin: 0 0 4px; color: var(--color-green-900); }
:root[data-theme="dark"] h1, :root[data-theme="dark"] h2, :root[data-theme="dark"] h3, :root[data-theme="dark"] h4 { color: var(--color-gold-100); }
p { margin: 0 0 8px; }
a { color: var(--color-green-700); }
button { font-family: inherit; }
::selection { background: var(--color-gold-400); color: var(--color-green-900); }

/* ---------- Layout raiz ---------- */
#app-root { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-width);
  flex-shrink: 0;
  background: var(--surface-sidebar);
  color: var(--color-gold-100);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}
.sidebar__brand {
  display: flex; align-items: center; gap: 10px;
  padding: 20px 20px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}
.sidebar__brand-mark {
  width: 36px; height: 36px; border-radius: 10px;
  background: linear-gradient(135deg, var(--color-gold-400), var(--color-gold-600));
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-serif-display); font-weight: 700; color: var(--color-green-900);
  flex-shrink: 0;
}
.sidebar__brand-name { font-family: var(--font-serif-display); font-size: 15px; line-height: 1.25; color: var(--color-white); }
.sidebar__brand-name small { display: block; font-family: var(--font-sans); font-size: 10px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--color-gold-400); margin-top: 2px; }

.nav-group { padding: 14px 12px; }
.nav-group__title { font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.09em; color: rgba(246,238,218,0.45); padding: 8px 10px 6px; }
.nav-link {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; border-radius: var(--radius-md);
  color: rgba(246,238,218,0.82); text-decoration: none; font-size: 13.5px;
  cursor: pointer; margin-bottom: 2px; transition: background .15s, color .15s;
  border: none; background: transparent; width: 100%; text-align: left;
}
.nav-link:hover { background: rgba(255,255,255,0.07); color: var(--color-white); }
.nav-link.active { background: rgba(198,161,91,0.18); color: var(--color-gold-400); font-weight: 600; }
.nav-link__icon { width: 18px; text-align: center; flex-shrink: 0; }
.nav-link__badge {
  margin-left: auto; background: var(--color-danger); color: white; font-size: 10.5px;
  padding: 1px 6px; border-radius: var(--radius-pill); font-weight: 700;
}

.sidebar__footer { margin-top: auto; padding: 14px 16px; border-top: 1px solid rgba(255,255,255,0.08); }
.sidebar__user { display: flex; align-items: center; gap: 10px; }
.avatar {
  width: 32px; height: 32px; border-radius: 50%; background: var(--color-gold-500);
  color: var(--color-green-900); display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 12px; flex-shrink: 0;
}
.sidebar__user-info { line-height: 1.25; min-width: 0; }
.sidebar__user-name { color: var(--color-white); font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar__user-role { font-size: 11px; color: var(--color-gold-400); }
.sidebar__logout { background: none; border: none; color: rgba(246,238,218,0.6); cursor: pointer; font-size: 12px; margin-top: 10px; padding: 0; }
.sidebar__logout:hover { color: var(--color-white); }

.main-area { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  height: var(--topbar-height); flex-shrink: 0; display: flex; align-items: center; gap: 14px;
  padding: 0 24px; background: var(--surface-card); border-bottom: 1px solid var(--surface-border);
  position: sticky; top: 0; z-index: 20;
}
.topbar__search { flex: 1; max-width: 420px; position: relative; }
.topbar__search input {
  width: 100%; padding: 8px 12px 8px 34px; border-radius: var(--radius-pill);
  border: 1px solid var(--surface-border); background: var(--color-gray-100); font-size: 13px;
}
.topbar__search input:focus { outline: none; border-color: var(--color-gold-500); background: var(--surface-card); }
.topbar__search-icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--color-gray-500); font-size: 13px; }
.topbar__spacer { flex: 1; }
.topbar__actions { display: flex; align-items: center; gap: 10px; }

.view-container { padding: 24px; flex: 1; }
.view-header { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.view-header__eyebrow { font-size: 11px; text-transform: uppercase; letter-spacing: 0.09em; color: var(--color-gold-600); font-weight: 700; margin-bottom: 2px; }
.view-header__actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- Botões ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 14px; border-radius: var(--radius-md); border: 1px solid transparent;
  font-size: 13px; font-weight: 600; cursor: pointer; transition: all .15s; white-space: nowrap;
  line-height: 1.2;
}
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn--primary { background: var(--color-green-800); color: var(--color-white); }
.btn--primary:hover:not(:disabled) { background: var(--color-green-700); }
.btn--gold { background: linear-gradient(135deg, var(--color-gold-400), var(--color-gold-600)); color: var(--color-green-900); }
.btn--gold:hover:not(:disabled) { filter: brightness(1.05); }
.btn--secondary { background: var(--surface-card); color: var(--color-green-800); border-color: var(--surface-border); }
.btn--secondary:hover:not(:disabled) { border-color: var(--color-gold-500); }
.btn--ghost { background: transparent; color: var(--color-gray-700); }
.btn--ghost:hover:not(:disabled) { background: var(--color-gray-100); }
.btn--danger { background: var(--color-danger-bg); color: var(--color-danger); }
.btn--danger:hover:not(:disabled) { background: #f6d9d3; }
.btn--sm { padding: 5px 10px; font-size: 12px; border-radius: var(--radius-sm); }
.btn--icon { padding: 7px; width: 32px; height: 32px; }
.btn--block { width: 100%; }

/* ---------- Cards ---------- */
.card { background: var(--surface-card); border: 1px solid var(--surface-border); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); }
.card__header { padding: 16px 18px; border-bottom: 1px solid var(--surface-border); display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.card__title { font-family: var(--font-serif-display); font-size: 15px; color: var(--color-green-900); }
.card__body { padding: 18px; }

.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; margin-bottom: 20px; }
.kpi-card {
  background: var(--surface-card); border: 1px solid var(--surface-border); border-radius: var(--radius-lg);
  padding: 16px 18px; box-shadow: var(--shadow-sm); position: relative; overflow: hidden;
}
.kpi-card::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--color-gold-500); }
.kpi-card__label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--color-gray-500); font-weight: 700; margin-bottom: 6px; }
.kpi-card__value { font-family: var(--font-serif-display); font-size: 24px; color: var(--color-green-900); }
:root[data-theme="dark"] .kpi-card__value { color: var(--color-gold-100); }
.kpi-card__sub { font-size: 12px; color: var(--color-gray-500); margin-top: 4px; }
.kpi-card__sub.positive { color: var(--color-success); }
.kpi-card__sub.negative { color: var(--color-danger); }

/* ---------- Tabelas ---------- */
.table-wrap { overflow-x: auto; border-radius: var(--radius-lg); border: 1px solid var(--surface-border); background: var(--surface-card); }
table.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.data-table thead th {
  text-align: left; padding: 11px 14px; background: var(--color-green-50); color: var(--color-green-800);
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em; font-weight: 700; border-bottom: 1px solid var(--surface-border);
  white-space: nowrap; position: sticky; top: 0;
}
:root[data-theme="dark"] .data-table thead th { background: #1c3a2f; color: var(--color-gold-100); }
.data-table tbody td { padding: 10px 14px; border-bottom: 1px solid var(--surface-border); vertical-align: middle; }
.data-table tbody tr:hover { background: var(--color-gray-50); }
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table--clickable tbody tr { cursor: pointer; }
.text-muted { color: var(--color-gray-500); }
.text-right { text-align: right; }
.text-center { text-align: center; }

/* ---------- Badges / pills ---------- */
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 9px; border-radius: var(--radius-pill); font-size: 11px; font-weight: 700; }
.badge--green { background: var(--color-success-bg); color: var(--color-success); }
.badge--gold { background: var(--color-gold-100); color: var(--color-gold-600); }
.badge--gray { background: var(--color-gray-100); color: var(--color-gray-700); }
.badge--red { background: var(--color-danger-bg); color: var(--color-danger); }
.badge--blue { background: var(--color-info-bg); color: var(--color-info); }
.dot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; }
.dot--red { background: var(--color-danger); }
.dot--yellow { background: var(--color-warning); }
.dot--green { background: var(--color-success); }

/* ---------- Formulários ---------- */
.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; }
.form-grid--1 { grid-template-columns: 1fr; }
.form-grid--3 { grid-template-columns: repeat(3, 1fr); }
.field { display: flex; flex-direction: column; gap: 5px; }
.field--span2 { grid-column: span 2; }
.field label { font-size: 12px; font-weight: 700; color: var(--color-gray-700); }
.field .hint { font-size: 11px; color: var(--color-gray-500); }
.field input, .field select, .field textarea {
  padding: 8px 11px; border: 1px solid var(--surface-border); border-radius: var(--radius-md);
  font-size: 13px; font-family: inherit; background: var(--surface-card); color: var(--color-gray-900);
}
.field input:focus, .field select:focus, .field textarea:focus { outline: none; border-color: var(--color-gold-500); box-shadow: 0 0 0 3px rgba(198,161,91,0.18); }
.field textarea { resize: vertical; min-height: 70px; }
.field-error { border-color: var(--color-danger) !important; }
.field-error-msg { font-size: 11px; color: var(--color-danger); }
.checkbox-row { display: flex; align-items: center; gap: 8px; }

/* ---------- Modal ---------- */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(11,20,17,0.55); display: flex; align-items: flex-start;
  justify-content: center; padding: 40px 16px; z-index: 100; overflow-y: auto; backdrop-filter: blur(2px);
}
.modal {
  background: var(--surface-card); border-radius: var(--radius-lg); width: 100%; max-width: 640px;
  box-shadow: var(--shadow-lg); animation: modal-in .18s ease-out;
}
.modal--wide { max-width: 880px; }
@keyframes modal-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
.modal__header { display: flex; align-items: center; justify-content: space-between; padding: 18px 22px; border-bottom: 1px solid var(--surface-border); }
.modal__title { font-family: var(--font-serif-display); font-size: 17px; color: var(--color-green-900); }
.modal__close { background: none; border: none; font-size: 18px; cursor: pointer; color: var(--color-gray-500); }
.modal__body { padding: 20px 22px; max-height: 70vh; overflow-y: auto; }
.modal__footer { padding: 16px 22px; border-top: 1px solid var(--surface-border); display: flex; justify-content: flex-end; gap: 8px; }

/* ---------- Tabs ---------- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--surface-border); margin-bottom: 16px; }
.tab-btn { background: none; border: none; padding: 10px 14px; font-size: 13px; font-weight: 600; color: var(--color-gray-500); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tab-btn.active { color: var(--color-green-800); border-color: var(--color-gold-500); }

/* ---------- Toast ---------- */
.toast-host { position: fixed; bottom: 20px; right: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 200; }
.toast { background: var(--color-green-900); color: var(--color-white); padding: 11px 16px; border-radius: var(--radius-md); font-size: 13px; box-shadow: var(--shadow-lg); opacity: 0; transform: translateY(8px); transition: all .25s; max-width: 320px; }
.toast--visible { opacity: 1; transform: translateY(0); }
.toast--success { background: var(--color-success); }
.toast--error { background: var(--color-danger); }
.toast--info { background: var(--color-green-900); }

/* ---------- Empty state ---------- */
.empty-state { text-align: center; padding: 60px 20px; color: var(--color-gray-500); }
.empty-state h2 { color: var(--color-gray-700); font-size: 16px; }

/* ---------- Utilitários ---------- */
.flex { display: flex; }
.flex-col { display: flex; flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-4 { gap: 4px; } .gap-6 { gap: 6px; } .gap-8 { gap: 8px; } .gap-12 { gap: 12px; } .gap-16 { gap: 16px; }
.mt-8 { margin-top: 8px; } .mt-12 { margin-top: 12px; } .mt-16 { margin-top: 16px; } .mt-24 { margin-top: 24px; }
.mb-8 { margin-bottom: 8px; } .mb-12 { margin-bottom: 12px; } .mb-16 { margin-bottom: 16px; }
.w-full { width: 100%; }
.pill-tab-group { display: flex; gap: 6px; background: var(--color-gray-100); padding: 4px; border-radius: var(--radius-pill); }
.pill-tab { border: none; background: transparent; padding: 6px 13px; border-radius: var(--radius-pill); font-size: 12.5px; font-weight: 600; color: var(--color-gray-700); cursor: pointer; }
.pill-tab.active { background: var(--surface-card); color: var(--color-green-800); box-shadow: var(--shadow-sm); }

.skeleton { background: linear-gradient(90deg, var(--color-gray-100) 25%, var(--color-gray-200) 37%, var(--color-gray-100) 63%); background-size: 400% 100%; animation: skeleton-loading 1.4s ease infinite; border-radius: var(--radius-sm); }
@keyframes skeleton-loading { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }

.timeline { position: relative; padding-left: 22px; }
.timeline::before { content: ''; position: absolute; left: 6px; top: 4px; bottom: 4px; width: 2px; background: var(--surface-border); }
.timeline-item { position: relative; padding-bottom: 18px; }
.timeline-item::before { content: ''; position: absolute; left: -22px; top: 3px; width: 10px; height: 10px; border-radius: 50%; background: var(--color-gold-500); border: 2px solid var(--surface-card); box-shadow: 0 0 0 2px var(--color-gold-500); }
.timeline-item__meta { font-size: 11px; color: var(--color-gray-500); margin-bottom: 2px; }
.timeline-item__title { font-size: 13px; font-weight: 600; color: var(--color-gray-900); }
.timeline-item__desc { font-size: 12.5px; color: var(--color-gray-700); }
