/* Motion design tokens — must be first import */
@import url('motion.css');

/* Apple design tokens — overrides after motion, before color-palettes */
@import url('apple-design-tokens.css');

/* Inter — self-hosted variable font (wwwroot/fonts/inter/) */
@font-face {
    font-family: 'Inter';
    src: url('../fonts/inter/Inter-VariableFont_opsz-wght.ttf') format('truetype');
    font-weight: 100 900;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'Inter';
    src: url('../fonts/inter/Inter-Italic-VariableFont_opsz-wght.ttf') format('truetype');
    font-weight: 100 900;
    font-style: italic;
    font-display: swap;
}

/* === Custom Font === */
@font-face {
    font-family: 'Datanomics Pro Bold';
    src: url('../fonts/DatanomicsProBold-Regular.otf') format('opentype');
    font-weight: normal;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'Lexend';
    src: url('../fonts/Lexend.ttf') format('truetype');
    font-weight: normal;
    font-style: normal;
    font-display: swap;
}


html {
    /**
     * Fluid base font-size — tự động điều chỉnh theo viewport width:
     * 320px → 13px | 768px → 13.4px | 1366px → 14.2px | 1920px → 15.1px
     * 2560px → 16px | 3840px → 18px (max)
     * Tự động resize khi kéo cửa sổ browser hoặc zoom
     */
    font-size: clamp(13px, calc(12.2px + 0.15vw), 18px);
}

html,
body {
    /* Body/UI font comes from the token so the DS bridge governs it (Inter under
       Datanomics DS; was hard-coded 'Lexend' pre-migration). */
    font-family: var(--font-body, 'Lexend', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif);
    font-weight: 400;
    font-size: var(--text-base, 1rem);
    line-height: var(--lh-body, 1.5);
    height: 100%;
    margin: 0;
    overflow: hidden;
}

/* h1 + .brand-heading: Datanomics Pro Bold (ALL-CAPS) — brand identity moments only */
h1,
.brand-heading {
    font-family: var(--font-display);
    color: var(--dp-text-primary);
}

/* h2-h4: Inter SemiBold/Medium — enterprise section & card headings */
h2,
h3 {
    font-family: var(--font-heading);
    font-weight: 600;
    color: var(--dp-text-primary);
}

h4 {
    font-family: var(--font-heading);
    font-weight: 500;
    font-size: var(--type-lg);
    line-height: 1.35;
    color: var(--dp-text-primary);
}

/* h5-h6: Lexend (đã có sẵn) weight 500 — label-level headings, transition sang body */
h5,
h6 {
    font-family: var(--font-body);
    font-weight: 500;
    color: var(--dp-text-primary);
}

/* Golden ratio fluid heading sizes */
h1 {
    font-size: var(--type-3xl);
    line-height: 1.2;
}

h2 {
    font-size: var(--type-2xl);
    line-height: 1.25;
}

h3 {
    font-size: var(--type-xl);
    line-height: 1.3;
}

h5 {
    font-size: var(--type-md);
    line-height: 1.4;
}

h6 {
    font-size: var(--type-base);
    line-height: 1.45;
}

/* Legacy Bootstrap form classes keep their existing baseline. Bare elements inherit
   typography from body or their owning component; never assign font metrics globally to
   span/div/p/table/list descendants because that breaks component-level inheritance. */
.form-label,
.form-check-label,
.col-form-label {
    font-weight: 400;
    font-size: 1rem;
}

/* Semantic small text stays relative to its component context. text-muted is a colour utility,
   not a typography utility, so it must not resize arbitrary component content. */
small {
    font-size: 0.8em;
    font-weight: inherit;
}

.form-text {
    font-size: 0.8rem;
    font-weight: 400;
}

