/**
 * GEX Components CSS
 * Component-specific styles for the GEX Analysis page
 * Theme-independent styles - theme variables defined in themes.css
 */

/* ========================================
   RESPONSIVE VISIBILITY: TOOLBAR CONTROLS
   ======================================== */

/* Replay bar speed: combobox shown on both mobile and desktop */
.tm-speed-select {
    width: auto;
    min-width: 60px;
    max-width: 70px;
    font-size: 0.875rem;
    padding: 0.25rem 0.5rem;
    flex-shrink: 0;
}

@media (max-width: 767.98px) {
    .tm-speed-select {
        font-size: 0.75rem;
        min-width: 55px;
        max-width: 60px;
        padding: 0.2rem 0.4rem;
    }
}

/* ========================================
   CONTAINER & LAYOUT
   ======================================== */

.gex-container {
    max-width: 100%;
    margin: 0 auto;
    padding: 0;
    overflow-x: hidden;
}

.main-content-full {
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
}

/* Desktop: limit content width */
@media (min-width: 992px) {
    .gex-container {
        max-width: 1150px;
    }

    .main-content-full {
        width: 100%;
        max-width: 1150px;
        margin: 0 auto;
    }

    .main-content-full .card {
        width: 100%;
        max-width: 1150px;
        margin: 0 auto;
        box-sizing: border-box;
    }

    .main-content-full .card-body {
        width: 100%;
        max-width: 1150px;
        margin: 0 0;
        box-sizing: border-box;
    }

    .header-bar {
        display: flex;
        justify-content: center;
        max-width: 1150px;
        margin: 0 auto;
        border-radius: 0 0 16px 16px;
        overflow: visible;
    }

}

/* On mobile, the overflow-x: hidden on parents blocks horizontal scrolling in child elements
   We need to remove this restriction on mobile to allow the marker cards to scroll */
@media (max-width: 768px) {

    html,
    body {
        overflow-x: visible !important;
    }

    .gex-container {
        overflow-x: visible !important;
    }

    .main-content-full {
        overflow-x: visible !important;
    }

    .main-content-full>.card {
        overflow-x: visible !important;
    }
}

/* --- Mobile Single Page Layout (Flexbox) --- */
@media (max-width: 768px) {

    /* 1. Force Full Height Body & Container */
    html {
        height: 100%;
        overflow: hidden;
        width: 100%;
    }

    body {
        height: 100%;
        overflow: hidden;
        display: flex;
        flex-direction: column;
        width: 100%;
        min-width: 100%;
        /* Prevent shrinking below viewport width */
    }

    /* Header takes natural height */
    .header-bar {
        flex-shrink: 0;
    }

    /* Container fills height, strict no-scroll unless absolutely necessary */
    .gex-container {
        display: flex;
        flex-direction: column;
        flex-grow: 1;
        min-height: 0;
        overflow: hidden;
        width: 100%;
        min-width: 100%;
        /* Prevent shrinking below viewport width */
    }

    .main-content-full {
        display: flex;
        flex-direction: column;
        flex-grow: 1;
        min-height: 0;
        width: 100%;
        min-width: 100%;
        /* Prevent shrinking below viewport width */
    }

    /* Toolbar is fixed height */
    .gex-control-toolbar {
        flex-shrink: 0;
    }

    /* Premium Banner fixed height */
    .premium-banner {
        flex-shrink: 0;
    }

    /* 2. Chart & Widgets Wrapper fills remaining space */
    #chart-widgets-container {
        display: flex;
        flex-direction: column;
        flex-grow: 1;
        min-height: 0;
        overflow-y: auto;
        /* Hide scrollbar on mobile - prevents width shift */
        scrollbar-width: none;
        /* Firefox */
        -ms-overflow-style: none;
        /* IE and Edge */
        max-height: 100%;
        width: 100%;
    }

    /* Hide scrollbar for WebKit browsers (Chrome, Safari) */
    #chart-widgets-container::-webkit-scrollbar {
        display: none;
    }

    /* Chart Section takes all available space */
    .chart-section {
        display: flex;
        flex-direction: column;
        flex-grow: 1;
        flex-basis: 0;
        min-height: 250px;
        position: relative;
        width: 100%;
    }

    /* 3. Markers Section - Fixed Height Bottom Widget */
    .markers-section {
        flex-shrink: 0;
        height: auto;
        /* Allow adaptive height */
        max-height: 25vh;
        /* Cap at ~25% of viewport (~160px on 667h) */
        min-height: 80px;
        /* Ensure strictly visible */
        overflow-y: hidden;
        /* Scroll handled by inner widget */
        background: var(--theme-bg-primary) !important;
        border-top: none !important;
        z-index: 10;
        margin-bottom: 0 !important;
        display: flex;
        flex-direction: column;
    }

    /* Ensure markers widget fits inside markers section */
    .markers-section .markers-widget {
        height: 100%;
        display: flex;
        flex-direction: column;
    }

    .markers-section .markers-widget-body {
        overflow-y: auto;
        flex-grow: 1;
        min-height: 0;
        /* CRITICAL: Allows shrinking when siblings (totals) expand */
    }
}

/* Chart container height - responsive */
.gex-chart-container,
.gex-ohlc-container {
    /* Desktop: Dynamic height based on viewport
       Offset 420px accounts for: Header, Controls, View Options, Markers Widget (100px) and Zoom Slider (100px) */
    height: calc(100vh - 480px);
    min-height: 300px;
    /* Ensure it doesn't get too small */
    overflow: hidden;
    position: relative;
    /* touch-action handled by Hammer.js - don't restrict here */
}

/* ===========================================
   Chart loading overlay (pseudo-elements)
   Applies to all three chart containers.
   Survives Plotly.purge() — no real DOM nodes.
   =========================================== */

/* Semi-transparent overlay — color adapts to active theme */
.gex-chart-container.gex-chart-loading::before,
.gex-ohlc-container.gex-chart-loading::before,
.gex-term-container.gex-chart-loading::before {
    content: '';
    position: absolute;
    inset: 0;
    z-index: 200;
    background: var(--gex-loading-overlay-bg, rgba(0, 0, 0, 0.5));
    border-radius: inherit;
    animation: gex-overlay-fade-in 0.12s ease forwards;
}

/* Spinning indicator — color adapts to active theme */
.gex-chart-container.gex-chart-loading::after,
.gex-ohlc-container.gex-chart-loading::after,
.gex-term-container.gex-chart-loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    z-index: 201;
    width: 2.5rem;
    height: 2.5rem;
    margin: -1.25rem 0 0 -1.25rem;
    border: 0.3em solid var(--gex-loading-spinner-track, rgba(255, 255, 255, 0.25));
    border-top-color: var(--gex-loading-spinner-color, #fff);
    border-radius: 50%;
    animation: gex-spin 0.7s linear infinite;
}

@keyframes gex-spin {
    to { transform: rotate(360deg); }
}

@keyframes gex-overlay-fade-in {
    from { opacity: 0; }
    to   { opacity: 1; }
}

@media (max-width: 768px) {

    /* Mobile: Flex grow to fill available space */
    .gex-view,
    .gex-chart-container {
        flex-grow: 1;
        flex-basis: 0;
        /* FORCE SHIRINKAGE below natural height */
        height: 100% !important;
        /* Use 100% of flex parent */
        min-height: 0 !important;
        /* Let parent .chart-section handle min-height */
        margin-bottom: 0 !important;
    }

    /* Remove padding or margins that affect height */
    .chart-section {
        padding-bottom: 0;
    }
}

.header-container {
    width: 100%;
    max-width: 1150px;
    margin: 0 auto;
    padding: 0.1rem 20px;
    box-sizing: border-box;
}

.header-menu-dropdown {
    margin-left: 0.5rem;
}

.header-menu-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.25rem;
}

.header-menu-btn .menu-icon {
    font-size: 1.35rem;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    transform: translateY(-1px);
}

/* Header dropdowns - default (desktop) - compact sizes */
#main-exchange-select {
    min-width: 100px;
    max-width: 120px;
}

@media (max-width: 768px) {
    .header-menu-dropdown {
        margin-left: 0;
    }

    .header-menu-btn {
        margin-left: 0 !important;
    }

    /* Ensure nav section items wrap properly on very small screens */
    #navAuthSection {
        flex-wrap: wrap;
        gap: 0.35rem !important;
    }
}

/* User Auth Section - Spacing to separate from controls */
@media (min-width: 576px) {

    /* Add extra spacing before auth section on larger screens */
    #loginBtn,
    #userDropdown {
        margin-left: 0.5rem;
        padding-left: 0.5rem;
        border-left: 1px solid var(--theme-border-primary);
        border-left-color: rgba(var(--bs-border-color-rgb), 0.3);
    }
}

/* On mobile, keep compact spacing */
@media (max-width: 575.98px) {

    #loginBtn,
    #userDropdown {
        margin-left: 0.25rem;
    }
}

/* ========================================
   UNIFIED CONTROL TOOLBAR
   ======================================== */

#gex-manual-refresh-btn.rate-limited {
    opacity: 0.6;
    cursor: not-allowed !important;
    pointer-events: none;
}

#gex-manual-refresh-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.gex-control-toolbar {
    width: 100%;
    margin: 0 auto;
    padding: 0 10px;
    max-width: 1150px;
}

/* Group Layouts */
.toolbar-group {
    display: flex;
    gap: 8px;
    align-items: flex-end;
    /* Align items to bottom so labels don't mess up input alignment */
}

.control-wrapper {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.control-label {
    font-size: 0.65rem;
    font-weight: 700;
    color: var(--theme-text-secondary);
    letter-spacing: 0.5px;
    line-height: 1;
    margin-bottom: 2px;
    padding-left: 2px;
    text-transform: uppercase;
}

/* Mobile: Smaller, more compact labels */
@media (max-width: 767.98px) {
    .control-label {
        font-size: 0.55rem;
        letter-spacing: 0.3px;
        margin-bottom: 1px;
        padding-left: 1px;
        opacity: 0.85;
    }
}

/* Mobile: 2-Row Grid */
@media (max-width: 767.98px) {
    .gex-control-toolbar {
        display: flex;
        flex-direction: column;
        gap: 6px;
        padding: 0 0.5rem;
        /* Use rem for consistency with other containers (0.5rem = 8px) */
    }

    .toolbar-group {
        display: grid;
        gap: 6px;
        width: 100%;
        align-items: stretch;
        /* Reset alignment for grid */
    }

    /* Data Sources: 3 columns (Exchange, Asset, Expiration) */
    .toolbar-group.data-sources {
        grid-template-columns: 1fr 1fr 1fr;
        order: 1;
    }

    /* View Controls: 3 equal columns (Chart, View, Mode) */
    .toolbar-group.view-controls {
        grid-template-columns: 1fr 1fr 1fr;
        order: 2;
    }

    .control-wrapper {
        min-width: 0;
        /* Prevent flex overflow */
        gap: 1px;
        /* Tighter gap between label and control on mobile */
    }

    /* Ensure all selectors in toolbar have equal width */
    .gex-control-toolbar .control-select,
    .gex-control-toolbar #main-exchange-select {
        width: 100%;
        min-width: 0;
        max-width: none;
    }
}

