﻿/* ==========================================================
   SCADA THEME PACK v2 — 4 temas + tokens semánticos
   - Menos variables repetidas, más semántica
   - Fácil de mantener, preparado para Blazor (data-theme="...")
   ========================================================== */

/* 0) RESET BÁSICO (opcional mínimo) */
* {
    box-sizing: border-box;
}

html, body {
    height: 100%;
}

/* 1) TOKENS BASE (pueden cambiar por tema vía [data-theme]) */
:root {
    /* Espaciado & efectos */
    --radius: 12px;
    --shadow-1: 0 1px 2px rgba(0,0,0,.06), 0 8px 24px rgba(0,0,0,.08);
    /* Núcleo cromático (semántico) */
    --bg: #0f1418;
    --surface: #161c22;
    --surface-2: #1b222a;
    --border: #26313a;
    --text: #e6edf3;
    --muted: #9aa6b2;
    /* Estados / acentos */
    --primary: #3ba6a1;
    --success: #3fb950;
    --warning: #e3b341;
    --danger: #f08770;
    --critical: #ff4d6d;
    --commfail: #b48ead;
    --disabled: #56616b;
    /* Utilidades por tema */
    --grid: color-mix(in srgb, var(--text) 10%, transparent);
    --overlay: rgba(0,0,0,.5);
    --header-bg: var(--surface-2);
    --header-fg: var(--text);
    --stripe: color-mix(in srgb, var(--text) 7%, transparent);
    /* PRELOADER */
    --preloader-gradient-top: color-mix(in srgb, var(--primary) 22%, var(--bg));
    --preloader-gradient-bottom: var(--bg);
    --preloader-panel-bg: color-mix(in srgb, var(--surface) 96%, black 4%);
    --preloader-panel-shadow: 0 25px 50px rgba(0, 0, 0, .6);
    --preloader-text: var(--text);
    --preloader-track: color-mix(in srgb, var(--surface-2) 92%, var(--bg) 8%);
    --preloader-fill-start: var(--success);
    --preloader-fill-end: var(--primary);
    --preloader-warning: var(--warning);
    /* Integración Bootstrap */
    --bs-body-bg: var(--bg);
    --bs-body-color: var(--text);
    --bs-table-striped-bg: var(--stripe);
    --bs-table-border-color: var(--border);
}


/* 2) TEMAS (cambia sólo estos bloques para nuevas pieles) */

