:root {
    --bg-main: linear-gradient(135deg, #050b14, #122650); /* Dark Midnight Blue to Strong Navy */
    --bg-panel: rgba(17, 24, 39, 0.6); /* Dark Glass */
    --border-light: rgba(255, 255, 255, 0.1);
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --primary: #3b82f6; /* Bright Neon Blue */
    --primary-hover: #60a5fa;
    --accent: #facc15; /* Bright Sun Yellow */
    --danger: #ef4444;  
    --success: #22c55e; 
    --sidebar-width: 260px;
    --transition-speed: 0.3s;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', sans-serif;
}

html, body {
    background: var(--bg-main);
    background-attachment: fixed;
    color: var(--text-main);
    overflow-x: hidden;
    max-width: 100vw;
}

.text-primary { color: var(--primary); }
.text-accent { color: var(--accent); }

/* Painéis Glass (Estilo Azul/Noite) */
.glass-panel {
    background: var(--bg-panel);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--border-light);
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

/* Layout */
.app-container {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background: rgba(10, 15, 30, 0.8);
    backdrop-filter: blur(20px);
    border-right: 1px solid var(--border-light);
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
    z-index: 50;
    box-shadow: 4px 0 20px rgba(0,0,0,0.2);
}

.sidebar-header {
    height: 80px;
    display: flex;
    align-items: center;
    padding: 0 24px;
    gap: 12px;
    border-bottom: 1px solid var(--border-light);
}

.logo-icon {
    font-size: 2.2rem;
    color: var(--accent);
}

.sidebar-nav {
    padding: 24px 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex-grow: 1;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 14px 20px;
    color: var(--text-muted);
    text-decoration: none;
    border-radius: 12px;
    font-weight: 500;
    transition: all var(--transition-speed) ease;
}

.nav-link i { font-size: 1.25rem; }

.nav-link:hover {
    color: var(--text-main);
    background: rgba(255, 255, 255, 0.05);
}

.nav-link.active {
    color: var(--text-main);
    background: linear-gradient(90deg, rgba(250, 204, 21, 0.15), transparent);
    border-left: 4px solid var(--accent);
    border-radius: 0 12px 12px 0;
}

.sidebar-footer {
    padding: 24px;
    border-top: 1px solid var(--border-light);
    background: rgba(0,0,0,0.2);
}

.user-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent), #d97706);
    color: #451a03;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    box-shadow: 0 0 10px rgba(250, 204, 21, 0.4);
}

.user-details { display: flex; flex-direction: column; }
.user-name { font-weight: 600; font-size: 0.9rem; }

/* Main Content */
.main-content {
    flex-grow: 1;
    margin-left: var(--sidebar-width);
    padding: 32px 48px;
    width: calc(100% - var(--sidebar-width));
}

.view-section {
    display: none;
    animation: fadeIn 0.4s ease forwards;
}

.view-section.active { display: block; }

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

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    margin-bottom: 32px;
}

.section-header h1 {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 4px;
    color: var(--text-main);
}

.section-header p { color: var(--text-muted); }

/* Buttons */
.btn {
    padding: 10px 20px;
    border-radius: 8px;
    border: none;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all var(--transition-speed);
}

