/*
 * ClaudeTrader v2 — Dashboard stylesheet.
 *
 * Dark theme, V1-parity design pass 2026-05-11.
 * dashboard-design-agent owns this file (lane-def 2026-05-11).
 *
 * Design targets:
 *   - Background  #0e1117 (very dark near-black, matches V1)
 *   - Cards       #161b22 (dark charcoal panel)
 *   - Card border #30363d (subtle dark separator)
 *   - Text        #e6edf3 (near-white primary)
 *   - Muted text  #9aa0a6 (muted gray)
 *   - Success     #3fb950 (green — paper env / gains)
 *   - Danger      #f85149 (red — losses / stale)
 *   - Warning/Live #ff9800 (orange — live env)
 *   - Accent      #58a6ff (link-blue for interactive elements)
 *
 * CSP: style-src 'self' — this file is self-hosted; no inline style
 * attributes, no external stylesheets. Section partials use CSS classes
 * from this file instead of inline style="...".
 *
 * Banner: env-paper (green) / env-live (orange) per §2.6 D137.
 * Banner is load-bearing safety signal — do NOT weaken or remove.
 */

/* ==========================================================================
   Reset & base
   ========================================================================== */

*, *::before, *::after {
    box-sizing: border-box;
}

html, body {
    height: 100%;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
                 "Helvetica Neue", Arial, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    color: #e6edf3;
    background: #0e1117;
    margin: 0;
    padding: 0;
}

/* ==========================================================================
   Bootstrap overrides — dark-mode resets
   ========================================================================== */

/* Tables */
.table {
    color: #e6edf3;
    --bs-table-bg: transparent;
    --bs-table-striped-bg: rgba(255,255,255,0.03);
    --bs-table-hover-bg: rgba(255,255,255,0.06);
    --bs-table-border-color: #30363d;
}

.table thead th {
    color: #9aa0a6;
    border-bottom-color: #30363d;
    font-weight: 600;
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.table tbody td {
    border-color: #30363d;
    padding-top: 0.3rem;
    padding-bottom: 0.3rem;
    vertical-align: middle;
}

.table-borderless td,
.table-borderless th {
    border: none;
}

/* Badges — override Bootstrap defaults for dark background */
.badge.bg-light {
    background-color: #30363d !important;
    color: #e6edf3 !important;
    border: 1px solid #444c56;
}

.badge.bg-secondary {
    background-color: #444c56 !important;
}

/* Card component (Bootstrap) — dark variant */
.card {
    background-color: #161b22;
    border-color: #30363d;
    color: #e6edf3;
}

.card-header {
    background-color: #1c2128;
    border-bottom-color: #30363d;
}

/* Bootstrap text utilities */
.text-muted {
    color: #9aa0a6 !important;
}

.text-secondary {
    color: #9aa0a6 !important;
}

.text-dark {
    color: #e6edf3 !important;
}

/* Bootstrap bg-light used in sub-metric cells */
.bg-light {
    background-color: #1c2128 !important;
}

/* Form controls (not used in dashboard today; forward-compat) */
.form-control {
    background-color: #1c2128;
    border-color: #30363d;
    color: #e6edf3;
}

/* List group dark */
.list-group-item {
    background-color: transparent;
    border-color: #30363d;
    color: #e6edf3;
}

/* Alert (no-data state) */
.alert-secondary {
    background-color: #1c2128;
    border-color: #30363d;
    color: #9aa0a6;
}

/* code element */
code {
    color: #58a6ff;
    background: transparent;
}

/* Border utilities */
.border-bottom {
    border-bottom-color: #30363d !important;
}

.border-top {
    border-top-color: #30363d !important;
}

.border {
    border-color: #30363d !important;
}

.border-warning {
    border-color: #d29922 !important;
}

/* bg-warning bg-opacity-10 for halted bot cells */
.bg-warning.bg-opacity-10 {
    background-color: rgba(210, 153, 34, 0.1) !important;
}

/* ==========================================================================
   Layout — page wrap
   ========================================================================== */

.page-wrap {
    /* Full-viewport-width: V1 scales to viewport.
     * 1800px cap prevents stretched-flat look on ultra-wide monitors.
     * margin-auto centers on narrower viewports. */
    max-width: 1800px;
    margin: 0 auto;
    padding: 0 24px 40px;
}

/* ==========================================================================
   Environment banner (#env-banner)
   ========================================================================== */

/*
 * Load-bearing safety signal per §2.6 D137.
 * Green for paper / orange for live. Sticky, full-width, non-dismissable.
 * Colours are non-negotiable (operator-pinned 2026-05-11).
 *
 * Note: banner HTML uses class="env-paper" or "env-live" on #env-banner.
 * This works with CSP style-src 'self' (no inline <style> blocks).
 */
#env-banner {
    position: sticky;
    top: 0;
    z-index: 9999;
    text-align: center;
    padding: 7px 0;
    font-weight: 700;
    font-size: 1rem;
    width: 100%;
    user-select: none;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

#env-banner.env-paper {
    background: #28a745;
    color: #fff;
}

