/* Global UI layer (AppGlobalStyles): cross-cutting premium treatments applied on top of
   MudBlazor. Depends on tokens.css. Signature moves: soft depth, glass appbar, brand-pill
   nav, shimmer skeletons, unified micro-motion, focus-visible rings. */

/* ---- Inter self-hosted 600/700 (400/500 declared in app.css) ---- */
@font-face { font-family:'Inter'; font-style:normal; font-weight:600; font-display:swap;
    src:url('fonts/inter-vietnamese-600.woff2') format('woff2');
    unicode-range:U+0102-0103,U+0110-0111,U+0128-0129,U+0168-0169,U+01A0-01A1,U+01AF-01B0,U+0300-0301,U+0303-0304,U+0308-0309,U+0323,U+0329,U+1EA0-1EF9,U+20AB; }
@font-face { font-family:'Inter'; font-style:normal; font-weight:600; font-display:swap;
    src:url('fonts/inter-latin-600.woff2') format('woff2');
    unicode-range:U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+2000-206F,U+2074,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD; }
@font-face { font-family:'Inter'; font-style:normal; font-weight:700; font-display:swap;
    src:url('fonts/inter-vietnamese-700.woff2') format('woff2');
    unicode-range:U+0102-0103,U+0110-0111,U+0128-0129,U+0168-0169,U+01A0-01A1,U+01AF-01B0,U+0300-0301,U+0303-0304,U+0308-0309,U+0323,U+0329,U+1EA0-1EF9,U+20AB; }
@font-face { font-family:'Inter'; font-style:normal; font-weight:700; font-display:swap;
    src:url('fonts/inter-latin-700.woff2') format('woff2');
    unicode-range:U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+2000-206F,U+2074,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD; }

/* ---- App canvas ---- */
.app-canvas { max-width: var(--u-canvas-max); margin: 0 auto; padding: var(--u-page-gutter); }
@media (max-width: 600px) { .app-canvas { padding: 16px; } }

/* ---- Glass appbar ---- */
.app-topbar.mud-appbar {
    background: var(--u-glass-bg) !important;
    -webkit-backdrop-filter: saturate(180%) blur(20px);
    backdrop-filter: saturate(180%) blur(20px);
    border-bottom: 1px solid var(--u-glass-border);
    color: var(--u-text-primary);
}
.app-logo-tile {
    width: 32px; height: 32px; border-radius: var(--u-radius-sm);
    background: var(--u-primary); color: #fff; display: flex; align-items: center;
    justify-content: center; font-weight: 700; flex: 0 0 auto;
}

/* ---- Soft-depth cards ---- */
.app-surface {
    background: var(--u-surface-1);
    border: 1px solid var(--u-border);
    border-radius: var(--u-radius-card);
    box-shadow: var(--u-shadow-md);
}
.app-surface--flat { box-shadow: none; }
.app-surface--interactive {
    transition: box-shadow var(--u-dur-2) var(--u-ease-standard),
                transform var(--u-dur-2) var(--u-ease-standard);
}
.app-surface--interactive:hover { box-shadow: var(--u-shadow-lg); transform: translateY(-2px); }

/* ---- Brand-pill nav (active/hover) ---- */
.app-nav .mud-nav-link,
.app-nav .mud-nav-group > .mud-nav-link {
    border-radius: var(--u-radius-sm);
    margin: 2px 6px;
    transition: background var(--u-dur-2) var(--u-ease-standard), color var(--u-dur-2) var(--u-ease-standard);
}
.app-nav .mud-nav-link:hover { background: #F1F0FA; }
.app-nav .mud-nav-link.active,
.app-nav .mud-nav-link.mud-nav-link-active {
    background: var(--u-primary-container);
    color: var(--u-primary) !important;
    font-weight: 600;
    box-shadow: inset 3px 0 0 0 var(--u-primary);
}
.app-nav .mud-nav-link.active .mud-icon-root { color: var(--u-primary) !important; }

/* ---- Shimmer skeleton engine (the ONLY shimmer definition) ---- */
.app-shimmer {
    position: relative; overflow: hidden;
    background: var(--u-skeleton-base);
    border-radius: var(--u-radius-sm);
}
.app-shimmer::after {
    content: ""; position: absolute; inset: 0;
    transform: translateX(-100%);
    background: linear-gradient(90deg, transparent, var(--u-skeleton-highlight), transparent);
    animation: app-shimmer 1600ms linear infinite;
}
@keyframes app-shimmer { 100% { transform: translateX(100%); } }

/* ---- Card / list entrance + stagger ---- */
.app-rise { animation: app-rise var(--u-dur-4) var(--u-ease-emphasized) both; }
@keyframes app-rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ---- Top route progress bar ---- */
.app-page-progress {
    position: fixed; top: 0; left: 0; height: 3px; width: 100%;
    z-index: 2000; background: transparent; overflow: hidden;
}
.app-page-progress > span {
    display: block; height: 100%; width: 40%;
    background: var(--u-primary);
    animation: app-progress 1100ms var(--u-ease-emphasized) infinite;
}
@keyframes app-progress { 0% { transform: translateX(-100%); } 100% { transform: translateX(350%); } }

/* ---- Focus-visible ring (keyboard only) ---- */
:focus-visible {
    outline: 2px solid var(--u-primary);
    outline-offset: 2px;
    border-radius: 4px;
}

/* ---- Confirm-dialog halo (reuses .app-state__halo sizing) ---- */
.app-confirm-halo--danger { background: var(--u-error-bg); color: var(--u-error); border-radius: 50%; display: flex; align-items: center; justify-content: center; }
.app-confirm-halo--primary { background: var(--u-primary-50); color: var(--u-primary); border-radius: 50%; display: flex; align-items: center; justify-content: center; }

/* ---- Description list (read-only detail rows) ---- */
.app-desc-list { margin: 0; }
.app-desc-row { display: grid; grid-template-columns: minmax(120px, 34%) minmax(0, 1fr); gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--u-border); }
.app-desc-row:last-child { border-bottom: none; }
.app-desc-term { color: var(--u-text-secondary); font-size: 13px; }
/* minmax(0, 1fr) + overflow-wrap: a value with no spaces (a sha256 hash, a GUID, a long file name)
   must wrap inside its cell instead of widening the grid and spilling over the next column. */
