/* ═══════════════════════════════════════════════════════════════════
   Portal Municipal — Design System
   Paleta: Azul #1565C0 · Verde #2E7D32
   ═══════════════════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

/* ── Tokens ─────────────────────────────────────────────────────── */
:root {
  --blue-900:  #0D3B8E;
  --blue-800:  #1565C0;
  --blue-700:  #1976D2;
  --blue-600:  #1E88E5;
  --blue-50:   #E3F2FD;

  --green-900: #1B5E20;
  --green-800: #2E7D32;
  --green-700: #388E3C;
  --green-600: #43A047;
  --green-50:  #E8F5E9;

  --gray-900:  #0F172A;
  --gray-800:  #1E293B;
  --gray-700:  #334155;
  --gray-600:  #475569;
  --gray-500:  #64748B;
  --gray-400:  #94A3B8;
  --gray-300:  #CBD5E1;
  --gray-200:  #E2E8F0;
  --gray-100:  #F1F5F9;
  --gray-50:   #F8FAFC;
  --white:     #FFFFFF;

  --danger:    #C62828;
  --warning:   #F57F17;
  --success:   #2E7D32;

  --shadow-xs: 0 1px 2px rgba(0,0,0,.06);
  --shadow-sm: 0 1px 4px rgba(0,0,0,.08);
  --shadow-md: 0 4px 12px rgba(0,0,0,.10);
  --shadow-lg: 0 8px 24px rgba(0,0,0,.12);
  --shadow-xl: 0 16px 40px rgba(0,0,0,.14);

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-xl: 24px;

  --transition: all .18s ease;
  --font: 'Inter', system-ui, -apple-system, sans-serif;
}

/* ── Reset ──────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; scroll-behavior: smooth; }

body {
  font-family: var(--font);
  background: var(--gray-100);
  color: var(--gray-900);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a { color: var(--blue-800); text-decoration: none; transition: var(--transition); }
a:hover { color: var(--blue-700); }
img { max-width: 100%; }
ul { list-style: none; }

/* ── Layout ─────────────────────────────────────────────────────── */
.container {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 24px;
}
main { flex: 1; }

/* ── HEADER ─────────────────────────────────────────────────────── */
header {
  background: var(--blue-800);
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow-md);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
  gap: 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
}

.brand-logo {
  width: 38px;
  height: 38px;
  background: var(--white);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 1.1rem;
  color: var(--blue-800);
  flex-shrink: 0;
}

.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}

.brand-name {
  font-size: 1rem;
  font-weight: 700;
  color: var(--white);
  letter-spacing: -.3px;
}

.brand-sub {
  font-size: .7rem;
  color: rgba(255,255,255,.65);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: .5px;
}

.header-nav {
  display: flex;
  align-items: center;
  gap: 4px;
}

.nav-link {
  color: rgba(255,255,255,.85);
  font-size: .875rem;
  font-weight: 500;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  transition: var(--transition);
}

.nav-link:hover { background: rgba(255,255,255,.12); color: var(--white); }

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* ── Buttons ─────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font);
  font-weight: 600;
  font-size: .875rem;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  padding: 10px 20px;
  transition: var(--transition);
  white-space: nowrap;
  text-decoration: none;
}

.btn-primary {
  background: var(--green-700);
  color: var(--white);
}
.btn-primary:hover { background: var(--green-800); color: var(--white); transform: translateY(-1px); box-shadow: var(--shadow-sm); }

.btn-outline {
  background: transparent;
  border: 1.5px solid rgba(255,255,255,.5);
  color: var(--white);
}
.btn-outline:hover { background: rgba(255,255,255,.12); border-color: var(--white); color: var(--white); }

.btn-ghost {
  background: transparent;
  color: var(--blue-800);
  border: 1.5px solid var(--gray-300);
}
.btn-ghost:hover { border-color: var(--blue-800); background: var(--blue-50); }

.btn-lg { padding: 14px 28px; font-size: 1rem; border-radius: var(--radius-md); }
.btn-sm { padding: 7px 14px; font-size: .81rem; }
.btn-block { width: 100%; justify-content: center; }

.btn-blue    { background: var(--blue-800);  color: var(--white); }
.btn-blue:hover { background: var(--blue-900); color: var(--white); }
.btn-green   { background: var(--green-700); color: var(--white); }
.btn-green:hover { background: var(--green-800); color: var(--white); }
.btn-danger  { background: var(--danger);    color: var(--white); }

/* ── HERO ───────────────────────────────────────────────────────── */
.hero {
  background: linear-gradient(135deg, var(--blue-900) 0%, var(--blue-800) 50%, var(--green-800) 100%);
  padding: 64px 0;
  color: var(--white);
  position: relative;
  overflow: hidden;
}