/* Desktop: Single Flex Row */
@media (min-width: 768px) {
    .gex-control-toolbar {
        display: flex;
        flex-wrap: nowrap;
        justify-content: space-between;
        align-items: flex-end;
        /* Align groups to bottom */
        gap: 16px;
        padding: 0 0px;
    }

    /* Left Group (Data Sources) */
    .toolbar-group.data-sources {
        flex: 0 1 auto;
    }

    /* Right Group (View Controls) - Now only 2 controls */
    .toolbar-group.view-controls {
        flex: 0 1 auto;
    }

    /* Adjust widths for desktop comfort */
    .exchange-wrapper {
        min-width: 110px;
    }

    .asset-wrapper {
        min-width: 110px;
    }

    .expiration-wrapper {
        min-width: 130px;
    }

    /* Chart and View wrappers get equal space */
    .chart-type-wrapper,
    .view-mode-wrapper {
        min-width: 120px;
    }

    .mode-wrapper {
        min-width: 120px;
    }
}

/* ========================================
   MODE BADGE (Beta/Replay Indicator)
   ======================================== */

.mode-badge {
    position: relative;
    top: -1px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    font-size: 0.5rem;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 8px;
    letter-spacing: 0.5px;
    z-index: 10;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    pointer-events: none;
    animation: badgePulse 2s ease-in-out infinite;
}

@keyframes badgePulse {

    0%,
    100% {
        opacity: 1;
        transform: scale(1);
    }

    50% {
        opacity: 0.85;
        transform: scale(1.05);
    }
}

/* Mobile: Adjust badge for smaller screens */
@media (max-width: 767.98px) {
    .mode-badge {
        font-size: 0.45rem;
        padding: 1px 4px;
    }
}

/* ========================================
   MODE TOGGLE SWITCH (Live/Replay)
   ======================================== */

.mode-switch {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    height: 34px;
    user-select: none;
}

.mode-switch input {
    display: none;
}

.mode-switch-track {
    position: relative;
    width: 40px;
    height: 22px;
    background-color: #388E3C;
    border-radius: 11px;
    transition: background-color 0.25s;
    flex-shrink: 0;
}

.mode-switch input:checked~.mode-switch-track {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.mode-switch-thumb {
    position: absolute;
    top: 2px;
    left: 2px;
    width: 18px;
    height: 18px;
    background: white;
    border-radius: 50%;
    transition: transform 0.25s;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

.mode-switch input:checked~.mode-switch-track .mode-switch-thumb {
    transform: translateX(18px);
}

.mode-switch-label {
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--theme-text-primary);
    white-space: nowrap;
}

/* Premium lock icon (next to disabled features) */
.premium-lock-icon {
    font-size: 0.7rem;
    vertical-align: middle;
    opacity: 0.8;
}

/* Toggle is always clickable — free users see premium modal on click */

/* ========================================
   COMPACT CONTROLS STYLING (UNIFIED)
   ======================================== */

/* 1. Base Height & Alignment */
.native-compact,
.gex-toggle-btn,
.gex-toggle-group {
    height: 34px !important;
    min-height: 34px !important;
    max-height: 34px !important;
    box-sizing: border-box !important;
}

/* 2. Inputs (Selects & Dropdowns) */
select.native-compact {
    line-height: normal;
    /* Form controls align better with normal */
    padding-top: 0 !important;
    padding-bottom: 0 !important;
    padding-left: 0.75rem !important;
    display: flex;
    align-items: center;
}

.asset-select-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    width: 100%;
}

.asset-select-icon {
    position: absolute;
    left: 8px;
    top: 50%;
    transform: translateY(-50%);
    height: 16px;
    width: 16px;
    pointer-events: none;
    z-index: 1;
}

select.asset-select-native {
    padding-left: 30px !important;
}

/* 3. Toggle Groups (Chart Type & View Mode) */
.gex-toggle-group {
    background-color: var(--theme-bg-tertiary);
    padding: 3px;
    border-radius: 8px;
    border: 1px solid var(--theme-border-primary);
    display: inline-flex;
    gap: 2px;
    align-items: center;
    vertical-align: middle;
}

/* 4. Toggle Buttons (Labels & Buttons) */
.gex-toggle-btn.btn {
    /* Target with .btn to be specific */
    border-radius: 6px;
    border: 1px solid transparent;
    background: transparent;
    color: var(--theme-text-secondary);
    font-size: 0.85rem !important;
    font-weight: 500;
    padding: 0 0.8rem !important;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    white-space: nowrap;
    margin: 0 !important;
    height: 100% !important;
    /* Fill the group height */
    box-shadow: none !important;
    /* Reset bootstrap shadow */
    position: relative;
    /* For absolute positioning of badges */
}

/* Beta Badge Styling */
.beta-badge {
    position: absolute;
    top: -6px;
    right: -4px;
    background: linear-gradient(135deg, #ff9800, #f44336);
    color: white;
    font-size: 0.55rem;
    font-weight: 800;
    padding: 1px 4px;
    border-radius: 4px;
    text-transform: uppercase;
    line-height: 1;
    letter-spacing: 0.5px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    z-index: 5;
    pointer-events: none;
}

/* Mobile adjustments for beta badge */
@media (max-width: 768px) {
    .beta-badge {
        font-size: 0.5rem;
        padding: 1px 3px;
        top: -5px;
        right: -3px;
    }
}

/* Override the list 1 rule for toggle group relative height */
.gex-toggle-group {
    height: 34px !important;
}

.gex-toggle-btn.btn:hover {
    color: var(--theme-text-primary);
    background-color: rgba(255, 255, 255, 0.05);
}

/* Active State (Checked Radio + Label OR Active Button) */
.btn-check:checked+.gex-toggle-btn.btn,
.gex-toggle-btn.btn.active {
    background-color: var(--theme-bg-card) !important;
    border-color: var(--theme-border-primary) !important;
    color: var(--theme-text-primary) !important;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05) !important;
    font-weight: 600 !important;
}

/* Dark Mode Active */
[data-bs-theme="dark"] .btn-check:checked+.gex-toggle-btn.btn,
[data-bs-theme="dark"] .gex-toggle-btn.btn.active {
    background-color: #2d333b !important;
    border-color: rgba(255, 255, 255, 0.1) !important;
    color: #ffffff !important;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3) !important;
}

/* Mobile: Compact View */
@media (max-width: 768px) {
    .gex-toggle-btn.btn {
        padding: 0 0.4rem !important;
        font-size: 0.75rem !important;
        gap: 0.2rem;
    }
}

/* 5. Refresh Button-Specific */
.refresh-wrapper button {
    border-color: var(--theme-border-primary);
    color: var(--theme-text-secondary);
}

.refresh-wrapper button:hover {
    border-color: var(--color-primary);
    color: var(--color-primary);
}

/* ========================================
   PREMIUM UPGRADE BANNER
   ======================================== */

.premium-banner {
    margin-bottom: 0.5rem;
    border-radius: 6px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    overflow: hidden;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    animation: slideDown 0.3s ease-out;
}

.premium-banner-content {
    display: flex;
    align-items: center;
    padding: 0.5rem 1rem;
    gap: 0.5rem;
}

.premium-icon {
    font-size: 1.25rem;
}

.premium-text {
    flex: 1;
    font-size: 0.85rem;
    line-height: 1.3;
}

.premium-banner button {
    white-space: nowrap;
    font-weight: 500;
    letter-spacing: 0.3px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.15);
    transition: all 0.2s ease;
}

.premium-banner button:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ========================================
   COUNTDOWN TIMER
   ======================================== */

.gex-countdown-container {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.25rem 0.65rem;
    border-radius: 6px;
    background-color: var(--theme-bg-secondary);
    border: 1px solid var(--theme-border-primary);
    font-size: 0.8rem;
    white-space: nowrap;
    transition: all 0.3s ease;
}

/* Header countdown - compact styling */
#gex-header-countdown {
    padding: 0.2rem 0.5rem;
    font-size: 0.75rem;
}

#gex-header-countdown .countdown-icon {
    font-size: 0.9rem;
}

#gex-header-countdown .countdown-text {
    font-size: 0.75rem;
    min-width: 28px;
    text-align: center;
}

/* Refresh button - rate limited state (free tier) */
#gex-manual-refresh-btn.rate-limited {
    opacity: 0.6;
    cursor: not-allowed;
    pointer-events: auto;
    /* Still allow clicks to show upgrade prompt */
}

#gex-manual-refresh-btn.rate-limited:hover {
    opacity: 0.7;
    transform: none;
    /* Disable hover animations */
}

/* Countdown container - rate limited state (free tier) */
#gex-header-countdown.rate-limited {
    opacity: 0.6 !important;
    pointer-events: none;
    /* Disable interactions */
}

#gex-header-countdown.rate-limited .countdown-icon,
#gex-header-countdown.rate-limited .countdown-label,
#gex-header-countdown.rate-limited .countdown-text {
    opacity: 1;
    /* Inherit parent's opacity, don't override */
}

.countdown-icon {
    font-size: 1rem;
    line-height: 1;
    opacity: 0.8;
}

.countdown-label {
    font-size: 0.7rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    opacity: 0.7;
    color: var(--theme-text-secondary);
    margin-right: 2px;
}

.countdown-text {
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    letter-spacing: 0.5px;
    color: var(--theme-text-primary);
}

