/* Terminal-style Stock Ranker */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --bg: #0a0a0a;
    --fg: #c0c0c0;
    --fg-dim: #606060;
    --fg-bright: #ffffff;
    --green: #00cc00;
    --green-dim: #004400;
    --red: #cc0000;
    --red-dim: #440000;
    --yellow: #cccc00;
    --cyan: #00cccc;
    --blue: #0066cc;
    --selection: #333333;
    --border: #333333;
}

body {
    background: var(--bg);
    color: var(--fg);
    font-family: 'SF Mono', 'Consolas', 'Monaco', monospace;
    font-size: 13px;
    line-height: 1.4;
    height: 100vh;
    overflow: hidden;
}

#app {
    display: flex;
    flex-direction: column;
    height: 100vh;
}

/* Header */
#header {
    padding: 8px 12px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

#header-row {
    display: flex;
    align-items: center;
    gap: 16px;
}

#header h1 {
    font-size: 14px;
    font-weight: normal;
    color: var(--cyan);
}

#header label {
    color: var(--fg-dim);
}

#header select,
#header input {
    background: var(--bg);
    color: var(--fg-bright);
    border: 1px solid var(--border);
    padding: 2px 6px;
    font-family: inherit;
    font-size: 12px;
}

#header select:focus,
#header input:focus {
    outline: 1px solid var(--cyan);
}

#status {
    color: var(--yellow);
    margin-left: auto;
}

/* Main Table */
#main {
    flex: 1;
    overflow: auto;
}

#stock-table {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
}

#stock-table th,
#stock-table td {
    padding: 4px 8px;
    text-align: left;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    border-bottom: 1px solid var(--border);
}

#stock-table th {
    background: #111;
    color: var(--fg-dim);
    font-weight: normal;
    position: sticky;
    top: 0;
    z-index: 1;
}

#stock-table th.sortable {
    cursor: pointer;
}

#stock-table th.sortable:hover {
    color: var(--fg-bright);
}

.sort-arrow {
    color: var(--cyan);
}

/* Column widths */
.col-rank { width: 50px; }
.col-ticker { width: 80px; }
.col-name { width: 200px; }
.col-gain { width: 90px; }
.col-perf { width: 100px; }
.col-start { width: 140px; }
.col-end { width: 140px; }
.col-ipo { width: 60px; }
.col-sector { width: 140px; }
.col-industry { width: 160px; }
.col-country { width: 100px; }


/* Row states */
#stock-table tbody tr {
    cursor: pointer;
}

#stock-table tbody tr:hover {
    background: var(--selection);
}

#stock-table tbody tr.selected {
    background: var(--blue);
    color: var(--fg-bright);
}

#stock-table tbody tr.watched td:first-child::before {
    content: '* ';
    color: var(--yellow);
}

#stock-table tbody tr.portfolio td:first-child::before {
    content: '+ ';
    color: var(--green);
}

/* If both watched and portfolio, show both markers */
#stock-table tbody tr.watched.portfolio td:first-child::before {
    content: '*+ ';
}

/* Column selection */
#stock-table th.col-selected {
    background: var(--blue);
    color: var(--fg-bright);
}

#stock-table td.cell-selected {
    outline: 2px solid var(--cyan);
    outline-offset: -2px;
}

/* Performance colors */
.gain-pos { color: var(--green); }
.gain-neg { color: var(--red); }

.gain-cell {
    padding: 2px 6px;
    border-radius: 2px;
}

.gain-cell.positive {
    background: var(--green-dim);
    color: var(--green);
}

.gain-cell.negative {
    background: var(--red-dim);
    color: var(--red);
}

/* Footer */
#footer {
    padding: 6px 12px;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    color: var(--fg-dim);
    font-size: 12px;
    flex-shrink: 0;
}

#help {
    color: var(--cyan);
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
}

.hidden {
    display: none !important;
}

/* Filter Popup */
.popup {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 200;
}

.popup-content {
    background: var(--bg);
    border: 1px solid var(--cyan);
    padding: 16px;
    min-width: 280px;
}

#filter-title {
    color: var(--cyan);
    margin-bottom: 12px;
    font-weight: bold;
}

#filter-input {
    width: 100%;
    background: #111;
    border: 1px solid var(--border);
    color: var(--fg-bright);
    padding: 8px;
    font-family: inherit;
    font-size: 14px;
    margin-bottom: 12px;
}

#filter-input:focus {
    outline: 1px solid var(--cyan);
}

#filter-op {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 12px;
}

.op-option {
    padding: 6px 10px;
    cursor: pointer;
    color: var(--fg-dim);
}

.op-option:hover,
.op-option.selected {
    background: var(--selection);
    color: var(--fg-bright);
}

.popup-hint {
    color: var(--fg-dim);
    font-size: 11px;
}

.modal.hidden {
    display: none;
}

.modal-content {
    background: var(--bg);
    border: 1px solid var(--border);
    width: 90%;
    max-width: 1000px;
    height: 70%;
    display: flex;
    flex-direction: column;
}

#graph-header {
    padding: 8px 12px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

#graph-title {
    color: var(--cyan);
}

.close-btn {
    cursor: pointer;
    color: var(--fg-dim);
    font-size: 20px;
}

.close-btn:hover {
    color: var(--fg-bright);
}

#graph-container {
    flex: 1;
    padding: 12px;
    position: relative;
}

#graph-canvas {
    width: 100% !important;
    height: 100% !important;
}

#graph-loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: var(--yellow);
    z-index: 10;
    background: var(--bg);
    padding: 10px 20px;
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg);
}

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

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