.hero::before {
  content: '';
  position: absolute;
  inset: 0;
  background: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23ffffff' fill-opacity='0.03'%3E%3Ccircle cx='30' cy='30' r='20'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
  pointer-events: none;
}

.hero-content { position: relative; z-index: 1; }

.hero-tags {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.tag {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: .75rem;
  font-weight: 600;
  letter-spacing: .3px;
}

.tag-green  { background: var(--green-700); color: var(--white); }
.tag-blue   { background: rgba(255,255,255,.15); color: var(--white); border: 1px solid rgba(255,255,255,.25); }

.hero h1 {
  font-size: clamp(1.8rem, 4vw, 2.75rem);
  font-weight: 800;
  line-height: 1.2;
  letter-spacing: -.5px;
  margin-bottom: 16px;
}

.hero-sub {
  font-size: 1.1rem;
  color: rgba(255,255,255,.8);
  margin-bottom: 32px;
  max-width: 540px;
}

.hero-search {
  display: flex;
  max-width: 560px;
  background: var(--white);
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: var(--shadow-lg);
}

.hero-search input {
  flex: 1;
  border: none;
  outline: none;
  padding: 14px 18px;
  font-size: 1rem;
  font-family: var(--font);
  color: var(--gray-900);
}

.hero-search button {
  background: var(--green-700);
  color: var(--white);
  border: none;
  padding: 14px 22px;
  font-weight: 600;
  font-size: .9rem;
  cursor: pointer;
  font-family: var(--font);
  transition: var(--transition);
}
.hero-search button:hover { background: var(--green-800); }

/* ── Badges ─────────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .3px;
}

.badge-green  { background: var(--green-50); color: var(--green-800); }
.badge-blue   { background: var(--blue-50);  color: var(--blue-800);  }
.badge-gray   { background: var(--gray-200); color: var(--gray-600);  }
.badge-warn   { background: #FFF9C4; color: var(--warning); }

/* ── SERVICE CATEGORY CARDS ─────────────────────────────────────── */
.section {
  padding: 48px 0;
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 28px;
}

.section-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--gray-900);
  letter-spacing: -.3px;
}

.section-subtitle {
  color: var(--gray-500);
  font-size: .9rem;
  margin-top: 4px;
}

.categories-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 20px;
}

.cat-card {
  background: var(--white);
  border-radius: var(--radius-md);
  padding: 24px;
  box-shadow: var(--shadow-sm);
  border-top: 4px solid var(--blue-800);
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  flex-direction: column;
  gap: 12px;
  text-decoration: none;
  color: inherit;
  position: relative;
  overflow: hidden;
}

.cat-card::after {
  content: '→';
  position: absolute;
  right: 20px;
  top: 50%;
  transform: translateY(-50%) translateX(8px);
  font-size: 1.2rem;
  color: var(--blue-700);
  opacity: 0;
  transition: var(--transition);
}

.cat-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-3px);
  border-top-color: var(--green-700);
  color: inherit;
}

.cat-card:hover::after { opacity: 1; transform: translateY(-50%) translateX(0); }

