/* ============================================================================
   Mathera ERP — Design System (Tema Dark Futurista)
   Inspirado em painéis SaaS modernos: navy-blue + cyan glow, cantos arredondados
   ============================================================================ */

:root {
  /* Cores — Dark Navy com toque cyan futurista */
  --bg: #070b1a;
  --bg-2: #0c1228;
  --surface: #131a30;
  --surface-2: #1a2340;
  --surface-hover: #1f2a4a;

  --sidebar-bg: #050816;
  --sidebar-border: #1a2340;
  --sidebar-text: #94a3b8;
  --sidebar-text-active: #ffffff;
  --sidebar-active-bg: rgba(99, 102, 241, 0.15);
  --sidebar-active-border: #6366f1;

  --border: #1f2a4a;
  --border-strong: #2a3760;

  --text: #f1f5f9;
  --text-muted: #94a3b8;
  --text-subtle: #64748b;

  --primary: #6366f1;          /* indigo-500 */
  --primary-hover: #818cf8;    /* indigo-400 */
  --primary-soft: rgba(99, 102, 241, 0.12);
  --primary-glow: rgba(99, 102, 241, 0.35);
  --primary-text: #a5b4fc;     /* indigo-300 */

  --accent: #22d3ee;           /* cyan-400, toque futurista */
  --accent-soft: rgba(34, 211, 238, 0.12);
  --accent-glow: rgba(34, 211, 238, 0.4);

  --success: #10b981;
  --success-soft: rgba(16, 185, 129, 0.12);
  --danger: #f43f5e;
  --danger-soft: rgba(244, 63, 94, 0.12);
  --warning: #fbbf24;
  --warning-soft: rgba(251, 191, 36, 0.12);
  --info: #38bdf8;
  --info-soft: rgba(56, 189, 248, 0.12);

  /* Cantos */
  --radius-sm: 10px;
  --radius: 16px;
  --radius-lg: 22px;

  /* Sombras com glow azul sutil */
  --shadow-sm: 0 1px 3px rgba(2, 6, 23, 0.4);
  --shadow: 0 4px 12px rgba(2, 6, 23, 0.5), 0 0 0 1px rgba(99, 102, 241, 0.04);
  --shadow-lg: 0 20px 40px -10px rgba(2, 6, 23, 0.6), 0 0 0 1px rgba(99, 102, 241, 0.06);
  --glow: 0 0 24px var(--primary-glow);
  --glow-accent: 0 0 24px var(--accent-glow);

  /* Layout */
  --sidebar-width: 248px;
  --topbar-height: 68px;
}

/* ─── Reset & base ─────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  background-image:
    radial-gradient(circle at 0% 0%, rgba(99, 102, 241, 0.08) 0%, transparent 40%),
    radial-gradient(circle at 100% 0%, rgba(34, 211, 238, 0.05) 0%, transparent 40%),
    radial-gradient(circle at 50% 100%, rgba(99, 102, 241, 0.04) 0%, transparent 50%);
  background-attachment: fixed;
  color: var(--text);
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}
a { color: var(--primary-text); text-decoration: none; transition: color 0.15s; }
a:hover { color: var(--accent); }
img, svg { display: block; max-width: 100%; }

h1, h2, h3, h4 {
  color: var(--text);
  margin: 0;
  line-height: 1.2;
  font-weight: 700;
  letter-spacing: -0.01em;
}
h1 { font-size: 28px; }
h2 { font-size: 20px; }
h3 { font-size: 16px; }

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

/* Scrollbar futurista */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: var(--bg-2); }
::-webkit-scrollbar-thumb { background: var(--surface-2); border-radius: 10px; border: 2px solid var(--bg-2); }
::-webkit-scrollbar-thumb:hover { background: var(--border-strong); }

/* ============================================================================
   AUTH PAGES (login, cadastro, reset)
   ============================================================================ */
