/* ═══════════════════════════════════════════════════════════════
   MARKETSKI — Borland Turbo Pascal IDE Theme
   Inspired by Borland International IDEs, circa 1990-1995
   ═══════════════════════════════════════════════════════════════ */

@font-face {
    font-family: "Perfect DOS VGA 437";
    src: local("Perfect DOS VGA 437"), local("PerfectDOSVGA437");
}

:root {
    /* ── EGA/VGA 16-color palette ── */
    --black: #000000;
    --blue: #0000aa;
    --green: #00aa00;
    --cyan: #00aaaa;
    --red: #aa0000;
    --magenta: #aa00aa;
    --brown: #aa5500;
    --light-gray: #aaaaaa;
    --dark-gray: #555555;
    --light-blue: #5555ff;
    --light-green: #55ff55;
    --light-cyan: #55ffff;
    --light-red: #ff5555;
    --light-magenta: #ff55ff;
    --yellow: #ffff55;
    --white: #ffffff;

    /* ── Semantic aliases — Borland C++ screenshot-accurate ── */

    /* Backgrounds */
    --bg-desktop: var(--cyan); /* #00AAAA — the main content area is CYAN */
    --bg-window: var(--cyan); /* window bodies are also cyan */
    --bg-window-title: var(
        --light-gray
    ); /* #AAAAAA — title bar stripe like Borland */
    --bg-menu: #1c1c1c; /* near-black top menu bar */
    --bg-status: #1c1c1c; /* same dark for bottom status bar */
    --bg-dropdown: #2a2a2a; /* dropdown panels */
    --bg-table-hdr: var(--blue); /* #0000AA — table column headers */
    --bg-table-alt: #009999; /* slightly darker cyan for alt rows */
    --bg-input: var(--black);
    --bg-button: var(--green);
    --bg-button-danger: var(--red);
    --bg-dialog: var(--light-gray);
    --bg-scrollbar: var(--dark-gray);
    --bg-stat-box: #007777; /* darker cyan for stat counter boxes */

    /* Foregrounds */
    --fg-desktop: var(--yellow); /* yellow text on cyan bg — classic Borland */
    --fg-menu: var(--white); /* white text on dark menu bar */
    --fg-menu-hot: var(--yellow); /* hotkey highlight on dark bg */
    --fg-menu-active: var(--black); /* text when menu item highlighted green */
    --fg-window-border: var(--white); /* bright white borders on cyan */
    --fg-status: var(--white); /* white text on dark status bar */
    --fg-status-key: var(--black); /* text inside F-key badge */
    --fg-title: var(--black); /* black text on light-gray title bar */
    --fg-data: var(--white); /* main data text, white on cyan */
    --fg-label: var(--yellow); /* labels in yellow */
    --fg-value: var(--white); /* values in white */
    --fg-link: var(--white); /* links: white, underlined on hover */
    --fg-error: var(--light-red);
    --fg-insider: var(--light-red);
    --fg-ok: var(--light-green);
    --fg-dim: var(--dark-gray);
    --fg-help-heading: var(--yellow);
    --fg-help-key: var(--yellow);

    --font-main:
        "Perfect DOS VGA 437", "Fixedsys", "Terminal", "Courier New",
        "Lucida Console", monospace;
    --font-size: 16px;
    --cell-h: 22px;
}

/* ── Reset ── */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html,
body {
    height: 100%;
    overflow: hidden;
}

body {
    font-family: var(--font-main);
    font-size: var(--font-size);
    font-weight: bold;
    line-height: 1.35;
    background: var(--bg-desktop);
    color: var(--fg-desktop);
    cursor: default;
    -webkit-font-smoothing: none;
    -moz-osx-font-smoothing: unset;
    text-rendering: optimizeSpeed;
}

a {
    color: var(--fg-link);
    text-decoration: none;
}
a:hover {
    color: var(--yellow);
    text-decoration: underline;
}

/* ════════════════════════════════════════════
   MENU BAR — top row
   ════════════════════════════════════════════ */

.menubar {
    display: flex;
    align-items: center;
    height: var(--cell-h);
    background: var(--bg-menu);
    color: var(--fg-menu);
    padding: 0 2px;
    position: relative;
    z-index: 100;
    user-select: none;
    flex-shrink: 0;
}

.menubar-brand {
    padding: 0 10px;
    color: var(--yellow);
    font-weight: bold;
    letter-spacing: 2px;
    border-right: 1px solid #444;
    margin-right: 4px;
}

.menubar-brand .brand-icon {
    color: var(--light-green);
}

