/* Overrides rápidos para ajuste de selects */
.form-select{padding-right:2.2rem !important}
.form-select::-ms-expand{display:none}

/* ================================================================
   Modo Escuro do usuário  (data-bs-theme="dark")
   ---------------------------------------------------------------
   Problema: os CSS de tema compilam  body { color: #333 }  como
   valor fixo, que é carregado APÓS o Bootstrap e portanto derruba
   a variável  --bs-body-color  que o BS 5.3 altera em dark mode.
   Este arquivo (overrides.css) é carregado por ÚLTIMO em ambos os
   layouts, então tem a prioridade necessária para corrigir.
   ================================================================ */

/* 1 ─ Corpo: restaura cor de texto e fundo que o tema sobreescreve */
[data-bs-theme="dark"] body {
    color: var(--bs-body-color);
    background-color: var(--bs-body-bg);
}

/* 1b ─ .bg-light em dark mode: força variável do Bootstrap que se adapta
         (cobre card-footer, divs info, etc. que usam bg-light nas páginas admin) */
[data-bs-theme="dark"] .bg-light {
    background-color: rgba(var(--bs-secondary-bg-rgb), 1) !important;
    color: var(--bs-body-color);
}

/* 2 ─ Cards de imóvel: bg/cor hardcoded no _base.scss */
[data-bs-theme="dark"] .card-imovel .card-body {
    background-color: var(--bs-card-bg);
    color: var(--bs-body-color);
    border-top-color: rgba(255,255,255,.06);
}

/* 3 ─ Seções com fundo suave do tema ficam invisíveis sobre bg escuro */
[data-bs-theme="dark"] .bg-theme-light {
    background-color: rgba(255,255,255,.05) !important;
    border-top-color: rgba(255,255,255,.08);
}

