/* =============================================
   IMOVEL MODAL — premium redesign
   Scoped to #imovel-modal to avoid collateral
   ============================================= */

/* ── Container ── */
#imovel-modal .modal {
    max-width: 1040px;
    border-radius: 16px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    max-height: 92vh;
    box-shadow: 0 24px 64px rgba(0,41,117,.14), 0 4px 16px rgba(0,0,0,.08);
}

/* Navy accent stripe at the very top */
#imovel-modal .modal::before {
    content: '';
    display: block;
    height: 3px;
    background: var(--brand-gradient);
    flex-shrink: 0;
}

/* ── Header ── */
#imovel-modal .modal-header {
    padding: 18px 28px 14px;
    border-bottom: 1px solid var(--border);
    gap: 12px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
}

#imovel-modal .modal-header h3 {
    font-family: 'Plus Jakarta Sans', 'DM Sans', sans-serif;
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text-primary);
    flex: 1;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    letter-spacing: -.2px;
}

/* Status flag — rounder, more refined */
#imovel-modal .imovel-status-flag {
    font-size: 10px;
    letter-spacing: .6px;
    padding: 4px 12px;
    border-radius: 100px;
    border-width: 1.5px;
    font-weight: 700;
}

/* ── Action badges bar ── */
#imovel-modal .imovel-action-buttons {
    padding: 8px 28px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    border-left: none;
    gap: 6px;
    flex-wrap: wrap;
    align-items: center;
}

#imovel-modal .imovel-action-badge {
    font-size: 11.5px;
    font-weight: 600;
    padding: 4px 12px;
    border-radius: 6px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    color: var(--text-primary);
}

/* ── Tab navigation ── */
#imovel-modal .imovel-tabs {
    padding: 0 24px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-surface);
    gap: 0;
    flex-shrink: 0;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}
#imovel-modal .imovel-tabs::-webkit-scrollbar { display: none; }

#imovel-modal .imovel-tab-btn {
    padding: 13px 16px;
    font-size: 12.5px;
    font-weight: 600;
    letter-spacing: .1px;
    color: var(--text-secondary);
    background: transparent;
    border: none;
    border-bottom: 2.5px solid transparent;
    cursor: pointer;
    white-space: nowrap;
    transition: color .15s ease, border-color .15s ease;
    margin-bottom: -1px;
    border-radius: 0;
}

#imovel-modal .imovel-tab-btn:hover {
    color: var(--text-primary);
    background: var(--bg-hover);
}

#imovel-modal .imovel-tab-btn.active {
    color: var(--brand-primary);
    border-bottom-color: var(--brand-primary);
    background: transparent;
}

/* ── Scrollable form body ── */
#imovel-modal .imovel-form {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 0;
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
}

/* ── Tab panels ── */
#imovel-modal .imovel-tab-panel {
    padding: 24px 28px 8px;
    animation: tabFadeIn .18s ease;
}

/* ── Analise layout: form + sticky sidebar ── */
#imovel-modal .analise-layout {
    display: grid;
    grid-template-columns: 1fr 280px;
    gap: 28px;
    align-items: start;
}

#imovel-modal .analise-content { min-width: 0; }

#imovel-modal .analise-sidebar {
    position: sticky;
    top: 12px;
}

/* ── Section fieldsets — editorial (no boxes) ── */
#imovel-modal .analise-content fieldset {
    border: none;
    border-radius: 0;
    padding: 0 0 24px;
    margin-bottom: 0;
    position: relative;
}

#imovel-modal .analise-content fieldset + fieldset {
    border-top: 1px solid var(--border-light);
    padding-top: 20px;
}

#imovel-modal .analise-content fieldset > legend {
    font-size: 10px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 1.2px;
    color: var(--brand-primary);
    padding: 0 0 14px;
    display: block;
    width: 100%;
    float: none;
    border-bottom: none;
}

/* fieldsets without a legend (bare wrapper) */
#imovel-modal .analise-content fieldset:not(:has(legend)) {
    padding-bottom: 16px;
}

/* ── Fields inside analise — bottom-line style ── */
#imovel-modal .analise-content .form-field {
    margin-bottom: 16px;
}

#imovel-modal .analise-content .form-field label {
    font-size: 10.5px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .7px;
    color: var(--text-secondary);
    margin-bottom: 6px;
    display: block;
}

#imovel-modal .analise-content .form-field--required label::after {
    content: ' *';
    color: var(--danger, #dc2626);
}

#imovel-modal .analise-content .form-field input,
#imovel-modal .analise-content .form-field select,
#imovel-modal .analise-content .form-field textarea {
    -webkit-appearance: none;
    appearance: none;
    border: none;
    border-bottom: 1.5px solid var(--border);
    border-radius: 0;
    padding: 7px 0;
    font-size: 13.5px;
    background: transparent;
    color: var(--text-primary);
    width: 100%;
    transition: border-color .15s;
    box-shadow: none;
}

#imovel-modal .analise-content .form-field select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%2394a3b8' stroke-width='1.5' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 4px center;
    padding-right: 24px;
    cursor: pointer;
}

#imovel-modal .analise-content .form-field input:focus,
#imovel-modal .analise-content .form-field select:focus,
#imovel-modal .analise-content .form-field textarea:focus {
    outline: none;
    border-bottom-color: var(--brand-primary);
    box-shadow: none;
    background: transparent;
}