/* Premium tier countdown - green accent */
.gex-countdown-container.countdown-premium {
    background: linear-gradient(135deg, color-mix(in srgb, var(--marker-pos-bg) 10%, transparent), color-mix(in srgb, #198754 10%, transparent));
    border-color: color-mix(in srgb, var(--marker-pos-bg) 30%, transparent);
}

.gex-countdown-container.countdown-premium .countdown-text {
    color: var(--marker-pos-bg);
}

/* Free tier countdown - amber/warning accent */
.gex-countdown-container.countdown-free {
    background: linear-gradient(135deg, rgba(255, 193, 7, 0.1), rgba(255, 152, 0, 0.1));
    border-color: rgba(255, 193, 7, 0.3);
}

.gex-countdown-container.countdown-free .countdown-text {
    color: #ff9800;
}

/* Mobile responsive adjustments */
@media (max-width: 768px) {
    .gex-countdown-container {
        font-size: 0.75rem;
        padding: 0.2rem 0.5rem;
        gap: 0.25rem;
    }

    .countdown-icon {
        font-size: 0.9rem;
    }

    /* Header countdown on mobile - even more compact */
    #gex-header-countdown {
        padding: 0.15rem 0.4rem;
        font-size: 0.7rem;
        gap: 0.2rem;
    }

    #gex-header-countdown .countdown-icon {
        font-size: 0.85rem;
    }

    #gex-header-countdown .countdown-label {
        font-size: 0.6rem;
        margin-right: 1px;
    }

    #gex-header-countdown .countdown-text {
        font-size: 0.7rem;
        min-width: 24px;
    }

    /* Header refresh button - compact on mobile */
    #gex-manual-refresh-btn {
        padding: 0.25rem 0.5rem !important;
        font-size: 0.875rem;
    }

    #gex-manual-refresh-btn span {
        line-height: 1;
    }
}

/* ========================================
   CARD COMPONENTS
   ======================================== */

/*
 * Only the primary card wrapper in gex_index.html should be transparent so
 * that the full-width layout blends with the surrounding background. Scope
 * the overrides to that wrapper so cards elsewhere use the theme defaults.
 */
.main-content-full>.card {
    border: none;
    margin-bottom: 0;
    max-width: 100%;
    overflow-x: hidden;
    overflow-y: visible;
    background-color: transparent !important;
}

.main-content-full>.card .card-body {
    background-color: transparent !important;
    padding: 0.5rem 0rem 0rem 0rem !important;
    overflow: visible;
}

/* ========================================
   MARKER & ZONE ITEMS
   ======================================== */

/* Note: .marker-item base styles are defined later in the file (line ~814) */

.zone-item {
    border-radius: 4px;
    transition: all 0.2s ease;
}

.zone-item:hover {
    transform: translateX(4px) !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15) !important;
    background-color: var(--zone-hover-color) !important;
}

/* Cliff indicator styling */
.cliff-indicator {
    transition: all 0.2s ease;
}

.cliff-indicator:hover {
    opacity: 1 !important;
    transform: scale(1.1);
}


.key-marker-item {
    transition: all 0.2s ease;
    background-color: var(--theme-bg-card);
    border-color: var(--theme-border-primary);
}

.key-marker-item:hover {
    transform: translateX(2px);
    box-shadow: var(--theme-shadow-md) !important;
}

/* ========================================
   GUIDE MODAL
   ======================================== */

.guide-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

.guide-modal-content {
    border-radius: 12px;
    max-width: 900px;
    width: 90%;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from {
        transform: translateY(-50px);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.guide-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 25px;
    border-radius: 12px 12px 0 0;
}

.guide-modal-header h5 {
    margin: 0;
    font-weight: 600;
}

.guide-modal-body {
    padding: 25px;
    overflow-y: auto;
    flex: 1;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-y: contain;
}

/* ========================================
   SETTINGS MODAL
   ======================================== */

#settingsModal {
    background-color: rgba(0, 0, 0, 0.25);
    backdrop-filter: none;
    animation: none;
}

.settings-modal-content {
    max-width: 500px;
    width: 92%;
}

.settings-modal-body {
    padding: 20px 24px;
}

.settings-section {
    margin-bottom: 1.5rem;
}

.settings-section:last-child {
    margin-bottom: 0;
}

.settings-section-title {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    opacity: 0.45;
    margin-bottom: 0.75rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid rgba(128, 128, 128, 0.2);
}

.settings-row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1.25rem;
    padding: 0.65rem 0;
}

.settings-row + .settings-row {
    border-top: 1px solid rgba(128, 128, 128, 0.12);
}

.settings-row-info {
    flex: 1;
    min-width: 0;
}

.settings-label {
    font-size: 0.875rem;
    font-weight: 500;
    margin-bottom: 0.3rem;
}

.settings-description {
    font-size: 0.775rem;
    opacity: 0.6;
    line-height: 1.55;
}

.settings-row-control {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    padding-top: 2px;
}

/* ========================================
   TABLE MARKERS LAYOUT (DESKTOP & MOBILE)
   ======================================== */

.markers-grouped-desktop {
    display: block;
    /* Show on both desktop and mobile */
}

.marker-section-header {
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--theme-text-secondary);
    letter-spacing: 0.5px;
    margin-top: 12px;
    margin-bottom: 8px;
    padding-bottom: 4px;
    border-bottom: 2px solid var(--theme-border-primary);
}

/* Markers table styling */
.markers-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
    background: var(--theme-bg-card);
    border: 1px solid var(--theme-border-primary);
    border-radius: 6px;
    overflow: hidden;
}

.markers-table thead {
    background: var(--theme-bg-tertiary);
    border-bottom: 2px solid var(--theme-border-primary);
}

.markers-table th {
    padding: 8px 12px;
    text-align: left;
    font-weight: 600;
    font-size: 0.75rem;
    color: var(--theme-text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.markers-table tbody tr {
    border-bottom: 1px solid var(--theme-border-primary);
    transition: all 0.2s ease;
}

.markers-table tbody tr:last-child {
    border-bottom: none;
}

.markers-table tbody tr:hover {
    background: var(--theme-hover-bg);
    cursor: pointer;
}

.markers-table td {
    padding: 8px 12px;
}

.marker-price-cell {
    font-weight: 700;
    color: var(--theme-text-primary);
}

.marker-value-cell {
    font-weight: 600;
}

.marker-table-row .badge {
    font-size: 0.7rem;
    padding: 3px 8px;
}

/* Mobile-specific table adjustments */
@media (max-width: 768px) {
    .markers-table {
        font-size: 0.8rem;
    }

    .markers-table th {
        padding: 6px 8px;
        font-size: 0.7rem;
    }

    .markers-table td {
        padding: 8px 8px;
    }

    .marker-table-row .badge {
        font-size: 0.65rem;
        padding: 2px 6px;
    }

    /* Larger touch targets on mobile */
    .markers-table tbody tr {
        min-height: 44px;
    }

    .marker-section-header {
        font-size: 0.7rem;
        margin-top: 8px;
        margin-bottom: 6px;
    }
}

/* ========================================
   MARKER WIDGET
   ======================================== */

/* New layout: markers below chart */
#chart-widgets-container {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

.chart-section {
    width: 100%;
    overflow: visible;
    /* Allow full chart visibility */
    flex-shrink: 0;
    /* Don't shrink chart section */
    position: relative;
    /* Ensure absolute children position relative to this */
}

.markers-section {
    width: 100%;
    min-height: auto;
    box-shadow: none !important;
    position: relative;
    z-index: 1;
    box-sizing: border-box;
    /* Ensure padding is included in width calculation */
}

/* Remove all shadows from markers section children */
.markers-section * {
    box-shadow: none !important;
}

.marker-tools-container {
    align-items: stretch;
}

.markers-widget {
    display: flex;
    flex-direction: column;
    height: 100%;
    border: 1px solid var(--theme-border-primary);
    border-radius: 8px;
    background-color: var(--theme-bg-card);
    box-shadow: none;
    overflow: visible;
    box-sizing: border-box;
    /* Ensure border is included in width calculation */
}

[data-bs-theme="dark"] .markers-widget {
    box-shadow: none;
}

.markers-widget-header {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    border-bottom: 1px solid var(--theme-border-primary);
}

.markers-widget-icon {
    font-size: 1.15rem;
    opacity: 0.7;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.marker-toggle-group {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    justify-content: flex-start;
    flex: 1 1 auto;
}

.marker-toggle {
    padding: 2px 9px;
    font-size: 0.7rem;
    border: 1px solid var(--theme-border-primary);
    border-radius: 16px;
    background-color: var(--theme-bg-card);
    color: var(--theme-text-primary);
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
    flex: 0 0 auto;
}

.marker-toggle:hover {
    background-color: var(--theme-hover-bg);
}

.marker-toggle.active {
    background: linear-gradient(135deg, var(--theme-header-start), var(--theme-header-end));
    color: #ffffff;
    border-color: transparent;
}

.marker-toggle-separator {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 0.25rem;
    color: var(--theme-text-secondary);
    opacity: 0.4;
    font-size: 0.75rem;
    user-select: none;
    pointer-events: none;
}

.markers-widget-body {
    flex: 1;
    overflow-y: auto;
    padding: 0.25rem 0rem 0.2rem 0rem;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-y: contain;
}

#gex-markers-container {
    display: block;
    min-height: 0;
}

.marker-display {
    display: flex;
    flex-wrap: nowrap;
    align-items: stretch;
    gap: 0.45rem;
    padding: 0.65rem 0.5rem 0rem 0.5rem;
    overflow-x: auto;
    overflow-y: visible;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: contain;
    scroll-behavior: smooth;
    touch-action: pan-x;
    scroll-snap-type: x proximity;
    /* Gentle snap - "proximity" is less aggressive than "mandatory" */
    scroll-padding-left: 0.5rem;
    /* Preserve left padding when snapping */
    scroll-padding-right: 0.5rem;
    /* Preserve right padding when snapping */
}

.marker-item {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: center;
    gap: 0.2rem;
    padding: 0.7rem 0.6rem 0.45rem 0.6rem;
    border-radius: 8px;
    background-color: rgba(0, 0, 0, 0.02);
    border: 1px solid rgba(0, 0, 0, 0.08);
    min-height: 56px;
    scroll-snap-align: start;
    /* Snap to start of each marker item */
}

[data-bs-theme="dark"] .marker-item {
    background-color: rgba(255, 255, 255, 0.04);
    border-color: rgba(255, 255, 255, 0.08);
}

.marker-item.max_pain {
    border-color: color-mix(in srgb, var(--marker-mp-bg) 40%, transparent);
}

.marker-item.positive {
    border-color: color-mix(in srgb, var(--marker-pos-bg) 40%, transparent);
}

.marker-item.negative {
    border-color: color-mix(in srgb, var(--marker-neg-bg) 40%, transparent);
}

.marker-item.absolute {
    border-color: color-mix(in srgb, var(--marker-abs-bg) 40%, transparent);
}

.marker-item.flip {
    border-color: color-mix(in srgb, var(--marker-flip-bg) 40%, transparent);
}

/* Price color matches marker type */
.marker-item.max_pain .marker-price {
    color: var(--marker-mp-bg);
}

.marker-item.positive .marker-price {
    color: var(--marker-pos-bg);
}

.marker-item.negative .marker-price {
    color: var(--marker-neg-bg);
}

.marker-item.absolute .marker-price {
    color: var(--marker-abs-bg);
}

[data-bs-theme="dark"] .marker-item.absolute .marker-price {
    color: #d0a6ff;
}

.marker-item.flip .marker-price {
    color: var(--marker-flip-bg);
}

.marker-item.stability .marker-price {
    color: var(--marker-pos-bg);
}

.marker-item.volatility .marker-price {
    color: var(--marker-neg-bg);
}

.marker-label {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    font-weight: 600;
    font-size: 0.7rem;
    line-height: 1;
}

.marker-line {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    font-weight: 600;
    font-size: 0.7rem;
    line-height: 1.1;
    width: 100%;
}

/* Light theme: darker subtitle for contrast on white */
.marker-subtitle {
    font-weight: 400;
    color: #7a7a7a;
    font-size: 0.65rem;
}

/* Dark theme: brighter subtitle for contrast on dark background */
[data-bs-theme="dark"] .marker-subtitle {
    color: #b0b0b0;
}

/* All marker cards - badge at top border */
.marker-item .marker-line:first-child {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    transform: translateY(-50%);
    width: 100%;
    justify-content: center;
}

.marker-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 3px 8px;
    border-radius: 999px;
    font-size: 0.62rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    line-height: 1;
    flex-shrink: 0;
    position: relative;
    z-index: 1;
}


.marker-price {
    font-weight: 700;
    font-size: 0.7rem;
    color: var(--theme-text-secondary);
    line-height: 1;
}

.marker-value {
    font-size: 0.67rem;
    color: var(--theme-text-secondary);
    line-height: 1;
}

[data-bs-theme="dark"] .marker-value {
    color: var(--theme-text-primary);
}

/* Default width for all marker items */
.marker-display .marker-item {
    min-width: 100px;
    flex: 0 0 100px;
}


/* Width override for zone cards on desktop */
.marker-display .gamma-zone-card {
    min-width: 145px;
    flex: 0 0 145px;
}

.marker-display .gamma-zone-card .marker-price {
    font-size: 0.65rem;
    white-space: nowrap;
}

.gamma-zone-card .marker-line {
    justify-content: center;
}

.gamma-current-price-indicator .marker-line:nth-child(2) {
    margin-top: auto;
    margin-bottom: auto;
    justify-content: center;
    width: 100%;
}

.marker-meta {
    font-size: 0.6rem;
    font-weight: 600;
    letter-spacing: 0.3px;
    text-transform: uppercase;
    color: var(--theme-text-secondary);
    opacity: 0.75;
    line-height: 1;
}

[data-bs-theme="dark"] .marker-meta {
    color: rgba(255, 255, 255, 0.65);
}

.marker-meta-caption {
    opacity: 0.65;
    font-weight: 500;
}

.marker-meta-label {
    opacity: 0.85;
}

.marker-status {
    font-size: 0.9rem;
    font-weight: 700;
    opacity: 0.85;
    line-height: 1;
    margin-left: auto;
}

.gamma-marker-empty {
    padding: 0.75rem 0.5rem;
}

@media (max-width: 992px) and (min-width: 769px) {

    /* Tablet-specific styles (769px-992px) */
    .markers-widget {
        height: auto;
        width: 100%;
    }

    .markers-widget-header {
        padding: 0.45rem 0.65rem;
        gap: 0.4rem;
    }

    .marker-toggle-group {
        justify-content: flex-start;
        flex-wrap: wrap;
        width: 100%;
        overflow: hidden;
    }

    #chart-widgets-container {
        flex-direction: column;
        align-items: stretch !important;
    }
}

