/* Multiclass Confusion Matrix Specific Styles */

/* Inherits base styles from unified-demos.css */

/* Matrix Grid Layout */
#confusion-matrix-grid {
    display: grid;
    /* Grid template columns will be set by JS based on number of classes */
    gap: 2px;
    background-color: var(--demo-border);
    border: 1px solid var(--demo-border);
    border-radius: 4px;
    overflow: hidden;
    margin: 20px auto;
    max-width: 100%;
    width: fit-content;
}

.cm-cell {
    background-color: var(--demo-surface);
    padding: 10px;
    text-align: center;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    min-width: 60px;
    min-height: 60px;
    transition: background-color 0.2s;
}

.cm-header {
    font-weight: bold;
    background-color: var(--demo-surface-alt);
    color: var(--demo-text);
}

.cm-value {
    font-size: 1.2em;
    font-weight: bold;
    color: var(--demo-text);
}

/* Highlighting classes */
/* True positive: stronger but still soft green for visibility */
.cm-cell.highlight-tp {
    background-color: rgba(76, 175, 80, 0.25); /* green tint */
    border: 2px solid rgba(76, 175, 80, 0.6);
}

/* Errors (both FP and FN): consistent light red with clearer border */
.cm-cell.highlight-fp,
.cm-cell.highlight-fn,
.cm-cell.highlight-error {
    background-color: rgba(244, 67, 54, 0.18); /* light red */
    border: 2px solid rgba(244, 67, 54, 0.55);
}

/* True negatives (optional) remain visible but subtle */
.cm-cell.highlight-tn {
    background-color: rgba(33, 150, 243, 0.18); /* light blue tint */
    border: 2px solid rgba(33, 150, 243, 0.5);
}

/* Active metric-card colors should match matrix highlights */
.metric-card.active[data-metric="tp"] {
    background-color: rgba(76, 175, 80, 0.08);
    border-color: rgba(76, 175, 80, 0.6);
}

.metric-card.active[data-metric="fp"],
.metric-card.active[data-metric="fn"] {
    background-color: rgba(244, 67, 54, 0.06);
    border-color: rgba(244, 67, 54, 0.55);
}

.metric-card.active[data-metric="tn"] {
    background-color: rgba(33, 150, 243, 0.06);
    border-color: rgba(33, 150, 243, 0.5);
}

/* Class Selector Buttons */
#class-selector {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
    margin-top: 10px;
}

.class-btn {
    padding: 8px 16px;
    border: 1px solid var(--demo-border);
    background-color: var(--demo-surface);
    color: var(--demo-text);
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
}

.class-btn:hover {
    background-color: var(--demo-surface-alt);
}

.class-btn.active {
    background-color: var(--demo-accent);
    color: white;
    border-color: var(--demo-accent);
}

/* Metrics Display Grid */
#metrics-display {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 15px;
    margin-top: 20px;
}

.metric-card {
    background-color: var(--demo-surface);
    border: 1px solid var(--demo-border);
    border-radius: 8px;
    padding: 15px;
    text-align: center;
    position: relative;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.metric-card.active {
    border-color: var(--demo-accent);
    box-shadow: var(--demo-shadow-hover);
    transform: translateY(-3px);
}

.metric-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    border-bottom: 1px solid var(--demo-border);
    padding-bottom: 5px;
}

.metric-header h4 {
    margin: 0;
    font-size: 0.9em;
    color: var(--demo-neutral);
}

.info-icon {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.1em;
    color: var(--demo-accent);
    padding: 0 5px;
}

.metric-value {
    font-size: 1.5em;
    font-weight: bold;
    color: var(--demo-text);
}

/* Global Metrics */
#global-metrics {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-top: 10px;
}

.global-metric {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px;
    background-color: var(--demo-surface-alt);
    border-radius: 4px;
}

.global-metric-label {
    font-weight: bold;
    color: var(--demo-neutral);
}

.global-metric-value {
    font-weight: bold;
    color: var(--demo-accent);
}

/* Modal Styles */
.info-modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    align-items: center;
    justify-content: center;
}

.info-modal-content {
    background-color: var(--demo-surface);
    margin: auto;
    padding: 25px;
    border: 1px solid var(--demo-border);
    border-radius: 8px;
    width: 90%;
    max-width: 500px;
    position: relative;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
}

.info-modal-close {
    color: var(--demo-neutral);
    float: right;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    line-height: 1;
}

.info-modal-close:hover {
    color: var(--demo-text);
}

.modal-formula {
    background-color: var(--demo-surface-alt);
    padding: 15px;
    border-radius: 4px;
    font-family: monospace;
    margin: 15px 0;
    text-align: center;
    border: 1px solid var(--demo-border);
}

.modal-explanation {
    line-height: 1.5;
    color: var(--demo-text);
}

/* Responsive adjustments */
@media (max-width: 600px) {
    .cm-cell {
        min-width: 40px;
        min-height: 40px;
        padding: 5px;
        font-size: 0.9em;
    }

    .cm-value {
        font-size: 1em;
    }
}