/* Custom theme colors — bridged to palette system --pp-* variables */
:root {
    /* === Font Family Variables ===
     * --font-display: ALL-CAPS brand font — dùng cho h1 và brand identity elements
     * --font-heading: Inter — enterprise SaaS standard cho h2-h4, excellent readability
     * --font-body:    Lexend — thiết kế cho readability trên màn hình
     */
    --font-display: 'Datanomics Pro Bold', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    --font-heading:  'Inter', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    --font-body:     'Lexend', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;

    --primary-color: var(--dp-interactive-primary);
    --secondary-color: var(--dp-text-secondary);
    --success-color: var(--dp-status-success);
    --danger-color: var(--dp-status-danger);
    --warning-color: var(--dp-status-warning);
    --info-color: var(--dp-status-info);
    --light-color: var(--dp-surface-brand-subtle);
    --dark-color: var(--dp-text-primary);

    /* === Golden Ratio Spacing Scale (φ = 1.618) === */
    --phi: 1.618;
    --gr-1: 0.25rem;
    /* 4px — micro spacing */
    --gr-2: 0.404rem;
    /* 6.5px — tiny */
    --gr-3: 0.654rem;
    /* 10.5px — small */
    --gr-4: 1.058rem;
    /* 17px — medium (≈ 1rem) */
    --gr-5: 1.712rem;
    /* 27px — large */
    --gr-6: 2.769rem;
    /* 44px — xlarge */
    --gr-7: 4.479rem;
    /* 72px — 2xlarge */
    --gr-8: 7.245rem;
    /* 116px — 3xlarge */

    /* === Golden Ratio Typography Scale === */
    --type-xs: clamp(0.7rem, 0.65rem + 0.1vw, 0.8rem);
    --type-sm: clamp(0.8rem, 0.75rem + 0.1vw, 0.9rem);
    --type-base: clamp(0.9rem, 0.85rem + 0.12vw, 1rem);
    --type-md: clamp(1rem, 0.95rem + 0.15vw, 1.125rem);
    --type-lg: clamp(1.1rem, 1rem + 0.2vw, 1.272rem);
    /* φ^0.5 */
    --type-xl: clamp(1.25rem, 1.1rem + 0.35vw, 1.618rem);
    /* φ */
    --type-2xl: clamp(1.5rem, 1.3rem + 0.5vw, 2.058rem);
    /* φ^1.5 */
    --type-3xl: clamp(1.75rem, 1.5rem + 0.8vw, 2.618rem);
    /* φ² */

    /* === Brand color tokens (new palette) === */
    --color-brand-bg: var(--dp-surface-brand-subtle);
    /* Cyan 50 — primary background */
    --color-brand-surface: var(--dp-surface-primary);
    /* White surface */
    --color-brand-primary: var(--dp-interactive-primary);
    /* Cyan 500 — brand primary */
    --color-brand-hover: var(--dp-interactive-primary-hover);
    /* Cyan 600 — hover state */
    --color-brand-active: var(--dp-interactive-primary-active);
    /* Cyan 700 — active state */
    --color-text-heading: var(--dp-text-primary);
    /* Neutral 800 */
    --color-text-body: var(--dp-text-secondary);
    /* Neutral 600 */
    --color-text-secondary: var(--dp-text-secondary);
    /* Neutral 500 */
    --color-text-muted: var(--dp-text-tertiary);
    /* Neutral 400 */
    --color-cta: var(--dp-interactive-accent);
    /* Yellow 500 — CTA */
    --color-cta-hover: var(--dp-interactive-accent-hover);
    /* Yellow 400 */
    --color-success: var(--dp-status-success);
    --color-danger: var(--dp-status-danger);
    --color-warning: var(--dp-status-warning);

    /* === Consistent card sizing (Apple Design Tokens) === */
    --card-padding: var(--card-padding-compact, 20px);
    --card-gap: var(--space-4, 16px);
    /* Apple tokens define --card-radius, --card-shadow, --card-shadow-hover */

    /* === Layout dimensions === */
    --navbar-height: 64px;
    --footer-height: 52px;
    --sidebar-width: 256px;
    --content-max-width: 1440px;
    --content-max-height: calc(100vh - var(--navbar-height));
}

h1:focus {
    outline: none;
}

a,
.btn-link {
    color: var(--primary-color);
    text-decoration: none;
    transition: all 0.2s ease-in-out;
}

a:hover,
.btn-link:hover {
    color: var(--primary-color);
    text-decoration: underline;
}

/*
 * .btn-primary styles moved to css/components/standard-buttons.css (Bootstrap bridge section).
 * The new system uses outline-first design: transparent background by default, fills on hover.
 * Table action small buttons (.btn-sm, .dp-action-btn) are excluded via :not() selectors.
 *
 * LEGACY — kept only for .btn-sm table action contexts that bootstrap bridge excludes:
 */
