/* gestoes.css — restyle fiel ao protótipo Claude Design (RE/MAX JUNTUS).
 * Escopo: cards sob #view-imoveis, modal sob #imovel-modal. Carrega DEPOIS de
 * components/imovel-modal.css, então prevalece. Usa apenas tokens --pd-*. */

/* ============================================================
 * CARD DO IMÓVEL  (#view-imoveis .imovel-card)
 * ============================================================ */
#view-imoveis .imovel-card {
    background: var(--pd-surface);
    border: 1px solid var(--pd-border);
    border-radius: var(--pd-r-sm);
    box-shadow: var(--pd-shadow-sm);
    overflow: hidden;
    font-family: var(--pd-font);
    /* Layout thumb-lateral: mídia à esquerda, conteúdo à direita, footer full-width */
    display: flex;
    flex-wrap: wrap;
    align-items: stretch;
    transition: transform .12s ease, box-shadow .12s ease, border-color .12s ease;
}
#view-imoveis .imovel-card:hover {
    box-shadow: var(--pd-shadow);
    border-color: #cfd6e0;
    transform: translateY(-1px);
}
#view-imoveis .imovel-card:focus-visible {
    outline: 2px solid var(--pd-brand);
    outline-offset: 2px;
}

/* --- Thumb / foto (coluna fixa à esquerda) --- */
#view-imoveis .imovel-card-media {
    position: relative;
    flex: none;
    width: 70px;
    align-self: flex-start;
    margin: 12px 0 12px 12px;
    border-radius: var(--pd-r-xs);
    overflow: hidden;
    aspect-ratio: 1 / 1;
}
#view-imoveis .imovel-card-media img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
#view-imoveis .imovel-card-placeholder--gradient {
    width: 100%;
    height: 100%;
    border-radius: 0;
}

/* --- Badge row: só MODALIDADE fica no topo do thumb; status vai pro corpo --- */
#view-imoveis .imovel-card-badges {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    display: flex;
    flex-wrap: wrap;
    gap: 3px;
    padding: 3px;
    z-index: 1;
}
#view-imoveis .imovel-card-modalidade,
#view-imoveis .imovel-card-negociado-tipo,
#view-imoveis .imovel-card-neg-date,
#view-imoveis .imovel-card-motivo-arquivamento {
    font: 800 8px var(--pd-font);
    letter-spacing: .05em;
    text-transform: uppercase;
    color: #fff;
    padding: 2px 6px;
    border-radius: 0 var(--pd-r-xs) 0 var(--pd-r-xs);
    line-height: 1.25;
    box-shadow: 0 2px 6px -2px rgba(8,14,26,.4);
}
/* Status vira pill soft no corpo (align-self start), não sobre o thumb */
#view-imoveis .imovel-card-status {
    align-self: flex-start;
    order: -1;
    font: 800 9px var(--pd-font);
    letter-spacing: .05em;
    text-transform: uppercase;
    color: #fff;
    padding: 2px 8px;
    border-radius: var(--pd-r-pill);
    line-height: 1.3;
    margin-bottom: 1px;
}

/* --- Avatar do corretor sobre o thumb (canto inferior) --- */
#view-imoveis .imovel-card-avatar {
    position: absolute;
    bottom: 3px;
    right: 3px;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    color: #fff;
    font: 800 8px var(--pd-font);
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1.5px solid var(--pd-surface);
    box-shadow: 0 2px 8px -2px rgba(8,14,26,.5);
    z-index: 1;
}

/* --- Corpo do card (coluna à direita) --- */
#view-imoveis .imovel-card-body {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 3px;
    padding: 12px 13px 13px 12px;
}
#view-imoveis .imovel-card-ref {
    font: 600 10px var(--pd-mono);
    color: var(--pd-muted-2);
    letter-spacing: .02em;
}
#view-imoveis .imovel-card-title {
    font: 700 14px var(--pd-font);
    color: var(--pd-text);
    letter-spacing: -.01em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
