/* ============================================================
   GUIA DE REPRESENTANTES — Design System Global
   Arquivo: static/styles.css
   ============================================================ */

/* ── Reset ── */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
html, body { overflow-x: hidden; }
* { min-width: 0; }

/* ── Design tokens ── */
:root {
  /* Cores base */
  --background:          200 35% 8%;
  --foreground:          180 20% 96%;
  --primary:             187 95% 44%;
  --primary-foreground:  200 40% 8%;
  --muted-foreground:    180 10% 60%;
  --border:              195 30% 20%;
  --input:               195 30% 12%;
  --accent:              195 30% 16%;
  --sidebar-bg:          200 35% 10%;
  --sidebar-accent:      195 30% 16%;

  /* Semânticas */
  --danger:  0  80% 55%;
  --success: 152 60% 45%;
  --warning: 38  92% 55%;

  /* Layout */
  --topbar-h: 50px;
  --sidebar-w: 240px;
  --radius: 10px;
  --radius-sm: 7px;
  --radius-lg: 14px;
}

/* Sem topbar (representantes) */
body.no-topbar { --topbar-h: 0px; }

/* ── Base ── */
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: hsl(var(--background));
  color: hsl(var(--foreground));
  line-height: 1.5;
}

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

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: hsl(var(--border)); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: hsl(var(--accent)); }

/* ============================================================
   TOPBAR / NAVBAR (admin)
   ============================================================ */
.topbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--topbar-h);
  background: hsl(var(--sidebar-bg));
  border-bottom: 1px solid hsl(var(--border));
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  z-index: 3000;
}

.topbar-brand {
  font-size: 15px;
  font-weight: 700;
  color: hsl(var(--primary));
  white-space: nowrap;
}

/* Nav links desktop */
.topbar-nav {
  display: flex;
  align-items: center;
  gap: 4px;
  list-style: none;
  height: 100%;
}

.topbar-nav > li {
  position: relative;
  height: 100%;
  display: flex;
  align-items: center;
}

.topbar-nav > li > a {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 0 13px;
  height: 100%;
  font-size: 13px;
  font-weight: 500;
  color: hsl(var(--muted-foreground));
  border-bottom: 2px solid transparent;
  transition: color 0.15s, border-color 0.15s;
  white-space: nowrap;
}

.topbar-nav > li > a:hover,
.topbar-nav > li > a.active {
  color: hsl(var(--foreground));
  border-bottom-color: hsl(var(--primary));
}

.topbar-nav .arrow {
  font-size: 9px;
  opacity: 0.6;
  transition: transform 0.2s;
}
.topbar-nav > li:hover .arrow { transform: rotate(180deg); }

/* Dropdown */
.topbar-nav > li > ul {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  min-width: 210px;
  background: hsl(var(--background));
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius);
  box-shadow: 0 16px 40px rgba(0,0,0,0.35);
  overflow: hidden;
  list-style: none;
  z-index: 4000;
}
.topbar-nav > li:hover > ul { display: block; }

.topbar-nav > li > ul > li > a {
  display: block;
  padding: 11px 16px;
  font-size: 13px;
  color: hsl(var(--foreground));
  transition: background 0.15s;
}
.topbar-nav > li > ul > li > a:hover {
  background: hsl(var(--accent));
  color: hsl(var(--primary));
}

/* Botão logout topbar */
.topbar-logout {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 13px;
  background: transparent;
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius-sm);
  color: hsl(var(--muted-foreground));
  font-size: 13px;
  transition: all 0.15s;
  white-space: nowrap;
  text-decoration: none;
}
.topbar-logout:hover {
  background: hsla(0,80%,55%,0.1);
  border-color: hsla(0,80%,55%,0.3);
  color: hsl(var(--danger));
}

/* Hamburger (mobile) */
.topbar-hamburger {
  display: none;
  background: transparent;
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius-sm);
  color: hsl(var(--foreground));
  padding: 7px 9px;
  align-items: center;
  justify-content: center;
}

/* Mobile drawer */
.mobile-drawer {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 5000;
}
.mobile-drawer.open { display: block; }

.mobile-drawer-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.55);
  backdrop-filter: blur(3px);
}

