/**
 * Shannon Entropy Visualizer Styles
 */

/* ============================================
   Custom Properties
   ============================================ */
:root {
    --entropy-gauge-low: #4CAF50;
    --entropy-gauge-mid: #FFC107;
    --entropy-gauge-high: #F44336;
    --entropy-bar-highlight: #ffd700;
    --entropy-bar-drag: #ff9800;
}

[data-theme="gruvbox-dark"] {
    --entropy-gauge-low: var(--gruvbox-green);
    --entropy-gauge-mid: var(--gruvbox-yellow);
    --entropy-gauge-high: var(--gruvbox-red);
    --entropy-bar-highlight: var(--gruvbox-yellow);
    --entropy-bar-drag: var(--gruvbox-orange);
}

/* ============================================
   Panel Heading with Badge
   ============================================ */
.panel-heading-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

/* ============================================
   Entropy Badge
   ============================================ */
/* .entropy-badge extends .viz-badge from visualizations.css */

.preset-header-select {
    width: auto;
    display: inline-block;
    font-size: 12px;
    padding: 2px 8px;
    height: auto;
    line-height: 1.4;
}

/* ============================================
   Canvas Styling
   ============================================ */
#entropy-canvas {
    display: block;
    width: 100%;
    height: 340px;
    cursor: default;
    background: var(--viz-canvas-bg);
}

/* ============================================
   Footer with Sum Indicator
   ============================================ */
.entropy-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 15px !important;
}

.sum-indicator {
    font-size: 12px;
    font-family: var(--viz-mono-font);
    padding: 3px 10px;
    border-radius: 3px;
    font-weight: 500;
}

.sum-indicator.valid {
    background: var(--viz-success-bg);
    color: var(--viz-success-border);
}

.sum-indicator.invalid {
    background: var(--viz-warning-bg);
    color: var(--viz-warning-border);
}

.encoding-avg-footer {
    font-size: 12px;
    font-family: var(--viz-mono-font);
    color: var(--viz-text-muted);
}

.encoding-avg-footer i {
    margin-right: 3px;
}

.entropy-hint {
    font-size: 11px;
    color: var(--viz-text-muted);
}

.entropy-hint i {
    margin-right: 4px;
}

/* ============================================
   Controls Panel Layout
   ============================================ */
.entropy-controls-panel {
    display: flex;
    gap: 20px;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
}

.entropy-options-col {
    display: flex;
    gap: 20px;
}

.entropy-option-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.entropy-actions-col {
    display: flex;
    gap: 8px;
    align-items: center;
}

/* ============================================
   Outcome Stepper
   ============================================ */
.entropy-stepper {
    display: flex;
    align-items: center;
    gap: 2px;
}

.entropy-stepper .btn {
    padding: 4px 10px;
    font-size: 14px;
    line-height: 1;
}

.outcome-count-display {
    min-width: 28px;
    text-align: center;
    font-weight: 600;
    font-size: 14px;
    padding: 0 4px;
}

/* ============================================
   Math Tab Breakdown
   ============================================ */
.entropy-breakdown {
    font-size: 13px;
}

.breakdown-formula {
    font-family: var(--viz-mono-font);
    margin-bottom: 12px;
    padding: 10px 12px;
    background: var(--viz-hover-bg);
    border-radius: 4px;
    overflow-x: auto;
    font-size: 12px;
    line-height: 1.6;
}

.breakdown-formula .term {
    white-space: nowrap;
}

/* .breakdown-table extends .viz-breakdown-table from visualizations.css */
.breakdown-table {
    margin-top: 12px;
}

/* ============================================
   Math Formula Display
   ============================================ */
.math-formula-display {
    text-align: center;
    padding: 15px;
    margin-bottom: 15px;
    background: var(--viz-hover-bg);
    border-radius: 4px;
}

.math-formula-display code {
    font-size: 16px;
    background: transparent;
    padding: 0;
}

/* ============================================
   Algorithm Steps
   ============================================ */
.algorithm-steps {
    padding-left: 20px;
    margin-bottom: 15px;
    font-size: 13px;
}

.algorithm-steps li {
    margin-bottom: 6px;
    line-height: 1.5;
}

/* ============================================
   Gauge Stats Display
   ============================================ */
.entropy-stats {
    display: flex;
    justify-content: space-between;
    padding: 0 20px;
    margin-top: 5px;
    font-size: 11px;
    color: var(--viz-text-muted);
}

/* ============================================
   Checkbox Labels
   ============================================ */
.checkbox-label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    cursor: pointer;
    white-space: nowrap;
}

.checkbox-label input[type="checkbox"] {
    margin: 0;
    cursor: pointer;
}

/* ============================================
   Huffman Encoding Panel
   ============================================ */
.encoding-avg {
    font-size: 12px;
    font-family: var(--viz-mono-font);
}

