/* Variáveis GLOBAIS - Tema Dark (Estilo IHM) */
:root {
    /* Cores de Fundo */
    --bg-main: #0B0E14;
    --bg-panel: #151A22;
    --bg-header: #10141A;
    
    /* Cores de Destaque / Interface */
    --accent-blue: #00E5FF;
    --accent-red: #FF3366;
    --accent-green: #00FF66;
    --text-main: #E2E8F0;
    --text-muted: #94A3B8;
    
    /* Bordas e Sombras */
    --border-color: rgba(255, 255, 255, 0.08);
    --glow-blue: 0 0 10px rgba(0, 229, 255, 0.4);
    --glow-red: 0 0 10px rgba(255, 51, 102, 0.4);
    
    /* Tipografia */
    --font-ui: 'Inter', sans-serif;
    --font-digital: 'Share Tech Mono', monospace;

    /* Estado das Tubulações (Dinâmico) */
    --pipe-fluid-color: #4A5568;
    --pipe-suction-color: #4A5568;
    --pipe-discharge-color: #4A5568;
    --pipe-liquid-color: #4A5568;
    --pipe-expansion-color: #4A5568;
}

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

body {
    font-family: var(--font-ui);
    background-color: var(--bg-main);
    color: var(--text-main);
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden; /* Evita scroll na tela principal do simulador */
}

/* ================= HEADER ================= */
.app-header {
    background-color: var(--bg-header);
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    border-bottom: 1px solid var(--border-color);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
    z-index: 10;
}

.logo {
    font-size: 20px;
    font-weight: 800;
    letter-spacing: 1px;
}

.logo-highlight {
    color: var(--accent-blue);
    text-shadow: var(--glow-blue);
}

.main-nav ul {
    display: flex;
    list-style: none;
    gap: 30px;
}

.main-nav a {
    color: var(--text-muted);
    text-decoration: none;
    font-size: 14px;
    font-weight: 600;
    transition: all 0.3s ease;
}

.main-nav a:hover, .main-nav a.active {
    color: var(--text-main);
}

.main-nav a.active {
    border-bottom: 2px solid var(--accent-blue);
    padding-bottom: 4px;
}

.system-status {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    font-weight: 600;
    background: rgba(0, 255, 102, 0.1);
    padding: 6px 12px;
    border-radius: 20px;
    border: 1px solid rgba(0, 255, 102, 0.2);
}

.status-indicator {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.status-indicator.online {
    background-color: var(--accent-green);
    box-shadow: 0 0 8px var(--accent-green);
}

/* ================= SIMULADOR ================= */
.simulator-container {
    flex: 1;
    display: flex;
    padding: 20px;
    gap: 20px;
    height: calc(100vh - 60px);
    overflow: hidden;
    background-image: 
        linear-gradient(rgba(255,255,255,0.01) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255,255,255,0.01) 1px, transparent 1px);
    background-size: 50px 50px;
}

.simulator-canvas {
    flex: 7; /* Parte superior da coluna principal */
    background-color: var(--bg-panel);
    border-radius: 12px;
    border: 1px solid var(--border-color);
    box-shadow: inset 0 0 50px rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
    cursor: grab;
    user-select: none;
}

.main-column {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 16px;
    height: 100%;
}

/* Estado Oculto do Gráfico */
.main-column.hide-trends .simulator-canvas {
    flex: 1;
}

.main-column.hide-trends .trend-chart-card {
    display: none;
}

.trend-chart-card {
    flex: 3;
    display: flex;
    flex-direction: column;
    background: rgba(15, 23, 42, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.chart-wrapper {
    flex: 1;
    min-height: 0;
    position: relative;
}

.simulator-canvas:active {
    cursor: grabbing;
}

.placeholder-text {
    text-align: center;
    color: var(--text-muted);
}

.placeholder-text h2 {
    color: var(--text-main);
    margin-bottom: 8px;
    font-weight: 400;
}

/* ================= SVG ANIMATIONS ================= */
.fan-spin {
    transform-origin: center;
    transform-box: fill-box;
}

/* Classes utilitárias para status (Ligar/Desligar via JS no futuro) */
.stopped {
    animation-play-state: paused !important;
}

/* ================= SIDEBAR ================= */
.control-sidebar {
    width: 340px;
    background-color: var(--bg-panel);
    border-radius: 14px;
    border: 1px solid var(--border-color);
    box-shadow: 0 10px 40px rgba(0,0,0,0.6);
    display: flex;
    flex-direction: column;
    z-index: 5;
    overflow: hidden;
}

.sidebar-header {
    padding: 18px 20px;
    border-bottom: 1px solid var(--border-color);
    background: rgba(255,255,255,0.02);
}

.sidebar-content {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* Custom Scrollbar */
.sidebar-content::-webkit-scrollbar {
    width: 4px;
}

.sidebar-content::-webkit-scrollbar-track {
    background: transparent;
}

.sidebar-content::-webkit-scrollbar-thumb {
    background: rgba(148, 163, 184, 0.1);
    border-radius: 10px;
}

#system-alerts {
    background: rgba(16, 185, 129, 0.04);
    border: 1px solid rgba(16, 185, 129, 0.1);
    margin: 10px 16px;
    padding: 10px 16px;
    border-radius: 10px;
    min-height: 42px;
    display: flex;
    align-items: center;
    transition: all 0.3s ease;
}

.card-header-mini {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
}

.card-header-mini .card-icon {
    font-size: 14px;
    opacity: 0.6;
}

.card-header-mini #alert-msg {
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    flex: 1;
}

.status-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #94A3B8;
    transition: all 0.3s ease;
}

