/* === Market Data Graph Plotter Styles === */

.market-data-plotter {
    min-height: 95vh;
    padding: 1rem;
    margin: -1rem -1rem 2rem -1rem;
    border-radius: 0;
}

.market-data-plotter .plotter-container {
    max-width: 95%;
    margin: 0 auto;
    background: white;
    border-radius: 15px;
    box-shadow: 0 20px 40px rgba(0,0,0,0.1);
    overflow: hidden;
    width: 98%;
}
        
.market-data-plotter .plotter-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 2rem;
    text-align: center;
}
        
.market-data-plotter .plotter-header h1 {
    font-size: 2.5em;
    margin-bottom: 0.5rem;
    font-weight: 700;
}
        
.market-data-plotter .plotter-header p {
    font-size: 1.2em;
    opacity: 0.9;
}
        
.market-data-plotter .controls {
    padding: 2rem;
    background: #f8f9fa;
    border-bottom: 2px solid #e9ecef;
}
        
.market-data-plotter .form-container {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.market-data-plotter .controls-row {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr auto;
    gap: 1rem;
    align-items: end;
}
        
.market-data-plotter .form-group {
    display: flex;
    flex-direction: column;
}

/* Compact row layout for form controls */
.market-data-plotter .controls-row-compact {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr 1.5fr;
    gap: 1rem;
    margin-bottom: 1rem;
    align-items: end;
    padding: 0 0.5rem;
}

/* Button row styling */
.market-data-plotter .button-row {
    text-align: center;
    margin-top: 1rem;
    padding: 0 0.5rem;
}

/* Controls section full width */
.market-data-plotter .controls-section {
    width: 100%;
    margin-bottom: 1rem;
}

/* Controls container - similar to indicators layout */
.market-data-plotter .controls-container {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr 1.5fr 1fr;
    gap: 1.2rem;
    padding: 1.2rem;
    background: #f8f9fa;
    border-radius: 8px;
    border: 1px solid #dee2e6;
    margin-bottom: 1rem;
    width: 100%;
    box-sizing: border-box;
}

.market-data-plotter .control-item {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.market-data-plotter .control-item label {
    font-size: 0.8rem;
    font-weight: 600;
    margin-bottom: 0.3rem;
    color: #495057;
    white-space: nowrap;
}

.market-data-plotter .control-input {
    padding: 0.6rem 0.75rem;
    font-size: 0.9rem;
    border: 1px solid #ced4da;
    border-radius: 6px;
    transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
    height: 40px;
    width: 100%;
    background-color: #fff;
    box-sizing: border-box;
}

.market-data-plotter .control-input:focus {
    border-color: #80bdff;
    outline: 0;
    box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25);
}

.market-data-plotter .control-button {
    height: 40px;
    padding: 0.6rem 1.2rem;
    font-size: 0.9rem;
    white-space: nowrap;
    margin-top: 0;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.market-data-plotter .control-item small {
    font-size: 0.7rem;
    color: #6c757d;
    margin-top: 0.2rem;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
        
.market-data-plotter .form-group-compact {
    display: flex;
    flex-direction: column;
    margin-bottom: 0;
    min-width: 0; /* Prevents overflow */
}
        
.market-data-plotter .form-group-compact label {
    font-size: 0.8rem;
    font-weight: 600;
    margin-bottom: 0.3rem;
    color: #495057;
}
        
.market-data-plotter .form-control-compact {
    padding: 0.5rem 0.75rem;
    font-size: 0.875rem;
    border: 1px solid #ced4da;
    border-radius: 6px;
    transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
    height: 38px;
    width: 100%;
    background-color: #fff;
    box-sizing: border-box;
}

.market-data-plotter .form-control-compact:focus {
    border-color: #80bdff;
    outline: 0;
    box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25);
}

.market-data-plotter .form-group-compact small {
    font-size: 0.75rem;
    color: #6c757d;
    margin-top: 0.25rem;
    line-height: 1.3;
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
        
.market-data-plotter .form-group label {
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: #495057;
}
        
.market-data-plotter .indicators-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 0.75rem;
    padding: 1rem;
    border: 2px solid #dee2e6;
    border-radius: 8px;
    background: white;
}
        
.market-data-plotter .indicator-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem;
    border-radius: 8px;
    border: 1px solid #e9ecef;
    background: #f8f9fa;
    transition: all 0.2s ease;
}
        
.market-data-plotter .indicator-item:hover {
    background: #e9ecef;
    border-color: #667eea;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.15);
}
        
.market-data-plotter .indicator-left {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex: 1;
}
        
.market-data-plotter .indicator-left input[type="checkbox"] {
    transform: scale(1.2);
    cursor: pointer;
    margin-right: 0.5rem;
    appearance: auto;
    -webkit-appearance: checkbox;
    -moz-appearance: checkbox;
}
        
.market-data-plotter .indicator-left label {
    font-weight: 600;
    color: #495057;
    cursor: pointer;
    text-transform: capitalize;
    font-size: 0.9rem;
    margin-bottom: 0;
}
        
.market-data-plotter .multiplier-input {
    width: 60px;
    padding: 0.25rem 0.5rem;
    font-size: 0.8rem;
    border: 1px solid #ced4da;
    border-radius: 4px;
    text-align: center;
    background: white;
}

.market-data-plotter select,
.market-data-plotter input[type="date"] {
    padding: 0.75rem;
    border: 2px solid #dee2e6;
    border-radius: 8px;
    font-size: 1rem;
    transition: border-color 0.3s;
}
        
.market-data-plotter select:focus,
.market-data-plotter input[type="date"]:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}
        