.btn.btn-primary.btn-sm {
    /* Table action btn-sm: keep original filled teal style via data-grid.css backward compat rules */
    background-color: var(--dp-surface-secondary);
    border-color: var(--dp-border-default);
    color: var(--dp-interactive-primary);
}

/* Focus rings now handled by apple-design-tokens.css via :focus-visible */

.content {
    padding-top: 1.1rem;
}

/* Custom navbar styles */

/* Navbar — palette-driven colors (no hardcoded navbar-dark/light) */
#main-navigation,
nav.navbar {
    background-color: var(--dp-navbar-bg);
    color: var(--dp-navbar-text);
    border-bottom: 1px solid var(--dp-navbar-border);
    box-shadow: var(--shadow-l1, 0 1px 3px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04));
}

/* All navbar children inherit palette text color */
#main-navigation .navbar-brand,
#main-navigation .nav-link,
#main-navigation .navbar-text,
#main-navigation .btn {
    color: var(--dp-navbar-text);
}

.navbar-brand {
    font-size: 1.4rem;
    font-weight: 400;
}

.navbar-nav .nav-link {
    font-weight: 400;
    transition: background-color var(--transition-micro, 150ms ease), color var(--transition-micro, 150ms ease);
}

.navbar-nav .nav-link:hover {
    background-color: var(--dp-interactive-ghost-hover);
    border-radius: var(--radius-md, 10px);
}

/* Navbar user profile button + avatar */
.navbar-user-btn {
    color: var(--dp-navbar-text);
    border: 1px solid var(--dp-navbar-border);
    background: transparent;
    border-radius: var(--radius-full, 9999px);
    padding: 4px 12px 4px 4px;
}

.navbar-user-btn:hover {
    background: var(--dp-interactive-ghost-hover);
    color: var(--dp-navbar-text);
}

.navbar-user-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--dp-interactive-primary);
    color: var(--dp-text-on-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    font-weight: 600;
    flex-shrink: 0;
}

/* Utility: text color that adapts to bg-primary in both light and dark mode */
.text-on-primary {
    color: var(--dp-text-on-primary) !important;
}

/* ================================
   Global Action Buttons — Unified Design System
   Applies to ALL btn-group-sm inside tables, cards, entity-actions,
   and any container. Ensures 32px square, neutral bg, semantic icons.
   ================================ */

/* btn-group layout: gap instead of connected */
.btn-group-sm,
.btn-group.btn-group-sm,
.btn-group:has(> .btn-sm) {
    gap: 4px;
}

/* Base: all small buttons in btn-group become 32px squares */
.btn-group-sm > .btn,
.btn-group-sm > .btn-sm,
.btn-group > .btn.btn-sm {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    padding: 0;
    border: 1px solid var(--dp-border-default);
    border-radius: var(--radius-sm, 6px) !important;
    background-color: var(--dp-surface-secondary);
    color: var(--dp-text-secondary);
    font-size: 0.8125rem;
    line-height: 1;
    transition: all 150ms ease;
    flex-shrink: 0;
}

/* Remove btn-group connected style — use gap instead */
.btn-group-sm > .btn + .btn,
.btn-group-sm > .btn-sm + .btn-sm,
.btn-group > .btn.btn-sm + .btn.btn-sm {
    margin-left: 0;
}

/* Override Bootstrap btn-group border-radius removal */
.btn-group-sm > .btn:not(:first-child),
.btn-group-sm > .btn:not(:last-child),
.btn-group > .btn.btn-sm:not(:first-child),
.btn-group > .btn.btn-sm:not(:last-child) {
    border-radius: var(--radius-sm, 6px) !important;
}

/* Hover: subtle lift */
.btn-group-sm > .btn:hover,
.btn-group > .btn.btn-sm:hover {
    background-color: var(--dp-surface-hover);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
    transform: translateY(-1px);
    z-index: 1;
}

.btn-group-sm > .btn:active,
.btn-group > .btn.btn-sm:active {
    transform: translateY(0);
    box-shadow: none;
}

