/* =========================================================
   GERADOR DE COMUNICADOS DE FERIADOS — Cobra
   Design simples e plano: fundo branco, vermelho da marca,
   botões pretos, cartões com borda fina.
   ========================================================= */

:root {
  --red: #e30613;
  --red-soft: #fbe7e8;
  --ink: #1c1c1c;
  --text-main: #1f2328;
  --text-muted: #6b7280;
  --border: #e5e7eb;
  --bg: #f4f5f6;
  --white: #ffffff;
  --green: #1f9254;
  --radius: 8px;
  --font-body: 'Manrope', -apple-system, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text-main);
  font-family: var(--font-body);
  min-height: 100vh;
}

.hidden { display: none !important; }

button {
  font-family: var(--font-body);
  cursor: pointer;
  border: none;
  background: none;
}
button:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible {
  outline: 2px solid var(--red);
  outline-offset: 1px;
}

.app-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ---------- Barra superior ---------- */

.topbar {
  background: var(--white);
  border-bottom: 3px solid var(--red);
  padding: 0 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 28px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
  font-size: 16.5px;
  color: var(--ink);
  white-space: nowrap;
}

.brand-flag { height: 26px; width: auto; display: block; }

.tabs {
  display: flex;
  gap: 4px;
}

.tab-btn {
  padding: 9px 16px;
  border-radius: 20px;
  font-size: 14px;
  font-weight: 700;
  color: var(--text-muted);
}
.tab-btn:hover { color: var(--text-main); }
.tab-btn.active {
  background: var(--red-soft);
  color: var(--red);
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 14px;
}

.year-select {
  background: var(--white);
  color: var(--text-main);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 7px 10px;
  font-family: var(--font-body);
  font-size: 13.5px;
}

main.content {
  max-width: 1100px;
  width: 100%;
  margin: 0 auto;
  padding: 32px 28px 64px;
}

.view-title {
  font-weight: 800;
  font-size: 24px;
  margin: 0 0 4px;
  color: var(--ink);
}

.view-sub {
  color: var(--text-muted);
  font-size: 14px;
  margin: 0 0 24px;
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text-muted);
  font-size: 13.5px;
  font-weight: 700;
  margin-bottom: 16px;
  padding: 0;
}
.back-link:hover { color: var(--text-main); }

/* ---------- Grid de meses ---------- */

.months-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 14px;
}

.month-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  text-align: left;
  transition: border-color 0.12s ease;
}
.month-card:hover { border-color: var(--red); }

.month-card .month-num {
  font-weight: 800;
  font-size: 28px;
  color: var(--red);
  line-height: 1;
}

.month-card .month-name {
  font-weight: 700;
  font-size: 15px;
  margin: 8px 0 4px;
  text-transform: capitalize;
  color: var(--ink);
}

.month-card .month-count {
  font-size: 12.5px;
  color: var(--text-muted);
}

.month-card .progress-bar {
  margin-top: 12px;
  height: 5px;
  border-radius: 4px;
  background: #eee;
  overflow: hidden;
}
.month-card .progress-fill { height: 100%; background: var(--green); }

/* ---------- Lista de feriados do mês ---------- */

.holiday-list { display: flex; flex-direction: column; gap: 10px; }

.holiday-row {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}

.holiday-row .info { flex: 1; min-width: 220px; cursor: pointer; }
.holiday-row .info:hover .name { color: var(--red); }

.holiday-row .name { font-weight: 700; font-size: 15px; text-transform: capitalize; }

.holiday-row .meta { font-size: 12.5px; color: var(--text-muted); margin-top: 2px; }