/* Estado OK */
#system-alerts.status-ok {
    background: rgba(16, 185, 129, 0.04);
    border-color: rgba(16, 185, 129, 0.1);
}
#system-alerts.status-ok #alert-msg { color: #10B981; }
#system-alerts.status-ok .status-dot { background: #10B981; box-shadow: 0 0 8px rgba(16, 185, 129, 0.4); }

/* Estado Alarme */
#system-alerts.status-alarm {
    background: rgba(239, 68, 68, 0.08);
    border-color: rgba(239, 68, 68, 0.2);
    animation: alarm-pulse 2s infinite ease-in-out;
}
#system-alerts.status-alarm #alert-msg { color: #EF4444; }
#system-alerts.status-alarm .status-dot { background: #EF4444; box-shadow: 0 0 10px rgba(239, 68, 68, 0.5); }

@keyframes alarm-pulse {
    0% { border-color: rgba(239, 68, 68, 0.2); }
    50% { border-color: rgba(239, 68, 68, 0.4); background: rgba(239, 68, 68, 0.12); }
    100% { border-color: rgba(239, 68, 68, 0.2); }
}

.sidebar-header h3 {
    font-size: 14px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 2px;
    color: var(--accent-blue);
    text-shadow: var(--glow-blue);
    margin-bottom: 20px;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 12px;
}

.control-group label {
    display: block;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    margin-bottom: 8px;
}

.digital-display {
    background-color: #05070a;
    border: 1px solid rgba(0, 255, 102, 0.3);
    border-radius: 6px;
    padding: 15px;
    color: var(--accent-green);
    font-family: var(--font-digital);
    font-size: 28px;
    text-align: center;
    box-shadow: inset 0 0 15px rgba(0, 255, 102, 0.1);
    text-shadow: 0 0 10px rgba(0, 255, 102, 0.5);
    margin-bottom: 25px;
}