.mobile-drawer-panel {
  position: absolute;
  top: 0; right: 0;
  width: min(300px, 85vw);
  height: 100dvh;
  background: hsl(var(--sidebar-bg));
  border-left: 1px solid hsl(var(--border));
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  animation: drawerIn 0.22s ease;
}
@keyframes drawerIn {
  from { transform: translateX(100%); }
  to   { transform: translateX(0); }
}

.drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid hsl(var(--border));
}
.drawer-brand { font-size: 15px; font-weight: 700; color: hsl(var(--primary)); }
.drawer-close {
  background: transparent;
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius-sm);
  color: hsl(var(--muted-foreground));
  padding: 6px 8px;
  display: flex;
  align-items: center;
}

.drawer-nav { list-style: none; padding: 12px 0; flex: 1; }
.drawer-nav li { border-bottom: 1px solid hsl(var(--border)); }
.drawer-nav li:last-child { border-bottom: none; }

.drawer-nav > li > a {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  font-size: 14px;
  font-weight: 500;
  color: hsl(var(--foreground));
  transition: background 0.15s;
}
.drawer-nav > li > a:hover { background: hsl(var(--accent)); color: hsl(var(--primary)); }

/* Sub-items no drawer */
.drawer-subnav { list-style: none; background: hsl(200 35% 7%); display: none; }
.drawer-subnav.open { display: block; }
.drawer-subnav li a {
  display: block;
  padding: 11px 20px 11px 36px;
  font-size: 13px;
  color: hsl(var(--muted-foreground));
  transition: background 0.15s, color 0.15s;
}
.drawer-subnav li a:hover { background: hsl(var(--accent)); color: hsl(var(--primary)); }

.drawer-footer {
  padding: 16px 20px;
  border-top: 1px solid hsl(var(--border));
}
.drawer-logout {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 12px;
  background: hsla(0,80%,55%,0.1);
  border: 1px solid hsla(0,80%,55%,0.2);
  border-radius: var(--radius);
  color: hsl(var(--danger));
  font-size: 14px;
  font-weight: 600;
}

/* ── Responsividade topbar ── */
@media (max-width: 768px) {
  .topbar-nav,
  .topbar-logout { display: none; }
  .topbar-hamburger { display: flex; }
  :root { --topbar-h: 48px; }
}

/* ============================================================
   LAYOUT PADRÃO (container + sidebar interna das páginas)
   ============================================================ */
.page-container {
  display: flex;
  margin-top: var(--topbar-h);
  height: calc(100dvh - var(--topbar-h));
  width: 100%;
  overflow: hidden;
}

/* ── Sidebar interna (oráculo, documentos, etc.) ── */
.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: hsl(var(--sidebar-bg));
  border-right: 1px solid hsl(var(--border));
  display: flex;
  flex-direction: column;
  transition: width 0.28s ease, transform 0.25s ease;
}

.sidebar.collapsed { width: 60px; }

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid hsl(var(--border));
  min-height: 60px;
  flex-shrink: 0;
  background: hsl(var(--sidebar-bg));
  position: sticky;
  top: 0;
  z-index: 20;
}

.sidebar-title {
  font-size: 17px;
  font-weight: 700;
  color: hsl(var(--primary));
}
.sidebar.collapsed .sidebar-title { display: none; }

.toggle-btn {
  background: transparent;
  border: none;
  color: hsl(var(--muted-foreground));
  padding: 8px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.toggle-btn:hover {
  background: hsl(var(--sidebar-accent));
  color: hsl(var(--primary));
}

/* ── Área principal ── */
.main-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}

/* ============================================================
   COMPONENTES COMUNS
   ============================================================ */

