/* ============================================================
   MACENA RETAIL INTELLIGENCE PLATFORM — style.css
   Padrão visual: dark near-black + accent LARANJA âmbar,
   cards premium com sparklines e brilho ambiente.
   ============================================================ */

:root {
  --bg:            #090C12;
  --bg-2:          #0C1018;
  --card:          #11151E;
  --card-hi:       #161C28;
  --orange:        #FF7A1A;   /* accent principal */
  --orange-soft:   #FFB070;
  --teal:          #34B3C9;   /* série secundária */
  --text:          #FFFFFF;
  --text-2:        #8B95A7;
  --text-mute:     #59637A;
  --green:         #34D399;   /* positivo */
  --yellow:        #FBBF24;
  --red:           #FF5C5C;   /* crítico */
  --border:        rgba(255,255,255,0.07);
  --border-accent: rgba(255,122,26,0.35);
  --shadow:        rgba(0,0,0,0.45);
  --glow:          rgba(255,122,26,0.18);
  --radius:        16px;
  --sidebar-w:     260px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 14px;
  line-height: 1.5;
}
/* brilho ambiente laranja (borda esquerda/topo) */
body::before {
  content: ''; position: fixed; top: 0; left: 0; width: 380px; height: 100%;
  background: radial-gradient(circle at 0% 30%, var(--glow), transparent 60%);
  pointer-events: none; z-index: 0;
}

h1, h2, h3, h4, .brand-text strong { font-family: 'Montserrat', 'Inter', sans-serif; }

button { font-family: inherit; cursor: pointer; }
a { color: var(--orange); }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: #20262f; border-radius: 8px; }
::-webkit-scrollbar-track { background: transparent; }

