/* -------------------------------------------------------------
   FOLHA DE ESTILO PRINCIPAL - SIMULADOR DE GOLPE DE ARÍETE
   Design: Dark Mode Premium, Glassmorphism, Neon Accents
   ------------------------------------------------------------- */

/* Definição de Variáveis Globais (Design Tokens) */
:root {
    --bg-base: #070a13;             /* Fundo da página (azul escuro quase preto) */
    --bg-surface: #0f1524;          /* Fundo dos cards (azul profundo) */
    --bg-surface-elevated: #182239; /* Fundo de elementos em foco ou inputs */
    
    --text-primary: #f8fafc;        /* Texto principal (quase branco) */
    --text-secondary: #94a3b8;      /* Texto secundário (cinza azulado) */
    --text-muted: #64748b;          /* Texto desabilitado ou menor relevância */

    --color-primary: #00f0ff;       /* Ciano Neon (água e pressões normais) */
    --color-primary-rgb: 0, 240, 255;
    --color-accent: #ff0055;        /* Magenta Neon (onda de choque / alta pressão) */
    --color-accent-rgb: 255, 0, 85;

    --color-success: #10b981;       /* Verde para estados seguros e estáveis */
    --color-warning: #f59e0b;       /* Laranja para alertas */
    --color-danger: #ef4444;        /* Vermelho para falha/rompimento */
    
    --border-color: rgba(255, 255, 255, 0.08); /* Borda padrão bem sutil */
    --border-highlight: rgba(0, 240, 255, 0.3); /* Borda em foco */

    --font-sans: 'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    --font-mono: 'JetBrains Mono', SFMono-Regular, Consolas, monospace;

    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.4);
    --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.5);
    --shadow-lg: 0 16px 40px rgba(0, 0, 0, 0.6);
    --shadow-glow: 0 0 15px rgba(0, 240, 255, 0.25);
    --shadow-glow-danger: 0 0 20px rgba(255, 0, 85, 0.4);
}

/* Reset básico e configurações de box-sizing */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    background-color: var(--bg-base);
    color: var(--text-primary);
    font-family: var(--font-sans);
    line-height: 1.5;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
}

/* -------------------------------------------------------------
   HEADER DA APLICAÇÃO
   ------------------------------------------------------------- */
.app-header {
    background: linear-gradient(180deg, rgba(15, 21, 36, 0.8) 0%, rgba(7, 10, 19, 0) 100%);
    backdrop-filter: blur(8px);
    border-bottom: 1px solid var(--border-color);
    padding: 1.5rem 2rem;
}

.header-container {
    max-width: 1600px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}.header-top-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    flex-wrap: wrap;
    gap: 1rem;
}

