/* ===========================================================
   Sales App — base styling rebased on inklaring-systeem foundation.
   Brand orange = #E8941A (Sales App identity).
   Layout tokens, font stack, login, app-shell, dashboard cards,
   forms/tables and validation rules mirror inklaring's app.css.
   Sales App specific blocks (cart badge, item grid bn-* hooks) live
   at the bottom so they stay visible when porting markup from inklaring.
   =========================================================== */

:root {
    /* === inklaring variable system (names mirrored, values use Sales App orange) === */
    --brand: #E8941A;
    --brand-dark: #cf800f;
    --brand-light: #fff4e6;
    --brand-gradient: linear-gradient(90deg, #E8941A 0%, #cf800f 100%);
    --brand-gradient-vertical: linear-gradient(135deg, #f5b04a 0%, #E8941A 50%, #cf800f 100%);
    --sidebar-bg: #ffffff;
    --sidebar-text: #495057;
    --sidebar-active-bg: #fff4e6;
    --sidebar-active-text: #cf800f;
    --content-bg: #f5f6f8;
    --topbar-h: 60px;
    --sidebar-w: 240px;

    /* === Sales App backward-compatible aliases (keep existing markup working) === */
    --brand-orange: #E8941A;
    --brand-orange-dark: #cf800f;
    --brand-orange-light: #fff4e6;
    --brand-orange-bg: #fff4e6;
    --brand-orange-shadow: rgba(232, 148, 26, 0.25);
    --topbar-height: 60px;
    --sidebar-width: 240px;
    --text-dark: #212529;
    --text-muted: #6c757d;
    --border-light: #e6e8eb;
    --bg-light: #f5f6f8;
}

html, body {
    height: 100%;
    margin: 0;
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: var(--content-bg);
    color: #212529;
}

a { text-decoration: none; }
a, .btn-link { color: var(--brand); }

/* ===== Buttons (brand) ===== */
.btn-brand,
.btn-primary {
    background: var(--brand);
    border-color: var(--brand);
    color: #ffffff;
    font-weight: 600;
    min-height: 38px;
}
.btn-brand:hover, .btn-brand:focus,
.btn-primary:hover, .btn-primary:focus, .btn-primary:active {
    background: var(--brand-dark);
    border-color: var(--brand-dark);
    color: #ffffff;
}
.btn-brand:disabled,
.btn-primary:disabled {
    background: #f0b162;
    border-color: #f0b162;
    color: #ffffff;
}
.btn-outline-brand {
    color: var(--brand);
    border-color: var(--brand);
    background: #ffffff;
}
.btn-outline-brand:hover {
    background: var(--brand);
    color: #ffffff;
}
.btn:focus, .btn:active:focus,
.btn-link.nav-link:focus,
.form-control:focus, .form-check-input:focus {
    box-shadow: 0 0 0 0.2rem var(--brand-orange-shadow);
}
.form-control:focus, .form-select:focus {
    border-color: var(--brand);
    box-shadow: 0 0 0 0.2rem var(--brand-orange-shadow);
}
.form-check-input:checked {
    background-color: var(--brand);
    border-color: var(--brand);
}

/* Touch-friendly button sizing */
.btn { min-height: 38px; }
.btn-sm { min-height: 30px; }

h1:focus { outline: none; }

/* ===== Login (mirrors inklaring) ===== */
.login-bg {
    min-height: 100vh;
    background: var(--brand-gradient-vertical);
    display: flex;
    align-items: center;
    justify-content: center;
}
.login-card {
    background: #fff;
    border-radius: 14px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.18);
    width: 100%;
    max-width: 380px;
    padding: 32px 28px;
}
.login-logo {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--brand-light);
    color: var(--brand);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 12px;
    font-size: 28px;
}
.login-title {
    text-align: center;
    color: #2b2f33;
    font-weight: 600;
    letter-spacing: 0.4px;
    margin-bottom: 22px;
    font-size: 14px;
}

/* ===========================================================
   App shell — two layouts coexist:
   1. .app-shell / .app-body / .app-content (inklaring-style flex shell)
   2. .app-layout (legacy Sales App grid shell — kept until TASK-017
      ports the markup over). Both share the same topbar/sidebar tokens.
   =========================================================== */

/* ----- inklaring-style flex shell ----- */
.app-shell {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}
.app-body {
    flex: 1;
    display: flex;
    min-height: 0;
}
.app-content {
    flex: 1;
    padding: 28px 32px;
    overflow-y: auto;
    background: var(--content-bg);
}

