/* ============================================================
   WCON Hub — Design System
   Tema escuro, identidade WCON, Poppins + DM Mono
   ============================================================ */

/* ── Tokens ── */
:root {
  --font:    'Poppins', sans-serif;
  --mono:    'DM Mono', monospace;

  /* Cores base */
  --bg:      #0A0A0A;
  --ink1:    #111111;
  --ink2:    #161616;
  --ink3:    #1E1E1E;
  --ink4:    #242424;
  --line:    #2A2A2A;
  --line2:   #333333;

  /* Texto */
  --text:    #F0F0F0;
  --text2:   #A0A0A0;
  --text3:   #606060;

  /* Brand */
  --brand:        #C0392B;
  --brand-hover:  #E74C3C;
  --brand-dim:    rgba(192,57,43,0.08);
  --brand-border: rgba(192,57,43,0.25);

  /* Status */
  --green:      #27AE60;
  --green-dim:  rgba(39,174,96,0.08);
  --green-glow: rgba(39,174,96,0.25);
  --blue:       #2980B9;
  --blue-dim:   rgba(41,128,185,0.08);
  --blue-glow:  rgba(41,128,185,0.25);
  --amber:      #F39C12;
  --amber-dim:  rgba(243,156,18,0.08);
  --red:        #C0392B;
  --red-dim:    rgba(192,57,43,0.08);
  --red-glow:   rgba(192,57,43,0.25);
  --purple:     #8E44AD;
  --gold:       #D4A017;
  --gold-dim:   rgba(212,160,23,0.08);
  --gold-glow:  rgba(212,160,23,0.25);

  /* Layout */
  --sidebar-w:   240px;
  --header-h:    56px;
  --radius:      10px;
  --radius2:     14px;
  --transition:  0.18s ease;

  /* Sombras */
  --shadow-sm:   0 2px 8px rgba(0,0,0,0.3);
  --shadow-md:   0 4px 20px rgba(0,0,0,0.4);
  --shadow-lg:   0 8px 40px rgba(0,0,0,0.5);
}

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
  overflow-x: hidden;
  -webkit-tap-highlight-color: transparent;
}

/* ── Logo WCON ── */
.logo-w   { color: var(--text); font-weight: 800; letter-spacing: -1px; }
.logo-con { color: var(--brand); font-weight: 800; letter-spacing: -1px; }
.logo-hub {
  font-size: 11px;
  font-weight: 700;
  color: var(--brand);
  letter-spacing: 3px;
  text-transform: uppercase;
  display: block;
  margin-top: 2px;
  font-family: var(--mono);
}
.logo-hub-sm {
  font-size: 9px;
  font-weight: 700;
  color: var(--brand);
  letter-spacing: 2px;
  margin-left: 6px;
  font-family: var(--mono);
  vertical-align: middle;
  opacity: 0.8;
}

/* ── Utilitários ── */
.hidden { display: none !important; }

/* ════════════════════════════════════════════════════
   LOGIN
════════════════════════════════════════════════════ */
#login {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
  background: var(--bg);
}

.login-bg {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.login-orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.12;
}

.login-orb-1 {
  width: 500px; height: 500px;
  background: var(--brand);
  top: -100px; left: -100px;
}

.login-orb-2 {
  width: 400px; height: 400px;
  background: #1a0a0a;
  bottom: -80px; right: -80px;
}

.login-card {
  position: relative;
  z-index: 2;
  width: 100%;
  max-width: 380px;
  background: var(--ink2);
  border: 1px solid var(--line2);
  border-radius: 20px;
  padding: 40px 36px;
  box-shadow: var(--shadow-lg);
  margin: 20px;
}

.login-logo {
  font-size: 32px;
  font-weight: 800;
  letter-spacing: -1px;
  margin-bottom: 2px;
  text-align: center;
}

.login-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text2);
  text-align: center;
  letter-spacing: 0.5px;
  margin-bottom: 4px;
}

.login-sub {
  font-size: 12px;
  color: var(--text3);
  text-align: center;
  font-family: var(--mono);
  margin-bottom: 28px;
}

/* ════════════════════════════════════════════════════
   APP LAYOUT
════════════════════════════════════════════════════ */
#app {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

#app.show { display: flex; }

/* ── Header ── */
#header {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 200;
  height: var(--header-h);
  background: var(--ink1);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  padding: 0 16px;
  gap: 12px;
  box-shadow: var(--shadow-sm);
}

