/* ==========================================================================
   Variables y Configuración Base
   ========================================================================== */
   :root {
    /* Paleta de Colores - Dark Mode Premium */
    --bg-base: #0B0F19;
    --bg-surface: rgba(20, 26, 40, 0.6);
    --text-primary: #F3F4F6;
    --text-secondary: #9CA3AF;
    
    /* Acentos */
    --accent-teal: #007D82;
    --accent-teal-light: #00A6AC;
    --accent-blue: #3b82f6;
    --accent-purple: #8b5cf6;
    --accent-amber: #f59e0b;
    
    /* Estados */
    --status-online: #10B981;
    --status-offline: #EF4444;
    
    /* Efectos de Cristal (Glassmorphism) */
    --glass-border: rgba(255, 255, 255, 0.08);
    --glass-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
    --glass-highlight: inset 0 1px 0 rgba(255, 255, 255, 0.1);
    
    /* Tipografía */
    --font-heading: 'Outfit', sans-serif;
    --font-body: 'Inter', sans-serif;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font-body);
    background-color: var(--bg-base);
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow-x: hidden;
    position: relative;
}

/* ==========================================================================
   Fondos Animados (Blobs)
   ========================================================================== */
.bg-animated {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: -1;
    overflow: hidden;
    background: radial-gradient(circle at center, #111827 0%, #030712 100%);
}

.blob {
    position: absolute;
    filter: blur(80px);
    opacity: 0.5;
    border-radius: 50%;
    animation: float 20s infinite alternate ease-in-out;
}

.blob-1 {
    top: -10%;
    left: -10%;
    width: 500px;
    height: 500px;
    background: var(--accent-teal);
    animation-delay: 0s;
}

.blob-2 {
    bottom: -20%;
    right: -10%;
    width: 600px;
    height: 600px;
    background: var(--accent-blue);
    animation-delay: -5s;
}

.blob-3 {
    top: 40%;
    left: 40%;
    width: 400px;
    height: 400px;
    background: var(--accent-purple);
    animation-delay: -10s;
}

@keyframes float {
    0% { transform: translate(0, 0) scale(1); }
    33% { transform: translate(50px, -50px) scale(1.1); }
    66% { transform: translate(-30px, 20px) scale(0.9); }
    100% { transform: translate(0, 50px) scale(1); }
}

/* ==========================================================================
   Contenedor Principal y Cabecera
   ========================================================================== */
.dashboard-container {
    width: 100%;
    max-width: 1200px;
    padding: 2rem;
    z-index: 1;
    display: flex;
    flex-direction: column;
    gap: 3rem;
}

.dashboard-header {
    text-align: center;
    animation: fadeInDown 1s ease-out;
}

.glow-text {
    font-family: var(--font-heading);
    font-size: 3.5rem;
    font-weight: 800;
    background: linear-gradient(135deg, #fff 0%, var(--text-secondary) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 0.5rem;
    letter-spacing: -1px;
}

.subtitle {
    font-size: 1.2rem;
    color: var(--text-secondary);
    font-weight: 400;
}

/* ==========================================================================
   Cuadrícula de Servicios (Grid)
   ========================================================================== */
.services-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 2rem;
}

/* ==========================================================================
   Tarjetas de Servicio (Glassmorphism)
   ========================================================================== */
.service-card {
    text-decoration: none;
    color: inherit;
    display: block;
    border-radius: 24px;
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.3s ease;
    animation: fadeInUp 0.8s ease-out forwards;
    opacity: 0;
    transform: translateY(20px);
}

/* Delay en animación para efecto cascada */
.service-card:nth-child(1) { animation-delay: 0.1s; }
.service-card:nth-child(2) { animation-delay: 0.2s; }
.service-card:nth-child(3) { animation-delay: 0.3s; }

.card-glass {
    background: var(--bg-surface);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--glass-border);
    box-shadow: var(--glass-shadow);
    border-radius: 24px;
    padding: 2rem;
    height: 100%;
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: var(--glass-highlight), var(--glass-shadow);
    transition: background 0.3s ease;
}

.service-card:hover {
    transform: translateY(-8px) scale(1.02);
}

.service-card:hover .card-glass {
    background: rgba(30, 38, 56, 0.7);
    border-color: rgba(255, 255, 255, 0.15);
}

