/* public/style.css */

/* === 0. Fuentes Modernas === */
@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700;800&display=swap');

/* === 1. Variables: "Vivid & Clean" === */
:root {
    /* Color Principal (Índigo Vibrante) */
    --primary: #6366f1;       
    --primary-dark: #4f46e5;  
    --primary-light: #eef2ff; 
    
    /* Base (Clara y Limpia) */
    --bg-body: #f8fafc;       /* Gris azulado muy pálido */
    --bg-surface: #ffffff;    /* Blanco puro */
    
    /* Textos */
    --text-main: #1e293b;     /* Gris oscuro casi negro */
    --text-muted: #64748b;    /* Gris medio */
    --border: #e2e8f0;        /* Bordes sutiles */

    /* Estados */
    --success: #10b981; --success-bg: #d1fae5;
    --danger: #ef4444;  --danger-bg: #fee2e2;
    --warning: #f59e0b; --warning-bg: #fef3c7;

    /* Dimensiones */
    --sidebar-width: 260px;
    --sidebar-width-collapsed: 80px;
    --header-height: 70px;
    
    /* UI */
    --radius: 16px;           
    --shadow: 0 10px 30px -10px rgba(0,0,0,0.06); 
    --transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1); 
}

/* === 2. Reset & Base (IMPORTANTE PARA SCROLL) === */
* { box-sizing: border-box; margin: 0; padding: 0; }

html { height: 100%; } /* Crucial para que el layout ocupe toda la pantalla */

body {
    font-family: 'Plus Jakarta Sans', sans-serif;
    background-color: var(--bg-body);
    color: var(--text-main);
    font-size: 0.95rem;
    height: 100%; 
    overflow: hidden; /* Ocultamos el scroll del body para usar el del main */
}

a { text-decoration: none; color: inherit; transition: var(--transition); }
ul { list-style: none; }
button { font-family: inherit; }

/* === 3. Layout Principal (Grid Dinámico) === */
#app-layout {
    display: grid;
    grid-template-columns: var(--sidebar-width) 1fr; 
    grid-template-rows: var(--header-height) 1fr; /* Header fijo, Main ocupa el resto */
    grid-template-areas: 
        "sidebar header"
        "sidebar main";
    height: 100%;
    width: 100%;
    transition: grid-template-columns 0.4s cubic-bezier(0.25, 0.8, 0.25, 1);
}

/* Estado Colapsado (Mini Sidebar) */
#app-layout.sidebar-collapsed {
    grid-template-columns: var(--sidebar-width-collapsed) 1fr;
}

/* === 4. Sidebar (Fijo/Sticky) === */
#app-sidebar {
    grid-area: sidebar;
    background: var(--bg-surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    padding: 1.5rem;
    z-index: 20;
    overflow: hidden;
    white-space: nowrap;
    transition: var(--transition);
    
    /* Lógica Sticky: Se mantiene fijo */
    height: 100%; 
}

.sidebar-header {
    display: flex; align-items: center; gap: 12px; height: 50px; margin-bottom: 2rem; padding-left: 5px;
}

.sidebar-logo-img { height: 35px; width: auto; object-fit: contain; }

.brand-text {
    font-size: 1.3rem; font-weight: 800; color: var(--text-main);
    opacity: 1; transition: opacity 0.2s ease;
}

/* Ocultar elementos al colapsar */
#app-layout.sidebar-collapsed .brand-text,
#app-layout.sidebar-collapsed .sidebar-nav span,
#app-layout.sidebar-collapsed #logout-text {
    opacity: 0; pointer-events: none; display: none;
}

/* Centrar iconos al colapsar */
#app-layout.sidebar-collapsed .sidebar-nav a,
#app-layout.sidebar-collapsed #logout-btn {
    justify-content: center; padding-left: 0; padding-right: 0;
}

