.cutoff-slider-wrap {
    position: relative;
}

.follow-toggle {
    position: absolute;
    top: 24px; /* will be adjusted by JS to follow thumb */
    transform: translateX(-50%);
}
/* Arrow toggle for Test Direction */
.arrow-toggle {
    position: relative;
    display: inline-block;
    width: 120px;
    height: 36px;
}

.arrow-toggle input {
    opacity: 0;
    width: 0;
    height: 0;
}

.arrow-toggle-label {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #f0f0f0;
    border: 2px solid #ddd;
    border-radius: 18px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 10px;
    transition: background-color .25s, border-color .25s;
}

.arrow-toggle-label::before {
    content: '';
    position: absolute;
    top: 3px;
    left: 3px;
    height: calc(100% - 6px);
    width: calc(50% - 6px);
    background-color: #e7f5ec; /* highlight behind the active arrow */
    border-radius: 14px;
    transition: transform .25s ease;
    z-index: 0; /* sit behind arrows */
}

.arrow {
    font-size: 16px;
    font-weight: 700;
    color: #888;
    z-index: 1; /* above the highlight */
}

input:checked + .arrow-toggle-label::before {
    transform: translateX(100%);
}

/* Arrow colors depend on selection */
input:not(:checked) + .arrow-toggle-label .arrow.left { color: #4CAF50; }
input:not(:checked) + .arrow-toggle-label .arrow.right { color: #888; }
input:checked + .arrow-toggle-label .arrow.left { color: #888; }
input:checked + .arrow-toggle-label .arrow.right { color: #4CAF50; }
/* CSS Variables for easy slider alignment */
:root {
    --plot-width: 800px; /* Canvas width - adjust this to match your plot */
    --slider-width: 680px; /* Slider width - matches plot x-axis width */
    --slider-margin-left: 60px; /* Aligns with plot y-axis */
    --slider-margin-right: 60px; /* Aligns with plot right edge */
    --label-width: 60px; /* Width for labels to align with plot y-axis */
}

/* Manual alignment classes - add these to individual sliders if needed */
.slider-align-left {
    margin-left: 0 !important;
    margin-right: auto !important;
}

.slider-align-right {
    margin-left: auto !important;
    margin-right: 0 !important;
}

.slider-align-center {
    margin-left: auto !important;
    margin-right: auto !important;
}

/* Individual slider width overrides */
.slider-width-small { width: 600px !important; }
.slider-width-medium { width: 700px !important; }
.slider-width-large { width: 800px !important; }
.slider-width-xlarge { width: 900px !important; }

body {
    font-family: Arial, sans-serif;
    margin: 0;
    padding: 20px;
    background-color: #f5f5f5;
}

.container {
    max-width: 1200px;
    margin: 0; /* Remove auto centering */
    background-color: white;
    border-radius: 10px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    padding: 20px;
    align-items: center;
}

h1 {
    text-align: center;
    color: #333;
    margin-bottom: 30px;
}

.controls {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    margin-bottom: 20px;
    padding: 20px;
    background-color: #f8f9fa;
    border-radius: 8px;
}

.control-group {
    display: flex;
    flex-direction: column;
    min-width: 200px;
}

.control-group label {
    font-weight: bold;
    margin-bottom: 5px;
    color: #555;
}

.slider-container {
    display: flex;
    align-items: center;
    gap: 10px;
}

.slider {
    flex: 1;
    height: 6px;
    border-radius: 3px;
    background: #ddd;
    outline: none;
    -webkit-appearance: none;
}

.slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #4CAF50;
    cursor: pointer;
}

.slider::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #4CAF50;
    cursor: pointer;
    border: none;
}

.value-display {
    min-width: 60px;
    text-align: center;
    font-weight: bold;
    color: #333;
}

select {
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
}

.toggles {
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
}

.toggle {
    display: flex;
    align-items: center;
    gap: 8px;
}

.toggle input[type="checkbox"] {
    width: 18px;
    height: 18px;
}

.canvas-container {
    display: flex;
    justify-content: flex-start; /* Left align the canvas */
    margin: 20px 0;
}

canvas {
    border: 1px solid #ddd;
    border-radius: 8px;
    background-color: white;
}

.stats {
    display: flex;
    justify-content: space-around;
    margin-top: 20px;
    padding: 10px;
    background-color: #e8f4f8;
    border-radius: 8px;
}

.stat-item {
    text-align: center;
}

.stat-value {
    font-size: 24px;
    font-weight: bold;
    color: #2c3e50;
}

.stat-label {
    font-size: 14px;
    color: #666;
    margin-top: 5px;
}

/* Special styling for aligned sliders */
.aligned-slider-container {
    position: relative;
    margin: 20px 0;
}

.aligned-slider {
    width: 100%;
    height: 6px;
    border-radius: 3px;
    background: #ddd;
    outline: none;
    -webkit-appearance: none;
    position: relative;
}

.aligned-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #4CAF50;
    cursor: pointer;
}

.aligned-slider::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #4CAF50;
    cursor: pointer;
    border: none;
}