#env-banner.env-live {
    background: #ff9800;
    color: #fff;
}

/* ==========================================================================
   Header
   ========================================================================== */

header {
    padding: 16px 0 12px;
    border-bottom: 1px solid #30363d;
    margin-bottom: 20px;
}

header h1 {
    margin: 0 0 2px;
    font-size: 1.25rem;
    font-weight: 600;
    color: #e6edf3;
}

header p {
    margin: 0;
    color: #9aa0a6;
    font-size: 0.8rem;
}

/* ==========================================================================
   Instance section headers
   ========================================================================== */

.instance-section > h2,
#cross-instance > h2 {
    font-size: 0.75rem;
    font-weight: 700;
    color: #9aa0a6;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    padding: 6px 10px;
    background: #1c2128;
    border-left: 3px solid #30363d;
    border-radius: 0 4px 4px 0;
    margin-bottom: 12px;
}

/* Instance sections for live instances: orange accent */
.instance-section[data-class="live"] > h2 {
    border-left-color: #ff9800;
    color: #ff9800;
}

/* Instance sections for paper instances: green accent */
.instance-section[data-class="paper"] > h2 {
    border-left-color: #3fb950;
    color: #3fb950;
}

/* Cross-instance system health: muted */
#cross-instance > h2 {
    border-left-color: #444c56;
    color: #9aa0a6;
}

/* ==========================================================================
   Panel cards
   ========================================================================== */

.panel {
    background: #161b22;
    border: 1px solid #30363d;
    border-radius: 6px;
    padding: 12px 14px;
    overflow: hidden;
}

/* Deprecated .panel h3 kept for backward-compat; card-header used instead */
.panel h3 {
    margin: 0 0 8px;
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #9aa0a6;
    border-bottom: 1px solid #30363d;
    padding-bottom: 6px;
}

.card-header span.fw-semibold {
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    color: #9aa0a6;
}

/* Panel header timestamp */
.ts-label {
    font-size: 0.68rem;
    color: #6e7681;
}

/* "No snapshot." — dimmed italic */
.panel .missing,
.missing {
    color: #6e7681;
    font-style: italic;
    font-size: 0.8rem;
    margin: 4px 0 0;
}

/* ==========================================================================
   Metric tiles (account_summary, drawdown sub-cells)
   ========================================================================== */

/* Dark metric tile — replaces Bootstrap .bg-light.rounded.p-2 */
.metric-tile {
    background: #1c2128;
    border: 1px solid #30363d;
    border-radius: 5px;
    padding: 8px 10px;
    text-align: center;
}

.metric-tile .metric-label {
    font-size: 0.68rem;
    color: #9aa0a6;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 2px;
}

.metric-tile .metric-value {
    font-size: 1.05rem;
    font-weight: 700;
    color: #e6edf3;
    line-height: 1.2;
}

.metric-tile .metric-sub {
    font-size: 0.68rem;
    color: #6e7681;
    margin-top: 1px;
}

/* ==========================================================================
   Colour semantics
   ========================================================================== */