.btn-group-sm > .btn:disabled,
.btn-group > .btn.btn-sm:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* Semantic: primary / edit actions */
.btn-group-sm > .btn.btn-light,
.btn-group-sm > .btn.btn-outline-primary,
.btn-group-sm > .btn.btn-primary:not(.dropdown-toggle),
.btn-group > .btn.btn-sm.btn-light,
.btn-group > .btn.btn-sm.btn-outline-primary {
    color: var(--dp-interactive-primary);
    background-color: var(--dp-surface-secondary);
    border-color: var(--dp-border-default);
}
.btn-group-sm > .btn.btn-light:hover,
.btn-group-sm > .btn.btn-outline-primary:hover,
.btn-group-sm > .btn.btn-primary:not(.dropdown-toggle):hover,
.btn-group > .btn.btn-sm.btn-light:hover,
.btn-group > .btn.btn-sm.btn-outline-primary:hover {
    color: var(--dp-interactive-primary-hover);
    border-color: var(--dp-interactive-primary);
    background-color: var(--dp-surface-hover);
}

/* Semantic: info / view actions */
.btn-group-sm > .btn.btn-outline-info,
.btn-group > .btn.btn-sm.btn-outline-info {
    color: var(--dp-status-info);
    background-color: var(--dp-surface-secondary);
    border-color: var(--dp-border-default);
}
.btn-group-sm > .btn.btn-outline-info:hover,
.btn-group > .btn.btn-sm.btn-outline-info:hover {
    color: var(--dp-status-info);
    border-color: var(--dp-status-info);
    background-color: var(--dp-surface-hover);
}

/* Semantic: success / activate actions */
.btn-group-sm > .btn.btn-outline-success,
.btn-group > .btn.btn-sm.btn-outline-success {
    color: var(--dp-status-success);
    background-color: var(--dp-surface-secondary);
    border-color: var(--dp-border-default);
}
.btn-group-sm > .btn.btn-outline-success:hover,
.btn-group > .btn.btn-sm.btn-outline-success:hover {
    color: var(--dp-status-success);
    border-color: var(--dp-status-success);
    background-color: var(--dp-surface-hover);
}

/* Semantic: warning / pause actions */
.btn-group-sm > .btn.btn-outline-warning,
.btn-group > .btn.btn-sm.btn-outline-warning {
    color: var(--dp-status-warning);
    background-color: var(--dp-surface-secondary);
    border-color: var(--dp-border-default);
}
.btn-group-sm > .btn.btn-outline-warning:hover,
.btn-group > .btn.btn-sm.btn-outline-warning:hover {
    color: var(--dp-status-warning);
    border-color: var(--dp-status-warning);
    background-color: var(--dp-surface-hover);
}

/* Semantic: secondary / neutral actions */
.btn-group-sm > .btn.btn-outline-secondary,
.btn-group > .btn.btn-sm.btn-outline-secondary {
    color: var(--dp-text-secondary);
    background-color: var(--dp-surface-secondary);
    border-color: var(--dp-border-default);
}
.btn-group-sm > .btn.btn-outline-secondary:hover,
.btn-group > .btn.btn-sm.btn-outline-secondary:hover {
    color: var(--dp-text-primary);
    border-color: var(--dp-text-secondary);
    background-color: var(--dp-surface-hover);
}

