/* =========================================
   1. VARIABLES Y BASE
   ========================================= */
:root {
    --bg-color: #ecf0f1;
    --text-color: #2c3e50;
    --primary-color: #34495e;
    --accent-color: #16a085;
    --danger-color: #c0392b;
    --white: #ffffff;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    margin: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    min-height: 100vh;
}

/* =========================================
   2. HEADER GLOBAL
   ========================================= */
header {
    background-color: var(--primary-color);
    color: var(--white);
    width: 100%;
    padding: 20px 0;
    text-align: center;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

h1 { margin: 0; font-weight: 300; letter-spacing: 2px; }

/* =========================================
   3. LOGIN Y MENÚ (index.html)
   ========================================= */
.main-container {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 40px;
    padding: 50px;
    max-width: 1200px;
    width: 100%;
    box-sizing: border-box;
}

.login-card {
    background: var(--white);
    padding: 40px;
    border-radius: 10px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
    width: 300px;
    text-align: center;
    max-width: 100%;
}

.login-card input {
    width: 100%;
    padding: 12px;
    margin: 10px 0;
    border: 1px solid #ddd;
    border-radius: 5px;
    box-sizing: border-box;
}

.btn-login {
    width: 100%;
    padding: 12px;
    background-color: var(--accent-color);
    color: var(--white);
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 16px;
    transition: background 0.3s;
}
.btn-login:hover { background-color: #1abc9c; }

/* IP y Errores */
.server-ip {
    color: var(--danger-color);
    font-weight: bold;
    font-family: monospace;
    font-size: 1.1em;
    margin: 5px 0 15px 0;
}
.error-message { color: red; font-size: 0.9em; margin-top: 10px; display: none; }
.text-accent { color: var(--accent-color); }
.hidden { display: none; }
.mb-5 { margin-bottom: 5px; }

/* Menú Principal */
.menu-grid {
    display: none;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
    opacity: 0;
    transition: opacity 0.5s ease;
    width: 100%;
}
.menu-item {
    background: var(--white);
    padding: 30px;
    border-radius: 10px;
    text-align: center;
    text-decoration: none;
    color: var(--primary-color);
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
    border-left: 5px solid var(--accent-color);
    font-weight: bold;
}
.menu-item:hover { transform: translateY(-5px); }
.menu-active { display: grid; opacity: 1; animation: fadeIn 0.5s ease-in-out; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

/* =========================================
   4. ESTILOS COMUNES (Botones Nav, Contenedores)
   ========================================= */
.admin-container, .dashboard-container {
    max-width: 1100px;
    width: 95%; /* Ocupa casi todo el ancho en móvil */
    margin: 20px auto;
    background: var(--white);
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    box-sizing: border-box;
}

/* Navegación Interna (Header de sección) */
.header-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 25px;
    flex-wrap: wrap; /* Permite que bajen los elementos si no caben */
    gap: 15px;
}

.header-nav h2 { margin: 0; font-size: 1.5em; color: var(--primary-color); }

/* Botones de Navegación (Estilo Unificado) */
.nav-buttons-group {
    display: flex;
    gap: 10px;
}

.btn-menu {
    text-decoration: none;
    background: var(--primary-color);
    color: white;
    padding: 10px 15px;
    border-radius: 4px;
    font-weight: bold;
    border: none;
    cursor: pointer;
    font-size: 0.95em;
    display: inline-block;
}

.btn-logout {
    cursor: pointer;
    background: var(--danger-color);
    color: white;
    padding: 10px 15px;
    border-radius: 4px;
    border: none;
    font-weight: bold;
    font-size: 0.95em;
    text-decoration: none;
    display: inline-block;
}

/* =========================================
   5. FORMULARIOS (Clientes/Staff)
   ========================================= */
.form-grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 15px; margin-bottom: 20px; }
.form-grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 15px; margin-bottom: 20px; }

/* Inputs generales */
input, select {
    width: 100%;
    padding: 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    box-sizing: border-box; /* Clave para que el padding no rompa el diseño */
    background-color: #f9f9f9;
}
input:focus, select:focus {
    outline: none;
    border-color: var(--accent-color);
    background-color: #fff;
}

.form-full-width { grid-column: span 2; }

