/* styles.css - Complejo Vera Paz (Diseño Premium & Responsive) */

/* ==========================================
   VARIABLES DE DISEÑO (PALETA NEUTRA & TEAL)
   ========================================== */
:root {
    --primary: #0d9488; /* Teal / Esmeralda Oscuro */
    --primary-hover: #0f766e;
    --primary-light: #ccfbf1;
    --secondary: #0284c7; /* Azul */
    --secondary-hover: #0369a1;
    
    --bg-main: #f8fafc; /* Gris Slate muy claro */
    --bg-card: #ffffff; /* Blanco */
    --bg-sidebar: #0f172a; /* Slate oscuro (casi negro) */
    --bg-sidebar-active: #1e293b;
    
    --text-main: #0f172a;
    --text-muted: #64748b;
    --text-light: #ffffff;
    
    --border-color: #e2e8f0;
    --border-focus: #0d9488;
    
    --success: #10b981; /* Verde */
    --success-light: #d1fae5;
    --warning: #f59e0b; /* Ámbar */
    --warning-light: #fef3c7;
    --danger: #ef4444; /* Rojo */
    --danger-light: #fee2e2;
    --info: #3b82f6;
    
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.05);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.05), 0 2px 4px -1px rgba(0,0,0,0.03);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -4px rgba(0, 0, 0, 0.08);
    --shadow-premium: 0 20px 25px -5px rgba(15, 23, 42, 0.08), 0 8px 10px -6px rgba(15, 23, 42, 0.08);

    --transition-fast: 0.15s ease;
    --transition-normal: 0.25s ease;
}

/* ==========================================
   ESTILOS GENERALES
   ========================================== */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background-color: var(--bg-main);
    color: var(--text-main);
    line-height: 1.5;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, h5, h6 {
    font-weight: 700;
    color: var(--text-main);
    line-height: 1.25;
}

a {
    color: var(--primary);
    text-decoration: none;
    transition: var(--transition-fast);
}

button, input, select, textarea {
    font-family: inherit;
    font-size: inherit;
}

/* Scrollbar personalizado */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* ==========================================
   CONTENEDOR Y LAYOUT PRINCIPAL
   ========================================== */
.app-container {
    display: flex;
    min-height: 100vh;
}

/* Barra lateral */
.sidebar {
    width: 260px;
    background-color: var(--bg-sidebar);
    color: var(--text-light);
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
    left: 0;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow-lg);
    transition: transform var(--transition-normal);
}

.sidebar-header {
    padding: 24px;
    display: flex;
    flex-direction: column;
    align-items: center;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    gap: 8px;
}

.logo-icon {
    width: 50px;
    height: 50px;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    font-weight: 800;
    color: white;
    box-shadow: 0 4px 10px rgba(13, 148, 136, 0.4);
}

.sidebar-header h2 {
    color: white;
    font-size: 1.15rem;
    letter-spacing: 0.5px;
    margin-top: 4px;
}

.sidebar-nav {
    flex: 1;
    padding: 20px 12px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.nav-item {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    color: #94a3b8;
    border-radius: var(--radius-md);
    font-weight: 500;
    gap: 12px;
    transition: var(--transition-normal);
    position: relative;
}

.nav-item i {
    width: 20px;
    height: 20px;
}

.nav-item:hover {
    color: white;
    background-color: rgba(255,255,255,0.05);
}

.nav-item.active {
    color: white;
    background-color: var(--primary);
    box-shadow: 0 4px 12px rgba(13, 148, 136, 0.3);
}

.sidebar-footer {
    padding: 20px 16px;
    border-top: 1px solid rgba(255,255,255,0.08);
}

/* Área de contenido principal */
.main-content {
    flex: 1;
    margin-left: 260px;
    padding: 30px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    gap: 24px;
    background-color: var(--bg-main);
    transition: margin var(--transition-normal);
}

.main-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border-color);
}

.menu-toggle {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-main);
}

.menu-toggle i {
    width: 24px;
    height: 24px;
}

.mobile-nav {
    display: none;
}

/* ==========================================
   ELEMENTOS DE INTERFAZ COMUNES (UI)
   ========================================== */
.card {
    background-color: var(--bg-card);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
    padding: 24px;
    transition: transform var(--transition-normal), box-shadow var(--transition-normal);
    overflow: hidden;
}