.slider-labels {
    display: flex;
    justify-content: space-between;
    margin-top: 5px;
    font-size: 12px;
    color: #666;
}

.slider-value {
    position: absolute;
    top: -30px;
    left: 50%;
    transform: translateX(-50%);
    background: #333;
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: bold;
    white-space: nowrap;
    pointer-events: none;
}

/* Table-based layout */
.plot-section {
    margin: 20px 0;
}

.main-layout-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 20px;
}

.left-column {
    width: 120px;
    vertical-align: top;
    padding-right: 20px;
}

.center-column {
    width: 800px;
    vertical-align: top;
    padding: 0 20px;
}

.right-column {
    width: 200px;
    vertical-align: top;
    padding-left: 20px;
}

.slider-table {
    width: auto; /* shrink to content so it hugs the left edge */
    border-collapse: collapse;
    margin: 0; /* align to the left inside the container */
    display: table; /* ensure it's not treated as inline-table */
    text-align: left; /* default left alignment within */
}

.slider-label-cell {
    width: 185px;
    vertical-align: middle;
    padding-right: 10px;
    text-align: right;
}

.slider-cell {
    width: 700px;
    vertical-align: middle;
    padding: 5px 0;
    text-align: left; /* Ensure sliders are left-aligned in the cell */
}

.slider-label-cell label {
    font-weight: bold;
    color: #555;
    font-size: 14px;
    display: block;
}

.plot-aligned-slider-container {
    position: relative;
    width: 100%;
    margin: 0; /* prevent unintended right alignment */
    display: inline-block; /* respect text-align on cell */
}

.plot-aligned-slider {
    width: 100%;
    height: 8px;
    border-radius: 4px;
    background: #ddd;
    outline: none;
    -webkit-appearance: none;
    position: relative;
}

