/* =============================================
   IMÓVEIS COMPARADOR — Design System
   Estética: Dashboard premium, tons neutros escuros com accent âmbar
   Font: Sora (headings) + DM Sans (body)
============================================= */

@import url('https://fonts.googleapis.com/css2?family=Sora:wght@300;400;500;600;700;800&family=DM+Sans:ital,opsz,wght@0,9..40,300;0,9..40,400;0,9..40,500;0,9..40,600;1,9..40,400&display=swap');

:root {
  --bg: #0f1117;
  --bg2: #161b27;
  --bg3: #1e2536;
  --border: #2a3147;
  --border2: #3a4560;
  --text: #e8eaf0;
  --text2: #9aa5be;
  --text3: #5f6b82;
  --accent: #f59e0b;
  --accent2: #fbbf24;
  --accent-dim: rgba(245, 158, 11, 0.12);
  --green: #22c55e;
  --green-dim: rgba(34, 197, 94, 0.12);
  --red: #ef4444;
  --red-dim: rgba(239, 68, 68, 0.12);
  --blue: #3b82f6;
  --blue-dim: rgba(59, 130, 246, 0.12);
  --purple: #a855f7;
  --shadow: 0 4px 24px rgba(0,0,0,0.4);
  --radius: 12px;
  --radius-sm: 8px;
  --font-head: 'Sora', sans-serif;
  --font-body: 'DM Sans', sans-serif;
}

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

html { scroll-behavior: smooth; }

body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  font-size: 14px;
  line-height: 1.6;
}

/* ---- LAYOUT ---- */
.app-layout { display: flex; min-height: 100vh; }

.sidebar {
  width: 240px;
  background: var(--bg2);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  transition: transform 0.3s;
}

.sidebar-logo {
  padding: 24px 20px 16px;
  border-bottom: 1px solid var(--border);
}

.sidebar-logo .logo-icon {
  width: 36px; height: 36px;
  background: var(--accent);
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; margin-bottom: 10px;
}

.sidebar-logo h1 {
  font-family: var(--font-head);
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.2;
}

.sidebar-logo p {
  font-size: 11px;
  color: var(--text3);
  margin-top: 2px;
}

.sidebar-nav { flex: 1; padding: 16px 12px; overflow-y: auto; }

.nav-section-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text3);
  padding: 12px 8px 6px;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: var(--radius-sm);
  color: var(--text2);
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 500;
  transition: all 0.15s;
  margin-bottom: 2px;
}

.nav-link:hover { background: var(--bg3); color: var(--text); }
.nav-link.active { background: var(--accent-dim); color: var(--accent); }
.nav-link .icon { width: 18px; text-align: center; font-size: 15px; }

.sidebar-footer {
  padding: 16px;
  border-top: 1px solid var(--border);
  font-size: 11px;
  color: var(--text3);
}

.main-content {
  flex: 1;
  margin-left: 240px;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.top-bar {
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  padding: 0 28px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky; top: 0; z-index: 50;
}

.top-bar-title {
  font-family: var(--font-head);
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
}

.breadcrumb {
  display: flex; align-items: center; gap: 6px;
  font-size: 12px; color: var(--text3);
}
.breadcrumb a { color: var(--text2); text-decoration: none; }
.breadcrumb a:hover { color: var(--accent); }
.breadcrumb span { color: var(--text3); }

.page-content { padding: 28px; flex: 1; }

/* ---- CARDS ---- */
.card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}

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

.card-title {
  font-family: var(--font-head);
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

.card-subtitle {
  font-size: 12px;
  color: var(--text3);
  margin-top: 2px;
}

/* ---- STAT CARDS ---- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}

.stat-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  transition: border-color 0.2s;
}

.stat-card:hover { border-color: var(--border2); }

.stat-card .label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text3);
  margin-bottom: 8px;
}

.stat-card .value {
  font-family: var(--font-head);
  font-size: 24px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.1;
}

.stat-card .value.accent { color: var(--accent); }
.stat-card .value.green { color: var(--green); }
.stat-card .value.red { color: var(--red); }

.stat-card .meta {
  font-size: 12px;
  color: var(--text3);
  margin-top: 4px;
}

/* ---- TABELAS ---- */
.table-wrap { overflow-x: auto; border-radius: var(--radius); }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

thead th {
  background: var(--bg3);
  color: var(--text3);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  padding: 10px 14px;
  text-align: left;
  white-space: nowrap;
  border-bottom: 1px solid var(--border);
}

tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background 0.1s;
}

