/* ==========================================================================
   BULK QUOTATION STYLES
   ========================================================================== */

/* ── 1. CORE LAYOUT ── */
.bulk-page-overlay {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(3px);
}

.bulk-grid-container {
    overflow-x: auto;
    overflow-y: auto;
    max-height: calc(100vh - 320px);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 8px;
    background: rgba(0,0,0,0.15);
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,0.2) transparent;
    margin: 0;
    padding: 0;
}

/* Custom Scrollbar for webkit */
.bulk-grid-container::-webkit-scrollbar { height: 10px; width: 10px; }
.bulk-grid-container::-webkit-scrollbar-track { background: rgba(0,0,0,0.1); border-radius: 8px; }
.bulk-grid-container::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.2); border-radius: 8px; }
.bulk-grid-container::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.3); }

/* ── 2. TABLE BASE ── */
.bq-table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 0.8rem; table-layout: fixed; }
.bq-table th {
    background: rgba(25,30,35,0.98);
    color: rgba(255,255,255,0.85);
    font-weight: 700;
    padding: 8px 10px;
    border-bottom: 2px solid rgba(255,255,255,0.1);
    white-space: nowrap;
    text-align: center;
    position: sticky;
    top: 0;
    z-index: 10;
}
.bq-table td {
    padding: 6px 10px;
    border-bottom: 1px solid rgba(255,255,255,0.04);
    vertical-align: middle;
}
.bq-row { transition: background 0.15s, opacity 0.3s; }
.bq-row:hover { background: rgba(255,255,255,0.04); }

/* ── 3. STICKY COLUMNS (4 cột: Checkbox, Sản Phẩm, Giá Vốn, BG Gốc) ── */
.bq-col-sticky {
    position: sticky;
    z-index: 5;
    background: #18191d;
}
.bq-table th.bq-col-sticky { z-index: 11; }

/* Column widths & offsets for sticky positioning */
.bq-col-sticky:nth-child(1) { left: 0; width: 40px; min-width: 40px; max-width: 40px; }
.bq-col-sticky:nth-child(2) { left: 40px; width: 200px; min-width: 200px; max-width: 200px; }
.bq-col-sticky:nth-child(3) { left: 240px; width: 90px; min-width: 90px; max-width: 90px; }
.bq-col-sticky:nth-child(4) { left: 330px; width: 90px; min-width: 90px; max-width: 90px; box-shadow: 4px 0 12px rgba(0,0,0,0.3); }