#imovel-modal .analise-content .form-field--invalid input,
#imovel-modal .analise-content .form-field--invalid select {
    border-bottom-color: var(--danger, #dc2626);
    background: transparent;
}

/* ── Radio buttons — pill selector style ── */
#imovel-modal .analise-content .radio-inline {
    display: inline-flex;
    align-items: center;
    gap: 0;
    padding: 6px 18px;
    border: 1.5px solid var(--border);
    border-radius: 8px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    transition: all .15s;
    margin-right: 6px;
    margin-top: 4px;
    background: var(--bg-surface);
    user-select: none;
}

#imovel-modal .analise-content .radio-inline:has(input:checked) {
    background: var(--brand-primary);
    border-color: var(--brand-primary);
    color: #fff;
    font-weight: 600;
}

#imovel-modal .analise-content .radio-inline input {
    display: none;
}

/* ── empresa-section fieldsets (Dados + Gestão tabs) — same editorial treatment ── */
#imovel-modal .empresa-section {
    border: none;
    border-radius: 0;
    padding: 0 0 24px;
    background: transparent;
    box-shadow: none;
    margin-bottom: 0;
}

#imovel-modal .empresa-section + .empresa-section {
    border-top: 1px solid var(--border-light);
    padding-top: 20px;
    margin-top: 0;
}

#imovel-modal .empresa-section > legend {
    font-size: 10px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 1.2px;
    color: var(--brand-primary);
    padding: 0 0 14px;
    float: none;
    width: 100%;
    margin-bottom: 0;
    border-bottom: none;
    display: block;
}

#imovel-modal .empresa-section .form-row {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    margin-bottom: 0;
}

#imovel-modal .empresa-section .form-row + .form-row {
    margin-top: 0;
}

#imovel-modal .empresa-section .form-group {
    flex: 1;
    min-width: 160px;
    margin-bottom: 16px;
}

#imovel-modal .empresa-section .form-group.empresa-col-2 {
    flex: 2;
}

#imovel-modal .empresa-section .form-group.empresa-col-full {
    flex: 0 0 100%;
}

#imovel-modal .empresa-section .form-group label {
    font-size: 10.5px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .7px;
    color: var(--text-secondary);
    margin-bottom: 6px;
    display: block;
}

#imovel-modal .empresa-section input,
#imovel-modal .empresa-section select,
#imovel-modal .empresa-section textarea {
    -webkit-appearance: none;
    appearance: none;
    border: none;
    border-bottom: 1.5px solid var(--border);
    border-radius: 0;
    padding: 7px 0;
    font-size: 13.5px;
    background: transparent;
    color: var(--text-primary);
    width: 100%;
    transition: border-color .15s;
    box-shadow: none;
}

#imovel-modal .empresa-section select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%2394a3b8' stroke-width='1.5' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 4px center;
    padding-right: 24px;
    cursor: pointer;
}

#imovel-modal .empresa-section input:focus,
#imovel-modal .empresa-section select:focus,
#imovel-modal .empresa-section textarea:focus {
    outline: none;
    border-bottom-color: var(--brand-primary);
    box-shadow: none;
    background: transparent;
}

/* Required asterisk (gestao tab) */
#imovel-modal .required-field > label::after {
    content: ' *';
    color: var(--danger, #dc2626);
    text-transform: none;
    font-size: 12px;
}

/* ── Footer — sticky ── */
#imovel-modal .imovel-form .modal-footer {
    padding: 14px 28px;
    border-top: 1px solid var(--border);
    background: var(--bg-surface);
    position: sticky;
    bottom: 0;
    z-index: 5;
    flex-shrink: 0;
    gap: 8px;
    margin-top: 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* ── Dark theme adjustments ── */
html[data-theme="dark"] #imovel-modal .analise-content .form-field input,
html[data-theme="dark"] #imovel-modal .analise-content .form-field select,
html[data-theme="dark"] #imovel-modal .analise-content .form-field textarea,
html[data-theme="dark"] #imovel-modal .empresa-section input,
html[data-theme="dark"] #imovel-modal .empresa-section select,
html[data-theme="dark"] #imovel-modal .empresa-section textarea {
    color: var(--text-primary);
}

html[data-theme="dark"] #imovel-modal .analise-content .radio-inline {
    background: var(--bg-column);
    border-color: var(--border);
}

html[data-theme="dark"] #imovel-modal .analise-content .radio-inline:has(input:checked) {
    background: var(--brand-mid);
    border-color: var(--brand-mid);
    color: #fff;
}

/* ── Responsive ── */
@media (max-width: 880px) {
    #imovel-modal .analise-layout {
        grid-template-columns: 1fr;
    }
    #imovel-modal .analise-sidebar {
        position: static;
        order: -1;
    }
}

@media (max-width: 640px) {
    #imovel-modal .imovel-tab-panel { padding: 16px 16px 8px; }
    #imovel-modal .modal-header { padding: 14px 16px 12px; }
    #imovel-modal .imovel-form .modal-footer { padding: 12px 16px; }
    #imovel-modal .imovel-action-buttons { padding: 8px 16px; }
    #imovel-modal .imovel-tabs { padding: 0 8px; }
}
