/**
 * Trading Pages Unified CSS
 * 
 * Consolidated styles from:
 * - ai-option-chain.blade.php
 * - sr.blade.php
 * - sr2.blade.php
 * - oi-analysis.blade.php
 * - deep-analysis.blade.php
 * 
 * This file contains all CSS styles used across the trading platform pages.
 */

/* Import Google Fonts */
@import url("https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Poppins:wght@400;500;600;700&display=swap");

/* ========================================
   CSS VARIABLES (ROOT)
   ======================================== */

/* Enhanced Root Variables */
:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --primary-light: #3b82f6;
    --success: #10b981;
    --success-dark: #059669;
    --success-light: #34d399;
    --warning: #f59e0b;
    --warning-dark: #d97706;
    --danger: #dc2626; /* Darkened from #ef4444 */
    --danger-dark: #991b1b; /* Darkened from #dc2626 */
    --dark: #1f2937;
    --dark-dark: #111827;
    --secondary: #6b7280;
    --secondary-dark: #4b5563;
    --light: #f9fafb;
    --light-dark: #e5e7eb;
    --border-color: #d1d5db;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1),
        0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1),
        0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --toolbar-height: 42px;
    --toolbar-radius: 10px;
    --toolbar-gap: 12px;
    --toolbar-padding: 16px 24px;
}

/* ========================================
   GLOBAL / BODY STYLES
   ======================================== */

/* Global Improvements */
body {
    background-color: #f3f4f6;
    font-family: 'Poppins', system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    font-size: 14px;
    line-height: 18px !important;
    color: var(--dark);
    height: 100vh;
}

h1, h2, h3, h4, h5, h6, .navbar-brand, .btn, th {
    font-family: 'Poppins', system-ui, -apple-system, sans-serif;
}

/* Alpine.js cloak - hide elements until Alpine initializes */
[x-cloak] {
    display: none !important;
}

/* ========================================
   TABLE STYLES
   ======================================== */

/* Enhanced Table Styling */
.table {
    background: white;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: var(--shadow);
    margin-bottom: 1.5rem;
    font-size: 11.5px;
    white-space: nowrap;
    font-weight: 700;
}

.table thead th {
    text-align: center;
    font-weight: 600;
    vertical-align: middle;
    padding: 0.5rem 0.4rem;
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 0.025em;
    border-bottom: 2px solid var(--border-color);
    line-height: 1.2;
}

.table tbody td {
    padding: 0.4rem 0.4rem;
    vertical-align: middle;
    font-size: 0.875rem;
    line-height: 1.3;
    text-align: center;
}

.table th,
.table td {
    padding: 2.5px;
}

.table-bordered {
    border: 1px solid var(--border-color);
}

.table-hover tbody tr:hover {
    background-color: rgba(37, 99, 235, 0.05);
    transition: background-color 0.15s ease;
}

/* ========================================
   TRADING CARD HEADER STYLES (Unified Toolbar)
   ======================================== */

.trading-card-header {
    color: rgb(14, 14, 14);
    padding: var(--toolbar-padding);
    border-bottom: none;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: var(--toolbar-gap);
    flex-wrap: wrap;
}

.trading-card-header .card-title {
    color: #ffffff;
    font-weight: 600;
    font-size: 18px;
    margin: 0;
    margin-right: 8px;
}

/* Unified Form Controls */
.trading-card-header .form-select,
.trading-card-header .form-control {
    background-color: #ffffff;
    color: #000000;
    border: 1px solid #dfe3e8;
    border-radius: var(--toolbar-radius);
    height: var(--toolbar-height);
    padding: 10px 14px;
    font-size: 14px;
    font-weight: 500;
    min-width: 100px;
    box-shadow: none;
}

.trading-card-header .form-select:focus,
.trading-card-header .form-control:focus {
    border-color: #2869ff;
    outline: none;
    box-shadow: none;
}

/* Loading Badge - can use existing .form-control styles */
.trading-card-header .loading-badge,
.trading-card-header .form-control.d-flex {
    background: #ffffff;
    padding: 10px 14px;
    border-radius: var(--toolbar-radius);
    border: 1px solid #dfe3e8;
    height: var(--toolbar-height);
    gap: 8px;
    display: flex;
    align-items: center;
}