@media (max-width: 768px) {
    .markers-widget {
        border-radius: 10px;
        height: auto;
        width: 100% !important;
        /* Full width - parent .markers-section provides the 8px padding for spacing */
        background-color: transparent !important;

    }

    .markers-widget-header {
        padding: 0.4rem 0.6rem;
    }

    .marker-toggle-group {
        justify-content: flex-start;
        flex-wrap: wrap;
        width: 100%;
        overflow: hidden;
    }

    #chart-widgets-container {
        flex-direction: column;
        align-items: stretch !important;
    }

    .markers-widget-icon {
        font-size: 1rem;
    }

    .marker-toggle {
        font-size: 0.65rem;
        padding: 2px 6px;
    }

    .markers-widget-body {
        padding: 0.3rem 0rem 0rem 0rem;
        overflow: visible;
    }

    .marker-display {
        gap: 0.35rem;
        padding: 0.6rem 0.5rem 0rem 0.5rem;
        position: relative;
        z-index: 1;
        /* keep marker bar above chart margin but below chart canvas */
    }

    .marker-display .marker-item {
        padding: 0.65rem 0.55rem 0.4rem 0.55rem;
        min-width: 95px;
        flex: 0 0 95px;
    }

    /* Width override for zone cards on mobile */
    .marker-display .gamma-zone-card {
        min-width: 135px;
        flex: 0 0 135px;
    }

    .marker-price {
        font-size: 0.68rem;
    }

    .marker-value {
        font-size: 0.62rem;
    }

    .marker-badge {
        font-size: 0.6rem;
        padding: 3px 7px;
    }
}

/* Old markers-sidebar desktop width - no longer needed */

/* ========================================
   COMMON WIDGET ITEM STYLES (GEX TOTALS & BIAS)
   ======================================== */

/* Common container for both widgets */
.widget-info-container {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    flex-wrap: nowrap;
    font-size: 0.82rem;
    line-height: 1.2;
    overflow: hidden;
    padding-left: 0.5rem;
}

/* Common item wrapper (each label:value pair) */
.widget-info-item {
    display: inline-flex;
    align-items: baseline;
    gap: 0.25rem;
    white-space: nowrap;
}

/* Common label style (grey, normal weight) */
.widget-info-label {
    font-size: 0.75rem;
    font-weight: 500;
    letter-spacing: 0.2px;
    color: var(--theme-text-secondary);
    line-height: 1.2;
}

/* Common value style (bold, colored) */
.widget-info-value {
    font-size: 0.8rem;
    font-weight: 600;
    line-height: 1.2;
    color: var(--theme-text-primary);
}

/* Color variants for values */
.widget-info-value--call {
    color: var(--theme-positive);
}

.widget-info-value--put {
    color: var(--theme-negative);
}

.widget-info-value--net {
    color: var(--color-info);
}

/* ========================================
   TOTAL GEX PANEL
   ======================================== */

.widget-panel-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding-left: 0.5rem;
    /* Match marker display left padding */
}

.widget-panel-title {
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--theme-text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 2px 0;
    line-height: 1;
    white-space: nowrap;
    flex-shrink: 0;
}

.gex-totals-panel {
    display: none;
    background-color: var(--theme-bg-card);
    border: 1px solid var(--theme-border-primary);
    border-radius: 8px;
    padding: 4px 0px;
    margin-top: 0.45rem;
    margin-left: 0.5rem;
    margin-right: 0.5rem;
    transition: opacity 0.3s ease-in-out;
}

/* Legacy classes - map to common classes */
.gex-totals-inline {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    flex-wrap: nowrap;
    font-size: 0.82rem;
    line-height: 1.2;
    overflow: hidden;
}

.gex-totals-inline span {
    display: inline-flex;
    align-items: baseline;
    gap: 0.25rem;
    white-space: nowrap;
}

.gex-totals-tag {
    font-size: 0.75rem;
    font-weight: 500;
    letter-spacing: 0.2px;
    color: var(--theme-text-secondary) !important;
}

.gex-totals-tag::after {
    content: ": ";
}

.gex-total-inline {
    display: flex;
    align-items: baseline;
    gap: 0.25rem;
}

.gex-total-inline span:not(.gex-totals-tag) {
    font-weight: 600;
    font-size: 0.8rem;
    color: var(--theme-text-primary);
}

.gex-total-inline--call span:not(.gex-totals-tag) {
    color: var(--theme-positive);
}

.gex-total-inline--put span:not(.gex-totals-tag) {
    color: var(--theme-negative);
}

.gex-total-inline--abs span:not(.gex-totals-tag) {
    color: var(--color-info);
}

@media (max-width: 992px) {

    /* Show totals and bias panels inside markers widget on mobile */
    .markers-section .gex-totals-panel,
    .markers-section #gex-bias-panel {
        display: block;
        width: auto;
        margin-top: 0.35rem;
        margin-bottom: 0.35rem;
        margin-left: 0.5rem;
        margin-right: 0.5rem;
    }

    /* Unified font sizing for both panels on mobile */
    .gex-totals-inline,
    .bias-header {
        font-size: 0.72rem;
        gap: 0.45rem;
    }

    .gex-totals-inline span,
    .bias-value-item {
        gap: 0.2rem;
    }

    .gex-totals-tag,
    .bias-ratio-label,
    .bias-value-label {
        font-size: 0.7rem;
    }

    .gex-total-inline span,
    .bias-ratio-value,
    .bias-value-number {
        font-size: 0.72rem;
    }

    .widget-panel-title {
        font-size: 0.68rem;
    }
}

/* ========================================
   ASYMMETRY CARD
   ======================================== */

.asymmetry-card {
    border-radius: 8px;
    padding: 12px;
    margin-bottom: 8px;
    text-align: center;
}

.asymmetry-icon {
    font-size: 2.5rem;
    margin-bottom: 6px;
}

.asymmetry-label {
    font-size: 1.05rem;
    font-weight: 700;
    text-transform: uppercase;
    margin-bottom: 8px;
    letter-spacing: 0.5px;
}

.asymmetry-ratio {
    font-size: 0.85rem;
    margin-bottom: 8px;
}

.asymmetry-detail {
    font-size: 0.75rem;
    opacity: 0.85;
    margin-bottom: 4px;
}

.collapsible-header {
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    user-select: none;
    padding: 4px 0;
}

.collapse-icon {
    transition: transform 0.2s ease;
    font-weight: bold;
}

.collapse-icon.collapsed {
    transform: rotate(-90deg);
}

.slider-section-container.slider-hidden {
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
}

.slider-section-container.slider-discrete .noUi-marker,
.slider-section-container.slider-discrete .noUi-marker-sub {
    display: none;
}

.slider-section-container.slider-discrete .noUi-marker.noUi-marker-large {
    display: block;
}

/* ========================================
   SLIDER STYLES
   ======================================== */

/* Highlight selected slider tick */
#gexThresholdSlider .noUi-value {
    cursor: pointer;
}

#gexThresholdSlider .noUi-value.active-tick {
    font-weight: bold;
    font-size: 1.1em;
}

/* ========================================
   BIAS PANEL
   ======================================== */