.app-desc-detail { color: var(--u-text-primary); font-weight: 500; min-width: 0; overflow-wrap: anywhere; }
@media (max-width: 560px) { .app-desc-row { grid-template-columns: 1fr; gap: 2px; } }

/* ---- Permission tree (role permissions dialog) ---- */
.app-perm-tree { border: 1px solid var(--u-border); border-radius: var(--u-radius-md); padding: 4px; max-height: 52vh; overflow-y: auto; }
.app-perm-node { display: flex; align-items: center; gap: 8px; }
.app-perm-module { font-weight: 600; }
.app-perm-tree .mud-treeview-item-content { border-radius: var(--u-radius-sm); }

/* ---- User menu (avatar dropdown) ---- */
.app-usermenu-trigger { display: inline-flex; align-items: center; cursor: pointer; border-radius: 50%; }
.app-usermenu-trigger:focus-visible { outline: 2px solid var(--u-primary); outline-offset: 2px; }
.app-usermenu { min-width: 260px; padding-top: 0; }
.app-usermenu-head { display: flex; gap: 12px; align-items: flex-start; padding: 16px; }
.app-usermenu-info { min-width: 0; }
.app-usermenu-name { font-weight: 600; font-size: 14px; color: var(--u-text-primary); }
.app-usermenu-email { font-size: 12.5px; color: var(--u-text-secondary); overflow: hidden; text-overflow: ellipsis; }

/* ---- Soft-tint tiles (stat-card icons, accents) ---- */
.app-tint--primary { background: var(--u-primary-50); color: var(--u-primary); }
.app-tint--success { background: var(--u-success-bg); color: var(--u-success-text); }
.app-tint--warning { background: var(--u-warning-bg); color: var(--u-warning-text); }
.app-tint--error { background: var(--u-error-bg); color: var(--u-error-text); }
.app-tint--info { background: var(--u-info-bg); color: var(--u-info-text); }
.app-tint--neutral { background: var(--u-neutral-chip); color: var(--u-neutral-chip-fg); }