/* S/R Version Switcher (Segmented Control) */
.trading-card-header .version-switcher {
    display: flex;
    align-items: center;
    gap: 8px;
}

.trading-card-header .version-switcher .btn-group {
    background: #dbe7ff;
    border-radius: var(--toolbar-radius);
    overflow: hidden;
    height: var(--toolbar-height);
    display: flex;
}

/* Version Switcher Button Content */
.trading-card-header .version-switcher .btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

/* Hide spinner by default */
.trading-card-header .version-switcher .btn-spinner {
    display: none;
    width: 14px;
    height: 14px;
    border-width: 2px;
}

/* Show spinner only in the CLICKED button */
.trading-card-header .version-switcher .btn.clicking .btn-spinner {
    display: inline-block;
}

.trading-card-header .btn-group {
    height: 100%;
    display: flex;
}

.trading-card-header .btn-check + .btn {
    background: #dbe7ff;
    color: #2869ff;
    border: none;
    border-radius: 0;
    height: var(--toolbar-height);
    padding: 0 18px;
    font-weight: 600;
    font-size: 13px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.trading-card-header .btn-check:checked + .btn {
    background: #2869ff;
    color: #ffffff;
}

.trading-card-header .btn-check + .btn:first-of-type {
    border-radius: var(--toolbar-radius) 0 0 var(--toolbar-radius);
}

.trading-card-header .btn-check + .btn:last-of-type {
    border-radius: 0 var(--toolbar-radius) var(--toolbar-radius) 0;
}

/* Unified Action Button Styles */
.trading-card-header .btn,
.trading-card-header .action-btn,
.trading-card-header .zone-toggle-btn {
    height: var(--toolbar-height);
    border-radius: var(--toolbar-radius);
    font-weight: 600;
    font-size: 13px;
    padding: 0 18px;
    border: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.15s ease;
    white-space: nowrap;
    box-shadow: none;
}

/* Read Me Button */
.trading-card-header .btn-danger {
    background: #e53935;
    color: #ffffff;
}

.trading-card-header .btn-danger:hover {
    background: #c62828;
}

/* Zone Toggle Group (Human/AI) */
.trading-card-header .zone-toggle-group {
    display: flex;
    gap: 4px;
    border: none;
    box-shadow: none;
    overflow: visible;
    border-radius: 0;
}

.trading-card-header .zone-toggle-btn {
    background: #009688;
    color: #ffffff;
}

.trading-card-header .zone-toggle-btn#aiZoneBtn {
    background: #43a047;
}

.trading-card-header .zone-toggle-btn:hover {
    filter: brightness(1.1);
}

.trading-card-header .zone-toggle-btn.active {
    box-shadow: none;
}

/* Action Buttons Group */
.trading-card-header .action-buttons-group {
    display: flex;
    gap: 4px;
}

.trading-card-header .action-btn {
    color: #ffffff;
}

.trading-card-header .btn-live {
    background: #4caf50;
}

.trading-card-header .btn-lock {
    background: #263238;
}

.trading-card-header .btn-live-lock {
    background: #ff9800;
}

.trading-card-header .btn-max {
    background: #d32f2f;
}

.trading-card-header .btn-weekly {
    background: #0288d1;
}

.trading-card-header .action-btn:hover {
    transform: none;
    filter: brightness(1.1);
    box-shadow: none;
}

.trading-card-header .action-btn.active {
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.2);
}

/* Status Indicator Dots */
.trading-card-header .status-indicator {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-right: 6px;
    background-color: rgba(255, 255, 255, 0.4);
}

.trading-card-header .active .status-indicator {
    background-color: #76ff03;
    box-shadow: 0 0 6px #76ff03;
    animation: pulseGreen 1.5s ease-in-out infinite;
}

@keyframes pulseGreen {
    0%,
    100% {
        opacity: 1;
        transform: scale(1);
    }
    50% {
        opacity: 0.7;
        transform: scale(1.15);
    }
}