/* ── Botões ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 9px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  border: none;
  transition: opacity 0.15s, background 0.15s;
  white-space: nowrap;
}
.btn:hover { opacity: 0.88; }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }

.btn-primary {
  background: hsl(var(--primary));
  color: hsl(var(--primary-foreground));
}
.btn-secondary {
  background: hsl(var(--accent));
  border: 1px solid hsl(var(--border));
  color: hsl(var(--foreground));
}
.btn-danger {
  background: hsla(0,80%,55%,0.12);
  border: 1px solid hsla(0,80%,55%,0.25);
  color: hsl(var(--danger));
}
.btn-danger:hover { background: hsla(0,80%,55%,0.2); opacity: 1; }

.btn-icon {
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  border: 1px solid hsl(var(--border));
  color: hsl(var(--muted-foreground));
}
.btn-icon:hover {
  background: hsl(var(--accent));
  color: hsl(var(--foreground));
  opacity: 1;
}

/* Tamanhos */
.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-lg { padding: 13px 22px; font-size: 15px; }
.btn-full { width: 100%; }

/* ── Inputs ── */
.input {
  width: 100%;
  padding: 10px 12px;
  background: hsl(var(--input));
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius-sm);
  color: hsl(var(--foreground));
  font-size: 14px;
  outline: none;
  transition: border-color 0.15s;
}
.input:focus { border-color: hsl(var(--primary)); }
.input::placeholder { color: hsl(var(--muted-foreground)); }
.input-sm { padding: 7px 10px; font-size: 13px; }

/* Busca com ícone */
.input-icon-wrap { position: relative; }
.input-icon-wrap .input { padding-left: 34px; }
.input-icon-wrap svg {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: hsl(var(--muted-foreground));
  pointer-events: none;
}

/* ── Cards ── */
.card {
  background: hsl(var(--sidebar-bg));
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius);
  overflow: hidden;
}
.card-header {
  padding: 12px 16px;
  border-bottom: 1px solid hsl(var(--border));
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}
.card-title { font-size: 13px; font-weight: 600; }
.card-subtitle { font-size: 11px; color: hsl(var(--muted-foreground)); margin-top: 2px; }
.card-body { padding: 14px 16px; }

/* ── Badges ── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
}
.badge-primary  { background: hsla(187,95%,44%,0.12); color: hsl(var(--primary)); border: 1px solid hsla(187,95%,44%,0.2); }
.badge-danger   { background: hsla(0,80%,55%,0.12);   color: hsl(var(--danger));  border: 1px solid hsla(0,80%,55%,0.2); }
.badge-success  { background: hsla(152,60%,45%,0.12); color: hsl(var(--success)); border: 1px solid hsla(152,60%,45%,0.2); }
.badge-warning  { background: hsla(38,92%,55%,0.12);  color: hsl(var(--warning)); border: 1px solid hsla(38,92%,55%,0.2); }
.badge-muted    { background: hsl(var(--accent));     color: hsl(var(--muted-foreground)); border: 1px solid hsl(var(--border)); }

/* ── Modal ── */
.modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.55);
  backdrop-filter: blur(4px);
  align-items: center;
  justify-content: center;
  z-index: 5000;
  padding: 16px;
}
.modal.active { display: flex; }

.modal-box {
  background: hsl(var(--background));
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 520px;
  max-height: 90dvh;
  overflow-y: auto;
  padding: 22px;
  animation: modalIn 0.2s ease;
}
@keyframes modalIn {
  from { opacity:0; transform:scale(0.95) translateY(8px); }
  to   { opacity:1; transform:none; }
}

.modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 16px;
  gap: 12px;
}
.modal-title    { font-size: 16px; font-weight: 700; }
.modal-subtitle { font-size: 12px; color: hsl(var(--muted-foreground)); margin-top: 3px; }

/* ── Toast / Flash ── */
.flash {
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 14px;
}
.flash-error   { background: hsla(0,80%,55%,0.1);   color: hsl(var(--danger));  border: 1px solid hsla(0,80%,55%,0.2); }
.flash-success { background: hsla(152,60%,45%,0.1); color: hsl(var(--success)); border: 1px solid hsla(152,60%,45%,0.2); }
.flash-info    { background: hsla(187,95%,44%,0.1); color: hsl(var(--primary)); border: 1px solid hsla(187,95%,44%,0.2); }

/* ── Tabelas ── */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.table th, .table td {
  padding: 10px 14px;
  text-align: left;
  border-bottom: 1px solid hsl(var(--border));
}
.table th {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: hsl(var(--muted-foreground));
  background: hsl(var(--sidebar-bg));
  white-space: nowrap;
}
.table tr:hover td { background: hsl(var(--accent)); }
.table td:last-child, .table th:last-child { text-align: right; }

