/* Importação de Fontes Modernas */
@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700;800&family=Inter:wght@300;400;500;600;700&display=swap');

:root {
    /* Paleta de Cores HSL Tailored */
    --bg-main: #111520; /* Fundo principal em tom cinza-ardósia escuro */
    --bg-card: #1A2030; /* Cartão opaco em cinza-azul mariano */
    --bg-card-hover: #20283C;
    --border-color: rgba(148, 163, 184, 0.25); /* Contorno bem nítido */
    --border-active: #5C67DE;
    
    --text-primary: #F1F5F9;
    --text-secondary: #94A3B8;
    --text-muted: #64748B;
    
    /* Cores de Acento Desaturadas (Sem brilho excessivo) */
    --accent-primary: #5C67DE; /* Azul-índigo desaturado */
    --accent-primary-glow: rgba(92, 103, 222, 0.12);
    --accent-secondary: #0A98B0; /* Cyan desaturado */
    --accent-success: #2E7D62; /* Verde esmeralda sóbrio */
    --accent-warning: #D97706; /* Âmbar sóbrio */
    --accent-danger: #993D3D; /* Vermelho terracota sóbrio */
    
    /* Gradientes mais suaves */
    --gradient-primary: linear-gradient(135deg, #4A58D1 0%, #2B6CB0 100%);
    --gradient-glow: radial-gradient(circle at 50% 50%, rgba(92, 103, 222, 0.08) 0%, transparent 70%);

    /* Transições */
    --transition-smooth: all 0.2s ease-in-out;
    
    /* Fontes */
    --font-heading: 'Plus Jakarta Sans', sans-serif;
    --font-body: 'Inter', sans-serif;
}

/* Reset Geral */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.1) transparent;
}

body {
    background-color: var(--bg-main);
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: 15px;
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    overflow-x: hidden;
    position: relative;
}

/* Fundo Decorativo com Efeito Nebulosa */
body::before {
    content: '';
    position: absolute;
    top: -10%;
    right: -10%;
    width: 60vw;
    height: 60vw;
    background: radial-gradient(circle, rgba(99, 102, 241, 0.08) 0%, transparent 70%);
    z-index: -1;
    pointer-events: none;
}

body::after {
    content: '';
    position: absolute;
    bottom: -10%;
    left: -10%;
    width: 50vw;
    height: 50vw;
    background: radial-gradient(circle, rgba(6, 182, 212, 0.06) 0%, transparent 70%);
    z-index: -1;
    pointer-events: none;
}

/* Layout Principal com Sidebar */
.app-container {
    display: flex;
    width: 100vw;
    min-height: 100vh;
}

/* Sidebar Estilo Glassmorphism */
.sidebar {
    width: 280px;
    background: rgba(13, 18, 30, 0.8);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-right: 1px solid var(--border-color);
    padding: 2.5rem 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 2.5rem;
    flex-shrink: 0;
}

.logo-container {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.logo-text {
    font-family: var(--font-heading);
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.5px;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.logo-sub {
    font-size: 0.8rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 2px;
    font-weight: 600;
}

.nav-menu {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    list-style: none;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.85rem 1rem;
    border-radius: 4px;
    color: var(--text-secondary);
    text-decoration: none;
    font-family: var(--font-heading);
    font-weight: 500;
    font-size: 0.95rem;
    cursor: pointer;
    transition: var(--transition-smooth);
    border-left: 4px solid transparent;
}

.nav-item i {
    font-size: 1.2rem;
    transition: var(--transition-smooth);
}

.nav-item:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.05);
}

.nav-item.active {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.08);
    border-left: 4px solid var(--accent-primary);
}

.nav-item.active i {
    color: var(--accent-primary);
}

.sidebar-footer {
    margin-top: auto;
    font-size: 0.8rem;
    color: var(--text-muted);
    text-align: center;
    border-top: 1px solid var(--border-color);
    padding-top: 1.5rem;
}

/* Área de Conteúdo Principal */
.main-content {
    flex-grow: 1;
    padding: 1.5rem 2rem;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    max-width: calc(100vw - 280px);
}

/* Seções de Visualização (Controladas por Abas) */
.content-section {
    display: none;
    animation: fadeIn 0.4s ease-out forwards;
}

.content-section.active {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Títulos de Seção */
.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 1.2rem;
}

.section-title {
    font-family: var(--font-heading);
    font-size: 1.8rem;
    font-weight: 600;
}

.section-desc {
    color: var(--text-secondary);
    font-size: 0.95rem;
    margin-top: 0.25rem;
}

