/* ═══════════════════════════════════════════
   TEAM HISTORY — Sự cố & Công nợ Khách hàng
   ═══════════════════════════════════════════ */

/* ─── Page Header ─── */
.th-page-title   { font-weight: 700; letter-spacing: 0.3px; }
.th-page-subtitle {
    font-size: 0.8rem;
    color: rgba(255,255,255,0.45);
    margin-bottom: 12px;
    display: block;
}

/* ═══ FILTER BAR ═══ */
.th-filter-bar {
    background: rgba(255,255,255,0.03);
    border: 1px solid rgba(255,255,255,0.07);
    border-radius: 10px;
    padding: 10px 14px;
    margin-bottom: 14px;
}

/* Flex container — tất cả sát nhau, không gap quá lớn */
.th-filter-row {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
}

/* Nhóm KH dropdown */
.th-filter-select.mud-input-control {
    width: 170px !important;
    flex-shrink: 0;
}
/* Override MudBlazor's default min-width */
.th-filter-select .mud-select-input { min-width: unset !important; }

/* Date pair: 2 datepicker liền nhau với mũi tên ở giữa */
.th-filter-dates {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
}
.th-date-pick.mud-input-control {
    width: 160px !important;
}
.th-date-sep {
    font-size: 0.9rem;
    color: rgba(255,255,255,0.3);
    flex-shrink: 0;
}

/* Actions group — buttons + tìm */
.th-filter-actions {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}
.th-quickbtn.mud-button-root {
    text-transform: none !important;
    font-size: 0.72rem !important;
    padding: 4px 10px !important;
    min-width: unset !important;
}

/* ═══ KPI SUMMARY CARDS ═══ */
.th-kpi-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
    margin-bottom: 14px;
}

@media (max-width: 900px)  { .th-kpi-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 500px)  { .th-kpi-grid { grid-template-columns: repeat(2, 1fr); gap: 6px; } }

.th-kpi-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-radius: 12px;
    border: 1px solid var(--th-kpi-border, rgba(255,255,255,0.08));
    background: var(--th-kpi-bg, rgba(255,255,255,0.04));
    transition: transform 0.18s ease, box-shadow 0.18s ease;
    cursor: default;
}
.th-kpi-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0,0,0,0.25);
}

