/* ============================================================
   JY COT Report Dashboard — Light Financial Theme
   ============================================================ */

:root {
    --cot-bg-primary: #ffffff;
    --cot-bg-secondary: #f6f8fa;
    --cot-bg-card: #ffffff;
    --cot-bg-card-hover: #f0f2f5;
    --cot-border: #d0d7de;
    --cot-border-light: #e8e8e8;
    --cot-text-primary: #1f2328;
    --cot-text-secondary: #656d76;
    --cot-text-muted: #8b949e;
    --cot-accent: #0969da;
    --cot-accent-dim: rgba(9, 105, 218, 0.1);
    /* Taiwan convention: red=up/long, green=down */
    --cot-up: #cf222e;
    --cot-up-bg: rgba(207, 34, 46, 0.08);
    --cot-down: #1a7f37;
    --cot-down-bg: rgba(26, 127, 55, 0.08);
    --cot-long: #cf222e;
    --cot-long-soft: rgba(207, 34, 46, 0.06);
    --cot-short: #0969da;
    --cot-short-soft: rgba(9, 105, 218, 0.06);
    --cot-net-positive: #cf222e;
    --cot-net-negative: #0969da;
    --cot-font-primary: 'Noto Sans TC', 'PingFang TC', -apple-system, BlinkMacSystemFont, sans-serif;
    --cot-font-mono: 'JetBrains Mono', 'SF Mono', 'Cascadia Code', 'Consolas', monospace;
    --cot-radius: 8px;
    --cot-radius-lg: 12px;
    --cot-shadow: 0 1px 3px rgba(0, 0, 0, 0.08), 0 1px 2px rgba(0, 0, 0, 0.04);
    --cot-shadow-md: 0 4px 6px rgba(0, 0, 0, 0.07), 0 2px 4px rgba(0, 0, 0, 0.04);
    --cot-transition: 0.2s ease;
}