.menubar-items {
    display: flex;
    list-style: none;
    height: 100%;
}

.menubar-item {
    position: relative;
}

.menubar-item > a {
    display: flex;
    align-items: center;
    height: var(--cell-h);
    padding: 0 12px;
    color: var(--fg-menu);
    text-decoration: none;
}

.menubar-item > a:hover,
.menubar-item > a.active {
    background: var(--green);
    color: var(--black);
}

.menubar-item > a .hotkey {
    color: var(--fg-menu-hot);
    text-decoration: underline;
}

.menubar-item > a:hover .hotkey,
.menubar-item > a.active .hotkey {
    color: var(--black);
    text-decoration: underline;
}

/* ── Dropdown menus ── */
.menubar-item .dropdown {
    display: none;
    position: absolute;
    top: var(--cell-h);
    left: 0;
    min-width: 220px;
    background: var(--bg-dropdown);
    border: 1px solid #555;
    border-top: none;
    box-shadow: 3px 3px 0 var(--black);
    z-index: 200;
}

.menubar-item:hover .dropdown {
    display: block;
}

.dropdown a {
    display: block;
    padding: 3px 14px;
    color: var(--white);
    white-space: nowrap;
    text-decoration: none;
}

.dropdown a:hover {
    background: var(--green);
    color: var(--black);
    text-decoration: none;
}

.dropdown a .hotkey {
    text-decoration: underline;
}

.dropdown .separator {
    height: 1px;
    background: #555;
    margin: 3px 6px;
}

.dropdown .shortcut {
    float: right;
    color: var(--light-gray);
    margin-left: 24px;
}

/* ════════════════════════════════════════════
   STATUS BAR — bottom row
   ════════════════════════════════════════════ */

.statusbar {
    display: flex;
    align-items: center;
    height: var(--cell-h);
    background: var(--bg-status);
    color: var(--fg-status);
    padding: 0 4px;
    flex-shrink: 0;
    user-select: none;
}

.statusbar-keys {
    display: flex;
    gap: 4px;
}

.statusbar-key {
    display: flex;
    align-items: center;
}

.statusbar-key .key {
    background: var(--light-gray);
    color: var(--black);
    padding: 0 5px;
    margin-right: 1px;
    font-weight: bold;
}

.statusbar-key .label {
    color: var(--white);
    padding-right: 10px;
}

.statusbar-spacer {
    flex: 1;
}

.statusbar-info {
    padding: 0 8px;
    color: var(--light-gray);
}

/* ════════════════════════════════════════════
   DESKTOP — main content area
   ════════════════════════════════════════════ */

.desktop {
    flex: 1;
    overflow: auto;
    background: var(--bg-desktop);
    position: relative;
}

.app-shell {
    display: flex;
    flex-direction: column;
    height: 100vh;
    min-height: 100vh;
}

/* ════════════════════════════════════════════
   WINDOW — Borland-style panel
   ════════════════════════════════════════════ */

.window {
    margin: 8px;
    border: 2px solid var(--fg-window-border);
    background: var(--bg-window);
    position: relative;
    display: flex;
    flex-direction: column;
    min-height: 0;
    box-shadow: 2px 2px 0 rgba(0, 0, 0, 0.5);
}

.window::before {
    content: "╔" attr(data-title) "╗";
    /* pseudo-element trick won't work for dynamic titles, using .window-title instead */
    display: none;
}

.window-title {
    background: var(--bg-window-title);
    color: var(--fg-title);
    text-align: center;
    padding: 0 12px;
    height: var(--cell-h);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    position: relative;
    flex-shrink: 0;
}

.window-title .close-btn {
    position: absolute;
    left: 4px;
    color: var(--fg-title);
    font-weight: bold;
    cursor: pointer;
    padding: 0 4px;
}

.window-title .zoom-btn {
    position: absolute;
    right: 4px;
    color: var(--fg-title);
    cursor: pointer;
    padding: 0 4px;
}

.window-number {
    position: absolute;
    right: 8px;
    color: var(--fg-title);
}

.window-body {
    padding: 8px 12px;
    flex: 1;
    overflow: auto;
    color: var(--fg-data);
}

/* ── Multiple windows layout ── */
.window-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0;
}

.window-grid .window {
    margin: 4px;
}

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

/* ════════════════════════════════════════════
   TABLES — DOS-style data grids
   ════════════════════════════════════════════ */

.dos-table {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--font-size);
}

