/* ==========================================================================
   DESIGN TOKENS — fonte única para cores, espaçamentos, raios e sombras
   ========================================================================== */
:root {
    /* Cores — superfícies */
    --bg-page: #F8FAFC;
    --bg-surface: #FFFFFF;
    --bg-muted: #F1F5F9;
    --bg-overlay: rgba(15, 23, 42, 0.04);

    /* Cores — texto */
    --text-primary: #0F172A;
    --text-secondary: #475569;
    --text-tertiary: #94A3B8;
    --text-on-accent: #FFFFFF;

    /* Cores — bordas */
    --border-subtle: #E2E8F0;
    --border-strong: #CBD5E1;

    /* Acento — azul Compra Judicial mais sóbrio */
    --accent: #0066CC;
    --accent-hover: #0052A3;
    --accent-soft: #DBEAFE;
    --accent-softer: #EFF6FF;

    /* Semânticas */
    --success: #059669;
    --success-soft: #D1FAE5;
    --success-softer: #ECFDF5;
    --warning: #D97706;
    --warning-soft: #FED7AA;
    --warning-softer: #FFFBEB;
    --danger: #DC2626;
    --danger-soft: #FECACA;
    --danger-softer: #FEF2F2;
    --info: #0EA5E9;
    --info-softer: #F0F9FF;

    /* Espaçamentos (4px grid) */
    --sp-1: 4px;
    --sp-2: 8px;
    --sp-3: 12px;
    --sp-4: 16px;
    --sp-5: 24px;
    --sp-6: 32px;
    --sp-7: 48px;
    --sp-8: 64px;

    /* Raios */
    --r-sm: 6px;
    --r-md: 10px;
    --r-lg: 14px;
    --r-xl: 20px;
    --r-full: 999px;

    /* Sombras */
    --shadow-1: 0 1px 2px rgba(15, 23, 42, 0.04);
    --shadow-2: 0 2px 6px rgba(15, 23, 42, 0.05), 0 1px 2px rgba(15, 23, 42, 0.04);
    --shadow-3: 0 8px 20px -4px rgba(15, 23, 42, 0.08), 0 4px 8px -2px rgba(15, 23, 42, 0.04);

    /* Tipografia */
    --font-sans: 'Outfit', system-ui, -apple-system, sans-serif;
    --fs-xs: 11px;
    --fs-sm: 13px;
    --fs-md: 14px;
    --fs-lg: 16px;
    --fs-xl: 20px;
    --fs-2xl: 28px;
    --fs-3xl: 36px;

    /* Transições */
    --t-fast: 120ms ease;
    --t-base: 180ms ease;

    /* Compatibilidade com classes antigas — vão sumindo conforme refator */
    --primary: var(--accent);
    --primary-dark: var(--accent-hover);
    --primary-light: var(--accent-softer);
    --bg-body: var(--bg-page);
    --bg-sidebar: var(--bg-surface);
    --text-main: var(--text-primary);
    --text-muted: var(--text-secondary);
    --border-color: var(--border-subtle);
    --shadow: var(--shadow-2);
    --shadow-lg: var(--shadow-3);
    --transition: all var(--t-base);
}

/* ==========================================================================
   BASE
   ========================================================================== */
* { box-sizing: border-box; margin: 0; padding: 0; font-family: var(--font-sans); }

html, body {
    background-color: var(--bg-page);
    color: var(--text-primary);
    font-size: var(--fs-md);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

body {
    display: flex;
    min-height: 100vh;
    overflow-x: hidden;
}

h1, h2, h3, h4 { color: var(--text-primary); letter-spacing: -0.01em; }
h1 { font-size: var(--fs-2xl); font-weight: 700; letter-spacing: -0.02em; }
h2 { font-size: var(--fs-xl); font-weight: 700; }
h3 { font-size: var(--fs-lg); font-weight: 600; }

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }

/* ==========================================================================
   SIDEBAR
   ========================================================================== */
