/* ==========================================================================
   Configuración de Paletas de Colores Dinámicas (Modo Claro por Defecto)
   ========================================================================== */
:root {
    /* Fondo con degradado sutil y limpio basado en la web clara */
    --bg-dark-system: radial-gradient(circle at 50% 50%, #f4f7fc 0%, #e2e8f0 100%);
    
    /* Contenedor tipo Glassmorphism adaptado para fondos claros */
    --glass-card-bg: rgba(255, 255, 255, 0.65);
    --glass-card-border: rgba(40, 117, 255, 0.15);
    
    /* Textos con alto contraste para legibilidad */
    --color-text-main: #0f172a;      /* Gris muy oscuro / azulado */
    --color-text-muted: #64748b;    /* Gris neutro para etiquetas secundarias */
    
    /* Identidad de Marca (Azul Speed Cargo) */
    --brand_blue: #2875FF;
    --brand_blue-hover: #1e5ade;
    
    /* Campos de entrada estilizados para modo claro */
    --field-bg: rgba(255, 255, 255, 0.9);
    --field-border: rgba(148, 163, 184, 0.3);
    --field-focus-glow: rgba(40, 117, 255, 0.15);
    
    /* Adaptación del contenedor del Logo */
    --logo-bg: rgba(15, 23, 42, 0.03);
    --logo-border: rgba(15, 23, 42, 0.08);
}

/* ==========================================================================
   Detección Automática de Tema Oscuro (Media Query del Navegador)
   ========================================================================== */
@media (prefers-color-scheme: dark) {
    :root {
        /* Mapeo exacto de la configuración tecnológica oscura */
        --bg-dark-system: radial-gradient(circle at 50% 50%, #0a1424 0%, #020710 100%);
        
        --glass-card-bg: rgba(255, 255, 255, 0.03);
        --glass-card-border: rgba(255, 255, 255, 0.07);
        
        --color-text-main: #ffffff;
        --color-text-muted: #7e8b9b;
        
        --brand_blue: #2875FF;
        --brand_blue-hover: #0077b6;
        
        --field-bg: rgba(255, 255, 255, 0.05);
        --field-border: rgba(255, 255, 255, 0.12);
        --field-focus-glow: rgba(0, 180, 216, 0.2);
        
        --logo-bg: rgba(255, 255, 255, 0.02);
        --logo-border: rgba(255, 255, 255, 0.08);
    }
}

/* ==========================================================================
   Base de la Página y Estructura Viewport
   ========================================================================== */
body {
    margin: 0;
    padding: 0;
    background: var(--bg-dark-system) !important;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
    height: 100vh;
}

.login-page-viewport {
    width: 100%;
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
    box-sizing: border-box;
}

/* ==========================================================================
   Romper Maquetación de Tablas Nativas de ASP para Implementar Flexbox
   ========================================================================== */
table#tblPrincipal, 
table#tblPrincipal > tbody, 
table#tblPrincipal > tbody > tr, 
table#tblPrincipal > tbody > tr > td {
    display: block;
    width: 100%;
    background: none !important;
}

table#tblCentral, table#tblCentral > tbody, table#tblCentral > tbody > tr, table#tblCentral > tbody > tr > td,
table#tblNuevoLogin, table#tblNuevoLogin > tbody, table#tblNuevoLogin > tbody > tr, table#tblNuevoLogin > tbody > tr > td {
    display: flex;
    flex-direction: column;
    width: 100%;
}

/* ==========================================================================
   Estilo del Panel Principal (Login Card)
   ========================================================================== */
table#tblPrincipal {
    max-width: 400px;
    background: var(--glass-card-bg) !important;
    border: 1px solid var(--glass-card-border) !important;
    border-radius: 16px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.15);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    padding: 30px;
    box-sizing: border-box;
    transition: background 0.3s ease, border 0.3s ease, box-shadow 0.3s ease;
}

@media (prefers-color-scheme: dark) {
    table#tblPrincipal {
        box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    }
}

/* Fila de Controles Ocultos de Configuración */
.row-hidden-control {
    display: none !important;
}

/* ==========================================================================
   Elementos del Formulario (Enlaces, Logos y Títulos)
   ========================================================================== */
/* Botón Inicio / Regreso */
.row-back-home {
    margin-bottom: 15px;
}
.modern-home-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--color-text-muted);
    text-decoration: none;
    font-size: 15px;
    transition: color 0.2s ease;
}
.modern-home-link:hover {
    color: var(--brand_blue);
}
.home-icon {
    font-size: 14px;
    display: inline-flex;
    align-items: center;
}