.dos-table thead th {
    background: var(--bg-table-hdr); /* dark blue header on cyan body */
    color: var(--white);
    padding: 2px 10px;
    text-align: left;
    font-weight: bold;
    white-space: nowrap;
    border-bottom: 2px solid var(--light-cyan);
    border-right: 1px solid #0000cc;
    position: sticky;
    top: 0;
    z-index: 10;
}

.dos-table tbody td {
    padding: 2px 10px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.15);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 400px;
    color: var(--white);
}

.dos-table tbody tr:nth-child(even) {
    background: var(--bg-table-alt); /* slightly darker cyan */
}

.dos-table tbody tr:hover {
    background: var(--yellow);
    color: var(--black);
}

.dos-table tbody tr:hover td {
    color: var(--black);
}

.dos-table tbody tr:hover a {
    color: var(--black);
}

.dos-table tbody tr:hover .insider-badge {
    background: var(--red);
    color: var(--white);
}

.dos-table tbody tr:hover .wallet-addr {
    color: var(--black);
}

.dos-table tbody tr:hover .usd,
.dos-table tbody tr:hover .pct,
.dos-table tbody tr:hover .timestamp-col {
    color: var(--black);
}

/* ════════════════════════════════════════════
   STATS BOXES — dashboard counters
   ════════════════════════════════════════════ */

.stats-row {
    display: flex;
    gap: 0;
    flex-wrap: wrap;
}

.stat-box {
    flex: 1;
    min-width: 140px;
    margin: 4px;
    border: 2px solid var(--white);
    background: var(--bg-stat-box);
    text-align: center;
    padding: 10px 4px;
}

.stat-box .stat-value {
    font-size: 30px;
    font-weight: bold;
    color: var(--yellow);
    line-height: 1.2;
}

.stat-box .stat-label {
    color: var(--light-cyan);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-top: 2px;
}

.stat-box.insider .stat-value {
    color: var(--light-red);
}

/* ════════════════════════════════════════════
   BADGES & TAGS
   ════════════════════════════════════════════ */

.insider-badge {
    background: var(--red);
    color: var(--yellow);
    padding: 0 6px;
    font-weight: bold;
    font-size: 12px;
    letter-spacing: 1px;
}

.badge-ok {
    color: var(--fg-ok);
}

.badge-warn {
    color: var(--yellow);
}

.badge-danger {
    color: var(--fg-error);
}

.wallet-addr {
    font-family: var(--font-main);
    color: var(--yellow);
    letter-spacing: 0.5px;
}

.usd {
    color: var(--white);
}

.pct {
    color: var(--light-green);
}

.timestamp-col {
    color: var(--light-cyan);
}

/* ════════════════════════════════════════════
   BUTTONS — DOS dialog buttons
   ════════════════════════════════════════════ */

.btn {
    display: inline-block;
    padding: 2px 18px;
    font-family: var(--font-main);
    font-size: var(--font-size);
    font-weight: bold;
    cursor: pointer;
    border: none;
    user-select: none;
    text-decoration: none;
}

.btn-primary {
    background: var(--green);
    color: var(--black);
    box-shadow: 2px 2px 0 var(--black);
}

.btn-primary:hover {
    background: var(--light-green);
    color: var(--black);
    text-decoration: none;
}

.btn-primary:active {
    box-shadow: none;
    transform: translate(2px, 2px);
}

.btn-danger {
    background: var(--red);
    color: var(--yellow);
    box-shadow: 2px 2px 0 var(--black);
}

.btn-danger:hover {
    background: var(--light-red);
    color: var(--black);
    text-decoration: none;
}

.btn-secondary {
    background: var(--blue);
    color: var(--white);
    box-shadow: 2px 2px 0 var(--black);
}

.btn-secondary:hover {
    background: var(--light-blue);
    color: var(--white);
    text-decoration: none;
}

.btn .hotkey {
    text-decoration: underline;
}

/* ════════════════════════════════════════════
   DIALOG BOX — modal-like panels
   ════════════════════════════════════════════ */

.dialog {
    border: 2px solid #888;
    background: var(--bg-dialog);
    color: var(--black);
    box-shadow: 4px 4px 0 var(--black);
    max-width: 600px;
    margin: 16px auto;
}

.dialog-title {
    background: var(--blue);
    color: var(--white);
    text-align: center;
    padding: 2px 8px;
    font-weight: bold;
}

.dialog-body {
    padding: 12px 16px;
    color: var(--black);
}

.dialog-body code {
    background: var(--dark-gray);
    color: var(--white);
    padding: 1px 5px;
}

.dialog-body pre {
    background: var(--dark-gray);
    color: var(--light-green);
    padding: 6px 10px;
    margin-top: 4px;
}

