/* ============================================================
   FM-HUB - Fórum Montijo
   styles.css - Estilos globais partilhados (baseado na Rondas FM)
   ============================================================ */
@import url('https://fonts.googleapis.com/css2?family=Nunito:wght@900&display=swap');

/* --- Variáveis de cor --- */
:root {
  color-scheme: light;
  --laranja:        #ED5526;
  --laranja-escuro: #CC2200;
  --laranja-claro:  #fff9f7;
  --laranja-borda:  #fde8e2;
  --amarelo:        #F5A800;
  --escuro:         #2C2C2A;
  --texto:          #3C3C3C;
  --texto-secundario: #5a5a5a;
  --texto-claro:    #777;
  --fundo:          #e4e6ea;
  --branco:         #ffffff;
  --borda:          #d8dadf;
  --verde:          #1D9E75;
  --verde-claro:    #f0faf5;
  --verde-borda:    #9FE1CB;
  --azul:           #185FA5;
  --azul-claro:     #e8f0fd;
}

/* --- Reset base --- */
* { box-sizing: border-box; margin: 0; padding: 0; accent-color: #E8451A; -webkit-tap-highlight-color: transparent; }

/* --- Escala de fonte unificada (mínimo 13px, excluindo títulos) --- */
:root {
  --font-xs:  12px;
  --font-sm:  13px;
  --font-md:  14px;
  --font-base: 15px;
  --font-lg:  16px;
}

/* --- Scrollbar global --- */
* { scrollbar-width: thin; scrollbar-color: rgba(237,85,38,0.85) transparent; }
*::-webkit-scrollbar { width: 7px; height: 7px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb { background: rgba(237,85,38,0.85); border-radius: 4px; }
*::-webkit-scrollbar-thumb:hover { background: rgba(237,85,38,1); }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--fundo);
  color: var(--texto);
  font-size: 16px;
  line-height: 1.5;
}

/* --- Tipografia --- */
h1 { font-size: 26px; font-weight: 500; }
h2 { font-size: 22px; font-weight: 500; }
h3 { font-size: 18px; font-weight: 500; }