.plot-aligned-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: #4CAF50;
    cursor: pointer;
    border: 2px solid white;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.plot-aligned-slider::-moz-range-thumb {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: #4CAF50;
    cursor: pointer;
    border: 2px solid white;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

/* Colored sliders */
.null-slider::-webkit-slider-thumb {
    background: #e74c3c !important;
}

.null-slider::-moz-range-thumb {
    background: #e74c3c !important;
}

.alternative-slider::-webkit-slider-thumb {
    background: #3498db !important;
}

.alternative-slider::-moz-range-thumb {
    background: #3498db !important;
}


.cutoff-slider::-webkit-slider-thumb {
    background: #7f8c8d !important;
}

.cutoff-slider::-moz-range-thumb {
    background: #7f8c8d !important;
}

/* Clickable stats */
.clickable-stat {
    cursor: pointer;
    transition: all 0.2s ease;
    border-radius: 8px;
    padding: 10px;
}

.clickable-stat:hover {
    background-color: rgba(0, 0, 0, 0.05);
    transform: translateY(-2px);
}

.clickable-stat.active {
    background-color: rgba(0, 0, 0, 0.1);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

/* Color coding for stats */
.type1-color {
    color: #e74c3c !important;
}

.type2-color {
    color: #3498db !important;
}

.power-color {
    color: #2ecc71 !important;
}

/* Error rates styling */
.error-rates {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    width: 100%;
}

.error-rates h3 {
    margin: 0 0 15px 0;
    color: #333;
    font-size: 16px;
}

.stat-display {
    display: flex;
    flex-direction: column;
    gap: 15px;
    width: 100%;
}

.clickable-stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 10px;
    border: 2px solid transparent;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: center;
}

.clickable-stat:hover {
    background-color: #f8f9fa;
    border-color: #e9ecef;
}

.clickable-stat.active {
    border-color: #007bff;
    background-color: #e7f3ff;
}

.stat-label {
    font-weight: bold;
    font-size: 14px;
    margin-bottom: 5px;
}

.stat-value {
    font-size: 18px;
    font-weight: bold;
    color: #333;
}

.right-controls {
    display: flex;
    flex-direction: column;
    gap: 30px;
    min-width: 120px;
}

/* Vertical slider */
.vertical-slider-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

.vertical-slider-container label {
    font-weight: bold;
    color: #555;
    font-size: 14px;
}

.vertical-slider-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    /* Let content define height so labels sit directly above/below */
}

.vertical-slider-stack {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px; /* Tight spacing above/below the slider */
}

.slider-end-label {
    font-size: 12px;
    font-weight: bold;
    color: #666;
    padding: 2px 0;
}

.slider-row {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 10px;
    position: relative; /* Anchor the bubble positioning */
}

.vertical-slider {
    writing-mode: bt-lr; /* IE */
    -webkit-appearance: slider-vertical; /* WebKit */
    width: 8px;
    height: 350px; /* Explicit track height for precise positioning */
    background: #ddd;
    outline: none;
    border-radius: 4px;
}

.vertical-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #4CAF50;
    cursor: pointer;
    border: 2px solid white;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.vertical-slider::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #4CAF50;
    cursor: pointer;
    border: 2px solid white;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.vertical-slider-labels {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    height: 180px;
    font-size: 12px;
    color: #666;
}

.vertical-value-display {
    font-weight: bold;
    color: #333;
    font-size: 12px;
    background: #4CAF50;
    color: #fff;
    padding: 2px 6px;
    border-radius: 10px;
    min-width: 28px;
    text-align: center;
    position: absolute;
    left: 20px;
    transform: translateY(-50%);
}

/* Test direction container */
.test-direction-container {
    display: flex;
    justify-content: center;
    margin-top: 15px;
}

/* Two-color toggle switch */
.two-color-toggle {
    position: relative;
    display: inline-block;
    width: 180px;
    height: 35px;
}

.two-color-toggle input {
    opacity: 0;
    width: 0;
    height: 0;
}

.two-color-toggle-label {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #f0f0f0;
    border: 2px solid #ddd;
    transition: .3s;
    border-radius: 18px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 8px;
}

.two-color-toggle-label:before {
    position: absolute;
    content: "";
    height: 25px;
    width: 25px;
    left: 3px;
    bottom: 3px;
    background-color: #4CAF50;
    transition: .3s;
    border-radius: 50%;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

input:checked + .two-color-toggle-label {
    background-color: #e8f5e8;
    border-color: #4CAF50;
}

input:checked + .two-color-toggle-label:before {
    transform: translateX(145px);
    background-color: #4CAF50;
}

.toggle-option {
    font-size: 11px;
    font-weight: bold;
    color: #666;
    z-index: 1;
    transition: color 0.3s;
}

/* When right-tailed is selected (checked) */
input:checked + .two-color-toggle-label .left-option {
    color: #999;
}

input:checked + .two-color-toggle-label .right-option {
    color: #4CAF50;
}

/* When left-tailed is selected (not checked) */
input:not(:checked) + .two-color-toggle-label .left-option {
    color: #4CAF50;
}

input:not(:checked) + .two-color-toggle-label .right-option {
    color: #999;
}