.th-kpi-icon {
    font-size: 1.6rem;
    line-height: 1;
    flex-shrink: 0;
}
.th-kpi-body { display: flex; flex-direction: column; }
.th-kpi-value {
    font-size: 1.7rem;
    font-weight: 800;
    line-height: 1.1;
    color: var(--th-kpi-accent, #60a5fa);
}
.th-kpi-label {
    font-size: 0.62rem;
    font-weight: 700;
    letter-spacing: 0.8px;
    color: rgba(255,255,255,0.4);
    text-transform: uppercase;
    margin-top: 2px;
}

/* variants */
.th-kpi-incident { --th-kpi-bg: rgba(245,158,11,0.10); --th-kpi-border: rgba(245,158,11,0.22); --th-kpi-accent: #fbbf24; }
.th-kpi-pending  { --th-kpi-bg: rgba(239,68,68,0.10);  --th-kpi-border: rgba(239,68,68,0.22);  --th-kpi-accent: #f87171; }
.th-kpi-reject   { --th-kpi-bg: rgba(124,58,237,0.10); --th-kpi-border: rgba(124,58,237,0.22); --th-kpi-accent: #a78bfa; }
.th-kpi-resolved { --th-kpi-bg: rgba(16,185,129,0.10); --th-kpi-border: rgba(16,185,129,0.22); --th-kpi-accent: #34d399; }

/* ─── Alert pending ─── */
.th-alert-pending {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 9px 14px;
    background: rgba(239,68,68,0.08);
    border: 1px solid rgba(239,68,68,0.22);
    border-radius: 8px;
    margin-bottom: 12px;
    font-size: 0.83rem;
    color: #fca5a5;
}

/* ═══ TAB TOOLBAR ═══ */
.th-tab-toolbar {
    display: flex;
    justify-content: flex-end;
    padding: 8px 0 6px;
}

/* ═══ TABLE HEADERS ═══ */
.th-th-incident {
    background: linear-gradient(135deg, #92400e, #d97706) !important;
    color: white !important;
}
.th-th-debt {
    background: linear-gradient(135deg, #1d4ed8, #3b82f6) !important;
    color: white !important;
}

/* ─── Incident type badges ─── */
.th-badge-exchange { background: rgba(59,130,246,0.18) !important; color: #93c5fd !important; }
.th-badge-return   { background: rgba(245,158,11,0.18) !important; color: #fcd34d !important; }
.th-badge-cancel   { background: rgba(239,68,68,0.18)  !important; color: #fca5a5 !important; }
.th-badge-reject   { background: rgba(124,58,237,0.18) !important; color: #c4b5fd !important; }
.th-badge-shortage { background: rgba(236,72,153,0.18) !important; color: #f9a8d4 !important; }
.th-badge-late     { background: rgba(249,115,22,0.18) !important; color: #fdba74 !important; }
.th-badge-damage   { background: rgba(220,38,38,0.18)  !important; color: #fca5a5 !important; }
.th-badge-weather  { background: rgba(14,165,233,0.18) !important; color: #7dd3fc !important; }

/* ─── Star Rating (Dialog) ─── */
.th-rating-field {
    border: 1px solid rgba(255,255,255,0.23);
    border-radius: 4px;
    padding: 6px 10px;
    min-height: 40px;
    display: flex;
    flex-direction: column;
    justify-content: center;
}
.th-rating-label {
    font-size: 0.68rem !important;
    color: rgba(255,255,255,0.5);
    margin-bottom: 2px;
    letter-spacing: 0.3px;
}
.th-star-row {
    display: flex;
    align-items: center;
    gap: 0;
}
.th-star-btn.mud-button-root {
    min-width: 28px !important;
    padding: 2px !important;
}
.th-rating-text {
    margin-left: 6px;
    font-weight: 700;
    color: #fbbf24;
}

/* ─── Stars Display (Table) ─── */
.th-stars-display {
    display: inline-flex;
    gap: 0;
    vertical-align: middle;
}

/* ─── Empty state ─── */
.th-empty {
    min-height: 200px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    color: rgba(255,255,255,0.28);
}

/* ═══ MULTI-ITEM TABLE trong Dialog ═══ */
.th-item-table {
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 8px;
    overflow: hidden;
}
.th-item-header {
    display: flex;
    align-items: center;
    background: rgba(245,158,11,0.10);
    padding: 5px 10px;
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    color: rgba(255,255,255,0.5);
    gap: 8px;
}
.th-item-row {
    display: flex;
    align-items: center;
    padding: 4px 8px;
    gap: 8px;
    border-top: 1px solid rgba(255,255,255,0.05);
}
.th-item-row:hover { background: rgba(255,255,255,0.02); }
.th-item-col-product { flex: 1; min-width: 0; }
.th-item-col-uom     { width: 95px;  flex-shrink: 0; text-align: center; }
.th-item-col-qty     { width: 95px; flex-shrink: 0; }
.th-item-col-action  { width: 32px;  flex-shrink: 0; }

/* ─── Empty items hint ─── */
.th-empty-items {
    display: block;
    text-align: center;
    padding: 10px 0;
    color: rgba(255,255,255,0.32);
    font-size: 0.77rem;
    font-style: italic;
}

/* ═══ Responsive ═══ */
@media (max-width: 600px) {
    .th-filter-row    { gap: 6px; }
    .th-filter-dates  { flex-direction: column; gap: 4px; }
    .th-date-sep      { display: none; }
    .th-date-pick.mud-input-control { width: 100% !important; }
    .th-filter-select.mud-input-control { width: 100% !important; }
    .th-kpi-value     { font-size: 1.35rem; }
    .th-kpi-icon      { font-size: 1.3rem; }
}
