/* ═══════════════════════════════════════════════════════════
   MCInfortec Portal — v2.3 Styles
   Barra lateral com grupos por área e perfil
═══════════════════════════════════════════════════════════ */
:root {
  --red:    #d71920;
  --red-d:  #a8141a;
  --dark:   #07090d;
  --card:   #fff;
  --text:   #10131a;
  --muted:  #6b7280;
  --line:   #e5e7eb;
  --side:   #0b0f17;

  /* Cores dos grupos do menu */
  --g-adm:  #3b82f6;   /* azul  — Administrativo */
  --g-adm-bg: #1e3a5f;
  --g-op:   #f59e0b;   /* âmbar — Operacional    */
  --g-op-bg:  #3d2e0f;
  --g-obra: #22c55e;   /* verde — Obra/Campo      */
  --g-obra-bg:#0f3320;
  --g-sys:  #8b5cf6;   /* roxo  — Sistema         */
  --g-sys-bg: #2d1b69;
}

*   { box-sizing: border-box; }
body { margin: 0; font-family: 'Figtree', Inter, Arial, sans-serif; background: #0a0d13; color: #1F2937; }

/* ── Utilitários ─────────────────────────────────────────── */
.hidden { display: none !important; }

/* ══════════════════════════════════════════════════════════
   LOGIN
══════════════════════════════════════════════════════════ */
.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background: radial-gradient(circle at top left, #2a0b0e, #05070b 45%, #000);
  position: relative;
  overflow: hidden;
}
.bg-orb { position: absolute; border-radius: 50%; filter: blur(30px); opacity: .35; }
.orb-1  { width: 320px; height: 320px; background: var(--red); left: -80px; top: -80px; }
.orb-2  { width: 260px; height: 260px; background: #fff; right: -80px; bottom: -80px; opacity: .08; }

.login-card {
  width: min(430px, 92vw);
  background: #fff;
  border-radius: 28px;
  padding: 30px;
  box-shadow: 0 30px 90px #0008;
}
.logo-box {
  background: #fff;
  border-radius: 22px;
  padding: 18px;
  margin-bottom: 10px;
  border: 1px solid #f1f1f1;
  text-align: center;
}
.logo-box img { max-width: 250px; max-height: 105px; object-fit: contain; }
h1, h2, h3 { margin: 0; }
h1 { font-size: 25px; }
label { display: block; margin-top: 18px; font-weight: 700; font-size: 13px; }
input, select {
  width: 100%; padding: 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  font-size: 15px;
  margin-top: 7px;
}
.error  { color: #b91c1c; margin-top: 12px; min-height: 18px; font-weight: 700; }
.muted  { color: var(--muted); margin: 6px 0 0; }
.hint   { margin-top: 16px; color: #6b7280; font-size: 13px; }

/* ── Botões ──────────────────────────────────────────────── */
.btn {
  border: 0;
  border-radius: 14px;
  padding: 12px 16px;
  font-weight: 800;
  cursor: pointer;
  background: #f3f4f6;
  color: #111;
}
.primary { background: #C0181F; color: white; }
.danger  { background: #991b1b;       color: #fff;  }
.ghost   { background: #151b26;       color: #fff;  border: 1px solid #263044; }
.full    { width: 100%; margin-top: 20px; }

/* ══════════════════════════════════════════════════════════
   APP SHELL
══════════════════════════════════════════════════════════ */
.app {
  height: 100vh;
  display: grid;
  grid-template-columns: 270px 1fr;
}

/* ══════════════════════════════════════════════════════════
   SIDEBAR
══════════════════════════════════════════════════════════ */
.sidebar {
  background: linear-gradient(180deg, #111827, #05070b);
  color: #fff;
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: #263044 transparent;
}
.sidebar::-webkit-scrollbar       { width: 4px; }
.sidebar::-webkit-scrollbar-thumb { background: #263044; border-radius: 4px; }

/* Brand / Logo */
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-bottom: 10px;
  border-bottom: 1px solid #1f2937;
}
.brand img {
  width: 56px; height: 44px;
  object-fit: contain;
  background: white;
  border-radius: 10px;
  padding: 5px;
  flex-shrink: 0;
}
.brand b    { font-size: 14px; display: block; color: #E2E4E8; }
.brand span { display: block; color: #9CA3AF; font-size: 11px; }

/* Userbox */
.userbox {
  border: 1px solid #273244;
  background: #111827;
  border-radius: 12px;
  padding: 10px 12px;
}
.userbox span  { display: block; font-weight: 800; font-size: 14px; color: #E2E4E8; }
.userbox small { color: #9CA3AF; font-size: 11px; }

/* ── Grupos do menu ──────────────────────────────────────── */
nav { display: flex; flex-direction: column; gap: 4px; flex: 1; }

/* Cabeçalho do grupo */
.menu-group {
  margin-top: 6px;
}
.menu-group:first-child { margin-top: 0; }

.menu-group-header {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 5px 8px 5px 10px;
  font-size: 9.5px;
  font-weight: 800;
  letter-spacing: .12em;
  text-transform: uppercase;
  border-radius: 8px 8px 0 0;
  margin-bottom: 3px;
  user-select: none;
  cursor: pointer;
}
.menu-group-header .g-arrow {
  margin-left: auto;
  font-size: 10px;
  transition: transform .2s;
}
.menu-group.collapsed .g-arrow { transform: rotate(-90deg); }
.menu-group.collapsed .menu-group-items { display: none; }

/* Cores dos grupos */
.menu-group-header.adm  { color: var(--g-adm);  background: var(--g-adm-bg);  }
.menu-group-header.op   { color: var(--g-op);   background: var(--g-op-bg);   }
.menu-group-header.obra { color: var(--g-obra); background: var(--g-obra-bg); }
.menu-group-header.sys  { color: var(--g-sys);  background: var(--g-sys-bg);  }

/* Linha lateral colorida nos itens do grupo */
.menu-group-items {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding-left: 6px;
  border-left: 2px solid;
  margin-left: 6px;
  margin-bottom: 4px;
}
.menu-group.adm  .menu-group-items { border-color: var(--g-adm);  }
.menu-group.op   .menu-group-items { border-color: var(--g-op);   }
.menu-group.obra .menu-group-items { border-color: var(--g-obra); }
.menu-group.sys  .menu-group-items { border-color: var(--g-sys);  }

/* Botões do menu */
nav button {
  width: 100%;
  text-align: left;
  background: transparent;
  color: #D1D5DB;
  border: 1px solid transparent;
  border-radius: 9px;
  padding: 9px 10px;
  cursor: pointer;
  font-weight: 600;
  font-size: 13px;
  transition: all .15s;
}
nav button:hover {
  background: #1f2937;
  border-color: #374151;
  color: #fff;
}
nav button.active {
  background: #1f2937;
  border-color: #374151;
  color: #fff;
}

/* Badge de contagem */
.menu-badge {
  display: inline-block;
  background: var(--red);
  color: #fff;
  font-size: 10px;
  font-weight: 800;
  padding: 1px 6px;
  border-radius: 99px;
  margin-left: 6px;
  vertical-align: middle;
}

/* Botão Início (sem grupo) */
.menu-btn-inicio {
  background: #1a2235 !important;
  border-color: #263044 !important;
  color: #e2e8f0 !important;
  font-weight: 700 !important;
  margin-bottom: 6px;
}
.menu-btn-inicio:hover {
  background: #1f2937 !important;
  color: #fff !important;
}

/* Botão Sair */
.btn-sair {
  background: #1a0a0a;
  color: #f87171;
  border: 1px solid #3d1a1a;
  border-radius: 12px;
  padding: 10px;
  font-weight: 700;
  cursor: pointer;
  font-size: 13px;
  text-align: center;
  width: 100%;
  margin-top: auto;
  transition: all .15s;
}
.btn-sair:hover { background: #991b1b; color: #fff; border-color: transparent; }

/* ══════════════════════════════════════════════════════════
   MAIN CONTENT
══════════════════════════════════════════════════════════ */
.main {
  background: #0F1117;
  min-width: 0;
  display: flex;
  flex-direction: column;
}
.topbar {
  height: 86px;
  background: #ffffff;
  border-bottom: 1px solid #E5E7EB;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
}
.content { padding: 24px; overflow: auto; background: #0F1117; }

/* ── Grid de cards ───────────────────────────────────────── */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 16px; }

/* Grupo de cards na home */
.cards-group { margin-bottom: 28px; }
.cards-group-title {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .1em;
  text-transform: uppercase;
  margin-bottom: 12px;
  padding: 6px 12px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.cards-group-title.adm  { color: #60A5FA; background: rgba(96,165,250,.12); }
.cards-group-title.op   { color: #FBBF24; background: rgba(251,191,36,.12); }
.cards-group-title.obra { color: #34D399; background: rgba(52,211,153,.12); }
.cards-group-title.sys  { color: #818CF8; background: rgba(129,140,248,.12); }

.card {
  background: #181C25;
  border: 1px solid rgba(255,255,255,.07);
  border-radius: 20px;
  padding: 20px;
  box-shadow: 0 4px 18px rgba(0,0,0,.4);
}
.card .icon { font-size: 30px; }
.card h3    { margin-top: 8px; font-size: 15px; color: #E8EAF0; }
.card p     { color: #8B92A8; font-size: 13px; min-height: 38px; margin-top: 6px; }

/* Borda lateral colorida nos cards por grupo */
.card.adm  { border-left: 3px solid #60A5FA; }
.card.op   { border-left: 3px solid #FBBF24; }
.card.obra { border-left: 3px solid #34D399; }

/* ── Tabela ───────────────────────────────────────────────── */
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.table { width: 100%; border-collapse: collapse; background: #181C25; border-radius: 16px; overflow: hidden; }
.table th, .table td { padding: 12px; border-bottom: 1px solid rgba(255,255,255,.07); text-align: left; font-size: 14px; color: #E8EAF0; }
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; margin: 14px 0; }

/* ── Iframe do módulo ────────────────────────────────────── */
.module-frame { width: 100%; height: calc(100vh - 86px); border: 0; background: #fff; }

/* ── Pill ─────────────────────────────────────────────────── */
.pill {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 99px;
  background: #fee2e2;
  color: #991b1b;
  font-size: 11px;
  font-weight: 800;
  margin: 2px;
}

/* ══════════════════════════════════════════════════════════
   MOBILE
══════════════════════════════════════════════════════════ */
@media (max-width: 800px) {
  .app { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .sidebar {
    height: auto;
    max-height: 50vh;
    overflow-y: auto;
    position: relative;
  }
  .row          { grid-template-columns: 1fr; }
  .topbar       { height: auto; padding: 16px; align-items: flex-start; }
  .module-frame { height: 70vh; }
}
/* Modulo-placeholder (icone p/módulos sem imagem) */
.modulo-placeholder {
  width:64px;height:64px;border-radius:14px;
  background:#f3f4f6;display:flex;align-items:center;
  justify-content:center;font-size:28px;
}
/* Icone picker */
.icone { font-size:20px; }

/* ══════════════════════════════════════════════════════════
   REFINAMENTOS v3.0 — Padronização visual unificada
══════════════════════════════════════════════════════════ */
@import url('https://fonts.googleapis.com/css2?family=Figtree:wght@400;500;600;700;800;900&display=swap');

:root {
  --mci-font: 'Figtree', system-ui, -apple-system, sans-serif;
}

body, button, input, select, textarea {
  font-family: var(--mci-font) !important;
}

/* ── Topbar aprimorada ──────────────────────────────────── */
.topbar {
  background: #ffffff;
  border-bottom: 1px solid rgba(0,0,0,.08);
  box-shadow: 0 1px 0 rgba(0,0,0,.05), 0 4px 12px rgba(0,0,0,.04);
  height: 68px;
  padding: 0 28px;
}
.topbar h2 { font-size: 18px; font-weight: 800; letter-spacing: -.02em; }
.topbar .muted { font-size: 12px; }

/* ── Cards da home refinados ────────────────────────────── */
.card {
  border-radius: 18px;
  transition: box-shadow .18s, transform .18s;
  cursor: pointer;
}
.card:hover {
  box-shadow: 0 8px 28px rgba(0,0,0,.12);
  transform: translateY(-2px);
}
.card h3 { font-size: 14px; font-weight: 700; letter-spacing: -.01em; }

/* ── Botões do portal unificados com módulos ────────────── */
.btn {
  font-family: var(--mci-font) !important;
  font-weight: 700 !important;
  letter-spacing: -.01em;
  transition: all .14s ease;
}
.btn.primary {
  background: #C0181F;
  color: #fff;
  border-radius: 10px;
  box-shadow: 0 2px 8px rgba(192,24,31,.25);
}
.btn.primary:hover { background: #8B0E13; }
.btn.ghost {
  background: rgba(255,255,255,.07);
  border: 1px solid rgba(255,255,255,.13);
  border-radius: 10px;
  color: #e2e8f0;
}
.btn.ghost:hover { background: rgba(255,255,255,.12); }

/* ── Login refinado ─────────────────────────────────────── */
.login-card { border-radius: 24px; }
.login-card h1 { font-size: 22px; font-weight: 800; letter-spacing: -.02em; }
input, select {
  border-radius: 10px !important;
  font-family: var(--mci-font) !important;
}
input:focus, select:focus {
  border-color: #C0181F !important;
  box-shadow: 0 0 0 3px rgba(192,24,31,.12) !important;
  outline: none;
}

/* ── Sidebar brand aprimorada ───────────────────────────── */
.brand img {
  width: 48px; height: 38px;
  padding: 4px;
  border-radius: 10px;
  background: #fff;
}
.brand b    { font-size: 13px; font-weight: 800; letter-spacing: -.01em; color: #E2E4E8; }

/* ── Scrollbar do sidebar ───────────────────────────────── */
.sidebar::-webkit-scrollbar { width: 3px; }
.sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,.15); }

/* ── Main area ──────────────────────────────────────────── */
.main { background: #F2F3F7; }
.content { padding: 22px 28px; }

/* ── Cards de módulos agrupados ──────────────────────────── */
.cards-group-title { font-weight: 800; letter-spacing: .08em; border-radius: 8px; }

/* ── Scrollbar global ───────────────────────────────────── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(0,0,0,.15); border-radius: 99px; }

/* ── Dark mode overrides for portal main content ─────────── */
#pageTitle { color: #1F2937 !important; }
#pageSub   { color: #6B7280 !important; }
#userName  { color: #E8EAF0 !important; }
.top-actions .btn { background: #F3F4F6; color: #374151; border: 1px solid #E5E7EB; }
.top-actions .btn:hover { background: #E5E7EB; color: #111827; }

/* Admin sections background */
#adminUsers, #adminModules, #home { background: #0F1117; }
.content h3  { color: #E8EAF0; }
.content label { color: #8B92A8; }
.content input, .content select, .content textarea {
  background: #1E2230 !important;
  border: 1px solid rgba(255,255,255,.12) !important;
  color: #E8EAF0 !important;
  border-radius: 9px;
}
.content input:focus, .content select:focus, .content textarea:focus {
  border-color: #C0181F !important;
  box-shadow: 0 0 0 3px rgba(192,24,31,.18) !important;
}
.content .btn { border-radius: 9px; }

/* ── Topbar texto escuro (branco → cinza escuro) ──────────── */
.topbar h2, .topbar #pageTitle { color: #111827 !important; font-weight: 700; }
.topbar p,  .topbar #pageSub   { color: #6B7280 !important; }

/* ══════════════════════════════════════════════════════════
   AJUSTE RESPONSIVO — barra retrátil sem alterar identidade visual
══════════════════════════════════════════════════════════ */
.sidebar-toggle {
  width: 100%;
  min-height: 34px;
  border: 1px solid #263044;
  border-radius: 10px;
  background: #151b26;
  color: #fff;
  cursor: pointer;
  font-weight: 800;
  font-size: 15px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.mobile-menu-btn { display: none; }
.mobile-overlay { display: none; }

.app.sidebar-collapsed { grid-template-columns: 78px 1fr; }
.app.sidebar-collapsed .sidebar { padding-left: 10px; padding-right: 10px; }
.app.sidebar-collapsed .brand { justify-content: center; }
.app.sidebar-collapsed .brand div,
.app.sidebar-collapsed .userbox,
.app.sidebar-collapsed .menu-group-header span:not(:first-child),
.app.sidebar-collapsed nav button,
.app.sidebar-collapsed .btn.ghost.full { display: none; }
.app.sidebar-collapsed .brand img { width: 44px; height: 36px; }
.app.sidebar-collapsed .menu-group-header { justify-content: center; padding: 8px 0; border-radius: 8px; }
.app.sidebar-collapsed .menu-group-items { display: none; }
.app.sidebar-collapsed .sidebar::after {
  content: 'Menu recolhido';
  writing-mode: vertical-rl;
  transform: rotate(180deg);
  margin: 10px auto;
  color: #9CA3AF;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .08em;
}

@media (min-width: 801px) and (max-width: 1180px) {
  .app { grid-template-columns: 230px 1fr; }
  .topbar { padding: 0 20px; }
  .content { padding: 18px 20px; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(205px, 1fr)); }
}

@media (max-width: 800px) {
  body { overflow: hidden; }
  .app { height: 100vh; display: block; position: relative; }
  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    width: min(320px, 88vw);
    height: 100vh;
    max-height: none;
    z-index: 30;
    transform: translateX(-105%);
    transition: transform .2s ease;
    box-shadow: 18px 0 45px rgba(0,0,0,.35);
  }
  .app.mobile-sidebar-open .sidebar { transform: translateX(0); }
  .app.mobile-sidebar-open .mobile-overlay {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.45);
    z-index: 20;
  }
  .mobile-menu-btn { display: inline-flex; }
  .main { min-height: 100vh; height: 100vh; }
  .topbar {
    min-height: 68px;
    height: auto;
    padding: 12px 14px;
    gap: 10px;
    align-items: center;
  }
  .topbar h2 { font-size: 16px; }
  .topbar .muted { font-size: 11px; word-break: break-word; }
  .top-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
  .top-actions .btn { padding: 10px 12px; }
  .content { padding: 14px; height: calc(100vh - 68px); overflow: auto; }
  .grid { grid-template-columns: 1fr; gap: 12px; }
  .row { grid-template-columns: 1fr; }
  .card { padding: 16px; border-radius: 16px; }
  .table { display: block; overflow-x: auto; white-space: nowrap; }
  .toolbar { gap: 8px; }
  .module-frame { width: 100%; height: calc(100vh - 68px); }
  #adminUsers, #adminModules, #home { height: calc(100vh - 68px); }
}

@media (max-width: 480px) {
  .login-card { width: 94vw; padding: 22px; border-radius: 20px; }
  .logo-box img { max-width: 210px; max-height: 88px; }
  .topbar { align-items: flex-start; flex-direction: column; }
  .top-actions { width: 100%; justify-content: flex-start; }
  .top-actions .btn { flex: 1; }
  .module-frame { height: calc(100vh - 112px); }
}
