/* huffman.css */
:root {
    --bg-main: #0f172a;
    --bg-panel: #1e293b;
    --text-main: #e2e8f0;
    --accent-teal: #14b8a6;
    --accent-blue: #3b82f6;
    --node-leaf: #0f766e;
    --node-parent: #1e3a8a;
}

body {
    background-color: var(--bg-main);
    color: var(--text-main);
    font-family: 'Inter', sans-serif;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.lab-container {
    display: flex;
    flex-direction: column;
    gap: 20px;
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
    flex-grow: 1;
    width: 100%;
}

@media(min-width: 1024px) {
    .lab-container {
        flex-direction: row;
        align-items: flex-start;
    }
}

/* Sidebar: Input & Stats */
.sidebar {
    width: 100%;
    max-width: 400px;
    background: var(--bg-panel);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

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

textarea {
    background: #020617;
    border: 1px solid #334155;
    color: white;
    padding: 10px;
    border-radius: 8px;
    resize: none;
    font-family: 'Fira Code', monospace;
    font-size: 1.1rem;
    height: 100px;
}

textarea:focus {
    outline: 2px solid var(--accent-teal);
}

.process-btn {
    background: var(--accent-teal);
    color: #000;
    font-weight: 700;
    padding: 10px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    border: none;
}

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

/* Frequency Table */
.freq-table-container {
    max-height: 300px;
    overflow-y: auto;
    border: 1px solid #334155;
    border-radius: 8px;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

th,
td {
    padding: 8px 12px;
    text-align: left;
    border-bottom: 1px solid #334155;
}

th {
    background: #0f172a;
    color: #94a3b8;
    position: sticky;
    top: 0;
}

td.code-col {
    font-family: 'Fira Code', monospace;
    color: var(--accent-teal);
}

/* Tree Visualization */
.tree-panel {
    flex-grow: 1;
    background: #020617;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.05);
    min-height: 600px;
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.tree-header {
    position: absolute;
    top: 15px;
    right: 20px;
    text-align: right;
    pointer-events: none;
    z-index: 10;
}

canvas {
    width: 100%;
    height: 100%;
}

/* Encoding Output */
.output-box {
    margin-top: auto;
    background: rgba(0, 0, 0, 0.5);
    padding: 15px;
    font-family: 'Fira Code', monospace;
    font-size: 0.9rem;
    color: #cbd5e1;
    word-break: break-all;
    border-top: 1px solid #334155;
    max-height: 100px;
    overflow-y: auto;
}

.highlight {
    color: var(--accent-teal);
    font-weight: bold;
}

.stat-row {
    display: flex;
    justify-content: space-between;
    font-size: 0.85rem;
    color: #94a3b8;
    margin-top: 5px;
}

.stat-val {
    color: white;
    font-weight: 600;
}