/* ─── TradeMate VN — Dashboard Panels (Unified with Screening) ─────────── */

/* ═══ Style Header ═══════════════════════════════════════════════ */
.tm-style-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-md);
    padding: var(--space-md) var(--space-lg);
    border-radius: var(--radius-lg);
    background: var(--color-bg-card);
    border: 1px solid var(--color-border);
    border-left: 3px solid var(--style-color, var(--color-primary));
    margin-bottom: var(--space-sm);
}
.tm-style-header-left {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    min-width: 0;
}
.tm-style-header-icon {
    font-size: 1.6rem;
    flex-shrink: 0;
}
.tm-style-header-name {
    font-size: var(--font-size-lg);
    font-weight: 700;
    color: var(--color-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.tm-style-header-meta {
    font-size: var(--font-size-xs);
    color: var(--color-text-muted);
    white-space: nowrap;
}
.tm-style-header-right {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    flex-shrink: 0;
}
.tm-exposure-badge {
    padding: 2px 10px;
    border-radius: var(--radius-full);
    font-size: var(--font-size-xs);
    font-weight: 600;
    background: rgba(139, 92, 246, 0.12);
    color: #a78bfa;
    white-space: nowrap;
}

/* Advice strip — expanded */
.tm-advice-strip {
    padding: var(--space-sm) var(--space-lg);
    border-radius: var(--radius-md);
    background: var(--color-bg-hover);
    border-left: 3px solid var(--style-color, var(--color-primary));
    margin-bottom: var(--space-md);
    line-height: 1.5;
}
.tm-advice-action {
    font-size: var(--font-size-sm);
    font-weight: 600;
    color: var(--color-text);
    margin-bottom: var(--space-xs);
}
.tm-advice-details {
    display: flex;
    gap: var(--space-lg);
    flex-wrap: wrap;
}
.tm-advice-item {
    display: flex;
    align-items: baseline;
    gap: var(--space-xs);
    font-size: var(--font-size-xs);
}
.tm-advice-label {
    color: var(--color-text-muted);
    white-space: nowrap;
    flex-shrink: 0;
}
.tm-advice-value {
    color: var(--color-text-secondary);
}

/* ═══ Market Strip (compact chips) ═══════════════════════════════ */
.tm-market-strip {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-sm);
    margin-bottom: var(--space-md);
}
.tm-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 12px;
    border-radius: var(--radius-full);
    background: var(--color-bg-card);
    border: 1px solid var(--color-border);
    font-size: var(--font-size-sm);
}
.tm-chip-label {
    color: var(--color-text-muted);
    font-size: var(--font-size-xs);
    font-weight: 500;
}
.tm-chip-value {
    font-weight: 600;
    color: var(--color-text);
}
.tm-chip-value small {
    font-weight: 400;
    font-size: 0.7rem;
    opacity: 0.8;
}
.tm-chip-value.positive { color: var(--color-positive); }
.tm-chip-value.negative { color: var(--color-negative); }

/* ═══ Regime badge ═══════════════════════════════════════════════ */
.tm-regime-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 10px;
    border-radius: var(--radius-full);
    font-size: var(--font-size-xs);
    font-weight: 600;
    text-transform: uppercase;
}
.tm-regime-badge.bull {
    background: rgba(16, 185, 129, 0.15);
    color: var(--color-positive);
}
.tm-regime-badge.bear {
    background: rgba(239, 68, 68, 0.15);
    color: var(--color-negative);
}
.tm-regime-badge.sideway {
    background: rgba(245, 158, 11, 0.15);
    color: var(--color-neutral);
}

/* ═══ Tab 0: Overview — 2-col horizontal ═════════════════════════ */
.tm-dash-overview {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-md);
    align-items: start;
}
.tm-dash-overview > .tm-panel {
    min-height: 0;
}
/* Screening tiles in right column: narrower grid */
.tm-dash-overview .sl-grid {
    grid-template-columns: repeat(4, 1fr);
}
.tm-dash-overview .sl-group-header {
    padding: var(--space-xs) var(--space-sm);
    font-size: var(--font-size-xs);
}
.tm-dash-overview .tm-screening-controls {
    margin-bottom: var(--space-sm);
}
.tm-dash-overview .sl-filter-input,
.tm-dash-overview .sl-sort-select {
    font-size: var(--font-size-xs);
    padding: 4px 8px;
    height: 28px;
}
.tm-dash-overview .sl-group-summary {
    gap: 4px;
    margin-bottom: var(--space-xs);
}
.tm-dash-overview .sl-group-pill {
    padding: 2px 6px;
    font-size: 0.6rem;
}
.tm-dash-overview .sl-group-pill-label {
    display: none;
}
.tm-dash-overview #dash-screening-body {
    padding: var(--space-sm) var(--space-md);
}