.sidebar {
    width: 240px;
    background-color: var(--bg-surface);
    border-right: 1px solid var(--border-subtle);
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
    z-index: 100;
    padding: var(--sp-5) var(--sp-3);
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: var(--sp-2);
    padding: var(--sp-2) var(--sp-3);
    margin-bottom: var(--sp-5);
    text-decoration: none;
}
.sidebar-brand-mark {
    width: 32px;
    height: 32px;
    border-radius: var(--r-md);
    background: linear-gradient(135deg, var(--accent), #1E40AF);
    display: grid;
    place-items: center;
    color: white;
    font-weight: 800;
    font-size: var(--fs-md);
    flex-shrink: 0;
}
.sidebar-brand-name {
    font-weight: 700;
    font-size: var(--fs-md);
    color: var(--text-primary);
    letter-spacing: -0.01em;
}

.sidebar-section-label {
    font-size: var(--fs-xs);
    text-transform: uppercase;
    color: var(--text-tertiary);
    font-weight: 600;
    letter-spacing: 0.04em;
    padding: var(--sp-4) var(--sp-3) var(--sp-2);
}

.nav-menu {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: var(--sp-3);
    padding: var(--sp-2) var(--sp-3);
    margin-bottom: 2px;
    border-radius: var(--r-md);
    color: var(--text-secondary);
    font-weight: 500;
    font-size: var(--fs-md);
    cursor: pointer;
    transition: background var(--t-fast), color var(--t-fast);
    text-decoration: none;
}
.nav-item:hover { background-color: var(--bg-muted); color: var(--text-primary); }
.nav-item.active {
    background-color: var(--accent-softer);
    color: var(--accent);
    font-weight: 600;
    box-shadow: none;
}
.nav-item i {
    font-style: normal;
    font-size: var(--fs-lg);
    width: 20px;
    text-align: center;
    margin: 0;
}

/* Backup block dentro da sidebar (compat) */
.sidebar > div[style*="margin-top: auto"] {
    margin-top: auto !important;
    padding: var(--sp-3) !important;
    border-top: 1px solid var(--border-subtle);
}

/* ==========================================================================
   MAIN
   ========================================================================== */
.main-content {
    margin-left: 240px;
    flex: 1;
    padding: var(--sp-5) var(--sp-6);
    max-width: calc(100vw - 240px);
}

header {
    margin-bottom: var(--sp-6);
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    gap: var(--sp-4);
}

.view-section { display: none; }
.view-section.active { display: block; animation: slideUp 220ms ease-out; }

@keyframes slideUp {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ==========================================================================
   CARDS
   ========================================================================== */
.card {
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--r-lg);
    padding: var(--sp-5);
    box-shadow: var(--shadow-1);
    margin-bottom: var(--sp-4);
}
.card h2 {
    font-size: var(--fs-lg);
    margin-bottom: var(--sp-4);
}
.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: var(--sp-3);
    margin-bottom: var(--sp-4);
    border-bottom: 1px solid var(--border-subtle);
}
.card-title {
    font-size: var(--fs-md);
    font-weight: 600;
}

/* ==========================================================================
   FORMS
   ========================================================================== */
.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: var(--sp-4);
}
.form-group { margin-bottom: var(--sp-4); }
.form-group label {
    display: block;
    margin-bottom: 6px;
    font-size: var(--fs-sm);
    font-weight: 600;
    color: var(--text-secondary);
}

input, select, textarea {
    width: 100%;
    padding: 10px 12px;
    border-radius: var(--r-md);
    border: 1px solid var(--border-subtle);
    background: var(--bg-surface);
    transition: border-color var(--t-fast), box-shadow var(--t-fast);
    font-size: var(--fs-md);
    color: var(--text-primary);
    font-family: inherit;
}
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-softer);
}

/* ==========================================================================
   BUTTONS
   ========================================================================== */
.btn {
    padding: 9px 16px;
    border-radius: var(--r-md);
    font-weight: 600;
    font-size: var(--fs-sm);
    cursor: pointer;
    transition: background var(--t-fast), color var(--t-fast), transform var(--t-fast);
    border: 1px solid transparent;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    font-family: inherit;
    line-height: 1.2;
}
.btn-primary {
    background-color: var(--accent);
    color: var(--text-on-accent);
}
.btn-primary:hover {
    background-color: var(--accent-hover);
}
.btn-secondary {
    background-color: var(--bg-surface);
    color: var(--text-secondary);
    border-color: var(--border-subtle);
}
.btn-secondary:hover {
    background-color: var(--bg-muted);
    color: var(--text-primary);
}

/* ==========================================================================
   KPI cards (componente)
   ========================================================================== */