.text-gain,
.text-success { color: #3fb950 !important; }

.text-loss,
.text-danger  { color: #f85149 !important; }

/* Live env orange */
.text-live    { color: #ff9800 !important; }

/* Pending / placeholder  */
.text-pending { color: #6e7681; font-style: italic; font-size: 0.8rem; }

/* ==========================================================================
   Stat summary row (top-of-instance 6-up strip)
   ========================================================================== */

.stat-strip {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 16px;
}

.stat-strip .stat-cell {
    flex: 1 1 120px;
    background: #1c2128;
    border: 1px solid #30363d;
    border-radius: 5px;
    padding: 8px 12px;
}

.stat-strip .stat-cell .stat-label {
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #9aa0a6;
}

.stat-strip .stat-cell .stat-val {
    font-size: 1.15rem;
    font-weight: 700;
    color: #e6edf3;
    margin: 2px 0 0;
}

.stat-strip .stat-cell .stat-sub {
    font-size: 0.65rem;
    color: #6e7681;
    margin-top: 1px;
}

/* ==========================================================================
   Strategy statistics table (full row-per-strategy format)
   ========================================================================== */

.strategy-stats-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.82rem;
}

.strategy-stats-table thead th {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #9aa0a6;
    border-bottom: 2px solid #30363d;
    padding: 4px 8px;
}

.strategy-stats-table tbody td {
    padding: 5px 8px;
    border-bottom: 1px solid #21262d;
    color: #e6edf3;
}

.strategy-stats-table tbody tr:last-child td {
    border-bottom: none;
}

.strategy-stats-table .strategy-name {
    font-weight: 600;
    color: #e6edf3;
    white-space: nowrap;
}

/* ==========================================================================
   Bot status grid
   ========================================================================== */

.bot-cell {
    background: #1c2128;
    border: 1px solid #30363d;
    border-radius: 5px;
    padding: 8px 10px;
}

.bot-cell.halted {
    border-color: #d29922;
    background: rgba(210, 153, 34, 0.08);
}

.bot-cell .bot-name {
    font-size: 0.8rem;
    font-weight: 600;
    color: #e6edf3;
    word-break: break-word;
}

.bot-cell .bot-meta {
    font-size: 0.72rem;
    color: #9aa0a6;
    margin-top: 3px;
}

.bot-cell .bot-hb {
    font-size: 0.68rem;
    color: #6e7681;
    margin-top: 2px;
}

/* ==========================================================================
   Service health table
   ========================================================================== */

.svc-name {
    font-size: 0.78rem;
    font-weight: 600;
    word-break: break-word;
    max-width: 16rem;
}

/* ==========================================================================
   Charts
   ========================================================================== */

/* Wrapper to give canvas a defined height while allowing responsiveness */
.chart-wrap {
    position: relative;
    width: 100%;
}

.chart-wrap canvas {
    display: block;
    width: 100% !important;
}

/* Placeholder card for charts pending data backbone (D153/D154) */
.chart-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    background: #1c2128;
    border: 1px dashed #30363d;
    border-radius: 5px;
    padding: 24px 16px;
    text-align: center;
    color: #6e7681;
    font-size: 0.8rem;
}

.chart-placeholder .ph-label {
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #9aa0a6;
    margin-bottom: 6px;
}

/* Donut chart canvas — fixed square so donut renders correctly */
.donut-wrap {
    position: relative;
    width: 100%;
    max-width: 200px;
    margin: 0 auto;
}

/* ==========================================================================
   Section dividers
   ========================================================================== */

.section-label {
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #6e7681;
    margin-bottom: 4px;
    margin-top: 10px;
}

/* ==========================================================================
   Footer
   ========================================================================== */

footer {
    margin-top: 40px;
    padding-top: 12px;
    border-top: 1px solid #30363d;
    font-size: 0.72rem;
    color: #6e7681;
    text-align: center;
}

/* ==========================================================================
   Responsive tweaks
   ========================================================================== */

@media (max-width: 768px) {
    .page-wrap {
        padding: 0 12px 32px;
    }

    .stat-strip .stat-cell {
        flex: 1 1 45%;
    }
}