.btn-primary {
    background: linear-gradient(180deg, #2D3748 0%, #1A202C 100%);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    padding: 12px;
    border-radius: 6px;
    font-family: var(--font-ui);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    margin-bottom: 10px;
}

.btn-primary:hover {
    border-color: var(--accent-blue);
    box-shadow: 0 0 15px rgba(0, 229, 255, 0.2);
    transform: translateY(-1px);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-small-text {
    font-size: 11px;
    color: var(--text-muted);
    display: block;
    margin-bottom: 20px;
    text-align: center;
}

/* ================= TUBULAÇÕES (PIPES) ================= */
.pipe-base {
    fill: none;
    stroke: #0F172A;
    stroke-width: 14px; /* Ajustado para equilíbrio visual */
    stroke-linecap: round;
    stroke-linejoin: round;
}

.pipe-fluid {
    fill: none;
    stroke: var(--pipe-fluid-color);
    stroke-width: 10px;
    stroke-linecap: round;
    stroke-linejoin: round;
    opacity: 0.8;
    filter: blur(0.5px);
    transition: stroke 1s ease;
}

/* Classes específicas para mapeamento JS */
.pipe-suction { stroke: var(--pipe-suction-color); }
.pipe-discharge { stroke: var(--pipe-discharge-color); }
.pipe-liquid { stroke: var(--pipe-liquid-color); }
.pipe-expansion { stroke: var(--pipe-expansion-color); }

/* Animação de fluxo (Direcionada e Colorida) */
.flow-animation {
    fill: none !important;
    stroke-dasharray: 25, 20; /* Segmentos maiores */
    animation: flow 0.8s linear infinite; /* Fluxo um pouco mais rápido */
    opacity: 0.8; /* Aumentado de 0.4 para 0.8 */
    stroke-width: 6px;
    filter: drop-shadow(0 0 2px rgba(255,255,255,0.3)); /* Brilho sutil seguro */
}

@keyframes flow {
    from { stroke-dashoffset: 35; }
    to { stroke-dashoffset: 0; }
}

/* ================= VENTILAÇÃO (FANS) ================= */
.fan-spin {
    transform-origin: center;
    transform-box: fill-box;
}

.fan-clickable {
    cursor: pointer;
    transition: filter 0.2s ease;
}

.fan-clickable:hover {
    filter: brightness(1.3) drop-shadow(0 0 10px var(--accent-blue));
}

/* Feedback de Clique */
.device-feedback {
    animation: ripple 0.5s ease-out;
}

@keyframes ripple {
    0% { filter: brightness(3) blur(0px); opacity: 1; }
    100% { filter: brightness(1) blur(5px); opacity: 0; }
}


/* Botões de Operação Sidebar */
.operation-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
    margin-top: 10px;
}

.btn-operation {
    background: #1E293B;
    border: 1px solid #334155;
    color: var(--text-muted);
    padding: 10px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 13px;
    font-family: var(--font-ui);
}

.btn-operation:hover {
    border-color: #4A5568;
    background: #2D3748;
}

.btn-operation.active {
    border-color: var(--accent-blue);
    color: white;
    box-shadow: 0 0 10px rgba(0, 229, 255, 0.1);
}

.status-led {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #475569; /* OFF */
    box-shadow: inset 0 0 4px rgba(0,0,0,0.5);
    transition: all 0.3s ease;
}

.btn-operation.active .status-led {
    background: #00FF66; /* ON */
    box-shadow: 0 0 8px rgba(0, 255, 102, 0.6);
}

/* ================= COMPONENT LABELS ================= */
.circuit-label {
    fill: var(--text-muted);
    font-family: var(--font-ui);
    font-size: 8px;
    font-weight: 700;
    letter-spacing: 0.5px;
    text-anchor: middle;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    pointer-events: none;
    opacity: 0.6;
}

/* Hover effect for translated labels */
.device-clickable:hover .circuit-label,
.fan-clickable:hover .circuit-label {
    fill: #FFF;
    opacity: 1;
    font-size: 8.5px;
    text-shadow: 0 0 10px rgba(0, 229, 255, 0.8);
}

/* ================= INSTRUMENTAÇÃO (SENSORS) ================= */
foreignObject { 
    pointer-events: none; /* Não bloqueia o que está por trás */
}

foreignObject.active {
    pointer-events: auto; /* Permite interação apenas quando aberto */
}

.sensor-dashboard {
    background: rgba(15, 23, 42, 0.9);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    padding: 10px;
    pointer-events: none;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.6);
    opacity: 0;
    visibility: hidden;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    pointer-events: none; /* Bloquear cliques enquanto oculto */
    z-index: 100;
}

.inst-icon, .pressostat-icon {
    cursor: pointer;
    pointer-events: all;
}

/* Painéis Interativos Específicos (Pressostatos) */
.pressostat-dashboard {
    width: 140px;
    height: auto;
    padding: 12px;
    background: rgba(15, 23, 42, 0.95);
    border: 2px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 10px 30px rgba(0,0,0,0.8);
    pointer-events: auto !important; /* Permitir interação com inputs */
}

.pressostat-dashboard::after {
    content: '';
    position: absolute;
    top: -10px;
    left: -10px;
    right: -10px;
    bottom: -10px;
    z-index: -1;
}

.press-control-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-top: 10px;
}

.press-input-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.press-input-group label {
    font-size: 8px;
    color: var(--text-muted);
    font-weight: 800;
}

.press-input {
    background: #000;
    border: 1px solid rgba(255,255,255,0.2);
    color: var(--accent-blue);
    font-family: var(--font-digital);
    font-size: 14px;
    padding: 4px;
    width: 100%;
    border-radius: 4px;
    text-align: center;
    outline: none;
}

.pressostat-dashboard.dashboard-high .press-input {
    color: var(--accent-red);
}

.press-unit {
    font-size: 8px;
    color: var(--text-muted);
    text-align: right;
    margin-top: 1px;
}

.press-bypass-row {
    margin-top: 12px;
    border-top: 1px solid rgba(255,255,255,0.05);
    padding-top: 8px;
}

.press-bypass-btn {
    width: 100%;
    background: #1E293B;
    border: 1px solid #334155;
    color: var(--text-main);
    padding: 6px;
    border-radius: 4px;
    font-size: 9px;
    font-weight: 800;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.2s;
}

.press-bypass-btn:hover {
    background: #334155;
    border-color: var(--accent-blue);
}

.bypass-led {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #4A5568;
    box-shadow: inset 0 0 3px rgba(0,0,0,0.5);
}

.bypass-active .bypass-led {
    background: #EF4444;
    box-shadow: 0 0 8px #EF4444;
}

.press-footer {
    margin-top: 10px;
    text-align: center;
}

.press-footer small {
    font-size: 7px;
    color: var(--accent-green);
    opacity: 0.6;
    letter-spacing: 0.5px;
}

/* Mostrar Dashboard apenas quando o container tiver a classe .active */
foreignObject.active .sensor-dashboard {
    opacity: 1 !important;
    visibility: visible !important;
    transform: translateY(0) !important;
    pointer-events: auto !important; /* Permitir cliques quando visível */
}

