/* ═══════════════════ MATRIX RADAR — MAIN STYLES ═══════════════════ */

:root {
    --yellow: #FFD700;
    --orange: #FF6600;
    --red: #FF0000;
    --green: #00FF00;
    --pump: #00FF88;
    --bg-dark: #000000;
    --bg-table: rgba(0, 20, 0, 0.85);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    overflow-x: hidden;
    background: var(--bg-dark);
    font-family: 'Courier New', monospace;
    min-height: 100vh;
}

body.has-topbar {
    padding-top: 64px;
}

/* ═══════════════════ TOP BAR (MENU) ═══════════════════ */
.topbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 120;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 10px 12px;
    background: rgba(0, 20, 0, 0.72);
    border-bottom: 1px solid rgba(0, 255, 0, 0.22);
    backdrop-filter: blur(6px);
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

.topbar-brand {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 4px 6px 4px 4px;
    text-decoration: none;
    font-weight: 900;
    letter-spacing: 1px;
    color: var(--green);
    user-select: none;
}

.topbar-brand .brand-mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border-radius: 10px;
    background: rgba(0, 255, 0, 0.10);
    border: 1px solid rgba(0, 255, 0, 0.35);
    box-shadow: 0 0 16px rgba(0, 255, 0, 0.18);
    overflow: hidden;
    flex: 0 0 auto;
}

.topbar-brand .brand-logo {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}

.topbar-brand .brand-text {
    font-weight: 900;
    letter-spacing: 1px;
    line-height: 1;
    white-space: nowrap;
}

.topbar-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    flex-wrap: wrap;
}

.topbar-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 44px;
    padding: 0 12px;
    border-radius: 10px;
    text-decoration: none;
    font-size: 14px;
    font-weight: 800;
    cursor: pointer;
    color: var(--green);
    background: #001100;
    border: 2px solid rgba(0, 255, 0, 0.55);
    transition: all 0.15s;
    white-space: nowrap;
}

.topbar-btn:hover {
    background: rgba(0, 255, 0, 0.16);
    border-color: rgba(0, 255, 0, 0.9);
    color: var(--green);
    transform: translateY(-1px);
}

.upgrade-btn.topbar-btn {
    background: rgba(0, 255, 0, 0.18);
}

/* ═══════════════════ BILLING / UPGRADE BUTTON ═══════════════════ */
.upgrade-btn {
    /* now used inside .topbar; layout handled there */
}

.upgrade-btn:hover {
    /* hover handled by .topbar-btn */
}

/* ═══════════════════ MATRIX CANVAS ═══════════════════ */
#matrix-canvas {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 1;
    pointer-events: none;
}

/* ═══════════════════ CONTAINER ═══════════════════ */
.container {
    position: relative;
    z-index: 2;
    padding: 10px;
    max-width: 100%;
}

h1 {
    text-align: center;
    color: var(--green);
    text-shadow: 0 0 20px var(--green);
    margin: 10px;
    font-size: clamp(1.2em, 4vw, 2em);
}

.brand-title {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
}

.brand-title--left {
    justify-content: flex-start;
}

.brand-title-logo {
    width: 34px;
    height: 34px;
    object-fit: contain;
    flex: 0 0 auto;
}

.slogan {
    text-align: center;
    color: var(--green);
    opacity: 0.7;
    font-size: 12px;
    margin-bottom: 15px;
}

/* ═══════════════════ ADD PANEL ═══════════════════ */
.add-panel {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin: 10px;
    flex-wrap: wrap;
}

.add-panel input {
    flex: 1;
    min-width: 200px;
    max-width: 400px;
    padding: 12px;
    font-size: 16px;
    background: #001100;
    color: var(--green);
    border: 2px solid var(--green);
    border-radius: 8px;
}

.add-panel input:focus {
    outline: none;
    box-shadow: 0 0 10px var(--green);
}

.add-panel button {
    padding: 12px 20px;
    font-size: 18px;
    background: var(--green);
    color: #000;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: bold;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.add-panel button .icon-inline {
    filter: none !important;
    color: #000 !important;
    margin: 0;
    vertical-align: middle;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.2em;
    height: 1.2em;
}

.add-panel button:hover {
    background: #0a0;
    transform: scale(1.05);
}

/* ═══════════════════ STATUS ═══════════════════ */
.status {
    text-align: center;
    font-size: 12px;
    color: var(--green);
    opacity: 0.6;
    margin: 5px;
}

