/* Main Styles for Beach Sand Analysis Web App */
/* Supports Dark and Light themes via CSS custom properties */

/* ===================================== */
/* Theme Variables                        */
/* Dual theme support with CSS variables  */
/* ===================================== */

/* Dark theme (default) - :root provides defaults, [data-bs-theme="dark"] for explicit */
:root,
[data-bs-theme="dark"] {
    /* Backgrounds */
    --sieve-body-bg: #121212;
    --sieve-card-bg: #1e1e1e;
    --sieve-card-header-bg: #252525;
    --sieve-navbar-bg: #1a1a1a;
    --sieve-footer-bg: #1a1a1a;
    --sieve-input-bg: #2a2a2a;
    --sieve-input-focus-bg: #333333;
    --sieve-table-bg: #1e1e1e;
    --sieve-table-striped-bg: #252525;
    --sieve-table-hover-bg: #2a2a2a;
    --sieve-modal-bg: #1e1e1e;

    /* Text colors */
    --sieve-text-primary: #e0e0e0;
    --sieve-text-secondary: #aaaaaa;
    --sieve-text-muted: #888888;
    --sieve-link-color: #6db3f2;
    --sieve-link-hover: #9dcbf7;

    /* Borders */
    --sieve-border-color: #333333;
    --sieve-border-color-subtle: #2a2a2a;

    /* Panel backgrounds (floating sieve/criteria panels) */
    --sieve-panel-bg: #1e1e1e;
    --sieve-panel-header-bg: #252525;

    /* Plotly colors - keep in sync with plot_builder.py DARK_THEME */
    --plot-annotation-bg: rgba(35, 35, 40, 0.95);
    --plot-annotation-border: rgba(100, 100, 100, 0.5);
    --plot-font-color: #c0c0c0;
    --plot-font-muted: #909090;

    /* Status colors - match plot_builder.py */
    --color-pass: #58d68d;
    --color-fail: #e74c3c;
    --color-warning: #f4d03f;

    /* Shadow */
    --sieve-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.3);
    --sieve-shadow-lg: 0 0.5rem 1rem rgba(0, 0, 0, 0.4);

    /* Button colors */
    --sieve-btn-secondary-bg: #444444;
    --sieve-btn-secondary-border: #555555;
    --sieve-btn-outline-color: #aaaaaa;
}

/* Light theme - MUST come after :root to override via cascade */
[data-bs-theme="light"] {
    /* Backgrounds */
    --sieve-body-bg: #f8f9fa;
    --sieve-card-bg: #ffffff;
    --sieve-card-header-bg: #f8f9fa;
    --sieve-navbar-bg: #ffffff;
    --sieve-footer-bg: #f8f9fa;
    --sieve-input-bg: #ffffff;
    --sieve-input-focus-bg: #ffffff;
    --sieve-table-bg: #ffffff;
    --sieve-table-striped-bg: #f8f9fa;
    --sieve-table-hover-bg: #e9ecef;
    --sieve-modal-bg: #ffffff;

    /* Text colors */
    --sieve-text-primary: #212529;
    --sieve-text-secondary: #495057;
    --sieve-text-muted: #6c757d;
    --sieve-link-color: #0d6efd;
    --sieve-link-hover: #0a58ca;

    /* Borders */
    --sieve-border-color: #dee2e6;
    --sieve-border-color-subtle: #e9ecef;

    /* Panel backgrounds (floating sieve/criteria panels) */
    --sieve-panel-bg: #ffffff;
    --sieve-panel-header-bg: #f8f9fa;

    /* Plotly colors - light theme equivalents */
    --plot-annotation-bg: rgba(248, 249, 250, 0.95);
    --plot-annotation-border: rgba(0, 0, 0, 0.1);
    --plot-font-color: #212529;
    --plot-font-muted: #6c757d;

    /* Status colors */
    --color-pass: #198754;
    --color-fail: #dc3545;
    --color-warning: #ffc107;

    /* Shadow */
    --sieve-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
    --sieve-shadow-lg: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);

    /* Button colors */
    --sieve-btn-secondary-bg: #e9ecef;
    --sieve-btn-secondary-border: #dee2e6;
    --sieve-btn-outline-color: #6c757d;
}

/* Smooth theme transition */
html.theme-transitioning,
html.theme-transitioning *,
html.theme-transitioning *::before,
html.theme-transitioning *::after {
    transition: background-color 0.3s ease,
                border-color 0.3s ease,
                color 0.3s ease,
                box-shadow 0.3s ease !important;
}

html {
    /* Always show scrollbar to prevent layout shift when content changes */
    overflow-y: scroll;
    /* Reserve space for scrollbar to prevent content shift */
    scrollbar-gutter: stable;
}

body {
    background-color: var(--sieve-body-bg) !important;
    color: var(--sieve-text-primary) !important;
    overflow-x: hidden; /* Prevent horizontal scrollbar */
}

.navbar {
    background-color: var(--sieve-navbar-bg) !important;
    border-bottom: 1px solid var(--sieve-border-color);
}

/* Theme toggle button in navbar */
#theme-toggle-btn {
    border: none;
    background: transparent;
    padding: 0.375rem 0.5rem;
    border-radius: 0.375rem;
    transition: background-color 0.2s ease;
    color: var(--sieve-text-primary);
}

#theme-toggle-btn:hover {
    background-color: var(--sieve-border-color);
}

#theme-toggle-btn:focus {
    outline: none;
    box-shadow: none;
}

#theme-toggle-btn i {
    font-size: 1.1rem;
}

[data-bs-theme="dark"] #theme-toggle-btn i {
    color: #ffc107;
}

[data-bs-theme="light"] #theme-toggle-btn i {
    color: #0d6efd;
}

/* Align navbar content with main content area (between sidebars) */
.navbar .container {
    max-width: calc(100vw - 520px);
    margin-left: 250px;
    margin-right: 250px;
    padding-left: 0;
    padding-right: 0;
}

@media (max-width: 1400px) {
    .navbar .container {
        max-width: 100%;
        margin-left: 20px;
        margin-right: 20px;
    }
}

.card {
    background-color: var(--sieve-card-bg) !important;
    border-color: var(--sieve-border-color) !important;
    color: var(--sieve-text-primary) !important;
}

.card-header {
    background-color: var(--sieve-card-header-bg) !important;
    border-color: var(--sieve-border-color) !important;
}