.btn-primary { 
    background: linear-gradient(135deg, var(--primary), #1e3a8a); 
    color: white; 
    border: 1px solid rgba(59, 130, 246, 0.5);
}
.btn-primary:hover { 
    background: linear-gradient(135deg, #60a5fa, var(--primary)); 
    box-shadow: 0 0 15px rgba(59, 130, 246, 0.4); 
    transform: translateY(-2px); 
}

/* Secondary turns into Yellow/Gold Action */
.btn-secondary { 
    background: linear-gradient(135deg, #facc15, #eab308); 
    color: #451a03; 
    border: none; 
}
.btn-secondary:hover { 
    background: linear-gradient(135deg, #fef08a, #facc15); 
    box-shadow: 0 0 15px rgba(250, 204, 21, 0.4); 
    transform: translateY(-2px);
}

.btn-danger { background: rgba(220, 38, 38, 0.2); color: #fca5a5; border: 1px solid rgba(220, 38, 38, 0.4); }
.btn-danger:hover { background: var(--danger); color: white; box-shadow: 0 0 15px rgba(220, 38, 38, 0.5); }

.btn-success { background: rgba(34, 197, 94, 0.2); color: #86efac; border: 1px solid rgba(34, 197, 94, 0.4); }
.btn-success:hover { background: var(--success); color: white; box-shadow: 0 0 15px rgba(34, 197, 94, 0.5); }

/* Dashboard KPIs */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 24px;
    margin-bottom: 32px;
}

.kpi-card {
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.kpi-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    color: var(--text-muted);
    font-weight: 500;
}

.kpi-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    background: rgba(255,255,255,0.05);
    color: var(--accent);
}

.kpi-value { font-size: 2rem; font-weight: 700; color: var(--text-main); }

/* Cards Grid (Imoveis & Inquilinos) */
.cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 24px;
}

.data-card {
    padding: 24px;
    position: relative;
    overflow: hidden;
}

.inquilino-avatar {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background-size: cover;
    background-position: center;
    margin-bottom: 16px;
    border: 2px solid var(--accent);
    box-shadow: 0 4px 15px rgba(250, 204, 21, 0.3);
}

.badge {
    position: absolute;
    top: 24px;
    right: 24px;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
}

.badge.primary { background: rgba(59, 130, 246, 0.2); color: #93c5fd; border: 1px solid rgba(59, 130, 246, 0.4); }
.badge.warning { background: rgba(250, 204, 21, 0.2); color: #fde047; border: 1px solid rgba(250, 204, 21, 0.4); }
.badge.danger  { background: rgba(239, 68, 68, 0.2); color: #fca5a5; border: 1px solid rgba(239, 68, 68, 0.4); }
.badge.success { background: rgba(34, 197, 94, 0.2); color: #86efac; border: 1px solid rgba(34, 197, 94, 0.4); }

/* --- Imovel Gallery & Rich Details --- */
.imovel-gallery {
    display: flex;
    overflow-x: auto;
    gap: 8px;
    padding-bottom: 4px;
    margin-bottom: 12px;
}
.imovel-gallery::-webkit-scrollbar { height: 6px; }
.imovel-gallery::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.2); border-radius: 10px; }
.gallery-img {
    height: 120px; width: 160px; object-fit: cover; border-radius: 8px;
    border: 1px solid var(--border-light); flex-shrink: 0;
}
.imovel-features { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.feature-badge {
    background: rgba(255,255,255,0.05); padding: 6px 10px; border-radius: 6px;
    font-size: 0.75rem; color: var(--text-muted); display: flex; align-items: center; gap: 6px;
    font-weight: 500; border: 1px solid var(--border-light);
}

/* --- Mobile Bottom Navigation --- */
.mobile-nav {
    display: none;
    position: fixed;
    bottom: 0; left: 0; width: 100%;
    background: rgba(10, 15, 30, 0.95);
    backdrop-filter: blur(20px);
    border-top: 1px solid var(--border-light);
    z-index: 1000;
    justify-content: space-around;
    padding: 10px 5px;
    padding-bottom: calc(10px + env(safe-area-inset-bottom));
    box-shadow: 0 -4px 20px rgba(0,0,0,0.5);
}
.mobile-nav .nav-link {
    display: flex; flex-direction: column; align-items: center;
    color: var(--text-muted); text-decoration: none;
    font-size: 0.7rem; gap: 4px; transition: 0.3s;
    padding: 8px; border-radius: 12px; margin: 0;
}
.mobile-nav .nav-link i { font-size: 1.5rem; }
.mobile-nav .nav-link.active {
    color: var(--accent); background: rgba(250, 204, 21, 0.1);
    box-shadow: none; border: none;
}

/* Media queries movidas para o final do arquivo por precedência */

.card-title {
    font-size: 1.25rem; font-weight: 700; margin-bottom: 8px; padding-right: 80px; color: var(--text-main);
}
.card-details {
    color: var(--text-muted); font-size: 0.9rem; margin-bottom: 20px; line-height: 1.5;
}
.card-actions {
    display: flex; gap: 12px; border-top: 1px solid var(--border-light); padding-top: 16px; margin-top: 16px;
}

/* Forms & Inputs */
.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 20px; }
.full-width { grid-column: 1 / -1; }
.input-group { display: flex; flex-direction: column; gap: 8px; }
.input-group label { font-size: 0.85rem; font-weight: 600; color: var(--accent); }
.input-group input, .input-group select, .input-group textarea {
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(255,255,255,0.2);
    color: var(--text-main);
    padding: 12px 16px;
    border-radius: 8px;
    font-size: 0.95rem;
    outline: none;
    transition: all 0.2s;
}
.input-group input:focus, .input-group select:focus, .input-group textarea:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(250, 204, 21, 0.2);
}
.contract-builder { padding: 32px; }

/* Tables */
.table-container { width: 100%; overflow-x: auto; background: var(--bg-panel); border-radius: 12px; border: 1px solid var(--border-light); }
.data-table { width: 100%; border-collapse: collapse; text-align: left; }
.data-table th, .data-table td { padding: 16px 24px; border-bottom: 1px solid var(--border-light); }
.data-table th { font-weight: 700; color: var(--accent); font-size: 0.85rem; text-transform: uppercase; }
.data-table tbody tr:hover { background: rgba(255,255,255,0.05); }

/* Modals */
.modal-overlay {
    position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 5, 15, 0.8); backdrop-filter: blur(8px);
    display: none; align-items: center; justify-content: center;
    z-index: 2000; opacity: 0; transition: opacity 0.3s;
}
.modal-overlay.active { display: flex; opacity: 1; }
.modal {
    width: 100%; max-width: 500px; padding: 32px; background: #0f172add;
    transform: translateY(20px); transition: transform 0.3s; border: 1px solid var(--border-light);
}
.modal-overlay.active .modal { transform: translateY(0); }
.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 24px; }
.modal-header h2 { color: var(--accent); }
.close-btn { background: transparent; border: none; color: var(--text-muted); font-size: 1.25rem; cursor: pointer; }
.close-btn:hover { color: var(--danger); }
.modal-actions { display: flex; justify-content: flex-end; gap: 12px; margin-top: 32px; }

/* Tela de Login Especial */
.login-screen {
    position: fixed;
    top: 0; left: 0; width: 100vw; height: 100vh;
    background: linear-gradient(135deg, #020617, #1e3a8a);
    display: none; align-items: center; justify-content: center;
    z-index: 9999;
}
.login-card {
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    width: 100%; max-width: 400px;
    padding: 40px; border-radius: 16px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.5);
    border: 1px solid rgba(255,255,255,0.1);
}

/* --- Responsive Media Queries (MOVIDO PARA O FIM PARA SOBRESCREVER) --- */
@media (max-width: 768px) {
    .sidebar { display: none; }
    .mobile-nav { 
        display: flex; 
        overflow-x: auto; 
        justify-content: flex-start; 
        gap: 12px; 
        padding: 10px 16px; 
        padding-bottom: calc(10px + env(safe-area-inset-bottom));
        flex-wrap: nowrap; 
        -webkit-overflow-scrolling: touch; 
    }
    .mobile-nav::-webkit-scrollbar { display: none; }
    .mobile-nav .nav-link { flex-shrink: 0; min-width: 74px; }
    
    .main-content {
        margin-left: 0;
        padding: 12px;
        padding-bottom: 110px;
        width: 100%;
        max-width: 100%;
        box-sizing: border-box;
        overflow-x: hidden;
    }
    .header {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }
    #imoveis-grid, #inquilinos-grid, #dashboard-kpis {
        grid-template-columns: 1fr;
    }
    .form-grid { grid-template-columns: 1fr; }
    .table-container { 
        width: 100%; 
        max-width: 100%; 
        overflow-x: auto; 
        -webkit-overflow-scrolling: touch;
        box-sizing: border-box;
    }
    table { min-width: 500px; font-size: 0.85rem; }
    
    .modal-overlay { align-items: flex-end; }
    .modal {
        margin-bottom: 0;
        border-bottom-left-radius: 0;
        border-bottom-right-radius: 0;
        max-width: 100% !important;
        max-height: 85vh !important;
        animation: slideUp 0.3s ease-out;
    }
    @keyframes slideUp {
        from { transform: translateY(100%); }
        to { transform: translateY(0); }
    }
}