/* ========================================
   OI ANALYSIS SPECIFIC TABLE STYLES  
   ======================================== */

/* Specific styles for oi-analysis page */
.oi-analysis-table {
    font-size: 15.5px;
    white-space: nowrap;
    font-weight: 700;
    border-collapse: separate;
    border-spacing: 0;
}

.oi-analysis-table th,
.oi-analysis-table td {
    padding: 8.5px;
}

.oi-analysis-table td {
    background-color: #f2f2f2;
}

.oi-analysis-table th {
    background-color: #073763 !important;
    color: white !important;
    text-align: center;
    border: 1px solid #073763 !important;
    position: sticky;
    top: 0;
    z-index: 10;
}

/* OI Table - Fixed Header with Scrollable Body */
.oi-table-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* Fixed Header */
.oi-sticky-header {
    display: table-header-group;
}

.oi-sticky-header th {
    position: sticky;
    top: 0;
    z-index: 100;
    background-color: #073763 !important;
    color: white !important;
    border-bottom: 2px solid #052c4f !important;
}

/* Scrollable Body */
.oi-analysis-table tbody {
    display: block;
    /* max-height: 80vh; */
    overflow-y: auto;
    overflow-x: hidden;
}

.oi-analysis-table thead,
.oi-analysis-table tbody tr {
    display: table;
    width: 100%;
    table-layout: fixed;
}

/* ========================================
   SR ANALYSIS TABLE STYLES
   ======================================== */

/* SR Table Wrapper */
.sr-table-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.sr-analysis-table {
    border-collapse: separate;
    border-spacing: 0;
    font-size: 13px;
    white-space: nowrap;
}

/* Fixed Header for SR Tables */
.sr-sticky-header {
    display: table-header-group;
}

.sr-sticky-header th {
    position: sticky;
    top: 0;
    z-index: 100;
}

/* Scrollable Body for SR Tables */
.sr-analysis-table tbody {
    display: block;
    /* max-height: 80vh; */
    overflow-y: auto;
    overflow-x: hidden;
}

.sr-analysis-table thead,
.sr-analysis-table tbody tr {
    display: table;
    width: 100%;
    table-layout: fixed;
}

/* ========================================
   SCROLLBAR UTILITIES
   ======================================== */

/* Hide scrollbars for SR and OI analysis tables */
.hide-scrollbar::-webkit-scrollbar,
.hide-scrollbar .sr-analysis-table tbody::-webkit-scrollbar,
.sr-analysis-table tbody::-webkit-scrollbar,
.oi-analysis-table tbody::-webkit-scrollbar {
    display: none;
}

.hide-scrollbar,
.hide-scrollbar .sr-analysis-table tbody,
.sr-analysis-table tbody,
.oi-analysis-table tbody {
    -ms-overflow-style: none; /* IE and Edge */
    scrollbar-width: none; /* Firefox */
}

/* ========================================
   AI OPTION CHAIN SPECIFIC STYLES
   ======================================== */

/* Custom blue theme for ai-option-chain */
.custom-blue,
.ai-option-chain th {
    background-color: #073763 !important;
    color: white !important;
    border: 1px solid #073763 !important;
    font-weight: 500 !important; /* Reduced from bold default */
}

.ai-option-chain th {
    text-align: center;
}

/* ========================================
   STICKY POSITIONING
   ======================================== */

.sticky-top,
thead th {
    position: sticky;
    top: 0;
    z-index: 10;
}

.sticky-col {
    position: sticky;
    left: 0;
    z-index: 2;
    font-weight: 500; /* Reduced from 600 */
}

.table tbody .sticky-col {
    z-index: 1;
}

/* Force normal weight on all table cells */
.table td, .table th {
    font-weight: 400 !important;
}

/* Exception for headers to be readable */
.table thead th {
    font-weight: 500 !important;
}

/* ========================================
   BACKGROUND COLORS - GRADIENTS
   ======================================== */

.bg-success {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%) !important;
    color: white !important;
}

.bg-danger {
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%) !important;
    color: white !important;
}