/* Estilos de Card Glassmorphism */
.glass-card {
    background: var(--bg-card);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 1.25rem;
    transition: var(--transition-smooth);
}

.glass-card:hover {
    border-color: rgba(255, 255, 255, 0.15);
    box-shadow: none;
}

/* Layout de Duas Colunas para Configurações */
.settings-grid {
    display: grid;
    grid-template-columns: 320px 1fr;
    gap: 2rem;
}

/* Formulário de Configuração Geral */
.form-group {
    margin-bottom: 0.85rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.form-label {
    font-size: 0.85rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-secondary);
}

.form-input {
    background: #0F1321;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 0.75rem 1rem;
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: 0.95rem;
    transition: var(--transition-smooth);
    width: 100%;
}

.form-input:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: none;
}

/* Botões Modernos */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.85rem 1.75rem;
    border-radius: 4px;
    font-family: var(--font-heading);
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    transition: var(--transition-smooth);
    border: none;
}

.btn-primary {
    background: var(--gradient-primary);
    color: #fff;
}

.btn-primary:hover {
    filter: brightness(1.1);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.2);
}

.btn-success {
    background: var(--accent-success);
    color: #fff;
}

.btn-success:hover {
    filter: brightness(1.1);
}

.btn-danger {
    background: rgba(239, 68, 68, 0.1);
    color: var(--accent-danger);
    border: 1px solid rgba(239, 68, 68, 0.2);
}

.btn-danger:hover {
    background: var(--accent-danger);
    color: #fff;
}

.btn-small {
    padding: 0.5rem 1rem;
    font-size: 0.85rem;
    border-radius: 4px;
}

/* Tabelas e Configurações de Eventos */
.table-container {
    width: 100%;
    overflow-x: auto;
}

.custom-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
}

.custom-table th {
    background: rgba(15, 23, 42, 0.4);
    padding: 0.5rem 0.75rem;
    font-family: var(--font-heading);
    font-weight: 600;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-secondary);
    border-bottom: 2px solid var(--border-color);
}

.custom-table td {
    padding: 0.5rem 0.75rem;
    border-bottom: 1px solid var(--border-color);
    vertical-align: middle;
}

.custom-table tr:hover td {
    background: rgba(255, 255, 255, 0.01);
}

/* Event Badges */
.event-badge {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 0.25rem 0.6rem;
    border-radius: 4px;
    font-size: 0.8rem;
    font-weight: 600;
    font-family: var(--font-heading);
    display: inline-block;
}

/* Select customizado */
.custom-select {
    background: #0F1321;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 0.5rem;
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: 0.9rem;
    outline: none;
    transition: var(--transition-smooth);
    width: 100%;
}

.custom-select:focus {
    border-color: var(--accent-primary);
}

/* Estilos de Inputs nas Tabelas */
.table-input {
    background: #0F1321;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 0.4rem 0.6rem;
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: 0.9rem;
    width: 100%;
    transition: var(--transition-smooth);
}

.table-input:focus {
    outline: none;
    border-color: var(--accent-primary);
}

/* Controles de Matriz */
.matrix-container {
    width: 100%;
    overflow-x: auto;
    padding: 1rem 0;
}

.matrix-table {
    border-collapse: separate;
    border-spacing: 4px;
    min-width: 100%;
}

.matrix-table th {
    padding: 0.35rem 0.5rem;
    font-family: var(--font-heading);
    font-size: 0.85rem;
    font-weight: 600;
    text-align: center;
    border-radius: 4px;
}

.matrix-table th.col-header {
    background: rgba(15, 23, 42, 0.3);
    color: var(--text-secondary);
}

.matrix-table th.row-header {
    background: rgba(15, 23, 42, 0.3);
    color: var(--text-secondary);
    text-align: right;
    white-space: nowrap;
    padding-right: 0.75rem;
}

.matrix-table td {
    padding: 0;
    text-align: center;
}

.matrix-cell-input {
    width: 78px;
    height: 28px;
    background: #0F1321;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    color: var(--text-primary);
    text-align: center;
    font-family: var(--font-body);
    font-size: 0.8rem;
    font-weight: 500;
    transition: var(--transition-smooth);
}

.matrix-cell-input:focus {
    outline: none;
    border-color: var(--accent-primary);
    background: rgba(99, 102, 241, 0.08);
}

.matrix-cell-input.diagonal {
    background: rgba(255, 255, 255, 0.03);
    border-color: transparent;
    color: var(--text-muted);
    font-style: italic;
    cursor: not-allowed;
}