.table {
    color: var(--sieve-text-primary) !important;
    --bs-table-bg: var(--sieve-table-bg);
    --bs-table-color: var(--sieve-text-primary);
    --bs-table-striped-bg: var(--sieve-table-striped-bg);
    --bs-table-striped-color: var(--sieve-text-primary);
    --bs-table-hover-bg: var(--sieve-table-hover-bg);
    --bs-table-hover-color: var(--sieve-text-primary);
}

.table > :not(caption) > * > * {
    color: var(--sieve-text-primary) !important;
    background-color: var(--sieve-table-bg) !important;
}

.table-striped > tbody > tr:nth-of-type(odd) > * {
    background-color: var(--sieve-table-striped-bg) !important;
    color: var(--sieve-text-primary) !important;
}

.table-light th {
    background-color: var(--sieve-card-header-bg) !important;
    color: var(--sieve-text-primary) !important;
}

.table-hover > tbody > tr:hover > * {
    background-color: var(--sieve-table-hover-bg) !important;
    color: var(--sieve-text-primary) !important;
}

/* Best result row highlight - subtle for dark theme */
tr.best-algo-row > td:first-child {
    border-left: 3px solid #4a9a6a;
}

/* Qualifying solutions - translucent green background */
tr.qualifying-row > td {
    background-color: rgba(72, 187, 120, 0.15) !important;
}

tr.qualifying-row:hover > td {
    background-color: rgba(72, 187, 120, 0.25) !important;
}

/* Non-qualifying solutions - translucent red background */
tr.non-qualifying-row > td {
    background-color: rgba(220, 53, 69, 0.15) !important;
}

tr.non-qualifying-row:hover > td {
    background-color: rgba(220, 53, 69, 0.25) !important;
}

/* Hidden state for non-qualifying toggle */
tr.non-qualifying-row.hidden-row {
    display: none;
}

.modal-content {
    background-color: var(--sieve-modal-bg) !important;
    color: var(--sieve-text-primary) !important;
    border-color: var(--sieve-border-color) !important;
}

.modal-header {
    border-color: var(--sieve-border-color) !important;
}

.modal-footer {
    border-color: var(--sieve-border-color) !important;
}

/* Modal body borders */
.modal-body .border-bottom {
    border-color: var(--sieve-border-color) !important;
}

.modal-body h6 {
    color: var(--sieve-text-primary);
}

/* Checkbox styling */
.form-check-input {
    background-color: var(--sieve-input-bg);
    border-color: var(--sieve-border-color) !important;
    /* Ensure checkboxes maintain proper square dimensions */
    width: 1em !important;
    height: 1em !important;
    flex-shrink: 0;
}

.form-check-input:checked {
    background-color: #0d6efd;
    border-color: #0d6efd !important;
}

.form-check-input:focus {
    border-color: #0d6efd !important;
    box-shadow: 0 0 0 0.2rem rgba(13, 110, 253, 0.25);
}

.form-control, .form-select {
    background-color: var(--sieve-input-bg) !important;
    border-color: var(--sieve-border-color) !important;
    color: var(--sieve-text-primary) !important;
}

.form-control:focus, .form-select:focus {
    background-color: var(--sieve-input-focus-bg) !important;
    border-color: var(--sieve-border-color) !important;
    color: var(--sieve-text-primary) !important;
}

.text-muted {
    color: var(--sieve-text-muted) !important;
}

.list-group-item {
    background-color: var(--sieve-card-bg) !important;
    border-color: var(--sieve-border-color) !important;
    color: var(--sieve-text-primary) !important;
}

.list-group-item-success {
    background-color: rgba(25, 135, 84, 0.2) !important;
    color: #75d9a3 !important;
}

.list-group-item-danger {
    background-color: rgba(220, 53, 69, 0.2) !important;
    color: #f5a6ae !important;
}

footer, .footer {
    background-color: var(--sieve-footer-bg) !important;
    color: var(--sieve-text-muted) !important;
}

a {
    color: var(--sieve-link-color) !important;
}

a:hover {
    color: var(--sieve-link-hover) !important;
}

.btn-primary {
    background-color: #0d6efd !important;
}

.btn-secondary {
    background-color: var(--sieve-btn-secondary-bg) !important;
    border-color: var(--sieve-btn-secondary-border) !important;
}

.btn-outline-secondary {
    color: var(--sieve-btn-outline-color) !important;
    border-color: var(--sieve-btn-secondary-border) !important;
}

.page-link {
    background-color: var(--sieve-card-bg) !important;
    border-color: var(--sieve-border-color) !important;
    color: var(--sieve-link-color) !important;
}

.page-item.active .page-link {
    background-color: #0d6efd !important;
    border-color: #0d6efd !important;
}

.page-item.disabled .page-link {
    background-color: var(--sieve-navbar-bg) !important;
    color: var(--sieve-text-muted) !important;
}

hr {
    border-color: var(--sieve-border-color) !important;
}

/* Bootstrap overrides for theme */
.bg-light {
    background-color: var(--sieve-card-bg) !important;
    color: var(--sieve-text-primary) !important;
}

.border {
    border-color: var(--sieve-border-color) !important;
}

.alert {
    background-color: var(--sieve-card-header-bg) !important;
    border-color: var(--sieve-border-color) !important;
    color: var(--sieve-text-primary) !important;
}

.alert-info {
    background-color: rgba(13, 110, 253, 0.15) !important;
    border-color: rgba(13, 110, 253, 0.3) !important;
    color: #6db3f2 !important;
}

.alert-success {
    background-color: rgba(25, 135, 84, 0.15) !important;
    border-color: rgba(25, 135, 84, 0.3) !important;
    color: #75d9a3 !important;
}

.alert-warning {
    background-color: rgba(255, 193, 7, 0.15) !important;
    border-color: rgba(255, 193, 7, 0.3) !important;
    color: #f0c674 !important;
}

.alert-danger {
    background-color: rgba(220, 53, 69, 0.15) !important;
    border-color: rgba(220, 53, 69, 0.3) !important;
    color: #f5a6ae !important;
}

/* Card hover effects */
.hover-card {
    transition: all 0.3s ease;
    box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
}

.hover-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
}

/* Table styling */
.table-sieve th {
    background-color: var(--sieve-card-header-bg) !important;
    font-weight: 600;
    vertical-align: middle;
    color: var(--sieve-text-primary) !important;
}

.table-sieve td {
    vertical-align: middle;
    color: var(--sieve-text-primary) !important;
}

/* Sticky table header for scrollable tables */
.table-responsive thead th {
    background-color: var(--sieve-card-header-bg) !important;
    color: var(--sieve-text-primary) !important;
}