/* ----- Sales App grid shell (current AppLayout.razor) ----- */
.app-layout {
    min-height: 100vh;
    display: grid;
    grid-template-columns: var(--sidebar-w) 1fr;
    grid-template-rows: var(--topbar-h) 1fr;
    grid-template-areas:
        "topbar topbar"
        "sidebar main";
}
.app-main {
    grid-area: main;
    padding: 28px 32px;
    min-width: 0;
    background: var(--content-bg);
}

/* ===== Topbar (full viewport width, solid orange — matches inklaring class names) ===== */
.app-topbar {
    grid-area: topbar;
    height: var(--topbar-h);
    background: var(--brand);
    color: #ffffff;
    display: flex;
    align-items: center;
    padding: 0 18px;
    box-shadow: 0 1px 6px rgba(0, 0, 0, 0.08);
    position: sticky;
    top: 0;
    z-index: 1030;
    width: 100%;
}
.app-topbar .brand,
.app-topbar .topbar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    font-weight: 600;
    font-size: 18px;
    color: #ffffff;
    text-decoration: none;
}
.app-topbar .brand-logo,
.app-topbar .topbar-logo {
    width: 38px;
    height: 38px;
    background: rgba(255, 255, 255, 0.18);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    font-weight: 700;
    color: #ffffff;
    line-height: 1;
    letter-spacing: 0.5px;
}
.app-topbar .topbar-title { white-space: nowrap; }
.app-topbar .topbar-spacer { flex: 1 1 auto; }

.app-topbar .topbar-toggle {
    background: transparent;
    border: 0;
    color: #ffffff;
    width: 44px;
    height: 44px;
    padding: 0;
    margin-right: 4px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 22px;
    display: none;
    align-items: center;
    justify-content: center;
}
.app-topbar .topbar-toggle:hover,
.app-topbar .topbar-toggle:focus {
    background-color: rgba(255, 255, 255, 0.15);
    outline: none;
}
.topbar-toggle-icon {
    display: inline-block;
    width: 22px;
    height: 2px;
    background-color: #ffffff;
    position: relative;
}
.topbar-toggle-icon::before,
.topbar-toggle-icon::after {
    content: "";
    position: absolute;
    left: 0;
    width: 22px;
    height: 2px;
    background-color: #ffffff;
}
.topbar-toggle-icon::before { top: -7px; }
.topbar-toggle-icon::after { top: 7px; }

.app-topbar .topbar-right {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 14px;
}
.app-topbar .welkom,
.app-topbar .topbar-welcome {
    font-size: 14px;
    font-weight: 500;
    color: #ffffff;
    margin-right: 0.25rem;
    max-width: 220px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.app-topbar .btn-logout,
.app-topbar .topbar-logout {
    background: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.4);
    color: #ffffff;
    padding: 5px 14px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    min-height: 36px;
}
.app-topbar .btn-logout:hover,
.app-topbar .topbar-logout:hover,
.app-topbar .topbar-logout:focus {
    background: rgba(255, 255, 255, 0.28);
    outline: none;
}

/* ===== Sidebar ===== */
.app-sidebar {
    grid-area: sidebar;
    width: var(--sidebar-w);
    background: var(--sidebar-bg);
    border-right: 1px solid #e6e8eb;
    overflow-y: auto;
    transition: margin-left 0.2s, transform 0.2s;
    flex-shrink: 0;
    position: sticky;
    top: var(--topbar-h);
    align-self: start;
    height: calc(100vh - var(--topbar-h));
    z-index: 1020;
}
.app-sidebar.closed { margin-left: calc(var(--sidebar-w) * -1); }

.sidebar-backdrop {
    display: none;
    position: fixed;
    inset: var(--topbar-h) 0 0 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 1010;
}

