/* ═══════════════════ CUSTOM MODAL SYSTEM ═══════════════════ */

/* Base modal overlay - covers entire screen */
.custom-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    z-index: 10050;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, visibility 0.2s ease;
    pointer-events: auto;
}

.custom-modal-overlay.active {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

/* Modal dialog container */
.custom-modal {
    background: #001100;
    border: 2px solid var(--green, #00ff00);
    border-radius: 12px;
    width: auto;
    max-width: 90vw;
    max-height: 90vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transform: scale(0.95);
    transition: transform 0.2s ease;
    box-shadow: 0 0 30px rgba(0, 255, 0, 0.3);
    position: relative;
    z-index: 10051;
}

.custom-modal-overlay.active .custom-modal {
    transform: scale(1);
}

/* Modal header */
.custom-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-bottom: 1px solid rgba(0, 255, 0, 0.3);
    background: rgba(0, 20, 0, 0.5);
    flex-shrink: 0;
}

.custom-modal-title {
    color: var(--green, #00ff00);
    font-family: 'Share Tech Mono', monospace;
    font-size: 18px;
    font-weight: 700;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 10px;
}

/* Close button */
.custom-modal-close {
    background: transparent;
    border: none;
    color: var(--green, #00ff00);
    font-size: 24px;
    width: 36px;
    height: 36px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    line-height: 1;
    opacity: 0.7;
}

.custom-modal-close:hover {
    background: rgba(0, 255, 0, 0.1);
    opacity: 1;
}

.custom-modal-close::before {
    content: "×";
    font-weight: 300;
    font-size: 28px;
    line-height: 1;
}

/* Modal body */
.custom-modal-body {
    padding: 16px;
    overflow-y: auto;
    overflow-x: hidden;
    flex: 1;
    min-height: 0;
    max-height: 70vh;
    color: #00ff00;
    font-family: 'Share Tech Mono', monospace;
}

/* Modal footer */
.custom-modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 12px 16px;
    border-top: 1px solid rgba(0, 255, 0, 0.3);
    background: rgba(0, 20, 0, 0.5);
    flex-shrink: 0;
}

/* Modal sizes */
.custom-modal-sm { width: 400px; }
.custom-modal-md { width: 600px; }
.custom-modal-lg { width: 700px; }
.custom-modal-xl { width: 900px; }

/* Settings modal - taller with more scroll */
.custom-modal-lg.custom-modal-settings {
    width: 720px;
}

.custom-modal-lg.custom-modal-settings .custom-modal-body {
    max-height: 65vh;
}

/* Orderbook modal - maximum height with 30px margins */
.custom-modal-orderbook {
    width: auto;
    min-width: 320px;
    max-width: 95vw;
    max-height: calc(100vh - 60px);
    margin: 30px 0;
}

.custom-modal-orderbook .custom-modal-body {
    max-height: none;
    height: 100%;
    min-height: 0;
    padding: 8px;
    overflow: hidden;
}

.custom-modal-orderbook .custom-modal-content {
    height: 100%;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

/* Close on overlay click */
.custom-modal-overlay.close-on-click {
    cursor: pointer;
}

/* Focus styles */
.custom-modal-close:focus {
    outline: 2px solid var(--green, #00ff00);
    outline-offset: 2px;
}

/* Matrix theme additions */
.custom-modal-content {
    background: linear-gradient(135deg, rgba(0, 15, 0, 0.98), rgba(0, 30, 0, 0.95));
}

.custom-modal-body input,
.custom-modal-body select {
    background: #000800;
    border: 1px solid #00aa00;
    color: #00ff00;
    padding: 10px;
    border-radius: 4px;
    font-family: 'Share Tech Mono', monospace;
}

.custom-modal-body input:focus,
.custom-modal-body select:focus {
    outline: none;
    border-color: #00ff00;
    box-shadow: 0 0 10px rgba(0, 255, 0, 0.3);
}


/* Pairs modal - grid layout for pair items */
#pairsListContainer.pair-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 6px;
    max-height: 400px;
    overflow-y: auto;
    border: 1px solid rgba(0, 255, 0, 0.3);
    border-radius: 8px;
    background: rgba(0, 10, 0, 0.5);
    padding: 8px;
}

#pairsListContainer.pair-grid .pair-item {
    display: flex;
    align-items: center;
    padding: 8px 10px;
    border-radius: 4px;
    transition: background 0.15s ease;
    cursor: pointer;
    min-height: 36px;
    box-sizing: border-box;
}

#pairsListContainer.pair-grid .pair-item:hover {
    background: rgba(0, 255, 0, 0.15);
}

#pairsListContainer.pair-grid .pair-item input[type="checkbox"] {
    width: 16px;
    height: 16px;
    margin-right: 8px;
    accent-color: #00ff00;
    flex-shrink: 0;
}