/* Sortable table headers */
th.sortable {
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
    transition: background-color 0.15s ease;
}

th.sortable:hover {
    background-color: var(--sieve-table-hover-bg) !important;
}

th.sortable .sort-icon {
    margin-left: 0.25rem;
    font-size: 0.75rem;
    opacity: 0.5;
    transition: opacity 0.15s ease;
}

th.sortable:hover .sort-icon {
    opacity: 0.8;
}

th.sortable.sorted-asc .sort-icon,
th.sortable.sorted-desc .sort-icon {
    opacity: 1;
    color: #6db3f2;
}

/* Progress bar custom styling */
.progress-criteria {
    height: 1.5rem;
    border-radius: 0.5rem;
}

.progress-criteria .progress-bar {
    border-radius: 0.5rem;
    font-weight: 600;
    line-height: 1.5rem;
}

/* Page headers */
.page-header {
    padding-bottom: 1rem;
    margin-bottom: 2rem;
    border-bottom: 1px solid #e9ecef;
}

/* Form elements */
.form-label {
    font-weight: 500;
}

.form-text {
    font-size: 0.85rem;
}

/* Plot container */
.plot-container {
    background-color: var(--sieve-card-bg);
    border-radius: 0.5rem;
    padding: 1rem;
    margin-bottom: 1.5rem;
    box-shadow: var(--sieve-shadow);
    border: 1px solid var(--sieve-border-color);
}

.plot-container img {
    width: 100%;
    height: auto;
    border-radius: 0.25rem;
}

/* Parameter cards */
.parameter-value {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 0;
    line-height: 1.2;
}

.parameter-label {
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #6c757d;
    margin-bottom: 0;
}

/* Criteria assessment */
.criteria-list {
    list-style-type: none;
    padding-left: 0;
}

.criteria-list li {
    padding: 0.5rem 0;
    border-bottom: 1px solid #e9ecef;
}

.criteria-list li:last-child {
    border-bottom: none;
}

.criteria-list .bi-check-circle {
    color: #198754;
}

.criteria-list .bi-x-circle {
    color: #dc3545;
}

/* Footer styling */
footer {
    margin-top: 4rem;
    padding-top: 2rem;
    padding-bottom: 2rem;
}

/* Mobile responsive adjustments */
@media (max-width: 768px) {
    .parameter-value {
        font-size: 1.75rem;
    }

    .btn-group {
        display: flex;
        flex-direction: column;
    }

    .btn-group .btn {
        margin-bottom: 0.5rem;
    }

    .page-header {
        text-align: center;
    }
}

/* ===================================== */
/* Card Container (Sortable & Collapsible) */
/* ===================================== */

/* Card container - holds all card slots */
.card-container {
    display: flex;
    flex-wrap: wrap;
    margin: -0.5rem;
    width: calc(100% + 1rem);
    overflow: hidden; /* Contain negative margin overflow */
}

/* Card slot - sortable wrapper that positions each card */
.card-container > .card-slot {
    padding: 0.5rem;
    box-sizing: border-box;
    min-width: 0; /* Prevent flex items from overflowing */
}

/* Full width cards */
.card-container > .card-slot.full-width {
    width: 100%;
    flex: 0 0 100%;
}

/* Half width cards */
.card-container > .card-slot.half-width {
    width: 50%;
    flex: 0 0 50%;
}

@media (max-width: 768px) {
    .card-container > .card-slot.half-width {
        width: 100%;
        flex: 0 0 100%;
    }
}

/* Plot containers - allow visible overflow for axis labels */
#sortable-cards .card {
    overflow: visible;
    width: 100%;
}

#sortable-cards .card-body {
    overflow: visible;
    padding: 1rem;
}

#sortable-cards [id$="-plot"] {
    max-width: 100%;
    overflow: visible;
}

/* Plotly chart containers */
.js-plotly-plot, .plotly {
    overflow: hidden !important;
}

.js-plotly-plot .main-svg {
    overflow: visible !important;
}

/* Clip the cartesian layer to prevent log-scale overflow */
.js-plotly-plot .cartesianlayer {
    clip-path: inset(0);
}

/* Ensure plot divs have enough space */
[id$="-plot"] {
    min-height: 650px;
    overflow: visible !important;
}

/* Prevent clipping on collapsible cards */
.collapsible-card .card-body {
    overflow: visible !important;
}

/* Plot area needs visible overflow for axis labels */
.plot-container,
.modebar-container {
    overflow: visible !important;
}

/* Collapsible card styling */
.collapsible-card {
    position: relative;
    transition: box-shadow 0.2s ease, transform 0.2s ease;
    overflow: visible !important;
}

.collapsible-card:hover {
    box-shadow: 0 0.5rem 1.5rem rgba(0, 0, 0, 0.4);
}

.collapsible-card > .card-body {
    overflow: visible !important;
    padding-bottom: 1.5rem;
}

/* ===================================== */
/* Collapsible Cards                     */
/* ===================================== */

/* Collapse toggle button */
.collapse-toggle {
    cursor: pointer;
    padding: 0.25rem 0.5rem;
    border-radius: 0.25rem;
    transition: color 0.15s ease, background 0.15s ease, transform 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.collapse-toggle:hover {
    color: #fff !important;
    background: rgba(255, 255, 255, 0.1);
}

.collapse-toggle i {
    transition: transform 0.2s ease;
}

/* Rotate chevron when collapsed */
.collapsible-card.collapsed .collapse-toggle i {
    transform: rotate(-90deg);
}

/* Card body collapse animation */
.collapsible-card .card-body {
    transition: max-height 0.3s ease, opacity 0.2s ease, padding 0.3s ease;
    overflow: hidden;
}

.collapsible-card.collapsed .card-body {
    max-height: 0 !important;
    opacity: 0;
    padding-top: 0 !important;
    padding-bottom: 0 !important;
    overflow: hidden;
}

/* Ensure expanded cards don't have max-height constraint */
.collapsible-card:not(.collapsed) .card-body {
    max-height: none;
    opacity: 1;
}

/* Drag handle - the grip icon that triggers dragging */
.drag-handle {
    cursor: grab;
    user-select: none;
    padding: 0.25rem 0.5rem;
    border-radius: 0.25rem;
    transition: color 0.15s ease, background 0.15s ease;
}

.drag-handle:hover {
    color: #fff !important;
    background: rgba(255, 255, 255, 0.1);
}

.drag-handle:active {
    cursor: grabbing;
    color: #fff !important;
    background: rgba(255, 255, 255, 0.15);
}

/* Drag icon in header (legacy support) */
.drag-icon {
    color: #666;
    font-size: 1.25rem;
    cursor: grab;
    padding: 0.25rem;
    border-radius: 0.25rem;
    transition: color 0.2s ease, background 0.2s ease;
}

.drag-icon:hover {
    color: #aaa;
    background: rgba(255, 255, 255, 0.1);
}

.drag-icon:active {
    cursor: grabbing;
    color: #fff;
}

/* Drag icon on success (green) headers */
.bg-success .drag-icon {
    color: rgba(255, 255, 255, 0.6);
}

.bg-success .drag-icon:hover {
    color: #fff;
    background: rgba(0, 0, 0, 0.2);
}

/* Sortable cards container */
#sortable-cards {
    min-height: 100px;
}