.market-data-plotter .btn {
    padding: 0.75rem 1.5rem;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

.market-data-plotter .btn-generate {
    padding: 0.75rem 2rem;
    font-size: 1rem;
    margin-top: 0;
    width: auto;
    display: inline-block;
    text-align: center;
    white-space: nowrap;
    min-width: 180px;
}
        
.market-data-plotter .btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 20px rgba(102, 126, 234, 0.3);
}

/* Disabled button state */
.market-data-plotter .btn:disabled {
    background: #adb5bd;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}
        
.market-data-plotter .chart-container {
    padding: 1.5rem;
    min-height: 800px;
}

.market-data-plotter .chart-wrapper {
    position: relative;
    height: 700px;
    background: white;
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: 0 5px 15px rgba(0,0,0,0.08);
    margin-bottom: 1rem;
    transition: all 0.3s ease;
}

.market-data-plotter .chart-wrapper.fullscreen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 9999;
    border-radius: 0;
    margin: 0;
    padding: 2rem;
    background: #1a1a1a;
}

.market-data-plotter .chart-controls {
    display: flex;
    gap: 0.5rem;
    justify-content: flex-end;
    margin-bottom: 1rem;
}

.market-data-plotter .chart-controls .btn {
    padding: 0.5rem 1rem;
    font-size: 0.85rem;
    border-radius: 6px;
    transition: all 0.2s ease;
    touch-action: manipulation;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.market-data-plotter .chart-controls .btn:hover {
    transform: translateY(-1px);
}

.market-data-plotter .no-data {
    text-align: center;
    padding: 5rem 1rem;
    color: #6c757d;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 90%;
}
        
.market-data-plotter .no-data h3 {
    font-size: 1.5em;
    margin: 1rem 0;
}

/* Tablet Styles */
@media (max-width: 1024px) {
    .market-data-plotter .plotter-container {
        width: 95%;
        max-width: 1200px;
    }
    
    .market-data-plotter .indicators-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.8rem;
    }
    
    .market-data-plotter .chart-wrapper {
        height: 450px;
        padding: 1.5rem;
    }
    
    .market-data-plotter .form-group {
        margin-bottom: 1rem;
    }
    
    .market-data-plotter .controls-container {
        grid-template-columns: 1fr 1fr 1fr;
        gap: 1rem;
    }
    
    .market-data-plotter .control-item:nth-child(4), /* Quick Time Range */
    .market-data-plotter .control-item:nth-child(5) { /* Generate Button */
        grid-column: span 1;
    }
    
    .market-data-plotter .control-item:nth-child(5) {
        grid-column: span 3;
    }
    
    .market-data-plotter .control-button {
        width: 100%;
    }
}