#pairsListContainer.pair-grid .pair-item span {
    color: #00ff00;
    font-family: 'Share Tech Mono', monospace;
    font-size: 12px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Responsive for pairs grid */
@media (max-width: 900px) {
    #pairsListContainer.pair-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 600px) {
    #pairsListContainer.pair-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Responsive */
@media (max-width: 768px) {
    .custom-modal {
        width: 95vw;
        max-height: 85vh;
    }
    
    .custom-modal-lg,
    .custom-modal-xl {
        width: 95vw;
    }
}

/* ═══════════════════ MATRIX SCROLLBARS ═══════════════════ */
::-webkit-scrollbar {
    width: 20px;
    height: 20px;
}

::-webkit-scrollbar-track {
    background: rgba(0, 60, 0, 0.6);
    border-radius: 5px;
    border: 1px solid rgba(0, 100, 0, 0.3);
}

::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg, #004400, #006600);
    border-radius: 5px;
    border: 1px solid rgba(0, 80, 0, 0.5);
    opacity: 0.6;
    transition: all 0.2s ease;
}

::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(180deg, #00aa00, #00ff00);
    opacity: 1;
    border-color: rgba(0, 255, 0, 0.5);
}

::-webkit-scrollbar-thumb:active {
    background: linear-gradient(180deg, #00ff00, #00ff88);
    opacity: 1;
}

::-webkit-scrollbar-corner {
    background: rgba(0, 40, 0, 0.6);
}

/* Firefox scrollbar */
* {
    scrollbar-width: auto;
    scrollbar-color: rgba(0, 100, 0, 0.5) rgba(0, 40, 0, 0.4);
}

*:hover {
    scrollbar-color: #00aa00 rgba(0, 60, 0, 0.6);
}

/* ═══════════════════ ALERT NOTIFICATIONS v2.0 STYLES ═══════════════════ */

.alert-notifications-section {
    margin: 15px 0;
    padding: 15px;
    background: rgba(0, 20, 0, 0.5);
    border: 1px solid rgba(0, 255, 0, 0.2);
    border-radius: 8px;
}

.alert-notifications-section h4 {
    color: #0f0;
    margin: 0 0 15px 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.alert-notifications-section h4 .icon-inline {
    width: 20px;
    height: 20px;
}

.alert-subsection {
    margin: 10px 0;
    padding: 10px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 6px;
}

.alert-subsection-title {
    color: #0f0;
    font-weight: bold;
    margin-bottom: 8px;
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.alert-indent {
    margin-left: 20px;
    padding-left: 15px;
    border-left: 2px solid rgba(0, 255, 0, 0.2);
}

.alert-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 0;
    cursor: pointer;
}

.alert-toggle input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: #0f0;
}

.alert-toggle span {
    font-size: 13px;
}

.alert-hint {
    font-size: 11px;
    color: #888;
    margin-top: 8px;
    font-style: italic;
}

.alert-subsection.red-special {
    border: 1px solid rgba(255, 0, 0, 0.3);
    background: rgba(50, 0, 0, 0.3);
}

.alert-subsection.red-special .alert-subsection-title {
    color: #ff4444;
}

/* ═══════════════════ VIGNETTE EFFECT ═══════════════════ */

#vignette {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    pointer-events: none;
    z-index: 998;
    opacity: 0;
    transition: opacity 0.3s ease;
    box-shadow: inset 0 0 25px rgba(0, 0, 0, 0.5);
}

#vignette.active {
    opacity: 1;
}

#vignette.yellow {
    box-shadow: inset 0 0 25px rgba(255, 215, 0, 0.3),
                inset 0 0 60px rgba(255, 215, 0, 0.2);
}

#vignette.orange {
    box-shadow: inset 0 0 25px rgba(255, 102, 0, 0.4),
                inset 0 0 60px rgba(255, 102, 0, 0.25);
}

#vignette.red {
    box-shadow: inset 0 0 25px rgba(255, 0, 0, 0.5),
                inset 0 0 60px rgba(255, 0, 0, 0.35);
}

#vignette.pump {
    box-shadow: inset 0 0 25px rgba(0, 255, 100, 0.3),
                inset 0 0 60px rgba(0, 255, 100, 0.2);
}

