/**
 * BOS UI v2 — Wave 21b + 21d styles.
 *
 * Smart Sidebar + Toast UX + Empty States + Skeleton.
 * Loaded sau Tailwind compile để override default styles khi cần.
 */

/* ===== Wave 21b — Smart Sidebar pin star + more toggle ===== */
.bos-pin-star { transition: opacity 0.15s, color 0.15s; }
.bos-pin-star:hover { opacity: 1 !important; color: #fbbf24 !important; }

.bos-sidebar-more-toggle {
    display: block;
    padding: 8px 16px;
    color: #6b7280;
    font-size: 13px;
    font-weight: 500;
    border-top: 1px solid #e5e7eb;
    margin-top: 8px;
    cursor: pointer;
    transition: background 0.15s;
}
.bos-sidebar-more-toggle:hover { background: #f3f4f6; color: #111827; }
.bos-sidebar-more-list a { font-size: 13px; padding-left: 28px !important; }

/* ===== Wave 21d — Undo Toast ===== */
.bos-undo-toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translate(-50%, 30px);
    background: #1f2937;
    color: #fff;
    padding: 14px 16px;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
    font-size: 14px;
    z-index: 99999;
    min-width: 280px;
    max-width: 420px;
    opacity: 0;
    transition: opacity 0.25s, transform 0.25s;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
}
.bos-undo-toast--in {
    opacity: 1;
    transform: translate(-50%, 0);
}
.bos-undo-toast-msg { flex: 1; min-width: 0; }
.bos-undo-toast-btn {
    background: transparent;
    color: #fbbf24;
    border: 1px solid #fbbf24;
    padding: 6px 12px;
    border-radius: 8px;
    font-weight: 600;
    font-size: 13px;
    cursor: pointer;
    transition: background 0.15s;
}
.bos-undo-toast-btn:hover { background: #fbbf24; color: #1f2937; }
.bos-undo-toast-bar {
    position: absolute;
    left: 0;
    bottom: 0;
    width: 100%;
    height: 3px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 0 0 12px 12px;
    overflow: hidden;
}
.bos-undo-toast-bar-fill {
    height: 100%;
    width: 100%;
    background: linear-gradient(90deg, #fbbf24, #f97316);
    transition: width 4.98s linear;
}

/* ===== Wave 21c — Loading Skeleton (placeholder shimmer) ===== */
.bos-skeleton {
    background: linear-gradient(90deg, #f1f5f9 0%, #e2e8f0 50%, #f1f5f9 100%);
    background-size: 200% 100%;
    animation: bosSkeletonShimmer 1.2s ease-in-out infinite;
    border-radius: 6px;
    display: inline-block;
    min-height: 16px;
}
@keyframes bosSkeletonShimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

/* ===== Wave 21c — Empty State ===== */
.bos-empty-state {
    text-align: center;
    padding: 48px 24px;
    color: #6b7280;
}
.bos-empty-state__icon {
    font-size: 56px;
    color: #cbd5e1;
    margin-bottom: 16px;
}
.bos-empty-state__title {
    font-size: 16px;
    font-weight: 600;
    color: #111827;
    margin-bottom: 6px;
}
.bos-empty-state__msg { font-size: 14px; margin-bottom: 16px; }
.bos-empty-state__cta {
    display: inline-block;
    background: #3b82f6;
    color: #fff;
    padding: 9px 16px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    transition: background 0.15s;
    text-decoration: none;
}
.bos-empty-state__cta:hover { background: #2563eb; color: #fff; text-decoration: none; }

/* ===== Wave 21g — Onboarding tour overlay + tooltip ===== */
.bos-tour-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.55);
    z-index: 99990;
    backdrop-filter: blur(2px);
}
.bos-tour-tooltip {
    position: absolute;
    z-index: 99991;
    width: 320px;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 24px 64px rgba(0, 0, 0, 0.3);
    padding: 20px;
    opacity: 0;
    visibility: hidden;
    transition: top 0.2s, left 0.2s, opacity 0.2s;
}
.bos-tour-step-counter {
    font-size: 11px;
    color: #6b7280;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
}
.bos-tour-title {
    font-size: 17px;
    font-weight: 700;
    margin: 0 0 10px;
    color: #111827;
}
.bos-tour-body {
    font-size: 14px;
    line-height: 1.5;
    color: #4b5563;
    margin-bottom: 16px;
}
.bos-tour-actions { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.bos-tour-skip {
    background: transparent;
    color: #6b7280;
    border: none;
    font-size: 13px;
    cursor: pointer;
    padding: 6px 10px;
}
.bos-tour-skip:hover { color: #111827; }
.bos-tour-next {
    background: #3b82f6;
    color: #fff;
    border: none;
    border-radius: 8px;
    padding: 9px 16px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s;
}
.bos-tour-next:hover { background: #2563eb; }
.bos-tour-target-highlight {
    position: relative;
    z-index: 99989;
    outline: 3px solid #fbbf24;
    outline-offset: 4px;
    border-radius: 6px;
    box-shadow: 0 0 0 9999px rgba(15, 23, 42, 0.55);
    pointer-events: none;
}

/* ===== Wave 21i — Theme Switcher FAB + Drawer ===== */
.bos-theme-fab {
    position: fixed; bottom: 80px; right: 24px;
    width: 48px; height: 48px; border-radius: 50%;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    color: #fff; border: none;
    box-shadow: 0 8px 20px rgba(99, 102, 241, 0.35);
    cursor: pointer; z-index: 9998; font-size: 18px;
    display: flex; align-items: center; justify-content: center;
    transition: transform 0.15s;
}
.bos-theme-fab:hover { transform: scale(1.08); }
.bos-theme-drawer {
    position: fixed; bottom: 24px; right: 24px;
    width: 320px; max-width: calc(100% - 48px);
    background: #fff; border-radius: 16px;
    box-shadow: 0 24px 64px rgba(0, 0, 0, 0.25);
    transform: translateY(20px) scale(0.95); opacity: 0; visibility: hidden;
    transition: all 0.2s; z-index: 9999; overflow: hidden;
}
.bos-theme-drawer.is-open {
    transform: translateY(0) scale(1); opacity: 1; visibility: visible; bottom: 140px;
}
.bos-theme-drawer-header { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid #f1f5f9; }
.bos-theme-drawer-header h4 { margin: 0; font-size: 16px; font-weight: 700; color: #111827; }
.bos-theme-drawer-close { background: transparent; border: none; font-size: 22px; color: #9ca3af; cursor: pointer; line-height: 1; }
.bos-theme-drawer-body { padding: 8px 0; max-height: 320px; overflow-y: auto; }
.bos-theme-item { display: flex; align-items: center; gap: 12px; padding: 12px 20px; color: #374151; text-decoration: none; transition: background 0.12s; }
.bos-theme-item:hover { background: #f9fafb; color: #111827; text-decoration: none; }
.bos-theme-item.is-active { background: #eef2ff; color: #4f46e5; font-weight: 600; }
.bos-theme-dot { width: 22px; height: 22px; border-radius: 50%; box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15); flex-shrink: 0; }
.bos-theme-label { flex: 1; font-size: 14px; }
.bos-theme-check { color: #4f46e5; font-size: 13px; }
.bos-theme-drawer-footer { padding: 12px 20px; border-top: 1px solid #f1f5f9; text-align: center; }
.bos-theme-back-classic { font-size: 12px; color: #6b7280; text-decoration: none; }
.bos-theme-back-classic:hover { color: #111827; }

/* ===== Wave 21j — Cmd+K Quick Search palette ===== */
.bos-cmdk-overlay { position: fixed; inset: 0; background: rgba(15, 23, 42, 0.55); backdrop-filter: blur(4px); z-index: 99995; }
.bos-cmdk-modal {
    position: fixed; top: 15%; left: 50%; transform: translateX(-50%);
    width: 560px; max-width: calc(100% - 32px); background: #fff;
    border-radius: 16px; box-shadow: 0 30px 80px rgba(0, 0, 0, 0.35);
    z-index: 99996; overflow: hidden; animation: bosCmdkIn 0.18s ease-out;
}
@keyframes bosCmdkIn { from { transform: translate(-50%, -10px) scale(0.97); opacity: 0; } to { transform: translate(-50%, 0) scale(1); opacity: 1; } }
.bos-cmdk-search { display: flex; align-items: center; gap: 12px; padding: 16px 20px; border-bottom: 1px solid #f1f5f9; }
.bos-cmdk-search i { color: #9ca3af; font-size: 16px; }
.bos-cmdk-input { flex: 1; border: none; outline: none; font-size: 16px; background: transparent; color: #111827; }
.bos-cmdk-esc { background: #f3f4f6; color: #6b7280; padding: 2px 8px; border-radius: 4px; font-family: monospace; font-size: 11px; cursor: pointer; border: none; }
.bos-cmdk-results { max-height: 360px; overflow-y: auto; padding: 8px 0; }
.bos-cmdk-empty { padding: 32px 20px; text-align: center; color: #9ca3af; font-size: 14px; }
.bos-cmdk-item { display: flex; align-items: center; gap: 12px; padding: 10px 20px; color: #374151; text-decoration: none; cursor: pointer; transition: background 0.08s; }
.bos-cmdk-item.is-active { background: #f0f9ff; color: #0c4a6e; }
.bos-cmdk-item:hover { color: #0c4a6e; text-decoration: none; }
.bos-cmdk-item-icon { width: 18px; color: #6b7280; text-align: center; }
.bos-cmdk-item.is-active .bos-cmdk-item-icon { color: #0284c7; }
.bos-cmdk-item-label { flex: 1; font-size: 14px; }
.bos-cmdk-item-hint { color: #9ca3af; font-size: 12px; }
.bos-cmdk-item.is-active .bos-cmdk-item-hint { color: #0284c7; }
.bos-cmdk-footer { display: flex; gap: 20px; padding: 10px 20px; border-top: 1px solid #f1f5f9; background: #fafbfc; font-size: 11px; color: #6b7280; }
.bos-cmdk-footer kbd { background: #fff; border: 1px solid #d1d5db; border-radius: 3px; padding: 1px 5px; font-family: monospace; font-size: 10px; box-shadow: 0 1px 0 #d1d5db; }

/* ===== Wave 21t — Inline form error UX =================== */
/*  Replace red text + red border default jQuery validation/Laravel error
    với icon ⚠ + colored bg + actionable hint. Shake animation on first appearance.
*/

body.bos-ui-v2 label.error,
body.bos-ui-v2 .invalid-feedback,
body.bos-ui-v2 span.text-danger.error-msg,
body.bos-ui-v2 .bos-error-enhanced {
    display: inline-block;
    background: #fef2f2;
    color: #b91c1c;
    border: 1px solid #fecaca;
    border-radius: 6px;
    padding: 4px 10px 4px 8px;
    font-size: 12px;
    font-weight: 500;
    margin-top: 5px;
    line-height: 1.4;
    max-width: 100%;
}
body.bos-ui-v2 .bos-error-icon {
    color: #dc2626;
    margin-right: 4px;
    font-size: 11px;
}
body.bos-ui-v2 .bos-error-msg {
    vertical-align: middle;
}

/* Input field on error: red border + soft pink bg + red focus ring */
body.bos-ui-v2 .form-group.has-error .form-control,
body.bos-ui-v2 .form-group.has-error input.form-control,
body.bos-ui-v2 .form-group.has-error select,
body.bos-ui-v2 .form-group.has-error textarea,
body.bos-ui-v2 .bos-input-error {
    border-color: #fca5a5 !important;
    background-color: #fef9f9 !important;
}
body.bos-ui-v2 .form-group.has-error .form-control:focus,
body.bos-ui-v2 .bos-input-error:focus {
    border-color: #dc2626 !important;
    box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.12) !important;
    background-color: #fff !important;
}
body.bos-ui-v2 .form-group.has-error label:not(.error):not(.bos-error-enhanced) {
    color: #b91c1c !important;
}

/* Shake animation when error first appears */
@keyframes bosErrorShake {
    0%, 100% { transform: translateX(0); }
    20%, 60% { transform: translateX(-4px); }
    40%, 80% { transform: translateX(4px); }
}
body.bos-ui-v2 .bos-error-shake {
    animation: bosErrorShake 0.5s ease;
}

/* Success state (validated field) */
body.bos-ui-v2 .form-group.has-success .form-control,
body.bos-ui-v2 .form-group.was-validated .form-control:valid {
    border-color: #6ee7b7 !important;
}
body.bos-ui-v2 .form-group.has-success label {
    color: #047857 !important;
}

/* KiotViet error variant — slightly muted */
body.bos-theme-kiotviet label.error,
body.bos-theme-kiotviet .bos-error-enhanced {
    border-color: #fecaca;
    background: #fef2f2;
}

/* Dark mode error variant */
body.bos-dark-mode label.error,
body.bos-dark-mode .bos-error-enhanced,
body.bos-dark-mode .invalid-feedback {
    background: rgba(239, 68, 68, 0.15) !important;
    color: #fca5a5 !important;
    border-color: rgba(239, 68, 68, 0.35) !important;
}
body.bos-dark-mode .bos-error-icon {
    color: #f87171 !important;
}
body.bos-dark-mode .form-group.has-error .form-control,
body.bos-dark-mode .bos-input-error {
    background-color: rgba(239, 68, 68, 0.08) !important;
    border-color: #f87171 !important;
}

/* ===== Wave 21u — Typography hierarchy + 8px spacing rhythm == */
/*  Establish proper visual hierarchy + consistent vertical rhythm.

    Type scale:    h1 24 → h2 20 → h3 18 → h4 16 → body 14 → small 12
    Spacing grid:  4 / 8 / 12 / 16 / 20 / 24 / 32 / 48 / 64

    Vertical rhythm:
       section margin-bottom    24px
       form-group margin-bottom 16px
       box-body padding          16px
       modal-body padding        20px
*/

body.bos-ui-v2 {
    --bos-space-1: 4px;
    --bos-space-2: 8px;
    --bos-space-3: 12px;
    --bos-space-4: 16px;
    --bos-space-5: 20px;
    --bos-space-6: 24px;
    --bos-space-8: 32px;
    --bos-space-12: 48px;

    --bos-font-xs: 11px;
    --bos-font-sm: 12px;
    --bos-font-base: 14px;
    --bos-font-md: 16px;
    --bos-font-lg: 18px;
    --bos-font-xl: 20px;
    --bos-font-2xl: 24px;

    --bos-leading-tight: 1.25;
    --bos-leading-normal: 1.5;
    --bos-leading-relaxed: 1.625;

    --bos-weight-medium: 500;
    --bos-weight-semibold: 600;
    --bos-weight-bold: 700;
}

/* Typography scale — proper inverse pyramid */
body.bos-ui-v2 .content-header h1,
body.bos-ui-v2 section.content-header > h1 {
    font-size: var(--bos-font-2xl) !important;
    line-height: var(--bos-leading-tight) !important;
    font-weight: var(--bos-weight-bold) !important;
    margin: 0 0 var(--bos-space-1) !important;
}
body.bos-ui-v2 .box-title,
body.bos-ui-v2 .box-header h3,
body.bos-ui-v2 .panel-heading h3,
body.bos-ui-v2 .card-header h3 {
    font-size: var(--bos-font-lg) !important; /* 18 — under h1 24 */
    line-height: var(--bos-leading-tight) !important;
    font-weight: var(--bos-weight-semibold) !important;
    margin: 0 !important;
}
body.bos-ui-v2 h4 {
    font-size: var(--bos-font-md) !important;
    font-weight: var(--bos-weight-semibold) !important;
    line-height: var(--bos-leading-normal) !important;
}
body.bos-ui-v2 .modal-title {
    font-size: var(--bos-font-lg) !important;
    font-weight: var(--bos-weight-semibold) !important;
}
body.bos-ui-v2 small,
body.bos-ui-v2 .small,
body.bos-ui-v2 .help-block,
body.bos-ui-v2 .text-muted {
    font-size: var(--bos-font-sm) !important;
    line-height: var(--bos-leading-normal) !important;
}

/* 8px spacing rhythm */
body.bos-ui-v2 .form-group {
    margin-bottom: var(--bos-space-4) !important; /* 16 */
}
body.bos-ui-v2 .box-body,
body.bos-ui-v2 .card-body,
body.bos-ui-v2 .panel-body {
    padding: var(--bos-space-4) !important; /* 16 */
}
body.bos-ui-v2 .modal-body {
    padding: var(--bos-space-5) !important; /* 20 */
}
body.bos-ui-v2 .box-header,
body.bos-ui-v2 .card-header,
body.bos-ui-v2 .panel-heading {
    padding: var(--bos-space-3) var(--bos-space-4) !important; /* 12 16 */
}
body.bos-ui-v2 section.content {
    padding: var(--bos-space-4) !important; /* 16 — instead of default 15 */
}
body.bos-ui-v2 .row {
    margin-left: -8px !important;
    margin-right: -8px !important;
}
body.bos-ui-v2 .row > [class*="col-"] {
    padding-left: 8px !important;
    padding-right: 8px !important;
}

/* Section gap (margin-bottom for top-level sections in content) */
body.bos-ui-v2 .box,
body.bos-ui-v2 .card,
body.bos-ui-v2 .panel {
    margin-bottom: var(--bos-space-6) !important; /* 24 */
}
body.bos-ui-v2 .alert {
    margin-bottom: var(--bos-space-4) !important;
    padding: var(--bos-space-3) var(--bos-space-4) !important;
}

/* Label sit closer to input (4px) */
body.bos-ui-v2 label {
    margin-bottom: var(--bos-space-1) !important; /* 4 */
    font-size: var(--bos-font-sm);
    font-weight: var(--bos-weight-medium);
}

/* ===== Wave 21v — Color semantic clean-up ================ */
/*  Strict semantic palette — utility classes + tokens.

    🔴 ERROR  — only for ERRORS (validation, system errors)
    🟠 WARNING — only for WARNINGS (stock low, expiring soon)
    🟢 SUCCESS — only for SUCCESS/PAID/ACTIVE
    🔵 INFO   — only for INFO/LINKS/TIPS
    💜 DUE    — only for AMOUNTS DUE (different from error)
    ⚫ NEUTRAL — for ACTIONS (edit, view, default buttons)
*/

body.bos-ui-v2 {
    /* Semantic tokens */
    --bos-color-error: #dc2626;
    --bos-color-error-bg: #fef2f2;
    --bos-color-error-border: #fca5a5;

    --bos-color-warning: #d97706;
    --bos-color-warning-bg: #fffbeb;
    --bos-color-warning-border: #fcd34d;

    --bos-color-success: #047857;
    --bos-color-success-bg: #ecfdf5;
    --bos-color-success-border: #6ee7b7;

    --bos-color-info: #1d4ed8;
    --bos-color-info-bg: #eff6ff;
    --bos-color-info-border: #93c5fd;

    --bos-color-due: #7c3aed; /* violet — chuyên cho "tiền nợ" */
    --bos-color-due-bg: #f5f3ff;
    --bos-color-due-border: #c4b5fd;

    --bos-color-neutral: #4b5563;
    --bos-color-neutral-bg: #f9fafb;
    --bos-color-neutral-border: #d1d5db;
}

/* Utility text classes */
body.bos-ui-v2 .bos-text-error    { color: var(--bos-color-error)   !important; }
body.bos-ui-v2 .bos-text-warning  { color: var(--bos-color-warning) !important; }
body.bos-ui-v2 .bos-text-success  { color: var(--bos-color-success) !important; }
body.bos-ui-v2 .bos-text-info     { color: var(--bos-color-info)    !important; }
body.bos-ui-v2 .bos-text-due      { color: var(--bos-color-due)     !important; font-weight: 600; }
body.bos-ui-v2 .bos-text-neutral  { color: var(--bos-color-neutral) !important; }

/* Utility badge/pill classes */
body.bos-ui-v2 .bos-pill-error,
body.bos-ui-v2 .bos-pill-warning,
body.bos-ui-v2 .bos-pill-success,
body.bos-ui-v2 .bos-pill-info,
body.bos-ui-v2 .bos-pill-due,
body.bos-ui-v2 .bos-pill-neutral {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 600;
    line-height: 1.5;
}
body.bos-ui-v2 .bos-pill-error    { background: var(--bos-color-error-bg);   color: var(--bos-color-error);   border: 1px solid var(--bos-color-error-border); }
body.bos-ui-v2 .bos-pill-warning  { background: var(--bos-color-warning-bg); color: var(--bos-color-warning); border: 1px solid var(--bos-color-warning-border); }
body.bos-ui-v2 .bos-pill-success  { background: var(--bos-color-success-bg); color: var(--bos-color-success); border: 1px solid var(--bos-color-success-border); }
body.bos-ui-v2 .bos-pill-info     { background: var(--bos-color-info-bg);    color: var(--bos-color-info);    border: 1px solid var(--bos-color-info-border); }
body.bos-ui-v2 .bos-pill-due      { background: var(--bos-color-due-bg);     color: var(--bos-color-due);     border: 1px solid var(--bos-color-due-border); }
body.bos-ui-v2 .bos-pill-neutral  { background: var(--bos-color-neutral-bg); color: var(--bos-color-neutral); border: 1px solid var(--bos-color-neutral-border); }

/* Re-map legacy Bootstrap classes → semantic tokens */
body.bos-ui-v2 .text-danger     { color: var(--bos-color-error)   !important; }
body.bos-ui-v2 .text-warning    { color: var(--bos-color-warning) !important; }
body.bos-ui-v2 .text-success    { color: var(--bos-color-success) !important; }
body.bos-ui-v2 .text-info       { color: var(--bos-color-info)    !important; }
body.bos-ui-v2 .text-primary    { color: var(--bos-color-info)    !important; }

body.bos-ui-v2 .label-danger,
body.bos-ui-v2 .badge-danger    { background: var(--bos-color-error)   !important; color: #fff; }
body.bos-ui-v2 .label-warning,
body.bos-ui-v2 .badge-warning   { background: var(--bos-color-warning) !important; color: #fff; }
body.bos-ui-v2 .label-success,
body.bos-ui-v2 .badge-success   { background: var(--bos-color-success) !important; color: #fff; }
body.bos-ui-v2 .label-info,
body.bos-ui-v2 .badge-info      { background: var(--bos-color-info)    !important; color: #fff; }

/* Money "due" amounts — chuyên dùng class .bos-amount-due trên td */
body.bos-ui-v2 .bos-amount-due,
body.bos-ui-v2 td.payment_due,
body.bos-ui-v2 td.due-amount {
    color: var(--bos-color-due) !important;
    font-weight: 700;
}
body.bos-ui-v2 .bos-amount-paid,
body.bos-ui-v2 td.payment_paid,
body.bos-ui-v2 td.total-paid {
    color: var(--bos-color-success) !important;
    font-weight: 600;
}

/* Action buttons (edit/view) use NEUTRAL, not the default Bootstrap "info" blue
   → tránh nhầm với link/info color */
body.bos-ui-v2 .table .btn-xs.btn-info,
body.bos-ui-v2 .table .btn-xs.btn-default {
    background: var(--bos-color-neutral-bg) !important;
    color: var(--bos-color-neutral) !important;
    border-color: var(--bos-color-neutral-border) !important;
}
body.bos-ui-v2 .table .btn-xs.btn-info:hover {
    background: #e5e7eb !important;
    color: #111827 !important;
}

/* ===== Wave 21r — Unified filter bar pattern ============== */
/*  Standardize report/list filter chrome:
    - search input | date range picker | status pills | apply button
    - Sticky top under page header on mobile
    - Auto-applies to .filters-row, .report-filters, .box-header.with-filters
*/

body.bos-ui-v2 .bos-filter-bar,
body.bos-ui-v2 .filters-row,
body.bos-ui-v2 .report-filters {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    margin-bottom: 16px;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.03);
}
body.bos-ui-v2 .bos-filter-bar > *,
body.bos-ui-v2 .filters-row > *,
body.bos-ui-v2 .report-filters > * {
    margin: 0;
}

/* Search input — flex-grow */
body.bos-ui-v2 .bos-filter-bar input[type="search"],
body.bos-ui-v2 .bos-filter-bar input.bos-filter-search,
body.bos-ui-v2 .filters-row input[type="search"],
body.bos-ui-v2 .report-filters input[type="search"] {
    flex: 1 1 200px;
    min-width: 180px;
    border-radius: 8px;
    border: 1px solid #d1d5db;
    padding: 8px 12px;
    background: #FAFBFC;
    transition: border-color 0.15s, background 0.15s;
}
body.bos-ui-v2 .bos-filter-bar input[type="search"]:focus,
body.bos-ui-v2 .filters-row input[type="search"]:focus {
    background: #fff;
    border-color: #3b82f6;
    outline: none;
}

/* Date range picker — keep its width */
body.bos-ui-v2 .bos-filter-bar .input-daterange,
body.bos-ui-v2 .filters-row .input-daterange,
body.bos-ui-v2 .report-filters .input-daterange,
body.bos-ui-v2 .bos-filter-bar #date_range,
body.bos-ui-v2 .bos-filter-bar input[name="date_range"] {
    flex: 0 0 auto;
    min-width: 220px;
}

/* Status pills (active filters shown as removable chips) */
body.bos-ui-v2 .bos-filter-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: #eff6ff;
    color: #1d4ed8;
    border: 1px solid #bfdbfe;
    border-radius: 999px;
    padding: 4px 12px;
    font-size: 12px;
    font-weight: 500;
    transition: background 0.12s;
}
body.bos-ui-v2 .bos-filter-pill .pill-remove {
    color: #6b7280;
    cursor: pointer;
    font-weight: 700;
    padding: 0 2px;
}
body.bos-ui-v2 .bos-filter-pill .pill-remove:hover {
    color: #dc2626;
}

/* Filter action buttons — flush right */
body.bos-ui-v2 .bos-filter-actions,
body.bos-ui-v2 .filters-row .filter-actions {
    margin-left: auto;
    display: flex;
    gap: 6px;
}
body.bos-ui-v2 .bos-filter-actions .btn-apply,
body.bos-ui-v2 .filters-row .btn-apply {
    background: #3b82f6;
    border-color: #3b82f6;
    color: #fff;
    border-radius: 8px;
    padding: 8px 14px;
    font-weight: 500;
}
body.bos-ui-v2 .bos-filter-actions .btn-reset,
body.bos-ui-v2 .filters-row .btn-reset {
    background: transparent;
    border: 1px solid #d1d5db;
    color: #6b7280;
    border-radius: 8px;
    padding: 8px 14px;
}
body.bos-ui-v2 .bos-filter-actions .btn-reset:hover {
    background: #f9fafb;
    color: #111827;
}

/* "More filters" expandable toggle */
body.bos-ui-v2 .bos-filter-more {
    color: #3b82f6;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    text-decoration: none;
    padding: 6px 10px;
    border-radius: 6px;
    background: #eff6ff;
}
body.bos-ui-v2 .bos-filter-more:hover {
    background: #dbeafe;
    text-decoration: none;
}

/* Sticky top on mobile/tablet */
@media (max-width: 768px) {
    body.bos-ui-v2 .bos-filter-bar,
    body.bos-ui-v2 .filters-row {
        position: sticky;
        top: 56px; /* under header */
        z-index: 50;
        flex-direction: column;
        align-items: stretch;
    }
    body.bos-ui-v2 .bos-filter-bar > *,
    body.bos-ui-v2 .filters-row > * {
        width: 100%;
    }
    body.bos-ui-v2 .bos-filter-actions {
        margin-left: 0;
        justify-content: flex-end;
    }
}

/* KiotViet theme variant */
body.bos-theme-kiotviet .bos-filter-bar,
body.bos-theme-kiotviet .filters-row,
body.bos-theme-kiotviet .report-filters {
    border-color: #E5E7EB;
}
body.bos-theme-kiotviet .bos-filter-pill {
    background: #E8F5EE;
    color: #0F7B5C;
    border-color: #A7F3D0;
}
body.bos-theme-kiotviet .bos-filter-actions .btn-apply {
    background: #27AE60;
    border-color: #27AE60;
}
body.bos-theme-kiotviet .bos-filter-more {
    color: #0F7B5C;
    background: #E8F5EE;
}

/* Dark mode variant */
body.bos-dark-mode .bos-filter-bar,
body.bos-dark-mode .filters-row,
body.bos-dark-mode .report-filters {
    background: #1E293B;
    border-color: #334155;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
}
body.bos-dark-mode .bos-filter-bar input[type="search"],
body.bos-dark-mode .filters-row input[type="search"] {
    background: #334155;
    border-color: #475569;
    color: #E2E8F0;
}
body.bos-dark-mode .bos-filter-pill {
    background: rgba(52, 211, 153, 0.15);
    color: #34D399;
    border-color: rgba(52, 211, 153, 0.3);
}

/* ===== Wave 21o — Unified action bar pattern ============== */
/*  Standardize button positioning:
    - Primary action LUÔN góc phải (bottom-right cho forms, top-right cho lists)
    - Secondary actions xếp bên trái primary
    - Cancel/Back far-left với outline style
    - "Add new" CTA top-right cho list pages
    - .bos-actions-floating opt-in cho sticky-bottom forms
*/

/* Bottom action chrome (form footer, modal footer, .box-footer) */
body.bos-ui-v2 .box-footer:not(.no-bos-actions),
body.bos-ui-v2 .modal-footer:not(.no-bos-actions),
body.bos-ui-v2 .form-actions:not(.no-bos-actions) {
    display: flex !important;
    justify-content: flex-end !important;
    align-items: center;
    gap: 8px;
    padding: 14px 18px !important;
    background: #FAFBFC !important;
    border-top: 1px solid #e5e7eb !important;
    border-radius: 0 0 10px 10px;
}
body.bos-ui-v2 .box-footer .btn,
body.bos-ui-v2 .modal-footer .btn,
body.bos-ui-v2 .form-actions .btn {
    margin: 0 !important;
}
/* Cancel/Close — far left in action bar */
body.bos-ui-v2 .box-footer .btn-default,
body.bos-ui-v2 .modal-footer .btn-default,
body.bos-ui-v2 .form-actions .btn-default,
body.bos-ui-v2 .box-footer button[data-dismiss="modal"],
body.bos-ui-v2 .modal-footer button[data-dismiss="modal"] {
    margin-right: auto !important;
}

/* "Add new" CTA pattern (top-right of list pages) */
body.bos-ui-v2 .box-header .btn-add,
body.bos-ui-v2 .content-header .btn-add,
body.bos-ui-v2 a.btn[href$="/create"]:not(.bos-no-reposition),
body.bos-ui-v2 a.btn[href*="/create?"]:not(.bos-no-reposition) {
    float: right;
    background: #10b981 !important;
    border-color: #10b981 !important;
    color: #fff !important;
    border-radius: 8px !important;
    font-weight: 500;
    padding: 8px 16px;
    box-shadow: 0 2px 8px rgba(16, 185, 129, 0.25);
    transition: background 0.15s, transform 0.1s;
}
body.bos-ui-v2 .box-header .btn-add:hover,
body.bos-ui-v2 a.btn[href$="/create"]:not(.bos-no-reposition):hover {
    background: #059669 !important;
    transform: translateY(-1px);
}

/* Floating sticky bottom action bar (opt-in via .bos-actions-floating on form) */
body.bos-ui-v2 .bos-actions-floating {
    position: sticky;
    bottom: 0;
    z-index: 100;
    background: #fff;
    border-top: 1px solid #e5e7eb;
    padding: 12px 18px;
    margin: 0 -18px -18px -18px;
    box-shadow: 0 -6px 16px rgba(15, 23, 42, 0.06);
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 8px;
}
body.bos-ui-v2 .bos-actions-floating .btn-default,
body.bos-ui-v2 .bos-actions-floating .btn-cancel {
    margin-right: auto;
}

/* Primary submit button — always green + always rightmost */
body.bos-ui-v2 .box-footer .btn-primary,
body.bos-ui-v2 .modal-footer .btn-primary,
body.bos-ui-v2 .form-actions .btn-primary {
    order: 99 !important; /* always last (rightmost) in flex order */
}

/* Mobile: stack action bar vertically with primary full-width */
@media (max-width: 575px) {
    body.bos-ui-v2 .box-footer:not(.no-bos-actions),
    body.bos-ui-v2 .modal-footer:not(.no-bos-actions),
    body.bos-ui-v2 .form-actions:not(.no-bos-actions) {
        flex-direction: column-reverse !important;
        gap: 6px !important;
    }
    body.bos-ui-v2 .box-footer .btn,
    body.bos-ui-v2 .modal-footer .btn,
    body.bos-ui-v2 .form-actions .btn {
        width: 100%;
        margin-right: 0 !important;
    }
}

/* ===== Wave 21f — Mobile responsive POS quick checkout ===== */
@media (max-width: 767px) {
    .bos-undo-toast {
        min-width: calc(100% - 32px);
        bottom: 16px;
    }
    .bos-tour-tooltip {
        width: calc(100% - 32px);
        left: 16px !important;
        right: 16px;
    }
    /* POS create.blade table-condensed → make rows tap-friendly */
    body.bos-ui-v2 #pos_table td,
    body.bos-ui-v2 #pos_table th {
        padding: 10px 6px;
        font-size: 13px;
    }
    /* Floating Pay button stays on top */
    body.bos-ui-v2 #pos-fab-pay {
        position: fixed;
        bottom: 16px;
        right: 16px;
        width: 56px;
        height: 56px;
        border-radius: 50%;
        background: #10b981;
        color: #fff;
        border: none;
        box-shadow: 0 6px 16px rgba(16, 185, 129, 0.45);
        font-size: 22px;
        z-index: 100;
        display: flex;
        align-items: center;
        justify-content: center;
    }
    /* Stack sidebar on top instead of side */
    body.bos-ui-v2 aside.side-bar {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        z-index: 1050;
        transform: translateX(-100%);
        transition: transform 0.25s;
    }
    body.bos-ui-v2.bos-sidebar-open aside.side-bar {
        transform: translateX(0);
    }
}
