/* ══════════════════════════════════════════════════════════════════════
   PETROBRIGHT v5 — Design System
   Temas: light / dark / auto (segue sistema operacional)
   ══════════════════════════════════════════════════════════════════════ */

/* ── TEMA CLARO ──────────────────────────────────────────────────────── */
:root, [data-theme="light"] {
  --bg:            #F5F6FA;
  --bg-alt:        #ECEDF2;
  --surface:       #FFFFFF;
  --surface-2:     #F8F9FC;
  --surface-3:     #F0F1F5;
  --border:        #DFE1E8;
  --border-light:  #ECEDF2;
  --accent:        #DC3545;
  --accent-hover:  #B02A37;
  --accent-soft:   rgba(220,53,69,.08);
  --blue:          #2563EB;
  --blue-soft:     rgba(37,99,235,.08);
  --green:         #059669;
  --green-soft:    rgba(5,150,105,.08);
  --yellow:        #D97706;
  --yellow-soft:   rgba(217,119,6,.08);
  --purple:        #7C3AED;
  --purple-soft:   rgba(124,58,237,.08);
  --text:          #1A1D26;
  --text-2:        #4A4F5E;
  --text-muted:    #8B90A0;
  --radius:        10px;
  --radius-sm:     6px;
  --radius-xs:     4px;
  --shadow-sm:     0 1px 3px rgba(0,0,0,.06);
  --shadow-md:     0 4px 16px rgba(0,0,0,.08);
  --shadow-lg:     0 8px 32px rgba(0,0,0,.12);
  --sidebar-bg:    #1A1D26;
  --sidebar-text:  #A0A4B0;
  --sidebar-active: var(--accent);
  --sidebar-hover: rgba(255,255,255,.06);
}

/* ── TEMA ESCURO ─────────────────────────────────────────────────────── */
[data-theme="dark"] {
  --bg:            #0C0F16;
  --bg-alt:        #10141C;
  --surface:       #161A25;
  --surface-2:     #1C2030;
  --surface-3:     #222638;
  --border:        #2A2E3E;
  --border-light:  #232736;
  --accent:        #EF4444;
  --accent-hover:  #DC2626;
  --accent-soft:   rgba(239,68,68,.12);
  --blue:          #3B82F6;
  --blue-soft:     rgba(59,130,246,.12);
  --green:         #10B981;
  --green-soft:    rgba(16,185,129,.12);
  --yellow:        #F59E0B;
  --yellow-soft:   rgba(245,158,11,.12);
  --purple:        #8B5CF6;
  --purple-soft:   rgba(139,92,246,.12);
  --text:          #E4E6EE;
  --text-2:        #9CA0B0;
  --text-muted:    #5C6070;
  --shadow-sm:     0 1px 3px rgba(0,0,0,.2);
  --shadow-md:     0 4px 16px rgba(0,0,0,.3);
  --shadow-lg:     0 8px 32px rgba(0,0,0,.4);
  --sidebar-bg:    #0C0F16;
  --sidebar-text:  #6B7080;
  --sidebar-active: var(--accent);
  --sidebar-hover: rgba(255,255,255,.04);
}

/* ── AUTO: segue sistema ─────────────────────────────────────────────── */
@media (prefers-color-scheme: dark) {
  [data-theme="auto"] {
    --bg:            #0C0F16;
    --bg-alt:        #10141C;
    --surface:       #161A25;
    --surface-2:     #1C2030;
    --surface-3:     #222638;
    --border:        #2A2E3E;
    --border-light:  #232736;
    --accent:        #EF4444;
    --accent-hover:  #DC2626;
    --accent-soft:   rgba(239,68,68,.12);
    --blue:          #3B82F6;
    --blue-soft:     rgba(59,130,246,.12);
    --green:         #10B981;
    --green-soft:    rgba(16,185,129,.12);
    --yellow:        #F59E0B;
    --yellow-soft:   rgba(245,158,11,.12);
    --purple:        #8B5CF6;
    --purple-soft:   rgba(139,92,246,.12);
    --text:          #E4E6EE;
    --text-2:        #9CA0B0;
    --text-muted:    #5C6070;
    --shadow-sm:     0 1px 3px rgba(0,0,0,.2);
    --shadow-md:     0 4px 16px rgba(0,0,0,.3);
    --shadow-lg:     0 8px 32px rgba(0,0,0,.4);
    --sidebar-bg:    #0C0F16;
    --sidebar-text:  #6B7080;
    --sidebar-active: var(--accent);
    --sidebar-hover: rgba(255,255,255,.04);
  }
}