#view-imoveis .imovel-card-addr {
    font: 500 11.5px var(--pd-font);
    color: var(--pd-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
#view-imoveis .imovel-card-sub {
    font: 500 11px var(--pd-font);
    color: var(--pd-muted-2);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
/* Preço = texto brand puro (sem caixa), igual ao protótipo. !important pra vencer
 * styles.css .imovel-card-price (que força degradê + border-left com !important). */
#view-imoveis .imovel-card-price {
    display: block;
    background: none !important;
    border: none !important;
    box-shadow: none !important;
    padding: 0 !important;
    margin: 5px 0 0 !important;
    font: 800 16px var(--pd-font) !important;
    color: var(--pd-brand) !important;
    font-variant-numeric: tabular-nums;
    letter-spacing: -.02em;
}
#view-imoveis .imovel-card-price--rent {
    color: var(--pd-green) !important;
    font-size: 14px !important;
}
#view-imoveis .imovel-card-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 3px;
}
#view-imoveis .imovel-card-meta span {
    font: 600 10.5px var(--pd-font);
    color: var(--pd-muted);
    display: inline-flex;
    align-items: center;
    gap: 3px;
}

/* --- Linha dias + leads + corretor --- */
#view-imoveis .imovel-card-info-row {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: nowrap;
    margin-top: 8px;
    min-width: 0;
}
#view-imoveis .imovel-card-info-row {
    justify-content: flex-start;
}
#view-imoveis .imovel-card-info-row .imovel-card-dias { flex: none; }
#view-imoveis .imovel-card-info-row .imovel-card-leads { flex: none; }
#view-imoveis .imovel-card-dias {
    font: 600 10.5px var(--pd-font);
    color: var(--pd-muted);
    display: inline-flex;
    align-items: center;
    gap: 3px;
}
#view-imoveis .imovel-card-dias--aging { color: var(--pd-gold); }
#view-imoveis .imovel-card-dias--stale { color: var(--pd-accent); }
#view-imoveis .imovel-card-leads {
    position: static;   /* reset do position:absolute herdado de crm.css (leads ia pro canto) */
    font: 700 10px var(--pd-font);
    padding: 2px 8px;
    border-radius: var(--pd-r-pill);
    background: var(--pd-brand-soft);
    color: var(--pd-brand);
    white-space: nowrap;
}
#view-imoveis .imovel-card-leads[data-has-leads="0"] {
    background: var(--pd-surface-2);
    color: var(--pd-muted-2);
}
/* Corretor responsável — linha própria no rodapé (avatar + nome), conforme layout */
#view-imoveis .imovel-card-corretor-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 10px 13px 0;
    padding-top: 10px;
    border-top: 1px solid var(--pd-border);
}
#view-imoveis .imovel-card-corretor-avatar {
    flex: none;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font: 800 9.5px var(--pd-font);
    color: #fff;
    letter-spacing: .02em;
}
#view-imoveis .imovel-card-corretor-nome {
    font: 700 12px var(--pd-font);
    color: var(--pd-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
#view-imoveis .imovel-card-corretor-row--vazio .imovel-card-corretor-nome {
    font-weight: 600;
    color: var(--pd-muted);
    font-style: italic;
}

/* --- Footer (ações rápidas) — full-width abaixo de thumb+corpo --- */
#view-imoveis .imovel-card-footer {
    flex-basis: 100%;
    width: 100%;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 0 13px 13px;
}
#view-imoveis .imovel-card-contrato-btn,
#view-imoveis .imovel-card-video-btn {
    flex: 1;
    min-width: 0;
    font: 700 11px var(--pd-font);
    padding: 8px 10px;
    border-radius: var(--pd-r-sm);
    border: 1px solid var(--pd-border);
    background: var(--pd-surface-2);
    color: var(--pd-text-2);
    cursor: pointer;
    transition: background .12s, border-color .12s, color .12s;
}
#view-imoveis .imovel-card-contrato-btn:hover {
    background: var(--pd-brand-soft);
    border-color: var(--pd-brand);
    color: var(--pd-brand);
}
#view-imoveis .imovel-card-video-btn:hover {
    background: var(--pd-accent-soft);
    border-color: var(--pd-accent);
    color: var(--pd-accent);
}

/* ============================================================
 * MODAL DO IMÓVEL  (#imovel-modal) — header, abas, certidões
 * ============================================================ */