/* Navegación */
.sidebar-nav { 
    flex: 1; display: flex; flex-direction: column; gap: 0.5rem; 
    overflow-y: auto; /* Scroll interno si el menú es muy largo */
}
.sidebar-nav::-webkit-scrollbar { width: 4px; }
.sidebar-nav::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

.sidebar-nav a {
    display: flex; align-items: center; gap: 14px; padding: 0.8rem 1rem;
    border-radius: 12px; color: var(--text-muted); font-weight: 600;
    transition: var(--transition); position: relative; flex-shrink: 0;
}

.sidebar-nav a:hover {
    background-color: var(--primary-light); color: var(--primary);
    transform: translateX(4px);
}
/* Sin movimiento en colapsado */
#app-layout.sidebar-collapsed .sidebar-nav a:hover { transform: none; }

.sidebar-nav a.active {
    background-color: var(--primary); color: white;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

.sidebar-nav svg { width: 22px; height: 22px; stroke-width: 2; flex-shrink: 0; }

/* Footer Sidebar */
.sidebar-footer { margin-top: auto; padding-top: 1rem; border-top: 1px solid var(--border); flex-shrink: 0; }

#logout-btn {
    width: 100%; display: flex; align-items: center; gap: 10px; padding: 0.8rem 1rem;
    background: transparent; border: 1px solid var(--border); border-radius: 12px;
    color: var(--text-muted); font-weight: 600; cursor: pointer; transition: var(--transition);
}
#logout-btn:hover {
    background: var(--danger-bg); color: var(--danger); border-color: var(--danger-bg);
}

/* === 5. Header (Sticky & Layout) === */
#app-header {
    grid-area: header;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
    padding: 0 2rem;
    display: flex; justify-content: space-between; align-items: center;
    z-index: 30; 
}

#sidebar-toggle {
    background: white; border: 1px solid var(--border); width: 42px; height: 42px;
    border-radius: 12px; cursor: pointer; display: flex; align-items: center; justify-content: center;
    color: var(--text-muted); transition: var(--transition); z-index: 2;
}
#sidebar-toggle:hover { border-color: var(--primary); color: var(--primary); }

/* Centro Absoluto para el Condominio */
.header-center {
    position: absolute; left: 50%; transform: translateX(-50%);
    display: flex; align-items: center; z-index: 1;
}

.condo-badge {
    background: var(--primary-light); padding: 0.5rem 1.5rem; border-radius: 50px;
    font-size: 0.9rem; font-weight: 700; color: var(--primary);
    border: 1px solid var(--primary-light); display: flex; align-items: center; gap: 8px;
    cursor: pointer; transition: var(--transition);
}
.condo-badge:hover {
    background: white; border-color: var(--primary);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.15); transform: translateY(-1px);
}

/* Perfil Usuario y Dropdown */
.header-right { display: flex; align-items: center; gap: 1rem; position: relative; z-index: 2; }

.user-profile-btn {
    background: transparent; border: none; cursor: pointer;
    display: flex; align-items: center; gap: 12px;
    padding: 4px; border-radius: 12px; transition: var(--transition);
}
.user-profile-btn:hover { background: var(--bg-body); }

.user-avatar {
    width: 42px; height: 42px; background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white; border-radius: 12px; display: flex; align-items: center; justify-content: center;
    font-weight: 800; font-size: 1.2rem; box-shadow: 0 4px 10px rgba(99,102,241,0.3);
}

/* Menú Desplegable */
.dropdown-menu {
    position: absolute; top: 100%; right: 0; margin-top: 10px;
    background: white; border: 1px solid var(--border); border-radius: 16px;
    box-shadow: 0 10px 40px -5px rgba(0,0,0,0.1); width: 200px;
    display: none; flex-direction: column; overflow: hidden;
    animation: slideDown 0.2s ease-out;
}
.dropdown-menu.show { display: flex; }
@keyframes slideDown { from { opacity:0; transform:translateY(-10px); } to { opacity:1; transform:translateY(0); } }