/* ── RESET & BASE ────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 14px; -webkit-font-smoothing: antialiased; }
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
}
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── TIPOGRAFIA ──────────────────────────────────────────────────────── */
.font-display { font-family: 'Sora', sans-serif; }
.font-mono { font-family: 'JetBrains Mono', 'DM Mono', monospace; }

/* ── LAYOUT SHELL (sidebar + main) ───────────────────────────────────── */
.shell { display: flex; min-height: 100vh; }

/* ── SIDEBAR ─────────────────────────────────────────────────────────── */
.sidebar {
  width: 240px;
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 50;
  transition: transform .25s cubic-bezier(.4,0,.2,1);
}
.sidebar-header {
  padding: 20px 18px;
  border-bottom: 1px solid rgba(255,255,255,.06);
}
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
}
.sidebar-brand-icon {
  width: 32px; height: 32px;
  background: var(--accent);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-family: 'Sora', sans-serif;
  font-weight: 800;
  font-size: 14px;
}
.sidebar-brand-text {
  font-family: 'Sora', sans-serif;
  font-size: 16px;
  font-weight: 700;
  color: #fff;
  letter-spacing: -.02em;
}
.sidebar-brand-text span { color: var(--accent); }
.sidebar-version {
  display: inline-block;
  margin-top: 6px;
  background: rgba(255,255,255,.08);
  color: rgba(255,255,255,.5);
  font-family: 'JetBrains Mono', monospace;
  font-size: 9px;
  font-weight: 500;
  padding: 2px 7px;
  border-radius: 3px;
  letter-spacing: .5px;
}
.sidebar-nav { flex: 1; padding: 12px 0; overflow-y: auto; }
.sidebar-section {
  padding: 14px 18px 5px;
  font-size: 10px;
  font-weight: 700;
  color: rgba(255,255,255,.25);
  letter-spacing: 1.2px;
  text-transform: uppercase;
}
.sidebar-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 18px;
  font-size: 13px;
  font-weight: 500;
  color: var(--sidebar-text);
  cursor: pointer;
  border-left: 3px solid transparent;
  transition: all .15s;
  user-select: none;
  text-decoration: none;
}
.sidebar-item:hover {
  color: #fff;
  background: var(--sidebar-hover);
  text-decoration: none;
}
.sidebar-item.active {
  color: var(--sidebar-active);
  background: rgba(220,53,69,.08);
  border-left-color: var(--sidebar-active);
}
.sidebar-item svg {
  width: 16px; height: 16px;
  stroke: currentColor; fill: none;
  flex-shrink: 0;
}
.sidebar-item .badge-count {
  margin-left: auto;
  background: var(--accent);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 10px;
  min-width: 18px;
  text-align: center;
}
.sidebar-footer {
  padding: 14px 18px;
  border-top: 1px solid rgba(255,255,255,.06);
}
.sidebar-user {
  font-size: 11px;
  color: rgba(255,255,255,.35);
  margin-bottom: 4px;
}
.sidebar-user strong {
  display: block;
  color: rgba(255,255,255,.85);
  font-size: 13px;
  margin-bottom: 1px;
}
.sidebar-company {
  font-size: 10px;
  color: var(--accent);
  font-weight: 600;
  letter-spacing: .3px;
  margin-bottom: 10px;
}

/* ── MAIN CONTENT ────────────────────────────────────────────────────── */
.main { flex: 1; margin-left: 240px; display: flex; flex-direction: column; min-height: 100vh; }
.topbar {
  padding: 14px 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  position: sticky;
  top: 0;
  z-index: 40;
}
.topbar-title {
  font-family: 'Sora', sans-serif;
  font-size: 16px;
  font-weight: 700;
}
.topbar-title em { color: var(--accent); font-style: normal; }
.topbar-actions { display: flex; align-items: center; gap: 8px; }
.content { padding: 24px; flex: 1; }