/* --- Header: ícone + título + subtitle corretor --- */
#imovel-modal .modal-header {
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid var(--pd-border);
}
#imovel-modal .modal-header .imh-left {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
    min-width: 0;
}
#imovel-modal .modal-header .imh-icon {
    width: 40px;
    height: 40px;
    flex: none;
    border-radius: var(--pd-r-sm);
    background: var(--pd-brand-soft);
    color: var(--pd-brand);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: inset 0 0 0 1px rgba(0,61,165,.12);
}
#imovel-modal .modal-header .imh-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
    flex: 1;
}
#imovel-modal .modal-header h3 {
    font: 800 16px var(--pd-font);
    color: var(--pd-text);
    letter-spacing: -.015em;
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
#imovel-modal .modal-header .imh-subtitle {
    font: 600 11.5px var(--pd-font);
    color: var(--pd-muted);
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* --- Chip do corretor responsável no header (avatar + nome + label) --- */
#imovel-modal .imh-corretor-chip {
    display: flex;
    align-items: center;
    gap: 9px;
    flex: none;
    padding: 5px 12px 5px 6px;
    background: var(--pd-surface-2);
    border: 1px solid var(--pd-border);
    border-radius: var(--pd-r-pill);
    max-width: 240px;
}
#imovel-modal .imh-corretor-avatar {
    width: 30px;
    height: 30px;
    flex: none;
    border-radius: 50%;
    color: #fff;
    font: 800 11px var(--pd-font);
    display: flex;
    align-items: center;
    justify-content: center;
}
#imovel-modal .imh-corretor-text {
    display: flex;
    flex-direction: column;
    gap: 0;
    min-width: 0;
}
#imovel-modal .imh-corretor-name {
    font: 700 12.5px var(--pd-font);
    color: var(--pd-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.25;
}
#imovel-modal .imh-corretor-label {
    font: 600 11px var(--pd-font);
    color: var(--pd-muted);
    white-space: nowrap;
    line-height: 1.2;
}
/* Chip clicável (gestor/admin trocam o corretor) */
#imovel-modal .imh-corretor-btn {
    display: flex;
    align-items: center;
    gap: 9px;
    width: 100%;
    background: none;
    border: none;
    padding: 0;
    margin: 0;
    font: inherit;
    color: inherit;
    text-align: left;
    cursor: default;
}
#imovel-modal .imh-corretor-btn--editable { cursor: pointer; }
#imovel-modal .imh-corretor-btn--editable:hover .imh-corretor-caret { color: var(--pd-brand); }
#imovel-modal .imh-corretor-chip:has(.imh-corretor-btn--editable):hover {
    border-color: var(--pd-brand);
    background: var(--pd-brand-soft);
}
#imovel-modal .imh-corretor-caret {
    font-size: 10px;
    color: var(--pd-muted);
    flex: none;
    margin-left: 2px;
}
/* Dropdown de troca de corretor */
#imovel-modal .imh-corretor-menu {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    z-index: 50;
    min-width: 240px;
    max-height: 300px;
    overflow-y: auto;
    background: var(--pd-surface);
    border: 1px solid var(--pd-border);
    border-radius: var(--pd-r);
    box-shadow: var(--pd-shadow-lg);
    padding: 6px;
}
#imovel-modal .imh-corretor-menu-item {
    display: flex;
    align-items: center;
    gap: 9px;
    width: 100%;
    background: none;
    border: none;
    border-radius: var(--pd-r-sm);
    padding: 6px 8px;
    cursor: pointer;
    text-align: left;
    font: 600 13px var(--pd-font);
    color: var(--pd-text);
}
#imovel-modal .imh-corretor-menu-item:hover { background: var(--pd-surface-2); }
#imovel-modal .imh-corretor-menu-item.is-selected { background: var(--pd-brand-soft); }
#imovel-modal .imh-corretor-menu-name {
    flex: 1;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
#imovel-modal .imh-corretor-menu-check { color: var(--pd-brand); font-weight: 800; flex: none; }
#imovel-modal .imh-corretor-menu .imh-corretor-avatar { width: 26px; height: 26px; font-size: 9.5px; }

