/* Plataforma Luxia — Estilos Globais */
:root {
  --navy:  #1B3A6B;
  --gold:  #D4AF37;
  --light: #F0F4FA;
  --white: #FFFFFF;
  --danger: #C00000;
  --muted: #6c757d;

  /* Tokens semanticos (mudam com o tema) */
  --bg-page:     #F0F4FA;
  --bg-surface:  #FFFFFF;
  --bg-elevated: #F8FAFD;
  --text-primary:   #1A1A1A;
  --text-secondary: #444444;
  --text-muted:     #6c757d;
  --border-default: rgba(27,58,107,.12);
  --table-stripe:   rgba(27,58,107,.05);
}

/* ─── Tema escuro ─────────────────────────────────── */
html[data-bs-theme="dark"] {
  --bg-page:     #0f1419;
  --bg-surface:  #1a2332;
  --bg-elevated: #243044;
  --text-primary:   #e8eaed;
  --text-secondary: #b6bcc6;
  --text-muted:     #8a93a3;
  --border-default: rgba(255,255,255,.10);
  --table-stripe:   rgba(255,255,255,.04);
}

/* ─── Geral ─────────────────────────────────────── */
body {
  background: var(--bg-page);
  color: var(--text-primary);
  font-family: 'Segoe UI', system-ui, sans-serif;
  min-height: 100vh;
}