/* ── CARDS ────────────────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.card-header {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}
.card-title {
  font-family: 'Sora', sans-serif;
  font-size: 13px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
}
.card-title svg { width: 15px; height: 15px; stroke: currentColor; fill: none; }
.card-body { padding: 18px; }

/* ── STAT CARDS ──────────────────────────────────────────────────────── */
.stats-row { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 14px; margin-bottom: 20px; }
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.stat-card::after {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: var(--stat-color, var(--blue));
}
.stat-label {
  font-size: 10px;
  font-weight: 700;
  color: var(--text-muted);
  letter-spacing: .8px;
  text-transform: uppercase;
  margin-bottom: 8px;
}
.stat-value {
  font-family: 'Sora', sans-serif;
  font-size: 26px;
  font-weight: 800;
  line-height: 1.1;
}
.stat-sub { font-size: 11px; color: var(--text-muted); margin-top: 3px; }

/* ── BOTÕES ──────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-family: 'Inter', sans-serif;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all .15s;
  white-space: nowrap;
  text-decoration: none;
}
.btn svg { width: 14px; height: 14px; stroke: currentColor; fill: none; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); box-shadow: 0 0 16px rgba(220,53,69,.25); text-decoration: none; }
.btn-primary:disabled { opacity: .45; cursor: not-allowed; box-shadow: none; }
.btn-secondary { background: var(--surface-2); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { border-color: var(--text-muted); text-decoration: none; }
.btn-ghost { background: none; color: var(--text-muted); padding: 6px 8px; }
.btn-ghost:hover { color: var(--text); background: var(--surface-2); text-decoration: none; }
.btn-danger { background: var(--accent-soft); color: var(--accent); border: 1px solid rgba(220,53,69,.2); }
.btn-danger:hover { background: rgba(220,53,69,.16); text-decoration: none; }
.btn-success { background: var(--green-soft); color: var(--green); border: 1px solid rgba(5,150,105,.2); }
.btn-success:hover { background: rgba(5,150,105,.16); text-decoration: none; }
.btn-info { background: var(--blue-soft); color: var(--blue); border: 1px solid rgba(37,99,235,.2); }
.btn-info:hover { background: rgba(37,99,235,.16); text-decoration: none; }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-xs { padding: 3px 8px; font-size: 11px; }
.btn-logout {
  width: 100%;
  padding: 8px;
  background: rgba(220,53,69,.08);
  color: var(--accent);
  border: 1px solid rgba(220,53,69,.2);
  border-radius: var(--radius-sm);
  font-family: 'Inter', sans-serif;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s;
}
.btn-logout:hover { background: rgba(220,53,69,.16); }

/* ── TABELAS ─────────────────────────────────────────────────────────── */
.table-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  margin-bottom: 16px;
}
.table-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
thead tr { background: var(--surface-2); border-bottom: 2px solid var(--border); }
th {
  padding: 9px 12px;
  text-align: left;
  font-size: 10px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .6px;
  white-space: nowrap;
}
td {
  padding: 9px 12px;
  border-bottom: 1px solid var(--border-light);
  vertical-align: middle;
  font-size: 13px;
}
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--surface-2); }