.logo-area {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.partner-logo-area {
    display: flex;
    align-items: center;
}

.partner-logo {
    height: 40px;
    width: auto;
    opacity: 0.85;
    transition: all 0.3s ease;
    filter: drop-shadow(0 0 8px rgba(255, 255, 255, 0.15));
}

.partner-logo:hover {
    opacity: 1;
    filter: drop-shadow(0 0 12px rgba(255, 255, 255, 0.3));
}
/* Ponto pulsante simulando fluxo ou pressão no header */
.pulse-dot {
    width: 10px;
    height: 10px;
    background-color: var(--color-primary);
    border-radius: 50%;
    box-shadow: 0 0 8px var(--color-primary);
    animation: pulse 2s infinite ease-in-out;
}

.app-header h1 {
    font-size: 1.8rem;
    font-weight: 800;
    letter-spacing: 2px;
    background: linear-gradient(90deg, #fff 0%, var(--color-primary) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.badge {
    background-color: rgba(0, 240, 255, 0.1);
    border: 1px solid rgba(0, 240, 255, 0.3);
    color: var(--color-primary);
    padding: 0.15rem 0.6rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
}

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

/* -------------------------------------------------------------
   CONTAINER PRINCIPAL E LAYOUT GRID (DUE COLUMNS)
   ------------------------------------------------------------- */
.app-container {
    max-width: 1600px;
    width: 100%;
    margin: 0 auto;
    padding: 2rem;
    flex: 1;
    display: grid;
    grid-template-columns: 420px 1fr;
    gap: 2rem;
    align-items: start;
}

@media (max-width: 1024px) {
    .app-container {
        grid-template-columns: 1fr;
    }
}

/* -------------------------------------------------------------
   ESTILOS DE CARDS (PAINÉIS)
   ------------------------------------------------------------- */
.card {
    background-color: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 1.5rem;
    box-shadow: var(--shadow-md);
    margin-bottom: 2rem;
    transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.card:hover {
    border-color: rgba(255, 255, 255, 0.12);
}

.card h2 {
    font-size: 1.15rem;
    font-weight: 600;
    margin-bottom: 1.25rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: #ffffff;
}

.card .icon {
    font-size: 1.3rem;
}

/* -------------------------------------------------------------
   PAINEL DE CONTROLE (COLUNA ESQUERDA)
   ------------------------------------------------------------- */
.control-panel {
    display: flex;
    flex-direction: column;
}

/* Estilo para seletores e inputs */
.form-select, .form-input {
    width: 100%;
    background-color: var(--bg-surface-elevated);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 0.75rem 1rem;
    border-radius: 8px;
    font-family: var(--font-sans);
    font-size: 0.95rem;
    outline: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.form-select:focus, .form-input:focus {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 2px rgba(0, 240, 255, 0.15);
}

/* Estilo para sliders customizados */
.input-group {
    margin-bottom: 1.25rem;
}

.label-val {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.4rem;
}

.label-val label {
    font-size: 0.9rem;
    color: var(--text-secondary);
    font-weight: 400;
}

.value-display {
    font-family: var(--font-mono);
    font-weight: 700;
    color: var(--color-primary);
    font-size: 0.95rem;
    background-color: rgba(0, 240, 255, 0.05);
    padding: 0.1rem 0.5rem;
    border-radius: 4px;
    border: 1px solid rgba(0, 240, 255, 0.1);
}

/* Sliders estéticos em Dark Mode */
.form-slider {
    -webkit-appearance: none;
    width: 100%;
    height: 6px;
    background: var(--bg-surface-elevated);
    border-radius: 9999px;
    outline: none;
    transition: background 0.2s;
}

.form-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--color-primary);
    cursor: pointer;
    box-shadow: 0 0 6px var(--color-primary);
    transition: transform 0.1s ease, background-color 0.2s;
}

.form-slider::-webkit-slider-thumb:hover {
    transform: scale(1.2);
    background: #ffffff;
}

/* -------------------------------------------------------------
   PAINEL DE RESULTADOS HIDRÁULICOS (ESTÁTICOS)
   ------------------------------------------------------------- */
.results-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.metric-box {
    background-color: var(--bg-surface-elevated);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 0.75rem;
    text-align: center;
}

.metric-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 0.25rem;
}

.metric-value {
    font-family: var(--font-mono);
    font-size: 1.3rem;
    font-weight: 700;
    color: #ffffff;
}

.metric-unit {
    font-size: 0.7rem;
    color: var(--text-muted);
}

/* Destaque para pressão máxima */
.metric-box:nth-child(4) .metric-value {
    color: var(--color-primary);
    text-shadow: 0 0 10px rgba(0, 240, 255, 0.3);
}

.alert-box {
    background-color: rgba(255, 255, 255, 0.03);
    border-left: 4px solid var(--text-muted);
    padding: 0.6rem 0.8rem;
    border-radius: 4px;
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 1rem;
}

/* Indicador de Segurança */
.safety-indicator {
    padding: 0.75rem;
    border-radius: 10px;
    margin-bottom: 1.25rem;
    text-align: left;
    font-size: 0.85rem;
    border: 1px solid transparent;
    transition: background-color 0.3s ease, border-color 0.3s ease;
}

.safety-status {
    font-weight: 600;
    margin-bottom: 0.15rem;
}

.safety-desc {
    color: var(--text-secondary);
    font-size: 0.8rem;
}

/* Classes dinâmicas para o Status de Segurança */
.status-safe {
    background-color: rgba(16, 185, 129, 0.08);
    border-color: rgba(16, 185, 129, 0.25);
    color: var(--color-success);
}
.status-safe strong {
    color: #10b981;
}

.status-warning {
    background-color: rgba(245, 158, 11, 0.08);
    border-color: rgba(245, 158, 11, 0.25);
    color: var(--color-warning);
}
.status-warning strong {
    color: #f59e0b;
}

.status-danger {
    background-color: rgba(239, 68, 68, 0.08);
    border-color: rgba(239, 68, 68, 0.25);
    color: var(--color-danger);
    animation: glow-danger 2.5s infinite alternate;
}
.status-danger strong {
    color: #ef4444;
}

/* -------------------------------------------------------------
   BOTÕES E COMPONENTES DE AÇÃO
   ------------------------------------------------------------- */
.action-buttons {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 0.75rem;
    margin-bottom: 1.25rem;
}

.btn {
    font-family: var(--font-sans);
    font-size: 0.95rem;
    font-weight: 600;
    padding: 0.75rem 1rem;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    transition: all 0.2s ease;
}

.btn-primary {
    background-color: var(--color-primary);
    color: #000000;
    box-shadow: var(--shadow-glow);
}

.btn-primary:hover {
    background-color: #ffffff;
    box-shadow: 0 0 25px rgba(255, 255, 255, 0.4);
    transform: translateY(-1px);
}

.btn-secondary {
    background-color: var(--bg-surface-elevated);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background-color: rgba(255, 255, 255, 0.08);
    border-color: var(--text-muted);
}

.btn-success {
    background-color: rgba(16, 185, 129, 0.15);
    color: var(--color-success);
    border: 1px solid rgba(16, 185, 129, 0.3);
    white-space: nowrap;
}

.btn-success:hover {
    background-color: var(--color-success);
    color: #ffffff;
}

.btn-danger-link {
    background: transparent;
    border: none;
    color: var(--color-danger);
    font-size: 0.8rem;
    cursor: pointer;
    text-decoration: underline;
    opacity: 0.7;
    transition: opacity 0.2s;
}

.btn-danger-link:hover {
    opacity: 1;
}

.save-preset-container {
    display: flex;
    gap: 0.5rem;
    border-top: 1px solid var(--border-color);
    padding-top: 1.25rem;
    margin-top: 0.5rem;
}

.save-preset-container .form-input {
    flex: 1;
    font-size: 0.85rem;
    padding: 0.6rem;
}

/* -------------------------------------------------------------
   PAINEL DE VISUALIZAÇÃO E ANIMAÇÃO (COLUNA DIREITA)
   ------------------------------------------------------------- */
.visualization-panel {
    display: flex;
    flex-direction: column;
}

/* Cabeçalhos especiais com Badges de Estado */
.card-header-with-status {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.card-header-with-status h2 {
    margin-bottom: 0;
}

.state-badge {
    padding: 0.2rem 0.6rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.state-idle {
    background-color: var(--bg-surface-elevated);
    color: var(--text-muted);
    border: 1px solid var(--border-color);
}

.state-running {
    background-color: rgba(0, 240, 255, 0.1);
    color: var(--color-primary);
    border: 1px solid var(--color-primary);
    animation: flash 1.5s infinite ease-in-out;
}

.state-ruptured {
    background-color: rgba(239, 68, 68, 0.2);
    color: var(--color-danger);
    border: 1px solid var(--color-danger);
    animation: shake 0.3s infinite;
}

/* Wrapper para o Canvas do Cano */
.canvas-wrapper {
    background-color: #060911;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    overflow: hidden;
    position: relative;
    width: 100%;
    margin-bottom: 0.75rem;
}

#pipe-canvas {
    display: block;
    width: 100%;
    height: 180px; /* Altura fixa confortável para o tubo horizontal */
    background-color: #060911;
}

/* Legenda do Canvas */
.canvas-legend {
    display: flex;
    justify-content: center;
    gap: 1.5rem;
    flex-wrap: wrap;
    font-size: 0.8rem;
    color: var(--text-secondary);
    padding: 0.25rem 0;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.color-box {
    width: 12px;
    height: 12px;
    border-radius: 3px;
    display: inline-block;
}

.color-box.normal-pressure {
    background-color: #0077aa;
    border: 1px solid var(--color-primary);
}

.color-box.shockwave {
    background-color: #990033;
    border: 1px solid var(--color-accent);
}

.color-box.arrow-legend {
    position: relative;
    background-color: transparent;
    border: none;
    width: 16px;
}

.color-box.arrow-legend::after {
    content: "➔";
    color: var(--color-primary);
    font-size: 1rem;
    position: absolute;
    top: -6px;
    left: 0;
}

/* Container de Tempo do Teste (Cronômetro) */
.simulation-timer-container {
    display: flex;
    justify-content: space-around;
    align-items: center;
    background-color: rgba(255, 255, 255, 0.02);
    border-top: 1px dashed rgba(255, 255, 255, 0.08);
    padding: 0.8rem 1rem;
    margin-top: 0.8rem;
    border-radius: 8px;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.timer-item {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.timer-item strong {
    color: var(--text-primary);
}

.timer-item span {
    font-family: 'JetBrains Mono', monospace;
    font-weight: 700;
    color: var(--color-primary);
    background-color: rgba(0, 204, 255, 0.08);
    padding: 0.15rem 0.5rem;
    border-radius: 4px;
    border: 1px solid rgba(0, 204, 255, 0.15);
    min-width: 75px;
    text-align: center;
    transition: all 0.3s ease;
}

/* Quando o teste for concluído, destaca o tempo final */
.timer-item span.elapsed-final {
    color: var(--color-success) !important;
    background-color: rgba(46, 204, 113, 0.08) !important;
    border: 1px solid rgba(46, 204, 113, 0.15) !important;
}

/* -------------------------------------------------------------
   GRÁFICO E HISTÓRICO
   ------------------------------------------------------------- */
.chart-wrapper {
    background-color: #060911;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 1rem;
    width: 100%;
    height: 280px;
}

/* Ajuste do tamanho do gráfico dentro do wrapper */
#pressure-chart {
    width: 100% !important;
    height: 100% !important;
}

/* Tabelas e Histórico */
.table-responsive {
    width: 100%;
    overflow-x: auto;
}

.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
    text-align: left;
}

.table th, .table td {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border-color);
}

.table th {
    color: var(--text-secondary);
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.5px;
    background-color: rgba(255, 255, 255, 0.01);
}

.table tbody tr {
    transition: background-color 0.2s ease, cursor 0.2s ease;
}

.table tbody tr:hover {
    background-color: rgba(255, 255, 255, 0.02);
    cursor: pointer;
}

.table td {
    color: var(--text-primary);
}

.table td.text-center {
    text-align: center;
    color: var(--text-muted);
    padding: 2rem;
}

/* Badges específicos da Tabela de histórico */
.badge-status {
    padding: 0.15rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
}

.badge-status.status-ok {
    background-color: rgba(16, 185, 129, 0.15);
    color: var(--color-success);
}

.badge-status.status-ruptured {
    background-color: rgba(239, 68, 68, 0.15);
    color: var(--color-danger);
}

/* -------------------------------------------------------------
   RODAPÉ DA APLICAÇÃO (FOOTER)
   ------------------------------------------------------------- */
.app-footer {
    background-color: #04060a;
    border-top: 1px solid var(--border-color);
    padding: 2.5rem 2rem;
    margin-top: auto;
    text-align: center;
}

.footer-container {
    max-width: 1000px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.8rem;
}

.footer-logo-row {
    margin-bottom: 0.5rem;
}

.footer-logo {
    height: 35px;
    width: auto;
    opacity: 0.65;
    transition: all 0.3s ease;
    filter: drop-shadow(0 0 5px rgba(255, 255, 255, 0.1));
}

.footer-logo:hover {
    opacity: 0.95;
    filter: drop-shadow(0 0 10px rgba(255, 255, 255, 0.2));
}

.footer-divider {
    width: 60px;
    height: 2px;
    background-color: var(--color-primary);
    border-radius: 2px;
    margin: 0.25rem 0;
    box-shadow: 0 0 8px var(--color-primary);
}

.footer-explanation {
    font-size: 0.82rem;
    color: var(--text-muted);
    line-height: 1.6;
    max-width: 800px;
    margin: 0;
}

.footer-explanation strong {
    color: var(--text-primary);
}

.footer-credits {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin: 0.25rem 0 0 0;
}

.footer-credits strong {
    color: var(--color-primary);
}

.footer-copyright {
    font-size: 0.78rem;
    color: var(--text-muted);
    margin: 0;
    letter-spacing: 0.5px;
}

/* -------------------------------------------------------------
   ANIMAÇÕES E EFEITOS ESPECIAIS (KEYFRAMES)
   ------------------------------------------------------------- */

/* Pulsação leve */
@keyframes pulse {
    0%, 100% {
        transform: scale(1);
        opacity: 1;
        box-shadow: 0 0 8px var(--color-primary);
    }
    50% {
        transform: scale(1.15);
        opacity: 0.8;
        box-shadow: 0 0 14px var(--color-primary);
    }
}

/* Piscar discreto */
@keyframes flash {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.6;
    }
}

/* Tremor de tela para simular o golpe e estouro */
@keyframes shake {
    0%, 100% { transform: translate(0, 0) rotate(0deg); }
    10% { transform: translate(-1px, -1px) rotate(-0.5deg); }
    20% { transform: translate(-2px, 0px) rotate(0.5deg); }
    30% { transform: translate(1px, 1px) rotate(0deg); }
    40% { transform: translate(1px, -1px) rotate(0.5deg); }
    50% { transform: translate(-1px, 2px) rotate(-0.5deg); }
    60% { transform: translate(-2px, 1px) rotate(0deg); }
    70% { transform: translate(2px, 1px) rotate(-0.5deg); }
    80% { transform: translate(-1px, -1px) rotate(0.5deg); }
    90% { transform: translate(2px, -1px) rotate(0deg); }
}

.shake-active {
    animation: shake 0.15s infinite;
}

/* Brilho perigoso para o card rompido */
@keyframes glow-danger {
    from {
        box-shadow: 0 0 5px rgba(239, 68, 68, 0.1), inset 0 0 5px rgba(239, 68, 68, 0.05);
    }
    to {
        box-shadow: 0 0 15px rgba(239, 68, 68, 0.3), inset 0 0 10px rgba(239, 68, 68, 0.15);
    }
}