.sensor-row {
    display: flex;
    flex-direction: column;
    margin-bottom: 8px;
}

.sensor-row:last-child {
    margin-bottom: 0;
}

.sensor-label {
    font-size: 8px;
    text-transform: uppercase;
    color: var(--text-muted);
    letter-spacing: 0.5px;
    margin-bottom: 2px;
}

.sensor-reading {
    display: flex;
    align-items: baseline;
    gap: 4px;
}

.sensor-value {
    font-family: var(--font-digital);
    font-size: 18px;
    color: white;
}

.sensor-unit {
    font-size: 10px;
    color: var(--text-muted);
}

/* Diferenciação de Cores */
.dashboard-low .sensor-value { color: #00A2FF; }  /* Azul */
.dashboard-high .sensor-value { color: #FF3366; } /* Vermelho */
.dashboard-temp .sensor-value { color: #FFA500; } /* Laranja */

/* Ícones de Instrumentos */
.inst-icon {
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.5));
}

/* Sombras Suaves para Componentes (CSS é mais estável que SVG Filters) */
#pos_evaporator, #pos_condenser, #pos_compressor, #pos_valve {
    filter: drop-shadow(0 10px 15px rgba(0,0,0,0.4));
    transition: filter 0.3s ease;
}

#pos_evaporator:hover, #pos_condenser:hover, #pos_compressor:hover {
    filter: drop-shadow(0 15px 25px rgba(0,0,0,0.6));
}

.inst-connection {
    stroke: rgba(255,255,255,0.2);
    stroke-width: 1;
    stroke-dasharray: 2, 2;
}

/* ================= SIDEBAR PREMIUM COCKPIT ================= */
.sidebar-content {
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding: 2px;
}

.sidebar-card {
    background: rgba(21, 26, 34, 0.45);
    backdrop-filter: blur(12px) saturate(180%);
    -webkit-backdrop-filter: blur(12px) saturate(180%);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 16px;
    padding: 16px;
    box-shadow: 
        0 4px 24px -1px rgba(0, 0, 0, 0.2),
        inset 0 0 0 1px rgba(255, 255, 255, 0.05);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar-card:hover {
    border-color: rgba(0, 229, 255, 0.3);
    background: rgba(21, 26, 34, 0.55);
    transform: translateY(-2px);
    box-shadow: 
        0 12px 40px -12px rgba(0, 0, 0, 0.4),
        0 0 15px rgba(0, 229, 255, 0.1);
}

.sidebar-card.mini { padding: 12px; }

.card-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 15px;
    opacity: 0.7;
}

.card-icon { font-size: 14px; }

.card-header h3 {
    font-family: var(--font-ui);
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    color: var(--text-muted);
    margin: 0;
}

/* ================= POWER CONTROL ================= */
.power-control {
    display: flex;
    align-items: center;
    gap: 15px;
    background: rgba(15, 23, 42, 0.5);
    border-radius: 12px;
    padding: 12px;
    cursor: pointer;
    border: 1px solid rgba(255, 255, 255, 0.05);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.power-btn-inner {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #1e293b;
    color: #475569;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.3);
    border: 1px solid rgba(255,255,255,0.05);
    transition: all 0.4s ease;
}

.power-label {
    display: flex;
    flex-direction: column;
}

.power-label span {
    font-family: var(--font-digital);
    font-size: 18px;
    letter-spacing: 1px;
    line-height: 1.2;
}

.power-label small {
    font-size: 9px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    opacity: 0.5;
}

/* Estados Power */
.power-control.standby .power-btn-inner {
    color: var(--accent-red);
    box-shadow: 0 0 15px rgba(239, 68, 68, 0.1);
}

.power-control.running {
    border-color: rgba(16, 185, 129, 0.3);
    background: rgba(16, 185, 129, 0.05);
}

.power-control.running .power-btn-inner {
    background: var(--accent-green);
    color: #064e3b;
    box-shadow: 0 0 20px rgba(16, 185, 129, 0.4);
    animation: pulse-power 2s infinite;
}

@keyframes pulse-power {
    0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.4); }
    70% { transform: scale(1.02); box-shadow: 0 0 0 10px rgba(16, 185, 129, 0); }
    100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