/* ── BADGES ──────────────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 9px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}
.badge-blue   { background: var(--blue-soft); color: var(--blue); }
.badge-green  { background: var(--green-soft); color: var(--green); }
.badge-yellow { background: var(--yellow-soft); color: var(--yellow); }
.badge-red    { background: var(--accent-soft); color: var(--accent); }
.badge-purple { background: var(--purple-soft); color: var(--purple); }
.badge-muted  { background: var(--surface-3); color: var(--text-muted); }

/* ── FORMULÁRIOS ─────────────────────────────────────────────────────── */
.form-group { margin-bottom: 16px; }
.form-label {
  display: block;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  letter-spacing: .5px;
  text-transform: uppercase;
  margin-bottom: 5px;
}
.form-input, .form-select, .form-textarea {
  width: 100%;
  padding: 9px 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: 'Inter', sans-serif;
  font-size: 13px;
  outline: none;
  transition: border .15s, box-shadow .15s;
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px var(--blue-soft);
}
.form-select option { background: var(--surface-2); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-grid-full { grid-column: 1 / -1; }

/* ── SEARCH ──────────────────────────────────────────────────────────── */
.search-wrap { position: relative; }
.search-wrap svg {
  position: absolute; left: 10px; top: 50%; transform: translateY(-50%);
  width: 14px; height: 14px; stroke: var(--text-muted); fill: none; pointer-events: none;
}
.search-input {
  padding: 8px 12px 8px 32px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: 'Inter', sans-serif;
  font-size: 13px;
  outline: none;
  width: 220px;
  transition: all .2s;
}
.search-input:focus { border-color: var(--blue); width: 280px; }

/* ── MODAL ────────────────────────────────────────────────────────────── */
.overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.6);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000;
  opacity: 0; pointer-events: none;
  transition: opacity .2s;
}
.overlay.visible { opacity: 1; pointer-events: all; }
.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 24px;
  width: 100%;
  max-width: 520px;
  box-shadow: var(--shadow-lg);
  transform: translateY(16px);
  transition: transform .2s;
}
.overlay.visible .modal { transform: none; }
.modal-title {
  font-family: 'Sora', sans-serif;
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 18px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.modal-title svg { width: 16px; height: 16px; stroke: var(--accent); fill: none; }
.modal-footer {
  display: flex; gap: 8px;
  justify-content: flex-end;
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

/* ── TOAST ────────────────────────────────────────────────────────────── */
.toast-container {
  position: fixed; bottom: 20px; right: 20px;
  z-index: 9999;
  display: flex; flex-direction: column; gap: 8px;
}
.toast {
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: 13px; font-weight: 600;
  box-shadow: var(--shadow-md);
  transform: translateX(120%);
  transition: transform .3s cubic-bezier(.4,0,.2,1);
  pointer-events: auto;
}
.toast.visible { transform: none; }
.toast-ok    { background: #022C22; color: #34D399; border: 1px solid rgba(52,211,153,.3); }
.toast-error { background: #3B0A0A; color: #F87171; border: 1px solid rgba(248,113,113,.3); }
.toast-info  { background: #0C1A2E; color: #60A5FA; border: 1px solid rgba(59,130,246,.3); }

/* ── EMPTY STATE ─────────────────────────────────────────────────────── */
.empty-state { text-align: center; padding: 48px; color: var(--text-muted); }
.empty-state svg { width: 48px; height: 48px; stroke: var(--border); fill: none; opacity: .5; margin-bottom: 12px; }
.empty-state h3 { font-family: 'Sora', sans-serif; font-size: 15px; font-weight: 700; color: var(--text-2); margin-bottom: 4px; }

/* ── THEME TOGGLE ────────────────────────────────────────────────────── */
.theme-toggle {
  display: flex; align-items: center; gap: 4px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 2px;
}
.theme-opt {
  padding: 4px 8px;
  border-radius: 16px;
  cursor: pointer;
  transition: all .15s;
  display: flex; align-items: center; justify-content: center;
}
.theme-opt svg { width: 14px; height: 14px; stroke: var(--text-muted); fill: none; }
.theme-opt.active { background: var(--accent); }
.theme-opt.active svg { stroke: #fff; }

/* ── PANELS ──────────────────────────────────────────────────────────── */
.panel { display: none; }
.panel.active { display: block; }

/* ── RESPONSIVE ──────────────────────────────────────────────────────── */
.sidebar-toggle { display: none; }
@media (max-width: 1024px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: none; }
  .main { margin-left: 0; }
  .sidebar-toggle { display: flex; }
}
@media (max-width: 768px) {
  .stats-row { grid-template-columns: repeat(2, 1fr); }
  .form-grid { grid-template-columns: 1fr; }
  .topbar { padding: 10px 16px; }
  .content { padding: 16px; }
}
@media (max-width: 480px) {
  .stats-row { grid-template-columns: 1fr; }
}