.header-brand {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.5px;
  flex: 1;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

.header-user {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 8px;
  border-radius: 8px;
  cursor: pointer;
  transition: background var(--transition);
}

.header-user:hover { background: var(--ink3); }

.header-avatar {
  width: 32px; height: 32px;
  border-radius: 8px;
  background: var(--brand-dim);
  border: 1px solid var(--brand-border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  color: var(--brand);
  overflow: hidden;
  flex-shrink: 0;
}

.header-user-info { line-height: 1.2; }
.header-user-info > div:first-child { font-size: 12px; font-weight: 600; }
.header-user-role { font-size: 10px; color: var(--text3); font-family: var(--mono); }

/* ── Sidebar ── */
#sidebar {
  position: fixed;
  top: 0; left: 0;
  width: var(--sidebar-w);
  height: 100vh;
  z-index: 150;
  background: var(--ink1);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  transition: left var(--transition);
  overflow-y: auto;
  overflow-x: hidden;
}

.sb-logo {
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -0.5px;
  padding: 16px 20px;
  height: var(--header-h);
  display: flex;
  align-items: center;
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
}

.sb-nav {
  flex: 1;
  padding: 12px 10px;
  overflow-y: auto;
}

.sb-section-label {
  font-size: 9px;
  font-weight: 700;
  color: var(--text3);
  letter-spacing: 2px;
  text-transform: uppercase;
  padding: 14px 10px 6px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 8px;
  cursor: pointer;
  transition: all var(--transition);
  font-size: 13px;
  font-weight: 500;
  color: var(--text2);
  position: relative;
  margin-bottom: 1px;
}

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

.nav-item.active {
  background: var(--brand-dim);
  color: var(--brand);
  border: 1px solid var(--brand-border);
}

.nav-ic {
  font-size: 14px;
  width: 20px;
  text-align: center;
  flex-shrink: 0;
}

.nav-badge {
  margin-left: auto;
  background: var(--brand);
  color: #fff;
  font-size: 9px;
  font-weight: 700;
  min-width: 18px;
  height: 18px;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
}

/* Role badge na sidebar */
.nav-role-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 0 10px 8px;
  padding: 6px 12px;
  background: var(--brand-dim);
  border: 1px solid var(--brand-border);
  border-radius: 8px;
  font-size: 10px;
  font-weight: 700;
  color: var(--brand);
  letter-spacing: 0.5px;
  font-family: var(--mono);
}

.sb-footer {
  padding: 12px;
  border-top: 1px solid var(--line);
  flex-shrink: 0;
}

.btn-logout {
  width: 100%;
  padding: 9px 14px;
  background: transparent;
  border: 1px solid var(--line2);
  border-radius: 8px;
  color: var(--text3);
  font-family: var(--font);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
  text-align: left;
}

.btn-logout:hover { border-color: var(--brand); color: var(--brand); background: var(--brand-dim); }

/* ── Main content ── */
#main-content {
  margin-left: var(--sidebar-w);
  margin-top: var(--header-h);
  padding: 24px;
  min-height: calc(100vh - var(--header-h));
  flex: 1;
}

.module { display: none; }
.module.active { display: block; }

/* ── Mobile overlay ── */
#mobile-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  z-index: 140;
  backdrop-filter: blur(2px);
}

#mobile-overlay.show { display: block; }

/* ════════════════════════════════════════════════════
   COMPONENTES
════════════════════════════════════════════════════ */

/* ── Botões ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 16px;
  border-radius: 8px;
  font-family: var(--font);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all var(--transition);
  text-decoration: none;
  white-space: nowrap;
}

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

.btn-ghost {
  background: transparent;
  border: 1px solid var(--line2);
  color: var(--text2);
}
.btn-ghost:hover { border-color: var(--text3); color: var(--text); background: var(--ink3); }

.btn-success { background: var(--green); color: #fff; }
.btn-success:hover { opacity: 0.9; }

.btn-danger { background: var(--red); color: #fff; }
.btn-danger:hover { opacity: 0.9; }

.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-lg { padding: 12px 24px; font-size: 15px; }

.btn-login {
  width: 100%;
  padding: 13px;
  font-size: 14px;
  margin-top: 4px;
}

.btn-icon-ghost {
  width: 36px; height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  border-radius: 8px;
  color: var(--text2);
  font-size: 16px;
  cursor: pointer;
  transition: all var(--transition);
}

.btn-icon-ghost:hover { background: var(--ink3); color: var(--text); }

/* ── Formulários ── */
.form-group { margin-bottom: 14px; }

.form-label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  color: var(--text2);
  letter-spacing: 0.8px;
  text-transform: uppercase;
  margin-bottom: 6px;
}

.form-input {
  width: 100%;
  background: var(--ink3);
  border: 1px solid var(--line2);
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 14px;
  font-family: var(--font);
  color: var(--text);
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
  appearance: none;
  -webkit-appearance: none;
}

.form-input:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(192,57,43,0.15);
}

.form-input::placeholder { color: var(--text3); }

select.form-input {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23666' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 40px;
}

textarea.form-input { min-height: 80px; resize: vertical; }

