/* Backtest Replay Styles */

.backtest-replay-container {
    padding: 2rem;
    max-width: 1400px;
    margin: 0 auto;
}

/* Header */
.backtest-header {
    text-align: center;
    margin-bottom: 3rem;
}

.backtest-title {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    margin-bottom: 0.5rem;
}

.backtest-title i {
    font-size: 2rem;
    color: #3b82f6;
}

.backtest-title h2 {
    font-size: 2rem;
    font-weight: 700;
    color: var(--text-primary, #1e293b);
    margin: 0;
}

.backtest-subtitle {
    color: var(--text-secondary, #64748b);
    font-size: 1rem;
}

/* Upload Section */
.backtest-upload-section {
    margin-bottom: 2rem;
}

.upload-card {
    background: var(--card-bg, white);
    border-radius: 16px;
    padding: 2rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.upload-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}

.upload-header i {
    font-size: 1.5rem;
    color: #8b5cf6;
}

.upload-header h3 {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary, #1e293b);
    margin: 0;
}

.upload-options {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
}

.upload-option {
    text-align: center;
}

.upload-label {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
    padding: 2rem 1rem;
    background: linear-gradient(135deg, #f0f9ff, #e0f2fe);
    border: 2px dashed #3b82f6;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.upload-label:hover {
    background: linear-gradient(135deg, #dbeafe, #bfdbfe);
    border-color: #2563eb;
    transform: translateY(-2px);
}

.upload-label i {
    font-size: 2rem;
    color: #3b82f6;
}

.upload-label span {
    font-weight: 600;
    color: #1e293b;
}

.api-connect-btn,
.sample-data-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
    width: 100%;
    padding: 2rem 1rem;
    background: linear-gradient(135deg, #f0fdf4, #dcfce7);
    border: 2px dashed #10b981;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-family: 'Vazirmatn', sans-serif;
}

.sample-data-btn {
    background: linear-gradient(135deg, #fef3c7, #fde68a);
    border-color: #f59e0b;
}

.api-connect-btn:hover,
.sample-data-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.api-connect-btn i,
.sample-data-btn i {
    font-size: 2rem;
    color: #10b981;
}

.sample-data-btn i {
    color: #f59e0b;
}

.api-connect-btn span,
.sample-data-btn span {
    font-weight: 600;
    color: #1e293b;
}

.upload-hint {
    font-size: 0.75rem;
    color: #64748b;
    margin-top: 0.5rem;
}

/* Chart Container */
.chart-container {
    background: var(--card-bg, white);
    border-radius: 16px;
    padding: 1.5rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.chart-controls-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    flex-wrap: wrap;
    gap: 1rem;
}

/* Timeframe Selector */
.timeframe-selector {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.tf-btn {
    padding: 0.5rem 1rem;
    background: #f1f5f9;
    border: 2px solid transparent;
    border-radius: 8px;
    font-weight: 600;
    color: #64748b;
    cursor: pointer;
    transition: all 0.3s ease;
    font-family: 'Vazirmatn', sans-serif;
}

.tf-btn:hover {
    background: #e2e8f0;
    color: #1e293b;
}

.tf-btn.active {
    background: linear-gradient(135deg, #3b82f6, #8b5cf6);
    color: white;
    border-color: #3b82f6;
}

/* Chart Info */
.chart-info {
    display: flex;
    gap: 1.5rem;
    font-size: 1.125rem;
    font-weight: 600;
}

#currentPrice {
    color: #10b981;
}

#currentTime {
    color: #64748b;
}

/* Chart Canvas */
#chartCanvas {
    width: 100%;
    height: 500px;
    margin-bottom: 1rem;
    border-radius: 12px;
    overflow: hidden;
}

/* Playback Controls */
.playback-controls {
    background: #f8fafc;
    border-radius: 12px;
    padding: 1.5rem;
    margin-bottom: 1rem;
}

.control-buttons {
    display: flex;
    justify-content: center;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.control-btn {
    width: 48px;
    height: 48px;
    background: white;
    border: 2px solid #e2e8f0;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    color: #64748b;
}

.control-btn:hover {
    background: #3b82f6;
    border-color: #3b82f6;
    color: white;
    transform: scale(1.1);
}

.control-btn.play-btn {
    width: 56px;
    height: 56px;
    background: linear-gradient(135deg, #3b82f6, #8b5cf6);
    border-color: #3b82f6;
    color: white;
}

.control-btn.play-btn:hover {
    transform: scale(1.15);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.4);
}

/* Progress Bar */
.progress-container {
    margin-bottom: 1rem;
}

#progressSlider {
    width: 100%;
    height: 8px;
    border-radius: 4px;
    background: #e2e8f0;
    outline: none;
    -webkit-appearance: none;
    margin-bottom: 0.5rem;
}

#progressSlider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: linear-gradient(135deg, #3b82f6, #8b5cf6);
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(59, 130, 246, 0.4);
}

#progressSlider::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: linear-gradient(135deg, #3b82f6, #8b5cf6);
    cursor: pointer;
    border: none;
    box-shadow: 0 2px 8px rgba(59, 130, 246, 0.4);
}

.progress-info {
    display: flex;
    justify-content: space-between;
    font-size: 0.875rem;
    color: #64748b;
}

/* Speed Control */
.speed-control {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
}

.speed-control label {
    font-weight: 600;
    color: #64748b;
}

.speed-control select {
    padding: 0.5rem 1rem;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    background: white;
    font-family: 'Vazirmatn', sans-serif;
    font-weight: 600;
    color: #1e293b;
    cursor: pointer;
}

/* Trading Panel */
.trading-panel {
    display: flex;
    gap: 1rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.trade-btn {
    flex: 1;
    min-width: 150px;
    padding: 1rem;
    border: none;
    border-radius: 12px;
    font-weight: 700;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    font-family: 'Vazirmatn', sans-serif;
}

.buy-btn {
    background: linear-gradient(135deg, #10b981, #059669);
    color: white;
}

.buy-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(16, 185, 129, 0.4);
}

.sell-btn {
    background: linear-gradient(135deg, #ef4444, #dc2626);
    color: white;
}

.sell-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(239, 68, 68, 0.4);
}

.close-btn {
    background: linear-gradient(135deg, #64748b, #475569);
    color: white;
}

.close-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(100, 116, 139, 0.4);
}

/* Stats Panel */
.stats-panel {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 1rem;
    background: #f8fafc;
    border-radius: 12px;
    padding: 1.5rem;
}

.stat-item {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.stat-label {
    font-size: 0.875rem;
    color: #64748b;
    font-weight: 500;
}

.stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: #1e293b;
}

.stat-value.success {
    color: #10b981;
}

.stat-value.danger {
    color: #ef4444;
}

/* API Dialog */
.api-dialog {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    padding: 1rem;
}

.api-dialog-content {
    background: white;
    border-radius: 16px;
    max-width: 500px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
}

.api-dialog-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem;
    border-bottom: 2px solid #e2e8f0;
}

.api-dialog-header h3 {
    font-size: 1.25rem;
    font-weight: 700;
    color: #1e293b;
    margin: 0;
}

.api-dialog-header button {
    width: 32px;
    height: 32px;
    border: none;
    background: #f1f5f9;
    border-radius: 50%;
    font-size: 1.5rem;
    color: #64748b;
    cursor: pointer;
    transition: all 0.3s ease;
}

.api-dialog-header button:hover {
    background: #ef4444;
    color: white;
}

.api-dialog-body {
    padding: 1.5rem;
}

.api-option {
    margin-bottom: 2rem;
}

.api-option:last-child {
    margin-bottom: 0;
}

.api-option h4 {
    font-size: 1rem;
    font-weight: 600;
    color: #1e293b;
    margin-bottom: 1rem;
}

.api-option input {
    width: 100%;
    padding: 0.75rem;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    margin-bottom: 0.75rem;
    font-family: 'Vazirmatn', sans-serif;
}

.api-option button {
    width: 100%;
    padding: 0.75rem;
    background: linear-gradient(135deg, #3b82f6, #8b5cf6);
    color: white;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    font-family: 'Vazirmatn', sans-serif;
}

.api-option button:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.4);
}

/* Dark Mode */
html[data-theme="dark"] .backtest-title h2,
html[data-theme="dark"] .upload-header h3,
html[data-theme="dark"] .upload-label span,
html[data-theme="dark"] .api-connect-btn span,
html[data-theme="dark"] .sample-data-btn span,
html[data-theme="dark"] .stat-value {
    color: #f1f5f9;
}

html[data-theme="dark"] .upload-card,
html[data-theme="dark"] .chart-container {
    background: rgba(30, 41, 59, 0.8);
}

html[data-theme="dark"] .upload-label {
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.1), rgba(59, 130, 246, 0.05));
}