.matrix-cell-input:hover:not(.diagonal) {
    border-color: rgba(255, 255, 255, 0.2);
}

/* Explicações e Alertas de Uso */
.info-box {
    display: flex;
    gap: 1rem;
    background: rgba(99, 102, 241, 0.08);
    border: 1px solid rgba(99, 102, 241, 0.15);
    border-radius: 4px;
    padding: 1.25rem;
    margin-bottom: 1.5rem;
    align-items: flex-start;
}

.info-box i {
    color: var(--accent-primary);
    font-size: 1.4rem;
    margin-top: 0.15rem;
}

.info-box p {
    font-size: 0.9rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

/* Dashboard de Resultados */
.results-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1.5rem;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 1.5rem;
    display: flex;
    align-items: center;
    gap: 1.25rem;
    position: relative;
    overflow: hidden;
}

.stat-card::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
    background: var(--accent-primary);
}

.stat-card.secondary::after {
    background: var(--accent-secondary);
}

.stat-card.success::after {
    background: var(--accent-success);
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    color: var(--accent-primary);
}

.stat-card.secondary .stat-icon {
    color: var(--accent-secondary);
}

.stat-card.success .stat-icon {
    color: var(--accent-success);
}

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

.stat-value {
    font-family: var(--font-heading);
    font-size: 1.6rem;
    font-weight: 700;
}

.stat-label {
    font-size: 0.8rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 500;
}

/* Gráficos */
.charts-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
}

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

.chart-wrapper {
    min-height: 320px;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Resultados das Simulações e Ranking */
.results-tabs {
    display: flex;
    gap: 1rem;
    margin-bottom: 1rem;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 0.5rem;
}

.results-tab-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-family: var(--font-heading);
    font-weight: 600;
    font-size: 0.95rem;
    padding: 0.5rem 1rem;
    cursor: pointer;
    position: relative;
    transition: var(--transition-smooth);
}

.results-tab-btn.active {
    color: var(--text-primary);
}

.results-tab-btn.active::after {
    content: '';
    position: absolute;
    bottom: -9px;
    left: 0;
    width: 100%;
    height: 2px;
    background: var(--accent-primary);
}

/* Visualizador de cenário binário */
.binary-grid-visualizer {
    display: inline-flex;
    gap: 3px;
    align-items: center;
}

.binary-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%; /* Circular LED style */
    display: inline-block;
    font-size: 0; /* Hide 1 and 0 text completely */
    color: transparent; /* Hide text color */
    transition: var(--transition-smooth);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.binary-dot.occurred {
    background-color: #10B981;
    /* Glowing green LED */
    box-shadow: 0 0 10px rgba(16, 185, 129, 0.6), inset 0 2px 4px rgba(255, 255, 255, 0.4);
    border-color: rgba(16, 185, 129, 0.4);
}

.binary-dot.not-occurred {
    background-color: #EF4444;
    /* Glowing red LED */
    box-shadow: 0 0 10px rgba(239, 68, 68, 0.6), inset 0 2px 4px rgba(255, 255, 255, 0.4);
    border-color: rgba(239, 68, 68, 0.4);
}

/* Ações Gerais no Topo */
.header-actions {
    display: flex;
    gap: 0.75rem;
}

