/* RendaOK — Shell de 3 zonas do app (§28.0 CLAUDE.md)
   Topbar 46px + sidebar 200px esquerda + tabs 38px + conteudo.
   Usado em dashboard.html e ficha-imovel.html.
   Requer base.css carregado antes (tokens + fontes + Tabler Icons). */

:root {
  --shell-topbar-h: 46px;
  --shell-sidebar-w: 200px;
  --shell-tabs-h: 38px;
}

html, body { height: 100%; }
body.shell-body { background: var(--bg); overflow: hidden; }

.shell {
  display: grid;
  grid-template-rows: var(--shell-topbar-h) 1fr;
  grid-template-columns: var(--shell-sidebar-w) 1fr;
  grid-template-areas:
    "topbar topbar"
    "sidebar main";
  height: 100vh;
  width: 100vw;
}

/* ================================
   TOPBAR
   ================================ */
.shell-topbar {
  grid-area: topbar;
  background: #fff;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px 0 20px;
  position: relative;
  z-index: 10;
}
.shell-topbar-left,
.shell-topbar-center,
.shell-topbar-right { display: flex; align-items: center; gap: 12px; }

.shell-brand {
  font-family: 'Bricolage Grotesque', sans-serif;
  font-weight: 700;
  font-size: 18px;
  letter-spacing: -0.025em;
  color: var(--ink);
  text-decoration: none;
}
.shell-brand .renda { color: var(--green); }
.shell-brand .ok    { font-family: 'Instrument Serif', serif; font-style: italic; color: var(--amber); font-weight: 400; margin-left: 1px; }

.trial-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 4px 12px;
  border-radius: 999px;
  background: var(--amber-soft);
  border: 1px solid rgba(194, 101, 10, 0.18);
  font-family: 'Geist Mono', monospace;
  font-size: 10.5px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--amber);
  font-weight: 600;
}
.trial-pill::before {
  content: '';
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--green);
  animation: tpulse 2s infinite;
}
@keyframes tpulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.4; } }

.storage-meter { display: inline-flex; align-items: center; gap: 8px; font-family: 'Geist Mono', monospace; font-size: 10px; color: var(--ink-3); letter-spacing: 0.04em; }
.storage-meter .track { width: 56px; height: 3px; background: var(--cream); border-radius: 999px; overflow: hidden; }
.storage-meter .fill  { height: 100%; background: var(--green); border-radius: 999px; transition: width 0.3s, background 0.3s; }
.storage-meter.warn .fill   { background: var(--amber); }
.storage-meter.danger .fill { background: var(--red); }

.avatar-mini {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--green-soft);
  border: 1.5px solid rgba(27, 94, 55, 0.25);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: 'Geist Mono', monospace;
  font-size: 10.5px;
  font-weight: 600;
  color: var(--green);
  cursor: pointer;
  letter-spacing: 0.02em;
}
.avatar-mini:hover { border-color: var(--green); }

.shell-topbar-toggle {
  display: none;
  background: none;
  border: 0;
  cursor: pointer;
  width: 32px; height: 32px;
  border-radius: 8px;
  align-items: center;
  justify-content: center;
  color: var(--ink-2);
}
.shell-topbar-toggle:hover { background: var(--paper); color: var(--ink); }

/* ================================
   SIDEBAR
   ================================ */
.shell-sidebar {
  grid-area: sidebar;
  background: #fff;
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  padding: 14px 0;
  overflow-y: auto;
  overflow-x: hidden;
}

.sidebar-section { padding: 0 12px; margin-bottom: 18px; }
.sidebar-section.is-footer { margin-top: auto; margin-bottom: 0; padding-bottom: 12px; border-top: 1px solid var(--line); padding-top: 14px; }
.sidebar-section .section-label {
  font-family: 'Geist Mono', monospace;
  font-size: 9.5px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-3);
  padding: 0 10px;
  margin-bottom: 8px;
  font-weight: 600;
}

.sidebar-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 13.5px;
  color: var(--ink-2);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  position: relative;
  text-decoration: none;
  margin-bottom: 1px;
}
.sidebar-item .ti { font-size: 15px; color: var(--ink-3); flex-shrink: 0; }
.sidebar-item:hover { background: var(--paper); color: var(--ink); }
.sidebar-item:hover .ti { color: var(--ink-2); }