/* ─── Navbar ─────────────────────────────────────── */
.navbar-luxia {
  background: var(--navy);
  border-bottom: 3px solid var(--gold);
  padding: 0 1.25rem;
  min-height: 58px;
  width: 100%;
}
/* Navbar brand — mesmo padrão visual do Módulo 1 */
.navbar-luxia .navbar-brand {
  background: transparent;
  border-radius: 0;
  padding: 0;
  box-shadow: none;
  display: flex;
  align-items: center;
  gap: .65rem;
  text-decoration: none;
}
.navbar-luxia .navbar-brand:hover { box-shadow: none; }
/* Caixa branca que envolve apenas a logo */
.navbar-logo-box {
  background: #ffffff;
  border-radius: 6px;
  padding: 3px 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 1px 6px rgba(0,0,0,.25);
  transition: box-shadow .2s;
}
.navbar-logo-box:hover { box-shadow: 0 2px 10px rgba(0,0,0,.35); }
.navbar-logo-img { height: 28px; width: auto; display: block; max-width: 130px; object-fit: contain; }
/* Texto ao lado da logo */
.navbar-platform-wrap { display: flex; flex-direction: column; line-height: 1.15; }
.navbar-platform-supra { font-size: .6rem; opacity: .65; letter-spacing: .1em; text-transform: uppercase; color: #fff; }
.navbar-platform-title { font-size: .85rem; font-weight: 700; color: #fff; }
.navbar-luxia .nav-link { color: rgba(255,255,255,.82) !important; font-size: .88rem; padding: .6rem .9rem; }
.navbar-luxia .nav-link:hover,
.navbar-luxia .nav-link.active { color: var(--gold) !important; }
.navbar-luxia .navbar-toggler { border-color: rgba(255,255,255,.3); }

/* Logo na sidebar */
.sidebar-logo-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  background: #ffffff;
  border-radius: 8px;
  padding: 5px 12px;
  margin: 0 12px 4px;
  box-shadow: 0 1px 6px rgba(0,0,0,0.20);
}
.sidebar-logo-wrap img { height: 42px; width: auto; display: block; }

/* ─── Sidebar (modulos) ─────────────────────────── */
.sidebar {
  min-height: calc(100vh - 61px);
  background: var(--navy);
  border-right: 1px solid rgba(255,255,255,.08);
  padding-top: 1rem;
  min-width: 210px;
}
.sidebar .nav-link {
  color: rgba(255,255,255,.75);
  padding: .55rem 1.2rem;
  font-size: .85rem;
  border-radius: 0;
  display: flex;
  align-items: center;
  gap: .55rem;
  transition: background .15s;
}
.sidebar .nav-link:hover { background: rgba(255,255,255,.08); color: #fff; }
.sidebar .nav-link.active { background: rgba(212,175,55,.15); color: var(--gold); border-left: 3px solid var(--gold); }
.sidebar .sidebar-section {
  font-size: .7rem;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: rgba(255,255,255,.35);
  padding: 1.1rem 1.2rem .3rem;
}

/* ─── Cards ──────────────────────────────────────── */
.card { border: none; border-radius: .6rem; box-shadow: 0 1px 6px rgba(27,58,107,.1); }
.card-header.bg-navy { background: var(--navy) !important; }

/* ─── KPI Cards ──────────────────────────────────── */
/* Dois padroes:
   1) .kpi-stat — cartao branco com borda colorida a esquerda (para
                  dashboards de Analytics, CMMS, SST, Cliente)
   2) .kpi-card — cartao com gradiente colorido (Propostas, OM)
   Ambos garantem altura uniforme e tipografia consistente.
*/

/* ── Padrao 1: claro com borda colorida ── */
.kpi-stat {
  background: var(--bg-surface, #fff);
  border-radius: .55rem;
  padding: .9rem 1rem;
  border-left: 4px solid #6c757d;
  box-shadow: 0 1px 6px rgba(27,58,107,.08);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 118px;
  gap: .15rem;
}
.kpi-stat .kpi-label {
  font-size: .78rem;
  color: var(--text-muted, #6c757d);
  display: flex; align-items: center; gap: .35rem;
  min-height: 1.1rem;
  font-weight: 500;
}
.kpi-stat .kpi-value {
  font-size: 1.85rem;
  font-weight: 700;
  color: var(--navy);
  line-height: 1.1;
  display: flex;
  align-items: baseline;
  gap: .25rem;
  white-space: nowrap;
}
.kpi-stat .kpi-value .kpi-unit {
  font-size: .85rem;
  color: var(--text-muted, #6c757d);
  font-weight: 500;
}
.kpi-stat .kpi-meta {
  font-size: .72rem;
  color: var(--text-muted, #6c757d);
  min-height: 1rem;
}
.kpi-stat .kpi-empty { color: #adb5bd; }
@media (max-width: 575.98px) {
  .kpi-stat { min-height: 96px; padding: .7rem .85rem; }
  .kpi-stat .kpi-value { font-size: 1.45rem; }
}
/* Variantes de cor (apenas a borda esquerda) */
.kpi-stat.kpi-primary { border-left-color: #1B3A6B; }
.kpi-stat.kpi-info    { border-left-color: #0dcaf0; }
.kpi-stat.kpi-success { border-left-color: #2e7d32; }
.kpi-stat.kpi-warning { border-left-color: #ffb300; }
.kpi-stat.kpi-danger  { border-left-color: #c00000; }
.kpi-stat.kpi-gold    { border-left-color: #D4AF37; }
.kpi-stat.kpi-muted   { border-left-color: #adb5bd; }

/* ── Padrao 2: gradiente colorido (usar SOMENTE em .kpi-card) ── */
.kpi-card {
  position: relative;
  border-radius: .6rem;
  padding: 1.1rem 1.4rem;
  color: #fff;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: .2rem;
  min-height: 118px;
  box-shadow: 0 2px 8px rgba(0,0,0,.15);
}
.kpi-card .kpi-value { font-size: 1.85rem; font-weight: 700; line-height: 1.1; }
.kpi-card .kpi-label { font-size: .78rem; opacity: .85; font-weight: 500; }
.kpi-card .kpi-icon  { font-size: 1.6rem; opacity: .3; position: absolute; right: 1rem; top: 1rem; }
/* Variantes coloridas — escopadas em .kpi-card para nao "vazar" no .kpi-stat */
.kpi-card.kpi-navy   { background: linear-gradient(135deg, var(--navy), #2a5298); }
.kpi-card.kpi-gold   { background: linear-gradient(135deg, #b8860b, var(--gold)); color: #1a1a1a; }
.kpi-card.kpi-danger { background: linear-gradient(135deg, #c00000, #e53935); }
.kpi-card.kpi-green  { background: linear-gradient(135deg, #1b6e35, #2e7d32); }
.kpi-card.kpi-blue   { background: linear-gradient(135deg, #0d47a1, #1976d2); }

/* ─── Cores de texto ────────────────────────────── */
.text-navy { color: var(--navy) !important; }
.text-gold { color: var(--gold) !important; }
.bg-navy   { background-color: var(--navy) !important; }
.bg-gold   { background-color: var(--gold) !important; }

/* ─── Badges de severidade ──────────────────────── */
.badge-critica { background: #C00000; color: #fff; }
.badge-alta    { background: #DC6400; color: #fff; }
.badge-media   { background: #0052A5; color: #fff; }
.badge-baixa   { background: #1B6E35; color: #fff; }

/* ─── Tabelas ────────────────────────────────────── */
.table thead th { background: var(--navy); color: #fff; font-size: .82rem; white-space: nowrap; }
.table tbody tr:hover { background: rgba(27,58,107,.05); }
.table td { font-size: .83rem; vertical-align: middle; }

/* ─── Login ──────────────────────────────────────── */
.login-wrapper {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #0d1f3c 60%, #1B3A6B 100%);
}
.login-box {
  background: #fff;
  border-radius: 1rem;
  padding: 2.5rem 2rem;
  width: 100%;
  max-width: 400px;
  box-shadow: 0 8px 40px rgba(0,0,0,.35);
}
.login-box .logo-wrap {
  display: flex;
  justify-content: center;
  margin-bottom: 1.8rem;
}
.login-box .logo-wrap .login-logo-img {
  height: 72px;
  width: auto;
  display: block;
  background: #ffffff;
  border-radius: 10px;
  padding: 6px 16px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.13);
}
.login-box h4 { color: var(--navy); font-weight: 700; text-align: center; margin-bottom: 1.5rem; }

/* ─── Hub cards (modulos) ────────────────────────── */
.modulo-card {
  border-radius: .75rem;
  border: none;
  cursor: pointer;
  transition: transform .18s, box-shadow .18s;
  text-decoration: none;
  color: inherit;
  display: block;
  height: 100%;
}
.modulo-card:hover { transform: translateY(-4px); box-shadow: 0 8px 24px rgba(27,58,107,.18); }
.modulo-card .modulo-icon {
  font-size: 2.8rem;
  margin-bottom: .7rem;
}
.modulo-card .modulo-num {
  font-size: .72rem;
  text-transform: uppercase;
  letter-spacing: .1em;
  opacity: .6;
  margin-bottom: .2rem;
}
.modulo-card .modulo-title { font-size: 1.15rem; font-weight: 700; }
.modulo-card .modulo-desc  { font-size: .82rem; opacity: .75; margin-top: .4rem; }
.modulo-disabled { opacity: .55; cursor: not-allowed; }
.modulo-disabled:hover { transform: none; box-shadow: none; }

/* ─── Status OS ──────────────────────────────────── */
.status-dot {
  display: inline-block;
  width: 9px; height: 9px;
  border-radius: 50%;
  margin-right: 5px;
}

/* ─── Scrollbar ──────────────────────────────────── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-thumb { background: rgba(27,58,107,.25); border-radius: 3px; }

/* ─── Botoes ─────────────────────────────────────── */
.btn-navy {
  background: var(--navy);
  color: #fff;
  border: none;
}
.btn-navy:hover { background: #14305c; color: #fff; }
.btn-gold {
  background: var(--gold);
  color: #1a1a1a;
  border: none;
  font-weight: 600;
}
.btn-gold:hover { background: #b8960b; color: #1a1a1a; }

/* ─── Form labels ────────────────────────────────── */
label.form-label { font-size: .83rem; font-weight: 600; color: #444; margin-bottom: .25rem; }

/* ─── Offcanvas Sidebar Mobile ───────────────────── */
.offcanvas-sidebar {
  background: var(--navy);
  width: 240px !important;
}
.offcanvas-sidebar .sidebar-section {
  font-size: .7rem;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: rgba(255,255,255,.35);
  padding: 1.1rem 1.2rem .3rem;
}
.offcanvas-sidebar .nav-link {
  color: rgba(255,255,255,.75);
  padding: .55rem 1.2rem;
  font-size: .88rem;
  display: flex;
  align-items: center;
  gap: .55rem;
}
.offcanvas-sidebar .nav-link:hover,
.offcanvas-sidebar .nav-link.active {
  background: rgba(212,175,55,.15);
  color: var(--gold);
}

/* Username truncado na navbar */
.nav-username {
  display: inline-block;
  max-width: 110px;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  vertical-align: middle;
}

/* ─── Layout body height ─────────────────────────── */
.layout-body {
  min-height: calc(100vh - 58px);
}
@media (max-width: 576px) {
  .layout-body { min-height: calc(100vh - 50px); }
}

/* ─── Responsive ─────────────────────────────────── */
@media (max-width: 991px) {
  /* Padding reduzido em TODOS os containers com px-4 / py-4 */
  .container-fluid.px-4,
  .container-fluid.px-md-4 { padding-left: .85rem !important; padding-right: .85rem !important; }
  .container-fluid.py-4,
  .container-fluid.py-md-4 { padding-top: .85rem !important; padding-bottom: .85rem !important; }

  /* Largura maxima garantida */
  .container-fluid { max-width: 100% !important; }

  /* Tabelas: sem nowrap forcado, scroll horizontal */
  .table thead th { white-space: normal; font-size: .75rem; padding: .4rem .5rem; }
  .table td       { font-size: .78rem; padding: .4rem .5rem; }

  /* Card headers que cortavam conteudo */
  .card-header { flex-wrap: wrap !important; gap: .4rem; font-size: .82rem; }
  .card-header .badge { font-size: .65rem !important; }

  /* Titulos de pagina */
  h3.fw-bold { font-size: 1.05rem; }
  h4.fw-bold { font-size: .95rem; }

  /* KPI cards */
  .kpi-card .kpi-value { font-size: 1.6rem; }

  /* Botoes em headers */
  .card-header .btn, .d-flex .btn { font-size: .75rem; padding: .3rem .65rem; }

  /* Badges menores */
  .badge { font-size: .68rem; }

  /* Formularios */
  .form-label { font-size: .78rem; }
  .form-control, .form-select { font-size: .85rem; }

  /* Esconde colunas menos criticas em telas pequenas */
  .col-mobile-hide { display: none !important; }

  /* Sticky footer do checklist — menor no mobile */
  .sticky-footer { padding: .5rem 1rem; }
}

/* ─── Overrides do tema ESCURO ─────────────────────────────────── */
html[data-bs-theme="dark"] .card {
  background-color: var(--bg-surface);
  color: var(--text-primary);
  box-shadow: 0 1px 6px rgba(0,0,0,.4);
}
html[data-bs-theme="dark"] .card-header.bg-white,
html[data-bs-theme="dark"] .card-header.bg-light,
html[data-bs-theme="dark"] .table-light {
  background-color: var(--bg-elevated) !important;
  color: var(--text-primary) !important;
}
html[data-bs-theme="dark"] .table {
  --bs-table-bg: var(--bg-surface);
  --bs-table-color: var(--text-primary);
  --bs-table-striped-bg: var(--table-stripe);
  --bs-table-hover-bg: rgba(212,175,55,.08);
  --bs-table-hover-color: var(--text-primary);
  --bs-table-border-color: var(--border-default);
}
html[data-bs-theme="dark"] .table tbody tr:hover { background: var(--table-stripe); }
html[data-bs-theme="dark"] .text-navy { color: #88a8d5 !important; }
html[data-bs-theme="dark"] .text-muted,
html[data-bs-theme="dark"] .text-secondary { color: var(--text-muted) !important; }
html[data-bs-theme="dark"] label.form-label { color: var(--text-secondary); }
html[data-bs-theme="dark"] .form-control,
html[data-bs-theme="dark"] .form-select {
  background-color: var(--bg-elevated);
  color: var(--text-primary);
  border-color: var(--border-default);
}
html[data-bs-theme="dark"] .form-control:focus,
html[data-bs-theme="dark"] .form-select:focus {
  background-color: var(--bg-elevated);
  color: var(--text-primary);
}
html[data-bs-theme="dark"] .form-control::placeholder { color: var(--text-muted); }
html[data-bs-theme="dark"] .dropdown-menu {
  background-color: var(--bg-elevated);
  border-color: var(--border-default);
}
html[data-bs-theme="dark"] .dropdown-item { color: var(--text-primary); }
html[data-bs-theme="dark"] .dropdown-item:hover,
html[data-bs-theme="dark"] .dropdown-item:focus {
  background-color: rgba(212,175,55,.12);
  color: var(--gold);
}
html[data-bs-theme="dark"] .modal-content { background-color: var(--bg-surface); color: var(--text-primary); }
html[data-bs-theme="dark"] .border-top,
html[data-bs-theme="dark"] .border-bottom,
html[data-bs-theme="dark"] .border { border-color: var(--border-default) !important; }
html[data-bs-theme="dark"] .bg-white,
html[data-bs-theme="dark"] .bg-light { background-color: var(--bg-surface) !important; color: var(--text-primary); }
html[data-bs-theme="dark"] .kpi-card { box-shadow: 0 2px 12px rgba(0,0,0,.5); }
html[data-bs-theme="dark"] .login-box { background: var(--bg-surface); color: var(--text-primary); }
html[data-bs-theme="dark"] .login-box h4 { color: #88a8d5; }
html[data-bs-theme="dark"] ::-webkit-scrollbar-thumb { background: rgba(255,255,255,.18); }
html[data-bs-theme="dark"] .badge.bg-warning.text-dark { color: #1a1a1a !important; }

@media (max-width: 576px) {
  /* Navbar mais compacta */
  .navbar-logo-img { height: 22px; }
  .navbar-logo-box { padding: 2px 7px; }
  .navbar-luxia    { min-height: 50px; }

  /* Topo das paginas — empilhar no mobile */
  .d-flex.align-items-center.justify-content-between.mb-3,
  .d-flex.align-items-center.justify-content-between.mb-4 {
    flex-direction: column;
    align-items: flex-start !important;
    gap: .5rem;
  }

  /* Textos menores */
  .small { font-size: .72rem; }

  /* Paginas com max-width fixo (ex: parametros) — full width no mobile */
  .container-fluid[style*="max-width"] {
    max-width: 100% !important;
    padding-left: .75rem !important;
    padding-right: .75rem !important;
    padding-top: .75rem !important;
  }
}