/* ================= TELEMETRY V2 / 3.0 GAUGES ================= */
.telemetry-grid-v2 {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.gauge-container {
    width: 100%;
    height: 4px;
    background: rgba(0,0,0,0.3);
    border-radius: 2px;
    margin: 8px 0;
    overflow: hidden;
}

.gauge-fill {
    height: 100%;
    width: 0%;
    border-radius: 2px;
    transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.gauge-container.high .gauge-fill {
    background: linear-gradient(90deg, var(--accent-red), #F43F5E);
    box-shadow: 0 0 8px rgba(239, 68, 68, 0.3);
}

.gauge-container.low .gauge-fill {
    background: linear-gradient(90deg, var(--accent-blue), #38BDF8);
    box-shadow: 0 0 8px rgba(0, 229, 255, 0.3);
}

.tel-group {
    background: rgba(15, 23, 42, 0.3);
    border-radius: 10px;
    padding: 12px;
    border-left: 3px solid #4a5568;
}

.tel-group.high { border-left-color: var(--accent-red); }
.tel-group.low { border-left-color: var(--accent-blue); }

.tel-group-label {
    font-size: 9px;
    font-weight: 700;
    color: var(--text-muted);
    margin-bottom: 4px;
}

.tel-item {
    display: flex;
    align-items: baseline;
    gap: 6px;
}

.tel-unit { font-size: 10px; opacity: 0.5; font-weight: 500; }

.tel-value-lg {
    font-family: var(--font-digital);
    font-size: 24px;
    color: white;
}

.tel-item-sub {
    font-size: 11px;
    margin-top: 4px;
    color: rgba(255,255,255,0.6);
    display: flex;
    justify-content: space-between;
}

.tel-item-sub span:last-child {
    font-weight: 700;
    color: #cbd5e1;
}

/* SH/SC Premium */
.sh-sc-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.perf-item {
    background: rgba(15, 23, 42, 0.3);
    padding: 10px;
    border-radius: 8px;
    text-align: center;
}

.perf-item label {
    font-size: 8px;
    text-transform: uppercase;
    display: block;
    margin-bottom: 5px;
    opacity: 0.5;
}

.perf-value {
    font-family: var(--font-digital);
    font-size: 18px;
    color: var(--accent-blue);
}

/* ================= OPERAÇÃO DE COMPONENTES ================= */
.operation-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* Grids de Parâmetros de Automação */
.param-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    padding: 10px;
    background: rgba(0,0,0,0.25);
    border-radius: 8px;
    margin-top: 5px;
}

.param-input-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.param-input-group label {
    font-size: 9px;
    color: #94a3b8;
    text-transform: uppercase;
    font-weight: 600;
}

.param-input-group .input-wrapper {
    display: flex;
    align-items: center;
    background: #0f172a;
    border: 1px solid #1e293b;
    border-radius: 6px;
    padding-right: 8px;
}

.param-input-group input {
    background: transparent;
    border: none;
    color: #38bdf8;
    padding: 6px 8px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 14px;
    width: 100%;
    outline: none;
}

.param-input-group .unit {
    font-size: 10px;
    color: #475569;
    font-weight: bold;
}


.action-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 12px;
    background: rgba(15, 23, 42, 0.3);
    border-radius: 10px;
    cursor: pointer;
    border: 1px solid transparent;
    transition: all 0.2s ease;
}

.action-row:hover {
    background: rgba(15, 23, 42, 0.5);
    border-color: rgba(255,255,255,0.05);
}

.action-info {
    display: flex;
    flex-direction: column;
}

.action-info span { font-size: 12px; font-weight: 600; }
.action-info small { font-size: 9px; opacity: 0.4; }

.status-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
}

.status-led {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #475569;
    box-shadow: inset 0 1px 1px rgba(0,0,0,0.5);
}

.action-row.active .status-led {
    background: var(--accent-green);
    box-shadow: 0 0 8px var(--accent-green);
}

/* ================= ALERTS V2 ================= */
#system-alerts {
    margin-top: 10px;
    margin-bottom: 15px;
    animation: slideDown 0.3s ease;
}

.alert-content {
    background: rgba(239, 68, 68, 0.15);
    border: 1px solid rgba(239, 68, 68, 0.3);
    padding: 10px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    gap: 10px;
    color: #fca5a5;
    font-size: 11px;
    font-weight: 700;
}

.alert-icon {
    font-size: 14px;
    animation: blink 1s infinite;
}

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

@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

/* Botão de Reset V2 */
.btn-reset-v2 {
    width: 100%;
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.02);
    color: var(--text-muted);
    padding: 8px;
    border-radius: 8px;
    font-size: 11px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-reset-v2:hover {
    background: rgba(255,255,255,0.1);
    color: white;
}

.alert-hidden { display: none !important; }

/* ================= SOLENOID & LEDS ================= */
#solenoid-led { transition: fill 0.3s ease; }
.led-off { stroke: rgba(0,0,0,0.5); }

/* Cor de tubulação específica p/ zona de expansão */
.pipe-expansion-zone {
    transition: stroke 1.5s ease;
}

/* ================= HUD ON-CANVAS ================= */
.hud-label {
    background: rgba(15, 23, 42, 0.85);
    backdrop-filter: blur(4px);
    border: 1.5px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    padding: 8px 12px;
    color: white;
    font-family: var(--font-digital);
    display: flex;
    flex-direction: column;
    align-items: center;
    box-shadow: 0 4px 15px rgba(0,0,0,0.5);
    pointer-events: none;
    user-select: none;
}