/* Sortable ghost (placeholder) */
.sortable-ghost {
    opacity: 0.4;
}

/* Sortable chosen (being dragged) */
.sortable-chosen {
    box-shadow: 0 1rem 3rem rgba(0, 0, 0, 0.5) !important;
    transform: rotate(2deg);
}

/* Sortable drag (actual dragging element) */
.sortable-drag {
    opacity: 1 !important;
    box-shadow: 0 1rem 3rem rgba(0, 0, 0, 0.6) !important;
}

/* Drop zone indicator */
.sortable-fallback {
    opacity: 0.8;
}

/* Card header with drag indicator */
.card-header.draggable-header {
    position: relative;
    padding-right: 3rem;
}

.card-header .drag-indicator {
    position: absolute;
    right: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: #555;
    cursor: grab;
    padding: 0.25rem;
    border-radius: 0.25rem;
    transition: color 0.2s, background 0.2s;
}

.card-header .drag-indicator:hover {
    color: #888;
    background: rgba(255, 255, 255, 0.05);
}

.card-header .drag-indicator:active {
    cursor: grabbing;
}

/* ===================================== */
/* Sortable Tabs                        */
/* ===================================== */

/* Make tabs draggable */
.nav-tabs.sortable-tabs .nav-item {
    cursor: grab;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.nav-tabs.sortable-tabs .nav-item:active {
    cursor: grabbing;
}

/* Tab being dragged */
.nav-tabs.sortable-tabs .nav-item.sortable-chosen {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
    z-index: 100;
}

/* Ghost placeholder for tabs */
.nav-tabs.sortable-tabs .nav-item.sortable-ghost {
    opacity: 0.3;
}

/* Drag indicator on hover */
.nav-tabs.sortable-tabs .nav-link::before {
    content: '\F3FE';  /* Bootstrap Icons grip-vertical */
    font-family: 'bootstrap-icons';
    margin-right: 0.5rem;
    opacity: 0;
    transition: opacity 0.2s;
    font-size: 0.8em;
    color: #666;
}

.nav-tabs.sortable-tabs .nav-item:hover .nav-link::before {
    opacity: 0.6;
}

/* ===================================== */
/* Floating Criteria Panel              */
/* ===================================== */

/* Floating panel */
.criteria-panel {
    position: fixed;
    left: -240px;
    top: calc(40vh + 30px);
    width: 220px;
    max-height: calc(60vh - 50px);
    background-color: var(--sieve-panel-bg);
    border: 1px solid var(--sieve-border-color);
    border-radius: 8px;
    box-shadow: var(--sieve-shadow-lg);
    z-index: 1039;
    transition: left 0.3s ease, right 0.3s ease;
    overflow: hidden;
}

.criteria-panel.open {
    left: 20px;
    right: auto;
}

.criteria-panel.open.position-right {
    left: auto;
    right: 20px;
    box-shadow: -4px 0 20px rgba(0, 0, 0, 0.4);
}

/* Panel drag handle */
.panel-drag-handle {
    cursor: grab;
    padding: 2px 4px;
    margin-left: 8px;
    color: #666;
    transition: color 0.2s;
}

.panel-drag-handle:hover {
    color: #aaa;
}

.panel-drag-handle:active {
    cursor: grabbing;
}

/* Panel being dragged */
.sieve-panel.dragging,
.criteria-panel.dragging {
    opacity: 0.8;
    z-index: 1050;
}

/* Drop zone indicators */
.panel-drop-zone {
    position: fixed;
    top: 0;
    bottom: 0;
    width: 100px;
    background: transparent;
    z-index: 1040;
    pointer-events: none;
    transition: background 0.2s;
}

.panel-drop-zone.left {
    left: 0;
}

.panel-drop-zone.right {
    right: 0;
}

.panel-drop-zone.active {
    background: rgba(13, 110, 253, 0.1);
    border: 2px dashed rgba(13, 110, 253, 0.5);
}

/* ===================================== */
/* Unified Floating Panel Styles         */
/* ===================================== */

/* Common panel header - used by all floating panels */
.floating-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 10px;
    background-color: var(--sieve-panel-header-bg);
    border-bottom: 1px solid var(--sieve-border-color);
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--sieve-text-primary);
    flex-shrink: 0;
}

/* Common panel body - used by all floating panels */
.floating-panel-body {
    padding: 8px 10px;
    overflow-y: auto;
    flex: 1;
    min-height: 0;
}

/* Common param row for all panels */
.param-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 4px 0;
    border-bottom: 1px solid var(--sieve-border-color-subtle);
    font-size: 0.75rem;
}

.param-row:last-child {
    border-bottom: none;
}

/* Make all values in param rows bold */
.param-row > span:last-child,
.param-row > span:last-of-type {
    font-weight: 600;
}

/* Common param badge for all panels */
.param-badge {
    display: inline-block;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.7rem;
}

/* Params section container */
.params-section {
    margin-bottom: 0;
}

.params-section.mb-3 {
    margin-bottom: 8px !important;
}

/* Legacy class aliases for backward compatibility */
.criteria-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 10px;
    background-color: var(--sieve-panel-header-bg);
    border-bottom: 1px solid var(--sieve-border-color);
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--sieve-text-primary);
}

.criteria-panel-body {
    padding: 8px 10px;
    overflow-y: auto;
    max-height: calc(100vh - 180px);
}

/* Criteria rows */
.criteria-row {
    margin-bottom: 6px;
}