.auth-container {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background:
    radial-gradient(ellipse at top, rgba(99, 102, 241, 0.15), transparent 60%),
    radial-gradient(ellipse at bottom, rgba(34, 211, 238, 0.08), transparent 60%),
    var(--bg);
  position: relative;
  overflow: hidden;
}
.auth-container::before {
  content: "";
  position: absolute; inset: 0;
  background: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='60' height='60' viewBox='0 0 60 60'><path d='M0 0h60v60H0z' fill='none'/><path d='M0 30h60M30 0v60' stroke='rgba(99,102,241,0.04)' stroke-width='0.5'/></svg>");
  pointer-events: none;
}
.auth-card {
  width: 100%;
  max-width: 440px;
  background: linear-gradient(180deg, var(--surface), var(--surface-2));
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 44px 36px;
  box-shadow: var(--shadow-lg);
  position: relative;
  z-index: 1;
}
.auth-card::before {
  content: "";
  position: absolute;
  inset: -1px;
  border-radius: var(--radius-lg);
  padding: 1px;
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.4), transparent 50%, rgba(34, 211, 238, 0.2));
  -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
          mask-composite: exclude;
  pointer-events: none;
}
.auth-card h1 { font-size: 26px; margin-bottom: 6px; }
.auth-card .subtitle { color: var(--text-muted); margin: 0 0 28px; font-size: 14px; }
.auth-links {
  margin-top: 18px;
  text-align: center;
  font-size: 13px;
  display: flex;
  justify-content: center;
  gap: 14px;
}
.auth-links a { color: var(--text-muted); }
.auth-links a:hover { color: var(--accent); }

/* ============================================================================
   APP SHELL — sidebar + topbar + content
   ============================================================================ */
.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar-width) 1fr;
  min-height: 100vh;
}

/* ─── Sidebar ─────────────────────────────────────────────────────────── */
.sidebar {
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  border-right: 1px solid var(--sidebar-border);
}
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 22px 22px 18px;
  border-bottom: 1px solid var(--sidebar-border);
  font-weight: 800;
  font-size: 17px;
  color: #fff;
  letter-spacing: -0.01em;
}
.sidebar-brand-icon {
  width: 36px; height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%);
  box-shadow: 0 0 20px rgba(99, 102, 241, 0.5);
  display: grid;
  place-items: center;
  color: #fff;
  font-size: 16px;
  font-weight: 900;
  letter-spacing: -0.05em;
}
.sidebar-section { padding: 10px 14px; }
.sidebar-section-title {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-subtle);
  padding: 14px 10px 8px;
  font-weight: 700;
}
.sidebar-nav { display: flex; flex-direction: column; gap: 3px; }
.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: var(--sidebar-text);
  font-size: 13.5px;
  font-weight: 500;
  transition: all 0.18s;
  position: relative;
}
.sidebar-nav a:hover {
  background: rgba(255, 255, 255, 0.04);
  color: var(--sidebar-text-active);
}
.sidebar-nav a.active {
  background: var(--sidebar-active-bg);
  color: var(--sidebar-text-active);
  font-weight: 600;
}
.sidebar-nav a.active::before {
  content: "";
  position: absolute;
  left: -14px;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 18px;
  background: var(--accent);
  border-radius: 0 3px 3px 0;
  box-shadow: 0 0 8px var(--accent-glow);
}
.sidebar-nav a .icon { font-size: 16px; width: 18px; text-align: center; }

.sidebar-user {
  margin-top: auto;
  padding: 14px;
  border-top: 1px solid var(--sidebar-border);
  display: flex;
  align-items: center;
  gap: 10px;
}
.user-avatar {
  width: 36px; height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  display: grid;
  place-items: center;
  color: #fff;
  font-weight: 700;
  font-size: 13px;
  flex-shrink: 0;
  box-shadow: 0 0 12px rgba(99, 102, 241, 0.3);
}
.user-info { flex: 1; min-width: 0; }
.user-name {
  font-weight: 600;
  font-size: 13px;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.user-role {
  font-size: 11px;
  color: var(--text-subtle);
  text-transform: capitalize;
}
.sidebar-logout {
  background: transparent;
  border: 0;
  color: var(--text-subtle);
  cursor: pointer;
  padding: 8px;
  border-radius: 8px;
  font-size: 16px;
  transition: all 0.15s;
}
.sidebar-logout:hover { color: #fff; background: rgba(244, 63, 94, 0.15); }

/* ─── Topbar + content ────────────────────────────────────────────────── */
.app-main {
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: var(--bg);
}
.topbar {
  height: var(--topbar-height);
  background: rgba(13, 18, 40, 0.7);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 32px;
  position: sticky;
  top: 0;
  z-index: 10;
}
.topbar-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.01em;
}
.topbar-title small {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  margin-top: 2px;
  letter-spacing: 0;
}
.topbar-actions { display: flex; align-items: center; gap: 8px; }

.app-content { flex: 1; padding: 32px; }

/* Overlay do menu mobile — escondido por padrão (display:none EXCLUI do grid).
   Sem isso, em desktop o overlay ocupava a 2ª coluna do grid e empurrava
   o conteúdo principal pra fora da viewport. */
.sidebar-overlay { display: none; }

/* ============================================================================
   CARDS, KPIs, FORMS, TABLES
   ============================================================================ */
.card {
  background: linear-gradient(180deg, var(--surface) 0%, var(--surface-2) 100%);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow);
}
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
}
.card-header h2, .card-header h3 { margin: 0; }
.card-subtitle { color: var(--text-muted); font-size: 13px; margin-top: 4px; }