/* ---- Reset & Base ---- */
.jy-cot-dashboard {
    font-family: var(--cot-font-primary);
    color: var(--cot-text-primary);
    background: var(--cot-bg-primary);
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 16px 40px;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

.jy-cot-dashboard * {
    box-sizing: border-box;
}

/* ---- Header ---- */
.jy-cot-header {
    padding: 16px 0;
    border-bottom: 1px solid var(--cot-border-light);
    margin-bottom: 16px;
}

.jy-cot-header-meta {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.jy-cot-report-date {
    font-size: 13px;
    color: var(--cot-text-secondary);
    font-family: var(--cot-font-mono);
}

.jy-cot-update-badge {
    font-size: 11px;
    color: var(--cot-accent);
    background: var(--cot-accent-dim);
    padding: 3px 10px;
    border-radius: 20px;
    font-weight: 500;
}

/* ---- Category Navigation ---- */
.jy-cot-nav {
    display: flex;
    gap: 6px;
    padding: 12px 0;
    overflow-x: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
    -webkit-overflow-scrolling: touch;
}

.jy-cot-nav::-webkit-scrollbar {
    display: none;
}

.jy-cot-nav-link {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border: 1px solid var(--cot-border);
    border-radius: 24px;
    background: var(--cot-bg-secondary);
    color: var(--cot-text-secondary);
    font-size: 14px;
    font-family: var(--cot-font-primary);
    text-decoration: none;
    white-space: nowrap;
    transition: all var(--cot-transition);
}

.jy-cot-nav-link:hover {
    border-color: var(--cot-accent);
    color: var(--cot-text-primary);
    background: var(--cot-bg-card);
}

.jy-cot-nav-link.active {
    border-color: var(--cot-accent);
    background: var(--cot-accent-dim);
    color: var(--cot-accent);
    font-weight: 600;
}

.jy-cot-nav-icon {
    font-size: 16px;
}

/* ---- Market Selector ---- */
.jy-cot-market-selector {
    padding: 8px 0 16px;
}

.jy-cot-market-group {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.jy-cot-market-link {
    padding: 8px 14px;
    border: 1px solid var(--cot-border-light);
    border-radius: var(--cot-radius);
    background: var(--cot-bg-secondary);
    color: var(--cot-text-secondary);
    font-size: 13px;
    font-family: var(--cot-font-primary);
    text-decoration: none;
    transition: all var(--cot-transition);
    display: flex;
    align-items: center;
    gap: 6px;
}

.jy-cot-market-link:hover {
    border-color: var(--cot-text-muted);
    color: var(--cot-text-primary);
    background: var(--cot-bg-card);
}

.jy-cot-market-link.active {
    border-color: var(--cot-accent);
    background: var(--cot-accent-dim);
    color: var(--cot-accent);
    font-weight: 600;
}

.jy-cot-market-short {
    font-family: var(--cot-font-mono);
    font-size: 11px;
    color: var(--cot-text-muted);
    opacity: 0.7;
}

.jy-cot-market-link.active .jy-cot-market-short {
    color: var(--cot-accent);
    opacity: 0.8;
}

/* ---- Content Area ---- */
.jy-cot-content {
    min-height: 400px;
}

/* ---- Loading ---- */
.jy-cot-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 80px 0;
    color: var(--cot-text-muted);
    font-size: 14px;
}

.jy-cot-spinner {
    width: 36px;
    height: 36px;
    border: 3px solid var(--cot-border);
    border-top-color: var(--cot-accent);
    border-radius: 50%;
    animation: jy-cot-spin 0.8s linear infinite;
    margin-bottom: 16px;
}

@keyframes jy-cot-spin {
    to { transform: rotate(360deg); }
}

/* ---- Error ---- */
.jy-cot-error {
    text-align: center;
    padding: 60px 0;
    color: var(--cot-text-muted);
}

.jy-cot-retry-btn {
    margin-top: 12px;
    padding: 8px 20px;
    border: 1px solid var(--cot-accent);
    border-radius: var(--cot-radius);
    background: transparent;
    color: var(--cot-accent);
    cursor: pointer;
    font-family: var(--cot-font-primary);
    font-size: 14px;
    transition: all var(--cot-transition);
}

.jy-cot-retry-btn:hover {
    background: var(--cot-accent-dim);
}

/* ---- Section Titles ---- */
.jy-cot-section-subtitle {
    font-size: 13px;
    color: var(--cot-text-muted);
    margin: 0 0 20px;
    font-family: var(--cot-font-mono);
}

/* ---- Gauge Row ---- */
.jy-cot-gauge-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 28px;
}

.jy-cot-gauge-card {
    background: var(--cot-bg-card);
    border: 1px solid var(--cot-border-light);
    border-radius: var(--cot-radius-lg);
    padding: 24px 20px 20px;
    box-shadow: var(--cot-shadow);
    text-align: center;
}

.jy-cot-card-title {
    font-size: 15px;
    font-weight: 600;
    margin: 0 0 8px;
    color: var(--cot-text-primary);
    white-space: nowrap;
}

.jy-cot-card-subtitle {
    font-size: 12px;
    font-weight: 400;
    color: var(--cot-text-muted);
    margin-left: 4px;
}

.jy-cot-gauge-container {
    display: flex;
    justify-content: center;
    align-items: center;
    margin: 8px auto 4px;
    max-width: 280px;
    height: 160px;
}

.jy-cot-gauge-container canvas {
    width: 100% !important;
    height: 100% !important;
}

/* Gauge labels row */
.jy-cot-gauge-labels {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-top: 12px;
}

.jy-cot-gauge-item {
    text-align: center;
}

.jy-cot-gauge-indicator {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 2px;
    margin-right: 4px;
    vertical-align: middle;
}

.jy-cot-gauge-indicator.long {
    background-color: var(--cot-long);
}

.jy-cot-gauge-indicator.short {
    background-color: var(--cot-short);
}

.jy-cot-gauge-label {
    font-size: 12px;
    color: var(--cot-text-muted);
    display: inline;
}

.jy-cot-gauge-long .jy-cot-gauge-label {
    color: var(--cot-long);
}

.jy-cot-gauge-short .jy-cot-gauge-label {
    color: var(--cot-short);
}

.jy-cot-gauge-value {
    font-size: 18px;
    font-weight: 700;
    font-family: var(--cot-font-mono);
    color: var(--cot-text-primary);
    margin-top: 2px;
}

.jy-cot-gauge-net-value.positive {
    color: var(--cot-net-positive);
}

.jy-cot-gauge-net-value.negative {
    color: var(--cot-net-negative);
}

/* Gauge changes row */
.jy-cot-gauge-changes {
    display: flex;
    justify-content: center;
    gap: 28px;
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--cot-border-light);
}

.jy-cot-gauge-change {
    text-align: center;
}

.jy-cot-gauge-change-label {
    font-size: 12px;
    color: var(--cot-text-muted);
    display: block;
    margin-bottom: 2px;
}

.jy-cot-gauge-change-value {
    font-size: 14px;
    font-family: var(--cot-font-mono);
    font-weight: 600;
    color: var(--cot-text-primary);
}

.jy-cot-gauge-change-value.positive {
    color: var(--cot-up);
}

.jy-cot-gauge-change-value.negative {
    color: var(--cot-down);
}

/* ---- Chart Section ---- */
.jy-cot-chart-section {
    margin-top: 28px;
}

.jy-cot-chart-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    flex-wrap: wrap;
    gap: 12px;
}

/* Chart Tabs */
.jy-cot-chart-tabs {
    display: flex;
    gap: 4px;
    background: var(--cot-bg-secondary);
    padding: 3px;
    border-radius: var(--cot-radius);
    border: 1px solid var(--cot-border);
}