/* ---- Premium MudDataGrid ---- */
.app-grid.mud-table-outlined { border: 1px solid var(--u-border); border-radius: var(--u-radius-card); overflow: hidden; box-shadow: var(--u-shadow-sm); }
.app-grid .mud-table-head th { background: var(--u-surface-sunken); color: var(--u-text-secondary); font-weight: 600; }
.app-grid .mud-table-row:hover { background: #F8F9FC; }

/* ---- Premium dialogs / popups ---- */
.mud-dialog {
    border-radius: var(--u-radius-xl) !important;
    box-shadow: var(--u-shadow-2xl) !important;
    border: 1px solid var(--u-border);
    overflow: hidden;
    animation: app-dialog-in var(--u-dur-3) var(--u-ease-emphasized) both;
}
@keyframes app-dialog-in { from { opacity: 0; transform: translateY(12px) scale(.98); } to { opacity: 1; transform: none; } }
.mud-dialog .mud-dialog-title { padding: 20px 24px 12px; border-bottom: 1px solid var(--u-border); }
.mud-dialog .mud-dialog-content { padding: 20px 24px; }
.mud-dialog .mud-dialog-actions { padding: 12px 24px; border-top: 1px solid var(--u-border); gap: 8px; background: var(--u-surface-2); }
.mud-overlay-dialog { backdrop-filter: blur(2px); background: var(--u-scrim) !important; }
/* All dialogs occupy a comfortable width — at least ~50% of the viewport, capped so they
   never overflow and go near-full on small screens. min-width beats MudBlazor's MaxWidth. */
.mud-dialog { width: clamp(320px, 50vw, calc(100vw - 32px)); max-width: calc(100vw - 32px) !important; }
@media (max-width: 700px) { .mud-dialog { width: calc(100vw - 24px); } }
.mud-dialog .mud-dialog-content { max-height: 70vh; overflow-y: auto; }

/* ---- Snackbar: rounded + left severity accent + soft shadow ---- */
.mud-snackbar { border-radius: var(--u-radius-md) !important; box-shadow: var(--u-shadow-lg) !important; border-left: 4px solid transparent; }
.mud-snackbar.mud-alert-filled-success { border-left-color: #0B6E38; }
.mud-snackbar.mud-alert-filled-error { border-left-color: #7A1418; }
.mud-snackbar.mud-alert-filled-warning { border-left-color: #8A5A00; }
.mud-snackbar.mud-alert-filled-info { border-left-color: #0058C7; }

/* ---- Buttons: weight + radius + press feedback ---- */
.mud-button-root { border-radius: var(--u-radius-sm) !important; font-weight: 600; letter-spacing: .01em; transition: transform var(--u-dur-1) var(--u-ease-standard), box-shadow var(--u-dur-2) var(--u-ease-standard); }
.mud-button-filled:active { transform: scale(.97); }
.mud-button-filled.mud-button-filled-primary { box-shadow: 0 2px 6px -1px rgba(13,0,157,.28); }
.mud-button-filled.mud-button-filled-primary:hover { box-shadow: 0 6px 14px -2px rgba(13,0,157,.34); }

/* ---- Inputs: focus ring in Duke Blue ---- */
.mud-input-outlined .mud-input-outlined-border { border-radius: var(--u-radius-sm); border-color: var(--u-border-control); }
.mud-input.mud-input-focused .mud-input-outlined-border { border-width: 1.5px !important; box-shadow: 0 0 0 3px rgba(13,0,157,.10); }

/* ---- Page content entrance ---- */
/* 123780: KHÔNG animate transform trên container trang — animation với fill-mode:both giữ lại
   transform (identity matrix) khiến .mud-container thành "containing block" cho position:fixed con
   → overlay/drawer Temporary bị neo theo container (đang cuộn) thay vì viewport, mở ra lệch vị trí.
   Dùng fade opacity-only (không transform) để giữ hiệu ứng vào trang mà không phá fixed-positioning. */
@keyframes app-fade { from { opacity: 0; } to { opacity: 1; } }
.mud-main-content > .mud-container { animation: app-fade var(--u-dur-4) var(--u-ease-emphasized) both; }

/* ---- Stat card top accent (liveliness) ---- */
.app-stat { position: relative; overflow: hidden; }
.app-stat::before { content: ""; position: absolute; top: 0; left: 0; right: 0; height: 3px; background: linear-gradient(90deg, var(--u-primary), var(--u-primary-300)); opacity: .9; }

/* ---- MudDataGrid: uppercase headers (Figma spec) ---- */
.mud-data-grid .mud-table-head .mud-table-cell {
    text-transform: uppercase;
    font-weight: 600;
    font-size: 12px; /* header nhỏ hơn body (14px) — đỡ chiếm chỗ, đỡ wrap 2-3 dòng ở cột hẹp */
    letter-spacing: 0.02em;
    color: var(--u-text-secondary, #4b5563);
}

/* ---- Table row 'View' action rendered as underlined link (Figma spec) ----
   MudButton's inner label span carries text-decoration:none by default; hit both the button
   and its inner label with !important so the underline actually paints. */
.mud-button-root.view-link,
.mud-button-root.view-link .mud-button-label,
.mud-button-root.view-link span { text-decoration: underline !important; text-underline-offset: 3px; }

/* ---- Opt-out list filter row (Figma spec) --------------------------------------------
   Layout: no card background — fields flow directly on the page surface. Static labels sit
   above each field; the search input has a square blue button glued to its right edge; the
   date range is one labeled group with a → separator; the Xóa (outlined) + Tìm kiếm (filled)
   actions sit on the far right of the SAME row. */
/* Bug 123273 (nguyên nhân THẬT — verify trên QA 2026-07-17): thanh scroll ngang cả trang KHÔNG do
   bảng, mà do MudDrawer detail (Anchor.End, 480px) khi ĐÓNG vẫn là position:fixed nằm off-canvas bên
   phải (right:-480px, visibility:visible) → cộng 480px vào scrollWidth toàn trang. body/html overflow-x
   hidden vô dụng vì drawer fixed theo viewport. Fix: drawer TEMPORARY bên phải khi đóng thì display:none
   (đóng = không chiếm layout) → hết tràn ngang; mở ra vẫn hiện bình thường. */
.mud-drawer-temporary.mud-drawer-pos-right.mud-drawer--closed { display: none !important; }
/* Responsive: drawer MỞ không bao giờ rộng hơn viewport (màn hẹp < 480px không tràn ngang);
   Width="480px" ở razor vẫn là chặn trên, max-width kéo về 100vw khi hẹp. Không hard-code px. */
.mud-drawer-temporary.mud-drawer-pos-right { max-width: 100vw; }
/* Sidebar (nav trái) không được scroll ngang: nav-group Administration rộng hơn drawer ~12px làm
   xuất hiện scrollbar ngang nhỏ dưới menu. Nav menu chỉ cuộn DỌC — chặn cuộn ngang, giữ overflow-y. */
.mud-drawer-pos-left .mud-drawer-content { overflow-x: hidden; }
/* Bug 123398: drawer detail cao = viewport TRỪ appbar (MudBlazor pin top = chiều cao appbar),
   KHÔNG bị bảng ít record kéo ngắn. Cần !important vì rule mặc định của MudDrawer specificity cao
   hơn (nếu không, height bám nội dung → cắt cụt). Nội dung dài (vd Rejected full history) cuộn
   TRONG drawer → nút hành động luôn thấy. Dùng biến appbar của Mud, không hard-code px. */
.mud-drawer-temporary.mud-drawer-pos-right { height: calc(100vh - var(--mud-appbar-min-height, 64px)) !important; }
.mud-drawer-temporary.mud-drawer-pos-right .mud-drawer-content { height: 100%; overflow-y: auto; }
/* Bug 123398 (regression): scrim overlay của drawer đang cao THEO content (position:fixed nhưng
   height = chiều cao container) → list < 10 record thì overlay ngắn, chừa khoảng trắng dưới bảng
   không bị làm mờ. Ép overlay kéo tới đáy viewport (bottom:0) để luôn phủ hết vùng nhìn thấy. */
.mud-overlay-drawer.mud-drawer-pos-right { bottom: 0 !important; min-height: calc(100vh - var(--mud-appbar-min-height, 64px)) !important; }
/* Giữ thêm: bảng rộng thì chỉ bảng cuộn ngang, không đẩy cả trang. */
.optout-table-scroll { overflow-x: auto; max-width: 100%; }
/* 123780 (re-open): width cột CỐ ĐỊNH & nhất quán mọi trang — table-layout:fixed để cột chỉ theo
   HeaderStyle (%), nội dung dài wrap trong cột thay vì nới cột. min-width giữ bảng không bị bóp méo;
   tràn màn hình nhỏ thì .optout-table-scroll cuộn ngang. break-word để token dài (userId) tự xuống dòng. */
.optout-table-scroll table { table-layout: fixed; width: 100%; min-width: 1080px; }
/* word-break chỉ cho BODY cell (token dài như userId) — header giữ wrap theo từ, không bẻ giữa chữ. */
.optout-table-scroll tbody .mud-table-cell { overflow-wrap: anywhere; word-break: break-word; vertical-align: top; }
.optout-table-scroll thead .mud-table-cell { overflow-wrap: normal; word-break: normal; }
/* 123780: Reason/Detail cell — clamp tối đa 2 dòng + "…", chặn nội dung dài phá layout cột */
.optout-clamp-2 { display: -webkit-box; -webkit-line-clamp: 2; line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; text-overflow: ellipsis; overflow-wrap: anywhere; }
.optout-filter { padding: 0; margin-bottom: 12px; min-width: 0; }
.optout-filter-grid {
    display: grid;
    grid-template-columns: minmax(220px, 1.6fr) minmax(120px, .8fr) minmax(120px, .8fr) minmax(260px, 1.4fr) auto;
    gap: 12px;
    align-items: end;
}
.optout-field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.optout-label { font-size: 12px; font-weight: 500; color: var(--u-text-secondary, #6b7280); letter-spacing: 0.01em; }
.optout-field .mud-input { background: #fff; }
/* Figma spec: filter inputs use 8px radius + 40px compact height (theme default is 12px/56px). */
.optout-field .mud-input-outlined-border { border-radius: 8px !important; }
.optout-field .mud-input.mud-input-outlined input.mud-input-slot,
.optout-field .mud-input.mud-input-outlined div.mud-input-slot { padding-top: 10px !important; padding-bottom: 10px !important; font-size: 13px; font-weight: 400; }
.optout-field .mud-input.mud-input-outlined input.mud-input-slot::placeholder { font-weight: 400; color: var(--u-text-secondary, #6b7280); opacity: 1; }
.optout-field .mud-input.mud-input-outlined { min-height: 40px; }
.optout-field .mud-input-adornment svg { font-size: 18px !important; color: var(--u-text-secondary, #6b7280); }
/* Search input + button glued into one control (Figma): the input grows, the button hugs its
   right edge sharing the border. Button borders on the left are flattened; input borders on
   the right are flattened; the two ride the same 40px height with a -1px overlap so their
   1px borders collapse into a single visual seam. */
.optout-field-search > div { align-items: stretch; gap: 0 !important; }
.optout-field-search .mud-input-control { flex: 1 1 auto; min-width: 0; margin-right: -1px; }
.optout-field-search .mud-input-outlined-border {
    border-top-right-radius: 0 !important;
    border-bottom-right-radius: 0 !important;
}
.optout-search-btn.mud-button-root {
    min-width: 40px;
    height: 40px;
    padding: 0 10px;
    border-radius: 0 8px 8px 0 !important;
    box-shadow: none;
    flex: 0 0 auto;
}
.optout-field-actions { flex-direction: row; gap: 8px; align-items: end; }
.optout-field-actions .mud-button-root { height: 40px; padding: 0 20px; }
@media (max-width: 900px) {
    .optout-filter-grid { grid-template-columns: 1fr 1fr; }
    .optout-field-actions { grid-column: 1 / -1; justify-content: flex-end; }
}

/* ---- Opt-out list tabs (Figma spec: rectangular container, rectangular pills) --------- */
.optout-tabs { display: flex; gap: 4px; padding: 4px; background: #fff; border-radius: 8px;
    border: 1px solid var(--u-border, #e5e7eb); width: fit-content; }
.optout-tab-pill {
    display: inline-flex; align-items: center; gap: 8px;
    padding: 6px 14px; border-radius: 6px; border: 1px solid transparent;
    background: transparent; color: var(--u-text-secondary, #4b5563);
    font-size: 14px; font-weight: 500; cursor: pointer; transition: background .15s, color .15s;
}
.optout-tab-pill:hover { background: rgba(13, 0, 157, .04); }
.optout-tab-pill--active {
    background: rgba(13, 0, 157, .06); border-color: rgba(13, 0, 157, .35);
    color: var(--u-primary, #0d009d);
}
.optout-tab-badge {
    display: inline-flex; align-items: center; justify-content: center;
    min-width: 22px; height: 20px; padding: 0 6px; border-radius: 4px;
    background: rgba(0, 0, 0, .06); color: var(--u-text-primary, #111827);
    font-size: 12px; font-weight: 600;
}
.optout-tab-pill--active .optout-tab-badge {
    background: rgba(13, 0, 157, .15); color: var(--u-primary, #0d009d);
}
.optout-create-btn.mud-button-root { height: 40px; padding: 0 20px; border-radius: 8px; }

/* ---- Opt-out action dialogs (Figma spec: 357px card, radius 16, bell icon centered,
   title, body/warning text, Cancel + primary CTA). Shared by Create / Approve / Reject /
   MarkCompleted / UpdateResult. Selectors cover BOTH cases where MudBlazor applies our
   Class to the .mud-dialog root itself (compound) OR to a wrapping container (descendant). */
.mud-dialog.optout-create-dialog,
.mud-dialog.optout-action-dialog,
.optout-create-dialog .mud-dialog,
.optout-action-dialog .mud-dialog { border-radius: 16px !important; max-width: 357px !important; width: 100% !important; }
/* Bug 123721: giá trị nhập ô Reject reason KHÔNG in đậm (theo Figma). */
.optout-reject-reason textarea, .optout-reject-reason input { font-weight: 400 !important; }
/* Text/placeholder mọi input & textarea trong popup opt-out = weight thường (Figma). Textarea
   multiline (vd Detail của Create) đang bị 600 (đậm) → ép 400 cho đồng nhất. */
.optout-create-dialog input, .optout-create-dialog textarea,
.optout-action-dialog input, .optout-action-dialog textarea { font-weight: 400 !important; font-size: 13px !important; }
.mud-dialog.optout-create-dialog .mud-dialog-title,
.mud-dialog.optout-action-dialog .mud-dialog-title,
.optout-create-dialog .mud-dialog-title,
.optout-action-dialog .mud-dialog-title { padding: 24px 24px 0 !important; border-bottom: 0 !important; }
.mud-dialog.optout-create-dialog .mud-dialog-content,
.mud-dialog.optout-action-dialog .mud-dialog-content,
.optout-create-dialog .mud-dialog-content,
.optout-action-dialog .mud-dialog-content { padding: 16px 24px !important; }
.mud-dialog.optout-create-dialog .mud-dialog-actions,
.mud-dialog.optout-action-dialog .mud-dialog-actions,
.optout-create-dialog .mud-dialog-actions,
.optout-action-dialog .mud-dialog-actions { padding: 16px 24px 20px !important; border-top: 0 !important; gap: 12px; }
.optout-create-header { display: flex; flex-direction: column; align-items: center; gap: 12px; }
/* 123728: title popup conflict căn giữa (kể cả khi xuống dòng) */
.optout-conflict-title { width: 100%; text-align: center; }
.optout-create-icon {
    width: 56px; height: 56px; border-radius: 50%;
    background: var(--u-primary-50, #EEEDFB);
    color: var(--u-primary, #0d009d);
    display: inline-flex; align-items: center; justify-content: center;
}
.optout-required { color: var(--u-error, #E5484D); margin-left: 2px; }
.optout-hint { display: block; margin-top: 4px; }
.optout-hint--ok { color: var(--u-success-text, #0B6E38); }
.optout-hint--err { color: var(--u-error-text, #A11D22); }
.optout-create-note { color: var(--u-text-secondary, #6b7280); font-size: 13px; }
.optout-dialog-note { color: var(--u-text-secondary, #6b7280); font-size: 13px; margin-top: 8px; }
.optout-dialog-warning { color: var(--u-text-primary, #111); font-size: 13px; margin-top: 12px; }
.optout-dialog-btn.mud-button-root { flex: 1 1 0; height: 40px; border-radius: 8px; white-space: nowrap; }
/* Figma: the primary confirm CTA carries a longer label ("Yes, mark completed") and gets more
   width than the Cancel button so it stays on one line. Outlined = Cancel, Filled = confirm. */
.optout-action-dialog .mud-dialog-actions .optout-dialog-btn.mud-button-filled,
.optout-create-dialog .mud-dialog-actions .optout-dialog-btn.mud-button-filled { flex: 1.7 1 0; }

/* ---- Request-detail right-side drawer: header stays put, body scrolls, actions sticky
   at the bottom so long history logs never push CTAs out of view. ---- */
/* 123780 (reopen): detail drawer full-height ĐÚNG. MudBlazor render paper ở top:0 height:calc(100%-64)
   → drawer bị lệch lên, chừa 64px trống ở ĐÁY (không chạm đáy màn hình) = "popup lệch lên trên ko fit".
   Ghim top:64 (dưới app bar) + height:calc(100dvh-64) → phủ kín từ app bar tới đáy màn hình.
   :has() chỉ nhắm drawer opt-out, không đụng nav drawer. */
.mud-drawer:has(.optout-detail-drawer) {
    top: 64px !important;
    height: calc(100dvh - 64px) !important;
}
.optout-detail-drawer { display: flex; flex-direction: column; height: 100%; width: 100%; }
.optout-detail-header {
    display: flex; align-items: center;
    padding: 16px 20px; border-bottom: 1px solid var(--u-border, #e5e7eb);
    flex: 0 0 auto;
}
/* Drawer full-height: body nở đầy (flex:1 1 auto) → actions ghim đáy; min-height:0 để body cuộn
   khi nội dung dài (không cắt cụt — 123398), actions luôn hiện ở đáy. */
.optout-detail-body { flex: 1 1 auto; min-height: 0; overflow-y: auto; padding: 16px 20px; }
/* 123835: History Log cards — tokens inspected from Figma "View by status" (exact). */
.optout-history { display: flex; flex-direction: column; gap: 16px; }
.optout-history-card {
    display: flex; flex-direction: column; gap: 4px;
    background: #F8FAFC; border: 1px solid #E3E8EF; border-radius: 8px; padding: 16px;
}
.optout-history-time { font-size: 14px; line-height: 20px; color: #4B5565; }
.optout-history-event { font-size: 14px; line-height: 20px; font-weight: 500; color: #2652B9; }
.optout-history-msg { font-size: 14px; line-height: 20px; font-weight: 500; color: #121926; }
/* Figma spec: CTAs pinned to the RIGHT edge, primary destructive on the left of the
   trailing group. Buttons keep intrinsic width; wrap only if the drawer is very narrow. */
.optout-detail-actions {
    display: flex; flex-wrap: wrap; gap: 12px;
    justify-content: flex-end;
    padding: 16px 20px 20px;
    border-top: 1px solid var(--u-border, #e5e7eb);
    background: #fff; flex: 0 0 auto;
}
.optout-detail-actions .mud-button-root { min-width: 96px; height: 40px; border-radius: 8px; }


/* ---- Pagination: outlined boxes for ALL buttons (Figma spec) ----
   MudPagination structure: <div.mud-pagination-item> wraps <button.mud-button-root>.
   Reset the wrapper to layout-only (no border/bg), then style the INNER button. */
.mud-data-grid .mud-pagination { gap: 1px !important; }
.mud-data-grid .mud-pagination .mud-pagination-item {
    margin: 0 !important; padding: 0 !important;
    border: 0 !important; background: transparent !important; box-shadow: none !important;
    min-width: 0 !important; width: auto !important; height: auto !important;
}
.mud-data-grid .mud-pagination .mud-pagination-item .mud-button-root {
    min-width: 28px !important; width: 28px !important; height: 28px !important;
    padding: 0 !important;
    border: 1px solid var(--u-border, #EDEEF3) !important; border-radius: 6px !important;
    background: #fff !important; color: var(--u-text-secondary, #6b7280) !important;
    font-size: 12px !important; font-weight: 500 !important;
    box-shadow: none !important;
}
.mud-data-grid .mud-pagination .mud-pagination-item .mud-button-root .mud-icon-root { font-size: 14px !important; }
.mud-data-grid .mud-pagination .mud-pagination-item .mud-button-root:hover:not(:disabled) {
    background: var(--u-neutral-50, #F6F7FB) !important;
}
.mud-data-grid .mud-pagination .mud-pagination-item.mud-pagination-item-selected .mud-button-root {
    background: var(--u-primary, #0d009d) !important; border-color: var(--u-primary, #0d009d) !important; color: #fff !important;
}
.mud-data-grid .mud-pagination .mud-pagination-item .mud-button-root::before,
.mud-data-grid .mud-pagination .mud-pagination-item .mud-button-root::after { display: none !important; }
.mud-data-grid .mud-pagination .mud-pagination-item .mud-button-root:disabled { opacity: 0.5 !important; }

/* ---- Reduced-motion kill switch ---- */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: .001ms !important; animation-iteration-count: 1 !important;
        transition-duration: .001ms !important; scroll-behavior: auto !important;
    }
    .app-shimmer::after { animation: app-shimmer-pulse 1400ms ease-in-out infinite; }
    @keyframes app-shimmer-pulse { 0%,100% { opacity: .5; } 50% { opacity: 1; } }
}

/* ── POC Promotion Engine ────────────────────────────────────────────────────
   Prefix `promo-`, same convention as `optout-` above: module CSS lives here in
   the host (not in the RCL) so one file owns every page-level layout rule.
   WP0 only claims the prefix and the two structures every screen needs; WP6
   fills in the rest as it builds the list, wizard and detail pages. */
.promo-filter { padding: 0; margin-bottom: 12px; min-width: 0; }
.promo-filter-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; align-items: end; }
.promo-field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.promo-label { font-size: 12px; font-weight: 500; color: var(--u-text-secondary, #6b7280); letter-spacing: 0.01em; }
/* Mechanic tab: the technical setting name (SkuCheck4, CBSkuCheck) is for devs only —
   small, mono and muted, under the requester's own sentence. */
.promo-tech { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 11px; color: var(--u-text-secondary, #6b7280); }

/* ── WP6 · Promotion Engine UI ───────────────────────────────────────────────
   Layout rules for the three screens (danh sách, wizard, chi tiết). Appended
   below WP0's block; nothing above this line is modified. Everything uses the
   --u-* tokens with a literal fallback, same as the optout-* block. */

/* Stat tiles: six across on a desktop, wrapping to two on a phone. The whole
   tile is the click target, so the pointer and the focus ring live here rather
   than on the AppStatCard inside it. */
.promo-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.promo-stat { cursor: pointer; border-radius: var(--u-radius-card, 14px); transition: transform var(--u-dur-1, 120ms) var(--u-ease-standard, ease); }
.promo-stat:hover { transform: translateY(-1px); }
.promo-stat:focus-visible { outline: 2px solid var(--u-primary, #0d009d); outline-offset: 2px; }
/* The selected tile IS the active State filter — it has to be unmistakable, not a tint. */
.promo-stat--active .app-surface { border-color: var(--u-primary, #0d009d); box-shadow: 0 0 0 1px var(--u-primary, #0d009d) inset; }

/* Filter row. WP0 declared .promo-filter/.promo-filter-grid/.promo-field/.promo-label;
   these are the two modifier columns the six-field layout adds. */
.promo-field-daterange { grid-column: span 2; min-width: 320px; }
.promo-field-actions { flex-direction: row; align-items: center; gap: 8px; align-self: end; }
.promo-field .mud-input { background: #fff; }
.promo-field .mud-input-outlined-border { border-radius: 8px !important; }
.promo-field .mud-input.mud-input-outlined { min-height: 40px; }
/* Search input + button glued into one control, same seam trick as optout. */
.promo-search-btn { min-width: 40px; height: 40px; padding: 0 10px; border-top-left-radius: 0; border-bottom-left-radius: 0; }

.promo-bulk { border-color: var(--u-primary-300, #b9b4e8); background: var(--u-primary-50, #f3f2fd); }

/* Wide tables scroll inside their own box rather than pushing the page sideways. */
.promo-table-scroll { overflow-x: auto; max-width: 100%; }
.promo-table-scroll table { width: 100%; }
.promo-table-scroll tbody td { vertical-align: top; }
/* The 1080px floor belongs to the CAMPAIGN LIST only — it has ten columns and stops being
   readable below that. Applying it to every .promo-table-scroll forced the small tables inside
   the mechanic cards, the scope tab and the simulation cards to 1080px too, so they grew a
   horizontal scrollbar inside an already-narrow column for no reason. */
.promo-grid-wide .mud-table-root { min-width: 1080px; }
.promo-clamp-2 { display: -webkit-box; -webkit-line-clamp: 2; line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; text-overflow: ellipsis; overflow-wrap: anywhere; }
.promo-strong { font-weight: 600; color: var(--u-text-primary, #111827); }
/* Simulation bill table: name column takes the width, the three money columns stay compact. */
.promo-bill-editor td, .promo-bill-editor th { vertical-align: middle; }
.promo-bill-editor .promo-bill-num { text-align: right; white-space: nowrap; width: 140px; }
.promo-bill-editor .promo-bill-code { width: 170px; white-space: nowrap; }
.promo-bill-editor .promo-bill-num .mud-input-slot { text-align: right; }
.promo-bill-editor .mud-input-control { margin-top: 0; }

/* Step strip — shared by the wizard's four steps and the detail page's six
   states, so the two screens read as one flow. */
.promo-stepper { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.promo-step { display: flex; align-items: center; gap: 6px; }
.promo-step-dot {
    width: 22px; height: 22px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center;
    font-size: 11px; font-weight: 600; background: var(--u-neutral-chip, #eef0f4); color: var(--u-neutral-chip-fg, #4b5563);
    border: 1px solid var(--u-border, #e5e7eb);
}
.promo-step-label { font-size: 12px; color: var(--u-text-secondary, #6b7280); white-space: nowrap; }
.promo-step-line { flex: 1 1 16px; min-width: 16px; height: 2px; background: var(--u-border, #e5e7eb); border-radius: 2px; }
.promo-step-line--done { background: var(--u-primary, #0d009d); }
.promo-step--done .promo-step-dot { background: var(--u-primary, #0d009d); color: #fff; border-color: var(--u-primary, #0d009d); }
.promo-step--current .promo-step-dot { background: var(--u-primary-container, #e5e3fa); color: var(--u-primary, #0d009d); border-color: var(--u-primary, #0d009d); }
.promo-step--current .promo-step-label { color: var(--u-text-primary, #111827); font-weight: 600; }
/* Invalid stops AT the Validated step rather than passing it — red, in place. */
.promo-step--failed .promo-step-dot { background: var(--u-error-bg, #fee2e2); color: var(--u-error-text, #991b1b); border-color: var(--u-error, #dc2626); }
.promo-step--failed .promo-step-label { color: var(--u-error-text, #991b1b); font-weight: 600; }

.promo-state-box { text-align: right; }
@media (max-width: 960px) { .promo-state-box { text-align: left; margin-top: 12px; } }

/* Right column follows the tabs on a long page; released below the md breakpoint
   where the column stacks underneath and sticking would be wrong. */
.promo-sticky { position: sticky; top: 84px; }
@media (max-width: 960px) { .promo-sticky { position: static; } }

/* Active-conditions checklist: icon and text on one baseline, wrapping cleanly. */
.promo-check { display: flex; align-items: flex-start; gap: 8px; padding: 3px 0; font-size: 13px; line-height: 1.45; }

/* Mechanic card — the requester-facing unit. */
.promo-mechanic { border-left: 3px solid var(--u-primary-300, #b9b4e8); }
/* 61 and 79 SKUs are real volumes on campaign 26145, so the SKU table gets its
   own scroll box instead of making the card thousands of pixels tall. */
/* Gift picture: a fixed box so a table row never jumps when an image loads, contain so a
   portrait bottle and a square badge both stay whole. */
.promo-gift-img { width: 40px; height: 40px; object-fit: contain; background: var(--u-surface, #fff); border: 1px solid var(--u-border, #e5e7eb); border-radius: var(--u-radius-sm, 8px); vertical-align: middle; }
.promo-gift-img-lg { width: 96px; height: 96px; }
.promo-gift-url { max-width: 240px; overflow-wrap: anywhere; }
.promo-gift-preview { display: flex; align-items: center; gap: 8px; }

.promo-sku-scroll { max-height: 320px; overflow-y: auto; border: 1px solid var(--u-border, #e5e7eb); border-radius: var(--u-radius-sm, 8px); }
/* One recognition word per chip: it has to be obvious that ALL of them must be
   present on the bill line, not just any one. */
.promo-kw {
    display: inline-block; margin: 1px 3px 1px 0; padding: 1px 6px; border-radius: 4px;
    background: var(--u-neutral-chip, #eef0f4); color: var(--u-neutral-chip-fg, #4b5563);
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 11px;
}
.promo-kv { display: inline-block; margin: 2px 6px 2px 0; padding: 2px 8px; border-radius: 6px; background: var(--u-surface-sunken, #f7f8fa); font-size: 12px; }

/* Raw bill text and JSON: preformatted, scrollable, never wrapped mid-token. */
.promo-pre {
    margin: 0 0 8px; padding: 10px 12px; max-height: 360px; overflow: auto;
    background: var(--u-surface-sunken, #f7f8fa); border: 1px solid var(--u-border, #e5e7eb);
    border-radius: var(--u-radius-sm, 8px);
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; line-height: 1.5;
    white-space: pre; color: var(--u-text-primary, #111827);
}

/* History diff: old value struck through, new value in success tone. */
.promo-changes { margin-top: 4px; padding-left: 8px; border-left: 2px solid var(--u-border, #e5e7eb); font-size: 12px; }
.promo-from { text-decoration: line-through; color: var(--u-text-secondary, #6b7280); margin: 0 4px; }
.promo-to { color: var(--u-success-text, #166534); font-weight: 500; }
.promo-timeline { padding-left: 0; }

.promo-narrow-select { max-width: 240px; }
.promo-mechanic-list { margin: 0; padding-left: 20px; font-size: 13px; line-height: 1.7; }
.promo-bullets { margin: 4px 0 0; padding-left: 20px; font-size: 13px; line-height: 1.7; color: var(--u-text-secondary, #6b7280); }
.promo-indent { padding-left: 34px; }

/* Wizard: mall/store pickers are long lists, so they scroll in place. */
.promo-scroll-260 { max-height: 260px; overflow-y: auto; border: 1px solid var(--u-border, #e5e7eb); border-radius: var(--u-radius-sm, 8px); padding: 4px 8px; }
.promo-pick-row { display: flex; align-items: center; gap: 4px; }
.promo-pick-label { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex: 1 1 auto; min-width: 0; font-size: 13px; }
.promo-pick-label > span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.promo-chip { margin: 2px 4px 2px 0; }

.promo-dropzone {
    border: 2px dashed var(--u-border-control, #d1d5db); border-radius: var(--u-radius-md, 10px);
    padding: 32px 16px; text-align: center; background: var(--u-surface-sunken, #f7f8fa);
}
.promo-rule-row { padding: 10px 0; border-bottom: 1px solid var(--u-border, #e5e7eb); }
.promo-rule-row:last-child { border-bottom: 0; }
/* The template download is an <a download> carrying a data: URL — styled as a
   filled button so it does not read as an ordinary text link. */
.promo-download {
    display: inline-flex; align-items: center; gap: 6px; padding: 8px 16px;
    background: var(--u-primary, #0d009d); color: #fff !important; border-radius: var(--u-radius-sm, 8px);
    font-size: 14px; font-weight: 500; text-decoration: none;
}
.promo-download:hover { filter: brightness(1.1); text-decoration: none; }