.card:hover {
    box-shadow: var(--shadow-md);
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 18px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border-color);
}

.card-header h3 {
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    gap: 8px;
}

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

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    text-align: center;
    color: var(--text-muted);
    gap: 12px;
}

.empty-state i {
    width: 48px;
    height: 48px;
    color: var(--text-muted);
}

/* Botones */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    padding: 10px 18px;
    border-radius: var(--radius-md);
    cursor: pointer;
    border: none;
    transition: var(--transition-normal);
    gap: 8px;
    font-size: 0.95rem;
}

.btn i {
    width: 18px;
    height: 18px;
}

.btn-primary {
    background-color: var(--primary);
    color: white;
}

.btn-primary:hover {
    background-color: var(--primary-hover);
    box-shadow: 0 4px 12px rgba(13, 148, 136, 0.25);
}

.btn-secondary {
    background-color: #f1f5f9;
    color: #475569;
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background-color: #e2e8f0;
    color: #1e293b;
}

.btn-danger {
    background-color: var(--danger);
    color: white;
}

.btn-danger:hover {
    background-color: #dc2626;
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.25);
}

.btn-sm {
    padding: 6px 12px;
    font-size: 0.85rem;
    border-radius: var(--radius-sm);
}

.btn-sm i {
    width: 14px;
    height: 14px;
}

.btn-icon-only {
    padding: 10px;
    border-radius: 50%;
}

.w-100 {
    width: 100%;
}

/* Badges */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.badge-admin {
    background-color: rgba(13, 148, 136, 0.2);
    color: #2dd4bf;
    font-size: 0.65rem;
}

.bg-success {
    background-color: var(--success-light);
    color: var(--success);
}

.bg-warning {
    background-color: var(--warning-light);
    color: var(--warning);
}

.bg-danger {
    background-color: var(--danger-light);
    color: var(--danger);
}

.bg-info {
    background-color: #dbeafe;
    color: var(--info);
}

.badge-count {
    background-color: var(--danger);
    color: white;
    font-size: 0.7rem;
    font-weight: bold;
    border-radius: 50%;
    width: 18px;
    height: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: absolute;
    top: 8px;
    right: 12px;
}

/* ==========================================
   VIEW: DASHBOARD
   ========================================== */
.grid-cards-summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 20px;
}

.summary-card {
    display: flex;
    align-items: center;
    gap: 18px;
    padding: 24px;
}

.summary-card .card-icon {
    width: 54px;
    height: 54px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
}

.card-income .card-icon {
    background-color: var(--success-light);
    color: var(--success);
}

.card-expense .card-icon {
    background-color: var(--danger-light);
    color: var(--danger);
}

.card-balance .card-icon {
    background-color: #e0f2fe;
    color: var(--secondary);
}

.card-info {
    display: flex;
    flex-direction: column;
}

.card-label {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.card-info h3 {
    font-size: 1.6rem;
    font-weight: 800;
}

.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 24px;
}

.col-2 {
    grid-column: span 2;
}

/* Feed de Alertas */
.alerts-feed {
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-height: 350px;
    overflow-y: auto;
    padding-right: 4px;
}

.alert-item {
    display: flex;
    align-items: flex-start;
    padding: 14px 16px;
    border-radius: var(--radius-md);
    border-left: 4px solid var(--border-color);
    gap: 12px;
    background-color: #fafafa;
    transition: var(--transition-fast);
}

.alert-item:hover {
    transform: translateX(3px);
}

.alert-item.alert-expired {
    border-left-color: var(--danger);
    background-color: #fef2f2;
}

.alert-item.alert-warning-30 {
    border-left-color: var(--danger);
    background-color: #fff5f5;
}

.alert-item.alert-warning-60 {
    border-left-color: var(--warning);
    background-color: #fffbeb;
}

.alert-item.alert-warning-90 {
    border-left-color: var(--info);
    background-color: #eff6ff;
}

.alert-item.alert-maint {
    border-left-color: var(--warning);
    background-color: #fffdf5;
}

.alert-item-content {
    flex: 1;
}

.alert-item-title {
    font-weight: 600;
    font-size: 0.95rem;
}