/* 4 ─ Search-box: inline CSS usa background:#ffffff (page home) */
[data-bs-theme="dark"] .search-box {
    background: var(--bs-tertiary-bg, #2b3035) !important;
}

/* 5 ─ .text-theme usa --theme-primary; no tema "dark" = #212529 (quase preto) */
[data-bs-theme="dark"] .text-theme {
    color: var(--theme-primary-lighter, var(--bs-body-color)) !important;
}

/* 6 ─ .alert-theme usa --theme-primary-10 como fundo (quase transparente) */
[data-bs-theme="dark"] .alert-theme {
    background-color: rgba(255,255,255,.06);
    border-color: rgba(255,255,255,.15);
    color: var(--bs-body-color);
}

/* 7 ─ Botão .btn-theme (usado em links "Ver todos") */
[data-bs-theme="dark"] .btn-theme {
    background: var(--theme-primary-light, var(--bs-primary));
    border-color: var(--theme-primary-light, var(--bs-primary));
    color: #fff;
}
[data-bs-theme="dark"] .btn-theme:hover,
[data-bs-theme="dark"] .btn-theme:focus {
    background: var(--theme-primary-lighter, var(--bs-primary));
    border-color: var(--theme-primary-lighter, var(--bs-primary));
    color: #fff;
}
/* ── Preço do imóvel ───────────────────────────────────────────── */
/* Em modo claro usa a cor primária do tema; em modo escuro usa um
   tom mais claro para manter contraste sobre fundo escuro do card */
.text-theme-price {
    color: var(--theme-primary);
}
[data-bs-theme="dark"] .text-theme-price {
    color: var(--theme-primary-lighter, #a8b4bf);
}

/* ── Card de imóvel ─────────────────────────────────────────────── */
/* _base.scss força bg/cor fixos; aqui restauramos as variáveis BS no dark */
[data-bs-theme="dark"] .card-imovel {
    background-color: var(--bs-card-bg);
    color: var(--bs-body-color);
    border-color: var(--bs-border-color) !important;
}
[data-bs-theme="dark"] .card-imovel hr {
    border-color: var(--bs-border-color);
}

/* ── Ícones do toggle claro/escuro ─────────────────────────────────── */
/* CSS controla a visibilidade em vez de JS — imune ao re-render do Lucide */
#icon-light { display: none; }
#icon-dark  { display: inline; }
[data-bs-theme="dark"] #icon-light { display: inline; }
[data-bs-theme="dark"] #icon-dark  { display: none; }

/* ── Página show.php — características rápidas e formulário ──────── */
[data-bs-theme="dark"] .feature-icon {
    color: var(--theme-primary-lighter, #a8b4bf);
}
/* frontend.css declara  .card { border: none }  que zera width+style.
   Precisamos do shorthand completo com !important para sobrepor. */
[data-bs-theme="dark"] .card {
    border: 1px solid rgba(255, 255, 255, 0.18) !important;
}

/* ---------------------------------------------------------
   Responsividade: empilhar botões de ação em telas pequenas
   --------------------------------------------------------- */
@media (max-width: 576px) {
    main .table .btn-group.btn-group-sm {
        display: flex !important;
        flex-direction: column;
        gap: .25rem;
        align-items: stretch;
    }
    main .table .btn-group.btn-group-sm .btn {
        width: 100%;
        display: block;
        justify-content: center;
    }
    /* Permite quebra de texto em colunas para dar espaço vertical */
    main .table td, main .table th {
        word-break: break-word;
    }
}

/* ---------------------------------------------------------
   Ajustes responsivos entre 1490px e 1024px para evitar
   overflow horizontal: diminuir fonte/padding e permitir
   quebra de texto em títulos. Em <=1024 empilha botões.
   --------------------------------------------------------- */
@media (max-width: 1490px) {
    main .table th,
    main .table td {
        font-size: .88rem;
        padding: .32rem .45rem;
        white-space: normal;
    }
    /* Fotos menores para economizar largura */
    main .table td:first-child img,
    main .table th:first-child img {
        max-width: 90px;
        max-height: 60px;
    }
    /* Referência (coluna 2) deve permanecer compacta */
    main .table td:nth-child(2),
    main .table th:nth-child(2) {
        width: 72px;
        white-space: nowrap;
    }
    /* Título pode quebrar linhas para liberar espaço horizontal */
    main .table td:nth-child(3),
    main .table th:nth-child(3) {
        max-width: 360px;
    }
    /* Ajusta botões para ocupar menos espaço */
    main .table .btn,
    main .table .btn-group .btn {
        padding: .18rem .36rem;
        font-size: .82rem;
    }
    /* Empilha os botões de ação já a partir de <1490px */
    main .table .btn-group.btn-group-sm {
        display: flex !important;
        flex-direction: column;
        gap: .25rem;
        align-items: stretch;
    }
    main .table .btn-group.btn-group-sm .btn {
        width: 100%;
        display: block;
    }
}

@media (max-width: 1024px) {
    main .table th,
    main .table td {
        font-size: .82rem;
        padding: .28rem .32rem;
    }
    /* Empilha os botões de ação verticalmente para economizar largura */
    main .table .btn-group.btn-group-sm {
        display: flex !important;
        flex-direction: column;
        gap: .25rem;
        align-items: stretch;
    }
    main .table .btn-group.btn-group-sm .btn {
        width: 100%;
        display: block;
    }
    /* Fotos ainda menores em telas bem pequenas */
    main .table td:first-child img { max-width: 80px; max-height: 56px; }
    /* Permitir quebra de palavras para liberar espaço */
    main .table td, main .table th { word-break: break-word; }
}

/* ---------------------------------------------------------
   Sincroniza o formulário de filtro com as mesmas regras
   de responsividade da tabela (font-size, padding, empilhamento)
   Aplicado apenas dentro de `main .card .card-body form`.
   --------------------------------------------------------- */
@media (max-width: 576px) {
    main .card .card-body form .row > .col-auto,
    main .card .card-body form .row > .col-auto.flex-grow-1 {
        width: 100% !important;
        flex: 0 0 100% !important;
    }
    main .card .card-body form .form-control-sm,
    main .card .card-body form .form-select.form-select-sm {
        font-size: .90rem;
    }
    main .card .card-body form .btn-sm { width: 100%; }
    /* ID input inline width override para mobile */
    main .card .card-body form input[name="id"] { width: 100% !important; }
}

@media (max-width: 1490px) {
    main .card .card-body form .form-control-sm,
    main .card .card-body form .form-select.form-select-sm {
        font-size: .88rem;
        padding: .32rem .45rem;
    }
    main .card .card-body form .btn-sm {
        padding: .18rem .36rem;
        font-size: .82rem;
    }
}

@media (max-width: 1024px) {
    main .card .card-body form .form-control-sm,
    main .card .card-body form .form-select.form-select-sm {
        font-size: .82rem;
        padding: .28rem .32rem;
    }
    main .card .card-body form .row > .col-auto { width: 100% !important; flex: 0 0 100% !important; }
}

/* Escala do display (125% / 150%) aplica-se também ao filtro */
.admin-scale-125 main .card .card-body form .form-control-sm,
.admin-scale-125 main .card .card-body form .form-select.form-select-sm {
    font-size: .84rem;
    padding: .30rem .40rem;
}
.admin-scale-125 main .card .card-body form .btn-sm {
    padding: .18rem .36rem;
    font-size: .82rem;
}
.admin-scale-150 main .card .card-body form .form-control-sm,
.admin-scale-150 main .card .card-body form .form-select.form-select-sm {
    font-size: .78rem;
    padding: .22rem .34rem;
}
.admin-scale-150 main .card .card-body form .btn-sm {
    padding: .14rem .3rem;
    font-size: .78rem;
}

/* ---------------------------------------------------------
   Corrige alinhamento do campo "Texto" para permanecer em
   linha com os outros inputs em larguras >= 1025px. A ideia
   é permitir que a coluna flex-grow-1 encolha (min-width:0)
   e evitar quebra de linha indesejada, sem afetar mobile.
   --------------------------------------------------------- */
main .card .card-body form .row { align-items: flex-end; }

/* Permite que o input de texto encolha quando necessário */
main .card .card-body form .row > .col-auto.flex-grow-1,
main .card .card-body form .row > .col-auto.flex-grow-1 .form-control,
main .card .card-body form .row > .col-auto.flex-grow-1 .form-select {
    min-width: 0;
}

@media (min-width: 1025px) {
    /* Em telas grandes preferimos manter tudo em uma linha */
    main .card .card-body form .row {
        flex-wrap: nowrap;
    }
    main .card .card-body form .row > .col-auto {
        flex: 0 0 auto;
    }
    main .card .card-body form .row > .col-auto.flex-grow-1 {
        flex: 1 1 auto;
        min-width: 220px; /* garante campo texto com largura mínima razoável */
    }
}

/* ---------------------------------------------------------
   Ajustes adicionais para usuários com escala do sistema
   (Windows display scale / browser zoom). As classes
   `admin-scale-125` e `admin-scale-150` são aplicadas via JS
   em `layouts/admin.php` quando o devicePixelRatio indica
   1.2 (≈125%) ou 1.45+ (≈150%).
   --------------------------------------------------------- */
.admin-scale-125 main .table th,
.admin-scale-125 main .table td {
    font-size: .84rem;
    padding: .30rem .40rem;
}
.admin-scale-150 main .table th,
.admin-scale-150 main .table td {
    font-size: .78rem;
    padding: .22rem .34rem;
}
.admin-scale-125 main .table .btn-group.btn-group-sm,
.admin-scale-150 main .table .btn-group.btn-group-sm {
    display: flex !important;
    flex-direction: column;
    gap: .25rem;
    align-items: stretch;
}
.admin-scale-125 main .table .btn-group.btn-group-sm .btn,
.admin-scale-150 main .table .btn-group.btn-group-sm .btn {
    width: 100%;
}
.admin-scale-150 main .table td:first-child img { max-width: 70px; max-height: 50px; }
.admin-scale-125 main .table .btn i,
.admin-scale-150 main .table .btn i,
.admin-scale-125 main .table .btn svg,
.admin-scale-150 main .table .btn svg { width: 14px !important; height: 14px !important; }

/* ---------------------------------------------------------
   Ajustes no sidebar para manter proporção com as tabelas
   quando o usuário usa escala de display (125% / 150%).
   Estas regras seguem as reduções aplicadas nas tabelas,
   com um leve aumento de fonte conforme solicitado.
   --------------------------------------------------------- */
.admin-scale-125 .sidebar {
    font-size: .90rem; /* aumentado levemente para melhorar legibilidade em 125% */
}
.admin-scale-125 .sidebar .nav-link {
    padding: .30rem .6rem;
    font-size: .90rem;
    line-height: 1.2;
}
.admin-scale-125 .sidebar .nav-link i[data-lucide],
.admin-scale-125 .sidebar .nav-link svg {
    width: 16px !important;
    height: 16px !important;
}
.admin-scale-125 .sidebar .sidebar-heading {
    font-size: .78rem;
    padding-left: .75rem;
    padding-right: .75rem;
}

.admin-scale-150 .sidebar {
    font-size: .84rem; /* aumentado levemente para 150% */
}
.admin-scale-150 .sidebar .nav-link {
    padding: .24rem .5rem;
    font-size: .84rem;
    line-height: 1.1;
}
.admin-scale-150 .sidebar .nav-link i[data-lucide],
.admin-scale-150 .sidebar .nav-link svg {
    width: 14px !important;
    height: 14px !important;
}
.admin-scale-150 .sidebar .sidebar-heading {
    font-size: .74rem;
    padding-left: .65rem;
    padding-right: .65rem;
}

/* ---------------------------------------------------------
   Força a cor do heading 'Configurações' no sidebar para
   seguir o esquema de cores do menu (branco/sem destaque).
   Isto corrige casos onde a classe `text-body-secondary`
   aplica cor escura indevida.
   --------------------------------------------------------- */
.sidebar-theme .sidebar-heading,
.sidebar-theme .sidebar-heading span,
.sidebar-theme .sidebar-heading .text-body-secondary {
    color: rgba(255,255,255,.85) !important;
}