/* Efecto de resplandor en Hover - SCADA */
.scada-card:hover .card-glass {
    box-shadow: 0 0 40px rgba(0, 125, 130, 0.2), inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

/* Efecto de resplandor en Hover - FV & PRVE */
.fv-card .card-icon {
    color: var(--accent-amber);
    background: rgba(245, 158, 11, 0.1);
}

.fv-card:hover .card-glass {
    box-shadow: 0 0 40px rgba(245, 158, 11, 0.2), inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

.card-icon {
    font-size: 2.5rem;
    color: var(--accent-teal-light);
    margin-bottom: 1.5rem;
    background: rgba(0, 125, 130, 0.1);
    width: 64px;
    height: 64px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 16px;
    transition: transform 0.3s ease;
}

.service-card:hover .card-icon {
    transform: scale(1.1) rotate(5deg);
}

.placeholder-card .card-icon {
    color: var(--text-secondary);
    background: rgba(255, 255, 255, 0.05);
}

.card-content h2 {
    font-family: var(--font-heading);
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.card-content p {
    font-size: 0.95rem;
    color: var(--text-secondary);
    line-height: 1.5;
    flex-grow: 1;
}

/* Estados (Online/Offline) */
.card-status {
    margin-top: 2rem;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 0.4rem 0.8rem;
    border-radius: 20px;
    background: rgba(0,0,0,0.2);
    align-self: flex-start;
}

.status-online { color: var(--status-online); }
.status-offline { color: var(--text-secondary); }

.pulse-dot {
    width: 8px;
    height: 8px;
    background-color: var(--status-online);
    border-radius: 50%;
    display: block;
    box-shadow: 0 0 0 rgba(16, 185, 129, 0.4);
    animation: pulse 2s infinite;
}

/* ==========================================================================
   Footer
   ========================================================================== */
.dashboard-footer {
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.9rem;
    border-top: 1px solid var(--glass-border);
    padding-top: 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
    animation: fadeIn 1.5s ease-out;
}

.system-time {
    font-family: var(--font-heading);
    font-variant-numeric: tabular-nums;
    background: rgba(255, 255, 255, 0.05);
    padding: 0.5rem 1rem;
    border-radius: 8px;
    border: 1px solid var(--glass-border);
}

/* ==========================================================================
   Keyframes
   ========================================================================== */
@keyframes pulse {
    0% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.4); }
    70% { box-shadow: 0 0 0 10px rgba(16, 185, 129, 0); }
    100% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

@keyframes fadeInDown {
    from { opacity: 0; transform: translateY(-30px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes fadeInUp {
    to { opacity: 1; transform: translateY(0); }
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* ==========================================================================
   Media Queries
   ========================================================================== */
@media (max-width: 768px) {
    .glow-text {
        font-size: 2.5rem;
    }
    .dashboard-footer {
        flex-direction: column;
        justify-content: center;
    }
}

/* ==========================================================================
   Autenticación (Login / Registro)
   ========================================================================== */
.auth-container {
    width: 100%;
    max-width: 500px;
    padding: 2rem;
    z-index: 1;
    display: flex;
    flex-direction: column;
}

.auth-card {
    background: var(--bg-surface);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--glass-border);
    box-shadow: var(--glass-shadow);
    border-radius: 24px;
    padding: 3rem 2rem;
    animation: fadeInUp 0.8s ease-out forwards;
}

.auth-card h2 {
    font-family: var(--font-heading);
    font-size: 1.8rem;
    margin-bottom: 2rem;
    text-align: center;
    color: var(--text-primary);
}

.input-group {
    margin-bottom: 1.5rem;
    display: flex;
    flex-direction: column;
}

.input-group label {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.input-group input {
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    padding: 0.8rem 1rem;
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: 1rem;
    outline: none;
    transition: border-color 0.3s ease, background 0.3s ease;
}

.input-group input:focus {
    border-color: var(--accent-teal);
    background: rgba(0, 0, 0, 0.4);
}

.checkbox-group {
    display: flex;
    align-items: flex-start;
    gap: 0.8rem;
    margin-bottom: 1.5rem;
}

.checkbox-group input {
    margin-top: 0.3rem;
}

.checkbox-group label {
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.4;
}

.btn-primary {
    width: 100%;
    background: linear-gradient(135deg, var(--accent-teal), var(--accent-teal-light));
    color: white;
    border: none;
    padding: 1rem;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 125, 130, 0.3);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
    border: 1px solid var(--glass-border);
    padding: 0.6rem 1.2rem;
    border-radius: 8px;
    font-size: 0.9rem;
    cursor: pointer;
    transition: background 0.2s ease;
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.15);
}

.auth-switch {
    margin-top: 1.5rem;
    text-align: center;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.auth-switch a {
    color: var(--accent-teal-light);
    text-decoration: none;
    font-weight: 500;
}

.auth-switch a:hover {
    text-decoration: underline;
}

.error-msg {
    color: var(--status-offline);
    font-size: 0.85rem;
    margin-bottom: 1rem;
    text-align: center;
}

.success-msg {
    color: var(--status-online);
    font-size: 0.85rem;
    margin-bottom: 1rem;
    text-align: center;
}

/* ==========================================================================
   Modal de Login
   ========================================================================== */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(8px);
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.2s ease;
}

.modal-card {
    background: rgba(15, 22, 36, 0.95);
    border: 1px solid var(--glass-border);
    border-radius: 24px;
    padding: 3rem 2.5rem;
    width: 100%;
    max-width: 420px;
    height: fit-content;
    align-self: center;
    position: relative;
    animation: fadeInUp 0.3s ease;
}

.modal-card h2 {
    font-family: var(--font-heading);
    font-size: 1.8rem;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
    text-align: center;
}

.modal-subtitle {
    font-size: 0.9rem;
    color: var(--text-secondary);
    text-align: center;
    margin-bottom: 2rem;
}

.modal-close {
    position: absolute;
    top: 1rem;
    right: 1.2rem;
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1.8rem;
    cursor: pointer;
    line-height: 1;
    transition: color 0.2s;
}
.modal-close:hover { color: var(--text-primary); }

/* Header row con usuario */
.header-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    margin-bottom: 0.5rem;
}

.user-email-badge {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-right: 1rem;
}

#userBadge {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* ==========================================================================
   Gestión de Usuarios (Admin Portal)
   ========================================================================== */
.admin-modal-card {
    max-width: 750px !important;
}

.btn-admin {
    border-color: rgba(0, 166, 172, 0.4) !important;
}
.btn-admin:hover {
    background: rgba(0, 125, 130, 0.2) !important;
    border-color: var(--accent-teal-light) !important;
}

.admin-table th, .admin-table td {
    padding: 12px 10px;
    vertical-align: middle;
    font-size: 0.95rem;
}

.admin-table tr {
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    transition: background 0.2s ease;
}
.admin-table tr:hover {
    background: rgba(255, 255, 255, 0.02);
}

.admin-table select {
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--glass-border);
    border-radius: 6px;
    color: var(--text-primary);
    padding: 4px 8px;
    font-family: var(--font-body);
    font-size: 0.85rem;
    outline: none;
    cursor: pointer;
}
.admin-table select:focus {
    border-color: var(--accent-teal-light);
}

.btn-status-toggle {
    border: none;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    text-transform: uppercase;
}
.btn-status-toggle.active {
    background: rgba(16, 185, 129, 0.15);
    color: var(--status-online);
    border: 1px solid rgba(16, 185, 129, 0.3);
}
.btn-status-toggle.inactive {
    background: rgba(239, 68, 68, 0.15);
    color: var(--status-offline);
    border: 1px solid rgba(239, 68, 68, 0.3);
}
.btn-status-toggle:hover {
    transform: scale(1.05);
}

.btn-delete-user {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 1.1rem;
    padding: 4px;
    transition: color 0.2s ease, transform 0.2s ease;
}
.btn-delete-user:hover {
    color: var(--status-offline);
    transform: scale(1.1);
}

/* ==========================================================================
   Estilos de Tarjetas Adicionales (Gastos / Facturación)
   ========================================================================== */
.gastos-card .card-icon {
    color: var(--accent-purple);
    background: rgba(139, 92, 246, 0.1);
}

.gastos-card:hover .card-glass {
    box-shadow: 0 0 40px rgba(139, 92, 246, 0.2), inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

.facturacion-card .card-icon {
    color: var(--accent-blue);
    background: rgba(59, 130, 246, 0.1);
}

.facturacion-card:hover .card-glass {
    box-shadow: 0 0 40px rgba(59, 130, 246, 0.2), inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

/* Delay en animación para efecto cascada (Tarjetas 3 y 4) */
.service-card:nth-child(3) { animation-delay: 0.3s; }
.service-card:nth-child(4) { animation-delay: 0.4s; }

.status-local {
    color: var(--accent-blue);
}

.pulse-dot-purple {
    width: 8px;
    height: 8px;
    background-color: var(--accent-purple);
    border-radius: 50%;
    display: block;
    box-shadow: 0 0 0 rgba(139, 92, 246, 0.4);
    animation: pulse-purple 2s infinite;
}

.pulse-dot-blue {
    width: 8px;
    height: 8px;
    background-color: var(--accent-blue);
    border-radius: 50%;
    display: block;
    box-shadow: 0 0 0 rgba(59, 130, 246, 0.4);
    animation: pulse-blue 2s infinite;
}

@keyframes pulse-purple {
    0% { box-shadow: 0 0 0 0 rgba(139, 92, 246, 0.4); }
    70% { box-shadow: 0 0 0 10px rgba(139, 92, 246, 0); }
    100% { box-shadow: 0 0 0 0 rgba(139, 92, 246, 0); }
}

@keyframes pulse-blue {
    0% { box-shadow: 0 0 0 0 rgba(59, 130, 246, 0.4); }
    70% { box-shadow: 0 0 0 10px rgba(59, 130, 246, 0); }
    100% { box-shadow: 0 0 0 0 rgba(59, 130, 246, 0); }
}
