/* --- 1. VARIABLES Y BASE --- */
:root { 
    --header-bg: #2c3e50; 
    --border-color: #dee2e6; 
    --primary-blue: #007bff;
    --bg-light: #f4f7f6;
}

* { box-sizing: border-box; }

body { 
    background-color: var(--bg-light); 
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; 
    margin: 0; 
    overflow-x: hidden; 
}

/* --- 2. ESTRUCTURA COMÚN --- */
.app-wrapper {
    max-width: 1200px;
    margin: 0 auto;
    background-color: #fff;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 0 30px rgba(0,0,0,0.1);
}

/* Ajustes específicos de ancho por página */
.page-perfil .app-wrapper { max-width: 600px; margin: 20px auto; border-radius: 15px; overflow: hidden; }
.page-login .app-wrapper, .page-registro .app-wrapper { max-width: 450px; min-height: auto; background: transparent; box-shadow: none; }

/* --- 3. CABECERA PREMIUM (INDEX / PERFIL) --- */
.main-header {
    background: var(--header-bg);
    color: white;
    padding: 12px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.brand-area { display: flex; align-items: center; gap: 12px; }
.brand-logo { 
    width: 38px; height: 38px; 
    background: #3498db; border-radius: 10px; 
    display: flex; align-items: center; justify-content: center;
    font-size: 1.3rem; box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.user-info { text-align: right; line-height: 1.2; }
.user-name { font-size: 0.9rem; font-weight: bold; display: block; color: #fff; text-decoration: none; }
.user-vivienda { font-size: 0.75rem; color: #bdc3c7; }

.header-actions { display: flex; gap: 10px; align-items: center; margin-left: 15px; }
.btn-header { 
    padding: 6px 12px; font-size: 0.8rem; border-radius: 8px; 
    text-decoration: none; transition: all 0.2s; border: none;
}
.btn-admin { background: #f39c12; color: white; }
.btn-admin:hover { background: #e67e22; transform: translateY(-1px); }
.btn-logout { background: #e74c3c; color: white; }
.btn-logout:hover { background: #c0392b; }

/* --- 4. SELECTOR DE SEMANA Y FECHA --- */
.nav-header { 
    display: flex; justify-content: space-between; align-items: center; 
    padding: 12px; background: #f8f9fa; border-bottom: 1px solid var(--border-color);
    margin: 10px; border-radius: 10px; border: 1px solid #eee;
}

#fecha_selector_wrapper { padding: 5px 10px; border-radius: 5px; transition: background 0.2s; cursor: pointer; }
#fecha_selector_wrapper:hover { background: rgba(0,0,0,0.05); }
#datepicker_input::-webkit-calendar-picker-indicator { cursor: pointer; }

/* --- 5. GRID DEL CALENDARIO --- */
.week-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    background-color: var(--border-color);
    gap: 1px;
    width: 100%;
    flex: 1;
}

.day-column {
    background-color: #fff;
    display: grid;
    grid-template-rows: 45px repeat(26, minmax(24px, auto));
    align-content: start;
}

.day-header {
    grid-row: 1;
    background: var(--header-bg);
    color: white;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    font-size: 0.65rem;
    font-weight: bold;
    text-transform: uppercase;
}

/* --- 6. SLOTS Y ESTADOS --- */
.slot-item {
    margin: 1px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    border-radius: 3px;
    cursor: pointer;
    font-size: 0.58rem;
    padding: 4px 0;
    transition: all 0.2s ease;
}

.slot-item.libre { background-color: #e2f9e1; color: #1e4620; }
.slot-item.ocupado { background-color: #f8d7da; color: #721c24; cursor: not-allowed; }
.slot-item.slot-mio { background-color: var(--primary-blue); color: white; font-weight: bold; }

.time-label { font-weight: bold; letter-spacing: -0.3px; }
.vivienda-label {
    background: rgba(0, 0, 0, 0.08);
    border-radius: 3px;
    padding: 0 4px;
    margin-top: 2px;
    font-size: 0.65rem;
}
.slot-mio .vivienda-label { background: rgba(255, 255, 255, 0.2); }

.slot-item.libre:hover, .slot-item.slot-mio:hover {
    filter: brightness(0.9);
    transform: scale(1.02);
    box-shadow: 0 4px 10px rgba(0,0,0,0.1);
    z-index: 2;
}

/* Bloqueos */
.slot-item.bloqueado {
    writing-mode: vertical-rl;
    text-orientation: mixed;
    font-weight: bold;
    font-size: 0.75rem;
    cursor: default !important;
}
.slot-item.bloqueado[data-tipo="mantenimiento"] {
    background: repeating-linear-gradient(45deg, #fff3cd, #fff3cd 10px, #ffeeba 10px, #ffeeba 20px) !important;
    color: #856404;
}
.slot-item.bloqueado[data-tipo="festivo"] {
    background-color: #f8f9fa !important;
    color: #6c757d;
    border: 1px dashed #ccc !important;
}

/* --- 7. LEYENDA Y FOOTER --- */
.legend { display: flex; gap: 15px; padding: 15px; font-size: 0.7rem; justify-content: center; background: #fff; }
.dot { width: 12px; height: 12px; border-radius: 3px; display: inline-block; margin-right: 5px; vertical-align: middle; }

.main-footer {
    background: #f8f9fa;
    border-top: 1px solid #eee;
    padding: 25px;
    text-align: center;
    color: #7f8c8d;
    font-size: 0.8rem;
    margin-top: auto;
}

/* --- 8. ESTILOS ESPECÍFICOS: PERFIL / LOGIN / REGISTRO --- */
/* Login y Registro */
.page-login, .page-registro {
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
}
.page-login .card, .page-registro .card { border: none; border-radius: 15px; overflow: hidden; width: 100%; box-shadow: 0 10px 25px rgba(0,0,0,0.1); background: white; }
.page-login .card-header, .page-registro .card-header { background: var(--header-bg); color: white; text-align: center; padding: 1.5rem; }

/* Perfil */
.page-perfil .profile-header { background: var(--header-bg); color: white; padding: 30px; text-align: center; }
.page-perfil .nav-pills .nav-link.active { background-color: var(--header-bg); }
.page-perfil .reserva-card { border-left: 5px solid #3498db; margin-bottom: 10px; }
.page-perfil .historial-card { border-left: 5px solid #bdc3c7; opacity: 0.8; }

/* --- 9. RESPONSIVE --- */
@media (max-width: 768px) {
    .app-wrapper { max-width: 100% !important; box-shadow: none; margin: 0; }
    .day-header { font-size: 0.55rem; }
    .slot-item { font-size: 0.5rem; }
    .legend { flex-wrap: wrap; }
}