.sidebar-item.is-active {
  background: var(--green-soft);
  color: var(--green);
  font-weight: 500;
}
.sidebar-item.is-active .ti { color: var(--green); }
.sidebar-item.is-active::before {
  content: '';
  position: absolute;
  left: -12px;
  top: 6px;
  bottom: 6px;
  width: 2.5px;
  background: var(--green);
  border-radius: 0 2px 2px 0;
}

.sidebar-item .badge {
  margin-left: auto;
  font-family: 'Geist Mono', monospace;
  font-size: 9.5px;
  font-weight: 600;
  letter-spacing: 0.04em;
  padding: 2px 7px;
  border-radius: 999px;
}
.sidebar-item .badge.red   { background: #FEE2E2; color: #B91C1C; }
.sidebar-item .badge.amber { background: var(--amber-soft); color: var(--amber); }
.sidebar-item .badge.green { background: var(--green-soft); color: var(--green); }

.sidebar-item.is-add {
  border: 1px dashed var(--line-2);
  margin: 0 2px 8px;
  color: var(--green);
  justify-content: flex-start;
  font-weight: 500;
}
.sidebar-item.is-add .ti { color: var(--green); }
.sidebar-item.is-add:hover { background: var(--green-soft); border-color: var(--green); }

/* ================================
   MAIN AREA — TABS + CONTENT
   ================================ */
.shell-main {
  grid-area: main;
  display: grid;
  grid-template-rows: var(--shell-tabs-h) 1fr;
  min-height: 0;
  background: var(--bg);
}
/* Páginas SEM barra de tabs contextual (ex.: ficha-imovel) não devem reservar a
   linha de --shell-tabs-h, senão o conteúdo cai nessa faixa de 38px e o resto da
   altura fica vazio. `:has()` auto-corrige qualquer página sem `.shell-tabs`. */
.shell-main:not(:has(> .shell-tabs)) { grid-template-rows: 1fr; }

.shell-tabs {
  background: #fff;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: stretch;
  padding: 0 24px;
  gap: 0;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;
}
.shell-tabs::-webkit-scrollbar { display: none; }

.shell-tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0 14px;
  font-size: 13px;
  color: var(--ink-3);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  background: none;
  border-left: 0;
  border-right: 0;
  border-top: 0;
  white-space: nowrap;
  transition: color 0.15s, border-color 0.15s;
  font-family: inherit;
  height: 100%;
}
.shell-tab:hover { color: var(--ink); }
.shell-tab.is-active {
  color: var(--green);
  border-bottom-color: var(--green);
  font-weight: 500;
}
.shell-tab .count {
  font-family: 'Geist Mono', monospace;
  font-size: 10px;
  letter-spacing: 0.04em;
  color: var(--ink-3);
  margin-left: 4px;
}
.shell-tab.is-active .count { color: var(--green); }

.shell-content {
  overflow-y: auto;
  overflow-x: hidden;
  padding: 22px 24px 60px;
}

/* ================================
   COMPONENTES DO DASHBOARD
   ================================ */
.shell-h1 {
  font-family: 'Bricolage Grotesque', sans-serif;
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.2;
  margin-bottom: 4px;
}
.shell-sub {
  color: var(--ink-2);
  font-size: 14px;
  margin-bottom: 18px;
}

/* KPIs */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
  margin-bottom: 22px;
}
.metric {
  background: #fff;
  border: 1px solid var(--line-2);
  border-radius: 13px;
  padding: 13px 15px;
  position: relative;
  overflow: hidden;
}
.metric::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: var(--accent, var(--line-2));
}
.metric.is-green  { --accent: var(--green); }
.metric.is-amber  { --accent: var(--amber); }
.metric.is-red    { --accent: var(--red); }