/* ── PRICE-LIST COLUMN HEADERS ── */
.bq-col-header { min-width: 160px; }
.bq-col-header-name { font-size: 0.85rem; font-weight: 700; color: var(--mud-palette-info, #42a5f5); }
.bq-col-header-subtitle { font-size: 0.7rem; color: rgba(255,255,255,0.4); font-weight: 400; margin-top: 2px; }

/* ── STRATEGY INFO BLOCK (per column header) ── */
.bq-strategy-block {
    margin-top: 4px;
    padding: 4px 6px;
    background: rgba(251,191,36,0.06);
    border: 1px solid rgba(251,191,36,0.18);
    border-radius: 6px;
}
.bq-strategy-name {
    font-size: 0.62rem;
    font-weight: 700;
    color: #fbbf24;
    text-align: center;
    margin-bottom: 2px;
    cursor: help;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.bq-strategy-details {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0;
    font-size: 0.56rem;
    line-height: 1.3;
}
.bq-strat-item { display: inline-flex; align-items: center; gap: 2px; }
.bq-strat-label { color: rgba(255,255,255,0.35); font-weight: 400; }
.bq-strat-val { font-weight: 700; }
.bq-strat-floor { color: #f87171; }
.bq-strat-ceil { color: #34d399; }
.bq-strat-hist { color: #60a5fa; }
.bq-strat-sep { color: rgba(255,255,255,0.15); margin: 0 3px; }
.bq-strategy-wp {
    font-size: 0.54rem;
    color: rgba(255,255,255,0.45);
    text-align: center;
    margin-top: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ── 4. HEAT STRIPE (LEFT BORDER STATUS) ── */
.bq-row td:first-child { border-left: 4px solid transparent; }
.bq-row.safe td:first-child { border-left-color: #34d399; }
.bq-row.warn td:first-child { border-left-color: #fbbf24; }
.bq-row.danger td:first-child { border-left-color: #f87171; }
.bq-row.anomaly td:first-child {
    border-left-color: #e879f9;
    animation: bq-pulse 2s infinite;
}

/* ── 5. CELL HEATMAP ── */
.bq-cell { border-left: 1px solid rgba(255,255,255,0.03); text-align: center; padding: 6px 8px !important; }
.bq-cell.heat-safe { background: rgba(52, 211, 153, 0.05); }
.bq-cell.heat-mild { background: rgba(251, 191, 36, 0.07); }
.bq-cell.heat-high { background: rgba(251, 146, 60, 0.1); }
.bq-cell.heat-extreme { background: rgba(248, 113, 113, 0.12); }

/* ── 6. BADGES ── */
.bq-badges { display: flex; gap: 4px; flex-wrap: wrap; justify-content: center; margin-top: 4px; }
.bq-badge { font-size: 0.6rem; padding: 2px 5px; border-radius: 4px; font-weight: 600; white-space: nowrap; }
.bq-badge-up   { color: #34d399; background: rgba(52,211,153,0.12); }   /* TĂNG = XANH */
.bq-badge-down { color: #f87171; background: rgba(248,113,113,0.12); } /* GIẢM = ĐỎ  */
.bq-badge-flat { color: rgba(255,255,255,0.5); background: rgba(255,255,255,0.05); }
.bq-badge-capped { color: #fca5a5; background: rgba(239, 68, 68, 0.2); border: 1px solid rgba(239, 68, 68, 0.4); animation: bq-fade 2s infinite; }
.bq-badge-new     { color: #93c5fd; background: rgba(59, 130, 246, 0.2); border: 1px solid rgba(59, 130, 246, 0.3); }
.bq-badge-repeat  { color: #a78bfa; background: rgba(139, 92, 246, 0.15); border: 1px solid rgba(139, 92, 246, 0.3); }

/* Filter chip variants */
.bq-filter-chip.chip-repeat.active { border-color: #a78bfa; background: rgba(139,92,246,0.15); color: #a78bfa; }
.bq-filter-chip.chip-new.active    { border-color: #93c5fd; background: rgba(59,130,246,0.15);  color: #93c5fd; }
.bq-filter-chip.chip-up.active     { border-color: #34d399; background: rgba(52,211,153,0.12);  color: #34d399; }
.bq-filter-chip.chip-down.active   { border-color: #f87171; background: rgba(248,113,113,0.12); color: #f87171; }
.bq-filter-chip.chip-warn.active   { border-color: #fbbf24; background: rgba(251,191,36,0.12);  color: #fbbf24; }
.bq-filter-chip.chip-err.active    { border-color: #f87171; background: rgba(248,113,113,0.12); color: #f87171; }
.bq-filter-chip.chip-sold.active   { border-color: #fb923c; background: rgba(251,146,60,0.15);  color: #fb923c; }

/* ── 7. QUICK FILTERS & COMPACT INPUTS ── */
.bq-filter-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}
.bq-filter-chip {
    transition: all 0.2s;
    cursor: pointer;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 0.75rem;
    border: 1px solid rgba(255,255,255,0.1);
    color: rgba(255,255,255,0.7);
    user-select: none;
}
.bq-filter-chip:hover { background: rgba(255,255,255,0.06); border-color: rgba(255,255,255,0.2); }
.bq-filter-chip.active { border-color: var(--mud-palette-primary); background: rgba(var(--mud-palette-primary-rgb), 0.15); color: #fff; font-weight: 600; }
.bq-filter-count { background: rgba(0,0,0,0.3); padding: 1px 6px; border-radius: 8px; margin-left: 6px; font-size: 0.65rem; }

/* ── GROUP TOGGLE BUTTONS (thay MudChipSet — reliable hơn) ── */
.bq-group-btn {
    padding: 4px 12px;
    border-radius: 14px;
    border: 1px solid rgba(255,255,255,0.15);
    background: transparent;
    color: rgba(255,255,255,0.6);
    font-size: 0.75rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.18s ease;
    white-space: nowrap;
    user-select: none;
    line-height: 1.4;
}
.bq-group-btn:hover {
    background: rgba(255,255,255,0.07);
    border-color: rgba(255,255,255,0.3);
    color: rgba(255,255,255,0.9);
}
.bq-group-btn.active {
    background: rgba(99,179,237,0.18);
    border-color: #63b3ed;
    color: #90cdf4;
    font-weight: 700;
    box-shadow: 0 0 6px rgba(99,179,237,0.2);
}

/* ── PRICE INPUT BASE ── */
.bq-input {
    width: 85px; text-align: center; font-size: 0.85rem; font-weight: 700;
    color: #fff; background: rgba(0,0,0,0.25); border: 1px solid rgba(255,255,255,0.12); border-radius: 6px; padding: 5px 4px;
    transition: background 0.25s ease, border-color 0.25s ease, box-shadow 0.2s ease;
}
.bq-input:focus { border-color: var(--mud-palette-primary); outline: none; background: rgba(0,0,0,0.45); box-shadow: 0 0 0 2px rgba(var(--mud-palette-primary-rgb), 0.25); }
.bq-input::-webkit-inner-spin-button,
.bq-input::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.bq-input[type=number] { -moz-appearance: textfield; }

/* ── PRICE WRAPPER + FORMATTED OVERLAY ── */
.bq-price-wrapper {
    position: relative;
    width: 100%;
}
/* Input trong wrapper: text trong suốt → overlay hiện số đẹp */
.bq-price-wrapper .bq-input {
    width: 100%;
    color: transparent;
    caret-color: rgba(255,255,255,0.9);
}
/* Khi focus: ẩn overlay, hiện số thô để gõ */
.bq-price-wrapper .bq-input:focus { color: #fff; font-size: 0.9rem; }
.bq-price-wrapper:focus-within .bq-price-display { opacity: 0; pointer-events: none; }

/* Overlay hiện số được format */
.bq-price-display {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.88rem;
    letter-spacing: 0.01em;
    pointer-events: none;
    transition: opacity 0.12s ease;
    color: rgba(255,255,255,0.92);
}

/* ── HIGHLIGHT LEVELS (theo T1Delta) ── */
/* Tăng mạnh > +10% */
.bq-price-wrapper.hl-up2 .bq-input { background: rgba(52,211,153,0.18); border-color: rgba(52,211,153,0.55); }
.bq-price-wrapper.hl-up2 .bq-price-display { color: #34d399; text-shadow: 0 0 8px rgba(52,211,153,0.4); }
/* Tăng nhẹ +1% → +10% */
.bq-price-wrapper.hl-up1 .bq-input { background: rgba(52,211,153,0.07); border-color: rgba(52,211,153,0.28); }
.bq-price-wrapper.hl-up1 .bq-price-display { color: #6ee7b7; }
/* Giảm mạnh < -10% */
.bq-price-wrapper.hl-dn2 .bq-input { background: rgba(248,113,113,0.18); border-color: rgba(248,113,113,0.55); }
.bq-price-wrapper.hl-dn2 .bq-price-display { color: #f87171; text-shadow: 0 0 8px rgba(248,113,113,0.35); }
/* Giảm nhẹ -1% → -10% */
.bq-price-wrapper.hl-dn1 .bq-input { background: rgba(248,113,113,0.07); border-color: rgba(248,113,113,0.28); }
.bq-price-wrapper.hl-dn1 .bq-price-display { color: #fca5a5; }

/* Focus lấy lại border primary bất kể màu highlight */
.bq-price-wrapper .bq-input:focus {
    border-color: var(--mud-palette-primary);
    box-shadow: 0 0 0 2px rgba(var(--mud-palette-primary-rgb), 0.3);
    background: rgba(0,0,0,0.5);
}

/* ── 8. STICKY TFOOT (Revenue Summary inside grid) ── */
.bq-table tfoot td {
    position: sticky;
    bottom: 0;
    z-index: 6;
    background: rgba(18,20,24,0.97);
    backdrop-filter: blur(6px);
}
.bq-table tfoot td.bq-col-sticky { z-index: 12; }
.bq-summary-row td { border-top: 2px solid rgba(255,255,255,0.12) !important; border-bottom: none !important; }
.bq-foot-cell { padding: 4px 6px !important; white-space: nowrap; text-align: center; }
/* Ensure last body row isn't hidden behind sticky tfoot */
.bq-table tbody tr:last-child td { padding-bottom: 32px; }

/* Action buttons in tfoot */
.bq-action-btn {
    padding: 4px 10px;
    border-radius: 6px;
    border: 1px solid rgba(255,255,255,0.15);
    background: rgba(255,255,255,0.05);
    color: rgba(255,255,255,0.75);
    font-size: 0.68rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s ease;
    white-space: nowrap;
}
.bq-action-btn:hover {
    background: rgba(99,179,237,0.15);
    border-color: #63b3ed;
    color: #90cdf4;
}

/* Column adjust buttons (+1 -1 +5 -5) */
.bq-col-adjust {
    display: flex;
    gap: 2px;
    justify-content: center;
    margin-top: 3px;
}
.bq-adj-btn {
    padding: 1px 5px;
    border-radius: 4px;
    border: 1px solid rgba(255,255,255,0.12);
    background: rgba(255,255,255,0.04);
    color: rgba(255,255,255,0.55);
    font-size: 0.58rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.12s;
    line-height: 1.3;
}
.bq-adj-btn:hover {
    background: rgba(99,179,237,0.18);
    border-color: #63b3ed;
    color: #fff;
}

/* Locked (reviewed) price cell */
.bq-price-wrapper.bq-locked .bq-input {
    background: rgba(255,255,255,0.02) !important;
    border-color: rgba(52,211,153,0.25) !important;
    cursor: not-allowed;
}
.bq-price-wrapper.bq-locked .bq-price-display {
    color: rgba(52,211,153,0.7) !important;
}

/* ── 8b. SUMMARY FOOTER (cards below grid) ── */
.bq-summary {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: stretch;
}
.bq-summary-card {
    flex: 1 1 140px;
    max-width: 200px;
    padding: 12px 14px;
    background: rgba(255,255,255,0.03);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 8px;
    transition: all 0.2s;
}
.bq-summary-card:hover {
    background: rgba(255,255,255,0.06);
    border-color: rgba(255,255,255,0.15);
    transform: translateY(-1px);
}
.bq-summary-best {
    border-color: rgba(52, 211, 153, 0.3);
    background: rgba(52, 211, 153, 0.05);
}
.bq-summary-worst {
    border-color: rgba(248, 113, 113, 0.3);
    background: rgba(248, 113, 113, 0.05);
}
.bq-summary-label {
    font-weight: 700;
    font-size: 0.9rem;
    color: var(--mud-palette-text-primary, #fff);
    margin-bottom: 4px;
}
.bq-summary-value {
    font-size: 0.8rem;
    color: rgba(255,255,255,0.7);
}

/* ── 9. ANIMATIONS ── */
.bq-row.reviewed { opacity: 0.3; }
.bq-row.hiding { animation: slideOut 0.4s forwards; }

@keyframes bq-pulse {
    0%, 100% { border-left-color: #e879f9; }
    50% { border-left-color: rgba(232, 121, 249, 0.2); }
}
@keyframes bq-fade {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}
@keyframes slideOut {
    from { opacity: 1; line-height: normal; padding: 6px 10px; }
    to { opacity: 0; line-height: 0; padding: 0 10px; visibility: hidden; }
}

/* ── 10. REVENUE ROW + EXPLANATION ── */
.bq-rev-row {
    display: flex;
    gap: 4px;
    align-items: center;
    justify-content: center;
    font-size: 0.62rem;
    margin-top: 3px;
    padding: 2px 4px;
    background: rgba(255,255,255,0.03);
    border-radius: 4px;
    white-space: nowrap;
}

.bq-badge-info {
    color: rgba(147,197,253,0.8);
    background: rgba(59,130,246,0.1);
    border: 1px solid rgba(59,130,246,0.25);
    font-size: 0.7rem;
    padding: 1px 6px;
    transition: background 0.15s;
}
.bq-badge-info:hover { background: rgba(59,130,246,0.25); }

/* Explanation panel — inline bên dưới badges */
.bq-explain-panel {
    width: 100%;
    margin-top: 6px;
    background: rgba(0,0,0,0.35);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 6px;
    padding: 6px 8px;
    font-size: 0.67rem;
    animation: bq-slide-in 0.15s ease;
}
@keyframes bq-slide-in {
    from { opacity: 0; transform: translateY(-4px); }
    to   { opacity: 1; transform: translateY(0); }
}
.bq-explain-row {
    display: flex;
    justify-content: space-between;
    padding: 2px 0;
    border-bottom: 1px solid rgba(255,255,255,0.04);
    color: rgba(255,255,255,0.7);
    gap: 8px;
}
.bq-explain-row:last-child { border-bottom: none; }
.bq-explain-row span:first-child { color: rgba(255,255,255,0.45); }
.bq-explain-warn { color: #fbbf24 !important; font-style: italic; }
.bq-explain-warn span { color: #fbbf24 !important; }

/* ── 11. RESPONSIVE ── */
@media (max-width: 1200px) {
    .bq-summary-card { flex: 1 1 120px; max-width: none; }
    .bq-col-header { min-width: 140px; }
}