/* ===== Sidebar nav items (inklaring-style nav-link) ===== */
.app-sidebar .menu-label {
    font-size: 11px;
    text-transform: uppercase;
    color: #adb5bd;
    padding: 14px 18px 6px;
    letter-spacing: 1px;
}
.app-sidebar .nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 18px;
    color: var(--sidebar-text);
    font-size: 14px;
    border-left: 3px solid transparent;
    border-radius: 0;
}
.app-sidebar .nav-link i { font-size: 17px; width: 20px; text-align: center; }
.app-sidebar .nav-link:hover { background: #f8f9fa; color: var(--brand); }
.app-sidebar .nav-link.active {
    background: var(--sidebar-active-bg);
    color: var(--sidebar-active-text);
    border-left-color: var(--brand);
    font-weight: 600;
}
.app-sidebar .nav-group-toggle {
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 18px;
    color: var(--sidebar-text);
    font-size: 14px;
    user-select: none;
}
.app-sidebar .nav-group-toggle:hover { color: var(--brand); }
.app-sidebar .nav-group-toggle .chev { margin-left: auto; transition: transform 0.15s; }
.app-sidebar .nav-group-toggle.open .chev { transform: rotate(90deg); }
.app-sidebar .nav-group-children .nav-link { padding-left: 48px; font-size: 13.5px; }
.app-sidebar .nav-link.disabled {
    color: #adb5bd;
    cursor: not-allowed;
}
.app-sidebar .nav-link.disabled:hover {
    background: transparent;
    color: #adb5bd;
}

/* ===== Sales-App AppMenu (current markup) — kept for compatibility until TASK-018 ===== */
.app-menu {
    display: flex;
    flex-direction: column;
    padding: 0.75rem 0;
}
.app-menu-section {
    padding: 1rem 1.25rem 0.4rem 1.25rem;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    color: #adb5bd;
    letter-spacing: 1px;
}
.app-menu-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 18px;
    min-height: 44px;
    color: var(--sidebar-text);
    text-decoration: none;
    border-left: 3px solid transparent;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    background: none;
    border-top: 0;
    border-right: 0;
    border-bottom: 0;
    width: 100%;
    text-align: left;
}
.app-menu-item:hover {
    background: #f8f9fa;
    color: var(--brand);
    text-decoration: none;
}
.app-menu-item.active {
    background: var(--sidebar-active-bg);
    border-left-color: var(--brand);
    color: var(--sidebar-active-text);
    font-weight: 600;
}
.app-menu-item.disabled {
    color: #adb5bd;
    cursor: not-allowed;
    pointer-events: none;
}
.app-menu-icon {
    width: 20px;
    text-align: center;
    font-size: 17px;
    line-height: 1;
}
.app-menu-label { flex: 1 1 auto; }
.app-menu-badge {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--text-muted);
    background-color: var(--bg-light);
    padding: 0.1rem 0.5rem;
    border-radius: 10px;
    letter-spacing: 0.3px;
}

