/* =========================================
   Painel Web – folha de estilos principal
   Última revisão: 2025-08-12
========================================= */

/* Reset básico */
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: Arial, Helvetica, sans-serif;
  background: #f3f6fa;
  color: #222;
  display: flex;
  flex-direction: column;
}

/* ========== Topbar ========== */
.topbar{
  height: 56px;
  background: #0646c1;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 18px;
}
.topbar a{ color: #fff; text-decoration: none; font-weight: 600; }
.topbar a:hover{ text-decoration: underline; }

/* ========== Layout base ========== */
.app-container{
  flex: 1;
  display: flex;
  min-height: calc(100vh - 56px);
}

/* ========== Sidebar ========== */
.sidebar-nav{
  width: 240px;
  background: #0d3ea1;
  color: #fff;
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.sidebar-nav .brand{ font-size: 22px; font-weight: 700; }
.menu{ list-style: none; }
.menu li{ margin: 10px 0; }
.menu a{
  color: #fff;
  text-decoration: none;
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 8px 10px;
  border-radius: 6px;
}
.menu a:hover{ background: rgba(255,255,255,.12); }

/* ========== Calendário na sidebar (fixo ao rodapé da sidebar) ========== */
.mini-cal{
  margin-top: auto;
  background: rgba(255,255,255,.10);
  padding: 12px;
  border-radius: 10px;
  color: #fff;
}
.mini-cal-header{ text-align: left; margin-bottom: 8px; font-weight: 700; }
.mini-cal-table{
  width: 100%;
  border-collapse: separate;
  border-spacing: 4px;
  color: #fff;
  font-size: 12px;
  table-layout: fixed;
}
.mini-cal-table th{ text-align: center; opacity: .9; font-weight: 700; }
.mini-cal-table td{
  text-align: center;
  padding: 6px 0;
  border-radius: 8px;
  background: rgba(255,255,255,.08);
}
.mini-cal-table td.today{ background: #ffffff; color: #0d3ea1; font-weight: 700; }
.mini-cal-table td.holiday{ background: rgba(255,255,255,.22); }
.mini-cal-table td.vazio{ background: transparent; }

/* ========== Área de conteúdo ========== */
.content-area{
  flex: 1;
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 22px;
  max-width: 1100px;
  margin: 0 auto;
  padding-bottom: 72px; /* espaço extra para não encostar no rodapé */
}
.card{
  background: #fff;
  border-radius: 10px;
  padding: 18px;
  box-shadow: 0 4px 16px rgba(0,0,0,.06);
}
.card h2{ font-size: 22px; margin-bottom: 12px; color: #0c2e6e; }
.card h3{ font-size: 18px; margin-bottom: 10px; color: #0c2e6e; }

/* ========== Ferramentas (grade de cards) ========== */
.grid-cards{
  display: grid;
  grid-template-columns: repeat(3, minmax(220px, 1fr)); /* 3 colunas estáveis no desktop */
  gap: 20px;
}
.grid-cards .card{
  background: #f7f9fc;
  border: 1px solid #e7edf6;
  border-radius: 12px;
  text-align: center;
  padding: 16px 10px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.04);
  transition: transform .15s ease, box-shadow .15s ease, background .15s ease;
  min-height: 140px;                /* altura uniforme */
  display: flex; align-items: center; justify-content: center;
}
.grid-cards .card a{
  display: flex;
  flex-direction: column;
  gap: 8px;
  color: #1b2a4a;
  text-decoration: none;
  align-items: center;
  justify-content: center;
  padding: 6px 0;
}
.grid-cards .card i{ color: #0646c1; }
.grid-cards .card p{ margin: 6px 0 0; font-weight: 600; }
.grid-cards .card:hover:not(.disabled){
  transform: translateY(-2px);
  background: #eef3fc;
  box-shadow: 0 6px 18px rgba(0,0,0,0.06);
}
/* Desabilitados */
.grid-cards .card.disabled{
  opacity: .55;
  cursor: not-allowed;
  pointer-events: none;
}

/* ========== Barra “Links úteis” (horizontal, com rótulo à esquerda) ========== */
.quick-links{
  margin-top: auto;         /* encosta no fim do <main> */
  margin-bottom: 12px;      /* respiro antes do rodapé */
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  padding: 12px 10px;
}
.quick-links .ql-label{
  font-size: 12px;
  color: #6b7a90;
  font-weight: 600;
  opacity: 0.85;
  margin-right: auto;       /* fixa o rótulo à esquerda */
}
.quick-links .ql-items{
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: center;
}
.quick-links .ql-items a{
  background: #f7f9fc;
  border: 1px solid #e7edf6;
  border-radius: 20px;
  padding: 8px 12px;
  text-decoration: none;
  color: #0646c1;
  font-weight: 600;
}
.quick-links .ql-items a:hover{
  background: #eef3fc;
  border-color: #d9e6fb;
}

/* ========== Alertas e botões (desligar / reiniciar / arquivos) ========== */
.alert { padding: 12px; border-radius: 8px; margin: 12px 0; }
.alert.ok { background: #e9f7ef; border: 1px solid #c9e7d5; color: #22693a; }
.alert.error { background: #fdecea; border: 1px solid #f5c6cb; color: #7a1e1e; }

.btn{
  display: inline-block;
  padding: 8px 12px;
  border-radius: 8px;
  text-decoration: none;
  border: 1px solid #e7edf6;
  background: #f7f9fc;
  color: #1b2a4a;
  font-weight: 600;
  margin-right: 8px;
}
.btn:hover{ background: #eef3fc; border-color: #d9e6fb; }
.btn.warn{ background: #fff7e6; border-color: #ffe3b3; color: #8a5d00; }
.btn.warn:hover{ background: #ffefcc; }
.btn.danger{ background: #ffeceb; border-color: #f5c6cb; color: #7a1e1e; }
.btn.danger:hover{ background: #ffd9d6; }

/* ========== Tabela de arquivos (files.php) ========== */
.file-table th,
.file-table td{
  border-bottom: 1px solid #e7edf6;
}
.file-table th{
  background: #f7f9fc;
  color: #0c2e6e;
  font-weight: 700;
}
.file-table td{ background: #fff; }

/* ========== Rodapé (não fixo) ========== */
.app-footer{
  position: static !important; /* garante que NÃO fique fixo */
  bottom: auto; left: auto; right: auto; width: 100%;
  background: #0646c1; color: #fff;
  text-align: center; padding: 10px;
  margin-top: auto;
  z-index: 1;
}

/* ========== Responsivo ========== */
@media (max-width: 900px){
  .sidebar-nav{ width: 220px; }
}
@media (max-width: 1100px){
  .grid-cards{ grid-template-columns: repeat(2, minmax(220px, 1fr)); }
}
@media (max-width: 620px){
  .grid-cards{ grid-template-columns: 1fr; }
}

/* ===== Ferramentas – modo compacto (5 colunas, 2 linhas) ===== */
.grid-cards{
  grid-template-columns: repeat(5, minmax(140px, 1fr));
  gap: 14px;
}
.grid-cards .card{
  min-height: 110px;            /* mais baixo */
  padding: 12px 8px;            /* menos respiro */
  display: flex; align-items: center; justify-content: center;
}
.grid-cards .card i{
  font-size: 22px !important;   /* sobrescreve fa-2x e afins */
}
.grid-cards .card p{
  font-size: 14px;              /* texto menor */
}

/* Responsivo: 4 / 3 / 2 / 1 colunas conforme largura */
@media (max-width: 1200px){
  .grid-cards{ grid-template-columns: repeat(4, minmax(140px, 1fr)); }
}
@media (max-width: 900px){
  .grid-cards{ grid-template-columns: repeat(3, minmax(140px, 1fr)); }
}
@media (max-width: 640px){
  .grid-cards{ grid-template-columns: repeat(2, minmax(140px, 1fr)); }
}
@media (max-width: 400px){
  .grid-cards{ grid-template-columns: 1fr; }
}

/* ---- Ajuste de posicionamento dos Links úteis ---- */
.content-area{
  padding-bottom: 20px !important;  /* reduzir o espaço inferior */
}

.quick-links{
  margin-top: auto !important;      /* empurra para baixo dentro do <main> */
  margin-bottom: 4px !important;    /* bem perto do rodapé */
}

/* ==== FIX: rodapé deve acompanhar o scroll da página ==== */

/* A página (body) é a única com scroll vertical */
html, body {
  height: auto;
  min-height: 100%;
}
body {
  display: flex;
  flex-direction: column;
  min-height: 100vh; /* empurra o footer para o fim quando o conteúdo é curto */
}

/* O app ocupa o espaço flexível da página (sem criar um scroll próprio) */
.app-container {
  flex: 1 0 auto;
  height: auto !important;
  max-height: none !important;
  overflow: visible !important;
}

/* Nada de scroll próprio no main/conteúdo */
.main,
.content-area {
  height: auto !important;
  max-height: none !important;
  overflow: visible !important;
}

/* A TABELA pode rolar na horizontal (quando precisar) */
.table-wrap {
  overflow-x: auto;
  overflow-y: visible !important;
}

/* Footer no fluxo normal (NÃO fixo, NÃO sticky) */
.app-footer {
  position: static !important;
  top: auto !important;
  bottom: auto !important;
  left: auto !important;
  right: auto !important;
  margin-top: 24px;      /* um respiro acima */
  z-index: 1;
}

/* Só por garantia: links úteis não devem ser sticky/fixed */
.quick-links {
  position: static !important;
}

.tailscale-box {
  background: #1a1a1a;
  color: #eee;
  padding: 15px;
  border-radius: 8px;
  box-shadow: 0 0 10px #0006;
  margin-bottom: 20px;
}
.tailscale-box h3 {
  margin-top: 0;
  color: #4cc9f0;
}
.tailscale-box .btn {
  background: #4cc9f0;
  color: #111;
  border: none;
  padding: 8px 12px;
  border-radius: 4px;
  cursor: pointer;
}
.tailscale-box .btn:hover {
  background: #72eaff;
}
