/* Enhanced Replay Panel & Backtesting Styles */
.replay-panel {
    padding: 20px;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    border-radius: 12px;
    color: white;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

.replay-header {
    text-align: center;
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 2px solid rgba(255, 255, 255, 0.1);
}

.replay-header h2 {
    margin: 0 0 10px 0;
    font-size: 2.2rem;
    font-weight: 700;
    background: linear-gradient(45deg, #22c55e, #3b82f6);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.replay-header .subtitle {
    margin: 0 0 20px 0;
    color: rgba(255, 255, 255, 0.7);
    font-size: 1.1rem;
    font-weight: 400;
}

/* Mode Selector */
.mode-selector {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin-top: 20px;
}

.mode-btn {
    padding: 12px 24px;
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-radius: 25px;
    background: rgba(255, 255, 255, 0.05);
    color: rgba(255, 255, 255, 0.7);
    font-weight: 600;
    transition: all 0.3s ease;
}

.mode-btn.active {
    background: linear-gradient(45deg, #22c55e, #16a34a);
    border-color: #22c55e;
    color: white;
    transform: scale(1.05);
}

.mode-btn:hover:not(.active) {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.4);
    color: white;
}

/* Mode Sections */
.mode-section {
    margin-top: 30px;
}

/* Backtest Configuration */
.backtest-config {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 10px;
    padding: 25px;
    margin-bottom: 25px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.backtest-config h3 {
    margin: 0 0 25px 0;
    font-size: 1.4rem;
    color: #22c55e;
    display: flex;
    align-items: center;
    gap: 10px;
}

.config-section {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.config-row {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    align-items: end;
}

.config-group, .param-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-width: 180px;
    flex: 1;
}

.config-group label, .param-group label {
    font-size: 0.9rem;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.8);
}

.strategy-params {
    background: rgba(255, 255, 255, 0.03);
    border-radius: 8px;
    padding: 15px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    margin-top: 10px;
}

.config-actions {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    margin-top: 20px;
}

/* Backtest Progress */
.backtest-progress {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 10px;
    padding: 25px;
    margin-bottom: 25px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.progress-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.progress-header h4 {
    margin: 0;
    color: #3b82f6;
    font-size: 1.2rem;
}

.progress-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 10px;
    font-size: 0.9rem;
    color: rgba(255, 255, 255, 0.7);
}

/* Backtest Results */
.backtest-results {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 10px;
    padding: 25px;
    margin-bottom: 25px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.backtest-results h3 {
    margin: 0 0 25px 0;
    font-size: 1.4rem;
    color: #22c55e;
    display: flex;
    align-items: center;
    gap: 10px;
}

.results-summary {
    margin-bottom: 30px;
}

.result-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 15px;
    margin-bottom: 20px;
}

.result-card {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    padding: 18px;
    text-align: center;
    border: 1px solid rgba(255, 255, 255, 0.1);
    transition: transform 0.3s ease;
}

.result-card:hover {
    transform: translateY(-2px);
    background: rgba(255, 255, 255, 0.08);
}

.result-label {
    font-size: 0.85rem;
    color: rgba(255, 255, 255, 0.7);
    margin-bottom: 8px;
    display: block;
}

.result-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: white;
}

.result-value.positive {
    color: #22c55e;
}

.result-value.negative {
    color: #ef4444;
}

/* Chart Tabs */
.backtest-charts {
    margin-bottom: 30px;
}

.chart-tabs {
    display: flex;
    gap: 5px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.chart-tab {
    padding: 10px 16px;
    border: none;
    border-radius: 6px 6px 0 0;
    background: rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.7);
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: 500;
}

.chart-tab.active {
    background: linear-gradient(45deg, #22c55e, #16a34a);
    color: white;
}

.chart-tab:hover:not(.active) {
    background: rgba(255, 255, 255, 0.15);
    color: white;
}

/* Trade List */
.trade-list {
    margin-top: 30px;
}

.trade-list h4 {
    margin: 0 0 15px 0;
    color: #3b82f6;
    display: flex;
    align-items: center;
    gap: 8px;
}

.trade-filters {
    display: flex;
    gap: 15px;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.trades-table {
    max-height: 400px;
    overflow-y: auto;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.trades-table-element {
    width: 100%;
    border-collapse: collapse;
    background: rgba(255, 255, 255, 0.03);
}

.trades-table-element th {
    background: rgba(255, 255, 255, 0.1);
    padding: 12px 8px;
    text-align: left;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.9);
    font-size: 0.9rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
}

.trades-table-element td {
    padding: 10px 8px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    font-size: 0.85rem;
}

.trades-table-element tr:hover {
    background: rgba(255, 255, 255, 0.05);
}

.trade-side.buy {
    background: rgba(34, 197, 94, 0.2);
    color: #22c55e;
    padding: 2px 6px;
    border-radius: 3px;
    font-weight: 600;
}

.trade-side.sell {
    background: rgba(239, 68, 68, 0.2);
    color: #ef4444;
    padding: 2px 6px;
    border-radius: 3px;
    font-weight: 600;
}

/* Enhanced existing styles */
.form-control textarea {
    resize: vertical;
    min-height: 100px;
    font-family: 'Courier New', monospace;
}

/* Control Sections */
.replay-controls {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 10px;
    padding: 20px;
    margin-bottom: 25px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.control-section {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    align-items: end;
}

.control-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-width: 150px;
}

.control-group label {
    font-size: 0.9rem;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.8);
}

.form-control {
    padding: 10px 12px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.1);
    color: white;
    font-size: 0.95rem;
    transition: all 0.3s ease;
}

.form-control:focus {
    outline: none;
    border-color: #22c55e;
    box-shadow: 0 0 0 2px rgba(34, 197, 94, 0.2);
}

.form-control option {
    background: #1a1a2e;
    color: white;
}

/* Buttons */
.btn {
    padding: 10px 16px;
    border: none;
    border-radius: 6px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 0.95rem;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.btn-primary {
    background: linear-gradient(45deg, #22c55e, #16a34a);
    color: white;
}

.btn-primary:hover {
    background: linear-gradient(45deg, #16a34a, #15803d);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(34, 197, 94, 0.3);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.1);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: translateY(-1px);
}

/* Playback Controls */
.playback-controls {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 10px;
    padding: 20px;
    margin-bottom: 25px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.playback-section {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    align-items: center;
    justify-content: space-between;
}

.playback-buttons {
    display: flex;
    gap: 8px;
}

.btn-control {
    width: 45px;
    height: 45px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.2);
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.btn-control:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: scale(1.05);
}

.btn-play {
    background: linear-gradient(45deg, #22c55e, #16a34a);
    border-color: #22c55e;
}

.btn-play:hover {
    background: linear-gradient(45deg, #16a34a, #15803d);
}

.speed-control {
    display: flex;
    align-items: center;
    gap: 10px;
}

.speed-control input[type="range"] {
    width: 120px;
    height: 6px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 3px;
    outline: none;
    -webkit-appearance: none;
    appearance: none;
}

.speed-control input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 16px;
    height: 16px;
    background: #22c55e;
    border-radius: 50%;
    cursor: pointer;
}

#speed-display {
    font-weight: 600;
    color: #22c55e;
    min-width: 30px;
}

.progress-info {
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-width: 200px;
}

.progress-bar {
    width: 100%;
    height: 6px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 3px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #22c55e, #16a34a);
    border-radius: 3px;
    transition: width 0.3s ease;
}

/* Session Overview */
.session-overview {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 10px;
    padding: 20px;
    margin-bottom: 25px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.session-overview h3 {
    margin: 0 0 20px 0;
    font-size: 1.3rem;
    color: #22c55e;
    display: flex;
    align-items: center;
    gap: 8px;
}

.session-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 15px;
}

.stat-card {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    padding: 15px;
    text-align: center;
    border: 1px solid rgba(255, 255, 255, 0.1);
    transition: transform 0.3s ease;
}

.stat-card:hover {
    transform: translateY(-2px);
    background: rgba(255, 255, 255, 0.08);
}

.stat-label {
    font-size: 0.85rem;
    color: rgba(255, 255, 255, 0.7);
    margin-bottom: 5px;
    display: block;
}

.stat-value {
    font-size: 1.4rem;
    font-weight: 700;
    color: white;
}

.stat-value.positive {
    color: #22c55e;
}

.stat-value.negative {
    color: #ef4444;
}

/* Current Event */
.current-event {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 10px;
    padding: 20px;
    margin-bottom: 25px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.event-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.event-header h3 {
    margin: 0;
    color: #22c55e;
}

.timestamp {
    font-size: 0.9rem;
    color: rgba(255, 255, 255, 0.7);
}

.event-content {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.trade-execution, .portfolio-update {
    background: rgba(255, 255, 255, 0.03);
    border-radius: 8px;
    padding: 15px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.trade-execution h4, .portfolio-update h4 {
    margin: 0 0 12px 0;
    font-size: 1rem;
    color: #3b82f6;
}

.trade-info {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 10px;
}

.trade-symbol {
    font-weight: 700;
    color: #22c55e;
    font-size: 1.1rem;
}

.trade-side {
    padding: 4px 8px;
    border-radius: 4px;
    font-weight: 600;
    font-size: 0.85rem;
}

.trade-side.buy {
    background: rgba(34, 197, 94, 0.2);
    color: #22c55e;
}

.trade-side.sell {
    background: rgba(239, 68, 68, 0.2);
    color: #ef4444;
}

.trade-pnl {
    font-weight: 700;
    font-size: 1.1rem;
}

.trade-pnl.positive {
    color: #22c55e;
}

.trade-pnl.negative {
    color: #ef4444;
}

.portfolio-metrics {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.metric {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.metric .label {
    color: rgba(255, 255, 255, 0.7);
    font-size: 0.9rem;
}

.metric .value {
    font-weight: 600;
}

.metric .value.positive {
    color: #22c55e;
}

.metric .value.negative {
    color: #ef4444;
}

/* Chart Section */
.chart-section {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 10px;
    padding: 20px;
    margin-bottom: 25px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.chart-section h3 {
    margin: 0 0 20px 0;
    font-size: 1.3rem;
    color: #22c55e;
    display: flex;
    align-items: center;
    gap: 8px;
}

.chart-container {
    height: 400px;
    position: relative;
}

/* Timeline */
.event-timeline {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 10px;
    padding: 20px;
    margin-bottom: 25px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.event-timeline h3 {
    margin: 0 0 20px 0;
    font-size: 1.3rem;
    color: #22c55e;
    display: flex;
    align-items: center;
    gap: 8px;
}

.timeline-container {
    max-height: 400px;
    overflow-y: auto;
    padding-right: 10px;
}

.timeline-event {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 12px;
    margin-bottom: 8px;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    cursor: pointer;
    transition: all 0.3s ease;
}

.timeline-event:hover {
    background: rgba(255, 255, 255, 0.08);
    transform: translateX(5px);
}

.timeline-event.current {
    background: rgba(34, 197, 94, 0.2);
    border-color: #22c55e;
}

.timeline-event.completed {
    opacity: 0.7;
}

.timeline-time {
    font-size: 0.85rem;
    color: rgba(255, 255, 255, 0.7);
    min-width: 80px;
}

.timeline-content {
    flex: 1;
}

.timeline-type {
    font-weight: 600;
    color: #3b82f6;
    font-size: 0.9rem;
}

.timeline-trade {
    font-size: 0.85rem;
    color: rgba(255, 255, 255, 0.8);
    margin-top: 4px;
}

.timeline-pnl {
    font-weight: 600;
    font-size: 0.9rem;
    min-width: 80px;
    text-align: right;
}

.timeline-pnl.positive {
    color: #22c55e;
}

.timeline-pnl.negative {
    color: #ef4444;
}

/* Playlists */
.replay-playlists {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 10px;
    padding: 20px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.replay-playlists h3 {
    margin: 0 0 20px 0;
    font-size: 1.3rem;
    color: #22c55e;
    display: flex;
    align-items: center;
    gap: 8px;
}

.playlists-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 15px;
}

.playlist-card {
    background: rgba(255, 255, 255, 0.03);
    border-radius: 8px;
    padding: 15px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    transition: all 0.3s ease;
}

.playlist-card:hover {
    background: rgba(255, 255, 255, 0.08);
    transform: translateY(-2px);
}

.playlist-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.playlist-header h4 {
    margin: 0;
    color: #3b82f6;
}

.playlist-pnl {
    font-weight: 700;
}

.playlist-pnl.positive {
    color: #22c55e;
}

.playlist-pnl.negative {
    color: #ef4444;
}

.playlist-info {
    display: flex;
    flex-direction: column;
    gap: 5px;
    margin-bottom: 15px;
    font-size: 0.9rem;
    color: rgba(255, 255, 255, 0.7);
}

.btn-outline {
    background: transparent;
    color: #22c55e;
    border: 1px solid #22c55e;
}

.btn-outline:hover {
    background: #22c55e;
    color: white;
}

.btn-sm {
    padding: 8px 12px;
    font-size: 0.85rem;
}

/* Responsive Design */
@media (max-width: 768px) {
    .replay-panel {
        padding: 15px;
    }
    
    .control-section {
        flex-direction: column;
        align-items: stretch;
    }
    
    .control-group {
        min-width: unset;
    }
    
    .playback-section {
        flex-direction: column;
        align-items: center;
        gap: 15px;
    }
    
    .event-content {
        grid-template-columns: 1fr;
    }
    
    .session-stats {
        grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    }
    
    .chart-container {
        height: 300px;
    }
}

@media (max-width: 900px) {
    .replay-header {
        text-align: left;
    }

    .mode-selector {
        flex-wrap: wrap;
    }

    .config-row {
        flex-direction: column;
        align-items: stretch;
    }

    .config-group,
    .param-group {
        min-width: 100%;
    }

    .progress-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }

    .trade-filters {
        flex-direction: column;
        align-items: stretch;
    }
}

@media (max-width: 600px) {
    .mode-btn {
        width: 100%;
        justify-content: center;
    }

    .config-actions {
        flex-direction: column;
    }

    .config-actions .btn {
        width: 100%;
        justify-content: center;
    }

    .result-cards {
        grid-template-columns: repeat(2, 1fr);
    }

    .trades-table {
        overflow-x: auto;
    }

    .trades-table-element {
        min-width: 520px;
    }
}

/* Scrollbar Styling */
.timeline-container::-webkit-scrollbar {
    width: 6px;
}

.timeline-container::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
}

.timeline-container::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.3);
    border-radius: 3px;
}

.timeline-container::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.5);
}