/* =====================================================================
   Simulador de Colada · Identidad Ternium (feature 009)
   Mismos tokens que NEXUS (variante A): nexus-rediseno/BRAND.md.
   Los valores de la marca también están en Theming/ColadaTheme.cs.
   ===================================================================== */
:root {
    /* Paleta Ternium: primarios */
    --tx-red: #FF3300;          /* acción principal, íconos, bordes, indicadores (NO texto normal) */
    --tx-gray: #666666;         /* texto de cuerpo */
    --tx-orange: #FF9900;       /* advertencia (NO texto sobre blanco) */
    --tx-white: #FFFFFF;

    /* Paleta Ternium: secundarios */
    --tx-steel: #485458;        /* drawer, títulos, encabezados del panel */
    --tx-pale: #D4D4D4;         /* bordes, divisores, fondo del panel */
    --tx-cyan: #01688A;         /* links, información, foco */
    --tx-dark-blue: #003366;    /* valores monoespaciados */
    --tx-green: #00B451;        /* OK (NO texto sobre blanco) */

    /* Neutros derivados */
    --tx-ink: #1A1A1A;          /* texto sobre fondos de color, displays */
    --tx-pale-25: #F4F4F4;      /* fondo de contenido */
    --tx-pale-50: #EAEAEA;      /* botones del panel, hover */

    /* Semáforo */
    --sem-ok: var(--tx-green);
    --sem-warn: var(--tx-orange);
    --sem-crit: var(--tx-red);
    --sem-ok-bg: #E6F7EE;
    --sem-warn-bg: #FFF5E6;
    --sem-crit-bg: #FFEBE6;
    --sem-info-bg: #E6F0F3;

    /* Tipografía (Arial = respaldo web de Trade Gothic) */
    --font-heading: Arial, "Helvetica Neue", Helvetica, sans-serif;
    --font-sans: Arial, "Helvetica Neue", Helvetica, sans-serif;
    --font-mono: Consolas, "Courier New", monospace;

    /* Forma y elevación */
    --radius-lg: 8px;
    --radius-md: 4px;
    --shadow: 0 1px 3px rgba(0, 0, 0, .08);
    --shadow-2: 0 4px 12px rgba(0, 0, 0, .10);
    --focus-ring: 0 0 0 3px rgba(1, 104, 138, .35);

    /* Panel HMI de la simulación */
    --hmi-oscuro: var(--tx-steel);      /* barra superior y encabezados */
    --hmi-panel: var(--tx-pale);        /* fondo de los paneles */
    --hmi-borde: var(--tx-gray);        /* borde de los paneles */
    --hmi-lcd: var(--tx-ink);           /* fondo de los displays */
    --hmi-lcd-vel: #80B4C5;             /* Cyan al 50 % sobre blanco: legible sobre el display */
    --hmi-btn: var(--tx-pale-50);       /* botón de mando */
    --hmi-btn-off: #B3B3B3;             /* Gray al 50 % sobre blanco: opción no seleccionada */
}

/* La raíz queda en 16px: los rem del panel y del tema se calculan sobre ella */
html, body {
    font-family: var(--font-sans);
}

body {
    font-size: 14px;
    color: var(--tx-gray);
}

h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-heading);
    color: var(--tx-steel);
}

h1:focus {
    outline: none;
}

a, .btn-link {
    color: var(--tx-cyan);
}

:focus-visible {
    outline: none;
    box-shadow: var(--focus-ring);
}

/* =====================================================================
   Carga inicial y error de Blazor
   ===================================================================== */
.colada-splash {
    position: fixed;
    inset: 0;
    background: var(--tx-white);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    color: var(--tx-steel);
    font-family: var(--font-sans);
}

.colada-splash-circulo {
    width: 48px;
    height: 48px;
    border: 4px solid var(--tx-pale);
    border-top-color: var(--tx-red);
    border-radius: 50%;
    animation: colada-giro 1s linear infinite;
    margin-bottom: 20px;
}

@keyframes colada-giro { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }

.colada-splash-texto { font-size: 12px; letter-spacing: 3px; font-weight: 700; }

#blazor-error-ui {
    background: var(--sem-warn-bg);
    color: var(--tx-ink);
    border-top: 3px solid var(--tx-orange);
    bottom: 0;
    box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2);
    box-sizing: border-box;
    display: none;
    left: 0;
    padding: 0.6rem 1.25rem 0.7rem 1.25rem;
    position: fixed;
    width: 100%;
    z-index: 1100;
}

    #blazor-error-ui .dismiss {
        cursor: pointer;
        position: absolute;
        right: 0.75rem;
        top: 0.5rem;
    }

/* =====================================================================
   Layout (AppBar blanco · Drawer Steel Gray)
   ===================================================================== */
.nexus-appbar {
    border-bottom: 1px solid var(--tx-pale);
}