.dialog-buttons {
    text-align: center;
    padding: 8px;
    display: flex;
    justify-content: center;
    gap: 16px;
}

/* ════════════════════════════════════════════
   FIELDSET — config groups
   ════════════════════════════════════════════ */

.config-group {
    margin-bottom: 14px;
}

.config-group-title {
    color: var(--fg-label);
    border-bottom: 1px solid var(--cyan);
    padding-bottom: 2px;
    margin-bottom: 6px;
    font-weight: bold;
}

.config-group-foot {
    color: var(--light-cyan);
    margin-top: 4px;
}

.config-row {
    display: flex;
    padding: 2px 0;
}

.config-key {
    color: var(--light-cyan);
    width: 300px;
    flex-shrink: 0;
}

.config-val {
    color: var(--yellow);
    font-weight: bold;
}

/* Editable config form layout */
.config-field-row {
    display: grid;
    grid-template-columns: 280px 140px 1fr;
    align-items: center;
    gap: 8px;
    padding: 3px 0;
}

.config-field-label {
    flex-shrink: 0;
}

.config-field-desc {
    color: var(--dark-gray);
    font-size: 0.9em;
}

.dos-input {
    background: var(--bg-input);
    color: var(--yellow);
    border: 1px solid var(--light-cyan);
    font-family: inherit;
    font-size: inherit;
    font-weight: bold;
    padding: 1px 4px;
    width: 130px;
    text-align: right;
}

.dos-input:focus {
    outline: none;
    border-color: var(--yellow);
    color: var(--white);
}

/* ════════════════════════════════════════════
   HELP PAGE — Borland help viewer
   ════════════════════════════════════════════ */

.help-container {
    display: flex;
    height: 100%;
    min-height: 0;
}

.help-index {
    width: 220px;
    flex-shrink: 0;
    border-right: 2px solid var(--white);
    overflow-y: auto;
    padding: 4px 0;
    background: var(
        --blue
    ); /* dark blue sidebar — contrasts with cyan content */
}

.help-index a {
    display: block;
    padding: 2px 12px;
    color: var(--white);
    white-space: nowrap;
    text-decoration: none;
}

.help-index a:hover,
.help-index a.active {
    background: var(--green);
    color: var(--black);
    text-decoration: none;
}

.help-index .section-head {
    color: var(--yellow);
    padding: 8px 10px 2px;
    font-weight: bold;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 1px;
    border-top: 1px solid #0044aa;
    margin-top: 2px;
}

.help-content {
    flex: 1;
    overflow-y: auto;
    padding: 12px 20px;
}

.help-content h2 {
    color: var(--yellow);
    border-bottom: 2px solid var(--blue);
    padding-bottom: 4px;
    margin: 16px 0 8px 0;
    font-size: 16px;
}

.help-content h2:first-child {
    margin-top: 0;
}

.help-content h3 {
    color: var(--white);
    margin: 12px 0 4px 0;
    font-size: var(--font-size);
}

.help-content p {
    margin: 4px 0;
    color: var(--white);
}

.help-content .key-ref {
    color: var(--fg-help-key);
    font-weight: bold;
}

.help-content code {
    background: var(--black);
    color: var(--light-green);
    padding: 1px 6px;
}

.help-content pre {
    background: var(--black);
    color: var(--light-green);
    padding: 8px 12px;
    margin: 6px 0;
    border: 1px solid var(--dark-gray);
    overflow-x: auto;
}

.help-content ul {
    margin: 4px 0 4px 20px;
    color: var(--fg-data);
}

.help-content li {
    margin: 2px 0;
}

.help-content .def-term {
    color: var(--light-cyan);
    font-weight: bold;
}

.help-content .def-desc {
    color: var(--fg-data);
    margin-left: 24px;
    margin-bottom: 6px;
}

.help-content table {
    border-collapse: collapse;
    margin: 6px 0;
}

.help-content table th {
    background: var(--blue);
    color: var(--white);
    padding: 2px 10px;
    text-align: left;
}

.help-content table td {
    padding: 2px 10px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.2);
    color: var(--white);
}

/* ════════════════════════════════════════════
   MONITOR LOG — terminal output
   ════════════════════════════════════════════ */

.monitor-log {
    background: var(--black);
    color: var(--light-green);
    padding: 8px 12px;
    font-size: 13px;
    min-height: 120px;
    max-height: 400px;
    overflow-y: auto;
    border: 1px solid var(--dark-gray);
    white-space: pre-wrap;
    word-break: break-all;
}

