/* =========================================================
   MailMKT — Design System v2 (SaaS clean)
   Paleta clara, tipografia moderna, foco em hierarquia.
   ========================================================= */

:root {
  --bg:            #f7f8fb;
  --surface:       #ffffff;
  --surface-2:    #f1f2f7;
  --border:        #e5e7eb;
  --border-strong: #d1d5db;
  --text:          #111827;
  --text-muted:    #6b7280;
  --text-soft:     #9ca3af;

  --brand:         #7c3aed;
  --brand-strong:  #6d28d9;
  --brand-soft:    #ede9fe;
  --brand-softer:  #f5f3ff;

  --info:          #2563eb;
  --info-soft:     #dbeafe;
  --success:       #16a34a;
  --success-soft:  #dcfce7;
  --warning:       #f59e0b;
  --warning-soft:  #fef3c7;
  --danger:        #dc2626;
  --danger-soft:   #fee2e2;

  --radius-sm:  6px;
  --radius:     10px;
  --radius-lg:  14px;
  --radius-xl:  20px;

  --shadow-sm:  0 1px 2px rgba(17,24,39,.05);
  --shadow:     0 1px 3px rgba(17,24,39,.06), 0 1px 2px rgba(17,24,39,.04);
  --shadow-lg:  0 10px 25px -10px rgba(17,24,39,.12), 0 4px 10px -3px rgba(17,24,39,.06);

  --sidebar-w:  248px;
  --header-h:   64px;

  --font-sans:  'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --font-mono:  ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

/* ---------- Reset ---------- */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
a { color: var(--brand); text-decoration: none; }
a:hover { color: var(--brand-strong); text-decoration: underline; }
img, svg { max-width: 100%; }

h1, h2, h3, h4, h5 { color: var(--text); margin: 0 0 .6em; font-weight: 600; letter-spacing: -.01em; }
h1 { font-size: 22px; }
h2 { font-size: 18px; }
h3 { font-size: 16px; }
p  { margin: 0 0 .6em; }
small, .muted { color: var(--text-muted); font-size: 13px; }
hr { border: 0; border-top: 1px solid var(--border); margin: 20px 0; }

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

.sidebar {
  position: fixed; inset: 0 auto 0 0;
  width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  z-index: 50;
  overflow-y: auto;
}
.sidebar-brand {
  height: var(--header-h);
  display: flex; align-items: center; gap: 10px;
  padding: 0 22px;
  border-bottom: 1px solid var(--border);
  font-weight: 700; font-size: 17px; color: var(--text);
  letter-spacing: -.01em;
}
.sidebar-brand .logo-dot {
  width: 28px; height: 28px; border-radius: 8px;
  background: linear-gradient(135deg, var(--brand), #a78bfa);
  display: inline-flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 700; font-size: 14px;
  box-shadow: 0 6px 12px -6px rgba(124,58,237,.6);
}

.sidebar-section-title {
  padding: 18px 22px 6px;
  font-size: 11px; font-weight: 600; letter-spacing: .08em;
  color: var(--text-soft); text-transform: uppercase;
}

.sidebar-nav { padding: 6px 12px 24px; display: flex; flex-direction: column; gap: 2px; }
.sidebar-nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; border-radius: 8px;
  color: var(--text-muted); font-weight: 500; font-size: 14px;
  text-decoration: none; transition: background .15s, color .15s;
  white-space: nowrap;
}
.sidebar-nav a:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.sidebar-nav a.active {
  background: var(--brand-softer);
  color: var(--brand-strong);
  font-weight: 600;
}
.sidebar-nav a.disabled { opacity: .45; pointer-events: none; }
.sidebar-nav .nav-icon {
  width: 18px; height: 18px; display: inline-flex; align-items: center; justify-content: center;
  flex: 0 0 18px;
}

.sidebar-foot {
  margin-top: auto; padding: 14px 22px;
  border-top: 1px solid var(--border);
  font-size: 12px; color: var(--text-soft);
}

/* ---------- Conteúdo ---------- */
.main {
  flex: 1;
  margin-left: var(--sidebar-w);
  min-width: 0;
  display: flex; flex-direction: column;
}
.topbar {
  height: var(--header-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 28px;
  display: flex; align-items: center; justify-content: space-between;
  position: sticky; top: 0; z-index: 40;
}
.topbar-title { font-size: 15px; font-weight: 600; color: var(--text); margin: 0; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.topbar-user {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 12px; border: 1px solid var(--border);
  border-radius: 999px; background: var(--surface);
  font-size: 13px; color: var(--text);
}
.avatar {
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--brand-soft); color: var(--brand-strong);
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 12px;
}

.content { padding: 28px; max-width: 1400px; width: 100%; }
.page-header { margin-bottom: 22px; display:flex; align-items:center; justify-content:space-between; flex-wrap:wrap; gap: 14px; }
.page-header h1 { margin: 0; font-size: 22px; }
.page-header .subtitle { color: var(--text-muted); margin-top: 4px; font-size: 14px; }

/* ---------- Cards ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow-sm);
}
.card-hover { transition: box-shadow .15s, transform .15s; }
.card-hover:hover { box-shadow: var(--shadow-lg); transform: translateY(-1px); }
.card-title { font-size: 15px; font-weight: 600; margin: 0 0 12px; }
.card-actions { display:flex; gap: 8px; flex-wrap: wrap; }

/* KPI cards */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; margin-bottom: 24px; }
.kpi {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  display: flex; flex-direction: column; gap: 6px;
}
.kpi .label { font-size: 12px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: .04em; }
.kpi .value { font-size: 26px; font-weight: 700; color: var(--text); line-height: 1.2; }
.kpi .trend { font-size: 12px; color: var(--text-muted); }
.kpi.brand .value { color: var(--brand-strong); }
.kpi.success .value { color: var(--success); }
.kpi.warning .value { color: var(--warning); }
.kpi.danger  .value { color: var(--danger); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 16px;
  font-size: 14px; font-weight: 600; line-height: 1;
  border-radius: 8px; border: 1px solid transparent;
  cursor: pointer; text-decoration: none;
  background: var(--surface-2); color: var(--text);
  transition: background .15s, color .15s, border-color .15s, transform .05s;
  white-space: nowrap;
}
.btn:hover { text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn:disabled, .btn.is-loading { opacity: .65; pointer-events: none; }
.btn.is-loading::before {
  content: ''; width: 14px; height: 14px; border-radius: 50%;
  border: 2px solid currentColor; border-right-color: transparent;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.btn-primary { background: var(--brand); color: #fff; border-color: var(--brand); }
.btn-primary:hover { background: var(--brand-strong); border-color: var(--brand-strong); color: #fff; }

.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border-strong); }
.btn-secondary:hover { background: var(--surface-2); }

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

.btn-danger { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-danger:hover { background: #b91c1c; border-color: #b91c1c; color: #fff; }

.btn-success { background: var(--success); color: #fff; border-color: var(--success); }
.btn-success:hover { background: #15803d; border-color: #15803d; color: #fff; }

.btn-warning { background: var(--warning); color: #fff; border-color: var(--warning); }
.btn-warning:hover { background: #d97706; border-color: #d97706; color: #fff; }

.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-lg { padding: 12px 22px; font-size: 15px; }
.btn-block { width: 100%; }
.btn-link { background: transparent; color: var(--brand); border: none; padding: 0; height: auto; font-weight: 600; }
.btn-link:hover { text-decoration: underline; }

.btn-group { display: inline-flex; gap: 6px; flex-wrap: wrap; }

/* ---------- Forms ---------- */
.field { margin-bottom: 14px; }
.field label, .field .label {
  display: block; font-weight: 600; font-size: 13px;
  color: var(--text); margin-bottom: 6px;
}
.field .hint { color: var(--text-muted); font-size: 12px; margin-top: 4px; }

.input, .select, .textarea {
  width: 100%;
  padding: 10px 12px;
  font: inherit; font-size: 14px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  transition: border-color .15s, box-shadow .15s;
  appearance: none;
}
.input:focus, .select:focus, .textarea:focus {
  outline: none; border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(124,58,237,.15);
}
.input[disabled], .select[disabled], .textarea[disabled] {
  background: var(--surface-2); color: var(--text-muted); cursor: not-allowed;
}
.textarea { resize: vertical; min-height: 96px; line-height: 1.5; }
.select {
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'><path fill='%236b7280' d='M6 8L0 0h12z'/></svg>");
  background-repeat: no-repeat; background-position: right 12px center; padding-right: 32px;
}

.input-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; }

input[type="checkbox"], input[type="radio"] {
  width: 16px; height: 16px; accent-color: var(--brand);
  margin: 0 6px 0 0; vertical-align: middle;
}

/* ---------- Tables ---------- */
.table-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 14px; }
.table th, .table td { padding: 12px 16px; text-align: left; }
.table thead th {
  background: var(--surface-2);
  color: var(--text-muted);
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .04em;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.table tbody td { border-bottom: 1px solid var(--border); color: var(--text); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background: var(--surface-2); }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table .actions { text-align: right; white-space: nowrap; }
.table .empty {
  text-align: center; padding: 36px 20px; color: var(--text-muted); font-style: italic;
}

/* ---------- Badges ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 9px; font-size: 12px; font-weight: 600;
  border-radius: 999px; line-height: 1.4;
  background: var(--surface-2); color: var(--text);
}
.badge-success { background: var(--success-soft); color: #166534; }
.badge-warning { background: var(--warning-soft); color: #92400e; }
.badge-danger  { background: var(--danger-soft);  color: #991b1b; }
.badge-info    { background: var(--info-soft);    color: #1e40af; }
.badge-brand   { background: var(--brand-soft);   color: var(--brand-strong); }
.badge-muted   { background: var(--surface-2);    color: var(--text-muted); }

/* ---------- Alerts ---------- */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
  margin-bottom: 16px;
  font-size: 14px;
  display: flex; align-items: flex-start; gap: 10px;
}
.alert .alert-icon { flex: 0 0 18px; line-height: 1.5; }
.alert-success { background: var(--success-soft); border-color: #bbf7d0; color: #166534; }
.alert-warning { background: var(--warning-soft); border-color: #fde68a; color: #92400e; }
.alert-danger  { background: var(--danger-soft);  border-color: #fecaca; color: #991b1b; }
.alert-info    { background: var(--info-soft);    border-color: #bfdbfe; color: #1e40af; }

/* ---------- Modais ---------- */
.modal {
  position: fixed; inset: 0; background: rgba(17,24,39,.55);
  display: none; align-items: center; justify-content: center;
  z-index: 100; padding: 20px;
  backdrop-filter: blur(2px);
}
.modal.open { display: flex; }
.modal-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  max-width: 520px; width: 100%;
  box-shadow: var(--shadow-lg);
  display: flex; flex-direction: column;
  max-height: 90vh; overflow: hidden;
  animation: modalIn .18s ease-out;
}
.modal-card.modal-lg  { max-width: 720px; }
.modal-card.modal-xl  { max-width: 960px; }
@keyframes modalIn { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }
.modal-head {
  padding: 18px 22px; border-bottom: 1px solid var(--border);
  display: flex; justify-content: space-between; align-items: center;
}
.modal-head h2, .modal-head h3 { margin: 0; font-size: 16px; }
.modal-close {
  background: none; border: none; cursor: pointer;
  font-size: 22px; line-height: 1; color: var(--text-muted);
  padding: 4px 8px;
}
.modal-close:hover { color: var(--text); }
.modal-body { padding: 20px 22px; overflow-y: auto; }
.modal-foot { padding: 14px 22px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; background: var(--surface-2); }

/* ---------- Pagination ---------- */
.pagination { display: inline-flex; gap: 4px; flex-wrap: wrap; }
.pagination a, .pagination span {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 32px; height: 32px; padding: 0 10px;
  border-radius: 8px; border: 1px solid var(--border);
  font-size: 13px; font-weight: 600; color: var(--text);
  background: var(--surface); text-decoration: none;
}
.pagination a:hover { background: var(--surface-2); text-decoration: none; }
.pagination .active { background: var(--brand); color: #fff; border-color: var(--brand); }

/* ---------- Empty state ---------- */
.empty-state {
  background: var(--surface);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-lg);
  padding: 40px 20px;
  text-align: center;
  color: var(--text-muted);
}
.empty-state h3 { color: var(--text); margin-bottom: 6px; }

/* ---------- Login screen ---------- */
.auth-wrap {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  background:
    radial-gradient(circle at 0% 0%, rgba(124,58,237,.08), transparent 40%),
    radial-gradient(circle at 100% 100%, rgba(37,99,235,.08), transparent 40%),
    var(--bg);
  padding: 20px;
}
.auth-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%; max-width: 410px;
  padding: 36px 32px;
}
.auth-brand {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 24px; justify-content: center;
}
.auth-brand .logo-dot { width: 38px; height: 38px; border-radius: 10px;
  background: linear-gradient(135deg, var(--brand), #a78bfa);
  display: inline-flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 700; font-size: 17px;
}
.auth-brand .name { font-size: 18px; font-weight: 700; color: var(--text); letter-spacing: -.01em; }
.auth-title { font-size: 20px; font-weight: 700; margin: 0 0 6px; text-align: center; }
.auth-sub   { font-size: 14px; color: var(--text-muted); margin: 0 0 22px; text-align: center; }

/* ---------- Utilities ---------- */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 8px; } .gap-3 { gap: 12px; } .gap-4 { gap: 16px; }
.mt-1{margin-top:4px}.mt-2{margin-top:8px}.mt-3{margin-top:12px}.mt-4{margin-top:16px}
.mb-1{margin-bottom:4px}.mb-2{margin-bottom:8px}.mb-3{margin-bottom:12px}.mb-4{margin-bottom:16px}.mb-6{margin-bottom:24px}
.w-full{width:100%}
.text-center{text-align:center}
.text-right{text-align:right}
.text-muted{color:var(--text-muted);}
.text-danger{color:var(--danger);}
.text-success{color:var(--success);}
.text-brand{color:var(--brand-strong);}
.font-mono{font-family:var(--font-mono);}
.code {
  font-family: var(--font-mono); background: var(--surface-2);
  padding: 2px 6px; border-radius: 4px; font-size: 13px; color: var(--text);
  word-break: break-all;
}
.grid { display: grid; gap: 16px; }
.grid-cards { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.grid-cards-sm { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }

.toolbar {
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 12px; margin-bottom: 16px;
}
.toolbar .filters { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.toolbar .filters .input,
.toolbar .filters .select { padding: 8px 12px; font-size: 13px; min-width: 130px; }

.divider { height: 1px; background: var(--border); margin: 16px 0; border: 0; }

/* ---------- Mobile ---------- */
.menu-toggle {
  display: none;
  background: transparent; border: none; cursor: pointer;
  font-size: 22px; color: var(--text); padding: 6px 8px;
}
@media (max-width: 920px) {
  .sidebar { transform: translateX(-100%); transition: transform .2s; }
  body.sidebar-open .sidebar { transform: translateX(0); }
  .main { margin-left: 0; }
  .menu-toggle { display: inline-flex; }
  .content { padding: 20px 18px; }
  .table th, .table td { padding: 10px 12px; }
}

/* ---------- Print ---------- */
@media print {
  .sidebar, .topbar, .btn, .pagination { display: none !important; }
  .main { margin-left: 0; }
  .content { padding: 0; }
}