.hud-label.evap { border-left: 3px solid var(--accent-blue); }
.hud-label.cond { border-left: 3px solid var(--accent-red); }

.hud-main {
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 2px;
    display: flex;
    align-items: baseline;
    gap: 4px;
}

.hud-main small { font-size: 10px; opacity: 0.5; }

.hud-sub {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
}

/* ================= TOP ALARM MATRIX ================= */
.canvas-alerts-top {
    position: absolute;
    top: 20px;
    left: 20px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    z-index: 100;
    pointer-events: none;
}

.canvas-alert-item {
    background: rgba(239, 68, 68, 0.15);
    border: 1px solid rgba(239, 68, 68, 0.4);
    backdrop-filter: blur(10px);
    padding: 8px 16px;
    border-radius: 20px;
    color: #fca5a5;
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 1px;
    display: flex;
    align-items: center;
    gap: 8px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.3);
    animation: slideInLeft 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.canvas-alert-item .dot {
    width: 8px;
    height: 8px;
    background: #ef4444;
    border-radius: 50%;
    box-shadow: 0 0 10px #ef4444;
    animation: alert-blink 1s infinite alternate;
}

.canvas-alert-item.hidden {
    display: none;
}

@keyframes slideInLeft {
    from { opacity: 0; transform: translateX(-20px); }
    to { opacity: 1; transform: translateX(0); }
}

@keyframes alert-blink {
    from { opacity: 1; transform: scale(1); }
    to { opacity: 0.4; transform: scale(0.8); }
}

@keyframes compressor-vibrate {
    0% { transform: translate(0, 0); }
    25% { transform: translate(0.3px, 0.3px); }
    50% { transform: translate(0, 0.5px); }
    75% { transform: translate(-0.3px, 0.3px); }
    100% { transform: translate(0, 0); }
}

.vibrating {
    animation: compressor-vibrate 0.1s linear indefinite;
    /* Usaremos indefinite mas como a classe é alternada no JS, o efeito é controlado */
}

/* Forçamos a repetição infinita se a classe estiver presente */
#comp_compressor.vibrating {
    animation: compressor-vibrate 0.1s linear infinite;
}

/* ================= PAINEL DE CONTROLE CAREL IJ ================= */
#carel-display path {
    stroke: #1A202C; /* Cor 'off' */
    stroke-width: 8;
    stroke-linecap: round;
    transition: stroke 0.2s ease, filter 0.2s ease;
    fill: none;
}

#carel-display path.active-digit {
    stroke: #00FF66; /* Cor 'on' - Verde Carel */
    filter: drop-shadow(0 0 5px rgba(0,255,102,0.6));
}

#seg-dot.active-digit {
    fill: #00FF66;
    filter: drop-shadow(0 0 5px rgba(0,255,102,0.6));
}

/* Ícones Carel */
#carel-ico-cool.active {
    stroke: #00FF66;
    filter: drop-shadow(0 0 3px #00FF66);
}

/* Chave Seletora */
#panel-switch-knob {
    transform-origin: center;
    transform-box: fill-box; /* Garante que o eixo seja o próprio elemento */
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

#panel-switch-knob.switch-on {
    transform: rotate(90deg);
}

#panel-switch-knob.switch-off {
    transform: rotate(0deg);
}

/* ================= SELETOR DE COMANDO (OFF/MAN/AUTO) ================= */
.system-selector {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    background: rgba(0, 0, 0, 0.4);
    padding: 6px;
    border-radius: 12px;
    margin-bottom: 20px;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.mode-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 12px 4px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(30, 41, 59, 0.2);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    color: var(--text-muted);
}

.mode-btn:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.15);
}

.mode-btn-led {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #475569;
    box-shadow: inset 0 2px 3px rgba(0,0,0,0.4);
    transition: all 0.3s ease;
}

.mode-label {
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 1px;
    text-transform: uppercase;
}

/* Estado Ativo - OFF */
.mode-btn.mode-off.active {
    background: rgba(239, 68, 68, 0.08);
    border-color: rgba(239, 68, 68, 0.4);
    color: #FCA5A5;
}
.mode-btn.mode-off.active .mode-btn-led {
    background: #EF4444;
    box-shadow: 0 0 10px #EF4444;
}

/* Estado Ativo - MANUAL */
.mode-btn.mode-man.active {
    background: rgba(245, 158, 11, 0.08);
    border-color: rgba(245, 158, 11, 0.4);
    color: #FCD34D;
}
.mode-btn.mode-man.active .mode-btn-led {
    background: #F59E0B;
    box-shadow: 0 0 10px #F59E0B;
}

