/**
 * TACTICAL TRADING MODE BUILDER - MILITARY INTERFACE
 * CLASSIFICATION: RESTRICTED
 */

/* Modal Overlay - Tactical Screen */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(5, 10, 15, 0.94);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10000;
    backdrop-filter: blur(4px) saturate(0.6);
}

/* Custom Mode Modal - Command Center */
.custom-mode-modal {
    background: linear-gradient(135deg, #0a0e12 0%, #050708 100%);
    border: 2px solid #2a3a4a;
    border-radius: 0;
    width: 95%;
    max-width: 1200px;
    max-height: 90vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: 0 0 50px rgba(59, 130, 246, 0.2),
                0 0 100px rgba(30, 60, 120, 0.15),
                inset 0 0 100px rgba(0, 0, 0, 0.6);
    position: relative;
    clip-path: polygon(0 0, calc(100% - 20px) 0, 100% 20px, 100% 100%, 0 100%);
}

/* Tactical Corner Accent */
.custom-mode-modal::before {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 20px;
    height: 20px;
    background: linear-gradient(135deg, transparent 50%, #3b82f6 50%);
    z-index: 1;
}

/* Tactical Grid Background */
.custom-mode-modal::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image: 
        linear-gradient(rgba(59, 130, 246, 0.04) 1px, transparent 1px),
        linear-gradient(90deg, rgba(59, 130, 246, 0.04) 1px, transparent 1px);
    background-size: 20px 20px;
    pointer-events: none;
    opacity: 0.4;
}

/* Modal Header - Command Bar */
.custom-mode-modal .modal-header {
    background: linear-gradient(180deg, #151a20 0%, #0d1015 100%);
    border-bottom: 2px solid #3b82f6;
    border-top: 1px solid #1e3a5f;
    padding: 16px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: relative;
    z-index: 2;
    box-shadow: 0 4px 20px rgba(59, 130, 246, 0.25);
}

.custom-mode-modal .modal-header::before {
    content: 'SYSTEM ACTIVE';
    position: absolute;
    top: -1px;
    right: 100px;
    font-size: 9px;
    color: #60a5fa;
    letter-spacing: 3px;
    font-family: 'Courier New', monospace;
    font-weight: bold;
    opacity: 0.7;
    animation: pulseStatus 2s ease-in-out infinite;
}

@keyframes pulseStatus {
    0%, 100% { opacity: 0.7; }
    50% { opacity: 1; }
}

.custom-mode-modal .modal-header h3 {
    color: #60a5fa;
    margin: 0;
    font-size: 18px;
    font-weight: 700;
    letter-spacing: 2px;
    text-transform: uppercase;
    font-family: 'Courier New', monospace;
    text-shadow: 0 0 10px rgba(96, 165, 250, 0.4),
                 0 0 20px rgba(59, 130, 246, 0.2);
}

.custom-mode-modal .modal-close {
    background: linear-gradient(135deg, #1a1e25 0%, #0f1117 100%);
    border: 1px solid #3b82f6;
    color: #60a5fa;
    font-size: 20px;
    cursor: pointer;
    padding: 0;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 0;
    transition: all 0.2s ease;
    clip-path: polygon(0 0, calc(100% - 6px) 0, 100% 6px, 100% 100%, 0 100%);
    font-weight: bold;
    box-shadow: 0 0 10px rgba(59, 130, 246, 0.3);
}

.custom-mode-modal .modal-close:hover {
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
    color: #000;
    box-shadow: 0 0 20px rgba(59, 130, 246, 0.6),
                inset 0 0 10px rgba(255, 255, 255, 0.2);
    transform: scale(1.05);
}

/* Modal Body - Operations Theater */
.custom-mode-modal .modal-body {
    padding: 12px;
    overflow-y: auto;
    flex: 1;
    position: relative;
    z-index: 1;
}

/* Mode Name Section - Command Input */
.mode-name-section {
    background: linear-gradient(135deg, #0d1217 0%, #080a0d 100%);
    border: 1px solid #3b82f6;
    border-left: 3px solid #3b82f6;
    border-radius: 0;
    padding: 10px 12px;
    margin-bottom: 12px;
    box-shadow: 0 0 15px rgba(59, 130, 246, 0.15);
}

.mode-name-section label {
    display: block;
    color: #60a5fa;
    font-weight: 700;
    margin-bottom: 6px;
    font-size: 11px;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    font-family: 'Courier New', monospace;
}

.mode-name-section input[type="text"] {
    width: 100%;
    padding: 8px 10px;
    background: #000;
    border: 1px solid #1e3a5f;
    border-radius: 0;
    color: #93c5fd;
    font-size: 14px;
    margin-bottom: 8px;
    font-family: 'Courier New', monospace;
    letter-spacing: 0.5px;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.5);
}

.mode-name-section input[type="text"]:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 10px rgba(59, 130, 246, 0.3),
                inset 0 2px 4px rgba(0, 0, 0, 0.5);
}

.mode-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

.mode-actions select {
    flex: 1;
    padding: 7px 8px;
    background: #000;
    border: 1px solid #1e3a5f;
    border-radius: 0;
    color: #93c5fd;
    font-size: 12px;
    font-family: 'Courier New', monospace;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.5);
}

.mode-actions .action-btn {
    padding: 7px 14px;
    background: linear-gradient(135deg, #1e3a5f 0%, #0f1d2f 100%);
    color: #60a5fa;
    border: 1px solid #3b82f6;
    border-radius: 0;
    cursor: pointer;
    font-weight: 700;
    font-size: 11px;
    letter-spacing: 1px;
    text-transform: uppercase;
    transition: all 0.15s ease;
    font-family: 'Courier New', monospace;
    box-shadow: 0 0 8px rgba(59, 130, 246, 0.2);
    clip-path: polygon(0 0, calc(100% - 4px) 0, 100% 4px, 100% 100%, 0 100%);
}

.mode-actions .action-btn:hover {
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
    color: #000;
    box-shadow: 0 0 15px rgba(59, 130, 246, 0.5);
    transform: translateY(-1px);
}

.mode-actions .action-btn:disabled {
    background: #1a1a1a;
    border-color: #333;
    color: #555;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.mode-actions .action-btn.danger {
    background: linear-gradient(135deg, #3a1a1a 0%, #1f0d0d 100%);
    border-color: #ef4444;
    color: #ef4444;
}

.mode-actions .action-btn.danger:hover {
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    color: #000;
    box-shadow: 0 0 15px rgba(239, 68, 68, 0.5);
}

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

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

/* Rule Sections - Operation Zones */
.rule-section {
    background: linear-gradient(135deg, #0a0f0a 0%, #060806 100%);
    border: 1px solid #1a3a1a;
    border-radius: 0;
    padding: 10px;
    min-height: 180px;
    position: relative;
    box-shadow: inset 0 0 30px rgba(0, 0, 0, 0.5);
}

.rule-section.long-section {
    border-left: 3px solid #22c55e;
    border-top: 1px solid #22c55e;
}

.rule-section.short-section {
    border-left: 3px solid #ef4444;
    border-top: 1px solid #ef4444;
}

.rule-section h4 {
    color: #22c55e;
    margin: 0 0 6px 0;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    font-family: 'Courier New', monospace;
    text-shadow: 0 0 8px rgba(34, 197, 94, 0.5);
}

.rule-section.short-section h4 {
    color: #ef4444;
    text-shadow: 0 0 8px rgba(239, 68, 68, 0.5);
}

.rule-description {
    color: #666;
    font-size: 9px;
    margin-bottom: 10px;
    font-style: normal;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    font-family: 'Courier New', monospace;
    opacity: 0.7;
}

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

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

.rule-controls {
    display: grid;
    grid-template-columns: 2fr 80px 120px 32px;
    gap: 8px;
    align-items: center;
    margin-bottom: 8px;
}

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

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

.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: 120px;
}

.operator-select {
    width: 60px;
}

.value-input {
    width: 100px;
}

.remove-rule-btn {
    background: var(--danger-color, #ef4444);
    color: white;
    border: none;
    border-radius: 4px;
    width: 28px;
    height: 28px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    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: 11px;
    font-family: var(--font-numbers);
    background: var(--bg-tertiary, #333);
    padding: 4px 8px;
    border-radius: 3px;
    border-left: 3px 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: 12px;
    background: var(--bg-tertiary, #333);
    color: var(--text-secondary, #ccc);
    border: 1px dashed var(--border-accent, #555);
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    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: 8px;
    padding: 20px;
    margin-bottom: 24px;
}

.preview-section h4 {
    color: var(--text-primary, #fff);
    margin: 0 0 16px 0;
    font-size: 16px;
    font-weight: 600;
}

.strategy-preview {
    background: var(--bg-primary, #1a1a1a);
    border: 1px solid var(--border-subtle, #444);
    border-radius: 6px;
    padding: 16px;
    color: var(--text-secondary, #ccc);
    font-size: 13px;
    line-height: 1.5;
    font-family: var(--font-numbers);
    max-height: 200px;
    overflow-y: auto;
}

.preview-section-item {
    margin-bottom: 16px;
    padding-bottom: 12px;
    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: 20px 24px;
    display: flex;
    gap: 12px;
    justify-content: flex-end;
}

.custom-mode-modal .modal-footer .action-btn {
    padding: 12px 24px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 500;
    font-size: 14px;
    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);
    }
}