tbody tr:hover { background: var(--bg3); }
tbody tr:last-child { border-bottom: none; }

tbody td {
  padding: 12px 14px;
  color: var(--text);
  vertical-align: middle;
}

tbody td .meta { font-size: 11px; color: var(--text3); }

.td-nome { font-weight: 500; }
.td-nome a { color: var(--text); text-decoration: none; }
.td-nome a:hover { color: var(--accent); }

/* ---- BADGES ---- */
.badge {
  display: inline-flex; align-items: center;
  padding: 3px 8px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}

.badge-warning { background: rgba(245,158,11,0.15); color: #f59e0b; }
.badge-success { background: var(--green-dim); color: var(--green); }
.badge-danger { background: var(--red-dim); color: var(--red); }
.badge-primary { background: var(--blue-dim); color: var(--blue); }
.badge-secondary { background: var(--bg3); color: var(--text2); border: 1px solid var(--border); }
.badge-info { background: rgba(168,85,247,0.12); color: var(--purple); }

/* ---- SCORE PILL ---- */
.score-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 46px; height: 24px;
  border-radius: 12px;
  font-family: var(--font-head);
  font-size: 12px;
  font-weight: 700;
}

.score-pill.high { background: var(--green-dim); color: var(--green); }
.score-pill.mid { background: rgba(245,158,11,0.15); color: var(--accent); }
.score-pill.low { background: var(--red-dim); color: var(--red); }

/* ---- RANKING BADGE ---- */
.rank-badge {
  display: inline-flex; align-items: center; justify-content: center;
  width: 28px; height: 28px;
  border-radius: 50%;
  font-family: var(--font-head);
  font-size: 12px;
  font-weight: 800;
}

.rank-1 { background: var(--accent); color: #000; }
.rank-2 { background: #94a3b8; color: #000; }
.rank-3 { background: #cd7f32; color: #fff; }
.rank-other { background: var(--bg3); color: var(--text3); border: 1px solid var(--border); }

/* ---- BOTÕES ---- */
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 9px 16px;
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  text-decoration: none;
  transition: all 0.15s;
  white-space: nowrap;
}

.btn-primary { background: var(--accent); color: #000; }
.btn-primary:hover { background: var(--accent2); }

.btn-secondary { background: var(--bg3); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { border-color: var(--border2); background: #252d40; }

.btn-danger { background: var(--red-dim); color: var(--red); border: 1px solid rgba(239,68,68,0.2); }
.btn-danger:hover { background: var(--red); color: #fff; }

.btn-ghost { background: transparent; color: var(--text2); }
.btn-ghost:hover { color: var(--text); background: var(--bg3); }

.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-lg { padding: 12px 22px; font-size: 14px; }

/* ---- FORMULÁRIOS ---- */
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 16px; }
.form-grid-2 { grid-template-columns: 1fr 1fr; }
.form-grid-3 { grid-template-columns: 1fr 1fr 1fr; }

.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-group.full { grid-column: 1 / -1; }

label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text2);
  letter-spacing: 0.02em;
}

label .req { color: var(--red); margin-left: 3px; }

input[type="text"],
input[type="number"],
input[type="email"],
input[type="date"],
input[type="url"],
select,
textarea {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 13px;
  padding: 9px 12px;
  transition: border-color 0.15s;
  width: 100%;
  outline: none;
}

input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}

input::placeholder, textarea::placeholder { color: var(--text3); }

select { cursor: pointer; }
select option { background: var(--bg3); }

textarea { resize: vertical; min-height: 80px; }

input[type="file"] {
  padding: 8px 12px;
  cursor: pointer;
  font-size: 12px;
  color: var(--text2);
}

.input-hint { font-size: 11px; color: var(--text3); }

.form-section {
  margin-bottom: 32px;
}

.form-section-title {
  font-family: var(--font-head);
  font-size: 13px;
  font-weight: 700;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
  display: flex; align-items: center; gap: 8px;
}

/* ---- ALERTAS/FLASH ---- */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 20px;
  display: flex; align-items: center; gap: 10px;
  border: 1px solid transparent;
}

.alert-success { background: var(--green-dim); color: var(--green); border-color: rgba(34,197,94,0.2); }
.alert-danger { background: var(--red-dim); color: var(--red); border-color: rgba(239,68,68,0.2); }
.alert-info { background: var(--blue-dim); color: var(--blue); border-color: rgba(59,130,246,0.2); }
.alert-warning { background: rgba(245,158,11,0.1); color: var(--accent); border-color: rgba(245,158,11,0.25); }

/* ---- DETALHE IMÓVEL ---- */
.detail-header {
  position: relative;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 24px;
}

.detail-photo {
  width: 100%; height: 300px;
  object-fit: cover;
  display: block;
}

.detail-photo-placeholder {
  width: 100%; height: 280px;
  background: var(--bg3);
  display: flex; align-items: center; justify-content: center;
  font-size: 48px; color: var(--text3);
}

.detail-title-block {
  padding: 20px 24px;
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.detail-title h1 {
  font-family: var(--font-head);
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.2;
  margin-bottom: 6px;
}

.detail-meta { font-size: 13px; color: var(--text2); display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.detail-meta span { display: flex; align-items: center; gap: 5px; }

.detail-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---- BLOCOS INFO ---- */
.info-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; }

.info-item { display: flex; flex-direction: column; gap: 3px; }
.info-item .lbl { font-size: 11px; color: var(--text3); font-weight: 500; }
.info-item .val { font-size: 14px; color: var(--text); font-weight: 500; }
.info-item .val.accent { color: var(--accent); font-weight: 700; }
.info-item .val.green { color: var(--green); }
.info-item .val.red { color: var(--red); }

/* ---- FINANCEIRO RESUMO ---- */
.finance-blocks { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 16px; margin-bottom: 24px; }

.finance-block {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
}

.finance-block-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text3);
  margin-bottom: 14px;
}

