/* ==========================================================================
   Sistema de Gestão de Poda — Design System
   Paleta: Verde (poda/meio ambiente) + Laranja (energia elétrica)
   HTML5 + CSS3 + Bootstrap 5 (tema/override)
   ========================================================================== */

:root {
  /* Marca */
  --poda-green-900: #0f3d2e;
  --poda-green-800: #14513b;
  --poda-green-700: #1b6b4c;
  --poda-green-600: #22855f;
  --poda-green-500: #2fa172;
  --poda-green-100: #e3f4ec;
  --poda-green-050: #f1faf5;

  --poda-orange-700: #b45309;
  --poda-orange-600: #d97316;
  --poda-orange-500: #f59022;
  --poda-orange-100: #fde6cf;

  --poda-ink: #1f2a26;
  --poda-muted: #64726b;
  --poda-line: #e4e9e6;
  --poda-bg: #f4f7f5;
  --poda-surface: #ffffff;

  /* Bootstrap overrides */
  --bs-primary: var(--poda-green-700);
  --bs-primary-rgb: 27, 107, 76;
  --bs-body-color: var(--poda-ink);
  --bs-body-bg: var(--poda-bg);
  --bs-border-color: var(--poda-line);
  --bs-link-color: var(--poda-green-700);
  --bs-link-hover-color: var(--poda-green-800);

  --poda-radius: .7rem;
  --poda-shadow-sm: 0 1px 2px rgba(16,40,30,.06), 0 1px 3px rgba(16,40,30,.06);
  --poda-shadow: 0 6px 20px rgba(16,40,30,.08);
  --sidebar-w: 264px;
}

* { -webkit-font-smoothing: antialiased; }

body {
  font-family: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  color: var(--poda-ink);
  background: var(--poda-bg);
}

/* ---------- Botões / cores utilitárias ---------- */
.btn-primary {
  --bs-btn-bg: var(--poda-green-700);
  --bs-btn-border-color: var(--poda-green-700);
  --bs-btn-hover-bg: var(--poda-green-800);
  --bs-btn-hover-border-color: var(--poda-green-800);
  --bs-btn-active-bg: var(--poda-green-900);
  --bs-btn-active-border-color: var(--poda-green-900);
  --bs-btn-disabled-bg: var(--poda-green-500);
  --bs-btn-disabled-border-color: var(--poda-green-500);
}
.btn-outline-primary {
  --bs-btn-color: var(--poda-green-700);
  --bs-btn-border-color: var(--poda-green-700);
  --bs-btn-hover-bg: var(--poda-green-700);
  --bs-btn-hover-border-color: var(--poda-green-700);
  --bs-btn-active-bg: var(--poda-green-800);
}
.btn-energy {
  --bs-btn-color: #fff;
  --bs-btn-bg: var(--poda-orange-600);
  --bs-btn-border-color: var(--poda-orange-600);
  --bs-btn-hover-color: #fff;
  --bs-btn-hover-bg: var(--poda-orange-700);
  --bs-btn-hover-border-color: var(--poda-orange-700);
  --bs-btn-active-bg: var(--poda-orange-700);
  --bs-btn-focus-shadow-rgb: 217, 115, 22;
}
.text-primary { color: var(--poda-green-700) !important; }
.text-energy { color: var(--poda-orange-600) !important; }
.bg-brand { background: var(--poda-green-700) !important; }
.bg-brand-soft { background: var(--poda-green-050) !important; }
.link-quiet { color: inherit; text-decoration: none; }
.link-quiet:hover { color: var(--poda-green-700); }