/* Semantic: danger / delete — FILLED red, stands out as destructive */
.btn-group-sm > .btn.btn-outline-danger,
.btn-group-sm > .btn.btn-danger,
.btn-group > .btn.btn-sm.btn-outline-danger,
.btn-group > .btn.btn-sm.btn-danger {
    background-color: var(--dp-status-danger);
    border-color: var(--dp-status-danger);
    color: #FFFFFF;
}
.btn-group-sm > .btn.btn-outline-danger:hover,
.btn-group-sm > .btn.btn-danger:hover,
.btn-group > .btn.btn-sm.btn-outline-danger:hover,
.btn-group > .btn.btn-sm.btn-danger:hover {
    background-color: var(--dp-status-danger-hover, #991B1B);
    border-color: var(--dp-status-danger-hover, #991B1B);
    color: #FFFFFF;
}

/* Icon sizing inside btn-group action buttons */
.btn-group-sm > .btn i,
.btn-group > .btn.btn-sm i {
    font-size: 0.8125rem;
    line-height: 1;
}

/* Icon-only btn-sm in table cells: 32px square (only when no text content) */
td > .btn.btn-sm:not(.dp-btn):has(> i:only-child),
td > a.btn.btn-sm:not(.dp-btn):has(> i:only-child) {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    padding: 0;
    border: 1px solid var(--dp-border-default);
    border-radius: var(--radius-sm, 6px);
    background-color: var(--dp-surface-secondary);
    color: var(--dp-text-secondary);
    font-size: 0.8125rem;
    transition: all 150ms ease;
}

td > .btn.btn-sm:not(.dp-btn):has(> i:only-child):hover,
td > a.btn.btn-sm:not(.dp-btn):has(> i:only-child):hover {
    background-color: var(--dp-surface-hover);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
    transform: translateY(-1px);
}

td > .btn.btn-sm:not(.dp-btn):has(> i:only-child).btn-outline-primary,
td > a.btn.btn-sm:not(.dp-btn):has(> i:only-child).btn-outline-primary {
    color: var(--dp-interactive-primary);
}

td > .btn.btn-sm:not(.dp-btn):has(> i:only-child).btn-outline-danger,
td > a.btn.btn-sm:not(.dp-btn):has(> i:only-child).btn-outline-danger {
    background-color: var(--dp-status-danger);
    border-color: var(--dp-status-danger);
    color: #FFFFFF;
}

/* Buttons with text labels: auto-width instead of 32px square */
.btn-group-sm > .btn:has(> span),
.btn-group > .btn.btn-sm:has(> span),
.btn-group-sm > .btn:has(> .ms-1),
.btn-group > .btn.btn-sm:has(> .ms-1) {
    width: auto;
    padding: 0 0.5rem;
    gap: 4px;
}

/* Responsive: smaller on mobile */
@media (max-width: 768px) {
    .btn-group-sm > .btn,
    .btn-group-sm > .btn-sm,
    .btn-group > .btn.btn-sm {
        width: 28px;
        height: 28px;
        font-size: 0.75rem;
    }
    .btn-group-sm > .btn i,
    .btn-group > .btn.btn-sm i {
        font-size: 0.75rem;
    }
    td > .btn.btn-sm,
    td > a.btn.btn-sm {
        width: 28px;
        height: 28px;
        font-size: 0.75rem;
    }
}

/* Card enhancements — Apple Design Tokens (shadow-only, no translateY) */
.card {
    border: var(--card-border, none);
    border-radius: var(--card-radius, 14px);
    box-shadow: var(--card-shadow);
    transition: box-shadow var(--transition-micro, 150ms ease);
    margin-bottom: var(--space-4, 16px);
}

.card:hover {
    box-shadow: var(--card-shadow-hover);
}

.card-body {
    padding: var(--card-padding-compact, 20px);
}

.card-header,
.card-footer {
    padding: var(--space-4, 16px) var(--card-padding-compact, 20px);
}

/* Form styling now handled by apple-design-tokens.css (filled input style) */

/* Main layout footer — token-based, adapts to light and dark mode */
footer.main-footer {
    background-color: var(--dp-surface-page);
    background-image: none;
    color: var(--dp-text-secondary);
    border-top: 1px solid var(--dp-border-default);
}

/* Loading animation */
.loading-progress {
    position: relative;
    display: block;
    width: 8rem;
    height: 8rem;
    margin: 20vh auto 1rem auto;
}

.loading-progress circle {
    fill: none;
    stroke: var(--primary-color);
    stroke-width: 0.6rem;
    transform-origin: 50% 50%;
    transform: rotate(-90deg);
}

.loading-progress circle:last-child {
    stroke: var(--dp-surface-brand-subtle);
    stroke-dasharray: calc(3.141 * var(--blazor-load-percentage, 0%) * 0.8), 500%;
    transition: stroke-dasharray 0.05s ease-in-out;
}

.loading-progress-text {
    position: absolute;
    text-align: center;
    font-weight: bold;
    inset: calc(20vh + 3.25rem) 0 auto 0.2rem;
    color: var(--primary-color);
}

.valid.modified:not([type=checkbox]) {
    outline: 1px solid var(--dp-status-success);
}

.invalid {
    outline: 1px solid var(--dp-status-danger);
}

.validation-message {
    color: var(--dp-status-danger);
    font-size: 0.875rem;
    margin-top: 0.25rem;
}

#blazor-error-ui {
    color-scheme: light only;
    background: var(--dp-status-warning-bg);
    bottom: 0;
    box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2);
    box-sizing: border-box;
    display: none;
    left: 0;
    padding: 0.6rem 1.25rem 0.7rem 1.25rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
}