/* ============ SIDEBAR ============ */
.sidebar {
  position: fixed; top: 0; left: 0; bottom: 0;
  width: var(--sidebar-w);
  background: linear-gradient(180deg, #0b0f16, #090c12);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  z-index: 50;
}
.sidebar::after { /* fio de luz laranja na borda direita */
  content: ''; position: absolute; top: 8%; right: -1px; width: 2px; height: 84%;
  background: linear-gradient(180deg, transparent, var(--orange), transparent); opacity: .55;
}
.brand { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; padding: 22px 18px 18px; border-bottom: 1px solid var(--border); }
.brand-logo { width: 100%; max-width: 184px; height: auto; display: block; }
.brand-sub { font-size: 10.5px; letter-spacing: 1.5px; text-transform: uppercase; color: var(--orange-soft); font-weight: 600; padding-left: 2px; }

/* logo na barra superior — só aparece no mobile (sidebar recolhida) */
.topbar-logo { height: 30px; width: auto; display: none; }
.topbar-logo-dark { height: 34px; width: auto; display: none; } /* usada só na impressão (fundo claro) */

.nav { flex: 1; overflow-y: auto; padding: 12px 10px; display: flex; flex-direction: column; gap: 3px; }
.nav-item {
  display: flex; align-items: center; gap: 11px;
  background: transparent; border: none; color: var(--text-2);
  padding: 11px 13px; border-radius: 11px; text-align: left; font-size: 13px; width: 100%;
  transition: background .15s, color .15s;
}
.nav-item .ico { font-size: 15px; width: 18px; text-align: center; filter: grayscale(.3); }
.nav-item:hover { background: rgba(255,255,255,.04); color: var(--text); }
.nav-item.active {
  background: rgba(255,122,26,.12); color: #fff; font-weight: 600;
  box-shadow: inset 3px 0 0 var(--orange);
}
.nav-item.active .ico { filter: none; }

.sidebar-foot { padding: 14px 16px; border-top: 1px solid var(--border); font-size: 12px; color: var(--text-2); display: flex; align-items: center; gap: 8px; }
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
.dot-green { background: var(--green); } .dot-yellow { background: var(--yellow); } .dot-red { background: var(--red); }

/* ============ MAIN ============ */
.main { margin-left: var(--sidebar-w); min-height: 100vh; display: flex; flex-direction: column; position: relative; z-index: 1; }

.topbar {
  display: flex; align-items: center; gap: 16px;
  padding: 18px 26px; border-bottom: 1px solid var(--border);
  background: #0C1018; position: sticky; top: 0; z-index: 40;
}
.topbar-titles { flex: 1; }
.topbar-titles h1 { font-size: 16px; font-weight: 700; }
.topbar-titles p { font-size: 12px; color: var(--text-2); margin-top: 2px; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.badge-year { background: rgba(255,122,26,.12); border: 1px solid var(--border-accent); color: var(--orange-soft); padding: 6px 14px; border-radius: 20px; font-weight: 700; font-size: 13px; }
.hamburger { display: none; background: var(--card); border: 1px solid var(--border); color: #fff; font-size: 18px; border-radius: 8px; padding: 4px 10px; }

/* ============ FILTERS ============ */
.filters-bar {
  display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px;
  padding: 16px 26px; border-bottom: 1px solid var(--border); background: rgba(10,13,19,.6);
}
.filter { display: flex; flex-direction: column; gap: 4px; }
.filter label { font-size: 11px; color: var(--text-mute); text-transform: uppercase; letter-spacing: .5px; }
.filter select, .filter input {
  background: var(--card); border: 1px solid var(--border); color: var(--text);
  border-radius: 9px; padding: 8px 11px; font-size: 13px; min-width: 140px;
}
select:focus, input:focus { outline: none; border-color: var(--orange); box-shadow: 0 0 0 3px rgba(255,122,26,.12); }

/* ============ BUTTONS ============ */
.btn {
  background: linear-gradient(135deg, var(--orange), #ff9533);
  color: #1a0d02; border: none; border-radius: 10px; padding: 9px 16px; font-weight: 600; font-size: 13px;
  transition: transform .1s, box-shadow .15s;
}
.btn:hover { box-shadow: 0 6px 20px rgba(255,122,26,.4); transform: translateY(-1px); }
.btn-ghost { background: var(--card); color: var(--text); border: 1px solid var(--border); }
.btn-ghost:hover { background: var(--card-hi); box-shadow: none; border-color: var(--border-accent); }
.btn-sm { padding: 7px 12px; font-size: 12px; }
.btn-danger { background: var(--card); color: var(--red); border: 1px solid rgba(255,92,92,.4); }
.btn-row { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 8px; }

/* ============ VIEWS / LAYOUT ============ */
.views { padding: 24px 26px 64px; }
.view { display: none; animation: fade .25s ease; }
.view.active { display: block; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.view-head { margin-bottom: 18px; }
.view-head h2 { font-size: 21px; }
.view-head p { color: var(--text-2); font-size: 13px; margin-top: 4px; max-width: 900px; }

.section-title { font-size: 13px; text-transform: uppercase; letter-spacing: .8px; color: var(--text-2); margin: 28px 0 14px; font-weight: 600; }

/* Grids */
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-auto { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
@media (max-width: 1100px){ .grid-4{grid-template-columns:repeat(2,1fr);} .grid-3{grid-template-columns:repeat(2,1fr);} }
@media (max-width: 768px){ .grid-2{grid-template-columns:1fr;} .grid-3,.grid-4{grid-template-columns:1fr 1fr;} }
@media (max-width: 400px){ .grid-3,.grid-4{grid-template-columns:1fr;} }

/* Cards */
.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; box-shadow: 0 8px 22px var(--shadow); transition: border-color .15s, transform .15s; }
.card:hover { border-color: rgba(255,255,255,.12); }
.card-hi { background: var(--card-hi); }

/* KPI cards */
.kpi { position: relative; overflow: hidden; }
.kpi:hover { border-color: var(--border-accent); }
.kpi-top { display: flex; justify-content: space-between; align-items: flex-start; }
.kpi .kpi-label { font-size: 12.5px; color: var(--text-2); }
.kpi .kpi-icon { width: 32px; height: 32px; border-radius: 9px; background: rgba(255,255,255,.04); border: 1px solid var(--border); display: grid; place-items: center; font-size: 15px; }
.kpi .kpi-value { font-size: 26px; font-weight: 700; margin: 8px 0 2px; letter-spacing: -.5px; }
.kpi .kpi-desc { font-size: 11px; color: var(--text-mute); }
.kpi .kpi-delta { font-size: 12px; font-weight: 600; margin-top: 8px; display: inline-block; }
.kpi-spark { margin-top: 12px; height: 34px; }
.kpi-spark svg { width: 100%; height: 34px; display: block; }
.kpi-strip { width: 4px; height: 100%; position: absolute; left: 0; top: 0; }
.up { color: var(--green); } .down { color: var(--red); } .flat { color: var(--text-2); }
.status-pos .kpi-strip { background: var(--green); }
.status-warn .kpi-strip { background: var(--yellow); }
.status-crit .kpi-strip { background: var(--red); }
.status-neutral .kpi-strip { background: var(--orange); }

/* Chart cards */
.chart-card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; box-shadow: 0 8px 22px var(--shadow); }
.chart-card h3 { font-size: 14px; margin-bottom: 14px; font-weight: 600; }
.chart-wrap { position: relative; height: 280px; }
.chart-wrap.tall { height: 360px; }

/* Tables */
.table-card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; overflow: hidden; box-shadow: 0 8px 22px var(--shadow); }
.table-toolbar { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.table-toolbar h3 { font-size: 14px; }
.table-scroll { overflow-x: auto; max-height: 520px; overflow-y: auto; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 12.5px; }
table.tbl th, table.tbl td { padding: 9px 11px; text-align: left; border-bottom: 1px solid rgba(255,255,255,.05); white-space: nowrap; }
table.tbl th { position: sticky; top: 0; background: var(--card-hi); color: var(--text-2); font-weight: 600; cursor: pointer; user-select: none; font-size: 11.5px; text-transform: uppercase; letter-spacing: .4px; }
table.tbl th:hover { color: #fff; }
table.tbl tbody tr:hover { background: rgba(255,122,26,.06); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }

/* Pills / tags */
.pill { padding: 3px 9px; border-radius: 20px; font-size: 11px; font-weight: 600; display: inline-block; }
.pill-A { background: rgba(52,211,153,.15); color: var(--green); }
.pill-B { background: rgba(52,179,201,.15); color: var(--teal); }
.pill-C { background: rgba(251,191,36,.15); color: var(--yellow); }
.pill-D, .pill-E { background: rgba(255,92,92,.15); color: var(--red); }
.pill-crit { background: rgba(255,92,92,.18); color: var(--red); }
.pill-alto { background: rgba(255,122,26,.18); color: var(--orange-soft); }
.pill-medio { background: rgba(251,191,36,.16); color: var(--yellow); }
.pill-baixo { background: rgba(139,149,167,.16); color: var(--text-2); }
.pill-pos { background: rgba(52,211,153,.15); color: var(--green); }
.pill-warn { background: rgba(251,191,36,.16); color: var(--yellow); }

/* Insights */
.insight { border-left: 4px solid var(--orange); }
.insight.warn { border-left-color: var(--yellow); }
.insight.crit { border-left-color: var(--red); }
.insight.ok { border-left-color: var(--green); }
.insight h4 { font-size: 14px; margin-bottom: 6px; }
.insight .num { font-size: 13px; color: var(--orange-soft); font-weight: 700; }
.insight .risk { font-size: 12.5px; color: var(--text-2); margin: 6px 0; }
.insight .act { font-size: 12.5px; }
.insight .act b { color: #fff; }

/* Upload */
.upload-zone {
  border: 1.5px dashed var(--border-accent); border-radius: var(--radius); padding: 30px 20px; text-align: center;
  background: var(--card); transition: border-color .15s, background .15s; cursor: pointer;
}
.upload-zone:hover, .upload-zone.drag { border-color: var(--orange); background: var(--card-hi); }
.upload-zone .uz-ico { font-size: 32px; }
.upload-zone h3 { margin: 8px 0 4px; font-size: 15px; }
.upload-zone p { font-size: 12px; color: var(--text-2); max-width: 420px; margin: 0 auto; }
.upload-zone input[type=file] { display: none; }

.meta-list { list-style: none; font-size: 13px; }
.meta-list li { display: flex; justify-content: space-between; padding: 7px 0; border-bottom: 1px solid rgba(255,255,255,.05); }
.meta-list li span:first-child { color: var(--text-2); }
.meta-list li span:last-child { font-weight: 600; }

/* Validation list */
.valid-list { list-style: none; font-size: 13px; }
.valid-list li { padding: 8px 0; border-bottom: 1px solid rgba(255,255,255,.05); display: flex; gap: 8px; align-items: flex-start; }
.valid-list .vmark { font-size: 14px; }

/* Ranking */
.rank-list { list-style: none; }
.rank-list li { display: flex; align-items: center; gap: 12px; padding: 11px 0; border-bottom: 1px solid rgba(255,255,255,.05); }
.rank-pos { width: 26px; height: 26px; border-radius: 8px; background: rgba(255,122,26,.12); display: grid; place-items: center; font-weight: 700; color: var(--orange-soft); }
.rank-name { flex: 1; font-weight: 600; }
.rank-val { color: var(--text-2); font-size: 12.5px; }

/* Diagnosis tiles */
.diag-tile { display: flex; flex-direction: column; gap: 4px; }
.diag-tile .dt-label { font-size: 11px; text-transform: uppercase; letter-spacing: .5px; color: var(--text-mute); }
.diag-tile .dt-main { font-size: 17px; font-weight: 700; }
.diag-tile .dt-sub { font-size: 12px; color: var(--text-2); }

/* Editable team table inputs */
.tbl input.cell-input { width: 80px; background: var(--bg-2); border: 1px solid var(--border); color: #fff; border-radius: 6px; padding: 5px 7px; text-align: right; }

/* Top Produtos / barras horizontais estilo referência */
.hbar-list { list-style:none; display:flex; flex-direction:column; gap:14px; }
.hbar-row { display:flex; flex-direction:column; gap:5px; }
.hbar-top { display:flex; justify-content:space-between; font-size:12.5px; }
.hbar-track { height:6px; background:rgba(255,255,255,.06); border-radius:6px; overflow:hidden; }
.hbar-fill { height:100%; background:linear-gradient(90deg,var(--orange),#ff9d3c); border-radius:6px; }

/* Toast */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(40px);
  background: var(--card-hi); border: 1px solid var(--border); color: #fff;
  padding: 12px 20px; border-radius: 10px; font-size: 13px; box-shadow: 0 10px 28px var(--shadow);
  opacity: 0; pointer-events: none; transition: opacity .25s, transform .25s; z-index: 100; max-width: 90vw;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.ok { border-color: rgba(52,211,153,.5); }
.toast.err { border-color: rgba(255,92,92,.5); }

.empty-hint { color: var(--text-mute); font-size: 13px; padding: 30px; text-align: center; }
.muted { color: var(--text-2); }
.search-input { background: var(--card); border: 1px solid var(--border); color: #fff; border-radius: 8px; padding: 8px 12px; font-size: 13px; min-width: 240px; }

/* Simulator */
.sim-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin: 10px 0; }
.sim-row label { font-size: 13px; color: var(--text-2); min-width: 220px; }
.sim-row input[type=range] { accent-color: var(--orange); }
.sim-result { font-size: 22px; font-weight: 700; color: var(--green); }

/* Backdrop do menu (mobile) */
.sidebar-backdrop { display: none; }

/* Responsive sidebar */
@media (max-width: 980px){
  .sidebar { transform: translateX(-100%); transition: transform .25s; width: 84%; max-width: 300px; box-shadow: 8px 0 30px rgba(0,0,0,.5); }
  .sidebar.open { transform: none; }
  .main { margin-left: 0; }
  .hamburger { display: inline-block; }
  .topbar-logo { display: block; }
  .sidebar-backdrop { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.55); z-index: 45; opacity: 0; pointer-events: none; transition: opacity .2s; }
  .sidebar-backdrop.show { opacity: 1; pointer-events: auto; }
}

/* Polimento para celular */
@media (max-width: 768px){
  body::before { width: 220px; }
  .views { padding: 16px 13px 56px; }
  .topbar { padding: 12px 14px; gap: 10px; }
  .topbar-titles h1 { font-size: 13px; line-height: 1.15; }
  .topbar-titles p { display: none; }            /* esconde só o subtítulo longo */
  .badge-year { display: none; }
  #btn-print { padding: 8px 11px; font-size: 15px; }
  .topbar-logo { height: 24px; }

  .filters-bar { padding: 12px 13px; gap: 10px; }
  .filter { flex: 1 1 44%; }
  .filter select, .filter input { min-width: 0; width: 100%; }
  #btn-clear-filters { flex: 1 1 100%; }

  .view-head h2 { font-size: 19px; }
  .section-title { margin: 22px 0 12px; }
  .card, .chart-card, .table-card { padding: 14px; }
  .kpi .kpi-value { font-size: 19px; letter-spacing: -.3px; word-break: break-word; }
  .kpi .kpi-icon { width: 28px; height: 28px; font-size: 13px; }
  .kpi-spark { height: 26px; }

  .chart-wrap { height: 240px; }
  .chart-wrap.tall { height: 300px; }

  table.tbl th, table.tbl td { padding: 7px 8px; font-size: 12px; }
  .search-input { min-width: 0; width: 100%; }
  .table-toolbar { gap: 8px; }
  .table-toolbar > div { width: 100%; display: flex; gap: 8px; flex-wrap: wrap; }

  .sim-row label { min-width: 0; flex: 1 1 100%; }
  /* seletores das telas Relatórios/Painel Analítico ocupam a linha toda */
  #rep-tipo, #rep-loja-sel, #an-dim { min-width: 0 !important; width: 100%; }
  .sel-group { flex: 1 1 100%; }
}

/* Print */
@media print {
  body::before { display:none; }
  .sidebar, .filters-bar, .topbar-actions, .hamburger, .btn { display: none !important; }
  .main { margin-left: 0; }
  .view { display: block !important; page-break-after: always; }
  body { background: #fff; color: #000; }
  .card, .chart-card, .table-card { border-color: #ccc; box-shadow: none; }
  /* cabeçalho branco com a logo preto/prata no topo do PDF */
  .topbar { background: #fff !important; border-bottom: 3px solid #FF7A1A !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .topbar-logo { display: none !important; }
  .topbar-logo-dark { display: block !important; }
  .topbar-titles h1 { color: #111; }
  .topbar-titles p { color: #555; }
}
