/* style.css - Adicionado GND */

body {
    font-family: sans-serif;
    display: flex;
    flex-direction: column;
    align-items: center;
    background-color: #f0f0f0;
    padding: 20px;
    margin: 0;
    min-height: 100vh;
    padding-bottom: 60px; /* Espaço para o rodapé */
}

h1 {
    text-align: center;
    color: #333;
    margin-top: 40px;
    margin-bottom: 5px;
}
.subtitle {
    text-align: center;
    color: #555;
    font-size: 0.95em;
    margin-bottom: 20px;
}
h2 {
    text-align: center;
    color: #333;
}
h3 {
    text-align: center;
    color: #555;
    margin-top: 0;
    margin-bottom: 10px;
    font-size: 1.1em;
}

/* --- SELETOR DE IDIOMA --- */
.language-selector {
    position: absolute; top: 10px; right: 15px; display: flex; gap: 5px;
}
.language-selector button {
    background: none; border: 2px solid transparent; padding: 3px; cursor: pointer;
    font-size: 1.8em; line-height: 1; border-radius: 4px; transition: border-color 0.2s ease;
}
.language-selector button:hover { border-color: #ccc; }
.language-selector button.active-lang { border-color: #007bff; background-color: rgba(0, 123, 255, 0.1); }

/* --- ÁREA PRINCIPAL --- */
.simulation-area { 
    display: flex; 
    align-items: center; 
    justify-content: space-between; 
    width: 90%; 
    max-width: 900px; 
    margin-top: 10px; 
    background-color: #fff; 
    padding: 20px; 
    border-radius: 8px; 
    box-shadow: 0 2px 5px rgba(0,0,0,0.1); 
    position: relative; 
}

/* --- DISPOSITIVOS --- */
.device { 
    border: 2px solid #ccc; 
    padding: 20px; 
    border-radius: 8px; 
    background-color: #e9e9e9; 
    width: 300px; 
    position: relative; 
    display: flex; 
    flex-direction: column; 
    min-height: 350px; 
    justify-content: space-between;
}
.device h2 { margin-top: 0; margin-bottom: 15px; }
.device label { display: block; margin-top: 10px; margin-bottom: 3px; font-weight: bold; color: #555; text-align: left; }

#asciiInput { 
    padding: 8px; 
    border: 1px solid #ccc; 
    border-radius: 4px; 
    font-size: 1.1em; 
    width: calc(100% - 18px); 
    background-color: #e0ffe0; 
    text-align: left; 
    font-family: 'Courier New', Courier, monospace; 
}

/* --- CAIXAS DE PREVIEW --- */
.preview-box { 
    margin-top: 0px; 
    margin-bottom: 10px; 
    padding: 8px; 
    background-color: #fff; 
    border: 1px solid #ccc; 
    border-radius: 4px; 
    font-family: monospace; 
    font-size: 1.1em; 
    min-height: 1.5em; 
    word-wrap: break-word; 
    text-align: center; 
    color: #333; 
    line-height: 1.4; 
}
#binaryPreview { 
    font-size: 1.0em; 
    white-space: nowrap; 
    overflow-x: auto; 
    scrollbar-width: thin; 
}
#binaryPreview::-webkit-scrollbar { height: 6px; }
#binaryPreview::-webkit-scrollbar-thumb { background-color: #ccc; border-radius: 3px;}
#receiverScreen.screen { 
    background-color: #e0ffe0; 
    font-family: 'Courier New', Courier, monospace; 
    font-weight: bold; 
    font-size: 1.2em; 
    height: 60px; 
    overflow-y: auto; 
    text-align: left; 
}