/* Loading overlay */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(11, 15, 25, 0.85);
    backdrop-filter: blur(8px);
    z-index: 9999;
    display: none;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 1.5rem;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 4px solid rgba(99, 102, 241, 0.1);
    border-top: 4px solid var(--accent-primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.progress-container {
    width: 300px;
    height: 6px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 4px;
    overflow: hidden;
    margin-top: 1rem;
    border: 1px solid var(--border-color);
}

.progress-bar {
    width: 0%;
    height: 100%;
    background: var(--gradient-primary);
    transition: width 0.1s linear;
}

.loading-text {
    font-family: var(--font-heading);
    font-weight: 600;
    font-size: 1.2rem;
    letter-spacing: 0.5px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Ajustes finos adicionais */
.mt-4 { margin-top: 1rem; }
.mb-4 { margin-bottom: 1rem; }
.d-flex { display: flex; }
.gap-2 { gap: 0.5rem; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.flex-column { flex-direction: column; }
.w-100 { width: 100%; }

.input-helper-text {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 0.2rem;
}

.badge-order {
    background-color: var(--accent-primary-glow);
    border: 1px solid rgba(99, 102, 241, 0.3);
    color: var(--text-primary);
}

.badge-fo {
    background-color: rgba(16, 185, 129, 0.15);
    border: 1px solid rgba(16, 185, 129, 0.3);
    color: var(--accent-success);
}

.badge-fno {
    background-color: rgba(239, 68, 68, 0.15);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: var(--accent-danger);
}

/* ==========================================================================
   LIGHT THEME OVERRIDES
   ========================================================================== */
body.light-theme {
    --bg-main: #F1F5F9; /* Fundo cinza bem claro e azulado limpo (conforme referência) */
    --bg-card: rgba(255, 255, 255, 0.95);
    --bg-card-hover: rgba(255, 255, 255, 1.0);
    --border-color: rgba(15, 23, 42, 0.08);
    --border-active: rgba(99, 102, 241, 0.4);
    
    --text-primary: #0F172A;
    --text-secondary: #475569;
    --text-muted: #94A3B8;
    
    --accent-primary-glow: rgba(99, 102, 241, 0.08);
}

body.light-theme::before {
    background: radial-gradient(circle, rgba(99, 102, 241, 0.05) 0%, transparent 70%);
}

body.light-theme::after {
    background: radial-gradient(circle, rgba(6, 182, 212, 0.04) 0%, transparent 70%);
}

body.light-theme .sidebar {
    background: rgba(255, 255, 255, 0.8);
    border-right: 1px solid rgba(0, 0, 0, 0.06);
}

body.light-theme .nav-item:hover {
    background: rgba(15, 23, 42, 0.04);
}

body.light-theme .nav-item.active {
    background: rgba(15, 23, 42, 0.06);
    border-left: 4px solid var(--accent-primary);
}

body.light-theme .form-input, 
body.light-theme .custom-select,
body.light-theme .table-input {
    background: #F8FAFC;
    border: 1px solid #CBD5E1;
    color: var(--text-primary);
}

body.light-theme .form-input:focus,
body.light-theme .custom-select:focus,
body.light-theme .table-input:focus {
    border-color: var(--accent-primary);
    box-shadow: none;
}

body.light-theme .custom-table th {
    background: rgba(15, 23, 42, 0.03);
    border-bottom: 2px solid rgba(15, 23, 42, 0.08);
    color: var(--text-secondary);
}

body.light-theme .matrix-table th.col-header,
body.light-theme .matrix-table th.row-header {
    background: rgba(15, 23, 42, 0.03);
}

body.light-theme .matrix-cell-input {
    background: #F8FAFC;
    border: 1px solid #CBD5E1;
    color: var(--text-primary);
}

body.light-theme .matrix-cell-input:focus {
    background: rgba(99, 102, 241, 0.04);
}

body.light-theme .matrix-cell-input.diagonal {
    background: rgba(0, 0, 0, 0.02);
    color: var(--text-muted);
}

body.light-theme .info-box {
    background: rgba(99, 102, 241, 0.05);
    border: 1px solid rgba(99, 102, 241, 0.1);
}

body.light-theme .stat-card {
    background: rgba(255, 255, 255, 0.6);
    border: 1px solid rgba(15, 23, 42, 0.06);
}

body.light-theme .stat-card::after {
    background: var(--accent-primary);
}

body.light-theme .stat-icon {
    background: rgba(0, 0, 0, 0.02);
}

body.light-theme .binary-dot {
    border-color: rgba(15, 23, 42, 0.15);
}

body.light-theme .binary-dot.occurred {
    background-color: #10B981;
    /* Glowing green LED in light theme */
    box-shadow: 0 0 8px rgba(16, 185, 129, 0.5), inset 0 2px 3px rgba(255, 255, 255, 0.4);
    border-color: rgba(16, 185, 129, 0.4);
}

body.light-theme .binary-dot.not-occurred {
    background-color: #EF4444;
    /* Glowing red LED in light theme */
    box-shadow: 0 0 8px rgba(239, 68, 68, 0.5), inset 0 2px 3px rgba(255, 255, 255, 0.4);
    border-color: rgba(239, 68, 68, 0.4);
}

body.light-theme .loading-overlay {
    background: rgba(248, 250, 252, 0.9);
}

body.light-theme .loading-text {
    color: #0F172A;
}

body.light-theme .spinner {
    border: 4px solid rgba(99, 102, 241, 0.1);
    border-top: 4px solid var(--accent-primary);
}

body.light-theme .progress-container {
    background: rgba(0, 0, 0, 0.05);
    border: 1px solid rgba(15, 23, 42, 0.08);
}