/* ===== Dashboard cards (mirrors inklaring) ===== */
.dash-title { font-weight: 700; color: #1f3548; margin-bottom: 4px; }
.dash-sub { color: #6c757d; margin-bottom: 24px; }
.dash-card {
    background: #fff;
    border: 1px solid #eceef1;
    border-radius: 10px;
    padding: 26px 22px;
    text-align: center;
    transition: transform 0.12s, box-shadow 0.12s, border-color 0.12s;
    cursor: pointer;
    height: 100%;
    color: inherit;
    display: block;
}
.dash-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 22px rgba(232, 148, 26, 0.12);
    border-color: var(--brand);
    color: inherit;
}
.dash-card .icon {
    color: var(--brand);
    font-size: 38px;
    margin-bottom: 12px;
}
.dash-card .title { font-weight: 600; color: #1f3548; font-size: 17px; }
.dash-card .desc { color: #6c757d; font-size: 13px; margin-top: 4px; }
.dash-card.disabled {
    background: #fafafa;
    cursor: not-allowed;
}
.dash-card.disabled:hover {
    transform: none;
    box-shadow: none;
    border-color: #eceef1;
}
.dash-card.disabled .icon { color: #d6d6d6; }
.dash-card.disabled .title { color: #adb5bd; }
.dash-card.disabled .desc { color: #c5c5c5; }

/* ===== Forms / tables ===== */
.page-title { font-weight: 700; color: #1f3548; margin-bottom: 18px; }
.card-block {
    background: #fff;
    border: 1px solid #eceef1;
    border-radius: 10px;
    padding: 18px 20px;
    margin-bottom: 18px;
}
.card-block h6 {
    color: var(--brand);
    text-transform: uppercase;
    letter-spacing: 0.6px;
    font-size: 12px;
    font-weight: 700;
    border-bottom: 1px solid #eceef1;
    padding-bottom: 8px;
    margin-bottom: 14px;
}
.form-label { font-weight: 500; font-size: 13.5px; color: #495057; margin-bottom: 4px; }
.table thead { background: #f8f9fa; }
.table thead th {
    font-size: 12.5px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #6c757d;
    font-weight: 600;
    border-bottom: 2px solid #eceef1;
}
.table-actions .btn { padding: 4px 8px; }

/* Inline-label / input-group prefix pattern */
.card-block .input-group .input-group-text {
    min-width: 130px;
    justify-content: flex-end;
    font-size: 13px;
    background: #f8f9fa;
    color: #495057;
}
.card-block-compact { padding: 10px 14px; }
.card-block-compact h6 { margin-bottom: 0; padding-bottom: 0; border-bottom: 0; }
.card-block-compact .input-group-text { font-size: 12px; min-width: 120px; }

.totaal-row { border-top: 1px solid #eceef1; padding-top: 8px; margin-top: 6px; }

/* Audit cells */
.audit-cell { white-space: nowrap; padding: 6px 10px !important; }
.audit-cell .audit-user { font-size: 12px; color: #495057; line-height: 1.2; }
.audit-cell .audit-date { font-size: 11px; color: #adb5bd; line-height: 1.2; }

/* Right-side delete cell */
.table-delete {
    width: 56px;
    text-align: center;
    border-left: 1px solid #eceef1;
}
.table-delete .btn-outline-danger { border-color: #f5b5b5; }
.table-delete .btn-outline-danger:hover { background: #dc3545; color: #fff; }

/* ===== Validation ===== */
.valid.modified:not([type=checkbox]) { outline: 1px solid #26b050; }
.invalid { outline: 1px solid #dc3545; }
.validation-message { color: #dc3545; font-size: 12.5px; }

/* ===== Toast container ===== */
.toast-stack {
    position: fixed;
    top: 76px;
    right: 18px;
    z-index: 1100;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* ===== Error boundary ===== */
.blazor-error-boundary {
    background: #b32121;
    padding: 1rem;
    color: #fff;
}
.blazor-error-boundary::after { content: "Er is een fout opgetreden."; }

/* ===========================================================
   Sales App specific styles (kept on top of inklaring foundation)
   =========================================================== */

/* ----- Cart icon + badge in topbar ----- */
.topbar-cart {
    position: relative;
    background: rgba(255, 255, 255, 0.15);
    border: 0;
    color: #ffffff;
    width: 44px;
    height: 44px;
    padding: 0;
    border-radius: 8px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    line-height: 1;
}
.topbar-cart:hover, .topbar-cart:focus {
    background-color: rgba(255, 255, 255, 0.3);
    outline: none;
}
.topbar-cart-badge {
    position: absolute;
    top: -2px;
    right: -2px;
    min-width: 22px;
    height: 22px;
    padding: 0 5px;
    background-color: #ffffff;
    color: var(--brand);
    border-radius: 11px;
    font-size: 0.75rem;
    font-weight: 700;
    line-height: 22px;
    text-align: center;
    border: 2px solid var(--brand);
    box-sizing: content-box;
}

/* ----- BestellingNieuw item grid (bn-* hooks) ----- */
.bestelling-nieuw-page { display: block; }

.bn-state {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1.25rem;
    color: var(--text-muted);
}
.bn-state-text { font-size: 14px; }
.bn-alert { margin: 0 0 1rem 0; }

.bn-banner {
    display: flex;
    align-items: center;
    gap: 14px;
    background: #fff;
    border: 1px solid #eceef1;
    border-left: 4px solid var(--brand);
    border-radius: 10px;
    padding: 14px 18px;
    margin-bottom: 16px;
}
.bn-banner-icon {
    width: 44px;
    height: 44px;
    border-radius: 8px;
    background: var(--brand-light);
    color: var(--brand);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    flex-shrink: 0;
}
.bn-banner-info { flex: 1 1 auto; min-width: 0; }
.bn-banner-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    color: var(--text-muted);
    font-weight: 600;
}
.bn-banner-naam { font-size: 17px; font-weight: 700; color: #1f3548; line-height: 1.2; }
.bn-banner-meta { font-size: 13px; color: var(--text-muted); margin-top: 2px; }
.bn-banner-back { min-height: 44px; flex-shrink: 0; }

.bn-search-row { margin-bottom: 14px; }
.bn-search-group .input-group-text { background: #fff; border-right: 0; }
.bn-search-group .form-control { border-left: 0; }

.bn-empty {
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 2.5rem 1rem;
}
.bn-empty-icon { font-size: 42px; color: var(--brand); margin-bottom: 6px; }

.bn-grid { margin: 0; }
.bn-card {
    background: #fff;
    border: 1px solid #eceef1;
    border-radius: 10px;
    overflow: hidden;
    transition: transform 0.12s, box-shadow 0.12s, border-color 0.12s;
    height: 100%;
    display: flex;
    flex-direction: column;
}
.bn-card:hover {
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.06);
    border-color: var(--brand-light);
}
.bn-card-active {
    border: 2px solid var(--brand);
    box-shadow: 0 0 0 3px rgba(232, 148, 26, 0.15);
}
.bn-card-image {
    width: 100%;
    height: 120px;
    background: #f8f9fa;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--brand);
    font-size: 38px;
    overflow: hidden;
}
.bn-card-img { width: 100%; height: 100%; object-fit: contain; display: block; background-color: #f9f9f9; }
.bn-card-placeholder { color: var(--brand); }
.bn-card-body { padding: 10px 12px 12px; display: flex; flex-direction: column; gap: 4px; }
.bn-card-name {
    font-size: 14px;
    font-weight: 600;
    color: #1f3548;
    line-height: 1.25;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    min-height: 2.5em;
}
.bn-card-code { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.4px; }
.bn-card-price { font-size: 14px; font-weight: 700; color: var(--brand); margin-top: 2px; }
.bn-card-controls {
    margin-top: 8px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
}

.bn-qty-btn {
    width: 44px;
    height: 44px;
    padding: 0;
    border-radius: 8px;
    font-size: 18px;
    font-weight: 700;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.bn-qty-minus { background: #f8f9fa; border: 1px solid #e6e8eb; color: #495057; }
.bn-qty-minus:hover:not(:disabled) { background: #eceef1; }
.bn-qty-minus:disabled { opacity: 0.45; cursor: not-allowed; }
.bn-qty-value { font-size: 15px; font-weight: 700; color: #1f3548; min-width: 40px; text-align: center; }

.bn-pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-top: 18px;
}
.bn-page-btn { min-height: 44px; min-width: 44px; }
.bn-page-info { font-size: 13px; color: var(--text-muted); }

/* ===== Tablet / mobile tweaks ===== */
@media (max-width: 991.98px) {
    .app-layout {
        grid-template-columns: 1fr;
        grid-template-areas:
            "topbar"
            "main";
    }
    .app-topbar .topbar-toggle {
        display: inline-flex;
    }
    .app-topbar .welkom,
    .app-topbar .topbar-welcome { display: none; }
    .app-sidebar {
        position: fixed;
        top: var(--topbar-h);
        left: 0;
        bottom: 0;
        height: auto;
        width: var(--sidebar-w);
        max-width: 80vw;
        transition: transform 0.2s ease-in-out;
        box-shadow: 2px 0 8px rgba(0, 0, 0, 0.15);
        z-index: 1025;
    }
    .app-sidebar.closed { transform: translateX(-100%); margin-left: 0; }
    .app-sidebar.open { transform: translateX(0); margin-left: 0; }
    .sidebar-backdrop { display: block; }
    /* Legacy aliases (sales-app) */
    .app-layout.sidebar-open .app-sidebar { transform: translateX(0); }
    .app-layout.sidebar-open .sidebar-backdrop { display: block; }

    .card-block { padding: 14px 14px; }
    .page-title { font-size: 20px; }
}

@media (max-width: 767.98px) {
    .app-topbar { padding: 0 12px; }
    .app-topbar .brand-text,
    .app-topbar .topbar-title { display: none; }
    .app-content,
    .app-main { padding: 16px; }
}

@media (max-width: 575.98px) {
    .modal-dialog { margin: 0; }
    .modal-content { border-radius: 0; min-height: 100vh; }
    .modal-dialog-centered { min-height: auto; }
    .app-content,
    .app-main { padding: 12px; }

    .bn-banner { flex-wrap: wrap; }
    .bn-banner-back { width: 100%; margin-top: 4px; }
    .bn-card-image { height: 100px; }
    .bn-card-name { font-size: 13px; }
}

/* ===== Print ===== */
@media print {
    .app-topbar, .app-sidebar { display: none !important; }
    .app-content, .app-main { padding: 0; background: #fff; }
}