.criteria-label {
    display: block;
    font-size: 0.65rem;
    color: #888;
    margin-bottom: 2px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.criteria-inputs {
    display: flex;
    align-items: center;
    gap: 4px;
}

.criteria-inputs.single {
    max-width: 100px;
}

.criteria-sep {
    color: #666;
    font-size: 0.8rem;
    flex-shrink: 0;
}

/* Compact form controls */
.criteria-panel .form-control,
.criteria-panel .form-select {
    background-color: var(--sieve-input-bg) !important;
    border-color: var(--sieve-border-color) !important;
    color: var(--sieve-text-primary) !important;
    font-size: 0.75rem;
    padding: 3px 6px;
    height: auto;
}

.criteria-panel .form-control:focus,
.criteria-panel .form-select:focus {
    background-color: var(--sieve-input-focus-bg) !important;
    border-color: #0d6efd !important;
    box-shadow: 0 0 0 2px rgba(13, 110, 253, 0.2);
}

/* Status display */
.criteria-status {
    font-size: 0.7rem;
    padding: 4px 0;
    min-height: 22px;
}

.criteria-status .spinner-border {
    width: 0.7rem;
    height: 0.7rem;
}

/* Action buttons */
.criteria-actions {
    display: flex;
    gap: 6px;
    padding-top: 6px;
    border-top: 1px solid var(--sieve-border-color);
    margin-top: 6px;
}

.criteria-actions .btn {
    flex: 1;
    font-size: 0.7rem;
    padding: 4px 6px;
}

/* Preview indicator animation */
#preview-indicator {
    animation: pulse-warning 1.5s ease-in-out infinite;
}

@keyframes pulse-warning {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

/* Mobile adjustments */
@media (max-width: 768px) {
    .criteria-panel {
        top: auto;
        bottom: 20px;
        left: 10px;
        max-height: 60vh;
    }

    .criteria-panel.open.position-right {
        left: auto;
        right: 10px;
    }
}

/* ===================================== */
/* Floating Sieve Sizes Panel (Left)     */
/* ===================================== */

.sieve-panel {
    position: fixed;
    left: -240px;
    top: 10px;
    width: 220px;
    max-height: calc(40vh);
    background-color: var(--sieve-panel-bg);
    border: 1px solid var(--sieve-border-color);
    border-radius: 8px;
    box-shadow: var(--sieve-shadow-lg);
    z-index: 1039;
    transition: left 0.3s ease, right 0.3s ease;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.sieve-panel.open {
    left: 20px;
    right: auto;
}

.sieve-panel.open.position-right {
    left: auto;
    right: 20px;
    box-shadow: -4px 0 20px rgba(0, 0, 0, 0.4);
}

.sieve-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 10px;
    background-color: var(--sieve-panel-header-bg);
    border-bottom: 1px solid var(--sieve-border-color);
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--sieve-text-primary);
    flex-shrink: 0;
}

.sieve-panel-body {
    padding: 6px 10px;
    overflow-y: auto;
    flex: 1;
    min-height: 0;
}

#sieve-sizes-list {
    max-height: calc(30vh - 140px);
    overflow-y: auto;
}

.sieve-panel-footer {
    padding: 6px 10px;
    background-color: var(--sieve-panel-header-bg);
    border-top: 1px solid var(--sieve-border-color);
    flex-shrink: 0;
}

.sieve-size-item {
    display: flex;
    align-items: center;
    padding: 2px 0;
    border-bottom: 1px solid var(--sieve-border-color-subtle);
}

.sieve-size-item:last-child {
    border-bottom: none;
}

.sieve-size-item label {
    margin-left: 6px;
    margin-bottom: 0;
    font-size: 0.75rem;
    color: #ccc;
    cursor: pointer;
    flex: 1;
}

.sieve-size-item input[type="checkbox"] {
    cursor: pointer;
}

.sieve-size-item.disabled label {
    color: #666;
    text-decoration: line-through;
}

.sieve-count-badge {
    font-size: 0.75rem;
    padding: 2px 6px;
    border-radius: 10px;
    background-color: #3498db;
    color: white;
}

/* Sample detail page with both panels */
.sample-detail-content {
    max-width: calc(100vw - 520px);
    margin-left: 250px;
    margin-right: 250px;
    overflow-x: hidden;
}

/* Hide panels on smaller screens */
@media (max-width: 1400px) {
    .sample-detail-content {
        max-width: 100%;
        margin-left: 20px;
        margin-right: 20px;
    }

    .sieve-panel,
    .criteria-panel {
        display: none;
    }
}

@media (max-width: 768px) {
    .sieve-panel {
        top: auto;
        bottom: 20px;
        left: 10px;
        max-height: 60vh;
    }
}

/* ===================================== */
/* Right-side Floating Panels            */
/* ===================================== */

.right-panel {
    position: fixed;
    right: -240px;
    width: 220px;
    background-color: var(--sieve-panel-bg);
    border: 1px solid var(--sieve-border-color);
    border-radius: 8px;
    box-shadow: var(--sieve-shadow-lg);
    z-index: 1039;
    transition: right 0.3s ease;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.right-panel.open {
    right: 20px;
}

/* Right panels moved to left side */
.right-panel.position-left {
    right: auto;
    left: 20px;
    box-shadow: 4px 0 20px rgba(0, 0, 0, 0.4);
}

/* Best Solution Panel */
.best-solution-panel {
    top: 10px;
    max-height: none;
}

.best-solution-panel .right-panel-body {
    overflow-y: visible;
}

/* Assessment Panel */
.assessment-panel {
    top: 10px;
    max-height: calc(60vh);
}

.right-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 10px;
    border-bottom: 1px solid var(--sieve-border-color);
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--sieve-text-primary);
    flex-shrink: 0;
}

.best-solution-panel .right-panel-header {
    background-color: #198754;
    color: white;
    transition: background-color 0.2s ease;
}

.best-solution-panel .right-panel-header.custom-mode {
    background-color: #ffc107;
    color: #212529;
}

.assessment-panel .right-panel-header {
    background-color: var(--sieve-panel-header-bg);
}

.right-panel-body {
    padding: 8px 10px;
    overflow-y: auto;
    flex: 1;
    min-height: 0;
}

/* Compact stats layout for floating panels */
.right-panel .stat-item {
    text-align: center;
    padding: 4px 2px;
}

.right-panel .stat-value {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 1px;
}

.right-panel .stat-label {
    font-size: 0.65rem;
    color: var(--sieve-text-muted);
}

/* Hide right panels on small screens */
@media (max-width: 992px) {
    .right-panel {
        display: none;
    }
}

/* ===================================== */
/* Pareto Tabs Styling                   */
/* ===================================== */

#paretoTabs {
    border-bottom-color: var(--sieve-border-color);
}

#paretoTabs .nav-link {
    color: var(--sieve-text-muted);
    background-color: transparent;
    border-color: transparent;
    border-bottom: 2px solid transparent;
    padding: 0.75rem 1rem;
    transition: all 0.2s ease;
}