a { text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- Marca / logo ---------- */
.brand {
  display: inline-flex; align-items: center; gap: .55rem;
  font-weight: 700; color: var(--poda-green-800); letter-spacing: -.2px;
}
.brand__mark {
  width: 34px; height: 34px; border-radius: 9px;
  display: grid; place-items: center; color: #fff; flex: 0 0 auto;
  background: linear-gradient(135deg, var(--poda-green-600), var(--poda-green-800));
  position: relative; overflow: hidden;
}
.brand__mark::after {
  content: ""; position: absolute; right: -6px; bottom: -6px;
  width: 16px; height: 16px; border-radius: 50%;
  background: var(--poda-orange-500); box-shadow: 0 0 0 3px rgba(255,255,255,.25);
}
.brand__mark i { font-size: 1.05rem; }

/* ==========================================================================
   ÁREA PÚBLICA (landing)
   ========================================================================== */
.public-nav {
  background: rgba(255,255,255,.92); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--poda-line);
}
.hero {
  background:
    radial-gradient(1100px 480px at 85% -10%, rgba(245,144,34,.12), transparent 60%),
    linear-gradient(180deg, var(--poda-green-050), #ffffff 70%);
  border-bottom: 1px solid var(--poda-line);
}
.hero h1 { font-weight: 800; letter-spacing: -.5px; line-height: 1.08; }
.hero .lead { color: var(--poda-muted); }
.hero-visual {
  background: linear-gradient(135deg, var(--poda-green-700), var(--poda-green-900));
  border-radius: 1.1rem; color: #fff; box-shadow: var(--poda-shadow);
  position: relative; overflow: hidden;
}
.hero-visual .grid-lines {
  position: absolute; inset: 0;
  background-image: linear-gradient(rgba(255,255,255,.06) 1px, transparent 1px),
                    linear-gradient(90deg, rgba(255,255,255,.06) 1px, transparent 1px);
  background-size: 34px 34px;
}
.section { padding: 4.5rem 0; }
.section-eyebrow {
  text-transform: uppercase; letter-spacing: .12em; font-size: .78rem;
  font-weight: 700; color: var(--poda-orange-600);
}
.feature-card, .benefit-card, .step-card {
  background: var(--poda-surface); border: 1px solid var(--poda-line);
  border-radius: var(--poda-radius); height: 100%; transition: .18s ease;
}
.feature-card:hover, .benefit-card:hover { box-shadow: var(--poda-shadow); transform: translateY(-2px); }
.feature-ico {
  width: 46px; height: 46px; border-radius: 11px; display: grid; place-items: center;
  background: var(--poda-green-100); color: var(--poda-green-700); font-size: 1.3rem;
}
.feature-ico.energy { background: var(--poda-orange-100); color: var(--poda-orange-700); }
.step-badge {
  width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center;
  background: var(--poda-green-700); color: #fff; font-weight: 700; flex: 0 0 auto;
}
.footer {
  background: var(--poda-green-900); color: #cfe3d8;
}
.footer a { color: #eaf3ee; }
.footer h6 { color: #fff; }

/* Auth cards */
.auth-wrap {
  min-height: 100vh; display: grid; grid-template-columns: 1.05fr .95fr;
}
.auth-aside {
  background: linear-gradient(150deg, var(--poda-green-800), var(--poda-green-900));
  color: #fff; position: relative; overflow: hidden;
}
.auth-aside .grid-lines {
  position: absolute; inset: 0;
  background-image: linear-gradient(rgba(255,255,255,.05) 1px, transparent 1px),
                    linear-gradient(90deg, rgba(255,255,255,.05) 1px, transparent 1px);
  background-size: 36px 36px;
}
.auth-panel { display: grid; place-items: center; padding: 2rem; }
.auth-card { width: 100%; max-width: 420px; }
.demo-cred {
  border: 1px dashed var(--poda-line); border-radius: .6rem; background: var(--poda-green-050);
  font-size: .85rem;
}
.demo-cred button { font-size: .8rem; }
@media (max-width: 992px) { .auth-wrap { grid-template-columns: 1fr; } .auth-aside { display: none; } }

/* ==========================================================================
   ÁREA AUTENTICADA (layout app)
   ========================================================================== */
.app-layout { min-height: 100vh; }
.app-sidebar {
  position: fixed; top: 0; left: 0; bottom: 0; width: var(--sidebar-w);
  background: var(--poda-green-900); color: #d7e6dd; z-index: 1045;
  display: flex; flex-direction: column; transition: transform .25s ease;
}
.app-sidebar .brand { color: #fff; }
.app-sidebar__head { padding: 1rem 1.1rem; border-bottom: 1px solid rgba(255,255,255,.08); }
.app-sidebar__nav { overflow-y: auto; padding: .75rem .6rem 1.5rem; flex: 1; }
.app-sidebar__nav::-webkit-scrollbar { width: 8px; }
.app-sidebar__nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,.14); border-radius: 8px; }
.nav-group-label {
  font-size: .68rem; text-transform: uppercase; letter-spacing: .1em;
  color: #7fa694; padding: .9rem .8rem .35rem; font-weight: 700;
}
.app-sidebar .nav-link {
  color: #cdded4; border-radius: .5rem; padding: .55rem .8rem; margin-bottom: 2px;
  display: flex; align-items: center; gap: .7rem; font-size: .92rem; font-weight: 500;
}
.app-sidebar .nav-link i { font-size: 1.05rem; width: 20px; text-align: center; color: #8fb6a3; }
.app-sidebar .nav-link:hover { background: rgba(255,255,255,.07); color: #fff; text-decoration: none; }
.app-sidebar .nav-link.active { background: var(--poda-green-700); color: #fff; }
.app-sidebar .nav-link.active i { color: var(--poda-orange-500); }
.app-sidebar .nav-link .badge { margin-left: auto; }

.app-main { margin-left: var(--sidebar-w); display: flex; flex-direction: column; min-height: 100vh; }
.app-topbar {
  position: sticky; top: 0; z-index: 1030; background: var(--poda-surface);
  border-bottom: 1px solid var(--poda-line); padding: .6rem 1.2rem;
  display: flex; align-items: center; gap: 1rem;
}
.app-content { padding: 1.5rem 1.2rem 3rem; flex: 1; }
.app-content .container-fluid { max-width: 1360px; }

.topbar-search { max-width: 380px; flex: 1; }
.topbar-btn {
  border: 1px solid var(--poda-line); background: #fff; width: 40px; height: 40px;
  border-radius: 10px; display: grid; place-items: center; color: var(--poda-muted); position: relative;
}
.topbar-btn:hover { background: var(--poda-green-050); color: var(--poda-green-700); }
.topbar-btn .dot {
  position: absolute; top: 8px; right: 9px; width: 8px; height: 8px; border-radius: 50%;
  background: var(--poda-orange-500); border: 2px solid #fff;
}
.avatar {
  width: 38px; height: 38px; border-radius: 50%; background: var(--poda-green-700);
  color: #fff; display: grid; place-items: center; font-weight: 700; font-size: .9rem; flex: 0 0 auto;
}
.avatar.lg { width: 72px; height: 72px; font-size: 1.5rem; }

.sidebar-backdrop {
  position: fixed; inset: 0; background: rgba(15,40,30,.45); z-index: 1044; display: none;
}

@media (max-width: 991.98px) {
  .app-sidebar { transform: translateX(-100%); }
  .app-sidebar.open { transform: translateX(0); }
  .app-main { margin-left: 0; }
  .sidebar-backdrop.show { display: block; }
}

/* ---------- Componentes ---------- */
.page-head { margin-bottom: 1.25rem; }
.page-head h1 { font-size: 1.5rem; font-weight: 700; margin: 0; letter-spacing: -.3px; }
.breadcrumb { --bs-breadcrumb-divider-color: #9aa8a1; font-size: .82rem; margin-bottom: .35rem; }
.breadcrumb a { color: var(--poda-muted); }

.card { border-color: var(--poda-line); border-radius: var(--poda-radius); box-shadow: var(--poda-shadow-sm); }
.card-header { background: #fff; border-bottom: 1px solid var(--poda-line); font-weight: 600; }

.stat-card { border-radius: var(--poda-radius); border: 1px solid var(--poda-line); background: #fff; }
.stat-card .stat-ico {
  width: 48px; height: 48px; border-radius: 12px; display: grid; place-items: center; font-size: 1.4rem;
}
.stat-card .stat-value { font-size: 1.7rem; font-weight: 800; line-height: 1; letter-spacing: -.5px; }
.stat-card .stat-label { color: var(--poda-muted); font-size: .85rem; }
.tone-green { background: var(--poda-green-100); color: var(--poda-green-700); }
.tone-orange { background: var(--poda-orange-100); color: var(--poda-orange-700); }
.tone-blue { background: #e2edfb; color: #1d4ed8; }
.tone-red { background: #fde3e3; color: #c0392b; }
.tone-gray { background: #eceff0; color: #5b6b64; }

/* Status badges */
.status-badge {
  display: inline-flex; align-items: center; gap: .4rem; font-size: .74rem; font-weight: 600;
  padding: .28rem .6rem; border-radius: 30px; white-space: nowrap; line-height: 1;
}
.status-badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.st-registrada   { background: #eef1f3; color: #5b6b64; }
.st-validacao    { background: #e2edfb; color: #1d4ed8; }
.st-validada     { background: var(--poda-green-100); color: var(--poda-green-700); }
.st-planejamento { background: #efe7fb; color: #6d28d9; }
.st-cronograma   { background: #e6f1fa; color: #0e7490; }
.st-execucao     { background: var(--poda-orange-100); color: var(--poda-orange-700); }
.st-fiscalizacao { background: #fef3c7; color: #a16207; }
.st-retrabalho   { background: #fde3e3; color: #c0392b; }
.st-encerrada    { background: #d9f2e4; color: #14724a; }
.st-indeferida   { background: #eceff0; color: #6b7280; }
.st-vencida      { background: #fde3e3; color: #b91c1c; }

/* ---- Ordens de Serviço: status do ciclo + exceções ---- */
.st-aberta      , .os-aberta      { background:#eef1f3; color:#5b6b64; }
.os-despachada  { background:#e2edfb; color:#1d4ed8; }
.os-aceita      { background:#e6f1fa; color:#0e7490; }
.os-andamento   { background: var(--poda-orange-100); color: var(--poda-orange-700); }
.os-concluida   { background:#fef3c7; color:#a16207; }
.os-finalizada  { background:#d9f2e4; color:#14724a; }
.os-recusada    { background:#fde3e3; color:#c0392b; }
.os-reprovada   { background:#fde3e3; color:#b91c1c; }
.os-cancelada   { background:#eceff0; color:#6b7280; }

.pri-badge { display:inline-flex; align-items:center; gap:.3rem; font-size:.72rem; font-weight:700; padding:.22rem .55rem; border-radius:30px; line-height:1; white-space:nowrap; }
.pri-baixa   { background:#eceff0; color:#5b6b64; }
.pri-normal  { background:#e2edfb; color:#1d4ed8; }
.pri-alta    { background: var(--poda-orange-100); color: var(--poda-orange-700); }
.pri-urgente { background:#fde3e3; color:#b91c1c; box-shadow:0 0 0 2px rgba(185,28,28,.15); }
tr.os-urgent-row { box-shadow: inset 3px 0 0 #b91c1c; }

/* Ciclo (stepper de exceção reaproveita .stepper) */
.excecao-box { border:1px dashed var(--poda-line); border-radius:.6rem; padding:.75rem 1rem; background:#fff8f8; }

/* Kanban simples de despacho */
.kb-col { background:#fff; border:1px solid var(--poda-line); border-radius:.7rem; min-height:120px; }
.kb-col__head { padding:.5rem .75rem; border-bottom:1px solid var(--poda-line); font-weight:600; font-size:.85rem; display:flex; justify-content:space-between; align-items:center; }
.kb-card { border:1px solid var(--poda-line); border-radius:.55rem; padding:.55rem .65rem; margin:.5rem; background:#fff; cursor:pointer; }
.kb-card:hover { box-shadow: var(--poda-shadow-sm); border-color: var(--poda-green-500); }
.kb-card.sel { border-color: var(--poda-green-600); background: var(--poda-green-050); }

/* Marcadores do mapa operacional (Leaflet divIcon) */
.op-pin { border-radius:50%; border:2px solid #fff; box-shadow:0 1px 4px rgba(0,0,0,.3); width:16px; height:16px; }
.op-legend span.dot { width:12px; height:12px; border-radius:50%; display:inline-block; }

/* Construtor de formulários */
.fb-canvas { min-height:340px; }
.fb-field { border:1px solid var(--poda-line); border-radius:.55rem; padding:.6rem .7rem; margin-bottom:.5rem; background:#fff; }
.fb-field.sel { border-color: var(--poda-green-600); box-shadow: var(--poda-shadow-sm); }
.fb-field__grip { cursor:grab; color:#9aa8a1; }
.phone-frame { max-width:320px; margin:0 auto; border:10px solid #1f2a26; border-radius:28px; padding:14px 12px; background:#fff; box-shadow: var(--poda-shadow); }
.phone-frame .ph-note { font-size:.7rem; text-align:center; color:var(--poda-muted); }

.chan-badge { font-size: .72rem; font-weight: 600; padding: .2rem .5rem; border-radius: 6px; }
.chan-cidadao { background: var(--poda-orange-100); color: var(--poda-orange-700); }
.chan-programacao { background: var(--poda-green-100); color: var(--poda-green-700); }
.chan-institucional { background: #e2edfb; color: #1d4ed8; }

.table { --bs-table-hover-bg: var(--poda-green-050); }
.table thead th {
  font-size: .74rem; text-transform: uppercase; letter-spacing: .04em; color: var(--poda-muted);
  border-bottom: 1px solid var(--poda-line); font-weight: 700; white-space: nowrap;
}
.table td { vertical-align: middle; }
th.sortable { cursor: pointer; user-select: none; }
th.sortable:hover { color: var(--poda-green-700); }
th.sortable .bi { opacity: .35; font-size: .7rem; }
th.sortable.asc .bi-arrow-down, th.sortable.desc .bi-arrow-up { display: none; }
th.sortable.asc .bi, th.sortable.desc .bi { opacity: 1; color: var(--poda-green-700); }

.empty-state { text-align: center; padding: 3rem 1rem; color: var(--poda-muted); }
.empty-state .bi { font-size: 2.6rem; color: #c3cec8; }

.timeline { position: relative; padding-left: 1.6rem; }
.timeline::before { content:""; position:absolute; left: 8px; top: 4px; bottom: 4px; width: 2px; background: var(--poda-line); }
.timeline-item { position: relative; padding-bottom: 1.15rem; }
.timeline-item::before {
  content:""; position:absolute; left: -1.6rem; top: 2px; width: 14px; height: 14px; border-radius: 50%;
  background: #fff; border: 3px solid var(--poda-green-600);
}
.timeline-item.is-orange::before { border-color: var(--poda-orange-500); }
.timeline-item.is-red::before { border-color: #c0392b; }
.timeline-item .t-time { font-size: .78rem; color: var(--poda-muted); }

/* Wizard / stepper */
.stepper { display: flex; gap: .25rem; flex-wrap: wrap; }
.stepper .step {
  flex: 1; min-width: 120px; text-align: center; padding: .6rem .4rem; border-radius: .55rem;
  border: 1px solid var(--poda-line); background: #fff; color: var(--poda-muted); font-size: .82rem; font-weight: 600;
}
.stepper .step .n {
  display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 50%;
  background: #eceff0; color: #6b7280; font-size: .78rem; margin-right: .35rem;
}
.stepper .step.active { border-color: var(--poda-green-600); background: var(--poda-green-050); color: var(--poda-green-800); }
.stepper .step.active .n { background: var(--poda-green-700); color: #fff; }
.stepper .step.done { color: var(--poda-green-700); }
.stepper .step.done .n { background: var(--poda-green-600); color: #fff; }

/* Mapa simulado */
.map-sim {
  position: relative; border-radius: var(--poda-radius); overflow: hidden; border: 1px solid var(--poda-line);
  background:
    linear-gradient(rgba(47,161,114,.06) 1px, transparent 1px) 0 0 / 46px 46px,
    linear-gradient(90deg, rgba(47,161,114,.06) 1px, transparent 1px) 0 0 / 46px 46px,
    linear-gradient(120deg, #eef5f0, #e8f1ec);
  min-height: 460px;
}
.map-sim .road { position: absolute; background: #dfe7e2; }
.map-pin {
  position: absolute; transform: translate(-50%,-100%); cursor: pointer; text-align: center;
  color: var(--poda-green-700); transition: .12s;
}
.map-pin i { font-size: 1.7rem; filter: drop-shadow(0 2px 2px rgba(0,0,0,.2)); }
.map-pin:hover { transform: translate(-50%,-108%) scale(1.08); }
.map-pin.p-execucao { color: var(--poda-orange-600); }
.map-pin.p-encerrada { color: var(--poda-green-600); }
.map-pin.p-validacao { color: #1d4ed8; }
.map-pin.p-retrabalho { color: #c0392b; }

.evidence-thumb {
  aspect-ratio: 4/3; border-radius: .5rem; border: 1px solid var(--poda-line); overflow: hidden;
  display: grid; place-items: center; background: var(--poda-green-050); color: var(--poda-green-600);
  position: relative; cursor: pointer; transition: .15s;
}
.evidence-thumb:hover { box-shadow: var(--poda-shadow); }
.evidence-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.evidence-thumb .cap { position: absolute; bottom: 0; left: 0; right: 0; background: rgba(15,40,30,.72);
  color: #fff; font-size: .68rem; padding: .2rem .4rem; z-index: 1; }
.evidence-thumb .cap i { margin-right: .2rem; }

.notif-item { display: flex; gap: .7rem; padding: .7rem .9rem; border-bottom: 1px solid var(--poda-line); }
.notif-item.unread { background: var(--poda-green-050); }
.notif-ico { width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center; flex:0 0 auto; }

.form-label { font-weight: 600; font-size: .86rem; color: #3a4a43; }
.form-text { font-size: .78rem; }
.required::after { content: " *"; color: #c0392b; }

.help-fab { border-radius: 30px; }
kbd { background: #2c3a34; }

@media print {
  .app-sidebar, .app-topbar, .no-print { display: none !important; }
  .app-main { margin-left: 0; }
}