.finance-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 7px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}

.finance-row:last-child { border-bottom: none; font-weight: 700; color: var(--accent); }
.finance-row .fr-label { color: var(--text2); }
.finance-row .fr-value { font-weight: 500; color: var(--text); text-align: right; }
.finance-row.total .fr-value { color: var(--accent); }

/* ---- SCORE DISPLAY ---- */
.score-display {
  display: flex; align-items: center; gap: 20px;
  flex-wrap: wrap;
}

.score-big {
  display: flex; flex-direction: column; align-items: center;
  min-width: 90px;
}

.score-big .num {
  font-family: var(--font-head);
  font-size: 40px;
  font-weight: 800;
  line-height: 1;
}

.score-big .lbl {
  font-size: 11px;
  color: var(--text3);
  margin-top: 4px;
}

.score-bars { flex: 1; display: flex; flex-direction: column; gap: 8px; }

.score-bar-row { display: flex; align-items: center; gap: 10px; }
.score-bar-row .lbl { font-size: 12px; color: var(--text2); width: 120px; flex-shrink: 0; }
.score-bar-bg { flex: 1; height: 6px; background: var(--bg3); border-radius: 3px; overflow: hidden; }
.score-bar-fill { height: 100%; border-radius: 3px; transition: width 0.5s ease; }
.score-bar-row .num { font-size: 12px; font-weight: 600; color: var(--text2); width: 28px; text-align: right; }

/* ---- GALERIA ---- */
.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 10px;
}

.gallery-item {
  position: relative;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--bg3);
  border: 1px solid var(--border);
  aspect-ratio: 4/3;
}

.gallery-item img {
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.2s;
}

.gallery-item:hover img { transform: scale(1.05); }

.gallery-item .del-btn {
  position: absolute; top: 6px; right: 6px;
  background: rgba(0,0,0,0.7);
  border: none; color: #fff;
  width: 24px; height: 24px;
  border-radius: 50%;
  cursor: pointer; font-size: 12px;
  display: flex; align-items: center; justify-content: center;
  opacity: 0;
  transition: opacity 0.15s;
}

.gallery-item:hover .del-btn { opacity: 1; }

.pdf-item {
  display: flex; align-items: center; gap: 10px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  margin-bottom: 8px;
  transition: border-color 0.15s;
}

.pdf-item:hover { border-color: var(--border2); }
.pdf-item a { color: var(--text); text-decoration: none; font-size: 13px; flex: 1; }
.pdf-item a:hover { color: var(--accent); }