#paretoTabs .nav-link:hover {
    color: var(--sieve-text-primary);
    border-color: transparent;
    border-bottom-color: var(--sieve-border-color);
}

#paretoTabs .nav-link.active {
    color: var(--sieve-link-color);
    background-color: transparent;
    border-color: transparent;
    border-bottom: 2px solid #0d6efd;
}

#paretoTabsContent {
    padding-top: 1rem;
}

#paretoTabsContent .tab-pane {
    background-color: transparent;
}

/* ===================================== */
/* Plot Info Box                          */
/* Matches Plotly annotation style        */
/* ===================================== */
.plot-info-box {
    position: absolute;
    background: var(--plot-annotation-bg);
    border: 1px solid var(--plot-annotation-border);
    border-radius: 2px;
    padding: 8px;
    font-size: 10px;
    font-family: monospace;
    color: var(--plot-font-color);
    z-index: 100;
    pointer-events: none;
    line-height: 1.4;
}
.plot-info-box .info-header {
    font-weight: bold;
    color: var(--plot-font-color);
    font-size: 11px;
    margin-bottom: 6px;
    padding-bottom: 4px;
    border-bottom: 1px solid var(--plot-annotation-border);
}
.plot-info-box .info-section {
    margin-bottom: 6px;
}
.plot-info-box .info-section:last-child {
    margin-bottom: 0;
}
.plot-info-box .info-title {
    font-weight: bold;
    color: var(--plot-font-color);
    margin-bottom: 2px;
}
.plot-info-box .info-grid {
    display: grid;
    grid-template-columns: auto auto;
    gap: 1px 8px;
}
.plot-info-box .info-label {
    color: var(--plot-font-muted);
}
.plot-info-box .info-value {
    color: var(--plot-font-color);
    text-align: right;
    font-weight: 600;
}
.plot-info-box .info-value.pass {
    color: var(--color-pass);
}
.plot-info-box .info-value.fail {
    color: var(--color-fail);
}
.plot-info-box .info-value-container {
    display: flex;
    align-items: center;
    gap: 4px;
    justify-content: flex-end;
}
.plot-info-box .info-equipment-section {
    margin-top: 6px;
    padding-top: 6px;
    border-top: 1px solid var(--plot-annotation-border);
}

/* ===================================== */
/* Solution Cross-Highlighting           */
/* ===================================== */

/* Highlighted table row */
#qualifying-table tbody tr.solution-highlighted {
    background-color: rgba(13, 110, 253, 0.3) !important;
    outline: 2px solid #0d6efd;
    outline-offset: -2px;
}

#qualifying-table tbody tr.solution-highlighted td {
    background-color: transparent !important;
}

/* Make table rows clickable */
#qualifying-table tbody tr {
    cursor: pointer;
    transition: background-color 0.15s ease;
}

#qualifying-table tbody tr:hover {
    background-color: rgba(13, 110, 253, 0.15) !important;
}

/* Center align all qualifying table cells */
#qualifying-table th,
#qualifying-table td {
    text-align: center;
    vertical-align: middle;
}

/* ===================================== */
/* Preset Selector Styling               */
/* ===================================== */

.preset-selector {
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--sieve-border-color);
}

.preset-selector .form-select {
    background-color: var(--sieve-input-bg);
    border-color: var(--sieve-border-color);
    color: var(--sieve-text-primary);
    font-size: 0.75rem;
}

.preset-selector .form-select:focus {
    border-color: #0d6efd;
    box-shadow: 0 0 0 0.2rem rgba(13, 110, 253, 0.25);
}

.preset-selector .btn-outline-danger {
    border-color: var(--sieve-border-color);
    color: #dc3545;
    padding: 0.25rem 0.5rem;
}

.preset-selector .btn-outline-danger:hover {
    background-color: #dc3545;
    border-color: #dc3545;
    color: #fff;
}

.sieve-panel-footer #sieve-save-preset,
.criteria-panel-body #criteria-save-preset {
    font-size: 0.75rem;
    padding: 0.35rem 0.5rem;
}

/* ===================================== */
/* Plot Fullscreen Mode                  */
/* ===================================== */

/* Fullscreen container styling */
.card-body:fullscreen {
    background-color: var(--sieve-navbar-bg);
    padding: 20px;
    display: flex;
    flex-direction: column;
    width: 100vw !important;
    height: 100vh !important;
}

/* Tabs navigation in fullscreen - fixed at top */
.card-body:fullscreen > .nav-tabs {
    flex-shrink: 0;
    margin-bottom: 15px;
}