.bg-warning {
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%) !important;
    color: white !important;
}

.bg-th > th {
    background: linear-gradient(135deg, #1e3a8a 0%, #1e40af 100%) !important;
    color: white !important;
    font-weight: 600;
}

/* ========================================
   BACKGROUND COLORS - SUBTLE
   ======================================== */

.bg-success-subtle {
    background-color: #d1fae5 !important;
    color: #065f46 !important;
}

.bg-danger-subtle {
    background-color: #fee2e2 !important;
    color: #991b1b !important;
}

/* ========================================
   UNIFIED THEME MAPPINGS & UTILITIES
   ======================================== */

.bg-primary-gradient {
    background: linear-gradient(135deg, #1e3a8a 0%, #1e40af 100%) !important;
    color: white !important;
}

.bg-danger-dark {
    background: linear-gradient(
        135deg,
        var(--danger-dark) 0%,
        #7f1d1d 100%
    ) !important;
    color: white !important;
}

.text-primary {
    color: var(--primary) !important;
}
.text-warning {
    color: var(--warning) !important;
}
.text-success {
    color: var(--success) !important;
}
.text-danger {
    color: var(--danger) !important;
}

/* ========================================
   SPECIAL CELL CLASSES
   ======================================== */

.resistance {
    background-color: #ff4d4d;
    color: white;
}

.support {
    background-color: #4caf50;
    color: white;
}

.spot-price {
    background-color: #f4f4f4;
    font-weight: bold;
    text-align: center;
}

.netvalue {
    background: #c7bfe6 !important;
    color: black !important;
}

.midvalue {
    background: #ffadc9 !important;
    color: black !important;
}

.percentage {
    display: block;
    font-size: 10px;
}

/* ========================================
   BUTTON STYLES
   ======================================== */

/* Enhanced Buttons */
.btn {
    border-radius: 6px;
    padding: 0.5rem 1rem;
    font-weight: 600;
    font-size: 0.875rem;
    transition: all 0.2s ease;
    border: none;
    box-shadow: var(--shadow-sm);
}

.btn:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.btn:active {
    transform: translateY(0);
}

.btn-outline-dark {
    border: 2px solid var(--dark);
    color: var(--dark);
    background: white;
}

.btn-outline-dark:hover,
.btn-outline-dark.active,
.btn.active {
    background: var(--dark);
    color: white;
}

.btn.active {
    background-color: #212529;
    border-color: #212529;
}

button.btn.btn-outline-dark,
select.form-control.w-auto {
    border: 2px solid;
}

.toggle-btn-group .btn {
    padding: 2px 8px;
    font-size: 12px;
    margin: 2px;
}

/* ========================================
   HEADER COLUMN STYLES
   ======================================== */

.header-col {
    text-align: center;
}

.header-col h6,
.header-col p {
    margin-bottom: 0.2rem;
}

/* ========================================
   MODAL STYLES
   ======================================== */

/* Modal styling */
.modal-dialog.modal-custom {
    max-width: 90%;
    height: 90vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-body {
    height: calc(100% - 56px);
}

/* ========================================
   CHART SPECIFIC STYLES
   ======================================== */

.canvasjs-navigator-panel {
    display: none;
}

/* ========================================
   CONTAINER STYLES
   ======================================== */

/* Auto fit content */
.table-container {
    flex-wrap: wrap;
    justify-content: center;
    display: flex;
    overflow-x: auto;
    width: 100%;
}

/* Overflow container */
.overflow-x-auto,
.table-container-wrapper {
    background: white;
    border-radius: 10px;
    box-shadow: var(--shadow-md);
    padding: 0.5rem;
}

/* ========================================
   RESPONSIVE STYLES
   ======================================== */

/* Responsive - Mobile for Trading Card Header */
@media (max-width: 768px) {
    .trading-card-header {
        flex-direction: column;
        align-items: flex-start;
        padding: 12px 16px;
        gap: 10px;
    }

    .trading-card-header .d-flex {
        flex-wrap: wrap;
        gap: 10px;
    }

    .trading-card-header .zone-toggle-group,
    .trading-card-header .action-buttons-group {
        flex-wrap: wrap;
    }
}

/* ----------------------------------------
   TABLET OPTIMIZATION (768px - 1100px)
   ---------------------------------------- */
@media (max-width: 1100px) and (min-width: 769px) {
    .table {
        font-size: 10px;
    }

    .table th,
    .table td {
        padding: 2px 3px;
    }

    .header-col h6 {
        font-size: 11px;
    }

    .header-col p {
        font-size: 9px;
    }

    .percentage {
        font-size: 8px;
    }
}

/* ----------------------------------------
   MOBILE OPTIMIZATION (< 768px)
   ---------------------------------------- */
@media (max-width: 768px) {
    body {
        font-size: 11px;
    }

    .header-col {
        padding: 0.3rem !important;
    }

    .header-col h6 {
        font-size: 10px;
    }

    .header-col p {
        font-size: 8px;
    }

    /* Option Chain Table - Mobile Scroll Container */
    .table-container,
    .overflow-x-auto {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        padding: 0;
        margin: 0 -0.5rem;
        width: calc(100% + 1rem);
    }

    /* Table Compact Mode */
    .table {
        font-size: 9px;
        min-width: 900px; /* Force horizontal scroll */
    }

    .table th,
    .table td {
        padding: 2px 2px;
        white-space: nowrap;
    }

    .table thead th {
        font-size: 8px;
        padding: 3px 2px;
        letter-spacing: 0;
    }

    .table tbody td {
        font-size: 9px;
        line-height: 1.1;
    }

    .percentage {
        font-size: 7px;
        margin-top: 1px;
    }

    /* Sticky Strike Column - Center */
    .table th:nth-child(11),
    .table td:nth-child(11) {
        position: sticky;
        left: 0;
        z-index: 5;
        background: #eef2f6;
        box-shadow: 2px 0 4px rgba(0, 0, 0, 0.1);
    }

    .table thead th:nth-child(11) {
        z-index: 15;
        background: #073763;
    }

    /* Scroll Indicator Fade */
    .table-container::after {
        content: "";
        position: absolute;
        right: 0;
        top: 0;
        bottom: 0;
        width: 20px;
        background: linear-gradient(
            to left,
            rgba(255, 255, 255, 0.9),
            transparent
        );
        pointer-events: none;
    }

    /* Button Adjustments */
    .btn {
        padding: 0.3rem 0.6rem;
        font-size: 0.75rem;
    }

    .toggle-btn-group .btn {
        padding: 2px 5px;
        font-size: 10px;
        margin: 1px;
    }

    /* OI Analysis Table - Mobile Optimizations */
    .oi-analysis-table {
        font-size: 10px;
        min-width: 800px;
    }

    .oi-analysis-table th,
    .oi-analysis-table td {
        padding: 4px 3px;
    }

    /* Sticky Time Column for OI Analysis */
    .oi-analysis-table th:first-child,
    .oi-analysis-table td:first-child {
        position: sticky;
        left: 0;
        z-index: 5;
        background: #eef2f6;
        box-shadow: 2px 0 4px rgba(0, 0, 0, 0.1);
    }

    .oi-analysis-table thead th:first-child {
        z-index: 15;
        background: #073763;
    }

    /* OI Plus column image */
    .oi-analysis-table td:last-child {
        width: 60px;
        height: 35px;
        padding: 0;
    }

    .oi-analysis-table td:last-child img {
        width: 100%;
        height: 100%;
    }
}


/* ========================================
   CHART BACKTESTER SPECIFIC STYLES
   ======================================== */

/* Enhanced Chart Controls */
.chart-controls-wrapper {
    background: white;
    border-radius: 10px;
    box-shadow: var(--shadow-md);
    padding: 12px;
    margin-bottom: 1rem;
}

/* Zone Buttons Gradients */
.human-zone {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%) !important;
    color: white !important;
    transition: all 0.2s ease;
}

.ai-zone {
    background: linear-gradient(135deg, #8b5cf6 0%, #7c3aed 100%) !important;
    color: white !important;
    transition: all 0.2s ease;
}

/* Action Button Gradients */
.btn-live {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%) !important;
}

.btn-lock {
    background: linear-gradient(135deg, #1f2937 0%, #111827 100%) !important;
}

.btn-live-lock {
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%) !important;
}

.btn-max {
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%) !important;
}

.btn-weekly {
    background: linear-gradient(135deg, #6b7280 0%, #4b5563 100%) !important;
}

/* Status Indicators for Chart Buttons */
.status-indicator {
    display: inline-block;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    margin-right: 5px;
    background-color: rgba(255, 255, 255, 0.6);
    transition: all 0.2s ease;
}

.active .status-indicator {
    background-color: #ef4444;
    box-shadow: 0 0 8px #ef4444, 0 0 12px rgba(239, 68, 68, 0.6);
    animation: blinkRed 1.5s ease-in-out infinite;
}

@keyframes blinkRed {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.6; transform: scale(1.1); }
}

/* Chart Container */
#chartContainer {
    width: 100%;
    border-radius: 8px;
    overflow: hidden;
    position: relative;
    /* Height is handled by inline style or JS, but default minimum helps */
    min-height: 400px; 
}