.badge {
  display: inline-block;
  font-size: 10.5px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 20px;
  margin-right: 6px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.badge.nacional { background: #e6ecf7; color: #2c4a8f; }
.badge.municipal { background: #eee6f7; color: #6b3f9e; }
.badge.estadual { background: #e6f3ee; color: #2c7a56; }
.badge.facultativo { background: #f7ede6; color: #a05a1f; }

.check-group { display: flex; gap: 14px; }

.check-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  font-size: 10.5px;
  color: var(--text-muted);
  font-weight: 700;
}
.check-item input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--green); }

/* ---------- Botões ---------- */

.btn-primary {
  padding: 11px 18px;
  background: var(--ink);
  color: var(--white);
  border-radius: 8px;
  font-weight: 700;
  font-size: 14px;
}
.btn-primary:hover { background: #333; }

.btn-secondary {
  background: var(--white);
  border: 1px solid var(--border);
  color: var(--text-main);
  padding: 11px 18px;
  border-radius: 8px;
  font-weight: 700;
  font-size: 14px;
}
.btn-secondary:hover { background: #f2f2f2; }

.btn-danger {
  background: var(--white);
  border: 1px solid #f0c9c2;
  color: var(--red);
  padding: 8px 14px;
  border-radius: 8px;
  font-weight: 700;
  font-size: 13px;
}
.btn-danger:hover { background: var(--red-soft); }

.btn-red {
  background: var(--red);
  color: var(--white);
  padding: 11px 18px;
  border-radius: 8px;
  font-weight: 700;
  font-size: 14px;
}
.btn-red:hover { background: #c00510; }

/* ---------- Campos de formulário ---------- */

.field { margin-bottom: 16px; }

.field label {
  display: block;
  font-size: 12.5px;
  font-weight: 700;
  margin-bottom: 6px;
  color: var(--text-main);
}

.field input, .field select, .field textarea {
  width: 100%;
  padding: 11px 13px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-family: var(--font-body);
  font-size: 14px;
  background: var(--white);
  color: var(--text-main);
}

/* ---------- Painel de gerenciamento (modal) ---------- */

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(20, 20, 20, 0.45);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 40px 20px;
  overflow-y: auto;
  z-index: 50;
}

.manage-panel {
  background: var(--white);
  border-radius: 12px;
  width: 100%;
  max-width: 780px;
  padding: 28px;
  box-shadow: 0 16px 48px rgba(0,0,0,0.22);
}

.manage-panel h2 {
  font-size: 21px;
  font-weight: 800;
  margin: 0 0 2px;
  text-transform: capitalize;
  color: var(--ink);
}

.manage-panel .panel-sub { color: var(--text-muted); font-size: 13px; margin-bottom: 20px; }

.panel-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
@media (max-width: 620px) { .panel-grid { grid-template-columns: 1fr; } }

.type-toggle { display: flex; gap: 10px; }
.type-toggle label {
  flex: 1;
  border: 2px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  text-align: center;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  background: var(--white);
}
.type-toggle input { display: none; }
.type-toggle label.selected { border-color: var(--red); background: var(--red-soft); color: var(--red); }

.header-photo-preview {
  width: 100%;
  height: 130px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--border);
  display: block;
  margin-bottom: 8px;
}

.filiais-box {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px;
  max-height: 220px;
  overflow-y: auto;
}
.filial-check {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 2px;
  font-size: 13px;
}
.filial-check input { width: 16px; height: 16px; accent-color: var(--red); }

.add-filial-row {
  display: flex;
  gap: 6px;
  margin-top: 10px;
}
.add-filial-row input {
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 9px;
  font-size: 12.5px;
  font-family: var(--font-body);
}
.add-filial-row input:nth-child(1) { flex: 2; }
.add-filial-row input:nth-child(2) { flex: 1; width: 50px; }
.add-filial-row input:nth-child(3) { flex: 1; }
.add-filial-row button {
  background: var(--ink);
  color: var(--white);
  border-radius: 6px;
  padding: 8px 12px;
  font-size: 12.5px;
  font-weight: 700;
  white-space: nowrap;
}
.add-filial-row button:hover { background: #333; }

.panel-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 22px;
  flex-wrap: wrap;
}

.result-box {
  margin-top: 20px;
  border-top: 1px dashed var(--border);
  padding-top: 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}

.result-box .actions-row { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }

/* ---------- Poster do comunicado (canvas nativo, 1080x1920) ---------- */

.poster-canvas {
  width: 100%;
  max-width: 300px;
  height: auto;
  display: block;
  margin: 0 auto;
  border-radius: 12px;
  box-shadow: 0 6px 20px rgba(0,0,0,0.18);
  background: #F0F0F0;
}

.preview-caption { font-size: 11.5px; color: var(--text-muted); text-align: center; margin-top: 8px; }

/* ---------- Aba Administrar ---------- */

.admin-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}
@media (max-width: 800px) { .admin-grid { grid-template-columns: 1fr; } }

.admin-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 22px;
}

.admin-card h3 { margin: 0 0 18px; font-size: 17px; font-weight: 800; color: var(--ink); }

.remove-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 460px;
  overflow-y: auto;
}

.remove-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
}

.remove-row .r-info { min-width: 0; }
.remove-row .r-name { font-weight: 700; font-size: 13.5px; text-transform: capitalize; }
.remove-row .r-meta { font-size: 11.5px; color: var(--text-muted); }

/* ---------- Notificações ---------- */

.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--ink);
  color: var(--white);
  padding: 12px 20px;
  border-radius: 8px;
  font-size: 13.5px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.2);
  z-index: 100;
  max-width: 90vw;
}

.error-banner {
  background: #fbeae7;
  color: #a3281a;
  border: 1px solid #f0c9c2;
  border-radius: 8px;
  padding: 14px 16px;
  font-size: 13.5px;
  margin-bottom: 20px;
  line-height: 1.5;
}

.empty-state { text-align: center; padding: 60px 20px; color: var(--text-muted); }