.kpi {
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--r-lg);
    padding: var(--sp-5);
    transition: box-shadow var(--t-base);
}
.kpi:hover { box-shadow: var(--shadow-2); }
.kpi-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--sp-3);
}
.kpi-label {
    font-size: var(--fs-xs);
    text-transform: uppercase;
    color: var(--text-tertiary);
    font-weight: 600;
    letter-spacing: 0.04em;
}
.kpi-icon {
    width: 32px; height: 32px;
    border-radius: var(--r-md);
    display: grid; place-items: center;
    font-size: var(--fs-md);
}
.kpi-icon.blue { background: var(--accent-softer); color: var(--accent); }
.kpi-icon.green { background: var(--success-softer); color: var(--success); }
.kpi-icon.orange { background: var(--warning-softer); color: var(--warning); }
.kpi-icon.purple { background: #F5F3FF; color: #7C3AED; }
.kpi-icon.red { background: var(--danger-softer); color: var(--danger); }
.kpi-value {
    font-size: var(--fs-2xl);
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.02em;
    line-height: 1.1;
}
.kpi-delta {
    margin-top: var(--sp-2);
    font-size: var(--fs-xs);
    color: var(--text-tertiary);
}
.kpi-delta.up { color: var(--success); }
.kpi-delta.down { color: var(--danger); }
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: var(--sp-4);
    margin-bottom: var(--sp-5);
}
@media (max-width: 1100px) { .kpi-grid { grid-template-columns: repeat(2, 1fr); } }

/* ==========================================================================
   BADGES (componente)
   ========================================================================== */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 8px;
    border-radius: var(--r-full);
    font-size: var(--fs-xs);
    font-weight: 600;
    letter-spacing: 0.01em;
    white-space: nowrap;
}
.badge .dot {
    width: 6px; height: 6px;
    border-radius: var(--r-full);
    background: currentColor;
    flex-shrink: 0;
}
.badge.success { background: var(--success-softer); color: var(--success); }
.badge.info { background: var(--info-softer); color: var(--info); }
.badge.warning { background: var(--warning-softer); color: var(--warning); }
.badge.danger { background: var(--danger-softer); color: var(--danger); }
.badge.neutral { background: var(--bg-muted); color: var(--text-secondary); }
.badge.accent { background: var(--accent-softer); color: var(--accent); }

/* ==========================================================================
   FILTER TABS (pílulas no topo da página de Imóveis)
   ========================================================================== */
.filter-tabs {
    display: flex;
    gap: 4px;
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--r-md);
    padding: 4px;
    flex-wrap: wrap;
}
.filter-tab {
    padding: 6px 12px;
    border-radius: var(--r-sm);
    font-size: var(--fs-sm);
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: background var(--t-fast), color var(--t-fast);
    background: transparent;
    border: none;
    font-family: inherit;
}
.filter-tab:hover { color: var(--text-primary); }
.filter-tab.active {
    background: var(--accent);
    color: white;
    font-weight: 600;
}
.filter-tab .count {
    background: rgba(255,255,255,0.25);
    color: white;
    font-size: var(--fs-xs);
    font-weight: 700;
    padding: 1px 6px;
    border-radius: var(--r-full);
    line-height: 1.2;
}
.filter-tab:not(.active) .count { background: var(--bg-muted); color: var(--text-secondary); }

/* ==========================================================================
   TABLE (componente)
   ========================================================================== */
.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--fs-sm);
}
.data-table th {
    text-align: left;
    padding: var(--sp-3) var(--sp-4);
    font-size: var(--fs-xs);
    text-transform: uppercase;
    color: var(--text-tertiary);
    font-weight: 600;
    letter-spacing: 0.04em;
    border-bottom: 1px solid var(--border-subtle);
    background: var(--bg-muted);
}
.data-table th.right { text-align: right; }
.data-table th.center { text-align: center; }
.data-table td {
    padding: var(--sp-3) var(--sp-4);
    border-bottom: 1px solid var(--border-subtle);
    color: var(--text-primary);
    vertical-align: middle;
}
.data-table td.right { text-align: right; }
.data-table td.center { text-align: center; }
.data-table tr:last-child td { border-bottom: none; }
.data-table tbody tr { transition: background var(--t-fast); }
.data-table tbody tr:hover td { background: var(--bg-muted); cursor: pointer; }

/* Table container — sem padding pra a tabela ir até a borda do card */
.card.table-host { padding: 0; overflow: hidden; }

/* ==========================================================================
   EMPTY STATE
   ========================================================================== */