/* ========================================
   RESPONSIVE DESIGN FOR CHART BACKTESTER
   ======================================== */

/* Large Desktop (> 1400px) */
@media (min-width: 1400px) {
    .trading-card-header {
        padding: 1rem 2rem;
    }
    
    .action-btn {
        padding: 12px 20px;
        font-size: 0.95rem;
    }
}

/* Desktop (992px - 1400px) */
@media (max-width: 1400px) {
    .trading-card-header .d-flex.gap-3 {
        gap: 0.75rem !important;
    }
    
    .action-buttons-group {
        min-width: auto;
    }
}

/* Tablet / Small Desktop (768px - 991px) */
@media (max-width: 991px) {
    .trading-card-header {
        flex-direction: column;
        align-items: stretch !important;
        gap: 1rem !important;
    }
    
    .trading-card-header .card-title {
        margin-bottom: 0.5rem;
        text-align: center;
    }
    
    .trading-card-header .d-flex.gap-3 {
        flex-wrap: wrap;
        justify-content: center;
        width: 100%;
    }
    
    .version-switcher .btn-group,
    .zone-toggle-group,
    .action-buttons-group {
        flex: 1 1 auto;
        justify-content: center;
    }
    
    .action-buttons-group {
        display: grid;
        grid-template-columns: repeat(3, 1fr);
        gap: 8px;
        width: 100%;
    }
    
    .action-btn {
        width: 100%;
        margin: 0;
    }
}