.jy-cot-chart-tab {
    padding: 6px 16px;
    border: none;
    border-radius: 6px;
    background: transparent;
    color: var(--cot-text-muted);
    font-size: 13px;
    font-family: var(--cot-font-primary);
    cursor: pointer;
    transition: all var(--cot-transition);
    white-space: nowrap;
}

.jy-cot-chart-tab:hover {
    color: var(--cot-text-primary);
    background: var(--cot-bg-card);
}

.jy-cot-chart-tab.active {
    background: var(--cot-accent-dim);
    color: var(--cot-accent);
    font-weight: 600;
}

/* Range buttons */
.jy-cot-chart-range {
    display: flex;
    gap: 4px;
    background: var(--cot-bg-secondary);
    padding: 3px;
    border-radius: var(--cot-radius);
    border: 1px solid var(--cot-border);
}

.jy-cot-range-btn {
    padding: 5px 12px;
    border: none;
    border-radius: 6px;
    background: transparent;
    color: var(--cot-text-muted);
    font-size: 12px;
    font-family: var(--cot-font-primary);
    cursor: pointer;
    transition: all var(--cot-transition);
    white-space: nowrap;
}

.jy-cot-range-btn:hover {
    color: var(--cot-text-primary);
    background: var(--cot-bg-card);
}

.jy-cot-range-btn.active {
    background: var(--cot-accent-dim);
    color: var(--cot-accent);
    font-weight: 600;
}

.jy-cot-chart-wrapper {
    background: var(--cot-bg-card);
    border: 1px solid var(--cot-border-light);
    border-radius: var(--cot-radius-lg);
    padding: 20px;
    box-shadow: var(--cot-shadow);
}

/* ---- Data Table ---- */
.jy-cot-table-section {
    margin-top: 28px;
}

.jy-cot-table-title {
    font-size: 18px;
    font-weight: 700;
    margin: 0 0 16px;
    color: var(--cot-text-primary);
}

.jy-cot-table-scroll {
    overflow-x: auto;
    border: 1px solid var(--cot-border-light);
    border-radius: var(--cot-radius-lg);
    box-shadow: var(--cot-shadow);
}

.jy-cot-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.jy-cot-table thead {
    background: var(--cot-bg-secondary);
    position: sticky;
    top: 0;
}

.jy-cot-table th {
    padding: 12px 14px;
    text-align: right;
    font-weight: 600;
    color: var(--cot-text-secondary);
    border-bottom: 1px solid var(--cot-border);
    white-space: nowrap;
    font-size: 12px;
}

.jy-cot-table th:first-child {
    text-align: left;
}

.jy-cot-table td {
    padding: 10px 14px;
    text-align: right;
    font-family: var(--cot-font-mono);
    font-size: 12px;
    color: var(--cot-text-primary);
    border-bottom: 1px solid var(--cot-border-light);
    white-space: nowrap;
}

.jy-cot-table td:first-child {
    text-align: left;
    color: var(--cot-text-secondary);
}

.jy-cot-table tbody tr {
    background: var(--cot-bg-card);
    transition: background var(--cot-transition);
}

.jy-cot-table tbody tr:hover {
    background: var(--cot-bg-card-hover);
}

.jy-cot-table .positive {
    color: var(--cot-up);
}

.jy-cot-table .negative {
    color: var(--cot-down);
}

/* ---- Footer ---- */
.jy-cot-footer {
    margin-top: 40px;
    padding: 20px 0;
    border-top: 1px solid var(--cot-border-light);
    text-align: center;
    font-size: 12px;
    color: var(--cot-text-muted);
}

.jy-cot-footer a {
    color: var(--cot-accent);
    text-decoration: none;
}

.jy-cot-footer a:hover {
    text-decoration: underline;
}

.jy-cot-footer p {
    margin: 4px 0;
}

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

@media (max-width: 768px) {
    .jy-cot-gauge-row {
        grid-template-columns: 1fr;
    }

    .jy-cot-gauge-value {
        font-size: 16px;
    }

    .jy-cot-gauge-card {
        padding: 16px;
    }

    .jy-cot-chart-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .jy-cot-chart-wrapper {
        padding: 14px;
    }

    .jy-cot-nav-link {
        padding: 6px 12px;
        font-size: 13px;
    }

    .jy-cot-market-link {
        padding: 6px 10px;
        font-size: 12px;
    }

    .jy-cot-section-title {
        font-size: 18px;
    }
}

@media (max-width: 480px) {
    .jy-cot-dashboard {
        padding: 0 10px 30px;
    }

    .jy-cot-gauge-labels {
        gap: 12px;
    }

    .jy-cot-gauge-changes {
        gap: 16px;
    }

    .jy-cot-range-btn {
        padding: 5px 8px;
        font-size: 11px;
    }

    .jy-cot-chart-tab {
        padding: 5px 10px;
        font-size: 12px;
    }
}