/* --- Botões --- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0 18px;
  height: 50px;
  border-radius: 12px;
  border: none;
  font-size: 16px;
  font-weight: 500;
  cursor: pointer;
  transition: opacity 0.15s;
  text-decoration: none;
}
.btn:active { opacity: 0.85; }
.btn-primario  { background: var(--laranja); color: #fff; }
.btn-secundario { background: var(--branco); color: var(--laranja); border: 1px solid var(--laranja-borda); }
.btn-perigo    { background: #e24b4a; color: #fff; }
.btn-bloco     { width: 100%; justify-content: center; }
.btn-sm        { height: 36px; font-size: 14px; padding: 0 12px; border-radius: 8px; }

/* --- Botões de ação (ícone em linha de tabela/lista) --- */
.btn-acao {
  width: 32px; height: 32px;
  border-radius: 8px;
  border: 1px solid var(--borda);
  background: var(--branco);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; flex-shrink: 0;
  transition: border-color 0.12s;
}
.btn-acao:hover { border-color: var(--laranja); }
.btn-acao:disabled { opacity: .3; cursor: not-allowed; }
.btn-acao i { font-size: 14px; color: var(--texto-secundario); }
.btn-acao.perigo i { color: #e24b4a; }
.btn-acao.perigo:hover { border-color: #e24b4a; }

/* --- Inputs --- */
.input-group { display: flex; flex-direction: column; gap: 5px; margin-bottom: 14px; }
.input-group label { font-size: 14px; font-weight: 500; color: var(--texto-secundario); }
.input {
  width: 100%;
  height: 50px;
  border-radius: 12px;
  border: 1px solid var(--borda);
  padding: 0 12px 0 42px;
  font-family: inherit;
  font-size: 16px;
  color: var(--texto);
  background: var(--branco);
  outline: none;
  transition: border-color 0.15s;
}
.input:focus { border-color: var(--laranja); }
/* Select nativo escondido — visualmente substituído por .select-face */
.select-wrap { position: relative; display: block; }
.select-wrap select.input {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  opacity: 0;
  cursor: pointer;
  z-index: 2;
  margin: 0;
}
.select-face {
  width: 100%;
  height: 50px;
  border-radius: 12px;
  border: 1px solid var(--borda);
  padding: 0 36px 0 12px;
  font-size: 16px;
  color: var(--texto);
  background: var(--branco);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23777' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 16px;
  display: flex;
  align-items: center;
  pointer-events: none;
  transition: border-color 0.15s;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.select-wrap:focus-within .select-face { border-color: var(--laranja); }
.input-icon-wrap { position: relative; }
.input-icon {
  position: absolute;
  left: 11px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 16px;
  color: var(--texto-claro);
  pointer-events: none;
}

/* --- Cards --- */
.card {
  background: var(--branco);
  border-radius: 12px;
  border: 1px solid #e0e0e0;
  padding: 12px 16px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.07);
}
.card-titulo {
  font-size: 15px;
  font-weight: 600;
  color: var(--texto);
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.card-titulo a {
  font-size: 14px;
  color: var(--laranja);
  font-weight: 500;
  text-decoration: none;
}

/* --- Badges --- */
.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  white-space: nowrap;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 600;
}
.badge-admin,
.badge-vigilante   { min-width: 96px; }
.badge-admin       { background: #faeeda; color: #633806; }
.badge-vigilante   { background: var(--fundo); color: #5F5E5A; }
.badge-ativo       { background: var(--verde-claro); color: #0F6E56; }
.badge-inativo     { background: var(--fundo); color: var(--texto-secundario); }
.badge-concluida   { background: var(--verde-claro); color: #0F6E56; }
.badge-em-curso    { background: #fef9e8; color: #633806; }
.badge-pendente    { background: var(--fundo); color: var(--texto-secundario); }
.badge-conforme    { background: var(--verde-claro); color: #0F6E56; }
.badge-nao-conforme { background: var(--laranja-borda); color: #993C1D; }

/* --- Sidebar (dashboard) --- */
.sidebar {
  width: 228px;
  background: var(--laranja);
  display: flex;
  flex-direction: column;
  height: 100vh;
  position: fixed;
  left: 0; top: 0;
  overflow: hidden;
}
.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.75) transparent;
}
.sidebar-nav::-webkit-scrollbar { width: 7px; }
.sidebar-nav::-webkit-scrollbar-track { background: transparent; }
.sidebar-nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.75); border-radius: 4px; }
.sidebar-nav::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,1); }
.sidebar-logo {
  padding: 21px 16px 17px;
  border-bottom: 1px solid rgba(255,255,255,0.18);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  text-align: center;
}
@keyframes spin-pause {
  0%   { transform: rotate(0deg); }
  20%  { transform: rotate(360deg); }
  50%  { transform: rotate(360deg); }
  70%  { transform: rotate(720deg); }
  100% { transform: rotate(720deg); }
}
.sidebar-logo-circle {
  width: 64px; height: 64px;
  border-radius: 50%;
  background: var(--laranja);
  overflow: hidden;
  display: flex; align-items: center; justify-content: center;
}
.sidebar-logo-circle img { width: 64px; height: 64px; display: block; animation: spin-pause 6s ease-in-out infinite; }
.sidebar-logo .titulo { font-size: 22px; font-weight: 900; font-family: 'Nunito', sans-serif; color: #fff; line-height: 1.2; letter-spacing: -.4px; }
.sidebar-logo .sidebar-sub { font-size: 13px; font-weight: 800; color: #fff; margin-top: 3px; letter-spacing: .3px; }
.nav-secao { padding: 8px 0 3px; border-bottom: 1px solid rgba(255,255,255,0.14); }
.nav-label {
  font-size: 12px;
  font-weight: 700;
  color: rgba(255,255,255,0.5);
  padding: 0 16px;
  margin-bottom: 2px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 11px 15px;
  font-size: 16px;
  font-weight: 600;
  color: rgba(255,255,255,0.88);
  cursor: pointer;
  border-left: 5px solid transparent;
  text-decoration: none;
  transition: background 0.12s;
}
.nav-item:hover { background: rgba(0,0,0,0.12); color: #fff; }
.nav-item.ativo { background: rgba(0,0,0,0.2); color: #fff; border-left-color: #fff; font-weight: 700; }
.nav-item i { font-size: 19px; flex-shrink: 0; }
.nav-admin-btn i { font-size: 19px; }
.nav-sub-item { padding-left: 20px; gap: 8px; }
.nav-sub-item i { font-size: 16px; }
.nav-admin-btn { font-size: 16px; font-weight: 600; }
.sidebar-footer {
  margin-top: auto;
  padding: 12px 15px;
  border-top: 1px solid rgba(255,255,255,0.18);
}

/* --- Layout dashboard --- */
.dash-layout { background: var(--fundo); margin-left: 228px; min-height: 100vh; display: flex; flex-direction: column; }
.dash-main { flex: 1; display: flex; flex-direction: column; }
.dash-topbar {
  height: 50px;
  background: var(--branco);
  border-bottom: 1px solid var(--borda);
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
  display: flex;
  align-items: center;
  padding: 0 20px;
  position: sticky;
  top: 0;
  z-index: 10;
}
.dash-topbar-titulo { font-size: 17px; font-weight: 600; color: var(--texto); }
.dash-content { padding: 16px 20px; display: flex; flex-direction: column; gap: 10px; }

/* --- Stat cards --- */
.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.stat-card { background: var(--branco); border-radius: 10px; padding: 12px 14px; border: 1px solid #e0e0e0; box-shadow: 0 2px 8px rgba(0,0,0,0.07); }
.stat-card .val { font-size: 24px; font-weight: 600; color: var(--texto); }
.stat-card .lbl { font-size: 13px; color: var(--texto-claro); margin-top: 2px; }
.stat-card .trend { font-size: 12px; margin-top: 4px; }
.stat-card.alerta .val { color: var(--laranja); }

/* --- Tabelas --- */
.tabela { width: 100%; border-collapse: collapse; font-size: 14px; }
.tabela th { text-align: left; padding: 9px 12px; font-size: 12px; font-weight: 600; color: var(--texto-secundario); border-bottom: 1px solid var(--borda); background: var(--fundo); text-transform: uppercase; letter-spacing: .04em; }
.tabela td { padding: 11px 12px; border-bottom: 1px solid var(--borda); color: var(--texto); font-size: 14px; }
.tabela tr:last-child td { border-bottom: none; }
.tabela tr:hover td { background: #fafafa; }
.acoes { justify-content: flex-end; }

/* --- App mobile --- */
.app-screen *::-webkit-scrollbar { display: none; }
.app-screen * { -ms-overflow-style: none; scrollbar-width: none; }
.app-screen {
  max-width: 430px;
  height: 100vh;
  overflow: hidden;
  margin: 0 auto;
  background: var(--fundo);
  display: flex;
  flex-direction: column;
}
.app-header {
  background: var(--laranja);
  padding: 12px 16px 16px;
  padding-top: calc(12px + env(safe-area-inset-top));
  flex-shrink: 0;
}
.app-header-titulo { font-size: 22px; font-weight: 700; color: #fff; }
.app-header-sub { font-size: 15px; color: rgba(255,255,255,0.8); margin-top: 2px; }
.app-body { flex: 1; padding: 16px; display: flex; flex-direction: column; gap: 12px; overflow-y: auto; }
.app-footer { padding: 16px; padding-bottom: calc(16px + env(safe-area-inset-bottom)); }

/* --- Modais --- */
.modal-overlay { position:fixed;inset:0;background:rgba(0,0,0,.45);display:flex;align-items:center;justify-content:center;z-index:100; }
.modal { background:var(--branco);border-radius:16px;padding:28px;width:580px;max-width:95vw;box-shadow:0 20px 60px rgba(0,0,0,.2);max-height:90vh;overflow-y:auto; }
.modal-titulo { font-size:15px;font-weight:600;color:var(--texto);margin-bottom:20px;display:flex;justify-content:space-between;align-items:center; }
.form-group { display:flex;flex-direction:column;gap:6px; }
.label { font-size:14px;font-weight:600;color:var(--texto-secundario); }

/* --- Mobile responsivo (dashboard) --- */
.btn-hamburger {
  display: none;
  align-items: center;
  justify-content: center;
  width: 36px; height: 36px;
  background: none;
  border: 1px solid var(--borda);
  border-radius: 8px;
  cursor: pointer;
  flex-shrink: 0;
  margin-right: 8px;
  color: var(--texto);
}
.btn-hamburger i { font-size: 20px; }

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: transparent;
  z-index: 199;
}

@media (orientation: landscape) and (max-width: 1024px) and (max-height: 600px) {
  .stats-grid { grid-template-columns: repeat(3, 1fr) !important; gap: 8px; }
}

@media (max-width: 768px),
       (orientation: landscape) and (max-width: 1024px) and (max-height: 600px) {
  html, body { overflow-x: hidden; max-width: 100%; }

  .btn { font-size: 22px; height: 60px; }
  .btn-sm { font-size: 15px; height: 40px; }

  .sidebar {
    transform: translateX(-100%);
    transition: transform 0.26s ease;
    z-index: 200;
    box-shadow: none;
  }
  .sidebar.aberta {
    transform: translateX(0);
    box-shadow: 4px 0 24px rgba(0,0,0,0.18);
  }
  .sidebar-overlay.visivel { display: block; }

  .dash-layout { margin-left: 0 !important; overflow-x: hidden; }
  .dash-main {
    margin-left: 0 !important;
    width: 100%;
    min-width: 0;
    max-width: 100vw;
    overflow-x: hidden;
    box-sizing: border-box;
  }

  .btn-hamburger { display: flex; }

  .dash-topbar {
    height: auto !important;
    min-height: 50px;
    padding: 8px 12px !important;
    flex-wrap: wrap;
    gap: 6px;
  }
  .dash-topbar-titulo {
    font-size: 16px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
    flex: 1;
  }

  #sidebarNome { font-size: 15px !important; }
  #sidebarRole { font-size: 13px !important; }

  .dash-content { padding: 12px; gap: 12px; overflow-x: hidden; }

  .card {
    padding: 12px;
    box-sizing: border-box;
    min-width: 0;
    max-width: 100%;
    overflow: hidden !important;
  }
  .card-titulo {
    font-size: 15px;
    flex-wrap: wrap;
    gap: 8px;
  }
  .card-titulo input.input {
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box;
  }

  .card > table, .card > div > table {
    display: block !important;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch;
    width: auto !important;
    min-width: 100%;
  }

  .stats-grid { grid-template-columns: repeat(2, 1fr) !important; gap: 8px; }
  .stat-card .val { font-size: 22px; }
  .row2 { grid-template-columns: 1fr !important; }

  /* Editor com 2 colunas: colapsar para 1 */
  .editor-layout { grid-template-columns: 1fr !important; }

  .tabela th, .tabela td { padding: 9px 8px; font-size: 13px; }
  .tabela td { font-size: 14px; }

  .filtros-row { flex-direction: column !important; }
  .filtros-row .input-group { min-width: unset !important; width: 100% !important; }
}

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr 1fr !important; gap: 6px; }
  .stat-card { padding: 10px; }
  .stat-card .val { font-size: 20px; }
  .stat-card .lbl { font-size: 12px; }
}

/* --- Sombra em texto branco sobre laranja --- */
.sidebar-logo .titulo,
.sidebar-logo .sidebar-sub,
.nav-item,
.sidebar-footer * {
  text-shadow: 0 1px 4px rgba(0,0,0,0.28), 0 1px 2px rgba(0,0,0,0.15);
}
.nav-label,
.nav-admin-btn {
  text-shadow: 0 1px 3px rgba(0,0,0,0.16);
}
.btn-primario {
  text-shadow: 0 1px 4px rgba(0,0,0,0.22), 0 1px 2px rgba(0,0,0,0.12);
}

/* --- Utilitários --- */
.text-laranja { color: var(--laranja); }
.text-secundario { color: var(--texto-secundario); }
.text-claro { color: var(--texto-claro); }
.text-verde { color: var(--verde); }
.mt-4 { margin-top: 4px; }
.mt-8 { margin-top: 8px; }
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }
.mb-8 { margin-bottom: 8px; }
.mb-12 { margin-bottom: 12px; }
.mb-16 { margin-bottom: 16px; }
.flex { display: flex; }
.flex-center { display: flex; align-items: center; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.w-full { width: 100%; }
.text-center { text-align: center; }

/* --- Dark mode toggle button --- */
.dm-toggle {
  width: 36px;
  padding: 0 !important;
  justify-content: center;
  background: transparent !important;
  border: 1px solid var(--borda) !important;
  color: var(--texto-claro) !important;
}
.dm-toggle:hover { border-color: var(--laranja) !important; color: var(--laranja) !important; }

/* --- Dark mode --- */
html.dark {
  color-scheme: dark;
  --fundo:             #000000;
  --branco:            #0f0f0f;
  --borda:             #1a1d2a;
  --texto:             #e2e5ed;
  --texto-secundario:  #8a91a2;
  --texto-claro:       #515869;
  --laranja:           #7B2D0E;
  --laranja-escuro:    #541E08;
  --laranja-claro:     #190d04;
  --laranja-borda:     #2a1006;
  --azul-claro:        #060c1a;
  --verde-claro:       #050f0b;
  --verde-borda:       #0b2015;
}

html.dark .input { background: var(--branco); color-scheme: dark; }
html.dark .dash-topbar { border-bottom-color: var(--borda); box-shadow: 0 1px 4px rgba(0,0,0,0.35); }
html.dark .card { border-color: var(--borda); }
html.dark .stat-card { border-color: var(--borda); }
html.dark .tabela th { background: var(--fundo); }
html.dark .tabela tr:hover td { background: rgba(255,255,255,0.03); }
html.dark .btn-secundario { background: rgba(237,85,38,0.08); }
html.dark .badge-admin    { background: #2a1e08; color: #c49040; }
html.dark .badge-vigilante { background: var(--borda); color: var(--texto-secundario); }
html.dark .badge-pendente  { background: var(--borda); color: var(--texto-secundario); }
html.dark .badge-ativo      { background: rgba(14,110,86,0.15) !important; color: #2ec98a !important; }
html.dark .badge-concluida  { background: rgba(14,110,86,0.15) !important; color: #2ec98a !important; }
html.dark .badge-em-curso   { background: rgba(232,125,26,0.15) !important; color: #f0a060 !important; }
html.dark .badge-conforme   { background: rgba(14,110,86,0.15) !important; color: #2ec98a !important; }
html.dark .badge-nao-conforme { background: rgba(180,30,30,0.15) !important; color: #f09090 !important; }

/* Dark mode toggle button — mais visível em modo escuro */
html.dark .dm-toggle {
  background: rgba(255,255,255,0.07) !important;
  color: var(--texto-secundario) !important;
  border-color: rgba(255,255,255,0.15) !important;
}
html.dark .dm-toggle:hover { border-color: var(--laranja) !important; color: var(--laranja) !important; }
