/* Main Styles */
body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: #f8f9fa;
}

/* Strategy Rule Groups */
.rule-group {
    border: 2px solid #dee2e6;
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 15px;
    position: relative;
    background-color: #f8f9fa;
}

.rule-group-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.rule-group-title {
    font-weight: 600;
    color: #495057;
}

.rule-item {
    background-color: white;
    border: 1px solid #e9ecef;
    border-radius: 5px;
    padding: 15px;
    margin-bottom: 10px;
    position: relative;
}

.rule-group-operator {
    text-align: center;
    font-weight: bold;
    color: #6c757d;
    margin: 20px 0;
    font-size: 1.2em;
}

.remove-rule, .remove-group {
    position: absolute;
    top: 10px;
    right: 10px;
    cursor: pointer;
    color: #dc3545;
    opacity: 0.6;
    transition: opacity 0.2s;
}

.remove-rule:hover, .remove-group:hover {
    opacity: 1;
}

.sidebar {
    position: fixed;
    top: 56px;
    bottom: 0;
    left: 0;
    z-index: 100;
    padding: 48px 0 0;
    box-shadow: inset -1px 0 0 rgba(0, 0, 0, .1);
    background-color: #f8f9fa !important;
    min-height: calc(100vh - 56px);
}

.sidebar .nav-link {
    font-weight: 500;
    color: #333;
    padding: 10px 20px;
    margin: 5px 0;
    border-radius: 5px;
    transition: all 0.3s;
}

.sidebar .nav-link:hover {
    color: #007bff;
    background-color: #e9ecef;
}

.sidebar .nav-link.active {
    color: #fff;
    background-color: #007bff;
}

.sidebar .nav-link i {
    margin-right: 10px;
    width: 20px;
    text-align: center;
}

main {
    margin-left: 0;
    padding-top: 20px;
}

/* Card Styles */
.card {
    border: none;
    border-radius: 10px;
    box-shadow: 0 0 10px rgba(0,0,0,0.1);
    margin-bottom: 20px;
}

.card-header {
    background-color: #f8f9fa;
    border-bottom: 2px solid #e9ecef;
    font-weight: 600;
}

/* Specific Card Border Colors */
.border-left-primary {
    border-left: 4px solid #007bff !important;
}

.border-left-success {
    border-left: 4px solid #28a745 !important;
}

.border-left-info {
    border-left: 4px solid #17a2b8 !important;
}

.border-left-warning {
    border-left: 4px solid #ffc107 !important;
}

/* Button Styles */
.btn {
    border-radius: 5px;
    padding: 8px 20px;
    font-weight: 500;
    transition: all 0.3s;
}

.btn-block {
    display: block;
    width: 100%;
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0,0,0,0.2);
}

/* Table Styles */
.table {
    background-color: white;
}

.table thead th {
    border-top: none;
    border-bottom: 2px solid #dee2e6;
    font-weight: 600;
    color: #495057;
}

/* Form Styles */
.form-control:focus {
    border-color: #007bff;
    box-shadow: 0 0 0 0.2rem rgba(0,123,255,.25);
}

/* Status Badges */
.badge-status {
    padding: 5px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
}

.badge-pending {
    background-color: #ffc107;
    color: #000;
}

.badge-processing {
    background-color: #17a2b8;
    color: #fff;
}

.badge-completed {
    background-color: #28a745;
    color: #fff;
}

.badge-failed {
    background-color: #dc3545;
    color: #fff;
}

/* Page Content */
.page-content {
    animation: fadeIn 0.3s;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Code Block */
pre {
    background-color: #f4f4f4;
    border: 1px solid #ddd;
    border-radius: 5px;
    padding: 15px;
    max-height: 500px;
    overflow-y: auto;
}

code {
    font-family: 'Courier New', Courier, monospace;
    font-size: 14px;
}

/* Stats Cards */
.text-xs {
    font-size: .875rem;
}

.text-gray-800 {
    color: #5a5c69;
}

.text-gray-300 {
    opacity: 0.3;
}

/* Rules Container */
.rule-item {
    background-color: #f8f9fa;
    padding: 15px;
    border-radius: 5px;
    margin-bottom: 10px;
    border: 1px solid #dee2e6;
}

.rule-item .remove-rule {
    float: right;
    color: #dc3545;
    cursor: pointer;
}

/* Mobile Sidebar Styles */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 999;
}