/* Mobile Large (Landscape phones) */
@media (max-width: 768px) {
    .market-data-plotter {
        padding: 0.5rem;
        margin: -0.5rem -0.5rem 1rem -0.5rem;
        min-height: 90vh;
    }
    
    .market-data-plotter .plotter-container {
        width: 100%;
        max-width: none;
        border-radius: 10px;
    }
    
    .market-data-plotter .controls {
        padding: 1rem;
    }
    
    .market-data-plotter .controls-row {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    .market-data-plotter .controls-row-compact {
        grid-template-columns: 1fr 1fr;
        gap: 0.8rem;
        padding: 0;
    }
    
    .market-data-plotter .controls-container {
        grid-template-columns: 1fr 1fr;
        gap: 1rem;
        padding: 1rem;
    }
    
    .market-data-plotter .control-item:nth-child(4) { /* Quick Time Range */
        grid-column: span 2;
    }
    
    .market-data-plotter .control-item:nth-child(5) { /* Generate Button */
        grid-column: span 2;
    }
    
    .market-data-plotter .control-input {
        height: 38px;
        font-size: 0.85rem;
    }
    
    .market-data-plotter .control-button {
        height: 38px;
        font-size: 0.85rem;
        padding: 0.5rem 1rem;
    }
    
    .market-data-plotter .btn-generate {
        font-size: 0.9rem;
        padding: 0.6rem 1.5rem;
        min-width: 150px;
    }
    
    .market-data-plotter .indicators-grid {
        grid-template-columns: 1fr;
        gap: 0.6rem;
    }
    
    .market-data-plotter .plotter-header h1 {
        font-size: 1.8em;
        margin-bottom: 1rem;
    }
    
    .market-data-plotter .chart-container {
        padding: 0.8rem;
        min-height: 500px;
    }
    
    .market-data-plotter .chart-wrapper {
        height: 400px;
        padding: 0.5rem;
    }
    
    .market-data-plotter .chart-controls {
        flex-direction: row; /* Stacked controls looked bad */
        flex-wrap: wrap;
        gap: 0.5rem;
    }
    
    .market-data-plotter .chart-controls .btn {
        width: auto;
        flex-grow: 1;
        padding: 0.6rem;
        font-size: 0.8rem;
    }
    
    .market-data-plotter .form-group label {
        font-size: 0.9rem;
        margin-bottom: 0.3rem;
    }
    
    .market-data-plotter .form-group input,
    .market-data-plotter .form-group select {
        font-size: 1rem;
        padding: 0.8rem;
    }
    
    .market-data-plotter .btn {
        padding: 0.8rem 1.5rem;
        font-size: 1rem;
    }
}

/* Mobile Small */
@media (max-width: 480px) {
    .market-data-plotter {
        padding: 0.3rem;
        margin: -0.3rem -0.3rem 1rem -0.3rem;
    }
    
    .market-data-plotter .plotter-container {
        border-radius: 8px;
    }
    
    .market-data-plotter .plotter-header {
        padding: 1rem;
    }
    
    .market-data-plotter .plotter-header h1 {
        font-size: 1.5em;
        margin-bottom: 0.8rem;
    }
    
    .market-data-plotter .plotter-header p {
        font-size: 0.9rem;
    }
    
    .market-data-plotter .controls {
        padding: 0.8rem;
    }
    
    .market-data-plotter .chart-container {
        padding: 0.5rem;
        min-height: 450px;
    }
    
    .market-data-plotter .chart-wrapper {
        height: 350px;
        padding: 0.3rem;
    }
    
    .market-data-plotter .chart-controls .btn {
        font-size: 0.8rem;
        padding: 0.7rem;
    }
    
    .market-data-plotter .form-group {
        margin-bottom: 0.8rem;
    }
    
    .market-data-plotter .controls-row-compact {
        grid-template-columns: 1fr;
        gap: 0.8rem;
        padding: 0;
    }
    
    .market-data-plotter .controls-container {
        grid-template-columns: 1fr;
        gap: 0.8rem;
        padding: 0.8rem;
    }
    
    .market-data-plotter .control-item:nth-child(n) {
        grid-column: span 1; /* Reset all spans */
    }
    
    .market-data-plotter .control-input {
        height: 38px;
        font-size: 0.85rem;
    }
    
    .market-data-plotter .control-button {
        height: 38px;
        font-size: 0.8rem;
        padding: 0.5rem 1rem;
    }
    
    .market-data-plotter .form-control-compact {
        height: 40px;
        font-size: 0.9rem;
        padding: 0.6rem 0.8rem;
    }
    
    .market-data-plotter .btn-generate {
        font-size: 0.85rem;
        padding: 0.6rem 1.2rem;
        min-width: 130px;
    }
    
    .market-data-plotter .form-group small {
        font-size: 0.75rem;
    }
    
    .market-data-plotter .indicator-item {
        padding: 0.8rem;
        font-size: 0.9rem;
    }
    
    .market-data-plotter .multiplier-input {
        width: 60px;
        font-size: 0.8rem;
    }
}

/* Canvas and form touch optimizations */
.market-data-plotter canvas {
    touch-action: pan-x; /* Allow horizontal panning for chart */
    user-select: none;
    -webkit-touch-callout: none;
}

.market-data-plotter input:not([type="checkbox"]), 
.market-data-plotter select, 
.market-data-plotter button {
    -webkit-appearance: none;
    appearance: none;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

/* Prevent zoom on double tap for form elements */
.market-data-plotter input[type="date"], 
.market-data-plotter select {
    font-size: 16px; /* Prevents iOS zoom */
}

/* ADD/REPLACE THIS IN YOUR market_graphs.css FILE */

/* Modal Styles */
.modal-backdrop {
    display: none; /* Hidden by default */
    position: fixed;
    inset: 0;
    background-color: rgba(0, 0, 0, 0.6);
    z-index: 1000;
    backdrop-filter: blur(4px);
}
.modal-content {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: white;
    padding: 25px;
    border-radius: 12px;
    width: 90%;
    max-width: 500px;
    z-index: 1001;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
}
.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #e5e7eb;
    padding-bottom: 15px;
    margin-bottom: 20px;
}
.modal-header h2 {
    font-size: 1.25rem;
    color: #1f2937;
}
.modal-close-btn {
    background: none;
    border: none;
    font-size: 1.75rem;
    cursor: pointer;
    color: #9ca3af;
    line-height: 1;
}

/* Stage 1: Primary Indicator Selection */
.primary-selection-item {
    display: flex;
    align-items: center;
    padding: 12px;
    border-radius: 8px;
    cursor: pointer;
    border: 1px solid #e5e7eb;
    margin-bottom: 10px;
    transition: all 0.2s ease;
}
.primary-selection-item:hover {
    background-color: #f9fafb;
    border-color: var(--primary-color);
}
.primary-selection-item input[type="radio"] {
    margin-right: 15px;
    transform: scale(1.2);
    accent-color: var(--primary-color);
}
.primary-selection-item label {
    font-weight: 600;
    cursor: pointer;
}

/* Stage 2: Suggestion Results */
.suggestion-item {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    align-items: center;
    padding: 12px 0;
    font-size: 0.9rem;
    border-bottom: 1px solid #f3f4f6;
}
.suggestion-item:last-child {
    border-bottom: none;
}
.suggestion-item strong {
    color: #111827;
}
.suggestion-item .value {
    font-weight: 600;
    color: var(--primary-color);
    font-family: monospace;
    font-size: 1rem;
}
.primary-indicator-display {
    background: #eff6ff;
    padding: 8px;
    border-radius: 6px;
    color: #1e40af;
    font-weight: 600;
}

.modal-footer {
    text-align: right;
    margin-top: 25px;
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}