.alert-item-desc {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.alert-item-time {
    font-size: 0.75rem;
    font-weight: 700;
    margin-top: 4px;
}

.alert-action-btn {
    background: none;
    border: none;
    color: var(--primary);
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    align-self: center;
}

.alert-action-btn:hover {
    background-color: rgba(13, 148, 136, 0.1);
}

/* Gráfico Radial de Ocupación */
.occupation-radial {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 20px;
    height: 100%;
}

.radial-progress {
    position: relative;
    width: 130px;
    height: 130px;
    border-radius: 50%;
    background: conic-gradient(var(--primary) calc(var(--percent) * 1%), var(--border-color) 0);
    display: flex;
    align-items: center;
    justify-content: center;
}

.radial-inner {
    width: 106px;
    height: 106px;
    border-radius: 50%;
    background-color: var(--bg-card);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.radial-inner span {
    font-size: 1.6rem;
    font-weight: 800;
}

.radial-inner small {
    color: var(--text-muted);
    font-size: 0.75rem;
    text-transform: uppercase;
}

.occupation-legend {
    display: flex;
    gap: 16px;
}

.legend-item {
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    gap: 6px;
    font-weight: 500;
}

.dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: inline-block;
}

.bg-success { background-color: var(--success); }
.bg-danger { background-color: var(--danger); }

/* Checklist de Mantenimiento en Dashboard */
.maint-checklist {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.maint-check-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px;
    border-radius: var(--radius-md);
    background-color: #f8fafc;
    border: 1px solid var(--border-color);
}

.maint-check-info {
    display: flex;
    flex-direction: column;
}

.maint-check-title {
    font-size: 0.9rem;
    font-weight: 600;
}

.maint-check-meta {
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* Quick Actions */
.quick-actions-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
    height: 100%;
}

.btn-action {
    flex-direction: column;
    padding: 16px;
    background-color: #fafafa;
    border: 1px solid var(--border-color);
    color: var(--text-main);
    gap: 8px;
    text-align: center;
}

.btn-action:hover {
    background-color: var(--primary-light);
    color: var(--primary-hover);
    border-color: var(--primary);
    transform: translateY(-2px);
}

.btn-action i {
    width: 24px;
    height: 24px;
    color: var(--primary);
}

/* ==========================================
   VIEW: DEPARTAMENTOS
   ========================================== */
.view-actions-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.tabs-complex-map {
    display: flex;
    background-color: #f1f5f9;
    padding: 4px;
    border-radius: var(--radius-md);
    gap: 4px;
    width: 100%;
}

.tab-btn {
    flex: 1;
    background: none;
    border: none;
    padding: 8px 16px;
    font-weight: 600;
    font-size: 0.9rem;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    cursor: pointer;
    transition: var(--transition-normal);
}

.tab-btn:hover {
    color: var(--text-main);
}

.tab-btn.active {
    background-color: white;
    color: var(--primary);
    box-shadow: var(--shadow-sm);
}

.complex-map-card {
    padding: 30px;
    display: flex;
    justify-content: center;
    align-items: center;
    background-color: white;
}

.map-view-container {
    width: 100%;
    max-width: 800px;
}

/* Estructura del Mapa (Arquitectónico Simplificado) */
.map-grid-pb {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: auto auto auto auto;
    gap: 14px;
}

.map-grid-pa {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: auto auto auto; /* 2 filas de dptos (3+3) + entrepiso */
    gap: 14px;
}

.map-grid-terraza {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
}

.map-grid-terreno {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 14px;
}

.map-cell {
    background-color: #f8fafc;
    border: 2px dashed #cbd5e1;
    border-radius: var(--radius-md);
    padding: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    cursor: pointer;
    min-height: 100px;
    transition: var(--transition-normal);
    position: relative;
}

.map-cell:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-md);
    border-color: var(--primary);
}

.map-cell.dto-cell {
    border-style: solid;
}

.map-cell.rented {
    background-color: var(--success-light);
    border-color: var(--success);
    color: #065f46;
}

.map-cell.vacant {
    background-color: var(--danger-light);
    border-color: var(--danger);
    color: #991b1b;
}

.map-cell.common-cell {
    background-color: #f1f5f9;
    border-color: #94a3b8;
    color: #334155;
    border-style: solid;
}

.map-cell.common-cell:hover {
    border-color: var(--primary);
}

.map-cell-name {
    font-weight: 700;
    font-size: 1rem;
}