/* ═══ Screening controls ═════════════════════════════════ */
.tm-screening-controls {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    margin-bottom: var(--space-md);
    flex-wrap: wrap;
}


/* ═══ Panel base ════════════════════════════════════════════════ */
.tm-panel {
    background: var(--color-bg-card);
    border-radius: var(--radius-lg);
    border: 1px solid var(--color-border);
    overflow: hidden;
    animation: tmPanelIn 0.4s ease both;
}
.tm-panel:nth-child(2) { animation-delay: 0.05s; }
.tm-panel:nth-child(3) { animation-delay: 0.10s; }
.tm-panel:nth-child(4) { animation-delay: 0.15s; }

@keyframes tmPanelIn {
    from { opacity: 0; transform: translateY(12px); }
    to   { opacity: 1; transform: translateY(0); }
}

.tm-panel-header {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-md) var(--space-lg);
    border-bottom: 1px solid var(--color-border);
}
.tm-panel-icon {
    font-size: 1.1rem;
}
.tm-panel-title {
    font-size: var(--font-size-sm);
    font-weight: 600;
    color: var(--color-text);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}
.tm-panel-body {
    padding: var(--space-md) var(--space-lg);
}

/* ═══ Action Items ══════════════════════════════════════════════ */
.tm-action-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-xs);
}
.tm-action-item {
    display: flex;
    align-items: flex-start;
    gap: var(--space-sm);
    padding: var(--space-sm) 0;
    font-size: var(--font-size-sm);
    color: var(--color-text-secondary);
    border-bottom: 1px solid var(--color-border);
}
.tm-action-item:last-child {
    border-bottom: none;
}
.tm-action-icon {
    flex-shrink: 0;
    width: 20px;
    text-align: center;
}
.tm-action-item[data-priority="high"] {
    color: var(--color-text);
}
.tm-action-item[data-priority="high"] .tm-action-icon {
    color: var(--color-negative);
}
.tm-action-item[data-priority="medium"] .tm-action-icon {
    color: var(--color-neutral);
}

/* ═══ Loading Skeleton ══════════════════════════════════════════ */
.tm-skeleton {
    display: flex;
    flex-direction: column;
    gap: var(--space-lg);
}
.tm-skeleton-panel {
    background: var(--color-bg-card);
    border-radius: var(--radius-lg);
    border: 1px solid var(--color-border);
    padding: var(--space-lg);
}
.tm-skeleton-line {
    height: 14px;
    border-radius: 4px;
    background: var(--color-bg-hover);
    animation: tmShimmer 1.5s ease infinite;
    margin-bottom: var(--space-sm);
}
.tm-skeleton-line:nth-child(1) { width: 40%; }
.tm-skeleton-line:nth-child(2) { width: 70%; }
.tm-skeleton-line:nth-child(3) { width: 55%; }
.tm-skeleton-line:nth-child(4) { width: 80%; animation-delay: 0.1s; }

@keyframes tmShimmer {
    0%, 100% { opacity: 0.5; }
    50%      { opacity: 1; }
}

/* ═══ Refresh button ════════════════════════════════════════════ */
.tm-refresh-btn {
    background: none;
    border: none;
    color: var(--color-text-muted);
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    font-size: 1rem;
    transition: color 0.2s, transform 0.3s;
    margin-left: auto;
    min-width: 44px;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    -webkit-tap-highlight-color: transparent;
}
.tm-refresh-btn:hover {
    color: var(--color-text);
}
.tm-refresh-btn.spinning {
    animation: tmSpin 0.8s linear infinite;
}
@keyframes tmSpin {
    from { transform: rotate(0deg); }
    to   { transform: rotate(360deg); }
}

