/* ==========================================================================
   SESAN 3-WAY RECONCILIATION STYLES (ĐỐI CHIẾU 3 BÊN SESAN)
   File: /css/sesan-reconcile.css
   ========================================================================== */

/* ── Container Toàn Trang ── */
.sesan-page {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 64px);
    overflow: hidden;
    background-color: var(--mud-palette-background);
    color: var(--mud-palette-text-primary);
}

/* ── Top Bar Siêu Gọn ── */
.sesan-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 6px 16px;
    background: var(--mud-palette-surface);
    border-bottom: 1px solid var(--mud-palette-lines-default);
    min-height: 52px;
    flex-shrink: 0;
}

.sesan-topbar-left {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: nowrap;
}

.sesan-topbar-title {
    font-weight: 700;
    font-size: 1.05rem;
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 6px;
}

.sesan-topbar-center {
    display: flex;
    align-items: center;
    gap: 8px;
}

.sesan-topbar-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* ── Chuyển đổi Chế Độ (Segmented Tabs) ── */
.sesan-segment-group {
    display: flex;
    background: rgba(0, 0, 0, 0.06);
    border-radius: 8px;
    padding: 2px;
    border: 1px solid var(--mud-palette-lines-default);
}

.sesan-segment-btn {
    border: none;
    background: transparent;
    padding: 6px 14px;
    font-size: 0.82rem;
    font-weight: 600;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--mud-palette-text-secondary);
    transition: all 0.15s ease;
}

.sesan-segment-btn.active {
    background: var(--mud-palette-primary);
    color: #ffffff;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.15);
}

/* ── Split Workspace ── */
.sesan-workspace {
    display: flex;
    flex: 1;
    overflow: hidden;
    position: relative;
}

/* ── Cột Trái: Trình Xem Ảnh Phiếu Nhận ── */
.sesan-viewer-col {
    display: flex;
    flex-direction: column;
    width: 42%;
    min-width: 320px;
    max-width: 60%;
    background: #0b1120;
    border-right: 1px solid var(--mud-palette-lines-default);
    overflow: hidden;
    transition: width 0.2s ease, min-width 0.2s ease;
    position: relative;
}

.sesan-viewer-col.collapsed {
    width: 38px !important;
    min-width: 38px !important;
}

.sesan-viewer-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 10px;
    background: #0f172a;
    border-bottom: 1px solid #1e293b;
    color: #cbd5e1;
    font-size: 0.8rem;
    flex-shrink: 0;
}

.sesan-canvas-wrap {
    flex: 1;
    overflow: hidden;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #030712;
    user-select: none;
    cursor: grab;
}

.sesan-canvas-wrap:active {
    cursor: grabbing;
}

.sesan-canvas-img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    transition: transform 0.08s ease-out;
    transform-origin: center center;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
}

.sesan-thumb-strip {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    background: #0f172a;
    border-top: 1px solid #1e293b;
    overflow-x: auto;
    flex-shrink: 0;
}

.sesan-thumb-item {
    width: 46px;
    height: 46px;
    border-radius: 4px;
    overflow: hidden;
    border: 2px solid #334155;
    cursor: pointer;
    flex-shrink: 0;
    opacity: 0.7;
    transition: all 0.15s ease;
}

.sesan-thumb-item.active {
    border-color: #06b6d4;
    opacity: 1;
    transform: scale(1.05);
}

.sesan-thumb-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* ── Cột Phải: Dữ Liệu & Bảng ── */
.sesan-table-col {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: var(--mud-palette-surface);
}

/* ── Quick Filter Bar ── */
.sesan-filter-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 14px;
    background: var(--mud-palette-background);
    border-bottom: 1px solid var(--mud-palette-lines-default);
    gap: 8px;
    flex-wrap: wrap;
    flex-shrink: 0;
}