.monitor-log .log-time {
    color: var(--dark-gray);
}

.monitor-log .log-info {
    color: var(--light-green);
}

.monitor-log .log-warn {
    color: var(--yellow);
}

.monitor-log .log-error {
    color: var(--light-red);
}

.monitor-log .log-insider {
    color: var(--light-red);
    font-weight: bold;
}

.monitor-controls {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 8px;
}

.monitor-status {
    color: var(--white);
}

.monitor-status.running {
    color: var(--light-green);
}

.monitor-status.idle {
    color: var(--dark-gray);
}

/* ═══ Spinner ═══ */
@keyframes blink-cursor {
    0%,
    100% {
        opacity: 1;
    }
    50% {
        opacity: 0;
    }
}

.spinner {
    display: inline-block;
    animation: blink-cursor 1s step-end infinite;
    color: var(--yellow);
}

/* ════════════════════════════════════════════
   CHART DISPLAY
   ════════════════════════════════════════════ */

.chart-frame {
    border: 1px solid var(--fg-window-border);
    background: var(--black);
    padding: 4px;
    margin: 8px 0;
    text-align: center;
}

.chart-frame img {
    max-width: 100%;
    height: auto;
    image-rendering: auto;
}

.chart-frame .no-chart {
    color: var(--dark-gray);
    padding: 32px;
    font-style: italic;
}

/* ════════════════════════════════════════════
   FILTER BAR
   ════════════════════════════════════════════ */

.filter-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 8px;
    padding: 4px 0;
}

.filter-bar label {
    color: var(--white);
}

.filter-bar select,
.filter-bar input[type="text"] {
    font-family: var(--font-main);
    font-size: 13px;
    font-weight: bold;
    background: var(--blue);
    color: var(--white);
    border: 1px solid var(--white);
    padding: 2px 8px;
}

.filter-bar .checkbox-label {
    display: flex;
    align-items: center;
    gap: 4px;
    color: var(--white);
    cursor: pointer;
}

.filter-bar input[type="checkbox"] {
    accent-color: var(--cyan);
}

/* ════════════════════════════════════════════
   WALLET DETAIL
   ════════════════════════════════════════════ */

.wallet-header {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 12px;
    flex-wrap: wrap;
}

.wallet-header .wallet-full-addr {
    color: var(--white);
    font-size: 13px;
    word-break: break-all;
}

.wallet-stats {
    display: flex;
    gap: 24px;
    flex-wrap: wrap;
}

.wallet-stat {
    text-align: center;
}

.wallet-stat .ws-value {
    font-size: 22px;
    font-weight: bold;
    color: var(--yellow);
}

.wallet-stat .ws-label {
    font-size: 11px;
    color: var(--light-cyan);
    text-transform: uppercase;
}

/* ════════════════════════════════════════════
   SCROLLBARS — DOS-styled
   ════════════════════════════════════════════ */

::-webkit-scrollbar {
    width: 14px;
    height: 14px;
}

::-webkit-scrollbar-track {
    background: var(--dark-gray);
    border-left: 1px solid var(--black);
}

::-webkit-scrollbar-thumb {
    background: var(--light-gray);
    border: 1px solid var(--black);
}

::-webkit-scrollbar-thumb:hover {
    background: var(--white);
}

::-webkit-scrollbar-corner {
    background: var(--dark-gray);
}

/* ════════════════════════════════════════════
   MISC
   ════════════════════════════════════════════ */

.empty-state {
    text-align: center;
    padding: 32px;
    color: var(--white);
    opacity: 0.7;
}

.empty-state .empty-icon {
    font-size: 32px;
    margin-bottom: 8px;
}

.text-right {
    text-align: right;
}

.text-center {
    text-align: center;
}

.mt-8 {
    margin-top: 8px;
}
.mb-8 {
    margin-bottom: 8px;
}
.mb-4 {
    margin-bottom: 4px;
}

.flash-msg {
    background: var(--green);
    color: var(--black);
    padding: 4px 14px;
    margin-bottom: 8px;
    font-weight: bold;
    border: 1px solid var(--white);
}

.flash-error {
    background: var(--red);
    color: var(--yellow);
}

/* ── General text in window body ── */
.window-body p {
    color: var(--white);
}

.window-body code {
    background: var(--blue);
    color: var(--light-cyan);
    padding: 1px 6px;
}

/* ═══ Print ═══ */
@media print {
    .menubar,
    .statusbar {
        display: none;
    }
    .desktop {
        overflow: visible;
    }
    body {
        background: white;
        color: black;
    }
}