/* A) Slate Teal (Oscuro) */
body[data-theme="slate-teal"] {
    --bg: #0f1418;
    --surface: #161c22;
    --surface-2: #1b222a;
    --border: #26313a;
    --text: #e6edf3;
    --muted: #9aa6b2;
    --primary: #3ba6a1;
    --success: #3fb950;
    --warning: #e3b341;
    --danger: #f08770;
    --critical: #ff4d6d;
    --commfail: #b48ead;
    --disabled: #56616b;
    --grid: color-mix(in srgb, var(--text) 10%, transparent);
    --overlay: rgba(0,0,0,.5);
    --header-bg: linear-gradient(to right, #1b222a, rgba(27,34,42,.65));
    --stripe: color-mix(in srgb, var(--text) 7%, transparent);
    /* Opcional: refinar tabla para este tema */
}


/* B) Graphite Cyan (Oscuro suave) */
body[data-theme="graphite-cyan"] {
    --bg: #121416;
    --surface: #1a1e22;
    --surface-2: #20252a;
    --border: #2a3138;
    --text: #d8dee9;
    --muted: #a8b3bf;
    --primary: #35b0c6;
    --success: #5bb98c;
    --warning: #f0c674;
    --danger: #ef7356;
    --critical: #ff4d6d;
    --commfail: #b48ead;
    --disabled: #5a666f;
    --grid: color-mix(in srgb, var(--text) 10%, transparent);
    --overlay: rgba(0,0,0,.5);
    --header-bg: linear-gradient(to right, #20252a, rgba(32,37,42,.65));
    --stripe: color-mix(in srgb, var(--text) 8%, transparent);
}

/* C) Pebble Sand (Claro) */
body[data-theme="pebble-sand"] {
    --bg: #f6f7f9;
    --surface: #ffffff;
    --surface-2: #f0f2f5;
    --border: #d9dee5;
    --text: #0f1418;
    --muted: #6b7785;
    --primary: #2f6f87;
    --success: #2f8f4e;
    --warning: #b88000;
    --danger: #b03a2e;
    --critical: #d21f3c;
    --commfail: #8f6bb4;
    --disabled: #9aa6b2;
    --grid: rgba(0,0,0,.06);
    --overlay: rgba(0,0,0,.45);
    --header-bg: linear-gradient(to right, #eef1f5, rgba(240,242,245,.75));
    --stripe: rgba(0,0,0,.05);
}


/* D) Fog Blue (Claro frío, baja fatiga) */
body[data-theme="fog-blue"] {
    --bg: #eef2f6;
    --surface: #ffffff;
    --surface-2: #e7ecf2;
    --border: #cfd9e3;
    --text: #111418;
    --muted: #5d6a78;
    --primary: #2e7da6;
    --success: #2e8f6e;
    --warning: #b8842a;
    --danger: #b04b3a;
    --critical: #d33a5a;
    --commfail: #7a6fb4;
    --disabled: #97a3af;
    --grid: rgba(0,0,0,.055);
    --overlay: rgba(0,0,0,.42);
    --header-bg: linear-gradient(to right, #e7ecf2, rgba(231,236,242,.75));
    --stripe: rgba(0,0,0,.045);
}


body[data-theme="legacy-blue"] {
    --bg: #ffffff;
    --surface: #ffffff;
    --surface-2: #f3f7fc;
    --border: #95b3d7;
    --text: #0f1418;
    --muted: #345673;
    --primary: #4f81bd;
    --success: #4CAF50;
    --warning: #b8842a;
    --danger: #b03a2e;
    --critical: #d33a5a;
    --commfail: #7a6fb4;
    --disabled: #aab4bf;
    --grid: rgba(0,0,0,.06);
    --overlay: rgba(0,0,0,.4);
    --header-bg: linear-gradient(to right, #e9f0f9, #ffffff 60%);
    --stripe: rgba(0,0,0,.035);
}

/* E) Midnight Slate (Oscuro profundo, basado en el preloader) */
body[data-theme="midnight-slate"] {
    --bg: #020617;
    --surface: #020617;
    --surface-2: #0f172a;
    --border: #1f2937;
    --text: #e5e7eb;
    --muted: #9ca3af;
    --primary: #2dd4bf;
    --success: #22c55e;
    --warning: #f97316;
    --danger: #f97373;
    --critical: #fb7185;
    --commfail: #a855f7;
    --disabled: #4b5563;
    --grid: rgba(148, 163, 184, .12);
    --overlay: rgba(15, 23, 42, .80);
    --header-bg: linear-gradient( to right, #020617, rgba(15, 23, 42, .85) );
    --stripe: rgba(15, 23, 42, .95);
}



/* 3) BASE APP */
body, html {
    margin: 0;
    background-color: var(--bg);
    color: var(--text);
    font: 14px/1.45 system-ui, -apple-system, Segoe UI, Roboto, Ubuntu, Cantarell, "Noto Sans", Helvetica, Arial;
}

.layout {
    display: flex;
    flex-direction: column;
    height: 100vh;
}

.main {
    flex: 1;
    display: flex;
    overflow: hidden;
}

/* 4) CONTENT con grilla sutil (P&ID / mimics) */
.content {
    flex: 1;
    overflow-y: auto;
    background-color: var(--surface);
    background-image: linear-gradient(to right, var(--grid) 1px, transparent 1px), linear-gradient(to bottom, var(--grid) 1px, transparent 1px);
    background-size: 20px 20px;
    background-position: 0 0;
}

/* 5) TREE / MENÚ LATERAL */
.tree-menu, .tree-menu ul {
    list-style: none;
    padding-left: 1rem;
    margin: 0;
}

    .tree-menu li {
        margin: 4px 0;
    }
    .tree-menu .node-line:hover {
        color: color-mix(in srgb, var(--text) 70%, transparent);
        background-color: color-mix(in srgb, var(--bg) 20%, transparent);
        /*cursor: pointer;*/
    }

    .tree-menu .toggle {
        margin-right: 0;
        cursor: pointer;
        font-weight: 600;
        display: inline-block;
    }

    .tree-menu .toggle-placeholder {
        display: inline-block;
        width: 1rem;
    }

.menu-icon {
    margin-right: 4px;
    display: inline-block;
    width: 15px;
}

.tree-item {
    display: flex;
    align-items: center;
    gap: 6px;
}
.menu-link, .menu-label {
    cursor: pointer;
    color: var(--text);
    text-decoration: none;
}
    .menu-link:hover {
        color: color-mix(in srgb, var(--text) 70%, transparent);
        /*background-color: color-mix(in srgb, var(--primary) 20%, transparent);*/
    }

    .menu-link.active {
        font-weight: 700;
        color: color-mix(in srgb, var(--text) 70%, transparent);
    }

.fa-button {
    padding-left: 1px; 
    cursor: pointer;
}
    .fa-button:hover {
        color: color-mix(in srgb, var(--primary) 50%, transparent);
        /*background-color: color-mix(in srgb, var(--primary) 20%, transparent);*/
    }
    .fa-button:active {
        color: color-mix(in srgb, var(--warning) 50%, transparent);
        /*background-color: color-mix(in srgb, var(--primary) 20%, transparent);*/
    }
.draggable-menu {
    cursor: grab;
}

    .draggable-menu:active {
        cursor: grabbing;
    }

.drop-target-role,
.drop-target-menu {
    border-radius: 4px;
}

    .drop-target-role.drag-over,
    .drop-target-menu.drag-over {
        outline: 1px dashed #0d6efd;
        background-color: rgba(13, 110, 253, 0.08);
    }

/* 6) PRELOADER + SPINNER */
#preloader {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: var(--surface);
}

.spinner {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    border: 6px solid color-mix(in srgb, var(--text) 20%, transparent);
    border-top-color: var(--primary);
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* 7) TABLAS */

table {
    width: 100%;
    border-collapse: collapse;
    font-family: inherit;
    font-size: .9rem;
    color: var(--text);
    background-color: color-mix(in srgb, var(--bg) 70%, transparent);
}

/* Encabezado */
thead th {
    background: color-mix(in srgb, var(--surface-2) 85%, var(--text) 15%);
    color: var(--text);
    font-weight: 700;
    padding: 10px 12px;
    border-bottom: 2px solid var(--border);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Celdas */
td {
    padding: 8px 10px;
    border-bottom: 1px solid var(--border);
    color: var(--text);
}

/* Filas alternas (zebra) */
tbody > tr:nth-of-type(even) {
    background-color: color-mix(in srgb, var(--surface) 88%, var(--text) 12%);
}

tbody > tr:nth-of-type(odd) {
    background-color: color-mix(in srgb, var(--surface) 94%, var(--text) 6%);
 }

/* Hover */
tbody tr:hover {
    background-color: color-mix(in srgb, var(--primary) 20%, transparent);
    transition: background-color 0.2s ease;
}


.chart-container {
    width: 100%;
    max-width: 800px;
    height: 500px;
    background: color-mix(in srgb, var(--surface) 95%, var(--text) 5%);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    overflow: hidden;
}
/* 8) LAYOUT: PAGE + TABS */
.page {
    position: relative;
    display: flex;
    flex-direction: column;
}

.tab-header {
    display: flex;
    padding: 0;
    background-color: var(--surface-2);
    border-bottom: 1px solid var(--border);
    border-left: 1px solid var(--border);
}

    .tab-header button {
        background-color: var(--surface);
        color: var(--text);
        border: none;
        cursor: pointer;
        padding: 2px 12px;
        font-size: .9rem;
        display: flex;
        align-items: center;
        gap: 6px;
        border-right: 1px solid var(--border);
        border-bottom: 1px solid var(--border);
        transition: background-color .2s ease, color .2s ease;
    }

        .tab-header button:hover {
            background-color: color-mix(in srgb, var(--surface) 80%, var(--text) 20%);
        }

    .tab-header .active {
        background-color: var(--surface);
        color: var(--text);
        font-weight: 700;
        border-right: 1px solid var(--border);
        border-left: 1px solid var(--border);
        border-bottom: 1px solid var(--surface);
    }

    .tab-header span {
        color: var(--text);
        font-weight: 700;
        cursor: pointer;
    }

        .tab-header span:hover {
            color: var(--danger);
        }

.tab-content {
    color: var(--text);
    padding: 16px;
    border-radius: 0 0 var(--radius) var(--radius);
}

/* 9) MODAL */
.modal-overlay {
    position: fixed;
    inset: 0;
    background-color: var(--overlay);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-content {
    
    background-color: color-mix(in srgb, var(--surface) 96%, var(--text) 4%);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-1);
    /*padding: .75rem 1rem;*/
    margin: 3rem;
}
.modal-body {
    padding: .75rem 1rem;
    color: var(--text);
}
.modal-header {
    background-color: color-mix(in srgb, var(--surface) 90%, var(--text) 10%);
    color: var(--text);
    border-bottom: 1px solid var(--border);
    font-weight: 600;
    justify-content: space-between;
    padding: .75rem 1rem;
}
.modal-header:first-child {
        border-radius: var(--radius) var(--radius) 0 0;
    }
.modal-footer {
    padding: .75rem 1rem;
}
/* X) FROM */
.form-control {
    color:var(--text);
    background-color:var(--bg);
}
    .form-control:focus {
        background-color: var(--bg);
        color: var(--text);
    }
.form-select {
    color: var(--text);
    background-color: var(--bg);
}
    .form-select:focus {
        background-color: var(--bg);
        color: var(--text);
    }

/* 10) CARDS */
.card {
    background-color: color-mix(in srgb, var(--surface) 96%, var(--text) 4%);
    color: var(--text);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-1);
    /* dejamos que Bootstrap maneje width/max-width según el grid */
}

.card-header {
    border-radius: var(--radius);
    background-color: color-mix(in srgb, var(--surface) 90%, var(--text) 4%);
    color: var(--text);
    font-weight: 600;
}

.card-header:first-child {
    border-radius: var(--radius) var(--radius) 0 0;
}
.card-body {
    padding: .75rem 1rem;
    color: var(--text);
}

/* 11) TOPBAR */
.topbar {
    background: var(--header-bg);
    color: var(--text);
    padding: .5rem 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 40px;
}

.menu-btn {
    font-size: 20px;
    background: none;
    border: none;
    color: var(--text);
    cursor: pointer;
    margin-right: 6px;
    padding: 0;
}

.tname {
    font-weight: 900;
    font-family: "Segoe UI", system-ui, -apple-system, Roboto;
}

.tdiv {
    display: flex;
    align-items: center;
    gap: .5rem;
}

/* 12) USER MENU */
.user-menu {
    position: relative;
    display: inline-block;
}

.user-btn {
    background: transparent;
    border: none;
    color: var(--text);
    cursor: pointer;
    font-size: 1rem;
}

.user-dropdown {
    position: absolute;
    right: 0;
    background-color: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    min-width: 160px;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-1);
}

    .user-dropdown button {
        background: transparent;
        border: none;
        color: var(--text);
        padding: 8px 12px;
        text-align: left;
        cursor: pointer;
    }

        .user-dropdown button:hover {
            background-color: color-mix(in srgb, var(--surface) 85%, var(--text) 15%);
        }

.user-display {
    display: flex;
    align-items: center;
    cursor: pointer;
    color: var(--text);
}

.profile-pic {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    margin-right: 8px;
}

/* 13) FOOTER */
.footer {
    height: 36px;
    background-color: var(--surface-2);
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    color: var(--muted);
}

/* 14) SIDEBAR */
.sidebar-container {
    display: flex;
    height: 100vh;
    overflow: hidden;
    color: var(--text);
}

.sidebar {
    position: relative;
    background-color: var(--bg);
    color: var(--text);
    height: 100%;
    transition: width .25s ease;
    overflow: hidden;
}

    .sidebar.open {
        width: 250px;
    }

    .sidebar.closed {
        width: 10px;
    }

.toggle-button {
    position: absolute;
    top: 50%;
    right: -10px;
    transform: translateY(-50%);
    width: 30px;
    height: 30px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    background-color: color-mix(in srgb, var(--surface) 85%, var(--text) 15%);
    color: var(--text);
    font-size: 18px;
    z-index: 1000;
    box-shadow: 0 0 5px rgba(0,0,0,.4);
}

/* 15) BLAZOR ERROR */
#blazor-error-ui {
    color-scheme: light only;
    background: lightyellow;
    bottom: 0;
    box-shadow: 0 -1px 2px rgba(0,0,0,.2);
    display: none;
    left: 0;
    padding: .6rem 1.25rem .7rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
}

    #blazor-error-ui .dismiss {
        cursor: pointer;
        position: absolute;
        right: .75rem;
        top: .5rem;
    }

/* 16) ESTADOS — badges utilitarias */
.badge {
    display: inline-flex;
    gap: 6px;
    align-items: center;
    padding: 2px 8px;
    border: 1px solid var(--border);
    border-radius: 999px;
    font-weight: 600;
}

    .badge.ok {
        background: color-mix(in srgb, var(--success) 18%, transparent);
        color: var(--text);
    }

    .badge.warn {
        background: color-mix(in srgb, var(--warning) 18%, transparent);
        color: var(--text);
    }

    .badge.alarm {
        background: color-mix(in srgb, var(--danger) 18%, transparent);
        color: var(--text);
    }

    .badge.crit {
        background: color-mix(in srgb, var(--critical) 18%, transparent);
        color: var(--text);
    }

    .badge.comm {
        background: color-mix(in srgb, var(--commfail) 18%, transparent);
        color: var(--text);
    }

/* 17) ACCESIBILIDAD */
:focus-visible {
    outline: 3px solid color-mix(in srgb, var(--primary) 60%, white 40%);
    outline-offset: 2px;
    border-radius: 6px;
}

@media (prefers-reduced-motion: reduce) {
    .pulse {
        animation: none !important;
    }
}

/* 18) UTILIDADES (si las necesitas) */
.text-muted {
    color: var(--muted) !important;
}
.small.text-muted {
    font-size: 0.8rem;
}
.border {
    border: 1px solid var(--border);
}

.surface {
    background: var(--surface);
}

.surface-2 {
    background: var(--surface-2);
}

.rounded {
    border-radius: var(--radius);
}

.shadow-1 {
    box-shadow: var(--shadow-1);
}

/*Preload Revisar luego*/
/* PRELOADER (usa variables del tema) */
.preloader-overlay {
    position: fixed;
    inset: 0;
    background: radial-gradient( circle at top, var(--preloader-gradient-top) 0, var(--preloader-gradient-bottom) 60% );
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.preloader-panel {
    background: var(--preloader-panel-bg);
    border-radius: 16px;
    padding: 24px 32px;
    min-width: 320px;
    max-width: 480px;
    box-shadow: var(--preloader-panel-shadow);
    color: var(--preloader-text);
    text-align: center;
}

.preloader-title {
    font-size: 1.4rem;
    font-weight: 700;
    margin-bottom: 8px;
}

.preloader-message {
    font-size: 0.95rem;
    margin-bottom: 16px;
    opacity: 0.9;
}

.preloader-progress-container {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 8px;
}

.preloader-progress-bar {
    flex: 1;
    height: 8px;
    border-radius: 999px;
    background: var(--preloader-track);
    overflow: hidden;
}

.preloader-progress-fill {
    height: 100%;
    border-radius: 999px;
    background: linear-gradient( 90deg, var(--preloader-fill-start), var(--preloader-fill-end) );
    transition: width 0.25s ease-out;
}

.preloader-progress-text {
    font-family: system-ui, sans-serif;
    font-size: 0.9rem;
    min-width: 3ch;
    text-align: right;
}

.preloader-warning {
    margin-top: 8px;
    font-size: 0.8rem;
    color: var(--preloader-warning);
}