.sesan-filter-chips {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.sesan-filter-chip-btn {
    border: 1px solid var(--mud-palette-lines-default);
    background: var(--mud-palette-surface);
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: all 0.15s ease;
    color: var(--mud-palette-text-secondary);
}

.sesan-filter-chip-btn:hover {
    background: rgba(0, 0, 0, 0.04);
}

.sesan-filter-chip-btn.active {
    border-color: var(--mud-palette-primary);
    background: rgba(var(--mud-palette-primary-rgb), 0.1);
    color: var(--mud-palette-primary);
}

.sesan-filter-chip-btn.chip-unmapped {
    border-color: #ef4444;
    color: #f87171;
}

.sesan-filter-chip-btn.chip-unmapped.active {
    background: rgba(239, 68, 68, 0.15);
    border-color: #ef4444;
    color: #fca5a5;
}

.sesan-type-badge {
    border: 1px solid transparent;
    border-radius: 4px;
    padding: 2px 7px;
    font-size: 0.72rem;
    font-weight: 700;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 3px;
    transition: opacity 0.15s ease;
}

.sesan-type-badge:hover {
    opacity: 0.85;
}

.badge-rest {
    background: rgba(2, 132, 199, 0.18);
    color: #38bdf8;
    border-color: rgba(2, 132, 199, 0.35);
}

.badge-staff {
    background: rgba(245, 158, 11, 0.18);
    color: #fbbf24;
    border-color: rgba(245, 158, 11, 0.35);
}

.sesan-badge-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    font-size: 0.7rem;
    font-weight: 700;
    border-radius: 9px;
    background: rgba(255, 255, 255, 0.1);
}

.chip-unmapped .sesan-badge-count {
    background: #ef4444;
    color: #ffffff;
}

/* ── Validation Warning Banner ── */
.sesan-val-banner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 14px;
    background: rgba(239, 68, 68, 0.12);
    border-bottom: 1px solid rgba(239, 68, 68, 0.25);
    color: #fca5a5;
    font-size: 0.82rem;
    flex-shrink: 0;
}

.sesan-val-banner.val-success {
    background: rgba(16, 185, 129, 0.12);
    border-color: rgba(16, 185, 129, 0.25);
    color: #86efac;
}

/* ── Bảng Dữ Liệu Tối Ưu ── */
.sesan-grid-wrap {
    flex: 1;
    overflow-y: auto;
    position: relative;
    height: 100%;
}

.sesan-table {
    height: 100%;
}

.sesan-table .mud-table-head th {
    font-size: 0.78rem !important;
    font-weight: 700 !important;
    padding: 8px 10px !important;
    white-space: nowrap !important;
    background: #0f172a !important;
    border-bottom: 2px solid #1e293b !important;
    color: #94a3b8 !important;
}

.sesan-table .mud-table-body td {
    padding: 6px 10px !important;
    font-size: 0.82rem !important;
    vertical-align: middle !important;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05) !important;
}

.sesan-table .mud-input-control {
    margin: 0 !important;
}

.sesan-table input[type=number]::-webkit-inner-spin-button,
.sesan-table input[type=number]::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}
.sesan-table input[type=number] {
    -moz-appearance: textfield;
}

.sesan-table-row {
    cursor: pointer;
    transition: background 0.12s ease;
}

.sesan-table-row:hover {
    background: rgba(6, 182, 212, 0.08) !important;
}

.sesan-table-row.active-row {
    background: rgba(6, 182, 212, 0.15) !important;
    outline: 2px solid #06b6d4;
    outline-offset: -2px;
}

.sesan-table-row.row-unmapped {
    background: rgba(239, 68, 68, 0.06);
}

/* ── Cột Mapping Mã POS ── */
.sesan-map-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    background: rgba(16, 185, 129, 0.15);
    border: 1px solid rgba(16, 185, 129, 0.35);
    border-radius: 4px;
    color: #34d399;
    font-weight: 600;
    font-size: 0.8rem;
}

.sesan-unmapped-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    background: rgba(244, 63, 94, 0.15);
    border: 1px dashed #f43f5e;
    border-radius: 4px;
    color: #fb7185;
    font-weight: 700;
    font-size: 0.78rem;
}

/* ── 3-Way KPI Cards Gọn Gàng ── */
.sesan-kpi-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 14px;
    background: var(--mud-palette-surface);
    border-bottom: 1px solid var(--mud-palette-lines-default);
    flex-shrink: 0;
}

.sesan-kpi-card {
    flex: 1;
    padding: 6px 12px;
    border-radius: 6px;
    border: 1px solid var(--mud-palette-lines-default);
    background: var(--mud-palette-background);
}

.sesan-kpi-label {
    font-size: 0.72rem;
    color: var(--mud-palette-text-secondary);
    text-transform: uppercase;
    font-weight: 600;
}

.sesan-kpi-val {
    font-size: 1.05rem;
    font-weight: 700;
    line-height: 1.3;
}