/* ═══ No data state ═════════════════════════════════════════════ */
.tm-no-data {
    text-align: center;
    padding: var(--space-xl);
    color: var(--color-text-muted);
}
.tm-no-data-icon {
    font-size: 2.5rem;
    margin-bottom: var(--space-md);
}
.tm-no-data-title {
    font-size: var(--font-size-lg);
    font-weight: 600;
    color: var(--color-text-secondary);
    margin-bottom: var(--space-sm);
}

/* ═══ Recommendation Panel (Tab 0) ═════════════════════════════ */
.tm-rec-panel .tm-panel-header {
    gap: var(--space-sm);
}
.tm-rec-panel .tm-bot-section-badge {
    margin-left: auto;
}
.tm-rec-strip {
    display: flex;
    gap: var(--space-lg);
    padding: var(--space-sm) var(--space-lg);
    border-bottom: 1px solid var(--color-border);
    background: var(--color-bg-hover);
}
.tm-rec-strip-item {
    display: flex;
    align-items: center;
    gap: var(--space-xs);
    font-size: var(--font-size-xs);
}
.tm-rec-strip-label {
    color: var(--color-text-muted);
}
.tm-rec-strip-val {
    font-weight: 600;
    color: var(--color-text);
}

/* Watchlist strip */
.tm-rec-watchlist {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    flex-wrap: wrap;
    padding: var(--space-sm) var(--space-lg);
    border-top: 1px solid var(--color-border);
    background: var(--color-bg-hover);
}
.tm-rec-watch-label {
    font-size: var(--font-size-xs);
    color: var(--color-text-muted);
    font-weight: 600;
    flex-shrink: 0;
}
.tm-rec-watch-item {
    font-size: var(--font-size-xs);
    padding: 2px 8px;
    border-radius: var(--radius-full);
    background: var(--color-bg-card);
    border: 1px solid var(--color-border);
    color: var(--color-neutral);
    cursor: pointer;
    transition: border-color var(--transition-fast);
}
.tm-rec-watch-item:hover {
    border-color: var(--color-neutral);
}
.tm-rec-watch-item small {
    color: var(--color-text-muted);
    font-weight: 400;
}

/* ═══ Bot AI Tab ════════════════════════════════════════════════ */

/* Summary cards row */
.tm-bot-summary {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: var(--space-md);
    margin-bottom: var(--space-md);
}
.tm-bot-card {
    padding: var(--space-md) var(--space-lg);
    border-radius: var(--radius-lg);
    background: var(--color-bg-card);
    border: 1px solid var(--color-border);
}
.tm-bot-card--positive { border-left: 3px solid var(--color-positive); }
.tm-bot-card--negative { border-left: 3px solid var(--color-negative); }
.tm-bot-card-label {
    font-size: var(--font-size-xs);
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.03em;
    margin-bottom: var(--space-xs);
}
.tm-bot-card-value {
    font-size: var(--font-size-xl);
    font-weight: 700;
    color: var(--color-text);
}
.tm-bot-card-sub {
    font-size: var(--font-size-xs);
    color: var(--color-text-secondary);
    margin-top: 2px;
}
.tm-bot-card-sub.positive { color: var(--color-positive); }
.tm-bot-card-sub.negative { color: var(--color-negative); }

/* Section blocks */
.tm-bot-section {
    background: var(--color-bg-card);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    margin-bottom: var(--space-md);
}
.tm-bot-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-sm) var(--space-lg);
    border-bottom: 1px solid var(--color-border);
}
.tm-bot-section-title {
    font-size: var(--font-size-sm);
    font-weight: 600;
    color: var(--color-text);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}
.tm-bot-section-badge {
    font-size: var(--font-size-xs);
    padding: 2px 8px;
    border-radius: var(--radius-full);
    background: rgba(139, 92, 246, 0.12);
    color: #a78bfa;
    font-weight: 600;
}
.tm-bot-empty {
    padding: var(--space-xl);
    text-align: center;
    color: var(--color-text-muted);
    font-size: var(--font-size-sm);
}

