/**
 * Custom Trading Mode Builder Styles
 */

/* Modal Overlay */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.15);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10000;
    backdrop-filter: blur(0.5px);
}

/* Custom Mode Modal */
.custom-mode-modal {
    background: #0a0a0a;
    border: 2px solid #1a1a1a;
    border-radius: 8px;
    width: 90%;
    max-width: 900px;
    max-height: 90vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.8);
}

/* Modal Header */
.custom-mode-modal .modal-header {
    background: #111111;
    border-bottom: 1px solid #333;
    padding: 8px 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.custom-mode-modal .modal-header h3 {
    color: #10b981;
    margin: 0;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 2px;
    text-transform: uppercase;
}

.custom-mode-modal .modal-close {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid #333;
    color: var(--text-secondary, #999);
    font-size: 16px;
    cursor: pointer;
    padding: 0;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 3px;
    transition: all 0.2s ease;
}

.custom-mode-modal .modal-close:hover {
    background: var(--bg-hover, #444);
    color: var(--text-primary, #fff);
}

/* Modal Body */
.custom-mode-modal .modal-body {
    padding: 12px;
    overflow-y: auto;
    flex: 1;
}

/* Mode Name Section */
.mode-name-section {
    background: #0f0f0f;
    border: 1px solid #222222;
    border-radius: 4px;
    padding: 8px;
    margin-bottom: 10px;
}

.mode-controls-row {
    display: grid;
    grid-template-columns: 1fr 1fr auto auto;
    gap: 6px;
    align-items: center;
}

.mode-name-section input[type="text"] {
    padding: 6px 8px;
    background: #060606;
    border: 1px solid #333333;
    border-radius: 3px;
    color: #ffffff;
    font-size: 11px;
}

.mode-name-section input[type="text"]:focus {
    outline: none;
    border-color: var(--primary-accent, #10b981);
    box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.2);
}

#existingModesSelect {
    padding: 6px 8px;
    background: var(--bg-primary, #1a1a1a);
    border: 1px solid var(--border-accent, #333);
    border-radius: 3px;
    color: var(--text-primary, #fff);
    font-size: 11px;
}

.mode-name-section .action-btn {
    padding: 6px 10px;
    background: var(--primary-accent, #10b981);
    color: white;
    border: none;
    border-radius: 3px;
    cursor: pointer;
    font-weight: 600;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.mode-name-section .action-btn:hover {
    background: var(--primary-hover, #059669);
    transform: translateY(-1px);
}

.mode-name-section .action-btn:disabled {
    background: var(--bg-disabled, #555);
    cursor: not-allowed;
    transform: none;
    opacity: 0.5;
}

.mode-name-section .action-btn.danger {
    background: var(--danger-color, #ef4444);
}

.mode-name-section .action-btn.danger:hover {
    background: var(--danger-hover, #dc2626);
}

/* Rules Grid */
.rules-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 10px;
}

@media (max-width: 900px) {
    .rules-grid {
        grid-template-columns: 1fr;
        gap: 8px;
    }
}

/* Rule Sections */
.rule-section {
    background: var(--bg-secondary, #2a2a2a);
    border: 1px solid var(--border-accent, #333);
    border-radius: 4px;
    padding: 10px;
    min-height: 150px;
}

.rule-section.long-section {
    border-left: 4px solid var(--success-color, #10b981);
}

.rule-section.short-section {
    border-left: 4px solid var(--danger-color, #ef4444);
}

.rule-section h4 {
    color: var(--text-primary, #fff);
    margin: 0 0 4px 0;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.rule-description {
    color: var(--text-secondary, #999);
    font-size: 9px;
    margin-bottom: 8px;
    font-style: italic;
}

/* Rules Container */
.rules-container {
    margin-bottom: 8px;
}

/* Rule Rows */
.rule-row {
    background: var(--bg-primary, #1a1a1a);
    border: 1px solid var(--border-subtle, #444);
    border-radius: 4px;
    padding: 6px;
    margin-bottom: 6px;
}

.rule-controls {
    display: grid;
    grid-template-columns: 1.5fr 60px 90px 24px;
    gap: 4px;
    align-items: center;
    margin-bottom: 4px;
}

@media (max-width: 480px) {
    .rule-controls {
        grid-template-columns: 1fr;
        gap: 8px;
    }
}

.rule-controls select,
.rule-controls input {
    padding: 5px 6px;
    background: var(--bg-tertiary, #333);
    border: 1px solid var(--border-subtle, #555);
    border-radius: 3px;
    color: var(--text-primary, #fff);
    font-size: 11px;
}

.rule-controls select:focus,
.rule-controls input:focus {
    outline: none;
    border-color: var(--primary-accent, #10b981);
    box-shadow: 0 0 0 1px rgba(16, 185, 129, 0.2);
}

.property-select {
    min-width: 100px;
}

.operator-select {
    width: 60px;
}

.value-input {
    width: 100px;
}

.remove-rule-btn {
    background: var(--danger-color, #ef4444);
    color: white;
    border: none;
    border-radius: 3px;
    width: 22px;
    height: 22px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 14px;
    transition: all 0.2s ease;
}

.remove-rule-btn:hover {
    background: var(--danger-hover, #dc2626);
    transform: scale(1.1);
}

/* Rule Preview */
.rule-preview {
    color: var(--text-tertiary, #999);
    font-size: 9px;
    font-family: var(--font-numbers);
    background: var(--bg-tertiary, #333);
    padding: 3px 6px;
    border-radius: 2px;
    border-left: 2px solid var(--border-subtle, #555);
}

.rule-preview.valid {
    color: var(--success-color, #10b981);
    border-left-color: var(--success-color, #10b981);
}

/* Add Rule Button */
.add-rule-btn {
    width: 100%;
    padding: 6px;
    background: var(--bg-tertiary, #333);
    color: var(--text-secondary, #ccc);
    border: 1px dashed var(--border-accent, #555);
    border-radius: 4px;
    cursor: pointer;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 1px;
    transition: all 0.2s ease;
}

.add-rule-btn:hover {
    background: var(--bg-hover, #444);
    color: var(--text-primary, #fff);
    border-color: var(--primary-accent, #10b981);
    border-style: solid;
}

/* Preview Section */
.preview-section {
    background: var(--bg-secondary, #2a2a2a);
    border: 1px solid var(--border-accent, #333);
    border-radius: 4px;
    padding: 10px;
    margin-bottom: 10px;
}

.preview-section h4 {
    color: var(--text-primary, #fff);
    margin: 0 0 6px 0;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.strategy-preview {
    background: var(--bg-primary, #1a1a1a);
    border: 1px solid var(--border-subtle, #444);
    border-radius: 4px;
    padding: 8px;
    color: var(--text-secondary, #ccc);
    font-size: 10px;
    line-height: 1.4;
    font-family: var(--font-numbers);
    max-height: 150px;
    overflow-y: auto;
}

.preview-section-item {
    margin-bottom: 8px;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--border-subtle, #444);
}

.preview-section-item:last-child {
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: none;
}

/* Modal Footer */
.custom-mode-modal .modal-footer {
    background: var(--bg-secondary, #2a2a2a);
    border-top: 1px solid var(--border-accent, #333);
    padding: 10px 12px;
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}

.custom-mode-modal .modal-footer .action-btn {
    padding: 8px 16px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 500;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1px;
    transition: all 0.2s ease;
}

.custom-mode-modal .modal-footer .action-btn.test {
    background: var(--warning-color, #f59e0b);
    color: white;
}

.custom-mode-modal .modal-footer .action-btn.test:hover {
    background: var(--warning-hover, #d97706);
}

.custom-mode-modal .modal-footer .action-btn.save {
    background: var(--primary-accent, #10b981);
    color: white;
}

.custom-mode-modal .modal-footer .action-btn.save:hover {
    background: var(--primary-hover, #059669);
}

.custom-mode-modal .modal-footer .action-btn.cancel {
    background: var(--bg-tertiary, #333);
    color: var(--text-secondary, #ccc);
}

.custom-mode-modal .modal-footer .action-btn.cancel:hover {
    background: var(--bg-hover, #444);
    color: var(--text-primary, #fff);
}

/* Custom Mode Button Integration */
.custom-mode-trigger {
    background: var(--primary-accent, #10b981);
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 500;
    transition: all 0.2s ease;
    margin-left: 8px;
}

.custom-mode-trigger:hover {
    background: var(--primary-hover, #059669);
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(16, 185, 129, 0.3);
}

/* Scrollbar Styles */
.custom-mode-modal .modal-body::-webkit-scrollbar,
.strategy-preview::-webkit-scrollbar {
    width: 6px;
}

.custom-mode-modal .modal-body::-webkit-scrollbar-track,
.strategy-preview::-webkit-scrollbar-track {
    background: var(--bg-primary, #1a1a1a);
}

.custom-mode-modal .modal-body::-webkit-scrollbar-thumb,
.strategy-preview::-webkit-scrollbar-thumb {
    background: var(--border-accent, #333);
    border-radius: 3px;
}

.custom-mode-modal .modal-body::-webkit-scrollbar-thumb:hover,
.strategy-preview::-webkit-scrollbar-thumb:hover {
    background: var(--border-hover, #555);
}

/* Animation */
.modal-overlay {
    animation: fadeIn 0.3s ease;
}

.custom-mode-modal {
    animation: slideIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideIn {
    from { 
        opacity: 0;
        transform: scale(0.9) translateY(-20px);
    }
    to { 
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}
