/*
Filename: wwwroot/css/site.css
Purpose: Dark UI styling for the dashboard layout, table and QR overlay (includes draggable splitter + resizable table columns).
Inputs: HTML structure from index.html.
Outputs: Styled UI.
Dependencies: index.html.
Processes: Full-viewport flex layout, internal scrolling on left, full-height chart on right, draggable divider, overlay QR display, signal coloring, column resizing handles.
AI-Instructions:
  - When editing this file, always output drop-in code (no diff markers, no +/- lines).
  - Always include the filename and full updated declarations in the response.
  - Keep this code as simple as possible. Comment everything perfectly understandible
  - Prefer Config-Class values over literals; ask if a new constant is needed.
*/

:root {
    color-scheme: dark;
    /* Core theme */
    --bg: #0b0f14;
    --panel: #0f1722;
    --panel2: #0c131d;
    --text: #e6edf3;
    --muted: #9fb0c0;
    --border: #1f2a3a;
    /* Signal colors */
    --signal-gray: #8b949e;
    --signal-yellow: #d29922;
    --signal-green: #2ea043;
    --signal-red: #f85149;
    /* Split defaults (desktop) */
    --split-left: 70%;
    /* QR button sizing (used in table "SourceURI" column) */
    --uri-btn-pad-y: 6px;
    --uri-btn-pad-x: 10px;
    --uri-btn-radius: 10px;
    --uri-btn-font: 12px;
    --uri-btn-domain-font: 11px;
    --uri-btn-gap: 8px;
    /* Responsive breakpoint: "tablet / small screen".
       If you want a different breakpoint, say which width you consider "tablet". */
    --bp-tablet: 900px;
}

* {
    box-sizing: border-box;
}

html, body {
    height: 100%;
}

body {
    margin: 0;
    font-family: system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    overflow: hidden;
}

/* App root: full viewport */
.app {
    height: 100vh;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

/* Top status bar */
.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    border-bottom: 1px solid var(--border);
    background: #070a0f;
    flex: 0 0 auto;
}

.title {
    font-weight: 700;
    letter-spacing: 0.2px;
}

.status {
    font-size: 12px;
    color: var(--muted);
}

/* Desktop split layout */
.layout {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
}