/* ══════════════════════════════════════════════════════════════════════
   BẢNG ĐỐI SOÁT 3 CHIỀU DARK THEME HÀI HÒA & CHUYÊN NGHIỆP
   ══════════════════════════════════════════════════════════════════════ */
.sesan-table-3way {
    background: transparent !important;
}

/* Header Categories */
.sesan-table-3way .th-agg {
    background: rgba(2, 132, 199, 0.15) !important;
    color: #38bdf8 !important;
    border-bottom: 2px solid #0284c7 !important;
}

.sesan-table-3way .th-bep {
    background: rgba(16, 185, 129, 0.15) !important;
    color: #34d399 !important;
    border-bottom: 2px solid #10b981 !important;
}

.sesan-table-3way .th-kh {
    background: rgba(168, 85, 247, 0.15) !important;
    color: #c084fc !important;
    border-bottom: 2px solid #a855f7 !important;
}

.sesan-table-3way .th-lech {
    background: rgba(239, 68, 68, 0.15) !important;
    color: #f87171 !important;
    border-bottom: 2px solid #ef4444 !important;
}

.sesan-table-3way .th-pos {
    background: rgba(8, 145, 178, 0.15) !important;
    color: #22d3ee !important;
    border-bottom: 2px solid #0891b2 !important;
}

.sesan-table-3way .th-internal {
    background: rgba(245, 158, 11, 0.15) !important;
    color: #fbbf24 !important;
    border-bottom: 2px solid #f59e0b !important;
}

/* Data Cell Columns */
.sesan-table-3way td.col-agg {
    color: #94a3b8 !important;
    background: rgba(2, 132, 199, 0.03) !important;
}

.sesan-table-3way td.col-pos {
    color: #22d3ee !important;
    background: rgba(8, 145, 178, 0.03) !important;
}

.sesan-table-3way td.col-bep {
    color: #34d399 !important;
    background: rgba(16, 185, 129, 0.04) !important;
}

.sesan-table-3way td.col-internal {
    color: #fbbf24 !important;
    background: rgba(245, 158, 11, 0.04) !important;
}

.sesan-table-3way td.col-kh {
    color: #d8b4fe !important;
    background: rgba(168, 85, 247, 0.04) !important;
}

/* Delta Pills */
.sesan-delta-pill {
    display: inline-block;
    padding: 2px 7px;
    border-radius: 4px;
    font-size: 0.8rem;
    font-weight: 700;
}

.sesan-delta-pill.pill-ok {
    color: #34d399;
    font-weight: 600;
}

.sesan-delta-pill.pill-warn {
    background: rgba(245, 158, 11, 0.18);
    color: #fde68a;
    border: 1px solid rgba(245, 158, 11, 0.35);
}

.sesan-delta-pill.pill-err {
    background: rgba(239, 68, 68, 0.18);
    color: #fca5a5;
    border: 1px solid rgba(239, 68, 68, 0.35);
}

/* Status Badges */
.sesan-status-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 9px;
    border-radius: 4px;
    font-size: 0.78rem;
    line-height: 1.25;
}

.sesan-status-badge.badge-matched {
    background: rgba(16, 185, 129, 0.15);
    color: #34d399;
    border: 1px solid rgba(16, 185, 129, 0.3);
    font-weight: 600;
}

.sesan-status-badge.badge-oos {
    background: rgba(100, 116, 139, 0.18);
    color: #94a3b8;
    border: 1px solid rgba(100, 116, 139, 0.3);
}

.sesan-status-badge.badge-diff {
    background: rgba(239, 68, 68, 0.12);
    color: #fca5a5;
    border: 1px solid rgba(239, 68, 68, 0.25);
    font-weight: 500;
}

/* ── Bộ chọn Tùy chọn Ô trống Thực nhận (Blank Receipt Option) ── */
.sesan-blank-option-box {
    display: inline-flex;
    align-items: center;
}

.sesan-blank-select {
    min-width: 200px;
    background: rgba(255, 255, 255, 0.04);
    border-radius: 6px;
}

.sesan-blank-select .mud-input-outlined-border {
    border-color: rgba(255, 255, 255, 0.2) !important;
}

.sesan-blank-select:hover .mud-input-outlined-border {
    border-color: #38bdf8 !important;
}

.sesan-blank-select .mud-input-slot {
    font-size: 0.8rem !important;
    font-weight: 500;
}

.sesan-blank-opt-item {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    font-size: 0.82rem;
    font-weight: 500;
    padding: 2px 0;
}