.status.offline {
    color: var(--red);
    animation: blink 1s infinite;
}

@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

/* ═══════════════════ TABLE ═══════════════════ */
.table-wrap {
    overflow-x: auto;
    overflow-y: visible;
    margin: 10px;
}

table {
    width: 100%;
    color: var(--green);
    font-size: clamp(12px, 2.5vw, 16px);
    background: var(--bg-table);
    border-collapse: collapse;
    border-radius: 10px;
    overflow: hidden;
}

thead {
    position: relative;
}

th, td {
    padding: 8px 6px;
    border: 1px solid var(--green);
    text-align: center;
    white-space: nowrap;
}

th {
    background: #001a00;
    position: sticky;
    top: 0;
}

/* ═══════════════════ SORTABLE HEADERS ═══════════════════ */
.sortable-header {
    cursor: pointer;
    user-select: none;
    position: relative;
    transition: background-color 0.2s;
}

.sortable-header:hover {
    background: #002a00;
}

.limited-mode .sortable-header {
    opacity: 0.85;
}

.limited-mode .settings-panel input[disabled],
.limited-mode .settings-panel select[disabled] {
    opacity: 0.35;
    cursor: not-allowed;
}

.limited-mode .settings-panel label {
    opacity: 0.85;
}

.limited-mode .paid-only {
    display: none !important;
}

.limited-mode .sort-indicator,
.limited-mode #priceFilterDropdown {
    display: none !important;
}

.sort-indicator {
    margin-left: 5px;
    display: inline-flex;
    align-items: center;
    vertical-align: middle;
}

/* Up arrow for ascending sort */
.sort-indicator:not(.desc)::before {
    content: '';
    display: inline-block;
    width: 0;
    height: 0;
    border-left: 5px solid transparent;
    border-right: 5px solid transparent;
    border-bottom: 6px solid var(--green);
    filter: drop-shadow(0 0 3px var(--green));
    margin-left: 2px;
}

/* Down arrow for descending sort */
.sort-indicator.desc::before {
    content: '';
    display: inline-block;
    width: 0;
    height: 0;
    border-left: 5px solid transparent;
    border-right: 5px solid transparent;
    border-top: 6px solid var(--green);
    filter: drop-shadow(0 0 3px var(--green));
    margin-left: 2px;
}

/* ═══════════════════ PRICE FILTER DROPDOWN ═══════════════════ */
.price-filter-dropdown {
    position: fixed;
    z-index: 10000;
    background: #001100;
    border: 2px solid var(--green);
    border-radius: 8px;
    padding: 10px;
    margin-top: 5px;
    min-width: 200px;
    max-width: 300px;
    box-shadow: 0 4px 12px rgba(0, 255, 0, 0.3);
}

th.sortable-header {
    position: relative;
}

.price-filter-indicator {
    display: inline-block;
    margin-left: 5px;
    color: var(--green);
    font-size: 16px;
    font-weight: bold;
    cursor: help;
    vertical-align: middle;
    text-shadow: 0 0 5px var(--green);
    animation: pulse-filter 2s ease-in-out infinite;
}

@keyframes pulse-filter {
    0%, 100% {
        opacity: 1;
        text-shadow: 0 0 5px var(--green);
    }
    50% {
        opacity: 0.7;
        text-shadow: 0 0 10px var(--green);
    }
}

.price-filter-content {
    display: flex;
    flex-direction: column;
}

.price-filter-content input[type="number"] {
    font-size: 12px;
}

.price-filter-content input[type="number"]:focus {
    outline: none;
    box-shadow: 0 0 5px var(--green);
}

.price-filter-content button {
    font-size: 12px;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
}

.price-filter-content button:hover {
    transform: scale(1.05);
}

/* ═══════════════════ ALERT LEVELS ═══════════════════ */
.alert-1 {
    background: rgba(255, 215, 0, 0.3) !important;
    color: var(--yellow) !important;
}

.alert-2 {
    background: rgba(255, 102, 0, 0.4) !important;
    color: var(--orange) !important;
    animation: pulse 0.5s infinite;
}

.alert-3 {
    background: rgba(255, 0, 0, 0.5) !important;
    color: #fff !important;
    animation: flash 0.2s infinite;
}

.alert-4 {
    background: rgba(0, 255, 100, 0.4) !important;
    color: var(--pump) !important;
    animation: glow 0.3s infinite;
}

