/* ============================================================
   SupriCRM 2.0 — Sistema de Orçamentos
   Tema escuro idêntico ao PHP | sistema.css
   ============================================================ */

:root {
  --brand:        #f97316;
  --brand-dark:   #ea580c;
  --brand-light:  rgba(249,115,22,.1);
  --bg:           #0a0a0a;
  --surface:      #141414;
  --surface2:     #1e1e1e;
  --surface3:     #2a2a2a;
  --border:       #2a2a2a;
  --border-light: #333;
  --text:         #e5e5e5;
  --text-muted:   #888;
  --text-dark:    #aaa;
  --success:      #22c55e;
  --warning:      #f59e0b;
  --danger:       #ef4444;
  --info:         #3b82f6;
  --nav-w:        220px;
  --header-h:     52px;
  --radius:       8px;
  --radius-sm:    6px;
  --shadow:       0 2px 12px rgba(0,0,0,.4);
}

/* ─── RESET ─── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 14px; -webkit-font-smoothing: antialiased; }
body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
}
a { color: var(--brand); text-decoration: none; }
a:hover { color: var(--brand-dark); }
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border-light); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #555; }

/* ─── SIDEBAR ─── */
.sidenav {
  width: var(--nav-w);
  min-width: var(--nav-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0;
  height: 100vh;
  z-index: 200;
  overflow-y: auto;
  overflow-x: hidden;
}

.sidenav__logo {
  padding: 16px 16px 14px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
}
.sidenav__logo img { height: 32px; }
.sidenav__brand { display: flex; flex-direction: column; }
.sidenav__brand-name {
  color: var(--brand);
  font-weight: 800;
  font-size: 15px;
  letter-spacing: -.3px;
}

.sidenav__nav { padding: 8px 0; flex: 1; }

.sidenav__section {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
  padding: 14px 16px 4px;
  font-weight: 600;
}

.sidenav__link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 16px;
  color: var(--text-dark);
  font-size: 13px;
  font-weight: 500;
  border-left: 3px solid transparent;
  transition: all .15s;
  text-decoration: none;
}
.sidenav__link:hover {
  background: var(--surface2);
  color: var(--text);
}
.sidenav__link.active {
  background: var(--brand-light);
  color: var(--brand);
  border-left-color: var(--brand);
  font-weight: 600;
}
.sidenav__icon { font-size: 15px; width: 20px; text-align: center; flex-shrink: 0; }