.map-cell-info {
    font-size: 0.8rem;
    margin-top: 4px;
    opacity: 0.9;
}

/* Grid de Tarjetas de Departamentos */
.grid-departments {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 20px;
}

.dept-card {
    cursor: pointer;
}

.dept-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 16px;
}

.dept-card-header h3 {
    font-size: 1.2rem;
}

.dept-card-body {
    display: flex;
    flex-direction: column;
    gap: 8px;
    font-size: 0.9rem;
}

.dept-info-row {
    display: flex;
    justify-content: space-between;
    border-bottom: 1px solid #f1f5f9;
    padding-bottom: 4px;
}

.dept-info-label {
    color: var(--text-muted);
}

.dept-info-val {
    font-weight: 600;
}

/* Ficha de Departamento Detalle (Overlay) */
.department-detail-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(15, 23, 42, 0.4);
    backdrop-filter: blur(4px);
    z-index: 1000;
    display: flex;
    justify-content: flex-end;
    transition: opacity var(--transition-normal);
}

.detail-card {
    width: 100%;
    max-width: 650px;
    height: 100%;
    background-color: white;
    box-shadow: var(--shadow-premium);
    display: flex;
    flex-direction: column;
    padding: 30px;
    position: relative;
    overflow-y: auto;
    animation: slideInRight var(--transition-normal) forwards;
}

@keyframes slideInRight {
    from { transform: translateX(100%); }
    to { transform: translateX(0); }
}

.detail-close {
    position: absolute;
    top: 20px;
    right: 20px;
    font-size: 2rem;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-muted);
    transition: var(--transition-fast);
}

.detail-close:hover {
    color: var(--text-main);
}

.detail-header {
    margin-bottom: 24px;
    padding-right: 40px;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

.detail-header h2 {
    font-size: 1.8rem;
}

.detail-tabs {
    display: flex;
    border-bottom: 2px solid var(--border-color);
    margin-bottom: 24px;
    gap: 8px;
    overflow-x: auto;
}

.detail-tab-btn {
    background: none;
    border: none;
    padding: 12px 16px;
    font-weight: 600;
    color: var(--text-muted);
    cursor: pointer;
    position: relative;
    display: flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
}

.detail-tab-btn i {
    width: 18px;
    height: 18px;
}

.detail-tab-btn:hover {
    color: var(--text-main);
}

.detail-tab-btn.active {
    color: var(--primary);
}

.detail-tab-btn.active::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    width: 100%;
    height: 2px;
    background-color: var(--primary);
}

.detail-tab-content {
    display: none;
    flex-direction: column;
    gap: 20px;
}

.detail-tab-content.active {
    display: flex;
}

.inquilino-detail-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
    background-color: #f8fafc;
    padding: 20px;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
}

.inquilino-actions {
    display: flex;
    gap: 12px;
    margin-top: 10px;
}

.tab-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* ==========================================
   TABLAS Y DATOS
   ========================================== */
.table-responsive {
    width: 100%;
    overflow-x: auto;
}

.app-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
    font-size: 0.95rem;
}

.app-table th {
    background-color: #f8fafc;
    font-weight: 700;
    color: var(--text-muted);
    padding: 14px 16px;
    border-bottom: 2px solid var(--border-color);
}

.app-table td {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border-color);
    vertical-align: middle;
}

.app-table tbody tr:hover {
    background-color: #fafafa;
}

.img-thumbnail-cell {
    width: 50px;
    height: 50px;
    border-radius: var(--radius-sm);
    object-fit: cover;
    cursor: pointer;
    border: 1px solid var(--border-color);
    transition: var(--transition-fast);
}

.img-thumbnail-cell:hover {
    transform: scale(1.1);
}

.no-photo-badge {
    color: var(--text-muted);
    font-size: 0.75rem;
    font-style: italic;
}

.actions-cell {
    display: flex;
    gap: 8px;
}

.btn-action-table {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-muted);
    padding: 4px;
    border-radius: 4px;
    transition: var(--transition-fast);
}

.btn-action-table:hover {
    background-color: #e2e8f0;
    color: var(--text-main);
}

.btn-action-table.delete:hover {
    background-color: var(--danger-light);
    color: var(--danger);
}

/* ==========================================
   GASTOS GENERALES
   ========================================== */
.view-header-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    gap: 16px;
}