.panel {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.panel-left {
    flex: 0 0 var(--split-left);
    background: var(--panel2);
    min-width: 260px;
}

.panel-right {
    flex: 1 1 auto;
    background: var(--panel);
    min-width: 220px;
}

/* Splitter handle (desktop only; hidden on tablet via media query below) */
.splitter {
    flex: 0 0 8px;
    cursor: col-resize;
    background: #070a0f;
    border-left: 1px solid var(--border);
    border-right: 1px solid var(--border);
}

    .splitter:hover {
        background: #0a0f17;
    }

body.resizing {
    cursor: col-resize;
    user-select: none;
}

.panel-header {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    flex: 0 0 auto;
}

.panel-title {
    font-weight: 700;
}

.panel-subtitle {
    margin-top: 4px;
    font-size: 12px;
    color: var(--muted);
}

.table-wrap {
    flex: 1 1 auto;
    min-height: 0;
    overflow: auto;
}

/* Critical: fixed layout so col widths are respected and resizable */
.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
    table-layout: fixed;
}

    .data-table thead th {
        position: sticky;
        top: 0;
        background: #070a0f;
        z-index: 2;
        text-align: left;
        border-bottom: 1px solid var(--border);
        /* Right padding reserves space for the resizer handle */
        padding: 10px 18px 10px 8px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .data-table td {
        border-bottom: 1px solid var(--border);
        padding: 8px 8px;
        vertical-align: top;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .data-table tbody tr:hover {
        background: rgba(255,255,255,0.03);
    }

.cell-ellipsis {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Date: bold, date only */
.date-cell {
    font-weight: 800;
    white-space: nowrap;
}

/* Reason is the ONLY flexible column: wraps/clamps */
.reason {
    max-width: none;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Source "QR button with domain" (table cell content) */
.uri-cell {
    display: flex;
    align-items: center;
    min-width: 0; /* allows children to ellipsis instead of overflow */
}

/* Kept for backwards compatibility (not used by current JS anymore) */
.uri-domain {
    display: inline-block;
    min-width: 0;
    max-width: 100%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Bigger QR button + domain inside (tablet-friendly) */
.uri-btn {
    flex: 1 1 auto;
    min-width: 0;
    max-width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    gap: var(--uri-btn-gap);
    border: 1px solid var(--border);
    background: rgba(255,255,255,0.02);
    color: var(--text);
    padding: var(--uri-btn-pad-y) var(--uri-btn-pad-x);
    border-radius: var(--uri-btn-radius);
    font-size: var(--uri-btn-font);
    line-height: 1.2;
    cursor: pointer;
}

    .uri-btn:hover {
        background: rgba(255,255,255,0.06);
    }

.uri-btn-qr {
    flex: 0 0 auto;
    font-weight: 800;
    letter-spacing: 0.2px;
}

.uri-btn-domain {
    flex: 1 1 auto;
    min-width: 0;
    color: var(--muted);
    font-size: var(--uri-btn-domain-font);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Column resizer handle */
.col-resizer {
    position: absolute;
    top: 0;
    right: 0;
    width: 10px;
    height: 100%;
    cursor: col-resize;
    touch-action: none;
}

    .col-resizer::after {
        content: "";
        position: absolute;
        top: 0;
        right: 4px;
        width: 1px;
        height: 100%;
        background: rgba(255,255,255,0.06);
    }

    .col-resizer:hover::after {
        background: rgba(255,255,255,0.14);
    }

/* Badges */
.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 999px;
    border: 1px solid var(--border);
    font-size: 12px;
    white-space: nowrap;
}

.badge-yes {
    border-color: rgba(46,160,67,0.5);
    color: #8bdf9b;
}

.badge-no {
    border-color: rgba(248,81,73,0.4);
    color: #ff9b95;
}

/* Chart */
.chart-wrap {
    flex: 1 1 auto;
    min-height: 0;
    padding: 10px 12px;
    overflow: hidden;
}

#weeklyChart {
    width: 100% !important;
    height: 100% !important;
}

/* Signal styling */
.signal {
    padding: 1px 6px;
    border-radius: 999px;
    border: 1px solid var(--border);
    display: inline-block;
    line-height: 1.4;
    white-space: nowrap;
}

.signal-unset {
    color: var(--signal-gray);
    border-color: rgba(139,148,158,0.35);
}

.signal-neutral {
    color: var(--signal-yellow);
    border-color: rgba(210,153,34,0.35);
}

.signal-sell {
    color: var(--signal-red);
    border-color: rgba(248,81,73,0.35);
}

.signal-buy {
    color: var(--signal-green);
    border-color: rgba(46,160,67,0.35);
}

.signal-strong-buy {
    color: var(--signal-green);
    border-color: rgba(46,160,67,0.55);
    font-weight: 800;
}

.signal-stack {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.signal-row {
    display: flex;
    align-items: center;
    gap: 6px;
}

.signal-label {
    color: var(--muted);
    font-size: 11px;
    min-width: 58px;
    white-space: nowrap;
}

/* QR overlay */
.overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.88);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 18px;
    z-index: 100;
}

.hidden {
    display: none;
}

.overlay-content {
    width: min(720px, 95vw);
    background: #070a0f;
    border: 1px solid var(--border);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 12px 40px rgba(0,0,0,0.6);
}

.overlay-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 14px;
    border-bottom: 1px solid var(--border);
}

.overlay-title {
    font-weight: 700;
}

.overlay-body {
    padding: 14px;
    text-align: center;
}

#qrBox {
    display: inline-block;
    padding: 14px;
    background: white;
    border-radius: 10px;
}

.overlay-link {
    margin-top: 12px;
    font-size: 12px;
    color: var(--muted);
    word-break: break-all;
}

.overlay-actions {
    margin-top: 14px;
    display: flex;
    justify-content: center;
    gap: 10px;
}

.btn {
    border: 1px solid var(--border);
    background: transparent;
    color: var(--text);
    padding: 8px 12px;
    border-radius: 10px;
    cursor: pointer;
    font-weight: 600;
}

    .btn:hover {
        background: rgba(255,255,255,0.04);
    }

.btn-primary {
    background: rgba(46,160,67,0.15);
    border-color: rgba(46,160,67,0.5);
    text-decoration: none;
}

/* ---------------------------------------------------------------------------
   Tablet / small screen layout
   - Stack table over chart (better than a narrow split).
   - Hide the splitter.
   - Tighten padding slightly.
--------------------------------------------------------------------------- */
@media (max-width: 900px) {
    .topbar {
        padding: 8px 10px;
    }

    .layout {
        flex-direction: column;
    }

    .splitter {
        display: none;
    }

    .panel-left,
    .panel-right {
        min-width: 0;
        flex: 1 1 auto;
    }

    /* Give the table slightly more room by default */
    .panel-left {
        height: 56vh;
    }

    .panel-right {
        height: 44vh;
    }

    .panel-header {
        padding: 8px 10px;
    }

    .data-table {
        font-size: 11px;
    }

        .data-table thead th {
            padding: 8px 16px 8px 6px;
        }

        .data-table td {
            padding: 7px 6px;
        }

    /* Make the QR button still comfy on touch, but not too wide */
    .uri-btn {
        padding: 7px 10px;
    }

    /* Overlay: reduce padding so QR fits nicely */
    .overlay {
        padding: 12px;
    }

    .overlay-body {
        padding: 12px;
    }

    #qrBox {
        padding: 10px;
    }
}
