/* =========================================================
   Sistema de Notificacao de Cabos Baixos — Design tokens
   Paleta inspirada em infraestrutura urbana / sinalizacao de
   engenharia: slate-teal escuro (poste/infra), amber de alerta
   (perigo do cabo baixo), azul-fio para links e dados.
   ========================================================= */
:root {
  --bg: #EEF2F1;
  --surface: #FFFFFF;
  --ink: #16232A;
  --ink-soft: #4B5A60;
  --line: #D7DEDC;
  --line-strong: #B7C2BF;

  --primary: #1F4B4C;
  --primary-dark: #143333;
  --primary-contrast: #FFFFFF;

  --accent: #E2882F;
  --accent-dark: #B96A1C;

  --wire: #3E7C93;

  --status-novo: #B14832;
  --status-analise: #3E7C93;
  --status-atribuido: #7A5C9E;
  --status-resolvido: #3F7A5C;

  --radius-sm: 6px;
  --radius-md: 10px;
  --font-display: 'Archivo', system-ui, sans-serif;
  --font-body: 'IBM Plex Sans', system-ui, sans-serif;
  --shadow-1: 0 1px 2px rgba(22, 35, 42, 0.08);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--ink);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 {
  font-family: var(--font-display);
  color: var(--primary-dark);
  line-height: 1.2;
  margin: 0 0 0.5em;
}

a { color: var(--wire); }
p { max-width: 68ch; }

:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

img { max-width: 100%; display: block; }

/* ---------- Botoes ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5em;
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 1rem;
  padding: 0.85em 1.4em;
  border-radius: var(--radius-sm);
  border: 1.5px solid transparent;
  cursor: pointer;
  text-decoration: none;
  transition: transform 0.08s ease, background-color 0.15s ease, border-color 0.15s ease;
  min-height: 48px;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--primary); color: var(--primary-contrast); }
.btn-primary:hover { background: var(--primary-dark); }
.btn-accent { background: var(--accent); color: #241100; }
.btn-accent:hover { background: var(--accent-dark); color: #fff; }
.btn-outline { background: transparent; border-color: var(--line-strong); color: var(--ink); }
.btn-outline:hover { border-color: var(--primary); color: var(--primary); }
.btn-danger { background: transparent; border-color: var(--status-novo); color: var(--status-novo); }
.btn-danger:hover { background: var(--status-novo); color: #fff; }
.btn-sm { padding: 0.5em 1em; font-size: 0.9rem; min-height: 36px; }
.btn-block { width: 100%; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }

/* ---------- Formularios ---------- */
label { display: block; font-weight: 600; margin-bottom: 0.35em; font-size: 0.95rem; }
.hint { color: var(--ink-soft); font-size: 0.85rem; margin-top: 0.3em; }
input[type=text], input[type=email], input[type=tel], input[type=password], input[type=number], textarea, select {
  width: 100%;
  font-family: var(--font-body);
  font-size: 1rem;
  padding: 0.75em 0.85em;
  border: 1.5px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink);
}
input:focus, textarea:focus, select:focus { border-color: var(--primary); }
.field { margin-bottom: 1.25rem; }
.optional-tag { font-weight: 400; color: var(--ink-soft); font-size: 0.85em; }