/* KPI grid */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 18px;
  margin-bottom: 28px;
}
.kpi {
  background: linear-gradient(180deg, var(--surface), var(--surface-2));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
  transition: all 0.2s;
}
.kpi::before {
  content: "";
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 1px;
  background: linear-gradient(90deg, transparent, var(--primary), transparent);
  opacity: 0.6;
}
.kpi:hover {
  border-color: rgba(99, 102, 241, 0.4);
  box-shadow: var(--shadow), var(--glow);
  transform: translateY(-2px);
}
.kpi-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  display: flex;
  align-items: center;
  gap: 8px;
}
.kpi-value {
  font-size: 30px;
  font-weight: 800;
  color: var(--text);
  margin-top: 10px;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
}
.kpi-delta { font-size: 12px; margin-top: 6px; font-weight: 600; }
.kpi-delta.up { color: var(--success); }
.kpi-delta.down { color: var(--danger); }
.kpi-icon {
  position: absolute;
  top: 18px;
  right: 18px;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: var(--primary-soft);
  color: var(--primary-text);
  display: grid;
  place-items: center;
  font-size: 18px;
  border: 1px solid rgba(99, 102, 241, 0.2);
}

/* Charts */
.charts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(360px, 1fr));
  gap: 18px;
  margin-bottom: 28px;
}
.chart-card {
  padding: 22px;
  background: linear-gradient(180deg, var(--surface), var(--surface-2));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.chart-card h2 { font-size: 15px; margin-bottom: 16px; color: var(--text); }
.chart-card .chart-subtitle { color: var(--text-muted); font-size: 12px; margin-bottom: 14px; }
.chart-box { height: 280px; position: relative; }

/* Forms */
.form-card {
  background: linear-gradient(180deg, var(--surface), var(--surface-2));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 26px;
  box-shadow: var(--shadow);
  margin-bottom: 22px;
}
.form-card h2 { font-size: 16px; margin-bottom: 18px; }

form { display: grid; gap: 14px; }
label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 4px;
}
input, select, textarea {
  width: 100%;
  background: var(--bg-2);
  color: var(--text);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 11px 14px;
  font-size: 14px;
  font-family: inherit;
  outline: none;
  transition: all 0.15s;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft), 0 0 12px rgba(99, 102, 241, 0.15);
}
input::placeholder, textarea::placeholder { color: var(--text-subtle); }
input[type="checkbox"] { width: auto; }
select option { background: var(--surface); color: var(--text); }

/* Tables */
.list-card {
  background: linear-gradient(180deg, var(--surface), var(--surface-2));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 22px;
  overflow: hidden;
}
.list-card h2 {
  padding: 20px 22px;
  margin: 0;
  font-size: 15px;
  border-bottom: 1px solid var(--border);
}
.list-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 22px;
  border-bottom: 1px solid var(--border);
  transition: background 0.12s;
}
.list-item:last-child { border-bottom: 0; }
.list-item:hover { background: var(--surface-hover); }
.list-item strong { font-weight: 600; color: var(--text); }
.list-item small { color: var(--text-muted); font-size: 12px; }