/* Mobile (< 768px) */
@media (max-width: 768px) {
    .trading-card-header {
        padding: 0.75rem;
    }

    /* Stack everything nicely */
    .trading-card-header .d-flex.gap-3 {
        gap: 0.75rem !important;
    }

    /* Full width selects */
    .trading-card-header .form-select {
        width: 100%;
        flex: 1 1 100%;
    }

    /* Buttons groups 100% width */
    .version-switcher,
    .version-switcher .btn-group {
        width: 100%;
    }
    
    .version-switcher .btn {
        flex: 1;
    }

    /* Action buttons grid for mobile */
    .action-buttons-group {
        grid-template-columns: repeat(2, 1fr); /* 2 columns for buttons */
    }
    
    .action-btn {
        padding: 10px;
        font-size: 0.8rem;
    }
    
    /* Last odd button spans full width if needed, or keep 2x2 grid */
    .action-btn:last-child {
        grid-column: span 2; /* Make the last button (Weekly) full width if odd count */
    }
    
    #chartContainer {
        height: 60vh !important; /* Adjust chart height for mobile */
    }
}

/* Small Mobile (< 480px) */
@media (max-width: 480px) {
    .action-buttons-group {
        gap: 5px;
    }

    .action-btn {
        padding: 8px;
        font-size: 0.75rem;
    }
    
    .zone-toggle-btn {
        padding: 8px 12px;
        font-size: 0.75rem;
    }
}