.sidebar-overlay.active {
    display: block;
}

/* Mobile Toggle Button */
#sidebarToggle {
    margin-right: 10px;
    padding: 0.375rem 0.75rem;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

#sidebarToggle:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

/* Responsive */
@media (max-width: 767px) {
    /* Sidebar Mobile Styles */
    .sidebar {
        position: fixed !important;
        top: 56px;
        left: -280px;
        width: 280px;
        height: calc(100vh - 56px);
        z-index: 1000;
        transition: left 0.3s ease-in-out;
        box-shadow: 2px 0 10px rgba(0, 0, 0, 0.1);
        overflow-y: auto;
    }
    
    .sidebar.active {
        left: 0;
    }
    
    /* Main content adjustments for mobile */
    main.col-md-10 {
        margin-left: 0 !important;
        padding: 15px !important;
    }
    
    /* Make tables responsive */
    .table-responsive {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    /* Card adjustments for mobile */
    .card {
        margin-bottom: 15px;
    }
    
    .card-body {
        padding: 1rem;
    }
    
    /* Stats cards on mobile */
    .col-xl-3.col-md-6 {
        margin-bottom: 15px;
    }
    
    /* Keep navbar functional on mobile but compact */
    .navbar-collapse {
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        background-color: #212529;
        z-index: 1030;
    }
    
    /* Adjust modal sizes for mobile */
    .modal-dialog {
        margin: 10px;
        max-width: calc(100% - 20px);
    }
    
    .modal-dialog-lg {
        max-width: calc(100% - 20px);
    }
    
    /* Form adjustments for mobile */
    .form-control, .form-select {
        font-size: 16px; /* Prevents zoom on iOS */
    }
    
    /* Button adjustments */
    .btn-group-sm .btn {
        padding: 0.375rem 0.75rem;
        font-size: 0.875rem;
    }
    
    /* Optimization cards on mobile */
    .optimization-card {
        margin-bottom: 15px;
    }
    
    /* Charts on mobile */
    canvas {
        max-width: 100%;
        height: auto !important;
    }
}

@media (min-width: 768px) {
    /* Hide mobile-only elements on desktop */
    #sidebarToggle, #sidebarClose {
        display: none !important;
    }
    
    .sidebar-overlay {
        display: none !important;
    }
    
    /* Ensure sidebar is visible on desktop */
    .sidebar {
        display: block !important;
        position: fixed !important;
        left: 0 !important;
    }
}
@media (min-width: 768px) {
    main {
        margin-left: 200px;
    }
}

/* Loading Spinner */
.spinner-border {
    width: 1rem;
    height: 1rem;
    border-width: 0.2em;
}

/* Toast Styles */
.toast {
    min-width: 300px;
}

.toast.success .toast-header {
    background-color: #28a745;
    color: white;
}

.toast.error .toast-header {
    background-color: #dc3545;
    color: white;
}

.toast.info .toast-header {
    background-color: #17a2b8;
    color: white;
}

/* Equity Curve Chart Container */
#equity-curve-chart {
    height: 400px;
    width: 100%;
}

/* Strategy List */
.strategy-item {
    padding: 10px;
    margin-bottom: 10px;
    background-color: #f8f9fa;
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.3s;
}

.strategy-item:hover {
    background-color: #e9ecef;
    transform: translateX(5px);
}

.strategy-item.active {
    background-color: #007bff;
    color: white;
}

/* Trading Session Cards */
.session-card {
    padding: 15px;
    margin-bottom: 15px;
    background-color: #fff;
    border-radius: 8px;
    border: 1px solid #dee2e6;
}

.session-card.active {
    border-color: #28a745;
    background-color: #f8fff9;
}

.session-card .session-status {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
}

.session-card .session-pnl {
    font-size: 20px;
    font-weight: bold;
}

.session-pnl.positive {
    color: #28a745;
}

.session-pnl.negative {
    color: #dc3545;
}