/* ── Positions table (VNDirect style) ── */
.tm-bot-table-wrap {
    overflow-x: auto;
}
.tm-bot-table {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--font-size-sm);
}
.tm-bot-table th {
    padding: var(--space-sm) var(--space-md);
    text-align: right;
    font-size: var(--font-size-xs);
    font-weight: 600;
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.03em;
    border-bottom: 1px solid var(--color-border);
    white-space: nowrap;
}
.tm-bot-table th:first-child { text-align: left; }
.tm-bot-table td {
    padding: var(--space-sm) var(--space-md);
    text-align: right;
    color: var(--color-text-secondary);
    border-bottom: 1px solid rgba(255,255,255,0.04);
    white-space: nowrap;
}
.tm-bot-table td:first-child { text-align: left; }
.tm-bot-table tbody tr:last-child td { border-bottom: none; }
.tm-bot-table tbody tr:hover { background: var(--color-bg-hover); }
.tm-bot-table .col-symbol {
    font-weight: 600;
    color: var(--color-text);
}
.tm-bot-table .col-positive { color: var(--color-positive); font-weight: 600; }
.tm-bot-table .col-negative { color: var(--color-negative); font-weight: 600; }
.tm-bot-table .col-muted { color: var(--color-text-muted); font-size: var(--font-size-xs); }
/* Summary row */
.tm-bot-table tfoot td {
    padding: var(--space-sm) var(--space-md);
    border-top: 1px solid var(--color-border);
    font-weight: 600;
    color: var(--color-text);
    font-size: var(--font-size-xs);
}

/* ── Orders table ── */
.tm-bot-order-table {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--font-size-xs);
}
.tm-bot-order-table th {
    padding: var(--space-xs) var(--space-md);
    text-align: left;
    font-size: 0.65rem;
    font-weight: 600;
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.03em;
    border-bottom: 1px solid var(--color-border);
    white-space: nowrap;
}
.tm-bot-order-table td {
    padding: var(--space-xs) var(--space-md);
    text-align: left;
    color: var(--color-text-secondary);
    border-bottom: 1px solid rgba(255,255,255,0.04);
    white-space: nowrap;
}
.tm-bot-order-table tbody tr:last-child td { border-bottom: none; }
.tm-bot-order-table tbody tr:hover { background: var(--color-bg-hover); }
.tm-bot-order-table .side-buy { color: var(--color-positive); font-weight: 600; }
.tm-bot-order-table .side-sell { color: var(--color-negative); font-weight: 600; }
.tm-bot-order-table .col-symbol { font-weight: 600; color: var(--color-text); }
.tm-bot-order-table .status-filled {
    color: var(--color-positive);
    font-weight: 500;
}
.tm-bot-order-table .status-rejected {
    color: var(--color-negative);
    font-weight: 500;
}
.tm-bot-order-signal {
    font-size: 0.65rem;
    padding: 1px 6px;
    border-radius: var(--radius-full);
    background: var(--color-bg-hover);
    color: var(--color-text-muted);
    display: inline-block;
}

/* Action buttons */
.tm-bot-actions {
    display: flex;
    gap: var(--space-sm);
    margin-top: var(--space-md);
}

/* ═══ Responsive ════════════════════════════════════════════════ */
@media (max-width: 768px) {
    .tm-dash-overview {
        grid-template-columns: 1fr;
    }
    .tm-dash-overview .sl-grid {
        grid-template-columns: repeat(6, 1fr);
    }
    .tm-style-header {
        flex-direction: column;
        align-items: flex-start;
        gap: var(--space-sm);
    }
    .tm-style-header-right {
        align-self: flex-end;
    }
    .tm-market-strip {
        gap: var(--space-xs);
    }
    .tm-chip {
        padding: 3px 8px;
        font-size: var(--font-size-xs);
    }
    .tm-bot-summary {
        grid-template-columns: 1fr;
    }
    .tm-bot-table th,
    .tm-bot-table td {
        padding: var(--space-xs) var(--space-sm);
        font-size: var(--font-size-xs);
    }
    .tm-bot-order-table th,
    .tm-bot-order-table td {
        padding: var(--space-xs) var(--space-sm);
    }
}
@media (max-width: 480px) {
    .tm-dash-overview .sl-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}