.invalid {
    opacity: 0.4;
    color: #444 !important;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

@keyframes flash {
    0%, 100% {
        opacity: 1;
        background: rgba(255, 0, 0, 0.7);
    }
    50% {
        opacity: 0.5;
        background: rgba(139, 0, 0, 0.9);
    }
}

@keyframes glow {
    0%, 100% { box-shadow: inset 0 0 20px var(--green); }
    50% { box-shadow: inset 0 0 40px var(--green); }
}

/* ═══════════════════ DELETE BUTTON ═══════════════════ */
.delete-btn {
    background: #500;
    color: var(--red);
    border: 1px solid var(--red);
    border-radius: 4px;
    cursor: pointer;
    padding: 2px 8px;
    font-size: 12px;
    transition: all 0.2s;
}

.delete-btn:hover {
    background: var(--red);
    color: #000;
}

/* ═══════════════════ FULLSCREEN ALERT ═══════════════════ */
#alert {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    font-weight: bold;
    text-align: center;
    z-index: 999;
    pointer-events: none;
    transition: opacity 0.3s;
}

#alert.yellow {
    background: rgba(255, 215, 0, 0.9);
    color: #000;
}

#alert.orange {
    background: rgba(255, 102, 0, 0.95);
    color: #000;
}

#alert.red {
    background: rgba(180, 0, 0, 0.98);
    color: #fff;
}

#alert.pump {
    background: rgba(0, 100, 0, 0.95);
    color: var(--green);
}

#alert h2 {
    font-size: clamp(30px, 10vw, 80px);
    margin: 0;
    text-shadow: 0 0 30px currentColor;
}

#alert p {
    font-size: clamp(16px, 5vw, 40px);
    margin: 10px 0;
}

.about-btn {
    /* styled by .topbar-btn; keep class for selectors */
}

/* ═══════════════════ SETTINGS BUTTON ═══════════════════ */
.settings-btn {
    /* styled by .topbar-btn; keep class for JS */
}

.settings-btn:hover {
    /* hover handled by .topbar-btn */
}

/* ═══════════════════ PAIRS SELECTION BUTTON ═══════════════════ */
.pairs-btn {
    /* styled by .topbar-btn; keep class for JS */
}

.pairs-btn:hover {
    /* hover handled by .topbar-btn */
}

/* ═══════════════════ SETTINGS PANEL ═══════════════════ */
.overlay-bg {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    z-index: 999;
}

.overlay-bg.open {
    display: block;
}

.settings-panel {
    display: none;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: #001100;
    border: 2px solid var(--green);
    padding: 20px;
    border-radius: 15px;
    z-index: 1000;
    min-width: 300px;
    max-width: 90vw;
    max-height: 90vh;
    overflow-y: auto;
}

.settings-panel.open {
    display: block;
}

.settings-panel h3 {
    color: var(--green);
    margin-top: 0;
    text-align: center;
}

.settings-panel label {
    display: block;
    color: var(--green);
    margin: 10px 0 5px;
}

.settings-panel input[type="range"] {
    width: 100%;
    accent-color: var(--green);
}

.settings-panel input[type="checkbox"] {
    margin-right: 10px;
    accent-color: var(--green);
}

.settings-panel select {
    width: 100%;
    padding: 8px;
    background: #000;
    color: var(--green);
    border: 1px solid var(--green);
    border-radius: 5px;
}

.settings-panel .close-btn {
    background: var(--green);
    color: #000;
    border: none;
    padding: 10px 20px;
    border-radius: 8px;
    cursor: pointer;
    margin-top: 15px;
    width: 100%;
    font-weight: bold;
    font-size: 16px;
    transition: all 0.2s;
}

.settings-panel .close-btn:hover {
    background: #0a0;
}

.threshold-value {
    color: var(--green);
    float: right;
    font-weight: bold;
}

/* ═══════════════════ RESPONSIVE ═══════════════════ */
@media (max-width: 600px) {
    .add-panel {
        flex-direction: column;
        align-items: center;
    }

    .add-panel input {
        width: 100%;
        max-width: none;
    }

    .add-panel button {
        width: 100%;
    }

    th, td {
        padding: 5px 3px;
        font-size: 11px;
    }

    .topbar-btn {
        height: 40px;
        padding: 0 10px;
        font-size: 13px;
    }
}

/* Custom Modal Styles */
.custom-modal-content {
    background-color: rgba(0, 0, 0, 0.9); /* Darker background */
    color: #0f0; /* Matrix green text */
    border: 1px solid #0f0; /* Green border */
    box-shadow: 0 0 15px rgba(0, 255, 0, 0.7); /* Green glow effect */
}