.metric .label {
  font-family: 'Geist Mono', monospace;
  font-size: 9px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-3);
  margin-bottom: 6px;
  font-weight: 600;
}
.metric .value {
  font-family: 'Bricolage Grotesque', sans-serif;
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.025em;
  line-height: 1;
  color: var(--ink);
}
.metric .value .euro {
  font-family: 'Instrument Serif', serif;
  font-style: italic;
  font-weight: 400;
  font-size: 0.52em;
  vertical-align: super;
  color: var(--green);
  margin-right: 2px;
}
.metric.is-green .value { color: var(--green); }
.metric.is-amber .value { color: var(--amber); }
.metric.is-red   .value { color: var(--red); }
.metric .delta { font-size: 11.5px; color: var(--ink-3); margin-top: 4px; }

/* Asset cards */
.asset-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px 16px;
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 12px;
  align-items: center;
  transition: transform 0.15s, border-color 0.15s, box-shadow 0.15s;
  cursor: pointer;
  text-decoration: none;
  color: var(--ink);
  position: relative;
  overflow: hidden;
  margin-bottom: 10px;
}
.asset-card::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: var(--state-color, var(--line-2));
}
.asset-card.is-paid    { --state-color: var(--paid); }
.asset-card.is-pending { --state-color: var(--pending); }
.asset-card.is-overdue { --state-color: var(--overdue); }
.asset-card.is-vacant  { --state-color: var(--cream); }
.asset-card:hover { border-color: var(--line-2); transform: translateX(2px); box-shadow: 0 10px 24px -16px rgba(28, 28, 20, 0.15); }

.asset-card .dot {
  width: 9px; height: 9px;
  border-radius: 50%;
  flex-shrink: 0;
}
.asset-card.is-paid    .dot { background: var(--paid);    box-shadow: 0 0 0 3px rgba(22, 163, 74, 0.12); }
.asset-card.is-pending .dot { background: var(--pending); box-shadow: 0 0 0 3px rgba(217, 119, 6, 0.12); animation: tpulse 2.5s infinite; }
.asset-card.is-overdue .dot { background: var(--overdue); box-shadow: 0 0 0 3px rgba(192, 57, 43, 0.12); }
.asset-card.is-vacant  .dot { background: var(--cream); }

.asset-card .info .n { font-size: 14.5px; font-weight: 500; }
.asset-card .info .m { font-size: 12px; color: var(--ink-3); margin-top: 1px; }
.asset-card .rent {
  font-family: 'Bricolage Grotesque', sans-serif;
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.02em;
  white-space: nowrap;
}
.asset-card .rent .euro { font-family: 'Instrument Serif', serif; font-style: italic; font-weight: 400; font-size: 0.65em; vertical-align: super; color: var(--green); margin-right: 2px; }

/* Section header */
.section-h {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 24px 0 10px;
  gap: 12px;
}
.section-h h2 { font-family: 'Bricolage Grotesque', sans-serif; font-size: 16px; font-weight: 600; letter-spacing: -0.015em; }
.section-h .meta { font-family: 'Geist Mono', monospace; font-size: 10.5px; letter-spacing: 0.05em; text-transform: uppercase; color: var(--ink-3); }

/* Empty state */
.empty-shell {
  background: #fff;
  border: 1px dashed var(--line-2);
  border-radius: 16px;
  padding: 50px 28px;
  text-align: center;
}
.empty-shell h3 { font-family: 'Bricolage Grotesque', sans-serif; font-size: 18px; font-weight: 600; margin-bottom: 6px; }
.empty-shell p { color: var(--ink-2); font-size: 14px; margin-bottom: 18px; }

/* ================================
   MOBILE — sidebar vira drawer
   ================================ */
@media (max-width: 880px) {
  .shell {
    grid-template-columns: 1fr;
    grid-template-areas:
      "topbar"
      "main";
  }
  .shell-sidebar {
    position: fixed;
    top: var(--shell-topbar-h);
    left: -260px;
    width: 260px;
    height: calc(100vh - var(--shell-topbar-h));
    z-index: 50;
    transition: left 0.25s ease;
    box-shadow: 8px 0 32px -20px rgba(0, 0, 0, 0.20);
  }
  .shell-sidebar.is-open { left: 0; }
  .shell-topbar-toggle { display: inline-flex; }
  .shell-backdrop {
    position: fixed;
    inset: var(--shell-topbar-h) 0 0 0;
    background: rgba(28, 28, 20, 0.4);
    z-index: 40;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
  }
  .shell-backdrop.is-open { opacity: 1; pointer-events: auto; }
}