/* ============================================================
   AUTH PAGES (login, register, nova_senha)
   ============================================================ */
.auth-page {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: hsl(var(--background));
  padding: 20px;
}

.auth-card {
  width: 100%;
  max-width: 400px;
  background: hsl(var(--sidebar-bg));
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius-lg);
  padding: 36px 32px;
  box-shadow: 0 24px 60px rgba(0,0,0,0.4);
}

.auth-logo {
  text-align: center;
  margin-bottom: 24px;
}
.auth-logo img { width: 200px; height: auto; }
.auth-logo-text {
  font-size: 22px;
  font-weight: 700;
  color: hsl(var(--primary));
  text-align: center;
  margin-bottom: 6px;
}
.auth-logo-sub {
  font-size: 13px;
  color: hsl(var(--muted-foreground));
  text-align: center;
  margin-bottom: 28px;
}

.auth-field { margin-bottom: 14px; }
.auth-field label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: hsl(var(--muted-foreground));
  margin-bottom: 5px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.auth-field .input { font-size: 15px; padding: 12px 14px; }
.auth-field select.input { appearance: none; }

.auth-submit {
  width: 100%;
  padding: 13px;
  background: hsl(var(--primary));
  color: hsl(var(--primary-foreground));
  border: none;
  border-radius: var(--radius);
  font-size: 15px;
  font-weight: 700;
  margin-top: 8px;
  transition: opacity 0.15s;
}
.auth-submit:hover { opacity: 0.88; }

.auth-link {
  display: block;
  text-align: center;
  margin-top: 20px;
  font-size: 13px;
  color: hsl(var(--muted-foreground));
  transition: color 0.15s;
}
.auth-link:hover { color: hsl(var(--primary)); }

/* ============================================================
   INÍCIO / SPLASH
   ============================================================ */
.inicio-page {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: hsl(var(--background));
  padding: 20px;
  text-align: center;
}

.inicio-logo img {
  width: 260px;
  height: auto;
  margin-bottom: 32px;
}

.inicio-title {
  font-size: 32px;
  font-weight: 700;
  color: hsl(var(--foreground));
  line-height: 1.2;
}

.inicio-accent { color: hsl(var(--primary)); }

.inicio-sub {
  font-size: 15px;
  color: hsl(var(--muted-foreground));
  margin-top: 12px;
  max-width: 400px;
}

/* ============================================================
   UTILITÁRIOS
   ============================================================ */
.text-muted    { color: hsl(var(--muted-foreground)); }
.text-primary  { color: hsl(var(--primary)); }
.text-danger   { color: hsl(var(--danger)); }
.text-success  { color: hsl(var(--success)); }

.mt-auto { margin-top: auto; }
.gap-8   { gap: 8px; }
.gap-12  { gap: 12px; }
.flex    { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }

/* safe area mobile */
.safe-bottom { padding-bottom: calc(env(safe-area-inset-bottom) + 16px); }

/* ============================================================
   RESPONSIVIDADE GLOBAL
   ============================================================ */

/* Sidebar mobile: overlay sobre o conteúdo */
@media (max-width: 720px) {
  .page-container { position: relative; }

  .sidebar {
    position: fixed;
    top: var(--topbar-h);
    left: 0;
    height: calc(100dvh - var(--topbar-h));
    z-index: 2500;
    width: 280px !important;
    transform: translateX(0);
    box-shadow: 6px 0 30px rgba(0,0,0,0.4);
  }

  .sidebar.collapsed {
    transform: translateX(-100%);
  }

  /* Overlay escuro atrás da sidebar */
  .sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 2400;
    top: var(--topbar-h);
  }
  .sidebar-overlay.active { display: block; }
}

@media (max-width: 480px) {
  :root { --topbar-h: 46px; }

  .auth-card { padding: 24px 20px; }
  .modal-box { padding: 18px; }

  .inicio-title { font-size: 26px; }
  .inicio-logo img { width: 200px; }
  .auth-logo img { width: 160px; }
}