#vignette.red.pulsing {
    animation: vignettePulse 0.8s ease-in-out infinite;
}

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

#vignette.red.urgent {
    animation: vignetteUrgent 0.5s ease-in-out infinite;
}

@keyframes vignetteUrgent {
    0%, 100% {
        box-shadow: inset 0 0 30px rgba(255, 0, 0, 0.6),
                    inset 0 0 80px rgba(255, 0, 0, 0.4);
    }
    50% {
        box-shadow: inset 0 0 35px rgba(255, 0, 0, 0.7),
                    inset 0 0 90px rgba(255, 0, 0, 0.5);
    }
}

/* ═══════════════════ PAGE FLASH EFFECT ═══════════════════ */

@keyframes flashYellow {
    0% { background-color: transparent; }
    10% { background-color: rgba(255, 215, 0, 0.3); }
    20% { background-color: transparent; }
    30% { background-color: rgba(255, 215, 0, 0.25); }
    40% { background-color: transparent; }
    100% { background-color: transparent; }
}

@keyframes flashOrange {
    0% { background-color: transparent; }
    10% { background-color: rgba(255, 102, 0, 0.3); }
    20% { background-color: transparent; }
    30% { background-color: rgba(255, 102, 0, 0.25); }
    40% { background-color: transparent; }
    100% { background-color: transparent; }
}

@keyframes flashRed {
    0% { background-color: transparent; }
    8% { background-color: rgba(255, 0, 0, 0.4); }
    16% { background-color: transparent; }
    24% { background-color: rgba(255, 0, 0, 0.35); }
    32% { background-color: transparent; }
    40% { background-color: rgba(255, 0, 0, 0.3); }
    100% { background-color: transparent; }
}

@keyframes flashPump {
    0% { background-color: transparent; }
    10% { background-color: rgba(0, 255, 100, 0.2); }
    20% { background-color: transparent; }
    30% { background-color: rgba(0, 255, 100, 0.15); }
    40% { background-color: transparent; }
    100% { background-color: transparent; }
}

body.flash-yellow {
    animation: flashYellow 1.5s ease-out;
}

body.flash-orange {
    animation: flashOrange 1.5s ease-out;
}

body.flash-red {
    animation: flashRed 1.5s ease-out;
}

body.flash-pump {
    animation: flashPump 1.5s ease-out;
}

/* ═══════════════════ ENHANCED ALERT DIALOG ═══════════════════ */

#alert {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.9);
    width: 90%;
    max-width: 500px;
    min-height: 200px;
    padding: 30px;
    display: none;
    flex-direction: column;
    align-items: center;
    font-weight: bold;
    text-align: center;
    z-index: 99999;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    border-radius: 16px;
    background: #fff;
    color: #000;
    border: 3px solid;
    box-shadow: 0 0 50px rgba(0, 255, 0, 0.3);
}

#alert.active {
    display: flex;
    transform: translate(-50%, -50%) scale(1);
}

#alert.yellow {
    border-color: #FFD700;
    box-shadow: 0 0 50px rgba(255, 215, 0, 0.5);
}

#alert.orange {
    border-color: #FF6600;
    box-shadow: 0 0 50px rgba(255, 102, 0, 0.5);
}

#alert.red {
    border-color: #ff4444;
    box-shadow: 0 0 50px rgba(255, 0, 0, 0.6);
    animation: alertPulse 0.8s ease-in-out infinite;
}

#alert.pump {
    border-color: #00FF64;
    box-shadow: 0 0 50px rgba(0, 255, 100, 0.5);
}

#alert.active {
    display: flex;
    transform: translate(-50%, -50%) scale(1);
}

#alert .alert-level-badge {
    position: absolute;
    top: -15px;
    left: 50%;
    transform: translateX(-50%);
    background: currentColor;
    color: #000;
    padding: 6px 20px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 1px;
}

#alert .alert-dismiss-btn {
    position: absolute;
    top: 15px;
    right: 15px;
    background: rgba(0, 0, 0, 0.1);
    border: 2px solid currentColor;
    color: #000;
    padding: 8px 16px;
    font-size: 14px;
    font-weight: bold;
    cursor: pointer;
    border-radius: 8px;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s;
}

#alert .alert-dismiss-btn:hover {
    background: rgba(0, 0, 0, 0.2);
    transform: scale(1.05);
}

#alert .alert-dismiss-btn svg {
    width: 16px;
    height: 16px;
}