.form-row { display: grid; gap: 12px; margin-bottom: 14px; }
.form-row.cols-2 { grid-template-columns: 1fr 1fr; }
.form-row.cols-3 { grid-template-columns: 1fr 1fr 1fr; }
.form-row.cols-4 { grid-template-columns: 1fr 1fr 1fr 1fr; }

/* ── Cards ── */
.card {
  background: var(--ink2);
  border: 1px solid var(--line);
  border-radius: var(--radius2);
  overflow: hidden;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  gap: 12px;
}

.card-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
}

.card-body { padding: 16px; }

/* ── Stat cards ── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}

.stat-card {
  background: var(--ink2);
  border: 1px solid var(--line);
  border-radius: var(--radius2);
  padding: 16px;
  position: relative;
  overflow: hidden;
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
}

.stat-card.gold::before  { background: var(--gold); }
.stat-card.red::before   { background: var(--red); }
.stat-card.green::before { background: var(--green); }
.stat-card.blue::before  { background: var(--blue); }
.stat-card.amber::before { background: var(--amber); }
.stat-card.purple::before{ background: var(--purple); }

.stat-label {
  font-size: 10px;
  font-weight: 700;
  color: var(--text3);
  letter-spacing: 1.5px;
  text-transform: uppercase;
  margin-bottom: 6px;
}

.stat-value {
  font-size: 22px;
  font-weight: 800;
  font-family: var(--mono);
  color: var(--text);
  line-height: 1.1;
}

.stat-meta {
  font-size: 11px;
  color: var(--text3);
  margin-top: 4px;
  font-family: var(--mono);
}

/* ── Badges ── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 8px;
  border-radius: 20px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.5px;
  white-space: nowrap;
}

.badge-green  { background: var(--green-dim);  color: var(--green);  border: 1px solid var(--green-glow); }
.badge-red    { background: var(--red-dim);    color: var(--red);    border: 1px solid var(--red-glow); }
.badge-blue   { background: var(--blue-dim);   color: var(--blue);   border: 1px solid var(--blue-glow); }
.badge-amber  { background: var(--amber-dim);  color: var(--amber);  border: 1px solid rgba(243,156,18,0.3); }
.badge-gold   { background: var(--gold-dim);   color: var(--gold);   border: 1px solid var(--gold-glow); }
.badge-gray   { background: var(--ink3);       color: var(--text3);  border: 1px solid var(--line2); }
.badge-brand  { background: var(--brand-dim);  color: var(--brand);  border: 1px solid var(--brand-border); }

/* ── Chips ── */
.chip {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  background: var(--ink3);
  border: 1px solid var(--line2);
  border-radius: 6px;
  font-size: 11px;
  font-family: var(--mono);
  color: var(--text2);
  white-space: nowrap;
}

/* ── Tabelas ── */
.table-wrap {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

thead th {
  padding: 10px 14px;
  font-size: 10px;
  font-weight: 700;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: 1px;
  text-align: left;
  border-bottom: 1px solid var(--line);
  background: var(--ink3);
  white-space: nowrap;
}

tbody td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}

tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--ink3); }

.td-mono { font-family: var(--mono); }
.td-center { text-align: center; }

/* ── Page header ── */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 20px;
  gap: 16px;
  flex-wrap: wrap;
}

.page-title {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.5px;
  line-height: 1.2;
}

.page-sub {
  font-size: 12px;
  color: var(--text3);
  font-family: var(--mono);
  margin-top: 2px;
}

.page-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

/* ── Dashboard grid ── */
.dash-grid {
  display: grid;
  gap: 16px;
  margin-bottom: 16px;
}

.dash-grid.cols-2 { grid-template-columns: 1fr 1fr; }
.dash-grid.cols-3 { grid-template-columns: 1fr 1fr 1fr; }
.dash-grid.cols-4 { grid-template-columns: 1fr 1fr 1fr 1fr; }

/* ── Alerts ── */
.alert {
  padding: 12px 14px;
  border-radius: 8px;
  font-size: 13px;
  line-height: 1.5;
  margin-bottom: 12px;
}

.alert-green  { background: var(--green-dim); color: var(--green); border: 1px solid var(--green-glow); }
.alert-red    { background: var(--red-dim);   color: var(--red);   border: 1px solid var(--red-glow); }
.alert-amber  { background: var(--amber-dim); color: var(--amber); border: 1px solid rgba(243,156,18,0.3); }
.alert-blue   { background: var(--blue-dim);  color: var(--blue);  border: 1px solid var(--blue-glow); }

/* ── Modais ── */
.overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.75);
  z-index: 300;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(3px);
  padding: 20px;
}

.overlay.open { display: flex; }

.modal {
  background: var(--ink2);
  border: 1px solid var(--line2);
  border-radius: var(--radius2);
  padding: 28px;
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  overflow-y: auto;
  position: relative;
  box-shadow: var(--shadow-lg);
  animation: modalIn 0.2s ease;
}