.custom-modal-header {
    border-bottom: 1px solid #0f0; /* Green separator */
}

.custom-modal-header .modal-title {
    color: #0f0; /* Green title text */
}

.custom-btn-close {
    filter: invert(1) grayscale(1) brightness(2); /* Make close button green */
}

.btn-close:focus {
    box-shadow: 0 0 0 0.25rem rgba(0, 255, 0, 0.25); /* Green focus outline */
}

.custom-modal-body {
    /* Optional: padding adjustments */
    display: flex;
    flex-direction: column;
}

.custom-modal-body label {
    display: block;
    width: 100%;
    margin: 10px 0 5px;
    color: var(--green);
}

.custom-modal-body input[type="range"] {
    width: 100%;
    display: block;
    margin-bottom: 10px;
    accent-color: var(--green);
}

.custom-modal-body input[type="checkbox"] {
    margin-right: 10px;
    accent-color: var(--green);
}

.custom-modal-body select {
    width: 100%;
    display: block;
    padding: 8px;
    background: #000;
    color: var(--green);
    border: 1px solid var(--green);
    border-radius: 4px;
    margin-bottom: 10px;
}

.custom-modal-body hr {
    width: 100%;
    margin: 15px 0;
}

.custom-modal-body h4 {
    width: 100%;
    margin: 10px 0;
}

.custom-modal-body .paid-only {
    display: flex;
    flex-direction: column;
    width: 100%;
}

.custom-modal-body .paid-only label {
    display: flex;
    align-items: center;
    margin: 5px 0;
}

.custom-modal-body p {
    width: 100%;
    display: block;
    margin: 10px 0;
}

.custom-modal-body h3 {
    color: #0f0; /* Green for h3 inside modal */
}

.custom-modal-body ul {
    list-style-type: square; /* Square bullet points */
    padding-left: 20px;
}

.custom-modal-body ul li {
    margin-bottom: 5px;
}

.custom-modal-footer {
    border-top: 1px solid #0f0; /* Green separator */
    justify-content: center; /* Center buttons */
}

.custom-btn {
    background-color: #0f0; /* Green background for buttons */
    color: #000; /* Black text for buttons */
    border: 1px solid #0f0; /* Green border for buttons */
    margin: 0 5px;
}

.custom-btn:hover {
    background-color: #0a0; /* Darker green on hover */
    border-color: #0a0;
    color: #fff; /* White text on hover */
}

/* Specific button styles if needed */
.btn-secondary.custom-btn {
    background-color: #0f0; /* Ensure all custom buttons are green */
    border-color: #0f0;
    color: #000;
}

.btn-primary.custom-btn {
    background-color: #0f0; /* Ensure all custom buttons are green */
    border-color: #0f0;
    color: #000;
}

/* ═══════════════════ ICONS STYLING ═══════════════════ */
.icon-inline {
    display: inline-block;
    width: 1em;
    height: 1em;
    vertical-align: middle;
    margin-right: 0.3em;
    color: var(--green);
    filter: drop-shadow(0 0 4px var(--green));
    stroke-width: 2;
}

.icon-inline:last-child {
    margin-right: 0;
}

button .icon-inline,
.btn .icon-inline {
    margin-right: 5px !important;
}

button .icon-inline:last-child,
.btn .icon-inline:last-child {
    margin-right: 0;
    margin-left: 0.4em;
}

.icon-alert {
    width: 1.2em;
    height: 1.2em;
    animation: pulse-glow 1.5s ease-in-out infinite;
}

@keyframes pulse-glow {
    0%, 100% {
        filter: drop-shadow(0 0 4px var(--green));
        opacity: 1;
    }
    50% {
        filter: drop-shadow(0 0 12px var(--green));
        opacity: 0.8;
    }
}

/* Icon glow on hover for interactive elements */
button:hover .icon-inline,
.btn:hover .icon-inline,
.topbar-btn:hover .icon-inline {
    filter: drop-shadow(0 0 8px var(--green));
    transition: filter 0.2s ease;
}

/* Исключения для кнопок с черным текстом - иконки остаются черными при hover */
.close-btn:hover .icon-inline,
.settings-panel .close-btn:hover .icon-inline,
.add-panel button:hover .icon-inline,
.btn-secondary.custom-btn:hover .icon-inline,
.btn-primary.custom-btn:hover .icon-inline,
#pairsModal .btn-sm:first-of-type:hover .icon-inline,
button[style*="background:#0f0"]:hover .icon-inline,
button[style*="background:#f60"]:hover .icon-inline,
button[style*="background:var(--green)"]:hover .icon-inline,
.price-filter-content button:hover .icon-inline {
    filter: none !important;
    color: #000 !important;
    stroke: #000 !important;
}