#gex-bias-panel {
    margin-top: 0.45rem;
    margin-left: 0.5rem;
    margin-right: 0.5rem;
}

.gex-bias-panel-content {
    border-radius: 8px;
    padding: 4px 0px;
    background-color: var(--theme-bg-card);
    border: 1px solid var(--theme-border-primary);
}

.bias-header {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    margin-bottom: 0;
    font-size: 0.82rem;
    line-height: 1.2;
}

.bias-icon {
    display: none;
}

.bias-info {
    flex: 1;
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 0.6rem;
}

/* Legacy bias classes - map to common widget classes */
.bias-label {
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.2px;
    line-height: 1.2;
    color: var(--theme-text-primary);
}

.bias-ratio-line {
    display: flex;
    align-items: baseline;
    gap: 0.25rem;
}

.bias-ratio-label {
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--theme-text-secondary);
    line-height: 1.2;
    letter-spacing: 0.2px;
}

.bias-ratio-value {
    font-size: 0.8rem;
    font-weight: 600;
    line-height: 1.2;
    color: var(--theme-text-primary);
}

.bias-values {
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.bias-value-item {
    display: flex;
    flex-direction: row;
    align-items: baseline;
    gap: 0.25rem;
}

.bias-value-label {
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--theme-text-secondary);
    letter-spacing: 0.2px;
    line-height: 1.2;
}

.bias-value-number {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--theme-text-primary);
    line-height: 1.2;
}

/* ========================================
   RESPONSIVE SLIDER (SINGLE SLIDER)
   ======================================== */

.slider-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    margin-bottom: 0.25rem;
}

.slider-wrapper {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.slider-track {
    flex: 1;
}

.slider-value {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.25rem 0.75rem;
    min-width: 64px;
    /* Keep badge width stable as value changes */
    text-align: center;
    font-variant-numeric: tabular-nums;
    /* Use tabular numbers to avoid width jitter */
    transition: none;
    /* Prevent CSS transition-induced width changes */
}

/* Desktop: horizontal layout with label on left */
@media (min-width: 769px) {
    .slider-section-container {
        margin: 0 auto 0;
        padding: 0.75rem 1.5rem 1.25rem 1.5rem;
        border: 1px solid var(--theme-border-primary);
        border-radius: 8px;
        background: var(--theme-bg-card);
        display: grid;
        grid-template-columns: auto 1fr;
        align-items: center;
        gap: 0.75rem;
        max-width: 1150px;
        width: 100%;
        box-sizing: border-box;
    }

    .slider-header {
        justify-content: flex-start;
        gap: 0.5rem;
    }

    .slider-track {
        padding-bottom: 18px;
    }
}

/* Mobile: vertical layout, centered label, outside main-content */
@media (max-width: 768px) {
    .slider-section-container {
        /* position: fixed; removed for flex layout */
        /* bottom: 0; removed for flex layout */
        /* left: 0; removed for flex layout */
        /* right: 0; removed for flex layout */
        display: flex;
        flex-direction: column;
        align-items: stretch;
        gap: 0.45rem;
        /* padding: 0.55rem 0.85rem calc(0rem + env(safe-area-inset-bottom, 0px)); */
        padding: 0.55rem 0.5rem calc(0.55rem + env(safe-area-inset-bottom, 10px));
        /* Restore safe area padding */
        display: none !important;
        /* Hide on mobile as per requirement */
        background: var(--theme-bg-card);
        /* border-top: 1px solid var(--theme-border-primary); removed */
        border: 1px solid var(--theme-border-primary);
        /* Add full border */
        border-radius: 8px;
        /* Rounded corners */
        box-shadow: none;
        /* z-index: 1100; removed */
        flex-shrink: 0;
        /* Prevent shrinking */
        margin: 0 0.5rem 0.5rem 0.5rem;
        /* Margin for spacing */
    }

    .slider-header {
        margin-bottom: 0;
    }

    .slider-label {
        font-size: 0.9rem;
        font-weight: 600;
        letter-spacing: 0.4px;
    }

    .slider-wrapper {
        align-items: center;
        gap: 0.45rem;
    }

    .slider-track {
        padding-bottom: 16px;
    }

    .slider-value {
        font-size: 0.82rem;
        padding: 0.25rem 0.65rem;
        min-width: 60px;
        /* Fixed width to prevent layout shift */
        width: 60px;
        text-align: center;
        flex-shrink: 0;
        font-variant-numeric: tabular-nums;
        /* Monospace numbers */
    }

    /* Larger touch targets for mobile */
    #gexThresholdSlider .noUi-handle {
        width: 30px !important;
        height: 30px !important;
        right: -15px !important;
        top: -13px !important;
        border-radius: 50%;
        cursor: pointer;
        touch-action: none;
        box-shadow: 0 0 5px rgba(0, 0, 0, 0.3);
    }

    #gexThresholdSlider .noUi-target {
        height: 7px;
        touch-action: none;
    }

    #gexThresholdSlider .noUi-base {
        touch-action: none;
    }

    #gexThresholdSlider .noUi-pips {
        font-size: 0.65rem;
    }

    #gexThresholdSlider .noUi-marker-large {
        height: 8px;
    }
}

@media (max-width: 768px) {
    .gex-container {
        padding-bottom: 0 !important;
        /* Force remove fixed padding */
    }

    .gex-totals-row {
        gap: 0.35rem;
    }

    .gex-total-chip {
        padding: 0.22rem 0.35rem;
        gap: 0.25rem;
    }

    .gex-total-title {
        font-size: 0.7rem;
    }

    .gex-total-label {
        font-size: 0.6rem;
    }

    .gex-total-value {
        font-size: 0.78rem;
    }
}

/* Hide vertical toolbar on mobile */
@media (max-width: 768px) {
    .vertical-toolbar {
        display: none;
    }
}

/* Very small phones - wrap GEX totals into 2 rows */
/* Very small phones - wrap GEX totals into 2 rows */
@media (max-width: 380px) {

    .gex-totals-inline,
    .bias-info {
        flex-wrap: wrap !important;
        gap: 0.4rem 0.5rem !important;
        /* vertical gap, horizontal gap */
        justify-content: space-between;
    }

    .gex-total-inline,
    .bias-value-item {
        flex: 0 0 48%;
        /* Each item takes ~48% width, creates 2x2 grid */
        min-width: 0;
        /* Allow text truncation if needed */
        justify-content: flex-start;
        /* Ensure items align left */
    }

    .gex-totals-panel,
    .gex-bias-panel-content {
        padding: 6px 8px !important;
        /* Slightly more padding for wrapped layout */
    }

    /* Adjust bias header to allow wrapping if needed, or keep label on top */
    .bias-header {
        flex-wrap: wrap;
    }

    .bias-info {
        display: flex;
        /* Ensure flex behavior */
        width: 100%;
        /* Take full width to force wrapping */
    }
}

/* ========================================
   RESPONSIVE DESIGN
   ======================================== */

/* ========================================
   MOBILE LAYOUT - CONSISTENT 8px (0.5rem) PADDING
   ========================================
   Strategy: All content elements use 8px horizontal padding
   - Card body provides base padding
   - chart-widgets-container breaks out with negative margins
   - All child elements add padding back for consistent alignment
   ======================================== */

@media (max-width: 768px) {
    .main-content-full {
        padding: 0;
        overflow-x: visible !important;
        /* Allow content to use margins */
    }

    .main-content-full>.card {
        margin-bottom: 0.5rem;
        border-radius: 0;
        overflow-x: visible !important;
        /* Allow markers-widget margins to show */
    }

    .main-content-full>.card .card-body {
        padding: 0.5rem 0.5rem !important;
        /* Base 8px padding - matches toolbar */
    }

    /* Compact spacing for chart widgets container - stays within card-body padding */
    #chart-widgets-container {
        margin-bottom: 0 !important;
        padding: 0 !important;
        gap: 0.25rem !important;
        /* Reduced gap for mobile */
    }

    /* Chart section - no padding needed, charts extend to card-body edges */
    .chart-section {
        padding: 0 !important;
        box-sizing: border-box !important;
    }

    /* Markers section - needs padding so widget card has visual separation */
    .markers-section {
        padding: 0 0.5rem !important;
        /* Adds 8px spacing so widget doesn't touch card edges */
        box-sizing: border-box !important;
    }

    /* Term container - no padding at container level, handled by child views */
    .gex-term-container {
        padding: 0 !important;
    }

    /* #gex-term-chart-view styling moved to Term Structure section below */

    /* term-marker-widget padding now handled by parent .markers-section */

    /* Premium banner - ensure it extends to edges with proper padding */
    .premium-banner {
        margin-left: -0.5rem;
        margin-right: -0.5rem;
        border-radius: 0;
        /* Full width on mobile */
    }

    .premium-banner-content {
        padding: 0.5rem;
        /* Consistent 8px padding to match toolbar */
    }

    /* Chart containers should use full width */
    .gex-chart-container {
        width: 100% !important;
        padding: 0 !important;
        margin: 0 !important;
    }

    /* Compact header spacing - smaller height for mobile */
    .header-container {
        padding: 0.1rem 15px;
    }

    /* Smaller logo on mobile */
    #header-logo {
        height: 32px !important;
    }
}

/* ========================================
   GEX TERM STRUCTURE STYLES
   ======================================== */

/* Term Container - no margin needed, flex gap handles spacing */
.gex-term-container {
    padding: 0;
    width: 100%;
    margin: 0;
    position: relative; /* required for loading overlay pseudo-elements */
}

/* =====================================================================
   View Controls Row (Container for view switcher + expiration controls)
   ===================================================================== */

/* View switcher container - aligns switcher to start */
.view-switcher-container {
    display: flex;
    justify-content: flex-start;
    align-items: center;
    margin-bottom: 0;
}

/* =====================================================================
   View Switcher (Compact toggle buttons)
   ===================================================================== */

.view-switcher {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.3rem;
    border-radius: 999px;
    border: 1px solid var(--theme-border-primary);
    background: var(--theme-bg-secondary);
    max-width: 280px;
    flex-wrap: nowrap;
}

/* GEX View Containers */
.gex-view {
    width: 100%;
}


.gex-view.active {
    display: block;
}

.gex-ohlc-container {
    position: relative;
    background: var(--theme-bg-card);
    border-radius: 0.75rem;
    border: 1px solid var(--theme-border-primary);
    padding: 0rem 0.6rem 1.4rem 0.6rem;
    /* extra bottom padding so x-axis labels aren't clipped */
    width: 100%;
    max-width: 100%;
    overflow: hidden;
}