#blazor-error-ui .dismiss {
    cursor: pointer;
    position: absolute;
    right: 0.75rem;
    top: 0.5rem;
}

.blazor-error-boundary {
    background: url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNTYiIGhlaWdodD0iNDkiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiIG92ZXJmbG93PSJoaWRkZW4iPjxkZWZzPjxjbGlwUGF0aCBpZD0iY2xpcDAiPjxyZWN0IHg9IjIzNSIgeT0iNTEiIHdpZHRoPSI1NiIgaGVpZ2h0PSI0OSIvPjwvY2xpcFBhdGg+PC9kZWZzPjxnIGNsaXAtcGF0aD0idXJsKCNjbGlwMCkiIHRyYW5zZm9ybT0idHJhbnNsYXRlKC0yMzUgLTUxKSI+PHBhdGggZD0iTTI2My41MDYgNTFDMjY0LjcxNyA1MSAyNjUuODEzIDUxLjQ4MzcgMjY2LjYwNiA1Mi4yNjU4TDI2Ny4wNTIgNTIuNzk4NyAyNjcuNTM5IDUzLjYyODMgMjkwLjE4NSA5Mi4xODMxIDI5MC41NDUgOTIuNzk1IDI5MC42NTYgOTIuOTk2QzI5MC44NzcgOTMuNTEzIDI5MSA5NC4wODE1IDI5MSA5NC42NzgyIDI5MSA5Ny4wNjUxIDI4OS4wMzggOTkgMjg2LjYxNyA5OUwyNDAuMzgzIDk5QzIzNy45NjMgOTkgMjM2IDk3LjA2NTEgMjM2IDk0LjY3ODIgMjM2IDk0LjM3OTkgMjM2LjAzMSA5NC4wODg2IDIzNi4wODkgOTMuODA3MkwyMzYuMzM4IDkzLjAxNjIgMjM2Ljg1OCA5Mi4xMzE0IDI1OS40NzMgNTMuNjI5NCAyNTkuOTYxIDUyLjc5ODUgMjYwLjQwNyA1Mi4yNjU4QzI2MS4yIDUxLjQ4MzcgMjYyLjI5NiA1MSAyNjMuNTA2IDUxWk0yNjMuNTg2IDY2LjAxODNDMjYwLjczNyA2Ni4wMTgzIDI1OS4zMTMgNjcuMTI0NSAyNTkuMzEzIDY5LjMzNyAyNTkuMzEzIDY5LjYxMDIgMjU5LjMzMiA2OS44NjA4IDI1OS4zNzEgNzAuMDg4N0wyNjEuNzk1IDg0LjAxNjEgMjY1LjM4IDg0LjAxNjEgMjY3LjgyMSA2OS43NDc1QzI2Ny44NiA2OS43MzA5IDI2Ny44NzkgNjkuNTg3NyAyNjcuODc5IDY5LjMxNzkgMjY3Ljg3OSA2Ny4xMTgyIDI2Ni40NDggNjYuMDE4MyAyNjMuNTg2IDY2LjAxODNaTTI2My41NzYgODYuMDU0N0MyNjEuMDQ5IDg2LjA1NDcgMjU5Ljc4NiA4Ny4zMDA1IDI1OS43ODYgODkuNzkyMSAyNTkuNzg2IDkyLjI4MzcgMjYxLjA0OSA5My41Mjk1IDI2My41NzYgOTMuNTI5NSAyNjYuMTE2IDkzLjUyOTUgMjY3LjM4NyA5Mi4yODM3IDI2Ny4zODcgODkuNzkyMSAyNjcuMzg3IDg3LjMwMDUgMjY2LjExNiA4Ni4wNTQ3IDI2My41NzYgODYuMDU0N1oiIGZpbGw9IiNGRkU1MDAiIGZpbGwtcnVsZT0iZXZlbm9kZCIvPjwvZz48L3N2Zz4=) no-repeat 1rem/1.8rem, var(--dp-status-danger-bg);
    padding: 1rem 1rem 1rem 3.7rem;
    color: var(--dp-text-primary);
}

.blazor-error-boundary::after {
    content: "An error has occurred."
}

/* Note: .loading-progress base styles are defined above (lines 360-388).
   The second copy with hardcoded colors was removed to reduce duplication.
   The Blazor loading screen uses the base styles with --primary-color. */