html[data-theme="dark"] .api-connect-btn {
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.1), rgba(16, 185, 129, 0.05));
}

html[data-theme="dark"] .sample-data-btn {
    background: linear-gradient(135deg, rgba(245, 158, 11, 0.1), rgba(245, 158, 11, 0.05));
}

html[data-theme="dark"] .playback-controls,
html[data-theme="dark"] .stats-panel {
    background: rgba(15, 23, 42, 0.6);
}

html[data-theme="dark"] .control-btn {
    background: rgba(30, 41, 59, 0.8);
    border-color: rgba(148, 163, 184, 0.2);
}

html[data-theme="dark"] .tf-btn {
    background: rgba(30, 41, 59, 0.6);
}

html[data-theme="dark"] .api-dialog-content {
    background: #1e293b;
}

html[data-theme="dark"] .api-dialog-header {
    border-bottom-color: rgba(148, 163, 184, 0.2);
}

html[data-theme="dark"] .api-option h4 {
    color: #f1f5f9;
}

html[data-theme="dark"] .api-option input {
    background: rgba(15, 23, 42, 0.6);
    border-color: rgba(148, 163, 184, 0.2);
    color: #f1f5f9;
}

/* Responsive */
@media (max-width: 768px) {
    .backtest-replay-container {
        padding: 1rem;
    }

    .backtest-title h2 {
        font-size: 1.5rem;
    }

    .upload-options {
        grid-template-columns: 1fr;
    }

    #chartCanvas {
        height: 300px;
    }

    .chart-controls-top {
        flex-direction: column;
        align-items: stretch;
    }

    .timeframe-selector {
        justify-content: center;
    }

    .trading-panel {
        flex-direction: column;
    }

    .trade-btn {
        min-width: 100%;
    }

    .stats-panel {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Mode Selector */
.mode-selector {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
}

.mode-selector label {
    font-weight: 600;
    color: #cbd5e1;
}

.mode-selector select {
    padding: 6px 12px;
    background: #334155;
    color: #e2e8f0;
    border: 1px solid #475569;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
}

.mode-selector select:hover {
    background: #3f4b5f;
}

/* Chart Main Area with Sidebar */
.chart-main-area {
    display: flex;
    gap: 0;
    background: #1e293b;
    border-radius: 12px;
    overflow: hidden;
    margin-bottom: 12px;
}

/* Drawing Tools Sidebar (TradingView style) */
.drawing-tools-sidebar {
    width: 50px;
    background: #0f172a;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 8px 0;
    gap: 4px;
    border-right: 1px solid #334155;
}

.sidebar-tool-btn {
    width: 40px;
    height: 40px;
    background: transparent;
    color: #94a3b8;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    position: relative;
}

.sidebar-tool-btn:hover {
    background: #1e293b;
    color: #e2e8f0;
}

.sidebar-tool-btn.active {
    background: #3b82f6;
    color: white;
    box-shadow: 0 0 10px rgba(59, 130, 246, 0.5);
}

.sidebar-tool-btn i {
    font-size: 18px;
}

.sidebar-divider {
    width: 30px;
    height: 1px;
    background: #334155;
    margin: 8px 0;
}

/* Old Drawing Tools - Hide */
.drawing-tools {
    display: none;
}

/* Disabled state for forward mode */
button:disabled {
    opacity: 0.5 !important;
    cursor: not-allowed !important;
}

input[type="range"]:disabled {
    opacity: 0.5 !important;
    cursor: not-allowed !important;
}

/* Chart Engine Selector */
.chart-engine-selector {
    padding: 16px;
    background: rgba(59, 130, 246, 0.1);
    border: 1px solid rgba(59, 130, 246, 0.3);
    border-radius: 12px;
    margin-bottom: 16px;
}

.chart-engine-selector label {
    display: block;
    font-weight: 600;
    color: #e2e8f0;
    margin-bottom: 8px;
}

.chart-engine-selector select {
    width: 100%;
    padding: 10px 14px;
    background: #1e293b;
    color: #e2e8f0;
    border: 1px solid #475569;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
}

.chart-engine-selector select:hover {
    border-color: #3b82f6;
}

.chart-engine-selector select:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.engine-hint {
    margin-top: 8px;
    font-size: 13px;
    color: #94a3b8;
    display: flex;
    align-items: center;
    gap: 6px;
}

/* TradingView Container */
#chartCanvas {
    min-height: 500px;
    background: #1e293b;
}