/* ---- COMPARAÇÃO ---- */
.compare-table { width: 100%; border-collapse: collapse; }
.compare-table .field-col { 
  background: var(--bg3); width: 200px;
  font-size: 12px; font-weight: 500; color: var(--text2);
  padding: 10px 14px; border-bottom: 1px solid var(--border);
}
.compare-table .val-col {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  text-align: center;
  font-size: 13px;
}
.compare-table .header-col {
  background: var(--bg2); padding: 14px;
  text-align: center; border-bottom: 2px solid var(--accent);
}
.compare-table .section-row td {
  background: var(--bg);
  font-size: 11px; font-weight: 700;
  color: var(--accent); letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 8px 14px;
}
.compare-table .best { background: var(--green-dim); color: var(--green); font-weight: 700; }
.compare-table .worst { background: var(--red-dim); color: var(--red); }

/* ---- RANKING PAGE ---- */
.ranking-item {
  display: flex; align-items: center;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  margin-bottom: 12px;
  gap: 18px;
  transition: border-color 0.2s;
  text-decoration: none;
  color: inherit;
}

.ranking-item:hover { border-color: var(--border2); }
.ranking-item.rank-top { border-color: rgba(245,158,11,0.3); background: rgba(245,158,11,0.04); }

.ranking-item .ri-rank { flex-shrink: 0; }
.ranking-item .ri-info { flex: 1; min-width: 0; }
.ranking-item .ri-nome { font-weight: 600; font-size: 15px; color: var(--text); }
.ranking-item .ri-sub { font-size: 12px; color: var(--text3); margin-top: 2px; }
.ranking-item .ri-numbers { display: flex; gap: 20px; flex-wrap: wrap; }
.ranking-item .ri-num { text-align: right; }
.ranking-item .ri-num .lbl { font-size: 10px; color: var(--text3); }
.ranking-item .ri-num .val { font-size: 14px; font-weight: 600; color: var(--text); }

/* ---- PROGRESS BAR ---- */
.progress { height: 6px; background: var(--bg3); border-radius: 3px; overflow: hidden; }
.progress-fill { height: 100%; border-radius: 3px; background: var(--accent); }
.progress-fill.green { background: var(--green); }
.progress-fill.red { background: var(--red); }

/* ---- UPLOAD ÁREA ---- */
.upload-area {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 32px;
  text-align: center;
  transition: border-color 0.2s;
  cursor: pointer;
}

.upload-area:hover { border-color: var(--accent); }
.upload-area .icon { font-size: 32px; margin-bottom: 10px; }
.upload-area p { font-size: 13px; color: var(--text2); }
.upload-area small { color: var(--text3); }

/* ---- TABS ---- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 20px; }
.tab {
  padding: 9px 16px;
  font-size: 13px; font-weight: 500;
  color: var(--text2); cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all 0.15s;
  margin-bottom: -1px;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }

.tab-content { display: none; }
.tab-content.active { display: block; }

/* ---- UTILIDADES ---- */
.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.flex-gap { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.gap-sm { gap: 8px; }
.mt-4 { margin-top: 4px; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mb-16 { margin-bottom: 16px; }
.mb-24 { margin-bottom: 24px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 20px; }
.text-muted { color: var(--text3); }
.text-accent { color: var(--accent); }
.text-green { color: var(--green); }
.text-red { color: var(--red); }
.text-center { text-align: center; }
.fw-bold { font-weight: 700; }
.font-mono { font-family: 'Courier New', monospace; }

.divider { height: 1px; background: var(--border); margin: 20px 0; }

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

.empty-state .icon { font-size: 48px; margin-bottom: 16px; opacity: 0.4; }
.empty-state h3 { font-size: 18px; color: var(--text2); margin-bottom: 8px; }
.empty-state p { font-size: 14px; margin-bottom: 20px; }

/* ---- RESPONSIVO ---- */
@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .form-grid-2, .form-grid-3 { grid-template-columns: 1fr; }
}

/* ---- ANIMAÇÕES ---- */
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
.animate-in { animation: fadeIn 0.3s ease forwards; }

/* ---- SCROLLBAR ---- */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text3); }

/* ---- NÚMERO GRANDE ---- */
.big-number {
  font-family: var(--font-head);
  font-size: 28px;
  font-weight: 800;
  color: var(--accent);
}

/* ---- TOGGLE ---- */
.toggle-wrap { display: flex; gap: 10px; align-items: center; }
.toggle { display: flex; gap: 6px; }
.toggle label {
  padding: 7px 14px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 13px;
  background: var(--bg3);
  border: 1px solid var(--border);
  color: var(--text2);
  transition: all 0.15s;
}
.toggle input { display: none; }
.toggle input:checked + label { background: var(--accent-dim); color: var(--accent); border-color: rgba(245,158,11,0.3); }