/* Tab content in fullscreen - fill remaining space */
.card-body:fullscreen > .tab-content {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

/* Active tab pane fills the tab-content */
.card-body:fullscreen > .tab-content > .tab-pane.active {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

/* Plot div fills the tab pane */
.card-body:fullscreen [id$="-plot"] {
    flex: 1;
    min-height: 0;
    width: 100% !important;
}

/* For non-tabbed plots (direct child of card-body) */
.card-body:fullscreen > [id$="-plot"] {
    flex: 1;
    min-height: 0;
    width: 100% !important;
}

/* Ensure Plotly components fill available space */
.card-body:fullscreen .js-plotly-plot,
.card-body:fullscreen .plot-container {
    width: 100% !important;
    height: 100% !important;
}

.card-body:fullscreen .svg-container {
    width: 100% !important;
    height: 100% !important;
}

/* ===================================== */
/* Modal-Embedded Panels                 */
/* ===================================== */

/* Container for side-by-side panels in modal */
.modal-panels-row {
    display: flex;
    gap: 15px;
}

.modal-panels-row > .modal-panel-col {
    flex: 1;
    min-width: 0;
}

/* Override floating behavior for modal-embedded panels */
.modal-embedded.sieve-panel,
.modal-embedded.criteria-panel {
    position: static;
    width: 100%;
    max-height: none;
    transform: none;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.modal-embedded.sieve-panel {
    left: auto;
}

.modal-embedded.criteria-panel {
    right: auto;
}

/* Modal panel body with scroll */
.modal-embedded .sieve-panel-body {
    max-height: 250px;
    overflow-y: auto;
}

.modal-embedded .criteria-panel-body {
    max-height: none;
}

/* Hide drag handles in modal */
.modal-embedded .panel-drag-handle {
    display: none;
}

/* Responsive stacking for small screens */
@media (max-width: 768px) {
    .modal-panels-row {
        flex-direction: column;
    }
}


/* =============================================================================
   CUSTOMIZE TAB STYLES - Interactive Draggable Plots
   ============================================================================= */

/* Status bar styling */
.customize-status-bar {
    background-color: var(--sieve-navbar-bg);
    border: 1px solid var(--sieve-border-color);
    border-radius: 8px;
    padding: 12px 16px;
}

.customize-status-bar .yield-display {
    background-color: var(--sieve-card-header-bg);
    padding: 6px 12px;
    border-radius: 6px;
    border: 1px solid var(--sieve-border-color);
}

.customize-status-bar .analysis-display {
    background-color: var(--sieve-card-header-bg);
    padding: 6px 12px;
    border-radius: 6px;
    border: 1px solid var(--sieve-border-color);
}

/* Sieve item styling for customize tab */
.customize-sieve-item {
    margin-bottom: 2px;
}

.customize-sieve-item .form-check-label {
    cursor: pointer;
    user-select: none;
}

.customize-sieve-item .form-check-input:not(:checked) + .form-check-label {
    color: #666;
    text-decoration: line-through;
}

/* ===================================== */
/* Drag Overlay and Handles (Plot B)     */
/* ===================================== */

/* Overlay container - sits on top of plot, passes through clicks by default */
.drag-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
    z-index: 10;
}

/* Cutoff line drag handles - vertical strips that can be grabbed */
.cutoff-drag-handle {
    position: absolute;
    top: 60px;
    bottom: 60px;
    width: 24px;
    transform: translateX(-50%);
    cursor: ew-resize;
    pointer-events: all;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 11;
    border-radius: 4px;
    transition: background-color 0.15s ease;
}

/* Vertical line indicator */
.cutoff-drag-handle::before {
    content: '';
    position: absolute;
    top: 0;
    bottom: 0;
    width: 3px;
    border-radius: 2px;
}

/* Upper cutoff - red theme */
.cutoff-drag-handle.upper-cutoff::before {
    background-color: #e74c3c;
    box-shadow: 0 0 8px rgba(231, 76, 60, 0.5);
}

/* Lower cutoff - blue theme */
.cutoff-drag-handle.lower-cutoff::before {
    background-color: #3498db;
    box-shadow: 0 0 8px rgba(52, 152, 219, 0.5);
}

/* Hover state */
.cutoff-drag-handle:hover {
    background-color: rgba(255, 255, 255, 0.08);
}

/* Dragging state */
.cutoff-drag-handle.dragging {
    background-color: rgba(255, 255, 255, 0.15);
}

/* Grip icon inside handle */
.cutoff-drag-handle i {
    color: rgba(255, 255, 255, 0.6);
    font-size: 1rem;
    transition: color 0.15s ease;
}

.cutoff-drag-handle:hover i,
.cutoff-drag-handle.dragging i {
    color: rgba(255, 255, 255, 0.9);
}

/* Label showing current value */
.cutoff-drag-handle .cutoff-label {
    position: absolute;
    top: 4px;
    left: 50%;
    transform: translateX(-50%);
    background-color: var(--sieve-card-bg);
    border: 1px solid var(--sieve-border-color);
    border-radius: 4px;
    padding: 2px 6px;
    font-size: 0.7rem;
    white-space: nowrap;
    color: var(--sieve-text-primary);
    pointer-events: none;
}

.cutoff-drag-handle.upper-cutoff .cutoff-label {
    border-color: #e74c3c;
}

.cutoff-drag-handle.lower-cutoff .cutoff-label {
    border-color: #3498db;
}

/* ===================================== */
/* Envelope Boundary Drag Handles        */
/* ===================================== */

.envelope-drag-handle {
    position: absolute;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background-color: #9b59b6;
    border: 2px solid #fff;
    cursor: ew-resize;
    pointer-events: all;
    z-index: 12;
    transform: translate(-50%, -50%);
    /* Smooth animations for position updates and visual feedback */
    transition: left 0.15s ease-out, top 0.15s ease-out, transform 0.1s ease, box-shadow 0.1s ease;
    box-shadow: 0 0 8px rgba(155, 89, 182, 0.5);
}

.envelope-drag-handle:hover {
    transform: translate(-50%, -50%) scale(1.3);
    box-shadow: 0 0 12px rgba(155, 89, 182, 0.8);
}

.envelope-drag-handle.dragging {
    transform: translate(-50%, -50%) scale(1.4);
    box-shadow: 0 0 16px rgba(155, 89, 182, 1);
    /* Faster position transition for smooth trailing during drag */
    transition: left 0.08s ease-out, top 0.08s ease-out, transform 0.1s ease, box-shadow 0.1s ease;
}

/* D50 min marker - left side of envelope */
.envelope-drag-handle.envelope-min-handle {
    background-color: #9b59b6;
}

/* D50 max marker - right side of envelope */
.envelope-drag-handle.envelope-max-handle {
    background-color: #8e44ad;
}

/* Hide the icon text but keep the element for hover state */
.envelope-drag-handle .envelope-handle-icon {
    display: none;
}

/* ===================================== */
/* Custom Curve Endpoint Handles         */
/* ===================================== */

.endpoint-drag-handle {
    position: absolute;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    cursor: ew-resize;
    pointer-events: all;
    z-index: 13;
    transform: translate(-50%, -50%);
    /* Smooth animations for position updates and visual feedback */
    transition: left 0.08s ease-out, top 0.08s ease-out, transform 0.1s ease, box-shadow 0.1s ease;
}

.endpoint-drag-handle:hover {
    transform: translate(-50%, -50%) scale(1.3);
}

.endpoint-drag-handle.dragging {
    transform: translate(-50%, -50%) scale(1.4);
}

/* Upper endpoint - orange/red at 100% passing */
.endpoint-drag-handle.endpoint-upper-handle {
    background-color: rgba(230, 126, 34, 0.9);
    border: 2px solid #e74c3c;
    box-shadow: 0 0 8px rgba(230, 126, 34, 0.6);
}

.endpoint-drag-handle.endpoint-upper-handle:hover {
    box-shadow: 0 0 14px rgba(230, 126, 34, 0.9);
}

/* Lower endpoint - cyan/blue at ~0% passing */
.endpoint-drag-handle.endpoint-lower-handle {
    background-color: rgba(52, 152, 219, 0.9);
    border: 2px solid #3498db;
    box-shadow: 0 0 8px rgba(52, 152, 219, 0.6);
}

.endpoint-drag-handle.endpoint-lower-handle:hover {
    box-shadow: 0 0 14px rgba(52, 152, 219, 0.9);
}

/* ===================================== */
/* Width Handles (D25/D75 for So control) */
/* ===================================== */

.envelope-width-handle {
    position: absolute;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background-color: #2ecc71;
    border: 2px solid #fff;
    cursor: ew-resize;
    pointer-events: all;
    z-index: 14;
    transform: translate(-50%, -50%);
    /* Smooth animations for position updates and visual feedback */
    transition: left 0.15s ease-out, top 0.15s ease-out, transform 0.1s ease, box-shadow 0.1s ease;
    box-shadow: 0 0 8px rgba(46, 204, 113, 0.5);
}

.envelope-width-handle:hover {
    transform: translate(-50%, -50%) scale(1.3);
    box-shadow: 0 0 12px rgba(46, 204, 113, 0.8);
}

/* Smooth animation during active drag - handles trail smoothly behind cursor */
.envelope-width-handle.dragging {
    transform: translate(-50%, -50%) scale(1.4);
    box-shadow: 0 0 16px rgba(46, 204, 113, 1);
    /* Keep position transitions for smooth trailing effect during drag */
    transition: left 0.08s ease-out, top 0.08s ease-out, transform 0.1s ease, box-shadow 0.1s ease;
}

/* Constraint limit indicator - shows when handle can't move further */
.envelope-width-handle.at-limit {
    animation: limitPulse 0.3s ease-out;
}

@keyframes limitPulse {
    0% {
        box-shadow: 0 0 8px rgba(255, 100, 100, 0.8);
        transform: translate(-50%, -50%) scale(1.2);
    }
    50% {
        box-shadow: 0 0 20px rgba(255, 50, 50, 1);
        transform: translate(-50%, -50%) scale(1.3);
    }
    100% {
        box-shadow: 0 0 8px rgba(255, 100, 100, 0.5);
        transform: translate(-50%, -50%) scale(1.2);
    }
}

/* D10 handle - lower bound at 10% passing (Cu control) */
.envelope-width-handle.d10-handle {
    background-color: #e74c3c;
    box-shadow: 0 0 6px rgba(231, 76, 60, 0.5);
}

.envelope-width-handle.d10-handle:hover {
    box-shadow: 0 0 12px rgba(231, 76, 60, 0.8);
}

/* D25 handle - lower bound at 25% passing (So control) */
.envelope-width-handle.d25-handle {
    background-color: #27ae60;
}

/* D60 handle - upper bound at 60% passing (Cu control) */
.envelope-width-handle.d60-handle {
    background-color: #f39c12;
    box-shadow: 0 0 6px rgba(243, 156, 18, 0.5);
}

.envelope-width-handle.d60-handle:hover {
    box-shadow: 0 0 12px rgba(243, 156, 18, 0.8);
}

/* D75 handle - upper bound at 75% passing (So control) */
.envelope-width-handle.d75-handle {
    background-color: #2ecc71;
}

/* D90 handle - upper bound at 90% passing (spread/fines) */
.envelope-width-handle.d90-handle {
    background-color: #e74c3c;
    box-shadow: 0 0 6px rgba(231, 76, 60, 0.5);
}

.envelope-width-handle.d90-handle:hover {
    box-shadow: 0 0 12px rgba(231, 76, 60, 0.8);
}

/* Label inside width handle */
.envelope-width-handle .width-handle-label {
    position: absolute;
    font-size: 9px;
    font-weight: bold;
    color: #fff;
    text-shadow: 0 0 2px rgba(0, 0, 0, 0.8);
    pointer-events: none;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    line-height: 1;
}

/* Drag feedback tooltip for Cu/So values during width handle drag */
.drag-feedback-tooltip {
    position: absolute;
    background-color: rgba(30, 30, 35, 0.95);
    color: #fff;
    padding: 6px 10px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
    pointer-events: none;
    z-index: 1000;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.15);
    animation: tooltipFadeIn 0.15s ease-out;
}

.drag-feedback-tooltip::before {
    content: '';
    position: absolute;
    bottom: -6px;
    left: 10px;
    border-width: 6px 6px 0 6px;
    border-style: solid;
    border-color: rgba(30, 30, 35, 0.95) transparent transparent transparent;
}

@keyframes tooltipFadeIn {
    from {
        opacity: 0;
        transform: translateY(5px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ===================================== */
/* Snap Indicators                       */
/* ===================================== */

.snap-indicator {
    position: absolute;
    width: 1px;
    top: 60px;
    bottom: 60px;
    background-color: rgba(255, 255, 255, 0.1);
    pointer-events: none;
    z-index: 5;
    transition: background-color 0.1s ease, width 0.1s ease;
}

.snap-indicator.active {
    background-color: rgba(46, 204, 113, 0.6);
    width: 3px;
    box-shadow: 0 0 8px rgba(46, 204, 113, 0.5);
}

/* ===================================== */
/* Real-time Value Tooltip               */
/* ===================================== */

.drag-tooltip {
    position: absolute;
    background-color: var(--sieve-card-bg);
    border: 1px solid var(--sieve-border-color);
    border-radius: 6px;
    padding: 6px 10px;
    font-size: 0.75rem;
    color: var(--sieve-text-primary);
    white-space: nowrap;
    pointer-events: none;
    z-index: 20;
    box-shadow: var(--sieve-shadow-lg);
    transform: translateY(-100%) translateX(-50%);
    margin-top: -8px;
}

.drag-tooltip::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border-width: 6px;
    border-style: solid;
    border-color: var(--sieve-card-bg) transparent transparent transparent;
}

.drag-tooltip .tooltip-value {
    font-weight: bold;
    color: #4ecdc4;
}

.drag-tooltip .tooltip-label {
    color: #888;
    margin-right: 4px;
}

/* ===================================== */
/* Plot Card Styling                     */
/* ===================================== */

#customize-plot-a,
#customize-plot-b {
    background-color: transparent;
}

/* Ensure Plotly modebar doesn't overlap with drag handles */
#customize-plot-b .modebar {
    z-index: 15;
}

/* ===================================== */
/* Responsive Adjustments                */
/* ===================================== */

@media (max-width: 1200px) {
    /* Stack plots vertically on medium screens */
    .customize-status-bar .analysis-display {
        display: none !important;
    }
}

@media (max-width: 768px) {
    /* Hide panels column on small screens, show inline */
    .customize-status-bar {
        padding: 8px 12px;
    }

    .cutoff-drag-handle {
        width: 32px;
    }

    .cutoff-drag-handle .cutoff-label {
        font-size: 0.65rem;
    }
}