/* Nombre del producto como texto. Sin logo: no hay archivo oficial de Ternium
   para este simulador y la marca no permite recrearlo (BRAND.md §5). */
.colada-brand.mud-typography {
    color: var(--tx-steel);
    font-weight: 700;
    letter-spacing: 1.5px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    padding-left: 12px;
    border-left: 4px solid var(--tx-red);
}

/* Ítems del menú: blanco sobre Steel Gray, activo con barra roja */
.nexus-sidebar .mud-nav-link {
    color: var(--tx-white);
    position: relative;
}

.nexus-sidebar .mud-nav-link:hover:not(.mud-nav-link-disabled) {
    background-color: rgba(255, 255, 255, .08);
}

.nexus-sidebar .mud-navmenu .mud-nav-link.active:not(.mud-nav-link-disabled),
.nexus-sidebar .mud-navmenu .mud-nav-link.active:not(.mud-nav-link-disabled):hover {
    background-color: rgba(255, 255, 255, .12);
    border-inline-end-width: 0;
    color: var(--tx-white);
    font-weight: 700;
}

.nexus-sidebar .mud-navmenu .mud-nav-link.active:not(.mud-nav-link-disabled)::before {
    content: "";
    position: absolute;
    left: 0;
    top: 6px;
    bottom: 6px;
    width: 4px;
    border-radius: 2px;
    background: var(--tx-red);
}

.nexus-sidebar .mud-navmenu .mud-nav-link.active:not(.mud-nav-link-disabled) .mud-nav-link-icon {
    color: var(--tx-white);
}

.nexus-main-bg {
    background-color: var(--tx-pale-25);
    min-height: 100vh;
}

/* =====================================================================
   Sistema de diseño (clases nexus-* compartidas con NEXUS)
   ===================================================================== */
.nexus-card-border { border: 1px solid var(--tx-pale); }

.nexus-card {
    background: var(--tx-white);
    border: 1px solid var(--tx-pale);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    transition: box-shadow 0.2s ease;
}

.nexus-card:hover {
    box-shadow: var(--shadow-2);
}

.nexus-title-main {
    font-family: var(--font-heading);
    font-size: 1.375rem;
    font-weight: 700;
    color: var(--tx-steel);
}

.nexus-title-secondary {
    font-family: var(--font-heading);
    font-size: 1rem;
    font-weight: 700;
    color: var(--tx-steel);
}

.nexus-text-general {
    font-size: 0.875rem;
    color: var(--tx-gray);
}

/* Acción principal sobre rojo: blanco solo con bold de 16px o más (BRAND.md §3) */
.mud-button-root.colada-btn-main {
    font-size: 1rem;
    font-weight: 700;
    box-shadow: none;
}

/* Alertas: el naranja y el rojo no alcanzan contraste como texto; van en ícono y tinte */
.mud-alert.mud-alert-text-warning,
.mud-alert.mud-alert-text-error {
    color: var(--tx-ink);
}

/* Botones de texto de los diálogos (OK, Entendido): Cyan, el rojo no va como texto */
.mud-dialog .mud-button-text.mud-button-text-primary {
    color: var(--tx-cyan);
}

/* Login */
.colada-filete {
    width: 48px;
    height: 3px;
    background: var(--tx-red);
    margin: 8px auto 0 auto;
}

/* =====================================================================
   Menú: tarjetas de los casos. El color del caso va en el borde,
   el avatar y el botón; el título queda en Steel Gray.
   ===================================================================== */
.nexus-card.colada-caso {
    border: 2px solid var(--caso-color);
    height: 100%;
    display: flex;
    flex-direction: column;
}

.colada-caso .mud-card-content { flex-grow: 1; }
.colada-caso-a { --caso-color: var(--tx-red); }
.colada-caso-b { --caso-color: var(--tx-orange); }
.colada-caso-c { --caso-color: var(--tx-cyan); }
.colada-caso-aleatorio { --caso-color: var(--tx-steel); }
.colada-subtitulo.mud-typography { color: var(--tx-gray); }

/* =====================================================================
   Panel HMI de la simulación
   ===================================================================== */
.hmi-toolbar {
    background-color: var(--hmi-oscuro);
    color: var(--tx-white);
}

.hmi-toolbar .mud-button-outlined { border-color: currentColor; }

.hmi-toolbar-titulo.mud-typography {
    color: var(--tx-white);
    font-weight: 700;
    letter-spacing: 1px;
}

.hmi-reloj {
    background-color: var(--tx-red);
    color: var(--tx-white);
    padding: 2px 10px;
    border-radius: var(--radius-md);
    border: 2px solid rgba(0, 0, 0, .2);
}

.hmi-reloj .mud-icon-root,
.hmi-banner-torque .mud-icon-root {
    color: var(--tx-white);
}

.hmi-reloj .mud-typography {
    color: var(--tx-white);
    font-weight: 700;
    font-family: var(--font-mono);
}

