/* ═══════════════════════════════════════════════════
   WALLART VIETNAM – Blazor App Styles
   ═══════════════════════════════════════════════════ */

:root {
    --primary-dark:  #001529; /* Ant Design Layout Header */
    --primary:       #1677ff; /* Ant Design Primary */
    --primary-light: #4096ff;
    --header-h:      64px;    /* Ant Design standard */
    --nav-h:         46px;
    --text:          rgba(0, 0, 0, 0.88);
    --text-muted:    rgba(0, 0, 0, 0.45);
    --border:        #f0f0f0;
    --bg:            #f5f5f5;
    --white:         #ffffff;

    /* DevExpress Overrides to match Ant Design */
    --bs-primary: #1677ff;
    --bs-primary-rgb: 22, 119, 255;
    --bs-link-color: #1677ff;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, 'Noto Sans', sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol', 'Noto Color Emoji';
    font-size: 11px;
    color: var(--text);
    background: var(--bg);
    line-height: 1.5715;
}

/* ── Shell ───────────────────────────────────────── */
.app-shell {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* ── Header ──────────────────────────────────────── */
.app-header {
    position: sticky;
    top: 0;
    z-index: 900;
    height: var(--header-h);
    background: linear-gradient(135deg, #001529 0%, #003a6b 50%, #001529 100%);
    box-shadow: 0 2px 8px rgba(0,0,0,.25);
    box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.03), 0 1px 6px -1px rgba(0, 0, 0, 0.02), 0 2px 4px 0 rgba(0, 0, 0, 0.02);
}

.header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 100%;
    padding: 0 20px;
    max-width: 1600px;
    margin: 0 auto;
}

/* Brand */
.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
}

.brand-logo {
    height: 36px;
    max-width: 140px;
    object-fit: contain;
    border-radius: 4px;
}