/* --- Auto-save: indicador no footer + feedback sutil no campo --- */
#imovel-modal .imovel-autosave-status {
    margin-right: auto;
    align-self: center;
    font: 600 12px var(--pd-font);
    color: var(--pd-muted);
    transition: color .15s ease;
}
#imovel-modal .imovel-autosave-status[data-autosave="saved"] { color: var(--pd-green); }
#imovel-modal .imovel-autosave-status[data-autosave="error"] { color: var(--pd-accent); }
#imovel-modal .autosave-ok {
    box-shadow: 0 0 0 2px var(--pd-green-soft) !important;
    transition: box-shadow .2s ease;
}
#imovel-modal .autosave-err {
    box-shadow: 0 0 0 2px var(--pd-accent-soft) !important;
}

/* --- Status flag (pill outline) --- */
#imovel-modal .imovel-status-flag {
    font: 800 10px var(--pd-font);
    letter-spacing: .06em;
    text-transform: uppercase;
    padding: 4px 12px;
    border: 1.5px solid currentColor;
    border-radius: var(--pd-r-pill);
    flex: none;
}

/* --- Abas --- */
#imovel-modal .imovel-tabs {
    display: flex;
    gap: 4px;
    border-bottom: 1px solid var(--pd-border);
    background: var(--pd-surface);
}
#imovel-modal .imovel-tab-btn {
    font: 700 12.5px var(--pd-font);
    color: var(--pd-muted);
    padding: 11px 14px;
    border: 0;
    border-bottom: 2px solid transparent;
    background: transparent;
    cursor: pointer;
    white-space: nowrap;
    transition: color .12s, border-color .12s;
}
#imovel-modal .imovel-tab-btn:hover { color: var(--pd-text-2); }
#imovel-modal .imovel-tab-btn.active {
    color: var(--pd-brand);
    border-bottom-color: var(--pd-brand);
}

/* --- Seção Certidões (aba Documentos) --- */
#imovel-modal .imovel-certidoes-section {
    background: var(--pd-surface);
    border: 1px solid var(--pd-border);
    border-radius: var(--pd-r);
    box-shadow: var(--pd-shadow-sm);
    overflow: hidden;
    margin-bottom: 14px;
}
#imovel-modal .imovel-certidoes-head {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 13px 16px;
    border-bottom: 1px solid var(--pd-border);
}
#imovel-modal .imovel-certidoes-title {
    font: 800 13px var(--pd-font);
    color: var(--pd-text);
    letter-spacing: .02em;
    text-transform: uppercase;
}
#imovel-modal .imovel-certidoes-link {
    margin-left: auto;
    font: 700 11px var(--pd-font);
    color: var(--pd-brand);
    background: var(--pd-brand-soft);
    border: 0;
    padding: 5px 11px;
    border-radius: var(--pd-r-pill);
    cursor: pointer;
    transition: background .12s;
}
#imovel-modal .imovel-certidoes-link:hover { background: #dbe8fa; }
#imovel-modal .imovel-certidoes-empty {
    font: 500 12px var(--pd-font);
    color: var(--pd-muted);
    margin: 0;
    padding: 14px 16px;
}
#imovel-modal .imovel-certidoes-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 14px 16px;
}

/* Chips coloridos por status */
#imovel-modal .imovel-certidao-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font: 700 11px var(--pd-font);
    letter-spacing: .01em;
    padding: 5px 11px;
    border-radius: var(--pd-r-pill);
    border: 1px solid var(--pd-border);
    background: var(--pd-surface-2);
    color: var(--pd-text-2);
}
#imovel-modal .imovel-certidao-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    flex: none;
}
#imovel-modal .imovel-certidao-chip[data-status="aprovado"] {
    background: var(--pd-green-soft);
    border-color: transparent;
    color: var(--pd-green);
}
#imovel-modal .imovel-certidao-chip[data-status="reprovado"] {
    background: var(--pd-accent-soft);
    border-color: transparent;
    color: var(--pd-accent);
}
#imovel-modal .imovel-certidao-chip[data-status="pendente"] {
    background: #FBF1E0;
    border-color: transparent;
    color: var(--pd-gold);
}
#imovel-modal .imovel-certidao-chip[data-status="em_analise"] {
    background: var(--pd-brand-soft);
    border-color: transparent;
    color: var(--pd-brand);
}
#imovel-modal .imovel-certidao-chip[data-status="vencido"] {
    background: var(--pd-surface-2);
    border-color: var(--pd-border);
    color: var(--pd-muted);
}