/* --- BOTÕES DE CONTROLE --- */
.control-buttons { display: flex; justify-content: space-around; gap: 10px; margin-top: 15px; margin-bottom: 5px; }
.control-buttons button { padding: 8px 10px; font-size: 1.3em; line-height: 1; border: none; border-radius: 5px; cursor: pointer; background-color: #2196F3; color: white; transition: background-color 0.3s ease; flex-grow: 1; flex-basis: 0; }
.control-buttons button:hover:not(:disabled) { background-color: #1976D2; }
.control-buttons button:disabled { background-color: #ccc; cursor: not-allowed; }

/* --- INDICADORES DE ESTADO --- */
#senderState, #receiverState { 
    margin-top: 10px; 
    font-style: italic; 
    color: #666; 
    font-size: 0.9em; 
    text-align: center; 
    min-height: 1.2em;
}

/* --- BARRAMENTO --- */
.bus-container {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 0 20px;
    gap: 3px; /* Espaço entre os fios */
    position: relative; /* Adicionado para o GND */
    align-self: stretch; /* Garante que o container ocupe a altura */
}
.bus-wire {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 22px;
    border: 1px solid #999;
    border-radius: 4px;
    padding: 0 8px;
    transition: background-color 0.1s ease-in-out;
}
.bus-wire.low { 
    background-color: #007bff; /* Azul para LOW (0) */
    color: white;
}
.bus-wire.high { 
    background-color: #ffcc00; /* Amarelo para HIGH (1) */
    color: #333;
}
.wire-label {
    font-weight: bold;
    font-size: 0.8em;
}
.wire-value {
    font-family: monospace;
    font-weight: bold;
    font-size: 1.1em;
}
/* Destaque para o fio de Clock */
#clk-wire {
    border-width: 2px;
    border-color: #dc3545; /* Vermelho (como o stop bit do seu exemplo) */
    margin-bottom: 10px; /* Separa o CLK dos dados */
}
#clk-wire.low { background-color: #007bff; }
#clk-wire.high { background-color: #f08080; } /* Vermelho mais claro para CLK HIGH */

/* --- FIO TERRA (GND) --- */
.ground-wire { 
    position: absolute; 
    bottom: 30px; /* Posição relativa ao bus-container */
    left: 5%; 
    width: 90%; 
    height: 4px; 
    background-color: #3b2b0a; 
    border-radius: 2px; 
}
.ground-label { 
    position: absolute; 
    bottom: 10px; /* Posição relativa ao bus-container */
    left: 50%; 
    transform: translateX(-50%); 
    font-size: 0.8em; 
    color: #3b2b0a; 
}
/* ----------------------- */


/* --- HIGHLIGHT NO PREVIEW --- */
#binaryPreview span.char-group {
    display: inline-block;
    padding: 2px;
    border-radius: 3px;
    margin: 0 2px;
    transition: background-color 0.2s;
}
#binaryPreview span.highlighted-char {
    background-color: #ffdddd;
    font-weight: bold;
}

/* --- ANALISADOR LÓGICO (ESTILO CANVAS) --- */
#logic-analyzer { 
    width: 90%; 
    max-width: 1000px; 
    margin-top: 40px; 
    margin-bottom: 20px; 
    padding: 20px; 
    background-color: #fff; 
    border-radius: 8px; 
    box-shadow: 0 2px 5px rgba(0,0,0,0.1); 
    text-align: center; 
}
#logicAnalyzerCanvas { 
    border: 1px solid #aaa; 
    background-color: #fdfdfd; 
    margin-top: 10px; 
    max-width: 100%; 
    height: auto; 
    display: inline-block; 
}
.logic-analyzer-buttons {
    margin-top: 20px;
    justify-content: center;
}
.logic-analyzer-buttons button {
    flex-grow: 0;
    flex-basis: auto;
    padding: 8px 16px;
    font-size: 1em;
    background-color: #6c757d;
}
.logic-analyzer-buttons button:hover:not(:disabled) {
    background-color: #5a6268;
}


/* --- RODAPÉ --- */
.footer {
    position: relative; 
    margin-top: 30px; 
    width: 100%;
    text-align: center;
    font-size: 0.9em;
    color: #666;
    padding: 10px 0;
    background-color: #f0f0f0; 
    border-top: 1px solid #ddd; 
    z-index: 10;
}
.footer a { color: #007bff; text-decoration: none; }
.footer a:hover { text-decoration: underline; }