.cat-card--verde  { border-top-color: var(--green-700); }
.cat-card--roxo   { border-top-color: #7B1FA2; }
.cat-card--laranja{ border-top-color: #E65100; }
.cat-card--azul   { border-top-color: var(--blue-800); }
.cat-card--teal   { border-top-color: #00695C; }
.cat-card--rosa   { border-top-color: #AD1457; }
.cat-card--indigo { border-top-color: #283593; }
.cat-card--ciano  { border-top-color: #00838F; }
.cat-card--cinza  { border-top-color: #37474F; }

.cat-icon {
  font-size: 2rem;
  line-height: 1;
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--gray-100);
  border-radius: var(--radius-sm);
}

.cat-name {
  font-size: 1rem;
  font-weight: 700;
  color: var(--gray-900);
  line-height: 1.3;
}

.cat-desc {
  font-size: .82rem;
  color: var(--gray-500);
  line-height: 1.5;
}

.cat-count {
  font-size: .78rem;
  color: var(--blue-800);
  font-weight: 600;
}

/* ── SERVICE LIST ───────────────────────────────────────────────── */
.service-item {
  display: flex;
  align-items: center;
  gap: 16px;
  background: var(--white);
  border-radius: var(--radius-md);
  padding: 18px 20px;
  box-shadow: var(--shadow-xs);
  margin-bottom: 12px;
  transition: var(--transition);
  text-decoration: none;
  color: inherit;
}

.service-item:hover {
  box-shadow: var(--shadow-sm);
  transform: translateX(4px);
}

.service-item-info { flex: 1; }
.service-item-name { font-weight: 600; font-size: .95rem; color: var(--gray-900); }
.service-item-meta { font-size: .78rem; color: var(--gray-500); margin-top: 3px; }
.service-item-action { flex-shrink: 0; }

/* ── CARDS generic ──────────────────────────────────────────────── */
.card {
  background: var(--white);
  border-radius: var(--radius-md);
  padding: 24px;
  box-shadow: var(--shadow-sm);
}

.card-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--gray-900);
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 10px;
}

/* ── Stats ──────────────────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 32px;
}

.stat-card {
  background: var(--white);
  border-radius: var(--radius-md);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: center;
  gap: 16px;
}

.stat-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  background: var(--blue-50);
  flex-shrink: 0;
}

.stat-icon--green  { background: var(--green-50); }
.stat-icon--orange { background: #FFF3E0; }
.stat-icon--purple { background: #F3E5F5; }

.stat-val  { font-size: 1.5rem; font-weight: 800; color: var(--gray-900); }
.stat-label{ font-size: .78rem; color: var(--gray-500); font-weight: 500; }

/* ── FORMS ──────────────────────────────────────────────────────── */
.form-card {
  background: var(--white);
  border-radius: var(--radius-lg);
  padding: 40px;
  box-shadow: var(--shadow-md);
  max-width: 640px;
  margin: 0 auto;
}

.form-title {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--gray-900);
  margin-bottom: 6px;
  letter-spacing: -.4px;
}

.form-subtitle {
  color: var(--gray-500);
  font-size: .9rem;
  margin-bottom: 28px;
}

.form-group {
  margin-bottom: 20px;
}

.form-label {
  display: block;
  font-size: .82rem;
  font-weight: 600;
  color: var(--gray-700);
  margin-bottom: 7px;
  letter-spacing: .2px;
}

.form-label span { color: var(--danger); }

.form-input,
.form-select {
  width: 100%;
  padding: 11px 14px;
  border: 1.5px solid var(--gray-300);
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: .9rem;
  color: var(--gray-900);
  background: var(--white);
  outline: none;
  transition: var(--transition);
  appearance: none;
}

.form-input:focus,
.form-select:focus {
  border-color: var(--blue-700);
  box-shadow: 0 0 0 3px rgba(25, 118, 210, .12);
}

.form-input.error { border-color: var(--danger); }
.form-input::placeholder { color: var(--gray-400); }

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.form-hint {
  font-size: .76rem;
  color: var(--gray-500);
  margin-top: 5px;
}

.form-error {
  font-size: .76rem;
  color: var(--danger);
  margin-top: 5px;
  display: none;
}

.form-divider {
  border: none;
  border-top: 1.5px solid var(--gray-200);
  margin: 28px 0;
}

/* ── Stepper ─────────────────────────────────────────────────────── */
.stepper {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 36px;
}

.step-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  flex: 1;
  cursor: default;
}

.step-circle {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: .85rem;
  border: 2px solid var(--gray-300);
  color: var(--gray-400);
  background: var(--white);
  transition: var(--transition);
}

.step-item.active .step-circle {
  border-color: var(--blue-800);
  background: var(--blue-800);
  color: var(--white);
}

.step-item.done .step-circle {
  border-color: var(--green-700);
  background: var(--green-700);
  color: var(--white);
}

.step-label {
  font-size: .7rem;
  font-weight: 600;
  color: var(--gray-500);
  text-align: center;
  white-space: nowrap;
}

.step-item.active .step-label { color: var(--blue-800); }
.step-item.done  .step-label  { color: var(--green-700); }

.step-line {
  flex: 1;
  height: 2px;
  background: var(--gray-200);
  min-width: 20px;
  margin-top: -18px;
  align-self: flex-start;
}

.step-line.done { background: var(--green-700); }

/* ── Alert / Notification ───────────────────────────────────────── */
.alert {
  display: flex;
  gap: 12px;
  padding: 14px 18px;
  border-radius: var(--radius-sm);
  font-size: .9rem;
  margin-bottom: 20px;
  line-height: 1.5;
}

.alert-success { background: var(--green-50); border-left: 4px solid var(--green-700); color: var(--green-900); }
.alert-error   { background: #FFEBEE; border-left: 4px solid var(--danger); color: var(--danger); }
.alert-info    { background: var(--blue-50);  border-left: 4px solid var(--blue-700);  color: var(--blue-900);  }
.alert-warn    { background: #FFF9C4; border-left: 4px solid var(--warning); color: #5D4037; }

/* ── Auth gateway ──────────────────────────────────────────────── */
.auth-required {
  opacity: .6;
  pointer-events: none;
  position: relative;
}

.auth-gate {
  display: none;
  position: absolute;
  inset: 0;
  background: rgba(255,255,255,.85);
  border-radius: var(--radius-md);
  align-items: center;
  justify-content: center;
  z-index: 10;
}

/* ── DASHBOARD ──────────────────────────────────────────────────── */
.dashboard-grid {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 24px;
  align-items: start;
}

.user-card {
  background: linear-gradient(135deg, var(--blue-800), var(--blue-700));
  color: var(--white);
  border-radius: var(--radius-md);
  padding: 24px;
  text-align: center;
}

.user-avatar {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: rgba(255,255,255,.2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.8rem;
  font-weight: 800;
  margin: 0 auto 16px;
  border: 3px solid rgba(255,255,255,.3);
}

.user-name  { font-weight: 700; font-size: 1.1rem; }
.user-cpf   { font-size: .78rem; opacity: .75; margin-top: 4px; }
.user-since { font-size: .75rem; opacity: .65; margin-top: 12px; }

.history-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 0;
  border-bottom: 1px solid var(--gray-100);
}
.history-item:last-child { border-bottom: none; }

.history-icon {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-sm);
  background: var(--blue-50);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  flex-shrink: 0;
}

.history-info { flex: 1; }
.history-name { font-weight: 600; font-size: .88rem; }
.history-date { font-size: .75rem; color: var(--gray-500); margin-top: 2px; }

/* ── PAGE HEADER ────────────────────────────────────────────────── */
.page-header {
  background: var(--white);
  border-bottom: 1px solid var(--gray-200);
  padding: 24px 0;
}

.page-header h1 {
  font-size: 1.6rem;
  font-weight: 800;
  letter-spacing: -.4px;
}

.breadcrumb {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--gray-500);
  font-size: .8rem;
  margin-bottom: 8px;
}

.breadcrumb a { color: var(--blue-800); }
.breadcrumb span { color: var(--gray-400); }

/* ── FOOTER ─────────────────────────────────────────────────────── */
footer {
  background: var(--gray-900);
  color: rgba(255,255,255,.7);
  padding: 48px 0 24px;
  margin-top: auto;
}

.footer-grid {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1fr;
  gap: 40px;
  margin-bottom: 40px;
}

.footer-brand .brand-name { color: var(--white); font-size: 1.1rem; }
.footer-brand .brand-sub  { color: rgba(255,255,255,.5); }
.footer-desc {
  font-size: .83rem;
  line-height: 1.7;
  margin-top: 16px;
  color: rgba(255,255,255,.55);
}

.footer-title {
  font-size: .82rem;
  font-weight: 700;
  color: var(--white);
  text-transform: uppercase;
  letter-spacing: .7px;
  margin-bottom: 16px;
}

.footer-links li { margin-bottom: 10px; }
.footer-links a {
  font-size: .83rem;
  color: rgba(255,255,255,.55);
  transition: var(--transition);
}
.footer-links a:hover { color: var(--white); }

.footer-bottom {
  border-top: 1px solid rgba(255,255,255,.1);
  padding-top: 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: .78rem;
  color: rgba(255,255,255,.4);
}

/* ── Modal ──────────────────────────────────────────────────────── */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.modal-overlay.active { display: flex; }

.modal {
  background: var(--white);
  border-radius: var(--radius-lg);
  padding: 32px;
  max-width: 480px;
  width: 100%;
  box-shadow: var(--shadow-xl);
}

.modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 20px;
}

.modal-title { font-size: 1.2rem; font-weight: 700; }
.modal-close {
  background: none;
  border: none;
  font-size: 1.4rem;
  cursor: pointer;
  color: var(--gray-500);
  padding: 0;
  line-height: 1;
}

/* ── Select custom arrow ──────────────────────────────────────────*/
.select-wrapper {
  position: relative;
}
.select-wrapper::after {
  content: '▾';
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  pointer-events: none;
  color: var(--gray-500);
  font-size: .82rem;
}
.select-wrapper .form-select { padding-right: 36px; }

/* ── Skeleton loading ───────────────────────────────────────────── */
.skeleton {
  background: linear-gradient(90deg, var(--gray-200) 25%, var(--gray-100) 50%, var(--gray-200) 75%);
  background-size: 200% 100%;
  animation: skeleton-anim 1.2s infinite;
  border-radius: 4px;
}

@keyframes skeleton-anim {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ── Spinner ────────────────────────────────────────────────────── */
.spinner {
  width: 20px;
  height: 20px;
  border: 2.5px solid rgba(255,255,255,.3);
  border-top-color: var(--white);
  border-radius: 50%;
  animation: spin .6s linear infinite;
  flex-shrink: 0;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Responsive ─────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .header-nav    { display: none; }
  .footer-grid   { grid-template-columns: 1fr 1fr; }
  .form-row      { grid-template-columns: 1fr; }
  .dashboard-grid{ grid-template-columns: 1fr; }
  .form-card     { padding: 24px 20px; }
  .hero          { padding: 40px 0; }
}

@media (max-width: 480px) {
  .categories-grid{ grid-template-columns: 1fr; }
  .footer-grid    { grid-template-columns: 1fr; }
  .stepper        { gap: 4px; }
  .step-label     { font-size: .65rem; }
}