/* Иконки в кнопках с цветным фоном (Apply, Reset) - без свечения */
button[style*="background:#0f0"] .icon-inline,
button[style*="background:#f60"] .icon-inline,
button[style*="background:var(--green)"] .icon-inline {
    filter: none !important;
    color: #000 !important;
    stroke: #000 !important;
}

/* Иконки в кнопках с черным текстом - без свечения */
.price-filter-content button .icon-inline {
    filter: none !important;
    color: #000 !important;
    stroke: #000 !important;
    margin: 0;
    vertical-align: middle;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* Иконки в зеленых кнопках с черным текстом - черные иконки */
.close-btn .icon-inline,
.settings-panel .close-btn .icon-inline,
.add-panel button .icon-inline,
.btn-secondary.custom-btn .icon-inline,
.btn-primary.custom-btn .icon-inline,
#pairsModal .btn-sm:first-of-type .icon-inline {
    filter: none !important;
    color: #000 !important;
    stroke: #000 !important;
}

/* Иконки в кнопках с зеленым текстом на темном фоне - зеленые иконки */
#pairsModal .btn-sm:nth-of-type(2) .icon-inline {
    filter: drop-shadow(0 0 4px var(--green)) !important;
    color: #00FF00 !important;
    stroke: #00FF00 !important;
}

#pairsModal .btn-sm:nth-of-type(3) .icon-inline {
    filter: drop-shadow(0 0 4px #00FF88) !important;
    color: #00FF88 !important;
    stroke: #00FF88 !important;
}

/* Иконки в topbar кнопках - зеленые иконки (уже правильно, но убеждаемся) */
.topbar-btn .icon-inline {
    color: var(--green) !important;
    stroke: var(--green) !important;
    filter: drop-shadow(0 0 4px var(--green));
}

/* ═══════════════════ PAIRS MODAL MULTI-COLUMN LAYOUT ═══════════════════ */
#pairsListContainer {
    display: grid;
    grid-template-columns: 1fr;
    gap: 4px;
}

/* 2 columns on tablets */
@media (min-width: 576px) {
    #pairsListContainer {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* 3 columns on medium screens */
@media (min-width: 768px) {
    #pairsListContainer {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* 4 columns on large screens */
@media (min-width: 992px) {
    #pairsListContainer {
        grid-template-columns: repeat(4, 1fr);
    }
}

.pair-item {
    display: block;
    padding: 5px;
    cursor: pointer;
    transition: all 0.2s;
    border-radius: 4px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.pair-item:hover {
    background: rgba(0, 255, 0, 0.05);
}

/* ═══════════════════ PAIRS MODAL BUTTONS - MATRIX GREEN VARIATIONS ═══════════════════ */
/* Select All button - bright green */
#pairsModal .btn-sm:first-of-type {
    background: #00FF00 !important; /* var(--green) */
    color: #000 !important;
    border: 1px solid #00FF00 !important;
}

#pairsModal .btn-sm:first-of-type:hover {
    background: #00CC00 !important; /* darker green */
    border-color: #00CC00 !important;
    color: #000 !important;
}

/* Deselect All button - medium green */
#pairsModal .btn-sm:nth-of-type(2) {
    background: rgba(0, 255, 0, 0.25) !important; /* semi-transparent green */
    color: #00FF00 !important;
    border: 1px solid rgba(0, 255, 0, 0.6) !important;
}

#pairsModal .btn-sm:nth-of-type(2):hover {
    background: rgba(0, 255, 0, 0.4) !important;
    border-color: rgba(0, 255, 0, 0.8) !important;
    color: #00FF00 !important;
}

/* Reset to Full List button - dark green with border */
#pairsModal .btn-sm:nth-of-type(3) {
    background: #001100 !important; /* dark green background */
    color: #00FF88 !important; /* var(--pump) - lighter green text */
    border: 1px solid rgba(0, 255, 0, 0.55) !important;
}

#pairsModal .btn-sm:nth-of-type(3):hover {
    background: rgba(0, 255, 0, 0.16) !important;
    border-color: rgba(0, 255, 0, 0.9) !important;
    color: #00FF00 !important;
}