.loading-progress-text:after {
    content: var(--blazor-load-percentage-text, "Loading");
}

code {
    color: var(--dp-status-danger);
}

.form-floating>.form-control-plaintext::placeholder,
.form-floating>.form-control::placeholder {
    color: var(--bs-secondary-color);
    text-align: end;
}

.form-floating>.form-control-plaintext:focus::placeholder,
.form-floating>.form-control:focus::placeholder {
    text-align: start;
}

/*
 * === LAYOUT HEIGHT CHAIN ===
 * html/body (height:100%, overflow:hidden)
 *   └─ .min-vh-100 wrapper (height:100vh, flex column)
 *       └─ nav.fixed-top (out of flow)
 *       └─ main.flex-grow-1 (flex:1 1 0, min-height:0, overflow:hidden)
 *       │   └─ .container-fluid (height:100%, display:flex)
 *       │       └─ .row (flex:1, min-height:0)
 *       │           ├─ .sidebar-column (overflow-y:auto) ← scrollbar 1
 *       │           └─ .main-content-column (overflow-y:auto) ← scrollbar 2
 *       └─ footer (flex-shrink:0, desktop only)
 */

/* Wrapper: exact viewport height, flex column, no scroll */
.min-vh-100 {
    height: 100vh !important;
    min-height: unset !important;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Main area: fill remaining space after footer.
   min-height:0 is CRITICAL — allows flex item to shrink below its content size.
   overflow:hidden — prevents main itself from scrolling, delegates to children. */
main.flex-grow-1 {
    flex: 1 1 0 !important;
    /* grow + shrink + basis:0 */
    min-height: 0 !important;
    overflow: hidden;
}

/* Container inside main: full height, flex layout */
main.flex-grow-1>.container-fluid {
    height: 97%;
    display: flex;
    flex-direction: column;
}

/* Row inside container: fill remaining height */
main.flex-grow-1>.container-fluid>.row {
    flex: 1 1 0;
    min-height: 0;
}

/* Sidebar column — independent scroll (scrollbar 1) */
.sidebar-column {
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow-y: auto;
    overflow-x: hidden;
    scroll-behavior: smooth;
    scrollbar-width: thin;
    scrollbar-color: var(--dp-border-strong) transparent;
}

/* Custom scrollbar cho sidebar */
.sidebar-column::-webkit-scrollbar {
    width: 4px;
}

.sidebar-column::-webkit-scrollbar-track {
    background: transparent;
}

.sidebar-column::-webkit-scrollbar-thumb {
    background-color: var(--dp-border-strong);
    border-radius: 4px;
}

.sidebar-column::-webkit-scrollbar-thumb:hover {
    background-color: var(--dp-text-tertiary);
}

/* Ensure sidebar takes full height of its column */
.sidebar-column .unified-sidebar {
    flex: 1;
    min-height: 100%;
}

/* Main content column — independent scroll (scrollbar 2) */
.main-content-column {
    overflow-x: hidden;
    overflow-y: auto;
    min-width: 0;
    height: 100%;
    scroll-behavior: smooth;
}

/* Print: the height chain above pins the app to exactly one viewport and delegates scrolling
   to .main-content-column. A paged renderer has no scrollport, so it captures that single
   viewport and drops everything below it (measured: 1 of 25 rows). Unpin the chain so the
   document flows and the renderer can paginate. */
/* Shell-specific height/overflow resets (.ds-shell, .ds-shell-content) live in the scoped
   MainLayout.razor.css — a plain .ds-shell rule here (specificity 0,1,0) loses to the
   Blazor-scoped .ds-shell[b-xxxxx] rule (0,2,0) emitted for that component, so it must be
   declared in the same scope to actually win. See MainLayout.razor.css for the print block. */
@media print {
    html,
    body {
        height: auto;
        overflow: visible;
    }
}


.connection-status.connected {
    display: none;
}

.connection-status.disconnected .alert {
    border-left: 4px solid var(--dp-status-warning);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }

    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.spinner-border-sm {
    width: 1rem;
    height: 1rem;
}

/* ========================================
   Form Controls - Switches & Checkboxes
   ======================================== */

/* Fix toggle switches và checkboxes bị che - thêm margin và min-height */
.form-check {
    margin-bottom: 1rem;
    min-height: 1.5rem;
    display: flex;
    align-items: center;
}

.form-check.form-switch {
    margin-bottom: 1.5rem !important;
    min-height: 2.5rem;
    display: flex;
    align-items: center;
}

.form-check .form-check-input {
    margin-top: 0;
    flex-shrink: 0;
    cursor: pointer;
    margin-left: 0;
}

.form-check .form-check-label {
    padding-left: 0.5rem;
    display: flex;
    align-items: center;
    cursor: pointer;
    margin-bottom: 0;
}

.form-dsr.form-check .form-check-label {
    padding-left: 0.5rem;
    cursor: pointer;
    margin-bottom: 0;
    display: flow-root;
}

/* Đảm bảo toggle có đủ padding trong card-body */
.card-body .col-12:has(.form-check) {
    margin-bottom: 0.5rem;
}

.card-body .col-12:has(.form-check.form-switch) {
    margin-bottom: 0.5rem;
}

/* Form switch sizing */
.form-switch .form-check-input {
    width: 2em;
    height: 1em;
    transition: background-position var(--motion-base, 200ms) var(--ease-in-out);
    background-position: left center;
    border-radius: 2em;
}

.form-switch .form-check-input:checked {
    background-position: right center;
}

/* Checkbox và radio button cải tiến */
.form-check-input:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 0.25rem rgba(1, 205, 211, 0.25) /* brand tint */;
}