.empty-state {
    text-align: center;
    padding: var(--sp-7) var(--sp-5);
    color: var(--text-tertiary);
}
.empty-state-icon {
    font-size: 48px;
    margin-bottom: var(--sp-3);
    opacity: 0.6;
}
.empty-state-title {
    font-size: var(--fs-lg);
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: var(--sp-2);
}
.empty-state-desc { font-size: var(--fs-sm); }

/* ==========================================================================
   SEARCH BOX
   ========================================================================== */
.search-box {
    position: relative;
    flex: 1;
    max-width: 320px;
}
.search-box input {
    width: 100%;
    padding: 8px 12px 8px 36px;
    border: 1px solid var(--border-subtle);
    background: var(--bg-surface);
    border-radius: var(--r-md);
    font-size: var(--fs-sm);
}
.search-box .icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-tertiary);
    font-size: var(--fs-md);
    pointer-events: none;
}

/* ==========================================================================
   TOOLBAR (linha com tabs/filtros + busca)
   ========================================================================== */
.toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--sp-4);
    margin-bottom: var(--sp-4);
    flex-wrap: wrap;
}

/* ==========================================================================
   USER CHIP (no rodapé da sidebar)
   ========================================================================== */
.user-chip {
    display: flex;
    align-items: center;
    gap: var(--sp-3);
    padding: var(--sp-2);
    border-radius: var(--r-md);
    cursor: pointer;
    transition: background var(--t-fast);
    text-decoration: none;
}
.user-chip:hover { background: var(--bg-muted); }
.user-avatar {
    width: 32px; height: 32px;
    border-radius: var(--r-full);
    background: var(--accent-soft);
    color: var(--accent);
    display: grid; place-items: center;
    font-weight: 700;
    font-size: var(--fs-sm);
    flex-shrink: 0;
}
.user-info { line-height: 1.2; min-width: 0; }
.user-name { font-weight: 600; font-size: var(--fs-sm); color: var(--text-primary); }
.user-email { color: var(--text-tertiary); font-size: var(--fs-xs); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 140px; }

/* ==========================================================================
   STEPS (multi-step do cadastro — visual mais sutil)
   ========================================================================== */
.steps-container {
    display: flex;
    justify-content: center;
    margin-bottom: var(--sp-6);
    position: relative;
}
.steps-container::before {
    content: '';
    position: absolute;
    top: 18px;
    left: 18%;
    right: 18%;
    height: 2px;
    background: var(--border-subtle);
    z-index: 1;
}
.step {
    position: relative;
    z-index: 2;
    background: var(--bg-surface);
    width: 36px;
    height: 36px;
    border-radius: var(--r-full);
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid var(--border-subtle);
    margin: 0 var(--sp-5);
    font-weight: 700;
    color: var(--text-tertiary);
    transition: all var(--t-base);
    cursor: pointer;
}
.step.active {
    border-color: var(--accent);
    background: var(--accent);
    color: white;
    box-shadow: 0 0 0 4px var(--accent-softer);
}
.step.completed { background: var(--success); border-color: var(--success); color: white; }

/* ==========================================================================
   MODALS
   ========================================================================== */
.modal-overlay {
    position: fixed;
    top: 0; left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}
.modal-content {
    background: var(--bg-surface);
    padding: var(--sp-6);
    border-radius: var(--r-xl);
    width: 100%;
    max-width: 520px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-3);
}

.input-file {
    padding: 6px;
    font-size: var(--fs-xs);
    border: 1px solid var(--border-subtle);
    border-radius: var(--r-sm);
    width: 100%;
    background: var(--bg-surface);
}

/* ==========================================================================
   BREADCRUMB
   ========================================================================== */
.breadcrumb {
    display: flex;
    gap: var(--sp-2);
    align-items: center;
    font-size: var(--fs-sm);
    color: var(--text-tertiary);
    margin-bottom: var(--sp-3);
}
.breadcrumb a { color: var(--text-tertiary); }
.breadcrumb a:hover { color: var(--accent); }

/* ==========================================================================
   UTILS
   ========================================================================== */
.text-muted { color: var(--text-tertiary); }
.text-secondary { color: var(--text-secondary); }
.text-success { color: var(--success); }
.text-warning { color: var(--warning); }
.text-danger { color: var(--danger); }
.text-right { text-align: right; }
.text-center { text-align: center; }