/* Manejo del Logo */
.row-brand-logo {
    align-items: center;
    margin-bottom: 20px;
}
.modern-logo-wrapper {
    width: 100%;
    max-width: 400px;
    height: 100px;
    background: var(--logo-bg);
    border: 1px solid var(--logo-border);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 12px;
    box-sizing: border-box;
    transition: background 0.3s ease, border 0.3s ease;
}
.modern-logo-wrapper img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

/* Título */
.row-form-title {
    text-align: center;
    margin-bottom: 25px;
}
.modern-title-text {
    color: var(--color-text-main);
    font-size: 24px;
    font-weight: 600;
    letter-spacing: -0.5px;
    transition: color 0.3s ease;
}

/* ==========================================================================
   Campos de Entrada (Inputs y Cajas de Texto)
   ========================================================================== */
.row-modern-input {
    margin-bottom: 16px;
}
.modern-input-field {
    position: relative;
    display: flex;
    align-items: center;
}
.field-icon {
    position: absolute;
    left: 14px;
    padding: 0px;
    color: var(--color-text-muted);
    font-size: 15px;
    pointer-events: none;
    display: inline-flex;
    align-items: center;
}
.ctrl-textbox {
    width: 100%;
    padding: 13px 14px 13px 42px;
    background: var(--field-bg) !important;
    border: 1px solid var(--field-border) !important;
    border-radius: 8px;
    color: var(--color-text-main) !important;
    font-size: 14.5px;
    box-sizing: border-box;
    outline: none;
    transition: all 0.25s ease;
}
.ctrl-textbox:focus {
    border-color: var(--brand_blue) !important;
    box-shadow: 0 0 0 4px var(--field-focus-glow);
    background: var(--field-bg) !important;
}

/* Link de Recuperación */
.row-forgot-pass {
    text-align: right;
    margin-bottom: 25px;
}
.ctrl-forgot-link {
    color: var(--color-text-muted) !important;
    font-size: 12.5px;
    text-decoration: none !important;
    transition: color 0.2s ease;
}
.ctrl-forgot-link:hover {
    color: var(--brand_blue) !important;
}

/* ==========================================================================
   Transformación de Ingeniería del ImageButton Antiguo de ASP
   ========================================================================== */
.row-submit-action {
    margin-bottom: 20px;
}
.modern-btn-container {
    position: relative;
    width: 100%;
    height: 46px;
}
/* Forzamos al control original invisible a expandirse en toda la zona clickeable */
.ctrl-imagebutton-hidden {
    position: absolute;
    top: 0;
    left: 0;
    width: 100% !important;
    height: 100% !important;
    opacity: 0 !important;
    z-index: 5;
    cursor: pointer;
}
/* El botón de diseño estilizado renderizado en la capa inferior */
.modern-btn-visual {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--brand_blue);
    color: #ffffff;
    font-size: 15px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    z-index: 1;
    transition: background-color 0.2s ease, transform 0.1s ease;
    pointer-events: none; /* Deja pasar los clicks del mouse al ImageButton */
}
.modern-btn-container:hover .modern-btn-visual {
    background: var(--brand_blue-hover);
}
.modern-btn-container:active .modern-btn-visual {
    transform: scale(0.98);
}

/* ==========================================================================
   Área de Mensajes, Footer y Metadata del Sistema
   ========================================================================== */
/* Área de Mensajes de Error (Footer Control) */
.row-system-footer {
    margin-top: 15px;
    border-top: 1px solid var(--field-border) !important;
    padding-top: 15px;
    transition: border 0.3s ease;
}

/* Metadata de Versiones y Licencias */
.row-system-meta {
    margin-top: 10px;
    text-align: center;
}
.meta-label {
    display: block;
    color: var(--color-text-muted) !important;
    font-size: 11px !important;
    line-height: 1.6;
}

/* ==========================================================================
   Corrección de Filtros Inteligentes para Iconos SVG Nativos (.theme-icon)
   ========================================================================== */
.theme-icon {
    /* Convierte dinámicamente un SVG blanco/gris claro en el gris azulado corporativo (#64748b) */
    filter: brightness(0) saturate(100%) invert(48%) sepia(9%) saturate(849%) hue-rotate(174%) brightness(93%) contrast(90%);
    transition: filter 0.3s ease;
    vertical-align: middle;
}

@media (prefers-color-scheme: dark) {
    .theme-icon {
        /* En modo oscuro, remueve el filtro para lucir sus líneas claras/blancas originales */
        filter: none !important;
    }
}

/* ==========================================================================
   Optimización para Dispositivos Móviles (Media Query de Pantalla)
   ========================================================================== */
@media (max-width: 480px) {
    table#tblPrincipal {
        padding: 24px 16px;
    }
    .modern-title-text {
        font-size: 21px;
    }
}