.dropdown-item {
    padding: 12px 20px; font-size: 0.9rem; font-weight: 500; color: var(--text-main);
    background: transparent; border: none; text-align: left; cursor: pointer;
    transition: background 0.2s; display: flex; align-items: center; gap: 10px; width: 100%;
}
.dropdown-item:hover { background: var(--bg-body); color: var(--primary); }
.dropdown-item.danger { color: var(--danger); }
.dropdown-item.danger:hover { background: var(--danger-bg); }

/* === 6. CONTENIDO PRINCIPAL (SCROLL FIX) === */
#app-main { 
    grid-area: main; 
    padding: 2rem; 
    
    /* ESTO HABILITA EL SCROLL */
    overflow-y: auto; 
    height: 100%; 
    min-height: 0;
    
    scroll-behavior: smooth; 
}

h1, h2, h3, h4 { color: var(--text-main); margin-bottom: 1rem; font-weight: 700; letter-spacing: -0.02em; }

/* === 7. Componentes UI === */

/* Cards */
.card {
    background: var(--bg-surface); border-radius: var(--radius); padding: 2rem;
    box-shadow: var(--shadow); border: 1px solid var(--border);
    transition: var(--transition); margin-bottom: 1.5rem;
}
.card:hover { transform: translateY(-5px); box-shadow: 0 20px 40px -10px rgba(0,0,0,0.1); }

/* Botones */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    padding: 0.75rem 1.5rem; border-radius: 50px; font-weight: 600; font-size: 0.9rem;
    border: none; cursor: pointer; transition: var(--transition);
}
.btn:active { transform: scale(0.96); }
.btn-primary { background: linear-gradient(135deg, var(--primary), var(--primary-dark)); color: white; box-shadow: 0 4px 15px rgba(99, 102, 241, 0.4); }
.btn-primary:hover { filter: brightness(1.1); box-shadow: 0 6px 20px rgba(99, 102, 241, 0.5); }
.btn-secondary { background: white; color: var(--text-main); border: 1px solid var(--border); }
.btn-secondary:hover { border-color: var(--text-muted); background: var(--bg-body); }
.btn-danger { background: var(--danger-bg); color: var(--danger); }
.btn-danger:hover { background: #fecaca; }
.btn-sm { padding: 0.4rem 0.8rem; font-size: 0.8rem; }

/* Formularios */
.form-group { margin-bottom: 1.2rem; }
label { display: block; margin-bottom: 0.5rem; font-weight: 500; color: var(--text-main); font-size: 0.9rem; }
input, select, textarea {
    width: 100%; padding: 0.8rem 1rem; border: 1px solid var(--border); border-radius: 12px;
    background: var(--bg-body); font-family: inherit; font-size: 0.95rem; color: var(--text-main);
    transition: var(--transition);
}
input:focus, select:focus, textarea:focus { outline: none; background: white; border-color: var(--primary); box-shadow: 0 0 0 4px var(--primary-light); }

/* Tablas */
.data-table { width: 100%; border-collapse: separate; border-spacing: 0; }
.data-table th { text-align: left; padding: 1rem; color: var(--text-muted); font-size: 0.75rem; text-transform: uppercase; font-weight: 700; letter-spacing: 1px; border-bottom: 1px solid var(--border); }
.data-table td { padding: 1rem; border-bottom: 1px solid var(--bg-body); font-weight: 500; color: var(--text-main); }
.data-table tr:hover td { background: var(--primary-light); cursor: default; }
.data-table tr:last-child td { border-bottom: none; }

/* Modales */
.modal-backdrop {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.4); backdrop-filter: blur(4px);
    display: flex; justify-content: center; align-items: center;
    z-index: 1000; animation: fadeIn 0.2s ease-out;
}
.modal-content {
    background: white; padding: 2.5rem; border-radius: 20px;
    width: 90%; max-width: 500px; box-shadow: 0 20px 50px rgba(0,0,0,0.2);
    transform: scale(0.95); animation: zoomIn 0.2s ease-out forwards;
}
.modal-content.large-modal { max-width: 900px; }

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