/* ========================================
   CHART SETTINGS MODAL STYLES
   ======================================== */

/* Chart Settings Modal */
.chart-settings-modal {
    position: fixed;
    top: 220px;
    left: 20px;
    width: 220px;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.15);
    z-index: 1050;
    font-size: 13px;
    transition: opacity 0.2s ease, transform 0.2s ease;
    border: 1px solid #e0e0e0;
}

.chart-settings-modal.hidden {
    opacity: 0;
    transform: translateX(-10px);
    pointer-events: none;
}

.settings-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    background: black;
    color: #fff;
    border-radius: 8px 8px 0 0;
    cursor: move;
    user-select: none;
}

.settings-modal-title {
    font-weight: 600;
    font-size: 13px;
}

.settings-modal-close {
    background: none;
    border: none;
    color: #fff;
    cursor: pointer;
    padding: 0;
    font-size: 14px;
    opacity: 0.8;
    transition: opacity 0.2s;
}

.settings-modal-close:hover {
    opacity: 1;
}

.settings-modal-body {
    padding: 10px 12px;
    max-height: calc(100vh - 200px);
    overflow-y: auto;
}

.settings-group {
    margin-bottom: 10px;
}

.settings-group:last-child {
    margin-bottom: 0;
}

.settings-label {
    display: block;
    font-size: 11px;
    font-weight: 600;
    color: #666;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}

.settings-group .form-select {
    font-size: 12px;
    padding: 4px 8px;
}

.settings-group .btn-group {
    width: 100%;
}

.settings-group .btn {
    font-size: 11px;
    padding: 4px 8px;
}

.settings-group .zone-toggle-btn {
    font-size: 11px;
    padding: 4px 8px;
}

.action-buttons-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 4px;
}

.action-buttons-grid .action-btn {
    font-size: 10px;
    padding: 4px 6px;
    white-space: nowrap;
}

/* Settings Toggle Button Fixed on Left */
#settingsToggleBtn {
    position: fixed;
    left: 8px;
    top: 50%;
    transform: translateY(-50%);
    z-index: 1049;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    border: none;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    font-size: 12px;
}

#settingsToggleBtn:hover {
    transform: translateY(-50%) scale(1.1);
    box-shadow: 0 3px 12px rgba(0,0,0,0.3);
}

#settingsToggleBtn.modal-open {
    background: #dc3545;
}

/* ========================================
   SETTINGS MODAL BUTTON STYLES
   (Standalone styles for buttons inside modal)
   ======================================== */

/* Zone Toggle Buttons in Settings Modal */
.chart-settings-modal .zone-toggle-btn {
    border: 1px solid #ddd;
    border-radius: 6px;
    padding: 6px 12px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.chart-settings-modal .zone-toggle-btn#humanZoneBtn {
    background: #009688;
    color: #fff;
    border-color: #009688;
}

.chart-settings-modal .zone-toggle-btn#aiZoneBtn {
    background: #43a047;
    color: #fff;
    border-color: #43a047;
}

.chart-settings-modal .zone-toggle-btn.active {
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.2);
}

/* Action Buttons in Settings Modal */
.chart-settings-modal .action-btn {
    border: none;
    border-radius: 4px;
    padding: 6px 8px;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #fff;
}

.chart-settings-modal .btn-live {
    background: #4caf50;
}

.chart-settings-modal .btn-lock {
    background: #263238;
}

.chart-settings-modal .btn-live-lock {
    background: #ff9800;
}

.chart-settings-modal .btn-max {
    background: #d32f2f;
}

.chart-settings-modal .btn-weekly {
    background: #0288d1;
}

.chart-settings-modal .action-btn:hover {
    filter: brightness(1.1);
}

.chart-settings-modal .action-btn.active {
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.2);
}

/* Status indicator in modal buttons */
.chart-settings-modal .status-indicator {
    display: inline-block;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    margin-right: 4px;
    background-color: rgba(255, 255, 255, 0.4);
}

.chart-settings-modal .active .status-indicator {
    background-color: #76ff03;
    box-shadow: 0 0 4px #76ff03;
}