.alert {
  border-radius: var(--radius-sm);
  padding: 0.9em 1.1em;
  margin-bottom: 1.25rem;
  font-size: 0.95rem;
}
.alert-error { background: #FBEAE6; border: 1.5px solid var(--status-novo); color: #7A2E1D; }
.alert-success { background: #E7F1EA; border: 1.5px solid var(--status-resolvido); color: #244C36; }
.alert ul { margin: 0.3em 0 0; padding-left: 1.2em; }

/* =========================================================
   AREA PUBLICA
   ========================================================= */
.public-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
.public-header {
  background: var(--primary);
  color: #fff;
  padding: 1.1rem 1.25rem;
}
.public-header .city-name {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.4rem;
  color: #fff;
  margin: 0 0 0.2em;
  line-height: 1.15;
}
.public-header .eyebrow {
  font-size: 0.8rem;
  color: #BFE0DA;
  font-weight: 600;
}
.public-header h1 {
  color: #fff;
  font-size: 1.35rem;
  margin: 0.1em 0 0;
}
.public-main { flex: 1; padding: 1.25rem 1.1rem 3rem; max-width: 640px; margin: 0 auto; width: 100%; }

.step {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  margin-bottom: 1rem;
}
.step-head {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  margin-bottom: 0.9rem;
}
.step-number {
  flex: none;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.9rem;
}
.step-head h2 { font-size: 1.05rem; margin: 0; color: var(--ink); }
.step-desc { color: var(--ink-soft); font-size: 0.9rem; margin: -0.3rem 0 0.9rem; }

.photo-input-area {
  border: 2px dashed var(--line-strong);
  border-radius: var(--radius-md);
  padding: 1.5rem 1rem;
  text-align: center;
  background: #F7F9F8;
}
.photo-input-area input[type=file] { display: none; }
.photo-previews {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.6rem;
  margin-top: 1rem;
}
.photo-thumb {
  position: relative;
  aspect-ratio: 1;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--line);
  background: #fff;
}
.photo-thumb img { width: 100%; height: 100%; object-fit: cover; }
.photo-thumb button {
  position: absolute;
  top: 4px; right: 4px;
  background: rgba(22,35,42,0.75);
  color: #fff;
  border: none;
  border-radius: 50%;
  width: 24px; height: 24px;
  font-size: 0.85rem;
  cursor: pointer;
}

.location-status {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.8em 1em;
  border-radius: var(--radius-sm);
  background: #F7F9F8;
  border: 1.5px solid var(--line-strong);
  font-size: 0.92rem;
  margin-bottom: 0.8rem;
}
.location-status.ok { border-color: var(--status-resolvido); background: #EEF6F1; color: #244C36; }
.location-status.pending { border-color: var(--line-strong); }
.location-status.error { border-color: var(--status-novo); background: #FBEAE6; color: #7A2E1D; }
.location-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--ink-soft); flex: none; }
.location-status.ok .location-dot { background: var(--status-resolvido); }
.location-status.error .location-dot { background: var(--status-novo); }

#map-preview { height: 200px; border-radius: var(--radius-sm); margin-top: 0.8rem; border: 1px solid var(--line); display: none; }

.footer-note { text-align: center; color: var(--ink-soft); font-size: 0.82rem; padding: 1rem; }

/* =========================================================
   AREA ADMINISTRATIVA
   ========================================================= */
.admin-shell { display: flex; min-height: 100vh; }
.admin-sidebar {
  width: 232px;
  flex: none;
  background: var(--primary-dark);
  color: #DDEAE8;
  padding: 1.25rem 1rem;
  display: flex;
  flex-direction: column;
}
.admin-sidebar .brand { color: #fff; font-family: var(--font-display); font-weight: 700; font-size: 1.05rem; margin-bottom: 1.5rem; }
.admin-sidebar .brand small { display: block; font-family: var(--font-body); font-weight: 400; color: #9FC0BB; font-size: 0.75rem; margin-top: 2px; }
.admin-nav { display: flex; flex-direction: column; gap: 0.15rem; flex: 1; }
.admin-nav a {
  color: #CFE3E0;
  text-decoration: none;
  padding: 0.65em 0.75em;
  border-radius: var(--radius-sm);
  font-size: 0.93rem;
  font-weight: 500;
}
.admin-nav a:hover { background: rgba(255,255,255,0.08); }
.admin-nav a.active { background: var(--accent); color: #241100; font-weight: 600; }
.admin-user-box { border-top: 1px solid rgba(255,255,255,0.15); padding-top: 1rem; margin-top: 1rem; font-size: 0.85rem; }
.admin-user-box .role-tag { color: #9FC0BB; text-transform: none; }
.admin-user-box form { margin-top: 0.6rem; }

.admin-topbar { display: none; }

.admin-content { flex: 1; padding: 1.75rem 2rem; max-width: 1200px; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1.25rem; flex-wrap: wrap; }
.page-head h1 { font-size: 1.5rem; margin: 0; }

.stat-row { display: flex; gap: 0.75rem; flex-wrap: wrap; margin-bottom: 1.25rem; }
.stat-pill {
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 4px solid var(--line-strong);
  border-radius: var(--radius-sm);
  padding: 0.6rem 1rem;
  min-width: 120px;
}
.stat-pill .n { font-family: var(--font-display); font-size: 1.4rem; font-weight: 700; display: block; }
.stat-pill .l { font-size: 0.8rem; color: var(--ink-soft); }
.stat-pill.novo { border-left-color: var(--status-novo); }
.stat-pill.em_analise { border-left-color: var(--status-analise); }
.stat-pill.atribuido { border-left-color: var(--status-atribuido); }
.stat-pill.resolvido { border-left-color: var(--status-resolvido); }

.filter-bar { display: flex; gap: 0.6rem; flex-wrap: wrap; margin-bottom: 1.1rem; background: var(--surface); border: 1px solid var(--line); padding: 0.9rem; border-radius: var(--radius-md); }
.filter-bar > * { flex: 1; min-width: 140px; }
.filter-bar .field { margin-bottom: 0; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-md); padding: 1.25rem; margin-bottom: 1.25rem; }
.card h2 { font-size: 1.1rem; }

table.list { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-md); overflow: hidden; }
table.list th, table.list td { text-align: left; padding: 0.75em 0.9em; border-bottom: 1px solid var(--line); font-size: 0.92rem; }
table.list th { background: #F5F7F6; color: var(--ink-soft); font-weight: 600; font-size: 0.78rem; text-transform: none; }
table.list tr:last-child td { border-bottom: none; }
table.list tr:hover td { background: #F9FBFA; }
table.list a.row-link { color: var(--ink); text-decoration: none; font-weight: 600; }
table.list a.row-link:hover { color: var(--wire); }

.badge { display: inline-flex; align-items: center; gap: 0.4em; padding: 0.25em 0.7em; border-radius: 999px; font-size: 0.78rem; font-weight: 600; }
.badge::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.badge.novo { background: #FBEAE6; color: var(--status-novo); }
.badge.em_analise { background: #E7F0F3; color: var(--status-analise); }
.badge.atribuido { background: #EFEAF5; color: var(--status-atribuido); }
.badge.resolvido { background: #E7F1EA; color: var(--status-resolvido); }

.detail-grid { display: grid; grid-template-columns: 1.4fr 1fr; gap: 1.25rem; align-items: start; }
.photo-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.6rem; }
.photo-grid a { border-radius: var(--radius-sm); overflow: hidden; border: 1px solid var(--line); aspect-ratio: 1; }
.photo-grid img { width: 100%; height: 100%; object-fit: cover; }
#detail-map { height: 260px; border-radius: var(--radius-md); border: 1px solid var(--line); }

.meta-list { list-style: none; margin: 0; padding: 0; font-size: 0.92rem; }
.meta-list li { display: flex; justify-content: space-between; gap: 1rem; padding: 0.45em 0; border-bottom: 1px dashed var(--line); }
.meta-list li:last-child { border-bottom: none; }
.meta-list .k { color: var(--ink-soft); }

.checkbox-grid { display: flex; flex-direction: column; gap: 0.5rem; max-height: 260px; overflow-y: auto; padding: 0.2rem; }
.checkbox-row { display: flex; align-items: flex-start; gap: 0.7rem; font-weight: 500; }

/* Checkbox customizado (nao usa o desenho nativo do sistema operacional).
   Necessario porque o Safari/iOS ignora width/height em checkboxes nativos
   em varias versoes, fazendo o quadradinho ficar minusculo mesmo com CSS. */
.checkbox-row input[type=checkbox] {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  width: 26px;
  height: 26px;
  min-width: 26px;
  flex: none;
  margin: 0;
  border: 2px solid var(--line-strong);
  border-radius: 6px;
  background: #fff;
  position: relative;
  cursor: pointer;
}
.checkbox-row input[type=checkbox]:checked {
  background: var(--primary);
  border-color: var(--primary);
}
.checkbox-row input[type=checkbox]:checked::after {
  content: '';
  position: absolute;
  left: 8px;
  top: 3px;
  width: 7px;
  height: 13px;
  border: solid #fff;
  border-width: 0 3px 3px 0;
  transform: rotate(45deg);
}
.checkbox-row input[type=checkbox]:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

.tabs-empty { color: var(--ink-soft); padding: 2rem 1rem; text-align: center; }

.login-shell { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: var(--primary-dark); padding: 1rem; }
.login-card { background: var(--surface); border-radius: var(--radius-md); padding: 2rem; width: 100%; max-width: 380px; box-shadow: 0 10px 30px rgba(0,0,0,0.25); }
.login-card h1 { font-size: 1.3rem; }

@media (max-width: 860px) {
  .admin-shell { flex-direction: column; }
  .admin-sidebar { display: none; }
  .admin-topbar {
    display: flex; align-items: center; justify-content: space-between;
    background: var(--primary-dark); color: #fff; padding: 0.9rem 1rem;
    position: sticky; top: 0; z-index: 20;
  }
  .admin-topbar .brand { font-family: var(--font-display); font-weight: 700; }
  .admin-topbar select { width: auto; }
  .admin-bottom-nav {
    position: sticky; bottom: 0; display: flex; background: var(--surface);
    border-top: 1px solid var(--line); z-index: 20;
  }
  .admin-bottom-nav a {
    flex: 1; text-align: center; padding: 0.7rem 0.3rem; font-size: 0.72rem;
    color: var(--ink-soft); text-decoration: none; font-weight: 600;
  }
  .admin-bottom-nav a.active { color: var(--primary); }
  .admin-content { padding: 1.1rem; order: -1; }
  .detail-grid { grid-template-columns: 1fr; }
  table.list { display: block; overflow-x: auto; white-space: nowrap; }
}