table.data-table { width: 100%; border-collapse: collapse; }
.data-table th, .data-table td {
  padding: 13px 22px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  font-size: 13.5px;
}
.data-table th {
  font-weight: 700;
  color: var(--text-muted);
  background: rgba(255, 255, 255, 0.02);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.data-table tr:hover td { background: var(--surface-hover); }

/* Buttons */
.btn {
  appearance: none;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 10px 16px;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all 0.18s;
  font-family: inherit;
}
.btn:hover {
  background: var(--surface-hover);
  border-color: var(--primary);
  color: #fff;
}
.btn.primary {
  background: linear-gradient(135deg, var(--primary), #4f46e5);
  color: #fff;
  border-color: transparent;
  box-shadow: 0 4px 14px rgba(99, 102, 241, 0.35);
}
.btn.primary:hover {
  background: linear-gradient(135deg, var(--primary-hover), var(--primary));
  box-shadow: 0 6px 20px rgba(99, 102, 241, 0.5), 0 0 20px var(--primary-glow);
  transform: translateY(-1px);
}
.btn.full { width: 100%; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--text-muted); }
.btn.ghost:hover { background: rgba(255,255,255,0.05); color: var(--text); border-color: transparent; }
.btn.danger {
  background: linear-gradient(135deg, var(--danger), #e11d48);
  color: #fff;
  border-color: transparent;
}
.btn.danger:hover { box-shadow: 0 4px 14px rgba(244, 63, 94, 0.5); }
.btn.sm { padding: 7px 12px; font-size: 12px; }

/* Badges */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.badge.primary { background: var(--primary-soft); color: var(--primary-text); border: 1px solid rgba(99,102,241,0.3); }
.badge.success { background: var(--success-soft); color: #6ee7b7; border: 1px solid rgba(16,185,129,0.3); }
.badge.warning { background: var(--warning-soft); color: #fcd34d; border: 1px solid rgba(251,191,36,0.3); }
.badge.danger  { background: var(--danger-soft);  color: #fda4af; border: 1px solid rgba(244,63,94,0.3); }
.badge.muted   { background: rgba(255,255,255,0.04); color: var(--text-muted); border: 1px solid var(--border); }

/* Page header (interno aos módulos) */
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 28px;
  flex-wrap: wrap;
  gap: 12px;
}
.page-title {
  font-size: 24px;
  font-weight: 700;
  margin: 0;
  letter-spacing: -0.02em;
}
.page-subtitle { color: var(--text-muted); font-size: 13.5px; margin: 6px 0 0; }

/* Hero panel (welcome card) */
.hero-panel {
  padding: 32px;
  background:
    radial-gradient(circle at top right, rgba(34, 211, 238, 0.1), transparent 50%),
    linear-gradient(135deg, var(--surface), var(--surface-2));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 28px;
  position: relative;
  overflow: hidden;
}
.hero-panel::before {
  content: "";
  position: absolute;
  top: 0; right: 0;
  width: 200px; height: 200px;
  background: radial-gradient(circle, var(--primary-glow), transparent 60%);
  filter: blur(40px);
  opacity: 0.5;
  pointer-events: none;
}
.hero-panel h1 {
  font-size: 28px;
  margin-bottom: 8px;
  background: linear-gradient(135deg, #fff, var(--primary-text));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
          background-clip: text;
  position: relative;
}
.hero-panel p { margin: 0; color: var(--text-muted); position: relative; }

/* Empty state */
.empty {
  text-align: center;
  padding: 50px 20px;
  color: var(--text-muted);
}
.empty-icon { font-size: 40px; margin-bottom: 14px; opacity: 0.6; }

/* Toast */
.toast {
  position: fixed;
  bottom: 24px; right: 24px;
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 14px 20px;
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  z-index: 1000;
  animation: toast-in 0.2s ease;
  max-width: 360px;
}
.toast.success { background: linear-gradient(135deg, var(--success), #059669); color: #fff; border-color: transparent; }
.toast.error   { background: linear-gradient(135deg, var(--danger), #e11d48); color: #fff; border-color: transparent; }
@keyframes toast-in {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ============================================================================
   RESPONSIVE
   ============================================================================ */
@media (max-width: 900px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    width: 280px;
    z-index: 100;
    transform: translateX(-100%);
    transition: transform 0.25s;
    box-shadow: var(--shadow-lg);
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-overlay {
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.6);
    backdrop-filter: blur(4px);
    z-index: 99;
  }
  .sidebar.open ~ .sidebar-overlay { display: block; }
  .topbar { padding: 0 18px; }
  .app-content { padding: 18px; }
  .topbar-menu-btn { display: inline-flex; }
}

.topbar-menu-btn {
  display: none;
  background: transparent;
  border: 0;
  font-size: 22px;
  cursor: pointer;
  color: var(--text);
  padding: 8px;
  border-radius: var(--radius-sm);
}
.topbar-menu-btn:hover { background: var(--surface-hover); }

/* ─── Compatibilidade com classes legadas ───────────────────────────────── */
.container { width: 100%; max-width: none; padding: 0; margin: 0; }
.module-layout { padding: 0; }
.dashboard-page { padding: 0; }
.stats-wrapper { margin-bottom: 28px; }
.status-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; }
.modules-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; }
.module-card {
  background: linear-gradient(180deg, var(--surface), var(--surface-2));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: all 0.2s;
}
.module-card:hover {
  border-color: var(--primary);
  transform: translateY(-2px);
  box-shadow: var(--shadow), var(--glow);
}
.module-card h3 { font-size: 17px; }
.module-card p { color: var(--text-muted); font-size: 13px; margin: 0 0 12px; }
.section-header h2 { font-size: 18px; margin-bottom: 6px; }
.section-header p { color: var(--text-muted); margin: 0 0 18px; font-size: 13.5px; }