/* Estado Ativo - AUTO */
.mode-btn.mode-auto.active {
    background: rgba(34, 197, 94, 0.08);
    border-color: rgba(34, 197, 94, 0.4);
    color: #86EFAC;
}
.mode-btn.mode-auto.active .mode-btn-led {
    background: #22C55E;
    box-shadow: 0 0 10px #22C55E;
}

/* ================= ACTIVATOR QUICK ROW (NOVO) ================= */
.activator-quick-row {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    margin-bottom: 20px;
}

.quick-toggle-btn {
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 10px;
    padding: 10px 4px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.quick-toggle-btn::after {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: radial-gradient(circle at center, rgba(255,255,255,0.05) 0%, transparent 70%);
    opacity: 0;
    transition: opacity 0.3s;
}

.quick-toggle-btn:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.12);
    transform: translateY(-1px);
}

.quick-toggle-btn:hover::after { opacity: 1; }

.quick-toggle-btn.active {
    background: rgba(0, 255, 102, 0.08);
    border-color: rgba(0, 255, 102, 0.3);
    box-shadow: 0 0 15px rgba(0, 255, 102, 0.1);
}

.toggle-led {
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: #334155;
    box-shadow: inset 0 1px 2px rgba(0,0,0,0.8);
    transition: all 0.3s ease;
}

.quick-toggle-btn.active .toggle-led {
    background: var(--accent-green);
    box-shadow: 0 0 8px var(--accent-green), 0 0 15px rgba(0, 255, 102, 0.4);
}

.toggle-label {
    font-size: 8px;
    font-weight: 800;
    color: var(--text-muted);
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

.quick-toggle-btn.active .toggle-label {
    color: var(--accent-green);
    text-shadow: 0 0 8px rgba(0, 255, 102, 0.3);
}

/* ================= AUTOMATION ROWS (NOVO) ================= */
.automation-rows {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.auto-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
    background: rgba(0, 0, 0, 0.25);
    padding: 14px;
    border-radius: 14px;
    border: 1px solid rgba(255, 255, 255, 0.03);
    transition: all 0.3s ease;
}

.auto-row:hover {
    background: rgba(0, 0, 0, 0.3);
    border-color: rgba(255, 255, 255, 0.06);
}

.auto-row.full-row {
    grid-template-columns: 1fr 1fr 60px;
    align-items: flex-end;
}

.flex-center {
    display: flex;
    align-items: center;
    justify-content: center;
}

.no-border {
    background: transparent !important;
    border: none !important;
}

/* ================= TELEMETRY INTEGRATED (MONITORAMENTO) ================= */
.tel-group {
    padding: 16px;
    border-radius: 14px;
    border-left-width: 4px;
}

.tel-item-sub.highlight {
    background: rgba(255, 51, 102, 0.08);
    padding: 8px 10px;
    border-radius: 10px;
    border: 1px solid rgba(255, 51, 102, 0.15);
    margin-top: 10px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}


.system-mode-status {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px;
    background: rgba(15, 23, 42, 0.4);
    border-radius: 12px;
    font-size: 11px;
    font-weight: 800;
    color: var(--text-muted);
    border: 1px solid rgba(255, 255, 255, 0.03);
    letter-spacing: 0.5px;
}

.status-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #334155;
    box-shadow: 0 0 2px rgba(0,0,0,0.5);
}