.encoding-code-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
}

.encoding-code-table th,
.encoding-code-table td {
    padding: 6px 8px;
    border: 1px solid var(--viz-border);
    text-align: center;
}

.encoding-code-table th {
    background: var(--viz-hover-bg);
    font-weight: 600;
    font-size: 11px;
}

.encoding-code-table td:first-child {
    text-align: left;
}

.code-cell {
    font-family: var(--viz-mono-font);
    white-space: nowrap;
}

.bit {
    display: inline-block;
    width: 18px;
    height: 18px;
    line-height: 18px;
    text-align: center;
    margin: 1px;
    border-radius: 3px;
    font-weight: 600;
    font-size: 11px;
}

.bit-0 {
    background: var(--viz-hover-bg);
    border: 1px solid var(--viz-border);
    color: var(--viz-text-muted);
}

.bit-1 {
    background: var(--viz-active-bg);
    border: 1px solid var(--viz-active-border);
    color: var(--viz-active-border);
}

.encoding-empty {
    color: var(--viz-text-muted);
    font-style: italic;
    text-align: center;
    padding: 20px;
}

/* ============================================
   Sampling Tab
   ============================================ */
.sampling-intro {
    font-size: 13px;
    margin-bottom: 15px;
    color: var(--viz-text-muted);
}

.sampling-controls {
    display: flex;
    gap: 8px;
    margin-bottom: 15px;
    flex-wrap: wrap;
}

.last-sample {
    display: flex;
    justify-content: space-between;
    padding: 10px 12px;
    background: var(--viz-hover-bg);
    border-radius: 4px;
    margin-bottom: 12px;
    font-size: 13px;
}

.last-sample strong {
    font-family: var(--viz-mono-font);
}

.sample-histogram {
    min-height: 100px;
    margin: 12px 0;
}

.histogram-empty {
    color: var(--viz-text-muted);
    font-style: italic;
    text-align: center;
    padding: 30px;
}

.histogram-container {
    padding: 10px 0;
}

.histogram-legend {
    display: flex;
    gap: 15px;
    font-size: 11px;
    margin-bottom: 10px;
    color: var(--viz-text-muted);
}

.legend-theoretical::before {
    content: '';
    display: inline-block;
    width: 12px;
    height: 12px;
    border: 2px solid var(--viz-text-muted);
    margin-right: 4px;
    vertical-align: middle;
}

.legend-empirical::before {
    content: '';
    display: inline-block;
    width: 12px;
    height: 12px;
    background: var(--viz-text-muted);
    margin-right: 4px;
    vertical-align: middle;
}

.histogram-bars {
    display: flex;
    gap: 8px;
    align-items: flex-end;
    height: 80px;
}

.histogram-bar-group {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 30px;
}

.histogram-bar-wrapper {
    display: flex;
    gap: 2px;
    align-items: flex-end;
    height: 60px;
    width: 100%;
}

.histogram-bar {
    flex: 1;
    min-width: 10px;
    transition: height 0.2s ease;
}

.histogram-bar.theoretical {
    background: transparent;
    border: 2px solid;
    border-radius: 2px 2px 0 0;
}

.histogram-bar.empirical {
    border-radius: 2px 2px 0 0;
    opacity: 0.8;
}

.histogram-label {
    font-size: 10px;
    margin-top: 4px;
    color: var(--viz-text);
    font-weight: 500;
}

.histogram-count {
    font-size: 9px;
    color: var(--viz-text-muted);
}

.sample-stats {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    color: var(--viz-text-muted);
    padding-top: 8px;
    border-top: 1px solid var(--viz-border);
}

.sample-stats strong {
    color: var(--viz-text);
    font-family: var(--viz-mono-font);
}

.sampling-insight {
    margin-top: 15px;
    padding: 10px 12px;
    background: var(--viz-info-bg);
    border-left: 3px solid var(--viz-info-border);
    border-radius: 0 4px 4px 0;
    font-size: 12px;
}

.sampling-insight i {
    color: var(--viz-info-border);
    margin-right: 6px;
}

/* ============================================
   Ball Bag Mode
   ============================================ */
#entropy-canvas.ball-bag-mode {
    cursor: crosshair;
}

/* ============================================
   Responsive
   ============================================ */
@media (max-width: 992px) {
    .entropy-controls-panel {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }

    .entropy-options-col {
        flex-direction: column;
        gap: 12px;
        width: 100%;
    }

    .entropy-actions-col {
        width: 100%;
        justify-content: flex-start;
    }

    .entropy-footer {
        flex-direction: column;
        gap: 8px;
        align-items: flex-start;
    }
}

@media (max-width: 768px) {
    .entropy-badge {
        font-size: 12px;
        padding: 3px 8px;
    }
}