.filter-controls {
    display: flex;
    gap: 16px;
    flex: 1;
}

.form-group-filter {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 150px;
}

.form-group-filter label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
}

.form-control {
    width: 100%;
    padding: 10px 14px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    background-color: white;
    color: var(--text-main);
    outline: none;
    transition: var(--transition-fast);
}

.form-control:focus {
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px rgba(13, 148, 136, 0.15);
}

.flex-row {
    display: flex;
    align-items: flex-end;
}
.gap-sm { gap: 8px; }
.gap-md { gap: 16px; }
.flex-wrap { flex-wrap: wrap; }
.align-center { align-items: center; }

.btn-icon-left {
    justify-content: flex-start;
    gap: 10px;
}

.expenses-list-small {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.expense-item-sm {
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 14px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: #fafafa;
}

.expense-item-sm-info {
    display: flex;
    flex-direction: column;
}

.expense-item-sm-title {
    font-weight: 600;
}

.expense-item-sm-meta {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.expense-item-sm-monto {
    font-weight: 700;
    color: var(--danger);
}

/* ==========================================
   ALERTAS Y CONFIGURACIONES
   ========================================== */
.grid-maint-configs {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
}

.maint-config-card {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.maint-config-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

.maint-config-title {
    font-size: 1rem;
    font-weight: 700;
}

.maint-config-body {
    font-size: 0.85rem;
    color: var(--text-muted);
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.maint-config-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    border-top: 1px solid var(--border-color);
    padding-top: 12px;
}

/* Timeline Historial Inquilinos */
.history-timeline {
    position: relative;
    padding-left: 24px;
    margin-top: 10px;
}

.history-timeline::before {
    content: '';
    position: absolute;
    left: 7px;
    top: 8px;
    width: 2px;
    height: calc(100% - 16px);
    background-color: var(--border-color);
}

.timeline-item {
    position: relative;
    margin-bottom: 24px;
}

.timeline-item::before {
    content: '';
    position: absolute;
    left: -22px;
    top: 5px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background-color: var(--text-muted);
    border: 2px solid white;
}

.timeline-item.active-tenant::before {
    background-color: var(--success);
}

.timeline-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.timeline-name {
    font-weight: 700;
    font-size: 0.95rem;
}

.timeline-dates {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.timeline-details {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-top: 4px;
}

/* ==========================================
   MODALES (DISEÑO GENERAL)
   ========================================== */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(15, 23, 42, 0.4);
    backdrop-filter: blur(4px);
    z-index: 1100;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 1;
    transition: opacity var(--transition-normal);
}

.modal-overlay.hidden, .department-detail-overlay.hidden, .hidden {
    display: none !important;
}

.modal-card {
    background-color: white;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-premium);
    width: 100%;
    max-width: 600px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: zoomIn var(--transition-normal) forwards;
    margin: 20px;
}

.modal-sm {
    max-width: 450px;
}

.modal-lg {
    max-width: 800px;
}

@keyframes zoomIn {
    from { transform: scale(0.95); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

.modal-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    font-size: 1.2rem;
}

.modal-close {
    font-size: 1.8rem;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-muted);
    line-height: 1;
}

.modal-close:hover {
    color: var(--text-main);
}

.modal-body {
    padding: 24px;
    overflow-y: auto;
    max-height: 70vh;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.modal-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    background-color: #f8fafc;
}

/* Campos de Formulario */
.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.form-group label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-main);
}

.grid-2-col {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.grid-3-col {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
}

.form-group span {
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* File Uploaders (Fotos en Gastos) */
.file-uploader-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
}

.photo-input-card {
    border: 2px dashed var(--border-color);
    border-radius: var(--radius-md);
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    background-color: #fafafa;
    overflow: hidden;
    cursor: pointer;
    transition: var(--transition-fast);
}

.photo-input-card:hover {
    border-color: var(--primary);
    background-color: var(--primary-light);
}

.photo-upload-label {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    cursor: pointer;
    padding: 10px;
    text-align: center;
}

.photo-upload-label i {
    width: 28px;
    height: 28px;
    color: var(--text-muted);
}

.photo-upload-label span {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
}

.hidden-file-input {
    display: none;
}

.btn-remove-photo {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background-color: rgba(239, 68, 68, 0.9);
    color: white;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    font-weight: bold;
    z-index: 10;
}

.btn-remove-photo:hover {
    background-color: #dc2626;
}

.photo-preview-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    position: absolute;
    top: 0;
    left: 0;
}

