/* ==========================================================================
   ROCHA IMOBILIÁRIA — FOLHA DE ESTILO DO PAINEL ADMINISTRATIVO
   --------------------------------------------------------------------------
   Complementa o Bootstrap 5. O painel usa o mesmo vocabulário visual do site
   (verde-basalto, latão, cantos chanfrados), mas com foco em densidade e
   clareza: menu lateral escuro, área de trabalho clara e tabelas legíveis.
   Esta mesma folha também estiliza as telas de login (layout "auth").

   Índice
     1. Variáveis
     2. Base e ajustes do Bootstrap
     3. Estrutura: menu lateral, barra superior e área de conteúdo
     4. Cabeçalho de página, cartões e indicadores (dashboard)
     5. Tabelas e listas
     6. Formulários (abas, grupos, ajuda)
     7. Fotografias: envio, grade e reordenação
     8. Tour 3D no painel
     9. Histórico (linha do tempo), badges e detalhes
    10. Tela de login
    11. Responsivo e acessibilidade
   ========================================================================== */


/* ==========================================================================
   1. VARIÁVEIS
   --brand e --accent são sobrescritas pelo layout com as cores das Configurações.
   ========================================================================== */
:root {
    --brand: #1c3a38;
    --accent: #c79a4a;
    --brand-dark: color-mix(in srgb, var(--brand) 70%, #000);   /* versão mais escura da marca */
    --brand-soft: color-mix(in srgb, var(--brand) 9%, #fff);    /* tom bem claro para fundos */
    --accent-dark: color-mix(in srgb, var(--accent) 75%, #000);
    --accent-soft: color-mix(in srgb, var(--accent) 16%, #fff);

    --bg: #f3f3f0;          /* fundo da área de trabalho */
    --line: #dedcd4;        /* bordas e divisórias */
    --ink: #17211f;         /* texto principal */
    --muted: #6f726c;       /* texto secundário */

    --font-display: "Bricolage Grotesque", "Albert Sans", system-ui, sans-serif;
    --font-body: "Albert Sans", system-ui, -apple-system, "Segoe UI", sans-serif;

    --sidebar-w: 264px;     /* largura do menu lateral no computador */
    --radius: 10px;
    --shadow: 0 1px 2px rgb(23 33 31 / .06), 0 2px 8px rgb(23 33 31 / .05);
}


/* ==========================================================================
   2. BASE E AJUSTES DO BOOTSTRAP
   ========================================================================== */
body { font-family: var(--font-body); background: var(--bg); color: var(--ink); -webkit-font-smoothing: antialiased; }
h1, h2, h3, h4, h5 { font-family: var(--font-display); letter-spacing: -.015em; color: var(--ink); }
a { color: var(--brand); }
a:hover { color: var(--accent-dark); }

/* Foco visível para navegação por teclado. */
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

/* Botões nas cores de marca (o Bootstrap usa variáveis --bs-btn-* para isso). */
.btn { border-radius: 6px; font-weight: 600; }
.btn-primary {
    --bs-btn-bg: var(--brand); --bs-btn-border-color: var(--brand);
    --bs-btn-hover-bg: var(--brand-dark); --bs-btn-hover-border-color: var(--brand-dark);
    --bs-btn-active-bg: var(--brand-dark); --bs-btn-active-border-color: var(--brand-dark);
    --bs-btn-disabled-bg: var(--brand); --bs-btn-disabled-border-color: var(--brand);
    --bs-btn-focus-shadow-rgb: 199, 154, 74;
}
.btn-outline-primary {
    --bs-btn-color: var(--brand); --bs-btn-border-color: var(--brand);
    --bs-btn-hover-bg: var(--brand); --bs-btn-hover-border-color: var(--brand);
    --bs-btn-active-bg: var(--brand-dark); --bs-btn-active-border-color: var(--brand-dark);
}
.btn-accent {
    --bs-btn-color: var(--brand-dark); --bs-btn-bg: var(--accent); --bs-btn-border-color: var(--accent);
    --bs-btn-hover-color: var(--brand-dark); --bs-btn-hover-bg: color-mix(in srgb, var(--accent) 85%, #fff);
    --bs-btn-hover-border-color: color-mix(in srgb, var(--accent) 85%, #fff);
}

/* Campos de formulário. */
.form-control, .form-select { border-color: var(--line); border-radius: 6px; }
.form-control:focus, .form-select:focus, .form-check-input:focus {
    border-color: var(--brand);
    box-shadow: 0 0 0 .22rem color-mix(in srgb, var(--accent) 35%, transparent);
}
.form-check-input:checked { background-color: var(--brand); border-color: var(--brand); }
.form-label { font-weight: 600; font-size: .88rem; margin-bottom: .25rem; }
.form-text { font-size: .8rem; }

/* Paginação em cores de marca. */
.pagination {
    --bs-pagination-color: var(--brand); --bs-pagination-hover-color: var(--brand-dark);
    --bs-pagination-active-bg: var(--brand); --bs-pagination-active-border-color: var(--brand);
    --bs-pagination-border-color: var(--line);
}
.nav-pills { --bs-nav-pills-link-active-bg: var(--brand); }


/* ==========================================================================
   3. ESTRUTURA: MENU LATERAL, BARRA SUPERIOR E ÁREA DE CONTEÚDO
   ========================================================================== */

/* Menu lateral: fixo no computador; no celular vira gaveta (offcanvas do Bootstrap). */
.sidebar {
    background: var(--brand-dark); color: #b9c7c4;
    width: var(--sidebar-w);
    display: flex; flex-direction: column;
}
@media (min-width: 992px) {
    .sidebar { position: fixed; inset: 0 auto 0 0; overflow-y: auto; z-index: 1020; }
    .app-main { margin-left: var(--sidebar-w); }   /* abre espaço para o menu fixo */
}

/* Marca no topo do menu. */
.sidebar__brand { display: flex; align-items: center; gap: .65rem; padding: 1.1rem 1.2rem; text-decoration: none; color: #fff; border-bottom: 1px solid rgb(255 255 255 / .1); }
.sidebar__brand img { height: 36px; max-width: 150px; object-fit: contain; filter: brightness(0) invert(1); }
.sidebar__brand .glyph {
    width: 36px; height: 36px; display: grid; place-items: center; background: var(--accent); color: var(--brand-dark);
    font-family: var(--font-display); font-weight: 800; font-size: 1.2rem;
    clip-path: polygon(0 0, 70% 0, 100% 30%, 100% 100%, 0 100%);   /* canto chanfrado, assinatura visual */
}
.sidebar__brand span.name { font-family: var(--font-display); font-weight: 700; font-size: 1.1rem; line-height: 1.1; }

/* Título de grupo do menu (Operação, Cadastros, Sistema). */
.sidebar__group { font-size: .78rem; font-weight: 700; color: #8fa49f; padding: 1.1rem 1.2rem .4rem; }

/* Itens do menu. A página atual recebe .active (barra latão à esquerda). */
.sidebar .nav-link {
    color: #cdd9d6; padding: .55rem 1.2rem; display: flex; align-items: center; gap: .7rem;
    border-left: 3px solid transparent; font-size: .95rem;
}
.sidebar .nav-link i { font-size: 1.05rem; width: 1.2rem; text-align: center; opacity: .85; }
.sidebar .nav-link:hover { background: rgb(255 255 255 / .06); color: #fff; }
.sidebar .nav-link.active { background: rgb(255 255 255 / .1); color: #fff; border-left-color: var(--accent); }
.sidebar .badge-count { margin-left: auto; background: var(--accent); color: var(--brand-dark); font-weight: 700; font-size: .72rem; padding: .15rem .5rem; border-radius: 999px; }

/* Rodapé do menu: link para ver o site público. */
.sidebar__foot { margin-top: auto; padding: 1rem 1.2rem; border-top: 1px solid rgb(255 255 255 / .1); font-size: .85rem; }
.sidebar__foot a { color: #cdd9d6; text-decoration: none; }
.sidebar__foot a:hover { color: var(--accent); }

/* Barra superior com botão do menu (celular), título e usuário. */
.topbar {
    position: sticky; top: 0; z-index: 1010; background: rgb(255 255 255 / .9); backdrop-filter: blur(8px);
    border-bottom: 1px solid var(--line); padding: .6rem 1.25rem; display: flex; align-items: center; gap: 1rem;
}
.topbar .user-chip { display: inline-flex; align-items: center; gap: .6rem; text-decoration: none; color: var(--ink); }
.avatar {
    width: 36px; height: 36px; border-radius: 50%; background: var(--brand); color: #fff;
    display: inline-grid; place-items: center; font-weight: 700; font-size: .9rem; object-fit: cover;
}

/* Área de conteúdo. */
.app-content { padding: 1.5rem 1.25rem 3rem; max-width: 1480px; }
@media (min-width: 768px) { .app-content { padding: 2rem 2rem 3rem; } }


/* ==========================================================================
   4. CABEÇALHO DE PÁGINA, CARTÕES E INDICADORES
   ========================================================================== */

/* Título da página + botões de ação (ex.: "Novo imóvel"). */
.page-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.5rem; }
.page-head h1 { font-size: 1.7rem; font-weight: 700; margin: 0; }
.page-head p { margin: .2rem 0 0; color: var(--muted); }

/* Cartão branco padrão. */
.panel { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.panel__head { padding: .95rem 1.25rem; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; gap: .75rem; flex-wrap: wrap; }
.panel__head h2 { font-size: 1.05rem; margin: 0; font-weight: 650; }
.panel__body { padding: 1.25rem; }

/* Indicador do dashboard: número grande com rótulo e ícone. */
.stat {
    background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem 1.1rem;
    display: flex; align-items: center; gap: .9rem; height: 100%; box-shadow: var(--shadow);
    text-decoration: none; color: var(--ink);
}
a.stat:hover { border-color: var(--brand); color: var(--ink); }
.stat__icon {
    flex: none; width: 44px; height: 44px; display: grid; place-items: center; font-size: 1.25rem;
    background: var(--brand-soft); color: var(--brand); border-radius: 8px;
}
.stat__icon--accent { background: var(--accent-soft); color: var(--accent-dark); }
.stat__num { font-family: var(--font-display); font-size: 1.85rem; font-weight: 700; line-height: 1; }
.stat__label { font-size: .84rem; color: var(--muted); margin-top: .2rem; }

/* Gráfico de barras simples (sem biblioteca): cada barra é uma coluna com altura em %. */
.bars { display: flex; align-items: end; gap: .75rem; height: 160px; padding-top: .5rem; }
.bars__col { flex: 1; display: flex; flex-direction: column; justify-content: end; align-items: center; height: 100%; gap: .35rem; font-size: .78rem; color: var(--muted); }
.bars__bar { width: 100%; max-width: 48px; background: var(--brand); border-radius: 4px 4px 0 0; min-height: 3px; }
.bars__val { font-weight: 700; color: var(--ink); }


/* ==========================================================================
   5. TABELAS E LISTAS
   ========================================================================== */
.table-wrap { overflow-x: auto; }   /* tabelas largas rolam na horizontal no celular */
.table { --bs-table-bg: transparent; margin: 0; }
.table > :not(caption) > * > * { padding: .8rem 1rem; vertical-align: middle; }
.table thead th {
    font-size: .8rem; letter-spacing: .01em; color: var(--muted); font-weight: 700;
    background: #faf9f7; border-bottom: 1px solid var(--line); white-space: nowrap;
}
.table-hover > tbody > tr:hover > * { background: var(--brand-soft); }

/* Miniatura nas listas (foto do imóvel, do corretor). */
.thumb { width: 64px; height: 48px; object-fit: cover; border-radius: 6px; background: #e6e4dd; flex: none; }
.thumb--round { width: 44px; height: 44px; border-radius: 50%; }

/* Texto de célula com título e subtítulo empilhados. */
.cell-title { font-weight: 650; line-height: 1.25; }
.cell-sub { font-size: .82rem; color: var(--muted); }

/* Barra de filtros acima das tabelas. */
.filter-bar { padding: 1rem 1.25rem; border-bottom: 1px solid var(--line); background: #faf9f7; border-radius: var(--radius) var(--radius) 0 0; }

/* Estado vazio das listas. */
.empty { text-align: center; padding: 3rem 1rem; color: var(--muted); }
.empty i { font-size: 2.4rem; display: block; margin-bottom: .5rem; color: var(--accent-dark); }


/* ==========================================================================
   6. FORMULÁRIOS
   ========================================================================== */

/* Abas do formulário de imóvel (Principal, Localização, Características...). */
.form-tabs { border-bottom: 1px solid var(--line); gap: .25rem; flex-wrap: nowrap; overflow-x: auto; overflow-y: hidden; }
.form-tabs .nav-link {
    color: var(--muted); font-weight: 600; border: 0; border-bottom: 3px solid transparent; border-radius: 0;
    padding: .8rem 1rem; white-space: nowrap;
}
.form-tabs .nav-link:hover { color: var(--ink); }
.form-tabs .nav-link.active { color: var(--brand); border-bottom-color: var(--accent); background: transparent; }
/* Ponto vermelho na aba que contém erros de validação. */
.form-tabs .nav-link.has-error::after { content: ""; display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: #dc3545; margin-left: .4rem; vertical-align: middle; }

/* Título de subgrupo dentro de um formulário. */
.form-section { font-size: .95rem; font-weight: 700; margin: 1.5rem 0 .75rem; padding-bottom: .4rem; border-bottom: 1px solid var(--line); }
.form-section:first-child { margin-top: 0; }

/* Lista de caixinhas (comodidades) em grade responsiva. */
.check-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: .4rem 1rem; }

/* Barra de ações fixa no rodapé do formulário (salvar/cancelar sempre visíveis). */
.form-actions {
    position: sticky; bottom: 0; z-index: 5; background: rgb(255 255 255 / .94); backdrop-filter: blur(6px);
    border-top: 1px solid var(--line); padding: .85rem 1.25rem; display: flex; gap: .6rem; justify-content: flex-end;
    border-radius: 0 0 var(--radius) var(--radius);
}

/* Editor simples de HTML das páginas (apenas uma caixa de texto grande e monoespaçada). */
.code-area { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .88rem; min-height: 280px; }

/* Seletor de cor ao lado do campo de texto. */
.color-field { display: flex; gap: .5rem; align-items: center; }
.color-field input[type="color"] { width: 48px; height: 40px; padding: 2px; border: 1px solid var(--line); border-radius: 6px; background: #fff; }


/* ==========================================================================
   7. FOTOGRAFIAS: ENVIO, GRADE E REORDENAÇÃO
   ========================================================================== */

/* Área de soltar arquivos (arrastar e soltar ou clicar). */
.dropzone {
    border: 2px dashed var(--line); border-radius: var(--radius); background: #faf9f7;
    padding: 1.6rem 1rem; text-align: center; color: var(--muted); cursor: pointer;
    transition: border-color .2s, background .2s;
}
.dropzone:hover, .dropzone.is-over { border-color: var(--brand); background: var(--brand-soft); color: var(--ink); }
.dropzone i { font-size: 2rem; color: var(--accent-dark); display: block; }

/* Grade de fotos do imóvel (cada cartão é arrastável para reordenar). */
.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: .85rem; }
.photo-item {
    position: relative; background: #fff; border: 1px solid var(--line); border-radius: 8px; overflow: hidden;
    cursor: grab; transition: box-shadow .2s, opacity .2s;
}
.photo-item img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; display: block; }
.photo-item.is-dragging { opacity: .4; }
.photo-item.is-target { box-shadow: 0 0 0 3px var(--accent); }
.photo-item__tools { display: flex; justify-content: space-between; padding: .35rem .5rem; gap: .25rem; }
.photo-item__tools .btn { padding: .15rem .45rem; font-size: .85rem; }
/* Selo "Principal" sobre a foto. */
.photo-item__main { position: absolute; left: .4rem; top: .4rem; background: var(--accent); color: var(--brand-dark); font-weight: 700; font-size: .72rem; padding: .15rem .5rem; border-radius: 4px; }
.photo-item input.caption { border: 0; border-top: 1px solid var(--line); border-radius: 0; font-size: .82rem; padding: .35rem .5rem; }
/* Pré-visualização das fotos escolhidas antes de enviar. */
.preview-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: .5rem; margin-top: .8rem; }
.preview-grid img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 6px; border: 1px solid var(--line); }


/* ==========================================================================
   8. TOUR 3D NO PAINEL
   ========================================================================== */
.tour-status { display: flex; align-items: center; gap: .75rem; padding: .9rem 1rem; border-radius: 8px; background: var(--brand-soft); }
.tour-status--failed { background: #fdecea; }
.tour-status--ready { background: #e8f4ec; }
/* Barra de progresso da geração, na cor de destaque. */
.progress { --bs-progress-bar-bg: var(--accent); --bs-progress-height: .6rem; }
/* Fotos selecionáveis para enviar à IA. */
.pick-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: .5rem; }
.pick-grid label { position: relative; cursor: pointer; margin: 0; }
.pick-grid input { position: absolute; opacity: 0; }
.pick-grid img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 6px; border: 3px solid transparent; }
.pick-grid input:checked + img { border-color: var(--accent); }
.pick-grid input:focus-visible + img { outline: 3px solid var(--brand); outline-offset: 2px; }
model-viewer.admin-viewer { width: 100%; height: 340px; background: radial-gradient(circle at 50% 40%, #2c5a56, #10201f); border-radius: 8px; }


/* ==========================================================================
   9. HISTÓRICO (LINHA DO TEMPO), BADGES E DETALHES
   ========================================================================== */

/* Linha do tempo vertical do histórico de visitas/atendimentos. */
.timeline { list-style: none; margin: 0; padding: 0 0 0 1.2rem; border-left: 2px solid var(--line); }
.timeline li { position: relative; padding: 0 0 1.1rem 1rem; }
.timeline li::before {
    content: ""; position: absolute; left: -1.62rem; top: .35rem; width: 12px; height: 12px;
    border-radius: 50%; background: var(--accent); border: 2px solid #fff; box-shadow: 0 0 0 1px var(--line);
}
.timeline .when { font-size: .78rem; color: var(--muted); }

/* Lista de dados "rótulo: valor". */
.detail-list { margin: 0; }
.detail-list > div { display: flex; justify-content: space-between; gap: 1rem; padding: .55rem 0; border-bottom: 1px solid var(--line); }
.detail-list > div:last-child { border-bottom: 0; }
.detail-list dt { font-weight: 500; color: var(--muted); }
.detail-list dd { margin: 0; text-align: right; font-weight: 600; }

/* Badges ligeiramente maiores e mais legíveis. */
.badge { font-weight: 600; padding: .38em .65em; }

/* Texto de mensagem do visitante preservando quebras de linha. */
.pre-wrap { white-space: pre-wrap; word-break: break-word; }


/* ==========================================================================
   10. TELA DE LOGIN (layout "auth")
   Duas colunas: painel de marca escuro à esquerda e formulário à direita.
   ========================================================================== */
.auth { min-height: 100vh; display: grid; grid-template-columns: 1fr; }
@media (min-width: 992px) { .auth { grid-template-columns: 1.05fr 1fr; } }
.auth__brand {
    background: var(--brand); color: #fff; padding: 2.5rem; display: none; position: relative; overflow: hidden;
    flex-direction: column; justify-content: space-between;
}
@media (min-width: 992px) { .auth__brand { display: flex; } }
/* Textura de linhas diagonais, igual à do hero do site. */
.auth__brand::before { content: ""; position: absolute; inset: 0; background: repeating-linear-gradient(115deg, transparent 0 46px, rgb(255 255 255 / .03) 46px 47px); }
.auth__brand > * { position: relative; }
.auth__brand h1 { color: #fff; font-size: clamp(2rem, 3.4vw, 3rem); max-width: 14ch; }
.auth__brand p { color: #b9cbc7; max-width: 40ch; }
.auth__form { display: grid; place-items: center; padding: 2rem 1.25rem; background: var(--bg); }
.auth__card { width: 100%; max-width: 420px; }
.auth__card h2 { font-size: 1.7rem; }


/* ==========================================================================
   11. RESPONSIVO E ACESSIBILIDADE
   ========================================================================== */
@media (max-width: 575.98px) {
    .page-head h1 { font-size: 1.4rem; }
    .stat__num { font-size: 1.5rem; }
    .form-actions { flex-direction: column-reverse; }   /* botão principal em cima no celular */
}
/* Respeita quem prefere menos movimento. */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation: none !important; transition: none !important; }
}