/* OHLC Metadata Overlay - displays chart info at top-left */
.gex-ohlc-metadata-overlay {
    position: absolute;
    top: 12px;
    left: 12px;
    /* Moved right to avoid Y-axis overlap */
    z-index: 10;
    padding: 6px 12px;
    background: rgba(var(--theme-bg-card-rgb), 0.85);
    backdrop-filter: blur(4px);
    border: 1px solid var(--theme-border-secondary);
    border-radius: 6px;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--theme-text-primary);
    pointer-events: none;
    white-space: nowrap;
    line-height: 1.4;
}

/* Specific override for GEX by Strike view to avoid Y-axis overlap */
.gex-strike-metadata-overlay {
    left: 100px;
}

/* Dark mode specific adjustments */
[data-theme="dark"] .gex-ohlc-metadata-overlay {
    background: rgba(30, 30, 35, 0.9);
    border-color: rgba(255, 255, 255, 0.15);
}

/* Light mode specific adjustments */
[data-theme="light"] .gex-ohlc-metadata-overlay {
    background: rgba(255, 255, 255, 0.9);
    border-color: rgba(0, 0, 0, 0.1);
}

/* Static Chart Title (replaces overlay) - Two-line, left-aligned */
.gex-chart-title {
    display: block;
    width: 100%;
    padding: 4px 0 2px 8px;
    margin-bottom: 0;
    background: transparent;
    border-bottom: none;
    font-size: 12px;
    font-weight: normal;
    color: var(--theme-text-primary);
    white-space: normal;
    line-height: 1.4;
    box-sizing: border-box;
    text-align: left;
}

[data-theme="dark"] .gex-chart-title {
    color: #e0e0e0;
}

[data-theme="light"] .gex-chart-title {
    color: #333333;
}

/* Responsive styles for view controls */
@media (max-width: 768px) {
    .view-controls-row {
        gap: 0.5rem;
        padding: 0 0.75rem;
        /* Match card-body horizontal padding */
        margin-bottom: 0.35rem;
    }

    #strike-profile-view-controls-row {
        margin-bottom: 0.35rem;
    }

    .view-switcher-container {
        margin-bottom: 0;
    }

    .view-switcher {
        max-width: 100%;
        padding: 0.2rem;
        gap: 0.2rem;
    }

    .expiration-controls {
        gap: 0.4rem;
        justify-content: flex-end;
    }

    /* Make expiration selector wider on mobile to show full dates */
    .expiration-controls .gex-expiration-select {
        max-width: 160px !important;
        min-width: 120px !important;
        font-size: 0.8rem;
    }

    .gex-ohlc-container {
        height: 455px !important;
        /* Match Plotly chart height */
        width: 100% !important;
        max-width: 100% !important;
        padding: 0;
        /* Remove padding to match Plotly width */
        margin: 0 auto;
    }

    .gex-ohlc-metadata-overlay {
        font-size: 0.65rem;
        padding: 4px 6px;
        top: 6px;
        left: 6px;
        /* Moved right for mobile too */
    }

    .gex-strike-metadata-overlay {
        left: 60px;
    }
}

/* Very small screens - keep in one row but make everything smaller */
@media (max-width: 576px) {
    .view-controls-row {
        gap: 0.4rem;
    }

    .expiration-controls .gex-expiration-select {
        max-width: 140px !important;
        min-width: 110px !important;
    }
}



/* Old View Button Styles Removed (Unified) */

/* Responsive styles for view buttons */
@media (max-width: 768px) {
    .view-btn {
        font-size: 0.8rem;
        padding: 0.25rem 0.5rem;
    }
}

/* Table View */
#gex-term-table-view {
    padding: 0 0.5rem;
    overflow-x: hidden;
    background: var(--theme-bg-card);
    border-radius: 0.75rem;
    border: 1px solid var(--theme-border-primary);
}

.gex-term-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
    margin-top: 1rem;
}

.gex-term-table thead {
    position: sticky;
    top: 0;
    background: var(--theme-bg-card);
    z-index: 10;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.gex-term-table th,
.gex-term-table td {
    padding: 0.75rem;
    text-align: right;
    border-bottom: 1px solid var(--theme-border-primary);
}

.gex-term-table th:first-child,
.gex-term-table td:first-child {
    text-align: left;
    font-weight: 600;
    position: sticky;
    left: 0;
    background: var(--theme-bg-secondary);
    z-index: 11;
    /* ensure date column stays above scrolling rows */
}

.gex-term-table td.strike-cell {
    cursor: pointer;
    transition: background 0.2s;
}

.gex-term-table td.strike-cell:hover {
    background: var(--hover-bg);
}

.gex-term-table tr.total-row {
    font-weight: 700;
    background: var(--theme-bg-tertiary);
}

/* Marker column coloring */
.gex-term-table thead .marker-max-pain {
    color: var(--marker-mp-bg);
}

.gex-term-table thead .marker-positive {
    color: var(--marker-pos-bg);
}

.gex-term-table thead .marker-negative {
    color: var(--marker-neg-bg);
}

.gex-term-table thead .marker-absolute {
    color: var(--marker-abs-bg);
}

.gex-term-table thead .marker-flip {
    color: var(--marker-flip-bg);
}

@media (max-width: 768px) {
    #gex-term-table-view {
        padding: 0 0.5rem;
        /* Align with toolbar */
        overflow-x: auto;
        /* Allow horizontal scrolling for wide table */
    }

    .gex-term-table {
        min-width: 640px;
        /* Table needs to be wide, will scroll horizontally */
    }
}

/* Chart View */
#gex-term-chart-view {
    padding: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    flex-grow: 1;
    flex-basis: 0;
    min-height: 0;
}

#gex-term-plot {
    width: 100%;
    /* Desktop: Dynamic height for Term View - matches strike/profile offset
       Offset 480px accounts for: Header, Controls, Markers Widget (100px), Zoom Slider (100px) */
    height: calc(100vh - 480px);
    min-height: 300px;
    margin: 0;
    padding: 0;
    flex-grow: 1;
}

/* Ensure Plotly fills its container */
#gex-term-plot .plotly,
#gex-term-plot .plot-container,
#gex-term-plot .js-plotly-plot {
    width: 100% !important;
    height: 100% !important;
    margin: 0;
    padding: 0;
}

/* term-marker-widget is now wrapped by .markers-section, spacing handled by parent */

.term-marker-widget .markers-widget-body {
    padding: 0.75rem 0.85rem 0.85rem;
    overflow: visible;
}

.term-widget-header {
    justify-content: flex-start;
    gap: 0.5rem;
    padding: 0.55rem 0.85rem;
}

.term-widget-heading {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    line-height: 1.15;
    text-align: left;
}

.term-widget-title {
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text-primary);
}

.term-widget-subtitle {
    font-size: 0.78rem;
    color: var(--text-muted);
}

/* Marker Toggle Panel - Badge Style */
.term-marker-toggle-panel {
    padding: 0.5rem 0.25rem;
    margin-top: 0.35rem;
}

.term-badge-scroll-container {
    display: flex;
    gap: 0.5rem;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    padding-bottom: 0.25rem;
}

.term-badge-scroll-container::-webkit-scrollbar {
    height: 6px;
}

.term-badge-scroll-container::-webkit-scrollbar-track {
    background: var(--theme-bg-card);
    border-radius: 3px;
}

.term-badge-scroll-container::-webkit-scrollbar-thumb {
    background: var(--theme-border-primary);
    border-radius: 3px;
}

.term-badge-scroll-container::-webkit-scrollbar-thumb:hover {
    background: var(--accent-primary);
}

.term-marker-badge {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    padding: 5px 10px;
    white-space: normal;
    text-align: center;
}

.term-marker-badge .term-toggle-label {
    line-height: 1.2;
}

.term-marker-badge .marker-subtitle {
    line-height: 1.1;
}

.term-marker-badge.active {
    background: linear-gradient(135deg, var(--theme-header-start), var(--theme-header-end));
    color: #ffffff;
    border-color: transparent;
}

.term-marker-badge.active .marker-subtitle {
    color: rgba(255, 255, 255, 0.7);
}

/* Marker badges - active state with specific colors matching chart traces */
.term-badge-max-pain.active {
    background: var(--marker-mp-bg);
    border-color: color-mix(in srgb, var(--marker-mp-bg) 50%, transparent);
    color: #ffffff;
}

.term-badge-flip-points.active {
    background: var(--marker-flip-bg);
    border-color: color-mix(in srgb, var(--marker-flip-bg) 50%, transparent);
    color: #ffffff;
}

.term-badge-positive.active {
    background: var(--marker-pos-bg);
    border-color: color-mix(in srgb, var(--marker-pos-bg) 50%, transparent);
    color: #ffffff;
}

.term-badge-negative.active {
    background: var(--marker-neg-bg);
    border-color: color-mix(in srgb, var(--marker-neg-bg) 50%, transparent);
    color: #ffffff;
}

.term-badge-absolute.active {
    background: var(--marker-abs-bg);
    border-color: color-mix(in srgb, var(--marker-abs-bg) 50%, transparent);
    color: #ffffff;
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .gex-term-container {
        padding: 0;
        margin: 0;
        display: flex;
        flex-direction: column;
        flex-grow: 1;
        /* Fill chart-section like other views */
        flex-basis: 0;
        min-height: 0;
        /* Allow shrinking */
    }
}

/* ========================================
   REPLAY CONTROLS (TIME MACHINE) - MOBILE
   ======================================== */