.brand-text { display: flex; flex-direction: column; line-height: 1.2; }
.brand-name { color: #fff; font-weight: 700; font-size: 14px; letter-spacing: .1em; text-transform: uppercase; text-shadow: 0 1px 2px rgba(0,0,0,.3); }
.brand-sub  { color: #64b5f6; font-size: 10px; letter-spacing: .04em; }

/* Header Center - Search */
.header-center { flex: 1; display: flex; justify-content: center; padding: 0 40px; }
.header-search-wrap { position: relative; width: 100%; max-width: 480px; }
.header-search {
    display: flex; align-items: center;
    background: rgba(255,255,255,.1); border: 1px solid rgba(255,255,255,.15);
    border-radius: 24px; width: 100%;
    transition: all .3s ease;
}
.header-search:focus-within {
    background: rgba(255,255,255,.18); border-color: rgba(255,255,255,.35);
    box-shadow: 0 0 0 3px rgba(22,119,255,.25);
}
.header-search-icon { padding: 0 0 0 14px; color: rgba(255,255,255,.5); font-size: 13px; }
.header-search-input {
    background: transparent; border: none; outline: none;
    color: #fff; font-size: 12px; padding: 8px 12px; width: 100%;
}
.header-search-input::placeholder { color: rgba(255,255,255,.4); }
.header-search-clear {
    background: none; border: none; color: rgba(255,255,255,.5);
    cursor: pointer; padding: 0 12px 0 0; font-size: 12px;
}
.header-search-clear:hover { color: #fff; }
.header-search-spinner {
    width: 16px; height: 16px; border: 2px solid rgba(255,255,255,.2);
    border-top-color: #4096ff; border-radius: 50%; margin-right: 12px;
    animation: spin .6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Search Dropdown */
.search-dropdown {
    position: absolute; top: calc(100% + 6px); left: 0; right: 0;
    background: #fff; border-radius: 12px;
    box-shadow: 0 8px 30px rgba(0,0,0,.18), 0 2px 8px rgba(0,0,0,.08);
    max-height: 420px; overflow-y: auto; z-index: 9999;
    border: 1px solid #e5e7eb;
}
.search-group-label {
    padding: 8px 16px 4px; font-size: 10px; font-weight: 700;
    color: #6b7280; text-transform: uppercase; letter-spacing: .08em;
    background: #f9fafb; border-bottom: 1px solid #f0f0f0;
}
.search-item {
    display: flex; align-items: center; gap: 10px;
    padding: 8px 16px; text-decoration: none; color: #1f2937;
    transition: background .15s;
}
.search-item:hover { background: #eff6ff; }
.search-item-icon { font-size: 18px; width: 28px; text-align: center; flex-shrink: 0; }
.search-item-body { flex: 1; min-width: 0; }
.search-item-title { font-size: 13px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.search-item-sub { font-size: 11px; color: #6b7280; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.search-footer {
    padding: 10px 16px; text-align: center; font-size: 12px;
    color: #1677ff; cursor: pointer; border-top: 1px solid #f0f0f0;
    background: #f9fafb; border-radius: 0 0 12px 12px;
}
.search-footer:hover { background: #eff6ff; }
.search-empty { padding: 20px 16px; text-align: center; color: #9ca3af; font-size: 12px; }

/* Header User */
.header-user { display: flex; align-items: center; gap: 8px; margin-right: 8px; }
.header-avatar {
    width: 32px; height: 32px; border-radius: 50%;
    background: linear-gradient(135deg, #1677ff, #4096ff);
    color: #fff; font-weight: 700; font-size: 14px;
    display: flex; align-items: center; justify-content: center;
    box-shadow: 0 2px 6px rgba(22,119,255,.4);
}
.header-username { color: rgba(255,255,255,.85); font-size: 12px; font-weight: 500; max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Header Actions */
.header-actions {
    display: flex;
    align-items: center;
    gap: 4px;
}

.btn-header {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 8px 12px;
    font-size: 11px;
    font-weight: 500;
    color: rgba(255,255,255,.7);
    background: rgba(255,255,255,.06);
    border: 1px solid rgba(255,255,255,.1);
    border-radius: 8px;
    text-decoration: none;
    transition: all .2s ease;
}
.btn-header:hover { background: rgba(255,255,255,.15); color: #fff; transform: translateY(-1px); }

.btn-logout {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    font-size: 11px;
    font-weight: 600;
    color: #fca5a5;
    background: rgba(239,68,68,.08);
    border: 1px solid rgba(239,68,68,.18);
    border-radius: 8px;
    cursor: pointer;
    transition: all .2s ease;
}
.btn-logout:hover { background: rgba(239,68,68,.22); color: #fecaca; transform: translateY(-1px); }

.quick-actions { display: flex; gap: 4px; margin-right: 8px; }
.qa-btn {
    display: inline-flex; align-items: center; gap: 3px;
    padding: 5px 10px; font-size: 11px; font-weight: 600;
    border-radius: 6px; text-decoration: none; cursor: pointer;
    transition: all .2s ease; white-space: nowrap;
}
.qa-btn:hover { transform: translateY(-1px); filter: brightness(1.1); }
.qa-dh { background: #16a34a; color: #fff; border: 1px solid #15803d; }
.qa-pt { background: #0284c7; color: #fff; border: 1px solid #0369a1; }
.qa-pc { background: #7c3aed; color: #fff; border: 1px solid #6d28d9; }

@media (max-width: 992px) {
    .header-center { display: none; }
    .header-username { display: none; }
}

/* ── Nav & Body ───────────────────────────────────── */
.app-body {
    display: flex;
    flex: 1;
    overflow: hidden; /* Prevent body scrolling, let content scroll */
    min-height: calc(100vh - var(--header-h));
}

.app-sidebar {
    width: 210px;
    background: var(--white);
    border-right: 1px solid var(--border);
    flex-shrink: 0;
    overflow-y: auto;
    transition: width 0.25s ease;
    position: relative;
}
.app-sidebar.collapsed {
    width: 60px;
}
.sidebar-toggle {
    display: block;
    width: 100%;
    padding: 8px;
    background: none;
    border: none;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    font-size: 18px;
    color: #64748b;
    transition: background 0.2s;
}
.sidebar-toggle:hover {
    background: #f1f5f9;
    color: #0f172a;
}

/* ── Mobile Sidebar ──────────────────────────────── */
.mobile-menu-toggle {
    display: none;
}
.sidebar-backdrop {
    display: none;
}

@media (max-width: 767.98px) {
    .app-sidebar {
        position: fixed;
        top: var(--header-h);
        left: 0;
        bottom: 0;
        z-index: 1050;
        width: 260px;
        transform: translateX(-100%);
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        box-shadow: none;
        overflow-y: auto;
    }
    .app-sidebar.collapsed {
        width: 260px; /* On mobile, ignore collapsed width */
    }
    .app-sidebar.collapsed .nav-text,
    .app-sidebar.collapsed .section-title {
        display: revert;
        font-size: revert;
        height: auto;
        margin-bottom: 6px;
        padding-left: 10px;
        opacity: 1;
    }
    .app-sidebar.collapsed .nav-item-link {
        justify-content: flex-start;
        padding: 7px 12px;
    }
    .app-sidebar.collapsed .nav-icon {
        width: 24px;
        font-size: 16px;
    }
    .app-sidebar.mobile-open {
        transform: translateX(0);
        box-shadow: 4px 0 24px rgba(0, 0, 0, 0.15);
    }
    .sidebar-backdrop {
        display: block;
        position: fixed;
        top: var(--header-h);
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.45);
        z-index: 1040;
        animation: fadeIn 0.25s ease;
    }
    .app-sidebar .sidebar-toggle {
        display: none; /* Hide the inline toggle on mobile; use header hamburger instead */
    }
    .app-content {
        margin-left: 0 !important;
        width: 100% !important;
    }
    .mobile-menu-toggle {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 36px;
        height: 36px;
        border: 1px solid rgba(255,255,255,0.2);
        border-radius: 6px;
        background: rgba(255,255,255,0.1);
        color: #fff;
        font-size: 20px;
        cursor: pointer;
        flex-shrink: 0;
        margin-right: 8px;
        transition: background 0.2s;
    }
    .mobile-menu-toggle:hover {
        background: rgba(255,255,255,0.2);
    }
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* ── Ant Design Component Overrides ──────────────── */
.card {
    background-color: var(--white);
    border-radius: 8px;
    border: 1px solid var(--border) !important;
    box-shadow: none !important;
    transition: all 0.3s;
}
.card:hover {
    box-shadow: 0 1px 2px -2px rgba(0, 0, 0, 0.16), 0 3px 6px 0 rgba(0, 0, 0, 0.12), 0 5px 12px 4px rgba(0, 0, 0, 0.09) !important;
}
.card-header {
    background: transparent !important;
    border-bottom: 1px solid var(--border) !important;
    padding: 16px 24px !important;
}
.card-body {
    padding: 24px !important;
}
.card-body.p-0 { padding: 0 !important; }

/* DevExpress Button Overrides for Ant Design */
.btn, .dxbl-btn { white-space: nowrap !important; }

/* Force Ant Design Blue for Primary Buttons */
.btn-primary, .dxbl-btn-primary, .btn-primary:not(:disabled):not(.disabled), .dxbl-btn-primary:not(.disabled) {
    --bs-btn-bg: var(--primary) !important;
    --bs-btn-border-color: var(--primary) !important;
    --bs-btn-hover-bg: var(--primary-light) !important;
    --bs-btn-hover-border-color: var(--primary-light) !important;
    --bs-btn-active-bg: var(--primary-dark) !important;
    --bs-btn-active-border-color: var(--primary-dark) !important;
    background-color: var(--primary) !important;
    border-color: var(--primary) !important;
    color: #fff !important;
    background-image: none !important; /* Blazing berry sometimes uses gradients */
}
.btn-primary:hover, .btn-primary:focus, .btn-primary:active, .dxbl-btn-primary:hover { 
    background-color: var(--primary-light) !important; 
    border-color: var(--primary-light) !important; 
    background-image: none !important;
}

/* Force Warning Button to Ant Design Warning Color */
.btn-warning, .dxbl-btn-warning { 
    --bs-btn-bg: #faad14 !important;
    --bs-btn-border-color: #faad14 !important;
    background-color: #faad14 !important; 
    border-color: #faad14 !important; 
    color: #fff !important; 
    background-image: none !important;
}
.btn-warning:hover, .btn-warning:focus, .dxbl-btn-warning:hover { background-color: #ffc53d !important; border-color: #ffc53d !important; color: #fff !important; }

/* Force Info Button */
.btn-info, .dxbl-btn-info { 
    --bs-btn-bg: #13c2c2 !important;
    --bs-btn-border-color: #13c2c2 !important;
    background-color: #13c2c2 !important; 
    border-color: #13c2c2 !important; 
    color: #fff !important; 
    background-image: none !important;
}
.btn-info:hover, .btn-info:focus, .dxbl-btn-info:hover { background-color: #36cfc9 !important; border-color: #36cfc9 !important; color: #fff !important; }

/* DevExpress Grid Overrides for Ant Design Tables */
.dxbl-grid { border: 1px solid var(--border) !important; border-radius: 8px 8px 0 0 !important; overflow: hidden; font-size: 11px !important; }
.dxbl-grid .dxbl-table > thead > tr > th {
    background-color: #fafafa !important;
    border-bottom: 1px solid var(--border) !important;
    border-right: none !important;
    padding: 8px 10px !important;
    font-weight: 500 !important;
    font-size: 11px !important;
    color: rgba(0,0,0,0.85) !important;
}
.dxbl-grid .dxbl-table > tbody > tr > td {
    border-bottom: 1px solid var(--border) !important;
    border-right: none !important;
    padding: 6px 10px !important;
    font-size: 11px !important;
}
.dxbl-grid .dxbl-grid-filter-row td { font-size: 11px !important; }
.dxbl-grid .dxbl-grid-filter-row input { font-size: 11px !important; }
.dxbl-grid .dxbl-table-row:hover > td { background-color: #fafafa !important; }
.dxbl-grid .dxbl-grid-pager { background-color: #fff !important; border-top: 1px solid var(--border) !important; padding: 8px 10px !important; font-size: 11px !important; }
.dxbl-grid .dxbl-grid-footer td { font-size: 11px !important; }

/* ── Main Content ────────────────────────────────── */
.app-content {
    flex: 1;
    padding: 10px 10px 10px 2px;
    overflow-y: auto;
    width: 100%;
}


/* ── Footer ──────────────────────────────────────── */
.app-footer {
    background: #f8fafc;
    border-top: 1px solid var(--border);
    padding: 10px 20px;
    text-align: center;
    font-size: 11px;
    color: var(--text-muted);
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 16px;
}
.db-status {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    cursor: default;
}
.db-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
}
.db-dot-ok {
    background: #22c55e;
    box-shadow: 0 0 4px rgba(34,197,94,.5);
}
.db-dot-err {
    background: #ef4444;
    box-shadow: 0 0 4px rgba(239,68,68,.5);
    animation: db-blink 1s infinite;
}
@keyframes db-blink {
    50% { opacity: .4; }
}
.db-label {
    font-size: 11px;
}

/* ── Login Page ──────────────────────────────────── */
.login-wrap {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary-light) 100%);
}

.login-box {
    background: var(--white);
    border-radius: 16px;
    padding: 40px 36px;
    width: 360px;
    box-shadow: 0 20px 60px rgba(0,0,0,.25);
}

.login-logo { text-align: center; margin-bottom: 24px; }
.login-logo img { height: 48px; }
.login-title { font-size: 18px; font-weight: 700; color: var(--primary-dark); text-align: center; margin-bottom: 6px; }
.login-sub   { font-size: 12px; color: var(--text-muted); text-align: center; margin-bottom: 28px; }

.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: 12px; font-weight: 600; color: var(--text); margin-bottom: 6px; }
.form-input {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 13px;
    outline: none;
    transition: border-color .2s;
}
.form-input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(29,95,166,.12); }

.btn-login {
    width: 100%;
    padding: 10px;
    background: linear-gradient(135deg, var(--primary-dark), var(--primary-light));
    color: #fff;
    font-size: 14px;
    font-weight: 600;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    margin-top: 8px;
    transition: opacity .2s;
}
.btn-login:hover { opacity: .9; }

.login-error {
    background: #fef2f2;
    border: 1px solid #fecaca;
    color: #dc2626;
    padding: 10px 14px;
    border-radius: 8px;
    font-size: 12px;
    margin-bottom: 12px;
}

/* ── Blazor Error ────────────────────────────────── */
#blazor-error-ui {
    background: #fef3c7;
    bottom: 0;
    box-shadow: 0 -1px 2px rgba(0,0,0,.2);
    display: none;
    left: 0;
    padding: 0.6rem 1.25rem 0.7rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
}
#blazor-error-ui .dismiss { cursor: pointer; position: absolute; right: 0.75rem; top: 0.5rem; }

/* Keyboard shortcuts popup */
.shortcut-help-wrap { position: relative; display: inline-flex; }
.shortcut-popup {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 6px;
    background: #fff;
    color: #333;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0,0,0,.2);
    padding: 12px 16px;
    min-width: 230px;
    z-index: 9999;
    font-size: 13px;
}
.shortcut-popup-title {
    font-weight: 700;
    font-size: 13px;
    margin-bottom: 8px;
    color: #1a1a1a;
    border-bottom: 1px solid #eee;
    padding-bottom: 6px;
}
.shortcut-row {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 0;
}
.shortcut-row span { margin-left: auto; color: #666; }
.shortcut-row kbd {
    display: inline-block;
    background: #f0f0f0;
    border: 1px solid #ccc;
    border-radius: 3px;
    padding: 1px 6px;
    font-size: 12px;
    font-family: monospace;
    color: #333;
    box-shadow: 0 1px 0 #999;
}

/* === Order Status Badges (TrangThai) === */
.status-badge {
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    white-space: nowrap;
    display: inline-block;
    letter-spacing: 0.2px;
}
.status-new         { background: #3b82f6; color: #fff; }
.status-processing  { background: #f59e0b; color: #fff; }
.status-complete    { background: #10b981; color: #fff; }
.status-locked      { background: #6b7280; color: #fff; }

/* === Export Status Badges (TrangThaiXuat) === */
.xuat-unknown       { background: #94a3b8; color: #fff; }
.xuat-none          { background: #dc2626; color: #fff; }           /* Chưa xuất kho - đỏ */
.xuat-partial       { background: #dc2626; color: #fff; }           /* Chưa xuất đủ - đỏ */
.xuat-ready         { background: #10b981; color: #fff; }           /* Sẵn sàng giao - xanh */
.xuat-done          { background: #86efac; color: #166534; }        /* Đã giao xong - xanh nhạt */
.xuat-return        { background: #a855f7; color: #fff; }
.xuat-today         { background: #f59e0b; color: #fff; }           /* Giao hôm nay - cam */
.xuat-hold          { background: #0ea5e9; color: #fff; }           /* Giữ hàng - xanh dương */