/* === 8. CARRUSEL SELECTOR (3D) === */
.condo-selector-page {
    width: 100%; height: 100vh; display: flex; flex-direction: column;
    align-items: center; justify-content: center; background: var(--bg-body);
    overflow: hidden; text-align: center;
}

.carousel-wrapper {
    position: relative; width: 100%; height: 400px;
    perspective: 1000px; cursor: grab; user-select: none; margin: 2rem 0;
}
.carousel-wrapper.is-dragging { cursor: grabbing; }

.carousel-track {
    position: absolute; top: 0; left: 0; height: 100%;
    display: flex; align-items: center; transform-style: preserve-3d;
    transition: transform 0.5s cubic-bezier(0.25, 0.8, 0.25, 1);
}

.carousel-item {
    width: 320px; height: 240px; flex-shrink: 0; padding: 2rem; margin: 0 1rem;
    border-radius: 24px; background: var(--bg-surface);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.15); border: 1px solid var(--border);
    transition: transform 0.5s ease, opacity 0.5s ease, border-color 0.3s;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    transform-origin: center center; cursor: pointer;
}

.carousel-item.active-slide { border-color: var(--primary); box-shadow: 0 30px 60px -15px rgba(99, 102, 241, 0.3); }

.condo-card-icon { width: 80px; height: 80px; margin-bottom: 1.5rem; display: flex; align-items: center; justify-content: center; }
.condo-card-icon img { width: 100%; height: 100%; object-fit: contain; }

.carousel-item h3 { font-size: 1.4rem; color: var(--text-main); margin-bottom: 0.5rem; }
.carousel-item p { color: var(--text-muted); font-size: 0.9rem; }

.carousel-item.add-new { border: 2px dashed var(--border); background: transparent; box-shadow: none; }
.carousel-item.add-new:hover { border-color: var(--primary); color: var(--primary); }
.carousel-item.add-new .condo-card-icon { font-size: 3rem; color: var(--text-muted); background: none; }

.carousel-nav-btn {
    position: absolute; top: 50%; transform: translateY(-50%); z-index: 10;
    background: white; border: 1px solid var(--border); color: var(--text-main);
    width: 48px; height: 48px; border-radius: 50%; font-size: 1.5rem;
    cursor: pointer; box-shadow: var(--shadow); transition: var(--transition);
    display: flex; align-items: center; justify-content: center;
}
.carousel-nav-btn:hover { background: var(--primary); color: white; border-color: var(--primary); }
.carousel-nav-btn.prev { left: 10%; }
.carousel-nav-btn.next { right: 10%; }

.carousel-indicators { display: flex; gap: 0.8rem; margin-top: 1rem; z-index: 5; }
.carousel-indicator-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--border); border: none; cursor: pointer; transition: all 0.3s; }
.carousel-indicator-dot.active { background: var(--primary); transform: scale(1.3); }

/* === 9. Responsivo Mobile === */
@media (max-width: 768px) {
    #app-layout { grid-template-columns: 1fr; grid-template-areas: "header" "main"; }
    
    #app-sidebar { 
        position: fixed; left: 0; top: 0; height: 100%; width: 80%; 
        max-width: 300px; box-shadow: 10px 0 30px rgba(0,0,0,0.15); 
        transform: translateX(-100%); background: white; z-index: 100;
    }
    #app-sidebar.mobile-open { transform: translateX(0); }
    
    #app-header { padding: 0 1rem; }
    .header-center { position: static; transform: none; }
    .condo-badge span { display: none; } /* Oculta nombre en móvil, solo icono */
    .user-profile-info { display: none; } /* Solo avatar en móvil */
    
    .carousel-wrapper { height: 300px; }
    .carousel-item { width: 260px; height: 200px; }
}