@keyframes hmi-pulso {
    0% { opacity: 1; }
    100% { opacity: 0.75; }
}

.hmi-banner-torque {
    background-color: var(--tx-red);
    border: 2px solid var(--tx-red);
    box-shadow: 0 4px 10px rgba(0, 0, 0, .3);
    animation: hmi-pulso 0.8s infinite alternate;
}

.hmi-banner-torque .mud-typography {
    color: var(--tx-white);
    font-weight: 700;
    font-size: 1.1rem;
    letter-spacing: 1px;
    text-shadow: 1px 1px 3px rgba(0, 0, 0, .5);
}

.mud-card.hmi-panel {
    background-color: var(--hmi-panel);
    border: 2px solid var(--hmi-borde);
    border-radius: 0;
}

.mud-card.hmi-panel-falla { border-color: var(--tx-red); }

.hmi-header {
    background-color: var(--hmi-oscuro);
    color: var(--tx-white);
}

/* Texto oscuro sobre rojo: 4.8:1 con caption de 12px */
.hmi-header.hmi-header-falla {
    background-color: var(--tx-red);
    color: var(--tx-ink);
}

.hmi-header .mud-typography { font-weight: 700; }

.hmi-grupo {
    flex: 1;
    border: 1px solid var(--tx-white);
    padding: 4px;
}

.hmi-titulo.mud-typography {
    background-color: var(--hmi-oscuro);
    color: var(--tx-white);
    display: block;
    margin-bottom: 4px;
}

/* Displays */
.hmi-lcd {
    background-color: var(--hmi-lcd);
    color: var(--tx-white);
    padding: 2px 5px;
    font-family: var(--font-mono);
}

.hmi-lcd-ok { color: var(--tx-green); font-weight: 700; }
.hmi-lcd-vel { color: var(--hmi-lcd-vel); }
.hmi-lcd-crit { color: var(--tx-red); font-weight: 700; }
.hmi-lcd-grande { font-size: 1.1rem; }
.hmi-lcd-chico { padding: 1px 4px; font-size: 0.75rem; }

.hmi-lcd-sistema {
    padding: 10px;
    font-size: 2rem;
    text-align: right;
}

.hmi-lcd-unidad { font-size: 1rem; color: var(--tx-white); }

/* Botones de mando: el modificador solo cambia las variables */
.mud-button-root.hmi-btn.hmi-btn,
.mud-button-root.hmi-btn.hmi-btn:hover {
    background-color: var(--hmi-btn-bg, var(--hmi-btn));
    color: var(--hmi-btn-fg, var(--tx-ink));
}

.mud-button-root.hmi-btn.hmi-btn:hover { filter: brightness(0.95); }

.hmi-btn-on { --hmi-btn-bg: var(--tx-green); }
.hmi-btn-off { --hmi-btn-bg: var(--hmi-btn-off); }
.hmi-btn-warn { --hmi-btn-bg: var(--tx-orange); }
.hmi-btn-blanco { --hmi-btn-bg: var(--tx-white); }
.hmi-btn-oscuro { --hmi-btn-bg: var(--hmi-oscuro); --hmi-btn-fg: var(--tx-white); }

.mud-button-root.hmi-btn-xs { font-size: 0.6rem; padding: 2px; flex: 1; }
.mud-button-root.hmi-btn-sm { font-size: 0.7rem; padding: 2px; }
.mud-button-root.hmi-btn-redondo { border-radius: 10px; }

/* Caso C: validación del sensor */
.hmi-sensor {
    background-color: var(--sem-info-bg);
    border: 1px solid var(--tx-cyan);
    border-radius: var(--radius-md);
    padding: 4px;
}

.hmi-sensor-etiqueta.mud-typography { color: var(--tx-steel); font-weight: 700; }
.mud-button-root.hmi-sensor-btn { font-size: 0.65rem; }

/* Caso B: abortar. Blanco sobre rojo con bold de 16px */
.mud-button-root.hmi-abortar {
    font-weight: 700;
    font-size: 1rem;
    border-radius: 10px;
}

/* Indicadores */
.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
    box-shadow: 0 0 0 1px rgba(255, 255, 255, .7);
}

.status-dot.bueno { background-color: var(--sem-ok); }
.status-dot.desconectado { background-color: var(--sem-crit); box-shadow: 0 0 0 1px var(--tx-ink); }

/* =====================================================================
   Menú lateral: versión al pie y notas de versión (feature 011)
   ===================================================================== */
.colada-nav {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.colada-nav-version {
    margin-top: auto;
    padding: 12px 16px;
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: rgba(255, 255, 255, .6);
    white-space: nowrap;
}

/* Con el menú mini cerrado no hay lugar para el texto */
.mud-drawer--closed .colada-nav-version { display: none; }

.colada-notas-titulo.mud-typography {
    color: var(--tx-steel);
    font-weight: 700;
}