/* Sidebar footer (user) */
.sidenav__footer {
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  background: var(--surface);
}
.sidenav__user { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.sidenav__avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--brand);
  color: #000;
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 14px;
  flex-shrink: 0;
}
.sidenav__user-info { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.sidenav__user-name {
  font-size: 12px; font-weight: 700; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sidenav__user-actions { display: flex; gap: 8px; }
.sidenav__footer-link {
  font-size: 11px; color: var(--text-muted); text-decoration: none;
}
.sidenav__footer-link:hover { color: var(--brand); }

/* ─── MAIN CONTENT ─── */
.main-content {
  margin-left: var(--nav-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ─── TOPBAR ─── */
.topbar {
  height: var(--header-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  position: sticky;
  top: 0;
  z-index: 100;
}
.topbar__left { display: flex; align-items: center; gap: 12px; }
.topbar__burger { display: none; background: none; border: none; color: var(--text); font-size: 20px; cursor: pointer; }
.topbar__title { font-size: 16px; font-weight: 700; color: var(--text); }
.topbar__right { display: flex; align-items: center; gap: 16px; }
.topbar__empresa { text-align: right; }
.topbar__empresa-nome { font-size: 12px; font-weight: 600; color: var(--text); display: block; }
.topbar__empresa-regime { font-size: 10px; color: var(--text-muted); }

/* ─── PAGE BODY ─── */
.page-body {
  padding: 20px;
  flex: 1;
}

/* ─── CARDS ─── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 16px;
}
.card__title {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--text-muted);
  margin-bottom: 12px;
}

/* ─── KPI GRID ─── */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
}
.kpi-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}
.kpi-value {
  font-size: 24px;
  font-weight: 800;
  color: var(--text);
  margin-bottom: 4px;
}
.kpi-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--text-muted);
}

/* ─── BUTTONS ─── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all .15s;
  text-decoration: none;
  white-space: nowrap;
}
.btn--primary {
  background: var(--brand);
  color: #000;
  border-color: var(--brand);
}
.btn--primary:hover { background: var(--brand-dark); color: #000; }
.btn--ghost {
  background: transparent;
  color: var(--text-muted);
  border-color: var(--border-light);
}
.btn--ghost:hover { background: var(--surface2); color: var(--text); }
.btn--danger { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn--success { background: var(--success); color: #fff; border-color: var(--success); }
.btn--sm { padding: 5px 12px; font-size: 12px; }
.btn--lg { padding: 10px 24px; font-size: 15px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ─── BADGES ─── */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 700;
  line-height: 1.4;
}
.badge--rascunho { background: rgba(148,163,184,.12); color: #94a3b8; }
.badge--enviado { background: rgba(59,130,246,.12); color: #3b82f6; }
.badge--aprovado { background: rgba(34,197,94,.12); color: #22c55e; }
.badge--perdido { background: rgba(239,68,68,.12); color: #ef4444; }
.badge--cancelado { background: rgba(107,114,128,.12); color: #6b7280; }
.badge--aguardando_aprovacao { background: rgba(245,158,11,.12); color: #f59e0b; }
.badge--ajuste_pendente { background: rgba(245,158,11,.12); color: #f59e0b; }
.badge--em_compra { background: rgba(139,92,246,.12); color: #8b5cf6; }
.badge--recebido { background: rgba(56,189,248,.12); color: #38bdf8; }
.badge--faturando { background: rgba(249,115,22,.12); color: #f97316; }
.badge--faturado { background: rgba(34,197,94,.12); color: #22c55e; }
.badge--primary { background: rgba(59,130,246,.12); color: #3b82f6; }
.badge--success { background: rgba(34,197,94,.12); color: #22c55e; }
.badge--warning { background: rgba(245,158,11,.12); color: #f59e0b; }
.badge--danger { background: rgba(239,68,68,.12); color: #ef4444; }
.badge--purple { background: rgba(139,92,246,.12); color: #8b5cf6; }
.badge--info { background: rgba(56,189,248,.12); color: #38bdf8; }

/* ─── SEMÁFORO ─── */
.semaforo {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 700;
}
.semaforo.verde, .verde { background: rgba(34,197,94,.15); color: #22c55e; }
.semaforo.amarelo, .amarelo { background: rgba(245,158,11,.15); color: #f59e0b; }
.semaforo.vermelho, .vermelho { background: rgba(239,68,68,.15); color: #ef4444; }

/* ─── TABLES ─── */
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th {
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .3px;
  color: var(--text-muted);
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
}
.table td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
}
.table tbody tr:hover { background: var(--surface2); }

/* ─── FORMS ─── */
.form-group { margin-bottom: 12px; }
.form-label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .3px;
  color: var(--text-muted);
  margin-bottom: 4px;
}
.form-control {
  width: 100%;
  padding: 8px 10px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 13px;
  font-family: inherit;
  transition: border .15s;
}
.form-control:focus { outline: none; border-color: var(--brand); }
.form-control::placeholder { color: var(--text-muted); }
select.form-control { cursor: pointer; }
textarea.form-control { resize: vertical; min-height: 60px; }

/* ─── FILTROS (barra do dashboard) ─── */
.filtros-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.filtros-bar .filtros-label {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: .5px;
}
.filtro-btn {
  padding: 5px 12px;
  border-radius: 14px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid var(--border-light);
  background: transparent;
  color: var(--text-muted);
  transition: all .15s;
}
.filtro-btn:hover { background: var(--surface2); color: var(--text); }
.filtro-btn.active {
  background: var(--brand);
  color: #000;
  border-color: var(--brand);
}

/* ─── CHART CONTAINER ─── */
.chart-container {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 16px;
}
.chart-title {
  font-size: 14px;
  font-weight: 700;
  margin-bottom: 12px;
}

/* ─── MODAL ─── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.7);
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
}
.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  max-width: 500px;
  width: 90%;
  max-height: 80vh;
  overflow-y: auto;
}
.modal__title {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 16px;
}
.modal__close {
  position: absolute;
  top: 16px;
  right: 16px;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 18px;
  cursor: pointer;
}

/* ─── TOASTS ─── */
.toast {
  position: fixed;
  bottom: 20px;
  right: 20px;
  padding: 12px 20px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  z-index: 9999;
  transform: translateY(100px);
  opacity: 0;
  transition: all .3s;
}
.toast.show { transform: translateY(0); opacity: 1; }
.toast--success { background: var(--success); color: #fff; }
.toast--error { background: var(--danger); color: #fff; }
.toast--warning { background: var(--warning); color: #000; }

/* ─── GRID UTILS ─── */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }

/* ─── ORÇAMENTO FORM ─── */
.orc-header-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 12px;
}
.orc-itens-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}
.orc-itens-table th {
  padding: 6px 4px;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .3px;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.orc-itens-table td {
  padding: 4px;
  border-bottom: 1px solid var(--border);
}
.orc-itens-table input,
.orc-itens-table select {
  width: 100%;
  padding: 5px 6px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text);
  font-size: 12px;
  text-align: right;
}
.orc-itens-table input:focus { border-color: var(--brand); outline: none; }

/* Totais do orçamento */
.orc-totais {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}
.orc-totais-row {
  display: flex;
  justify-content: space-between;
  padding: 4px 0;
  font-size: 13px;
}
.orc-totais-row.destaque {
  font-weight: 700;
  font-size: 15px;
  border-top: 1px solid var(--border);
  margin-top: 6px;
  padding-top: 8px;
}

/* ─── FOLLOW-UP ─── */
.followup-item {
  border-left: 3px solid var(--brand);
  padding: 8px 12px;
  margin-bottom: 8px;
  background: var(--surface2);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}
.followup-meta { font-size: 11px; color: var(--text-muted); margin-bottom: 4px; }
.followup-desc { font-size: 13px; color: var(--text); }

/* ─── PERFORMANCE TABLE ─── */
.perf-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.perf-table th {
  text-align: left;
  font-size: 10px;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 6px 8px;
  border-bottom: 1px solid var(--border);
}
.perf-table td { padding: 8px; border-bottom: 1px solid var(--border); }

/* ─── INFO GRID ─── */
.info-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 10px;
}
.info-item { display: flex; flex-direction: column; gap: 2px; }
.info-item .label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .3px;
  color: var(--text-muted);
}
.info-item .value { font-size: 14px; color: var(--text); font-weight: 500; }

/* ─── LOADING SPINNER ─── */
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
  color: var(--text-muted);
}
.spinner {
  width: 24px; height: 24px;
  border: 3px solid var(--border);
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: spin .8s linear infinite;
  margin-right: 10px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ─── RESPONSIVE ─── */
@media (max-width: 768px) {
  .sidenav {
    transform: translateX(-100%);
    transition: transform .3s;
  }
  .sidenav.open { transform: translateX(0); }
  .main-content { margin-left: 0; }
  .topbar__burger { display: block; }
  .kpi-grid { grid-template-columns: 1fr 1fr; }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .page-body { padding: 12px; }
  .orc-header-grid { grid-template-columns: 1fr 1fr; }
}

/* ─── PRINT ─── */
@media print {
  .sidenav, .topbar, .btn, .filtros-bar { display: none !important; }
  .main-content { margin-left: 0 !important; }
  .page-body { padding: 0 !important; }
  body { background: #fff; color: #000; }
  .card { border: 1px solid #ddd; }
}

/* ─── Period Picker Global ─── */
.period-picker {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
}
.period-picker--compact {
  padding: 6px 10px;
  gap: 6px;
}
.period-picker .pp-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin: 0;
}
.period-picker .pp-btns {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}
.period-picker .pp-btn {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}
.period-picker .pp-btn:hover {
  background: var(--border);
  border-color: var(--primary);
}
.period-picker .pp-btn--active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}
.period-picker .pp-custom {
  display: flex;
  align-items: center;
  gap: 6px;
}
.period-picker .pp-date {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 5px 8px;
  border-radius: 6px;
  font-size: 12px;
  font-family: inherit;
  color-scheme: dark;
}
.period-picker .pp-date:focus {
  outline: none;
  border-color: var(--primary);
}
.period-picker .pp-sep {
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 700;
}
.period-picker .pp-info {
  margin-left: auto;
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 600;
}
@media (max-width: 720px) {
  .period-picker .pp-info { width: 100%; margin-left: 0; text-align: right; }
}