.single-photo {
    aspect-ratio: 16/9;
}

/* Visor de Fotos Grande */
.photo-viewer-card {
    background: transparent;
    box-shadow: none;
    border: none;
    position: relative;
}

.viewer-close {
    color: white;
    position: absolute;
    top: -40px;
    right: 0;
    font-size: 2.5rem;
}

.photo-viewer-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    max-height: 85vh;
}

.photo-viewer-content img {
    max-width: 100%;
    max-height: 75vh;
    border-radius: var(--radius-md);
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
    object-fit: contain;
}

.viewer-caption {
    color: white;
    margin-top: 16px;
    font-size: 1.1rem;
    font-weight: 500;
    text-align: center;
}

/* ==========================================
   CHARTS Y RENTABILIDAD
   ========================================== */
.charts-row {
    display: grid;
    grid-template-columns: 2fr 1.2fr;
    gap: 24px;
}

.chart-body {
    height: 320px;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

.mt-lg { margin-top: 24px; }
.mt-md { margin-top: 16px; }
.mt-sm { margin-top: 8px; }

/* ==========================================
   RESPONSIVIDAD Y MEDIA QUERIES
   ========================================== */

@media (max-width: 1024px) {
    .dashboard-grid {
        grid-template-columns: 1fr;
    }
    .col-2 {
        grid-column: span 1;
    }
    .charts-row {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    /* Ocultar barra lateral en móvil */
    .sidebar {
        transform: translateX(-100%);
        width: 240px;
    }
    
    .sidebar.open {
        transform: translateX(0);
    }
    
    .main-content {
        margin-left: 0;
        padding: 16px;
        padding-bottom: 90px; /* Espacio para barra inferior */
    }
    
    .menu-toggle {
        display: block;
    }
    
    /* Adaptar tarjetas comunes en móvil */
    .card {
        padding: 16px;
    }
    
    .complex-map-card {
        padding: 12px;
    }
    
    /* Botones de acción del Dashboard */
    .quick-actions-grid {
        grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
        gap: 8px;
    }
    
    .btn-action {
        padding: 12px;
        font-size: 0.85rem;
    }
    
    .btn-action i {
        width: 20px;
        height: 20px;
    }
    
    /* Barra de navegación inferior móvil */
    .mobile-nav {
        display: flex;
        position: fixed;
        bottom: 0;
        left: 0;
        width: 100%;
        height: 64px;
        background-color: var(--bg-sidebar);
        border-top: 1px solid rgba(255,255,255,0.08);
        z-index: 1000;
        justify-content: space-around;
        align-items: center;
        box-shadow: 0 -4px 10px rgba(0,0,0,0.1);
    }
    
    .mobile-nav-item {
        display: flex;
        flex-direction: column;
        align-items: center;
        color: #94a3b8;
        font-size: 0.7rem;
        font-weight: 500;
        gap: 4px;
        flex: 1;
        padding: 8px 0;
    }
    
    .mobile-nav-item i {
        width: 20px;
        height: 20px;
    }
    
    .mobile-nav-item.active {
        color: white;
    }
    
    .mobile-nav-item.active i {
        color: var(--primary);
    }

    /* Grillas y Formularios */
    .grid-2-col, .grid-3-col {
        grid-template-columns: 1fr;
        gap: 12px;
    }
    
    .inquilino-detail-grid {
        grid-template-columns: 1fr;
        padding: 14px;
        gap: 10px;
    }
    
    .inquilino-detail-grid .col-2 {
        grid-column: span 1;
    }
    
    /* Evitar desborde horizontal de modales */
    .modal-card {
        width: calc(100% - 32px);
        margin: 16px;
        max-height: 90vh;
    }
    
    .modal-body {
        padding: 16px;
    }
    
    .modal-footer {
        padding: 12px 16px;
    }
    
    .file-uploader-grid {
        grid-template-columns: repeat(auto-fit, minmax(80px, 1fr));
        gap: 8px;
    }
    
    /* Apilar filtros en lugar de desbordar horizontalmente */
    .view-header-row {
        flex-direction: column;
        align-items: stretch;
        gap: 16px;
    }
    
    .filter-controls {
        flex-direction: column;
        gap: 10px;
        width: 100%;
    }
    
    .form-group-filter {
        width: 100%;
        min-width: 100%;
    }
    
    .view-actions-bar {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
    }

    /* Ajuste de mapa interactivo en móvil */
    .map-grid-pb {
        grid-template-columns: 1fr;
        grid-template-rows: auto;
        gap: 8px;
    }
    
    .map-grid-pb .map-cell[style*="grid-column"] {
        grid-column: span 1 !important;
    }
    
    .map-grid-pa {
        grid-template-columns: 1fr;
        gap: 8px;
    }
    
    .map-grid-pa .map-cell[style*="grid-column"] {
        grid-column: span 1 !important;
    }
    
    .map-grid-terraza {
        grid-template-columns: 1fr;
        gap: 8px;
    }
    
    .map-cell {
        padding: 12px 16px;
        min-height: 80px;
    }
    
    .map-cell-name {
        font-size: 0.95rem;
    }
    
    .map-cell-info {
        font-size: 0.75rem;
    }
    
    /* Grilla de departamentos */
    .grid-departments {
        grid-template-columns: 1fr;
        gap: 16px;
    }

    /* Ficha detalle */
    .detail-card {
        max-width: 100%;
        padding: 16px;
    }
    
    .detail-header {
        margin-bottom: 16px;
    }
    
    .detail-header h2 {
        font-size: 1.4rem;
    }
    
    .detail-tabs {
        margin-bottom: 16px;
    }
    
    .detail-tab-btn {
        padding: 8px 12px;
        font-size: 0.85rem;
    }
    
    /* Gráficos responsivos */
    .chart-body {
        height: 250px;
    }
}

/* ==========================================
   ESTILOS DE IMPRESIÓN (PARA EXPORTACIÓN PDF)
   ========================================== */
@media print {
    body {
        background-color: white;
        color: black;
        font-size: 10pt;
    }
    
    /* Ocultar UI de navegación e interactiva */
    .sidebar, .mobile-nav, .mobile-nav-item, .main-header, 
    .view-actions-bar, .modal-overlay, .btn, .actions-cell,
    .btn-action, .quick-actions-grid, .menu-toggle {
        display: none !important;
    }
    
    .main-content {
        margin-left: 0 !important;
        padding: 0 !important;
        background-color: white !important;
    }

    .app-view {
        display: none !important;
    }

    #print-report-container {
        display: block !important;
    }

    /* Estilo del reporte */
    .print-report-header {
        text-align: center;
        margin-bottom: 30px;
        border-bottom: 2px solid #000;
        padding-bottom: 15px;
    }

    .print-report-header h2 {
        font-size: 20pt;
    }

    .print-section {
        margin-bottom: 25px;
        page-break-inside: avoid;
    }

    .print-section h3 {
        font-size: 14pt;
        border-bottom: 1px solid #ccc;
        padding-bottom: 6px;
        margin-bottom: 12px;
    }

    .print-table {
        width: 100%;
        border-collapse: collapse;
        margin-bottom: 15px;
    }

    .print-table th, .print-table td {
        border: 1px solid #ddd;
        padding: 8px;
        text-align: left;
    }

    .print-table th {
        background-color: #f2f2f2;
        font-weight: bold;
    }

    .print-net-positive {
        color: #047857 !important;
        font-weight: bold;
    }

    .print-net-negative {
        color: #b91c1c !important;
        font-weight: bold;
    }
}

.print-only {
    display: none;
}

/* ==========================================
   PANTALLA DE PIN — COMPATIBILIDAD
   ========================================== */
#pin-lock-screen {
    font-family: 'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

/* Asegurar que el app-container no sea visible hasta que se quite el PIN */
#pin-lock-screen + .app-container {
    /* El PIN overlay tiene z-index: 9999, así que la app queda tapada */
    visibility: visible;
}

/* Botones del sidebar footer (backup + cambiar PIN) */
.sidebar-footer .btn {
    width: 100%;
    justify-content: flex-start;
    gap: 10px;
    font-size: 0.85rem;
    padding: 10px 14px;
    border-radius: var(--radius-md);
    background-color: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.08);
    color: #94a3b8;
}

.sidebar-footer .btn:hover {
    background-color: rgba(255,255,255,0.1);
    color: white;
}