@media (max-width: 768px) {

    /* Increase Replay Controls Size */
    /* Increase Replay Controls Size */
    .tm-playback-controls button {
        padding: 0.35rem 0.7rem !important;
        font-size: 1.0rem !important;
        min-width: 30px;
        min-height: 30px;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    /* Increase Timeline Slider Toggle Size */
    #tm-slider .noUi-handle {
        width: 28px !important;
        height: 28px !important;
        right: -14px !important;
        top: -11px !important;
        box-shadow: 0 0 5px rgba(0, 0, 0, 0.4);
    }

    /* Ensure slider track accommodates larger handle */
    #tm-slider {
        height: 8px !important;
    }

    /* Increase Spacing Between Timeline and Controls */
    .tm-slider-wrapper {
        margin-top: 0.5rem !important;
    }

    /* Term View (Chart/Table) should fill available space */
    .term-view {
        display: flex;
        flex-direction: column;
        flex-grow: 1;
        flex-basis: 0;
        min-height: 0;
        margin: 0;
    }

    #gex-term-plot {
        flex-grow: 1;
        flex-basis: 0;
        min-height: 0;
        height: 100% !important;
        /* Override desktop fixed height */
        margin: 0;
    }

    /* Ensure Plotly chart fills container on mobile */
    #gex-term-plot .main-svg,
    #gex-term-plot .js-plotly-plot,
    #gex-term-plot .plot-container,
    #gex-term-plot .plotly {
        width: 100% !important;
        height: 100% !important;
    }

    #gex-term-plot .main-svg {
        border-radius: 0;
    }

    /* OHLC Container specific flex rules */
    .gex-ohlc-container {
        display: flex;
        flex-direction: column;
        height: 100% !important;
        min-height: 0 !important;
        flex-grow: 1;
        margin: 0;
        padding: 0;
    }

    /* Ensure the wrapper also expands */
    #gex-ohlc-view {
        display: flex;
        flex-direction: column;
        height: 100% !important;
        flex-grow: 1;
    }

    #gex-term-container .view-controls-row {
        margin-bottom: 0.35rem;
        padding: 0 0.75rem;
    }

    #gex-term-chart-view {
        padding: 0 0.5rem;
        /* Horizontal padding for toolbar alignment */
        height: 100% !important;
        flex-grow: 1;
        flex-basis: 0;
        min-height: 0;
    }

    /* #gex-term-plot { min-height: 300px; } Removed to allow flex shrinking */

    /* .term-marker-widget margin now handled by parent .term-markers-section */

    .gex-term-table {
        font-size: 0.75rem;
    }

    .gex-term-table th,
    .gex-term-table td {
        padding: 0.5rem 0.25rem;
    }

    .term-marker-toggle-panel {
        grid-template-columns: 1fr;
    }
}

/* ========================================
   MARKER BADGE UTILITIES (Centralized)
   ======================================== */
.marker-badge-pos {
    background-color: var(--marker-pos-bg) !important;
    color: var(--marker-pos-text) !important;
}

.marker-badge-neg {
    background-color: var(--marker-neg-bg) !important;
    color: var(--marker-neg-text) !important;
}

.marker-badge-abs {
    background-color: var(--marker-abs-bg) !important;
    color: var(--marker-abs-text) !important;
}

.marker-badge-flip {
    background-color: var(--marker-flip-bg) !important;
    color: var(--marker-flip-text) !important;
}

.marker-badge-mp {
    background-color: var(--marker-mp-bg) !important;
    color: var(--marker-mp-text) !important;
}

/* Status indicator removed - integrated into chart title */
/* Initialization: Fade in controls to prevent flickering.
   Uses opacity-only (no visibility:hidden) to preserve layout space and prevent layout shift. */
.gex-controls-init-hidden {
    opacity: 0 !important;
    transition: opacity 0.2s ease-in;
}

.gex-controls-visible {
    opacity: 1;
}

/* ========================================
   TIME MACHINE (REPLAY)
   ======================================== */

/* Time Machine Controls Bar (replay timeline only, hidden in live mode) */
.tm-controls-bar {
    padding: 4px var(--toolbar-px, 12px) 20px;
}

/* Playback buttons */
.tm-playback-controls {
    display: flex;
    gap: 2px;
    flex-shrink: 0;
}

.tm-playback-controls .btn {
    font-size: 0.75rem;
    padding: 0.2rem 0.45rem;
    line-height: 1;
}

/* Share replay link button */
#tm-share-btn {
    flex-shrink: 0;
    padding: 0.2rem 0.4rem;
    line-height: 1;
}

/* Speed control buttons removed - now using select/combobox */

/* Timeline slider */
.tm-slider-wrapper {
    flex: 1;
    min-width: 120px;
    padding: 0 4px;
}