.btn-action {
    background: var(--accent-color);
    color: var(--white);
    border: none;
    padding: 14px; /* Un poco más grande para tocar */
    cursor: pointer;
    border-radius: 4px;
    width: 100%;
    font-weight: bold;
    font-size: 1em;
    margin-top: 10px;
}
.btn-action:hover { background-color: #1abc9c; }

/* Tablas */
.table-responsive { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; margin-top: 20px; font-size: 0.9em; min-width: 600px; }
th, td { padding: 12px; text-align: left; border-bottom: 1px solid #ddd; }
th { background-color: var(--primary-color); color: var(--white); }

/* =========================================
   6. CCTV & SENSORES (Estilos específicos)
   ========================================= */
.kpi-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-bottom: 20px; }
.kpi-card { background: var(--white); padding: 20px; border-radius: 8px; text-align: center; box-shadow: 0 2px 5px rgba(0,0,0,0.1); }
.kpi-value { font-size: 2.5em; font-weight: bold; color: var(--primary-color); margin: 10px 0; }
.kpi-label { color: #7f8c8d; font-size: 1.1em; text-transform: uppercase; letter-spacing: 1px; }

.status-box { width: 100%; padding: 20px; border-radius: 8px; text-align: center; margin-bottom: 40px; color: white; font-weight: bold; font-size: 1.5em; box-sizing: border-box; }
.estado-ok { background-color: #27ae60; }
.estado-alerta { background-color: #c0392b; }
.estado-neutro { background-color: #95a5a6; }

.charts-section { background: var(--white); padding: 20px; border-radius: 8px; box-shadow: 0 2px 5px rgba(0,0,0,0.1); }
.chart-wrapper { margin-bottom: 40px; }
.chart-title { border-bottom: 2px solid var(--bg-color); padding-bottom: 10px; color: var(--primary-color); margin-top: 0; }

.cctv-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 15px; margin-bottom: 30px; }
.cam-box { background-color: #000; border: 2px solid #34495e; border-radius: 4px; position: relative; overflow: hidden; display: flex; justify-content: center; align-items: center; color: #555; width: 100%; aspect-ratio: 16 / 9; }
.cam-feed { width: 100%; height: 100%; object-fit: fill; }
.cam-overlay { position: absolute; top: 5%; left: 3%; background: rgba(0, 0, 0, 0.7); color: #0f0; padding: 5px 10px; font-size: clamp(10px, 1vw, 14px); font-family: monospace; border-radius: 3px; z-index: 2; }
.no-signal-text { display: flex; flex-direction: column; align-items: center; font-family: monospace; text-align: center; color: white; }
.rec-dot { color: red; animation: parpadeo 1s infinite; }
@keyframes parpadeo { 0% { opacity: 1; } 50% { opacity: 0; } 100% { opacity: 1; } }
.container-fluid { width: 98%; max-width: none; margin: 20px auto; padding: 0 10px; box-sizing: border-box;}
body.dark-mode { background-color: #1a1a1a; color: #ecf0f1; }

/* =========================================
   7. RESPONSIVE / MEDIA QUERIES (MÓVILES)
   ========================================= */
@media (max-width: 768px) {
    /* Ajustes generales */
    .main-container { padding: 20px; }
    .login-card { width: 100%; }
    
    /* Layouts en 1 Columna */
    .menu-grid, .cctv-grid, .kpi-grid, .form-grid-3, .form-grid-2 {
        grid-template-columns: 1fr;
    }

    /* HEADER NAV (Botones arriba/abajo) */
    .header-nav {
        flex-direction: column;
        align-items: stretch; /* Estira los elementos al ancho total */
        text-align: center;
    }
    
    .header-nav h2 {
        margin-bottom: 10px;
    }

    /* Grupo de botones en móvil */
    .nav-buttons-group {
        flex-direction: column; /* Un botón debajo del otro */
        width: 100%;
    }

    .btn-menu, .btn-logout {
        width: 100%; /* Botón ocupa todo el ancho */
        text-align: center;
        padding: 12px;
        box-sizing: border-box;
    }

    /* Formularios */
    .form-full-width { grid-column: span 1 !important; }
    
    input, select {
        padding: 14px; /* Más espacio para dedos */
        font-size: 16px; /* Evita zoom automático en iPhone */
    }
}

:root {
    /* ... tus variables anteriores ... */
    
    /* AGREGA ESTAS NUEVAS VARIABLES: */
    --staff-blue: #34495e;   /* Azul oscuro corporativo */
    --primary-teal: #1abc9c; /* Verde agua vibrante */
    --dark-teal: #16a085;    /* Verde agua oscuro */
    --text-light: #7f8c8d;   /* Gris para textos secundarios */
}

/* =========================================
   8. ESTILOS LANDING PAGE (index.html)
   ========================================= */

/* Contenedor Principal de Tarjetas */
.cards-container {
    display: flex;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
    gap: 30px;
    padding: 50px 20px;
    max-width: 1000px;
    margin: 0 auto;
}

/* Estilo Base de las Tarjetas */
.card {
    background: var(--white);
    border-radius: 15px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.1);
    padding: 40px;
    width: 300px;
    text-align: center;
    position: relative;
    overflow: hidden;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.card:hover {
    transform: translateY(-5px);
    box-shadow: 0 15px 35px rgba(0,0,0,0.15);
}

/* Franja decorativa superior (pseudo-elemento) */
.card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 8px; /* Grosor de la línea de color arriba */
}

/* --- Estilos Específicos Staff --- */
.card-staff::before { background-color: var(--staff-blue); }

.card-staff h2 { 
    color: var(--staff-blue); 
    font-size: 1.4rem;
    margin-bottom: 15px;
    font-weight: 700;
}

/* --- Estilos Específicos Users --- */
.card-users::before { background-color: var(--primary-teal); }

.card-users h2 { 
    color: var(--primary-teal);
    font-size: 1.4rem;
    margin-bottom: 15px;
    font-weight: 700;
}

/* --- Descripciones y Botones --- */
.card-desc {
    color: var(--text-light);
    font-size: 0.95rem;
    margin-bottom: 30px;
    line-height: 1.5;
    min-height: 45px; /* Para alinear botones si el texto varía */
}

.btn {
    display: inline-block;
    padding: 12px 30px;
    border-radius: 50px;
    text-decoration: none;
    font-weight: 600;
    transition: background 0.3s;
    font-size: 0.9rem;
}

.btn-staff {
    background-color: #ecf0f1;
    color: var(--staff-blue);
}
.btn-staff:hover { background-color: #bdc3c7; }

.btn-users {
    background-color: #e8f8f5; /* Fondo suave */
    color: var(--dark-teal);
}
.btn-users:hover { background-color: #d1f2eb; }

/* --- Footer Específico --- */
footer {
    text-align: center;
    padding: 20px;
    color: #95a5a6;
    font-size: 0.8rem;
    margin-top: auto; /* Empuja el footer abajo si hay poco contenido */
}

/* --- Botón Volver --- */
.btn-back {
    margin-top: 10px;       /* Espacio entre el botón Ingresar y Volver */
    background-color: #95a5a6; /* Color Gris para diferenciarlo */
}

.btn-back:hover {
    background-color: #7f8c8d; /* Gris más oscuro al pasar el mouse */
}


/* --- Estilos Información Usuario (indexuser.html) --- */
.user-info-box {
    margin-top: 25px;
    padding-top: 20px;
    border-top: 1px solid #eee;
    text-align: center;
}

.user-greeting {
    font-size: 1.1em;
    color: var(--primary-color);
    margin-bottom: 15px;
}

.sub-status-box {
    background-color: #f9f9f9;
    padding: 10px;
    border-radius: 8px;
    margin-bottom: 15px;
    font-size: 0.95em;
    color: #7f8c8d;
}

.status-badge {
    font-weight: bold;
    padding: 4px 8px;
    border-radius: 4px;
    text-transform: uppercase;
    font-size: 0.9em;
}

/* Clases dinámicas que usará JS */
.status-active {
    background-color: #e8f8f5;
    color: #16a085; /* Verde */
    border: 1px solid #16a085;
}

.status-inactive {
    background-color: #fdeaea;
    color: #c0392b; /* Rojo */
    border: 1px solid #c0392b;
}

.gym-location {
    font-size: 0.85em;
    color: #95a5a6;
    font-style: italic;
    margin-top: 10px;
}