.modal-title {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 4px;
  padding-right: 32px;
}

.modal-sub {
  font-size: 12px;
  color: var(--text3);
  font-family: var(--mono);
  margin-bottom: 20px;
}

.modal-close {
  position: absolute;
  top: 14px; right: 14px;
  width: 32px; height: 32px;
  background: var(--ink3);
  border: none;
  border-radius: 8px;
  color: var(--text2);
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
}

.modal-close:hover { background: var(--red-dim); color: var(--red); }

.modal-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  padding-top: 20px;
  border-top: 1px solid var(--line);
  margin-top: 20px;
}

.modal-divider {
  font-size: 10px;
  font-weight: 700;
  color: var(--text3);
  letter-spacing: 2px;
  text-transform: uppercase;
  padding: 14px 0 8px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 14px;
}

/* ── Empty state ── */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--text3);
}

.empty-icon { font-size: 32px; margin-bottom: 12px; opacity: 0.4; }
.empty-title { font-size: 15px; font-weight: 600; margin-bottom: 4px; color: var(--text2); }
.empty-sub { font-size: 12px; font-family: var(--mono); }

/* ── Rank bars ── */
.rank-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.rank-pos { font-size: 16px; width: 24px; flex-shrink: 0; }
.rank-name { font-size: 12px; font-weight: 500; min-width: 80px; color: var(--text2); }
.rank-track { flex: 1; height: 4px; background: var(--ink4); border-radius: 2px; overflow: hidden; }
.rank-fill { height: 100%; border-radius: 2px; transition: width 0.5s ease; }
.rank-val { font-family: var(--mono); font-size: 11px; color: var(--text2); min-width: 70px; text-align: right; }

/* ── Tag de escritório ── */
.esc-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  font-family: var(--mono);
  border: 1px solid;
}

/* ── Hierarquia badge ── */
.role-wcon     { background: rgba(212,160,23,0.1); color: var(--gold); border-color: var(--gold-glow); }
.role-franq    { background: var(--brand-dim); color: var(--brand); border-color: var(--brand-border); }
.role-gestor   { background: var(--blue-dim); color: var(--blue); border-color: var(--blue-glow); }
.role-superv   { background: var(--green-dim); color: var(--green); border-color: var(--green-glow); }
.role-adm      { background: var(--ink3); color: var(--text2); border-color: var(--line2); }
.role-vendedor { background: var(--ink3); color: var(--text3); border-color: var(--line); }

/* ── Progress bar ── */
.progress-wrap {
  height: 6px;
  background: var(--ink4);
  border-radius: 3px;
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  border-radius: 3px;
  background: var(--brand);
  transition: width 0.4s ease;
}

/* ── Divisor de seção ── */
.form-divider {
  font-size: 10px;
  font-weight: 700;
  color: var(--text3);
  letter-spacing: 2px;
  text-transform: uppercase;
  padding: 12px 0 8px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 14px;
}

/* ── Animações ── */
@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

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

/* ════════════════════════════════════════════════════
   TEMA CLARO (override)
════════════════════════════════════════════════════ */
body.theme-light {
  --bg:    #F4F4F4;
  --ink1:  #FFFFFF;
  --ink2:  #FAFAFA;
  --ink3:  #F0F0F0;
  --ink4:  #E8E8E8;
  --line:  #E0E0E0;
  --line2: #D0D0D0;
  --text:  #111111;
  --text2: #444444;
  --text3: #888888;
}

/* ════════════════════════════════════════════════════
   RESPONSIVO MOBILE
════════════════════════════════════════════════════ */
@media (max-width: 768px) {
  :root { --sidebar-w: 0px; }

  #sidebar {
    left: -280px;
    width: 280px;
    transition: left 0.3s cubic-bezier(0.4,0,0.2,1);
    z-index: 160;
  }

  #sidebar.mob-open { left: 0; box-shadow: 4px 0 32px rgba(0,0,0,0.6); }

  #main-content {
    margin-left: 0;
    padding: 16px;
    padding-top: calc(var(--header-h) + 16px);
  }

  .dash-grid.cols-2,
  .dash-grid.cols-3,
  .dash-grid.cols-4 {
    grid-template-columns: 1fr;
  }

  .form-row.cols-2,
  .form-row.cols-3,
  .form-row.cols-4 {
    grid-template-columns: 1fr;
  }

  .modal { padding: 20px 16px; }

  .page-header { flex-direction: column; }
}

@media (min-width: 769px) {
  #btn-toggle-sb { display: none; }
}

/* ════════════════════════════════════════════════════
   PRINT
════════════════════════════════════════════════════ */
@media print {
  #header, #sidebar, #mobile-overlay, .no-print { display: none !important; }
  #main-content { margin: 0; padding: 0; }
  .module.active { display: block; }
}