.form-check-input:checked {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
}

/* Fix spacing trong form groups */
.form-group .form-check {
    margin-bottom: 0.75rem;
}

.form-group .form-check:last-child {
    margin-bottom: 0;
}

/* Fix quill editor buttons height */
.ql-snow.ql-toolbar button,
.ql-snow .ql-toolbar button {
    height: unset;
}

/* ========================================
   Brand Background Utility Classes
   ======================================== */

/* Brand soft background — Cyan 50 */
.bg-brand-soft {
    background-color: var(--dp-surface-brand-subtle) !important;
}

/* All stat/metric cards: equal height in same row */
.row>[class*="col-"]>.stats-card,
.row>[class*="col-"]>.stats-card>.card {
    height: 100%;
}

/* Uniform card min-height for stats cards */
.stats-card .card {
    min-height: var(--stats-card-height, 8.5rem);
}




.btn-light {
    color: var(--dp-text-secondary);
    transition: all 0.3s ease;
    padding: 0.375rem 0.75rem;
    border-radius: 0.375rem;
}

.btn-light:hover {
    background-color: var(--dp-surface-brand-subtle);
    border-color: var(--dp-interactive-primary-active);
    color: var(--dp-text-primary);
    box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
    transform: translateY(-1px);
}

.btn-light:focus {
    box-shadow: 0 0 0 0.2rem var(--dp-border-focus);
}

/* Dark mode support — kept for backward compat with non-refactored files */
:global(.dark-mode) .btn-light {
    background-color: var(--dp-surface-primary);
    border-color: var(--dp-border-default);
    color: var(--dp-text-primary);
}

:global(.dark-mode) .btn-light:hover {
    background-color: var(--dp-surface-hover);
    border-color: var(--dp-border-strong);
    color: var(--dp-text-primary);
}

/* ==========================================================================
   Bootstrap Tooltip — token-driven theming (AppleTooltip + legacy callers)
   Bootstrap renders .tooltip + .tooltip-inner into <body>, outside Blazor's
   scoped CSS. Override globally here so AppleTooltip surfaces inherit our
   --dp-* tokens for both light and dark mode (dark mode duplicate retained
   in dark-mode.css for the legacy .dark-mode class selector).
   WCAG: text-on-inverse maintains 4.5:1 contrast on inverse surface.
   ========================================================================== */
.tooltip-inner {
    background-color: var(--dp-text-primary);
    color: var(--dp-text-inverse);
    font-size: 0.8125rem;
    line-height: 1.4;
    padding: 0.4rem 0.65rem;
    border-radius: 6px;
    max-width: 280px;
}

.tooltip .tooltip-arrow::before {
    /* Match the body color so arrow blends with inner box across both themes. */
    border-top-color: var(--dp-text-primary);
    border-bottom-color: var(--dp-text-primary);
    border-left-color: var(--dp-text-primary);
    border-right-color: var(--dp-text-primary);
}