.tm-slider-wrapper .noUi-target {
    height: 6px;
    border: none;
    box-shadow: none;
    background: var(--bs-border-color, #dee2e6);
}

.tm-slider-wrapper .noUi-connect {
    background: var(--bs-primary, #0d6efd);
}

.tm-slider-wrapper .noUi-handle {
    width: 16px;
    height: 16px;
    right: -8px;
    top: -6px;
    border-radius: 50%;
    background: var(--bs-primary, #0d6efd);
    border: 2px solid #fff;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
    cursor: pointer;
}

.tm-slider-wrapper .noUi-handle::before,
.tm-slider-wrapper .noUi-handle::after {
    display: none;
}

/* Slider tooltip */
.tm-slider-wrapper .noUi-tooltip {
    display: none;
    /* Hidden by default, shown only during drag */
    background: rgba(0, 0, 0, 0.9);
    color: #fff;
    border: none;
    border-radius: 4px;
    padding: 6px 10px;
    font-size: 0.66rem;
    font-weight: 500;
    white-space: nowrap;
    bottom: 125%;
    /* Closer to handle than 200% */
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    transition: transform 0.15s ease-out;
}

/* Tooltip positioning when near left edge */
.tm-slider-wrapper .noUi-tooltip.align-left {
    transform: translateX(0);
    left: 0;
}

/* Tooltip positioning when near right edge */
.tm-slider-wrapper .noUi-tooltip.align-right {
    transform: translateX(-100%);
    left: 0;
}

/* Slider pips (day/4h tick marks) */
.tm-slider-wrapper .noUi-pips {
    font-size: 0.5rem;
    padding: 3px 0 0;
    height: 24px;
    color: var(--theme-text-secondary, #6c757d);
}

.tm-slider-wrapper .noUi-pips .noUi-marker-large {
    height: 8px;
    width: 1px;
    background: var(--theme-text-secondary, #6c757d);
}

.tm-slider-wrapper .noUi-pips .noUi-marker-normal,
.tm-slider-wrapper .noUi-pips .noUi-marker-sub {
    height: 4px;
    width: 1px;
    background: var(--theme-text-muted, #adb5bd);
}

.tm-slider-wrapper .noUi-pips .noUi-value {
    font-size: 0.5rem;
    color: var(--theme-text-secondary, #6c757d);
    padding-top: 1px;
    cursor: pointer;
    transition: color 0.15s;
}

.tm-slider-wrapper .noUi-pips .noUi-value:hover {
    color: var(--theme-text-primary, #fff);
}

.tm-slider-wrapper .noUi-pips .noUi-value-sub {
    display: none;
}

.tm-date-picker {
    width: auto;
    max-width: 140px;
    font-size: 0.75rem;
    flex-shrink: 0;
}

/* Hide clear/reset button on date picker */
.tm-date-picker::-webkit-clear-button,
.tm-date-picker::-ms-clear {
    display: none;
}

/* Speed select styling removed - now handled in responsive section above */


/* Disabled chart/view mode buttons during replay */
.gex-toggle-btn.tm-disabled {
    opacity: 0.35;
    pointer-events: none;
    cursor: not-allowed;
}

/* Mobile: Stack replay bar */
@media (max-width: 767px) {
    .tm-controls-bar {
        padding-bottom: 2rem;
        /* Increased spacing between timeline and chart on mobile */
    }

    .tm-controls-bar .d-flex {
        flex-wrap: wrap;
        gap: 6px;
    }

    .tm-slider-wrapper {
        min-width: 100%;
        order: 10;
        overflow: visible !important;
        /* Ensure handle isn't clipped */
        padding: 0 10px;
        /* Add padding for handle overhang */
    }

    .tm-date-picker {
        max-width: 150px;
    }
}


/* ========================================
   TIPPY.JS TOOLTIP THEMES
   Contextual tooltips for UI controls and
   chart markers (Phase 1 Help System)
   ======================================== */

/* --- Light Theme --- */
.tippy-box[data-theme~='gex-light'] {
    background-color: #ffffff;
    color: #212529;
    border: 1px solid #dee2e6;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    font-size: 0.8125rem;
    line-height: 1.4;
    border-radius: 6px;
}

.tippy-box[data-theme~='gex-light'][data-placement^='top'] > .tippy-arrow::before {
    border-top-color: #ffffff;
}

.tippy-box[data-theme~='gex-light'][data-placement^='bottom'] > .tippy-arrow::before {
    border-bottom-color: #ffffff;
}

.tippy-box[data-theme~='gex-light'][data-placement^='left'] > .tippy-arrow::before {
    border-left-color: #ffffff;
}

.tippy-box[data-theme~='gex-light'][data-placement^='right'] > .tippy-arrow::before {
    border-right-color: #ffffff;
}

/* --- Dark Theme --- */
.tippy-box[data-theme~='gex-dark'] {
    background-color: #161b22;
    color: #e6edf3;
    border: 1px solid #30363d;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
    font-size: 0.8125rem;
    line-height: 1.4;
    border-radius: 6px;
}

.tippy-box[data-theme~='gex-dark'][data-placement^='top'] > .tippy-arrow::before {
    border-top-color: #161b22;
}

.tippy-box[data-theme~='gex-dark'][data-placement^='bottom'] > .tippy-arrow::before {
    border-bottom-color: #161b22;
}

.tippy-box[data-theme~='gex-dark'][data-placement^='left'] > .tippy-arrow::before {
    border-left-color: #161b22;
}

.tippy-box[data-theme~='gex-dark'][data-placement^='right'] > .tippy-arrow::before {
    border-right-color: #161b22;
}

/* --- Mobile --- */
@media (max-width: 767.98px) {
    .tippy-box[data-theme~='gex-light'],
    .tippy-box[data-theme~='gex-dark'] {
        font-size: 0.75rem;
        max-width: 240px;
    }
}


/* ========================================
   HELP DRAWER (Phase 2 Help System)
   Searchable side panel using Bootstrap
   Offcanvas + Fuse.js fuzzy search
   ======================================== */

/* --- Offcanvas Override --- */
.help-drawer {
    width: 380px;
    border-left: 1px solid var(--theme-border-color, #dee2e6);
    background-color: var(--theme-bg-secondary);
    color: var(--theme-text-primary);
    z-index: 10050;
}

.help-drawer-header {
    border-bottom: 1px solid var(--theme-border-color, #dee2e6);
    padding: 16px 20px;
    background-color: var(--theme-bg-secondary);
}

.help-drawer-header .offcanvas-title {
    font-weight: 600;
    font-size: 1.1rem;
}

.help-drawer-body {
    padding: 16px 20px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

/* --- Search Input --- */
.help-search-container .form-control {
    background-color: var(--theme-bg-primary);
    border-color: var(--theme-border-color);
    color: var(--theme-text-primary);
    font-size: 0.875rem;
}

.help-search-container .form-control::placeholder {
    color: var(--theme-text-secondary);
}

.help-search-container .form-control:focus {
    border-color: var(--theme-accent-color, #0d6efd);
    box-shadow: 0 0 0 0.2rem rgba(13, 110, 253, 0.15);
}

/* --- Category Accordion --- */
.help-accordion {
    margin-top: 4px;
}

.help-category {
    margin-bottom: 2px;
}

.help-category-header {
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    padding: 10px 0;
    display: flex;
    align-items: center;
    gap: 8px;
    border-bottom: 1px solid var(--theme-border-subtle, rgba(128,128,128,0.15));
    user-select: none;
    transition: opacity 0.15s;
}

.help-category-header:hover {
    opacity: 0.8;
}

.help-category-icon {
    font-size: 1rem;
    flex-shrink: 0;
}

.help-category-label {
    flex: 1;
}

.help-category-count {
    font-size: 0.7rem;
    font-weight: 500;
    padding: 2px 6px;
}

.help-category-chevron {
    font-size: 0.75rem;
    color: var(--theme-text-secondary);
    flex-shrink: 0;
}

/* --- Category Body (entries container) --- */
.help-category-body {
    padding-left: 12px;
    border-left: 2px solid var(--theme-border-subtle, rgba(128,128,128,0.18));
    margin-left: 6px;
}

/* --- Entry Card --- */
.help-entry,
.help-search-result {
    padding: 8px 0;
    border-bottom: 1px solid var(--theme-border-subtle, rgba(128,128,128,0.1));
    cursor: pointer;
    transition: background-color 0.15s;
}

.help-entry:last-child,
.help-search-result:last-child {
    border-bottom: none;
}

.help-entry:hover,
.help-search-result:hover {
    background-color: rgba(128,128,128,0.05);
}

.help-entry-title {
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--theme-text-primary);
    margin-bottom: 2px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.help-entry-color {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

/* Marker color classes for inline text references */
.mk-pos  { color: #28a745; font-weight: 600; }
.mk-neg  { color: #dc3545; font-weight: 600; }
.mk-abs  { color: #6c00cd; font-weight: 600; }
.mk-flip { color: #ff00ff; font-weight: 600; }
.mk-mp   { color: #007bff; font-weight: 600; }
.mk-gc   { color: #ff8c00; font-weight: 600; }

.help-entry-summary {
    font-size: 0.8rem;
    color: var(--theme-text-secondary);
    margin-bottom: 0;
    line-height: 1.4;
}

.help-entry-body {
    display: none;
    font-size: 0.8rem;
    color: var(--theme-text-primary);
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid var(--theme-border-subtle, rgba(128,128,128,0.1));
    line-height: 1.5;
}

.help-entry-body p {
    margin-bottom: 8px;
}

.help-entry-body ul {
    padding-left: 18px;
    margin-bottom: 8px;
}

.help-entry-body li {
    margin-bottom: 4px;
}

.help-entry-body kbd {
    background-color: rgba(128,128,128,0.15);
    border: 1px solid rgba(128,128,128,0.3);
    border-radius: 3px;
    padding: 1px 5px;
    font-size: 0.8em;
    font-family: monospace;
}

.help-entry.expanded .help-entry-body,
.help-search-result.expanded .help-entry-body {
    display: block;
}

.help-entry.expanded,
.help-search-result.expanded {
    background-color: var(--theme-help-expanded-bg);
    border-radius: 4px;
    padding-left: 8px;
    padding-right: 6px;
    border-left: 2px solid var(--theme-help-expanded-border);
}

.help-entry.expanded .help-entry-title,
.help-search-result.expanded .help-entry-title {
    color: var(--theme-help-expanded-title);
}

/* --- Related Links --- */
.help-entry-related {
    margin-top: 8px;
    padding-top: 6px;
    border-top: 1px solid var(--theme-border-subtle, rgba(128,128,128,0.1));
}

.help-related-label {
    font-size: 0.75rem;
    color: var(--theme-text-secondary);
    margin-right: 4px;
}

.help-related-link {
    font-size: 0.75rem;
    color: #58a6ff;
    cursor: pointer;
}

.help-related-link:hover {
    text-decoration: underline;
}

/* --- Scroll-to-Entry Highlight --- */
.help-entry-highlight {
    animation: helpEntryFlash 1.5s ease;
}

@keyframes helpEntryFlash {
    0% { background-color: rgba(13, 110, 253, 0.2); }
    100% { background-color: transparent; }
}

/* --- Tour CTA in Help Drawer --- */
.help-tour-cta {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 14px;
    margin-bottom: 12px;
    border-radius: 8px;
    cursor: pointer;
    background-color: rgba(108, 92, 231, 0.1);
    border: 1px solid rgba(108, 92, 231, 0.25);
    transition: background-color 0.15s ease;
}

.help-tour-cta:hover {
    background-color: rgba(108, 92, 231, 0.18);
}

.help-tour-cta-icon {
    font-size: 1.3rem;
    flex-shrink: 0;
}

.help-tour-cta-text {
    display: flex;
    flex-direction: column;
    gap: 1px;
    flex: 1;
    min-width: 0;
}

.help-tour-cta-text strong {
    font-size: 0.875rem;
    color: var(--theme-text-primary, #212529);
}

.help-tour-cta-text span {
    font-size: 0.75rem;
    color: var(--theme-text-secondary, #6c757d);
}

.help-tour-cta-arrow {
    font-size: 1.2rem;
    color: var(--theme-text-secondary, #6c757d);
    flex-shrink: 0;
}

/* --- Search Results --- */
.help-search-result .help-entry-category {
    font-size: 0.7rem;
    color: var(--theme-text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 2px;
}

.help-search-result mark {
    background-color: rgba(255, 193, 7, 0.3);
    color: inherit;
    padding: 0 1px;
    border-radius: 2px;
}


/* --- Tippy "Learn more" link --- */
.tippy-learn-more {
    margin-top: 6px;
    padding-top: 4px;
    border-top: 1px solid rgba(128,128,128,0.3);
    font-size: 0.75rem;
    color: #58a6ff;
    cursor: pointer;
}

.tippy-learn-more:hover {
    text-decoration: underline;
}

/* --- Mobile: Full-width drawer + larger help button tap target --- */
@media (max-width: 767.98px) {
    .help-drawer {
        width: 100% !important;
    }

    #helpFab,
    #gex-manual-refresh-btn {
        min-width: 36px;
        height: 36px;
        padding: 0.3rem 0.6rem;
        justify-content: center;
    }

    .header-menu-btn {
        height: 36px;
    }
}

/* ========================================
   DRIVER.JS TOUR THEME (Phase 3 Help System)
   ======================================== */

/* --- Dark theme (default) --- */
.driver-popover.gex-tour {
    background-color: #1e1e2e;
    color: #e0e0e0;
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
    border-radius: 10px;
    max-width: 340px;
}

.driver-popover.gex-tour .driver-popover-title {
    color: #ffffff;
    font-size: 1rem;
    font-weight: 600;
}

.driver-popover.gex-tour .driver-popover-description {
    color: #c0c0d0;
    font-size: 0.875rem;
    line-height: 1.5;
}

.driver-popover.gex-tour .driver-popover-description kbd {
    background-color: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 3px;
    padding: 1px 5px;
    font-size: 0.8em;
    color: #e0e0e0;
}

.driver-popover.gex-tour .driver-popover-progress-text {
    color: #888;
    font-size: 0.75rem;
}

.driver-popover.gex-tour .driver-popover-navigation-btns button {
    border-radius: 6px;
    font-size: 0.8rem;
    font-weight: 500;
    padding: 6px 16px;
    text-shadow: none;
}

.driver-popover.gex-tour .driver-popover-next-btn,
.driver-popover.gex-tour .driver-popover-close-btn {
    background-color: #6c5ce7;
    color: #ffffff;
    border: none;
}

.driver-popover.gex-tour .driver-popover-next-btn:hover,
.driver-popover.gex-tour .driver-popover-close-btn:hover {
    background-color: #7c6cf7;
}

.driver-popover.gex-tour .driver-popover-prev-btn {
    background-color: transparent;
    color: #c0c0d0;
    border: 1px solid rgba(255, 255, 255, 0.15);
}

.driver-popover.gex-tour .driver-popover-prev-btn:hover {
    background-color: rgba(255, 255, 255, 0.05);
}

/* Dark theme arrows */
.driver-popover.gex-tour .driver-popover-arrow-side-left {
    border-left-color: #1e1e2e;
}
.driver-popover.gex-tour .driver-popover-arrow-side-right {
    border-right-color: #1e1e2e;
}
.driver-popover.gex-tour .driver-popover-arrow-side-top {
    border-top-color: #1e1e2e;
}
.driver-popover.gex-tour .driver-popover-arrow-side-bottom {
    border-bottom-color: #1e1e2e;
}

/* --- Light theme --- */
[data-bs-theme="light"] .driver-popover.gex-tour {
    background-color: #ffffff;
    color: #1a1a2e;
    border: 1px solid rgba(0, 0, 0, 0.1);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
}

[data-bs-theme="light"] .driver-popover.gex-tour .driver-popover-title {
    color: #1a1a2e;
}

[data-bs-theme="light"] .driver-popover.gex-tour .driver-popover-description {
    color: #4a4a5a;
}

[data-bs-theme="light"] .driver-popover.gex-tour .driver-popover-description kbd {
    background-color: rgba(0, 0, 0, 0.06);
    border: 1px solid rgba(0, 0, 0, 0.15);
    color: #1a1a2e;
}

[data-bs-theme="light"] .driver-popover.gex-tour .driver-popover-progress-text {
    color: #888;
}

[data-bs-theme="light"] .driver-popover.gex-tour .driver-popover-next-btn,
[data-bs-theme="light"] .driver-popover.gex-tour .driver-popover-close-btn {
    background-color: #6c5ce7;
    color: #ffffff;
}

[data-bs-theme="light"] .driver-popover.gex-tour .driver-popover-next-btn:hover,
[data-bs-theme="light"] .driver-popover.gex-tour .driver-popover-close-btn:hover {
    background-color: #5b4bd6;
}

[data-bs-theme="light"] .driver-popover.gex-tour .driver-popover-prev-btn {
    background-color: transparent;
    color: #4a4a5a;
    border: 1px solid rgba(0, 0, 0, 0.15);
}

[data-bs-theme="light"] .driver-popover.gex-tour .driver-popover-prev-btn:hover {
    background-color: rgba(0, 0, 0, 0.04);
}

/* Light theme arrows */
[data-bs-theme="light"] .driver-popover.gex-tour .driver-popover-arrow-side-left {
    border-left-color: #ffffff;
}
[data-bs-theme="light"] .driver-popover.gex-tour .driver-popover-arrow-side-right {
    border-right-color: #ffffff;
}
[data-bs-theme="light"] .driver-popover.gex-tour .driver-popover-arrow-side-top {
    border-top-color: #ffffff;
}
[data-bs-theme="light"] .driver-popover.gex-tour .driver-popover-arrow-side-bottom {
    border-bottom-color: #ffffff;
}