#alert .alert-icon {
    margin-bottom: 15px;
}

#alert .alert-icon svg {
    width: 48px;
    height: 48px;
    filter: drop-shadow(0 0 10px currentColor);
}

#alert h2 {
    font-size: clamp(20px, 4vw, 28px);
    margin: 0 0 10px 0;
    color: #000;
    text-shadow: none;
}

#alert p {
    font-size: clamp(16px, 3vw, 22px);
    margin: 0 0 15px 0;
    color: #000;
}

#alert .alert-event-desc {
    font-size: 13px;
    color: #000;
    opacity: 0.9;
    margin-bottom: 15px;
    padding: 10px 15px;
    background: rgba(0, 0, 0, 0.1);
    border: 1px solid currentColor;
    border-radius: 8px;
    line-height: 1.4;
}

#alert .alert-details {
    display: flex;
    gap: 15px;
    margin-top: 15px;
    flex-wrap: wrap;
    justify-content: center;
    width: 100%;
}

#alert .alert-detail-item {
    background: rgba(0, 0, 0, 0.1);
    border: 1px solid currentColor;
    padding: 10px 20px;
    border-radius: 8px;
    min-width: 100px;
    flex: 1;
}

#alert .detail-label {
    display: block;
    font-size: 11px;
    opacity: 0.7;
    margin-bottom: 4px;
    text-transform: uppercase;
    color: #000;
}

#alert .detail-value {
    display: block;
    font-size: 16px;
    font-weight: bold;
    color: #000;
}

#alert.yellow {
    color: #FFD700;
}

#alert.orange {
    color: #FF6600;
}

#alert.red {
    color: #ff4444;
}

#alert.pump {
    color: #00aa00;
}

@keyframes alertPulse {
    0%, 100% { box-shadow: 0 0 50px rgba(255, 0, 0, 0.6); }
    50% { box-shadow: 0 0 70px rgba(255, 0, 0, 0.8); }
}

/* ═══════════════════ ALERT TEST DROPDOWN IN TOPBAR ═══════════════════ */

.alert-test-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    background: rgba(0, 20, 0, 0.98);
    border: 2px solid #0f0;
    border-radius: 12px;
    padding: 12px;
    z-index: 10001;
    box-shadow: 0 0 30px rgba(0, 255, 0, 0.4);
    font-family: 'Courier New', monospace;
    display: none;
    width: 240px;
    animation: dropdownFadeIn 0.2s ease-out;
}

.alert-test-dropdown.show {
    display: block;
}

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

.alert-test-dropdown-header {
    color: #0f0;
    font-weight: bold;
    font-size: 11px;
    text-align: center;
    margin-bottom: 10px;
    padding-bottom: 8px;
    border-bottom: 1px solid rgba(0, 255, 0, 0.3);
    letter-spacing: 1px;
}

.alert-test-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
    margin-bottom: 8px;
}

.alert-test-dropdown-item {
    width: 100%;
    border: none;
    padding: 8px 10px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
}

.alert-test-dropdown-item:hover {
    transform: scale(1.05);
    box-shadow: 0 0 8px currentColor;
}

.alert-test-dropdown-item.alert-yellow {
    background: linear-gradient(135deg, #FFD700, #FFA500);
    color: #000;
}

.alert-test-dropdown-item.alert-orange {
    background: linear-gradient(135deg, #FF6600, #FF4500);
    color: #fff;
}

.alert-test-dropdown-item.alert-red {
    background: linear-gradient(135deg, #FF0000, #8B0000);
    color: #fff;
}

.alert-test-dropdown-item.alert-pump {
    background: linear-gradient(135deg, #00FF64, #00CC50);
    color: #000;
}

.alert-test-dropdown-item.alert-dismiss {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid #666;
    color: #fff;
    margin-bottom: 6px;
}

.alert-test-dropdown-item.alert-dismiss:hover {
    background: rgba(255, 0, 0, 0.3);
    border-color: #f00;
}

.alert-test-dropdown-status {
    font-size: 10px;
    color: #888;
    text-align: center;
    padding-top: 6px;
    border-top: 1px solid rgba(0, 255, 0, 0.2);
}

/* Hide on production */
body.production-mode .alert-test-dropdown,
body.production-mode #alertTestBtn {
    display: none !important;
}

/* Show only in development */
body.development-mode .alert-test-dropdown,
body.staging-mode .alert-test-dropdown,
body.development-mode #alertTestBtn,
body.staging-mode #alertTestBtn {
    display: block !important;
}