.mode-off.active ~ .system-mode-status .status-dot { background: #EF4444; box-shadow: 0 0 10px #EF4444, 0 0 20px rgba(239, 68, 68, 0.4); }
.mode-man.active ~ .system-mode-status .status-dot { background: #F59E0B; box-shadow: 0 0 10px #F59E0B, 0 0 20px rgba(245, 158, 11, 0.4); }
.mode-auto.active ~ .system-mode-status .status-dot { background: #22C55E; box-shadow: 0 0 10px #22C55E, 0 0 20px rgba(34, 197, 94, 0.4); }

/* ================= SIMULAÇÃO TEMPORAL (NOVO) ================= */
.timer-display-v2 {
    display: grid;
    grid-template-columns: 1.5fr 1fr;
    gap: 12px;
    margin-bottom: 20px;
}

.clock-box, .cycle-box {
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 12px;
    padding: 12px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    box-shadow: inset 0 2px 10px rgba(0,0,0,0.4);
}

.clock-box span {
    font-family: var(--font-digital);
    font-size: 28px;
    color: var(--accent-blue);
    text-shadow: 0 0 15px rgba(0, 229, 255, 0.4);
    line-height: 1;
}

.cycle-box span {
    font-family: var(--font-digital);
    font-size: 28px;
    color: var(--accent-green);
    text-shadow: 0 0 15px rgba(0, 255, 102, 0.4);
    line-height: 1;
}

.clock-box small, .cycle-box small {
    font-size: 8px;
    font-weight: 800;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-top: 6px;
}

.speed-selector {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.speed-selector label {
    font-size: 10px;
    font-weight: 800;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.speed-buttons {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 6px;
}

.speed-btn {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.08);
    color: var(--text-muted);
    padding: 8px 0;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.speed-btn:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.2);
    color: var(--text-main);
}

.speed-btn.active {
    background: var(--accent-blue);
    border-color: var(--accent-blue);
    color: #0F172A;
    box-shadow: 0 0 15px rgba(0, 229, 255, 0.3);
}

.floating-show-chart-v2 {
    pointer-events: auto;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(0, 229, 255, 0.3);
    color: var(--accent-blue);
    padding: 6px 16px;
    border-radius: 20px;
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 1px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
    display: flex;
    align-items: center;
    gap: 8px;
}

.floating-show-chart-v2:hover {
    background: var(--accent-blue);
    color: #0F172A;
    border-color: var(--accent-blue);
    transform: translateY(-2px);
}

/* ================= NOVOS CONTROLES DE GRÁFICO ================= */
.trend-chart-card .card-header {
    display: flex;
    align-items: center;
    padding: 10px 16px;
    height: 58px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
}

/* Sidebar Top Controls */
.sidebar-fixed-header {
    background: rgba(15, 23, 42, 0.4);
    border-bottom: 1px solid var(--border-color);
    padding: 16px 0;
    backdrop-filter: blur(10px);
}

.sidebar-fixed-header .sim-top-card,
.sidebar-fixed-header .alarm-card {
    margin: 0 16px;
}

.sidebar-fixed-header .sim-top-card {
    margin-bottom: 10px;
}

.sim-top-card {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.05);
    margin: 16px 16px 10px 16px;
    padding: 12px;
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.sim-time-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

#sim-clock {
    font-family: var(--font-digital);
    font-size: 20px;
    color: var(--accent-blue);
    flex: 1;
    line-height: 1;
}

.btn-reset-mini {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 14px;
    padding: 4px;
    opacity: 0.5;
    transition: all 0.2s;
    display: flex;
    align-items: center;
}
.btn-reset-mini:hover { opacity: 1; color: var(--accent-blue); }

.speed-selector-sidebar {
    display: flex;
    gap: 4px;
}

.speed-selector-sidebar .speed-btn {
    flex: 1;
    padding: 4px 0;
    font-size: 9px;
    border-radius: 4px;
    min-width: auto;
}

.footer-left-controls {
    position: fixed;
    bottom: 25px;
    left: 30px;
    display: flex;
    justify-content: flex-start;
    pointer-events: none;
    z-index: 1000;
}

.chart-header-main {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.chart-header-main h3 {
    margin: 0;
    font-size: 11px;
    letter-spacing: 1px;
    color: var(--text-muted);
}

#chart-sim-clock {
    font-family: var(--font-digital);
    font-size: 16px;
    color: var(--accent-blue);
    line-height: 1;
}

.chart-controls {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-left: auto;
}

.speed-selector-mini {
    display: flex;
    gap: 4px;
    background: rgba(0, 0, 0, 0.2);
    padding: 4px;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.speed-selector-mini .speed-btn {
    padding: 2px 8px;
    font-size: 10px;
    border-radius: 5px;
    min-width: 32px;
}

.btn-icon-v2 {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--text-muted);
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-icon-v2:hover {
    background: rgba(239, 68, 68, 0.1);
    color: #EF4444;
    border-color: rgba(239, 68, 68, 0.2);
}

/* Floating Show Chart Button */
.floating-show-chart {
    position: fixed;
    bottom: 25px;
    right: 360px;
    background: rgba(15, 23, 42, 0.85);
    backdrop-filter: blur(12px);
    border: 1px solid var(--accent-blue);
    color: var(--accent-blue);
    padding: 10px 22px;
    border-radius: 30px;
    font-size: 12px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 1px;
    cursor: pointer;
    z-index: 1000;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4), 0 0 15px rgba(0, 229, 255, 0.2);
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    display: flex;
    align-items: center;
    gap: 8px;
}

.floating-show-chart:hover {
    background: var(--accent-blue);
    color: #0F172A;
    transform: translateY(-3px) scale(1.05);
    box-shadow: 0 12px 40px rgba(0, 229, 255, 0.4);
}

.floating-show-chart span {
    position: relative;
    top: 1px;
}



/* ================= DEFROST (DEGELO) STYLES ================= */
#card-defrost.defrost-active {
    border-color: #3B82F6;
    background: rgba(59, 130, 246, 0.05);
    box-shadow: 0 0 20px rgba(59, 130, 246, 0.2);
}

#card-defrost.defrost-active h3 {
    color: #3B82F6;
    text-shadow: 0 0 10px rgba(59, 130, 246, 0.4);
}

@keyframes pulse {
    0% { opacity: 0.6; transform: scale(0.95); }
    50% { opacity: 1; transform: scale(1); }
    100% { opacity: 0.6; transform: scale(0.95); }
}

.status-badge-mini {
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
