/* ============================================================
   JewelryCAD -- design tokens
   ============================================================ */
:root {
    --jc-primary: #4f46e5;
    --jc-primary-dark: #4338ca;
    --jc-primary-light: #eef2ff;
    --jc-ink: #1e2433;
    --jc-muted: #6b7280;
    --jc-border: #e5e7eb;
    --jc-bg: #f4f5f9;
    --jc-surface: #ffffff;
    --jc-danger: #dc2626;
    --jc-warning: #d97706;
    --jc-success: #16a34a;
    --jc-sidebar-width: 260px;
    --jc-topbar-height: 64px;
    --jc-radius: 0.85rem;
    --jc-radius-sm: 0.55rem;
    --jc-shadow: 0 1px 2px rgba(16, 24, 40, 0.05), 0 1px 3px rgba(16, 24, 40, 0.06);
    --jc-shadow-md: 0 4px 12px rgba(16, 24, 40, 0.08);
}

* {
    box-sizing: border-box;
}

html, body {
    height: 100%;
    /* A wide table (Items.aspx's grid can carry 15-20+ chosen columns, each
       forced to white-space:nowrap -- see .table > thead th below) must
       only ever scroll within its own .table-responsive wrapper, never
       widen the page itself. Without this, that overflow instead pushed
       the whole <body> wider than the viewport, producing a second,
       page-level horizontal scrollbar that sits below the visible fold
       (only reachable by first scrolling the page all the way down) on
       top of the correctly-contained one inside the grid. */
    overflow-x: hidden;
}

body {
    background-color: var(--jc-bg);
    color: var(--jc-ink);
    font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    font-size: 0.9rem;
    -webkit-font-smoothing: antialiased;
}

a {
    text-decoration: none;
}

h1, h2, h3, h4, h5, h6 {
    font-weight: 600;
    letter-spacing: -0.01em;
}

/* ============================================================
   Topbar
   ============================================================ */
.app-topbar {
    height: var(--jc-topbar-height);
    background-color: var(--jc-surface);
    border-bottom: 1px solid var(--jc-border);
    box-shadow: var(--jc-shadow);
    position: sticky;
    top: 0;
    z-index: 1030;
    display: flex;
    align-items: center;
}

.app-topbar .navbar-brand {
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--jc-ink) !important;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.app-topbar .navbar-brand .bi {
    color: var(--jc-primary);
    font-size: 1.35rem;
}

.navbar-brand-logo {
    height: 28px;
    width: auto;
    object-fit: contain;
}

#btnSidebarToggle {
    border: none;
    background: transparent;
    font-size: 1.35rem;
    color: var(--jc-ink);
    line-height: 1;
    padding: 0.25rem 0.5rem;
    border-radius: var(--jc-radius-sm);
}

#btnSidebarToggle:hover {
    background-color: var(--jc-bg);
}

.topbar-icon-btn {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.25rem;
    height: 2.25rem;
    border-radius: 50%;
    color: var(--jc-muted);
    font-size: 1.15rem;
}

.topbar-icon-btn:hover {
    background-color: var(--jc-bg);
    color: var(--jc-ink);
}

.notif-badge {
    position: absolute;
    top: 0.05rem;
    right: 0.05rem;
    background-color: var(--jc-danger);
    color: #fff;
    font-size: 0.6rem;
    font-weight: 700;
    min-width: 1.05rem;
    height: 1.05rem;
    border-radius: 999px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 0.2rem;
    border: 2px solid var(--jc-surface);
}

.notif-dropdown {
    width: 340px;
    max-width: 90vw;
}

.notif-list {
    max-height: 360px;
    overflow-y: auto;
}

.notif-item {
    position: relative;
    padding: 0.6rem 1rem 0.6rem 1.15rem;
    border-bottom: 1px solid var(--jc-border);
}

.notif-item:last-child {
    border-bottom: none;
}

.notif-item.notif-unread {
    background-color: var(--jc-primary-light);
}

.notif-item.notif-unread::before {
    content: "";
    position: absolute;
    left: 0.4rem;
    top: 0.95rem;
    width: 0.4rem;
    height: 0.4rem;
    border-radius: 50%;
    background-color: var(--jc-primary);
}

.notif-item-link {
    display: block;
    color: var(--jc-ink);
}

.notif-item-link:hover {
    color: var(--jc-primary-dark);
}

.notif-item-text {
    font-size: 0.83rem;
    line-height: 1.35;
    white-space: normal;
}

.notif-item.notif-unread .notif-item-text {
    font-weight: 600;
}

.notif-item-time {
    font-size: 0.72rem;
    color: var(--jc-muted);
    margin-top: 0.15rem;
}

.notif-item-mark {
    font-size: 0.72rem;
    color: var(--jc-primary);
    background: none;
    border: none;
    padding: 0;
    margin-top: 0.25rem;
}

.user-avatar {
    width: 2.1rem;
    height: 2.1rem;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--jc-primary), #7c6df2);
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.85rem;
    flex-shrink: 0;
    overflow: hidden;
}

.user-avatar-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
}

.avatar-lg {
    width: 4.5rem;
    height: 4.5rem;
    font-size: 1.6rem;
}

.avatar-upload-wrap {
    position: relative;
}

.avatar-upload-wrap .avatar-upload-input {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
}

/* ============================================================
   Shell layout
   ============================================================ */
.app-shell {
    display: flex;
    align-items: stretch;
    min-height: calc(100vh - var(--jc-topbar-height));
}

.app-sidebar {
    width: var(--jc-sidebar-width);
    flex-shrink: 0;
    background-color: var(--jc-surface);
    border-right: 1px solid var(--jc-border);
    position: sticky;
    top: var(--jc-topbar-height);
    height: calc(100vh - var(--jc-topbar-height));
    overflow-y: auto;
    transition: transform 0.2s ease, width 0.2s ease;
    z-index: 1020;
}

.app-content {
    flex-grow: 1;
    min-width: 0;
    padding: 1.75rem 2rem;
}

/* ============================================================
   Sidebar -- the "admin dashboard panel"
   ============================================================ */
.sidebar-section-title {
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.07em;
    text-transform: uppercase;
    color: var(--jc-muted);
    padding: 1.1rem 1.15rem 0.4rem;
    margin: 0;
}

.app-sidebar .nav {
    padding: 0.5rem 0.65rem;
}

.app-sidebar .nav-link {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    color: var(--jc-ink);
    font-weight: 500;
    font-size: 0.87rem;
    padding: 0.55rem 0.75rem;
    border-radius: var(--jc-radius-sm);
    margin-bottom: 0.15rem;
}

.app-sidebar .nav-link .bi {
    font-size: 1.05rem;
    color: var(--jc-muted);
    width: 1.25rem;
    text-align: center;
    flex-shrink: 0;
}

.app-sidebar .nav-link:hover {
    background-color: var(--jc-bg);
}

.app-sidebar .nav-link.active {
    background-color: var(--jc-primary-light);
    color: var(--jc-primary-dark);
    font-weight: 600;
}

.app-sidebar .nav-link.active .bi {
    color: var(--jc-primary);
}

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15, 18, 30, 0.45);
    z-index: 1015;
}

.nav-link-text {
    white-space: nowrap;
    overflow: hidden;
}

/* Global postback/loading overlay -- see Content/global-loader.js.
   Sits above everything (including modals) since a save can be triggered
   from inside one; opaque + pointer-events:auto is what blocks a second
   click on the same button during the round trip. */
.jc-loader-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15, 18, 30, 0.35);
    z-index: 2000;
    align-items: center;
    justify-content: center;
    pointer-events: auto;
}

.jc-loader-overlay.jc-loader-visible {
    display: flex;
}

/* ============================================================
   Sidebar tree groups (Data/Master/Admin) -- Bootstrap's own
   Collapse plugin drives the expand/collapse; these classes just
   style the toggle row, the rotating caret, and the indented
   children. See the inline script at the bottom of Site.Master
   for auto-expand-if-active and localStorage persistence.
   ============================================================ */
.nav-group-toggle {
    cursor: pointer;
    justify-content: space-between;
}

.nav-group-toggle .nav-group-toggle-label {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    flex-grow: 1;
    min-width: 0;
}

.nav-group-caret {
    font-size: 0.75rem !important;
    color: var(--jc-muted);
    width: auto !important;
    transition: transform 0.15s ease;
}

.nav-group-toggle[aria-expanded="true"] .nav-group-caret {
    transform: rotate(180deg);
}

.nav-group-children {
    padding-left: 1.6rem;
}

.nav-group-children .nav-link {
    font-size: 0.83rem;
}

/* Admin > Permissions role/permission matrix */
.jc-permission-matrix thead th {
    position: sticky;
    top: 0;
    background-color: var(--jc-surface);
    border-bottom: 2px solid var(--jc-border);
    z-index: 1;
}

/* ============================================================
   Desktop sidebar shrink -- icon-only collapsed mode
   ============================================================ */
@media (min-width: 992px) {
    .app-shell.sidebar-collapsed .app-sidebar {
        width: 4.5rem;
    }

    .app-shell.sidebar-collapsed .app-sidebar .sidebar-section-title,
    .app-shell.sidebar-collapsed .app-sidebar .nav-link-text,
    .app-shell.sidebar-collapsed .app-sidebar .nav-group-caret,
    .app-shell.sidebar-collapsed .app-sidebar .nav-group-children {
        display: none;
    }

    .app-shell.sidebar-collapsed .app-sidebar .nav {
        padding: 0.5rem;
    }

    .app-shell.sidebar-collapsed .app-sidebar .nav-link {
        justify-content: center;
        padding: 0.6rem;
    }

    .app-shell.sidebar-collapsed .app-sidebar .nav-link .bi {
        font-size: 1.25rem;
        width: auto;
    }
}

/* ============================================================
   Cards, KPI tiles, badges
   ============================================================ */
.card {
    border: 1px solid var(--jc-border);
    border-radius: var(--jc-radius);
    box-shadow: var(--jc-shadow);
}

.card-header {
    background-color: var(--jc-surface);
    border-bottom: 1px solid var(--jc-border);
    font-weight: 600;
    border-top-left-radius: var(--jc-radius) !important;
    border-top-right-radius: var(--jc-radius) !important;
}

.kpi-tile {
    border: 1px solid var(--jc-border);
    border-radius: var(--jc-radius);
    background-color: var(--jc-surface);
    box-shadow: var(--jc-shadow);
    padding: 0.9rem 1rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    height: 100%;
}

.kpi-tile .kpi-icon {
    width: 2.6rem;
    height: 2.6rem;
    border-radius: var(--jc-radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    flex-shrink: 0;
    background-color: var(--jc-primary-light);
    color: var(--jc-primary);
}

.kpi-tile.kpi-danger .kpi-icon { background-color: #fee2e2; color: var(--jc-danger); }
.kpi-tile.kpi-warning .kpi-icon { background-color: #fef3c7; color: var(--jc-warning); }
.kpi-tile.kpi-success .kpi-icon { background-color: #dcfce7; color: var(--jc-success); }

.kpi-tile .kpi-value {
    font-size: 1.4rem;
    font-weight: 700;
    line-height: 1.1;
}

.kpi-tile .kpi-label {
    font-size: 0.76rem;
    color: var(--jc-muted);
    font-weight: 500;
}

.status-badge {
    display: inline-block;
    padding: 0.28rem 0.7rem;
    border-radius: 999px;
    font-size: 0.74rem;
    font-weight: 600;
    color: #fff;
    letter-spacing: 0.01em;
}

.priority-urgent {
    color: var(--jc-danger);
    font-weight: 700;
}

/* ============================================================
   CAD Requests -- tile view
   ============================================================ */
.request-tile {
    overflow: hidden;
    transition: box-shadow 0.15s ease-in-out, transform 0.15s ease-in-out;
}

.request-tile:hover {
    box-shadow: var(--jc-shadow-md);
    transform: translateY(-2px);
}

.request-tile-img {
    height: 140px;
    background-color: var(--jc-bg);
    border-bottom: 1px solid var(--jc-border);
}

.request-tile-img img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.request-tile-img-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    color: #d8dbe3;
    font-size: 2.75rem;
}

/* ============================================================
   Removable file chips (see Content/file-input.js)
   ============================================================ */
.jc-file-chip-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin-top: 0.5rem;
}

.jc-file-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    background-color: var(--jc-bg);
    border: 1px solid var(--jc-border);
    border-radius: 999px;
    padding: 0.25rem 0.3rem 0.25rem 0.75rem;
    font-size: 0.78rem;
    max-width: 220px;
}

.jc-file-chip-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.jc-file-chip-remove {
    border: none;
    background: var(--jc-surface);
    color: var(--jc-muted);
    width: 1.2rem;
    height: 1.2rem;
    border-radius: 50%;
    line-height: 1;
    font-size: 0.9rem;
    cursor: pointer;
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

.jc-file-chip-remove:hover {
    background-color: var(--jc-danger);
    color: #fff;
}

/* ============================================================
   Drag-and-drop image input (Content/image-drop-input.js) --
   dropzone + thumbnail grid with per-item crop/remove controls.
   ============================================================ */
.jc-media-dropzone-wrap {
    border: 1px solid var(--jc-border);
    border-radius: 8px;
    overflow: hidden;
    background-color: var(--jc-surface);
}

.jc-media-dropzone {
    border: 1px dashed var(--jc-border);
    margin: 0.5rem;
    border-radius: 6px;
    min-height: 110px;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    cursor: pointer;
    background-color: var(--jc-bg);
    transition: border-color 0.15s ease, background-color 0.15s ease;
}

.jc-media-dropzone:hover {
    border-color: var(--jc-primary);
}

.jc-media-dropzone-active {
    border-color: var(--jc-primary);
    background-color: var(--jc-primary-light);
}

.jc-media-dropzone-hint {
    color: var(--jc-muted);
    font-size: 0.85rem;
    pointer-events: none;
    padding: 0.75rem;
}

.jc-media-dropzone-hint i {
    font-size: 1.4rem;
    display: block;
    margin-bottom: 0.35rem;
}

.jc-media-dropzone-subhint {
    font-size: 0.78rem;
    margin-top: 0.1rem;
}

.jc-media-thumbs-wrap {
    padding: 0 0.5rem;
}

.jc-media-browse-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    border-top: 1px solid var(--jc-border);
    padding: 0.4rem 0.5rem;
    background-color: var(--jc-surface);
}

.jc-media-browse-label {
    font-size: 0.82rem;
    color: var(--jc-muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1 1 auto;
}

.jc-media-browse-btn {
    flex-shrink: 0;
}

.jc-media-thumbs {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem;
    margin: 0.6rem 0;
}

.jc-media-thumb {
    position: relative;
    width: 96px;
    border: 1px solid var(--jc-border);
    border-radius: 6px;
    overflow: hidden;
    background-color: var(--jc-surface);
}

.jc-media-thumb img {
    width: 100%;
    height: 72px;
    object-fit: cover;
    display: block;
}

.jc-media-thumb video {
    width: 100%;
    height: 72px;
    object-fit: cover;
    display: block;
    background-color: #000;
    pointer-events: none;
}

.jc-media-thumb-icon {
    width: 100%;
    height: 72px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.6rem;
    color: var(--jc-muted);
}

.jc-media-thumb-playicon {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 72px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 1.6rem;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.6);
    pointer-events: none;
}

.jc-media-thumb-name {
    font-size: 0.68rem;
    padding: 0.15rem 0.3rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--jc-muted);
}

.jc-media-thumb-actions {
    position: absolute;
    top: 0.25rem;
    right: 0.25rem;
    display: flex;
    gap: 0.25rem;
}

.jc-media-thumb-btn {
    border: none;
    background-color: rgba(0, 0, 0, 0.55);
    color: #fff;
    width: 1.4rem;
    height: 1.4rem;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    line-height: 1;
}

.jc-media-thumb-btn:hover {
    background-color: var(--jc-primary);
}

.jc-media-thumb-btn-danger:hover {
    background-color: var(--jc-danger);
}

.jc-media-thumb {
    cursor: grab;
}

.jc-media-thumb-dragging {
    opacity: 0.4;
}

/* Already-uploaded photo gallery (ItemDetail.aspx) -- reorderable via
   jcWireReorderableGallery in image-drop-input.js. The first tile is the
   Items list-page thumbnail. */
.jc-reorder-gallery {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem;
    margin-bottom: 0.5rem;
}

.jc-reorder-thumb {
    position: relative;
    width: 96px;
    border: 1px solid var(--jc-border);
    border-radius: 6px;
    overflow: hidden;
    background-color: var(--jc-surface);
    cursor: grab;
}

.jc-reorder-thumb:first-child {
    border: 2px solid var(--jc-primary);
}

.jc-reorder-thumb:first-child::before {
    content: "Thumbnail";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    background-color: var(--jc-primary);
    color: #fff;
    font-size: 0.62rem;
    text-align: center;
    padding: 0.05rem 0;
    z-index: 1;
}

.jc-reorder-thumb img {
    width: 100%;
    height: 72px;
    object-fit: cover;
    display: block;
    pointer-events: none;
}

.jc-reorder-thumb-name {
    font-size: 0.68rem;
    padding: 0.15rem 0.3rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--jc-muted);
    pointer-events: none;
}

.jc-reorder-thumb-dragging {
    opacity: 0.4;
}

/* Already-uploaded Videos gallery -- same tile footprint as .jc-reorder-thumb
   but not draggable (no SortOrder/thumbnail concept for videos), so it's a
   separate class rather than reusing .jc-reorder-thumb's :first-child badge
   and grab cursor. */
.jc-video-tile {
    position: relative;
    width: 96px;
    border: 1px solid var(--jc-border);
    border-radius: 6px;
    overflow: hidden;
    background-color: var(--jc-surface);
}

.jc-video-tile video {
    width: 100%;
    height: 72px;
    object-fit: cover;
    display: block;
    background-color: #000;
    pointer-events: none;
}

.jc-reorder-thumb-actions {
    position: absolute;
    top: 0.25rem;
    right: 0.25rem;
    z-index: 2;
    display: flex;
    gap: 0.25rem;
}

/* Keep the view button clear of the "Thumbnail" badge bar on the first tile. */
.jc-reorder-thumb:first-child .jc-reorder-thumb-actions {
    top: 1.5rem;
}

/* Cropper.js measures its container's own box, not the source image's
   natural size -- a fixed height (not max-height+overflow) is what keeps a
   huge camera photo from blowing out the modal or the page. Cropper hides
   the plain <img> once it initializes and draws its own canvas sized to
   fit exactly this box, whatever the source resolution is. */
.jc-crop-frame {
    width: 100%;
    height: 55vh;
    max-height: 480px;
    min-height: 280px;
    background-color: var(--jc-bg);
    overflow: hidden;
}

.jc-crop-frame img {
    max-width: 100%;
    display: block;
}

.jc-crop-hint {
    color: var(--jc-muted);
    font-size: 0.78rem;
    margin-top: 0.15rem;
}

.jc-crop-toolbar {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    margin-top: 0.75rem;
}

.jc-crop-toolbar-sep {
    width: 1px;
    height: 1.4rem;
    background-color: var(--jc-border);
    margin: 0 0.25rem;
}

.jc-view-image {
    max-width: 100%;
    max-height: 75vh;
    object-fit: contain;
}

.jc-view-counter {
    font-size: 0.72rem;
    color: var(--jc-muted);
}

.jc-view-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    border: none;
    background-color: rgba(0, 0, 0, 0.45);
    color: #fff;
    width: 2.25rem;
    height: 2.25rem;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.15rem;
    z-index: 2;
}

.jc-view-nav:hover {
    background-color: rgba(0, 0, 0, 0.7);
}

.jc-view-nav-prev {
    left: 0.5rem;
}

.jc-view-nav-next {
    right: 0.5rem;
}

/* Items list thumbnail column */
.jc-list-thumb {
    display: block;
    width: 44px;
    height: 44px;
    border-radius: 6px;
    object-fit: cover;
    background-color: var(--jc-bg);
}

.jc-list-thumb-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--jc-muted);
    border: 1px dashed var(--jc-border);
    font-size: 1.1rem;
}

/* Job Order field grouping (NewJobOrder.aspx / JobOrderDetail.aspx) --
   visually separates the handful of fields a Job Order actually owns
   (editable) from everything cloned from its source Item (read-only, never
   edited on the Job Order -- see BLL.JobOrderService.PrepareFromItem). */
.jc-editable-card {
    border-left: 4px solid var(--bs-primary, #0d6efd);
}

.jc-editable-card > .card-header {
    background-color: rgba(13, 110, 253, 0.08);
}

.jc-readonly-card {
    border-left: 4px solid var(--bs-secondary, #6c757d);
    background-color: var(--bs-tertiary-bg, #f8f9fa);
}

.jc-readonly-card > .card-header {
    background-color: var(--bs-secondary-bg, #e9ecef);
    color: var(--bs-secondary-color, #6c757d);
}

.jc-readonly-card .form-control[readonly],
.jc-readonly-card .form-select:disabled {
    background-color: var(--bs-secondary-bg, #e9ecef);
    opacity: 1;
}

.jc-field-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 1rem;
}

.jc-field-legend-item {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.8rem;
    color: var(--bs-secondary-color, #6c757d);
}

.jc-field-legend-swatch {
    width: 0.85rem;
    height: 0.85rem;
    border-radius: 3px;
    display: inline-block;
}

.jc-field-legend-swatch-editable {
    background-color: var(--bs-primary, #0d6efd);
}

.jc-field-legend-swatch-readonly {
    background-color: var(--bs-secondary, #6c757d);
}

/* Searchable select (Content/searchable-select.js) -- type-to-filter box
   layered over a hidden native <select>, used by NewJobOrder.aspx's Item #
   picker and reusable anywhere a plain dropdown's list gets too long to
   scroll comfortably. */
.jc-searchable-select-wrap {
    position: relative;
}

.jc-searchable-select-list {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 1000;
    max-height: 260px;
    overflow-y: auto;
    background: var(--bs-body-bg, #fff);
    border: 1px solid var(--bs-border-color, #ced4da);
    border-radius: 0.375rem;
    box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
    margin-top: 2px;
}

.jc-searchable-select-item {
    padding: 0.375rem 0.75rem;
    cursor: pointer;
    font-size: 0.9rem;
}

.jc-searchable-select-item:hover {
    background: var(--bs-tertiary-bg, #f1f3f5);
}

.jc-searchable-select-empty {
    padding: 0.375rem 0.75rem;
    font-size: 0.9rem;
    color: var(--bs-secondary-color, #6c757d);
}

/* Column chooser (Content/column-chooser.js) -- generic drag-to-reorder
   checklist, used by Items.aspx and reusable on any future grid. */
.jc-col-list {
    list-style: none;
    margin: 0;
    padding: 0;
    max-height: 55vh;
    overflow-y: auto;
}

.jc-col-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 0.5rem;
    border: 1px solid var(--jc-border);
    border-radius: 6px;
    margin-bottom: 0.4rem;
    background-color: var(--jc-surface);
    cursor: grab;
}

.jc-col-item:last-child {
    margin-bottom: 0;
}

.jc-col-drag-handle {
    color: var(--jc-muted);
}

.jc-col-item .form-check {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.jc-col-item .form-check-input {
    margin-top: 0;
    flex-shrink: 0;
}

.jc-col-item-dragging {
    opacity: 0.4;
}

/* Bulk import preview table (ImportItems.aspx) */
.jc-import-row-error {
    background-color: rgba(220, 53, 69, 0.06);
}

.jc-import-row-ok {
    background-color: rgba(25, 135, 84, 0.04);
}

/* ============================================================
   Toggle switches. Styling input[type=checkbox] directly (even
   Bootstrap's own .form-switch) kept losing to other styling in
   this app's page context. Instead, the real checkbox is visually
   hidden (not display:none -- that would drop it from the tab
   order -- clipped to 1x1px instead, the standard accessible way
   to hide a form control while keeping it focusable) and the
   switch is drawn entirely by an adjacent <label class="jc-toggle-visual">
   sibling, styled via the :checked sibling combinator.
   ============================================================ */
.jc-toggle-input {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.jc-toggle-visual {
    position: relative;
    display: inline-block;
    box-sizing: border-box;
    width: 3em;
    height: 1.6em;
    flex-shrink: 0;
    background-color: #ced4da;
    border-radius: 999px;
    box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.08);
    cursor: pointer;
    transition: background-color 0.15s ease-in-out;
    vertical-align: middle;
}

.jc-toggle-visual::before {
    content: "";
    position: absolute;
    top: 0.16em;
    left: 0.16em;
    width: 1.28em;
    height: 1.28em;
    border-radius: 50%;
    background-color: #fff;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.35);
    transition: transform 0.15s ease-in-out;
}

.jc-toggle-input:checked + .jc-toggle-visual {
    background-color: var(--jc-primary);
}

.jc-toggle-input:checked + .jc-toggle-visual::before {
    transform: translateX(1.4em);
}

.jc-toggle-input:focus-visible + .jc-toggle-visual {
    box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.08), 0 0 0 0.2rem var(--jc-primary-light);
}

.jc-toggle-label {
    cursor: pointer;
    margin-left: 0.5rem;
    vertical-align: middle;
}

/* ============================================================
   Data tables -- plain Bootstrap <table>, styled to match the
   app's design tokens. Replaces the DevExpress ASPxGridView used
   everywhere until now; no !important needed here since there's no
   competing framework stylesheet to out-rank.
   ============================================================ */
.table-card {
    border: 1px solid var(--jc-border);
    border-radius: var(--jc-radius);
    background-color: var(--jc-surface);
    box-shadow: var(--jc-shadow);
    overflow: hidden;
}

.table {
    font-size: 0.85rem;
    color: var(--jc-ink);
    margin-bottom: 0;
}

/* ============================================================
   Job Order Board (Production/JobOrderBoard.aspx) -- Stage-based
   Kanban columns, plain HTML5 drag-and-drop (Content/job-order-board.js).
   ============================================================ */
.jc-board-wrap {
    overflow-x: auto;
    padding-bottom: 0.5rem;
}

.jc-board {
    align-items: flex-start;
}

.jc-board-col {
    flex: 0 0 260px;
    width: 260px;
    border: 1px solid var(--jc-border);
    border-radius: var(--jc-radius);
    background-color: var(--jc-surface);
    display: flex;
    flex-direction: column;
    max-height: calc(100vh - 220px);
}

.jc-board-col-header {
    padding: 0.5rem 0.75rem;
    font-weight: 600;
    font-size: 0.85rem;
    border-bottom: 1px solid var(--jc-border);
    background-color: rgba(0,0,0,0.02);
}

.jc-board-col-body {
    padding: 0.5rem;
    overflow-y: auto;
    flex: 1 1 auto;
    min-height: 60px;
}

.jc-board-col-body-over {
    background-color: rgba(13,110,253,0.06);
}

.jc-board-card {
    background-color: var(--jc-surface);
    border: 1px solid var(--jc-border);
    border-radius: 6px;
    padding: 0.5rem 0.6rem;
    margin-bottom: 0.5rem;
    cursor: grab;
    font-size: 0.8rem;
}

.jc-board-card-dragging {
    opacity: 0.4;
}

.jc-board-card-title {
    font-weight: 600;
    display: block;
}

.table > thead {
    background-color: var(--jc-bg);
}

.table > thead th {
    font-weight: 700;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--jc-muted);
    border-bottom: 2px solid var(--jc-border);
    padding: 0.7rem 0.9rem;
    white-space: nowrap;
}

.table > tbody td {
    padding: 0.65rem 0.9rem;
    vertical-align: middle;
    border-bottom: 1px solid var(--jc-border);
}

.table > tbody tr:last-child td {
    border-bottom: none;
}

.table-hover > tbody > tr:hover > * {
    background-color: var(--jc-primary-light);
}

.table a {
    color: var(--jc-primary);
    font-weight: 600;
    text-decoration: none;
}

.table a:hover {
    color: var(--jc-primary-dark);
    text-decoration: underline;
}

.table-empty-state {
    padding: 2.5rem 1rem;
    text-align: center;
    color: var(--jc-muted);
}

.table-toolbar {
    padding: 0.75rem 0.9rem;
    border-bottom: 1px solid var(--jc-border);
    background-color: var(--jc-surface);
}

.table-toolbar .form-control {
    max-width: 280px;
}

.sortable-th {
    cursor: pointer;
    user-select: none;
}

.sortable-th:hover {
    color: var(--jc-primary);
}

.sortable-th .sort-icon {
    margin-left: 0.35rem;
    font-size: 0.7rem;
    opacity: 0.35;
}

.sortable-th .sort-icon-active {
    opacity: 1;
    color: var(--jc-primary);
}

.table-pager {
    padding: 0.65rem 0.9rem;
    border-top: 1px solid var(--jc-border);
    background-color: var(--jc-surface);
}

/* ============================================================
   Central DataGrid component (Content/jc-grid.js, Tabulator.js-based).
   Theme override to match this app's .table-card/.table-toolbar design
   tokens instead of Tabulator's own default look -- see BLL.GridColumnDef
   for the column contract this renders.
   ============================================================ */
.jc-grid-container {
    font-size: 0.83rem;
    border: none;
    background-color: transparent;
}
/* Shown only when the grid gains focus via keyboard (Tab), not on a
   plain mouse click -- indicates Shift+ArrowUp/Down/Ctrl+A/Escape row
   selection is active without an intrusive outline on every click. */
.jc-grid-container:focus {
    outline: none;
}
.jc-grid-container:focus-visible {
    outline: 2px solid var(--jc-primary);
    outline-offset: -1px;
}
.jc-grid-container .tabulator-row.tabulator-selectable {
    user-select: none;
}

/* Header title row. */
.jc-grid-container .tabulator-header {
    background-color: var(--jc-bg);
    border-bottom: 1px solid var(--jc-border);
}
.jc-grid-container .tabulator-col {
    background-color: var(--jc-bg);
    border-right: 1px solid var(--jc-border);
}
.jc-grid-container .tabulator-col:last-child {
    border-right: none;
}
.jc-grid-container .tabulator-col-title {
    font-weight: 700;
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--jc-muted);
    overflow: visible;
}
.jc-grid-container .tabulator-col.tabulator-sortable:hover {
    background-color: var(--jc-primary-light);
}

/* The filter trigger now lives INSIDE the title row itself (top-right
   corner of each header cell, via titleFormatter -> .jc-grid-title-wrap
   below), not in a separate row underneath -- that old separate row read
   as a second strip of boxed controls rather than a quiet per-column
   affordance. Tabulator's own header-filter row still exists in the DOM
   (excelFilterEditor is still assigned as each column's headerFilter, see
   jc-grid.js) purely so its filter-state machinery -- getHeaderFilters()/
   setHeaderFilterValue(), used for saved-layout persistence -- keeps
   working unchanged; it's just never shown. */
.jc-grid-container .tabulator-header-filter {
    display: none;
}

/* One title + one funnel button, sharing the header row. The button is
   ABSOLUTELY positioned in the corner rather than a flex sibling of the
   text -- an earlier version used justify-content:space-between, which
   made the button a flex item competing for the same row's width as the
   label text; combined with Tabulator's own native sort-arrow (a sibling
   element outside this wrap, already eating into the column's width), long
   labels got crushed down to 1-4 visible characters ("L...", "SOURC...").
   Overlaying the button instead means the text keeps the wrap's FULL width
   (minus a small fixed padding-right reserved so the two never overlap),
   which is what actually fixes the truncation. */
.jc-grid-title-wrap {
    position: relative;
    display: block;
    width: 100%;
    padding-right: 16px;
    box-sizing: border-box;
}
.jc-grid-title-text {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.jc-grid-container .tabulator-row {
    background-color: var(--jc-surface);
    border-bottom: 1px solid var(--jc-border);
    transition: background-color 0.1s ease;
}
/* A faint zebra stripe on alternating rows -- purely a readability aid
   on a dense, many-column grid, subtle enough not to look busy. */
.jc-grid-container .tabulator-row.tabulator-row-even {
    background-color: var(--jc-bg);
}
.jc-grid-container .tabulator-row:hover {
    background-color: var(--jc-primary-light);
}
.jc-grid-container .tabulator-row.tabulator-selected {
    background-color: var(--jc-primary-light) !important;
    box-shadow: inset 3px 0 0 var(--jc-primary);
    transition: background-color 0.1s ease, box-shadow 0.1s ease;
}
.jc-grid-container .tabulator-col.tabulator-sortable {
    transition: background-color 0.1s ease;
}
.jc-grid-container .tabulator-cell {
    padding: 0.5rem 0.7rem;
    white-space: nowrap;
    border-right: 1px solid var(--jc-border);
}
.jc-grid-container .tabulator-cell:last-child {
    border-right: none;
}
.jc-grid-container.jc-grid-wrap .tabulator-cell {
    white-space: normal;
    word-break: break-word;
}
.jc-grid-container .tabulator-footer {
    background-color: var(--jc-surface);
    border-top: 1px solid var(--jc-border);
    font-size: 0.78rem;
    color: var(--jc-muted);
}
.jc-grid-container.jc-grid-row-compact .tabulator-row { min-height: 26px; }
.jc-grid-container.jc-grid-row-compact .tabulator-cell { padding: 0.25rem 0.6rem; }
.jc-grid-container.jc-grid-row-normal .tabulator-row { min-height: 36px; }
.jc-grid-container.jc-grid-row-comfortable .tabulator-row { min-height: 48px; }
.jc-grid-container.jc-grid-row-comfortable .tabulator-cell { padding: 0.85rem 0.9rem; }

.jc-grid-thumb {
    width: 36px;
    height: 36px;
    object-fit: cover;
    border-radius: 4px;
}
.jc-grid-thumb-placeholder {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 4px;
    background-color: var(--jc-bg);
    color: var(--jc-muted);
}

/* Excel-style AutoFilter replica (Content/jc-grid.js's excelFilterEditor /
   openExcelFilterPopup) -- the funnel button now renders inside the title
   row itself (see .jc-grid-title-wrap above), not this hidden filter row.
   The popup it opens is appended to <body> and positioned absolutely,
   since it needs to escape the header row's tight height and any table
   scroll-clipping. */
.jc-grid-filter-btn {
    position: absolute;
    top: 50%;
    right: -2px;
    transform: translateY(-50%);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 14px;
    border: 1px solid transparent;
    background-color: transparent;
    border-radius: 4px;
    color: var(--jc-muted);
    font-size: 0.62rem;
    line-height: 1;
    cursor: pointer;
    opacity: 0.45;
    transition: opacity 0.15s ease, background-color 0.15s ease, color 0.15s ease, transform 0.1s ease;
}
.jc-grid-filter-btn:hover {
    opacity: 1;
    color: var(--jc-primary);
    border-color: var(--jc-border);
    background-color: var(--jc-surface);
    transform: translateY(-50%) scale(1.08);
}
.jc-grid-filter-btn-active {
    opacity: 1;
    color: #fff;
    border-color: var(--jc-primary);
    background-color: var(--jc-primary);
}

.jc-grid-filter-popup {
    position: fixed;
    z-index: 2000;
    width: 230px;
    background-color: var(--jc-surface);
    border: 1px solid var(--jc-border);
    border-radius: var(--jc-radius);
    box-shadow: 0 6px 24px rgba(0,0,0,0.18);
    animation: jcFilterPopupIn 0.12s ease;
    padding: 4px 0;
    font-size: 0.82rem;
}
.jc-grid-filter-popup-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 5px 12px;
    cursor: pointer;
    color: var(--jc-ink);
    transition: background-color 0.1s ease;
}
.jc-grid-filter-popup-item:hover {
    background-color: var(--jc-primary-light);
}

@keyframes jcFilterPopupIn {
    from { opacity: 0; transform: translateY(-4px); }
    to { opacity: 1; transform: translateY(0); }
}
.jc-grid-filter-popup-item-disabled {
    color: var(--jc-muted);
    cursor: default;
}
.jc-grid-filter-popup-item-disabled:hover {
    background-color: transparent;
}
.jc-grid-filter-popup-item-arrow {
    color: var(--jc-muted);
    font-size: 0.7rem;
}
.jc-grid-filter-popup-value-title {
    padding: 4px 12px 6px;
    font-weight: 600;
    font-size: 0.8rem;
}
.jc-grid-filter-popup-and-label {
    padding: 4px 12px;
    font-size: 0.78rem;
    color: var(--jc-muted);
}
.jc-grid-filter-popup-divider {
    border-top: 1px solid var(--jc-border);
    margin: 4px 0;
}
.jc-grid-filter-popup-search {
    display: block;
    width: calc(100% - 20px);
    margin: 2px 10px 6px;
    padding: 3px 6px;
    font-size: 0.8rem;
    border: 1px solid var(--jc-border);
    border-radius: 3px;
}
.jc-grid-filter-popup-list {
    max-height: 220px;
    overflow-y: auto;
    padding: 0 10px;
    border-top: 1px solid var(--jc-border);
    border-bottom: 1px solid var(--jc-border);
}
.jc-grid-filter-popup-option {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 3px 0;
    cursor: pointer;
    font-weight: normal;
    margin-bottom: 0;
}
.jc-grid-filter-popup-select-all {
    font-weight: 600;
    border-bottom: 1px solid var(--jc-border);
    margin-bottom: 2px;
    padding-bottom: 5px;
}
.jc-grid-filter-popup-footer {
    display: flex;
    justify-content: flex-end;
    gap: 6px;
    padding: 8px 10px 2px;
}

/* ============================================================
   CAD Discussion -- per-request chat with image/3D-file
   attachments (Web/Content/chat.js).
   ============================================================ */
.chat-thread {
    max-height: 440px;
    overflow-y: auto;
    padding: 0.25rem 0.5rem 0.25rem 0.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
}

.chat-msg {
    max-width: 80%;
    background-color: var(--jc-bg);
    border: 1px solid var(--jc-border);
    border-radius: var(--jc-radius-sm);
    padding: 0.55rem 0.75rem;
    align-self: flex-start;
}

.chat-msg-mine {
    align-self: flex-end;
    background-color: var(--jc-primary-light);
    border-color: var(--jc-primary);
}

.chat-msg-header {
    font-size: 0.72rem;
    color: var(--jc-muted);
    margin-bottom: 0.25rem;
}

.chat-msg-header strong {
    color: var(--jc-ink);
    font-size: 0.78rem;
}

.chat-msg-revtag {
    color: var(--jc-primary);
    font-weight: 600;
}

.chat-msg-text {
    font-size: 0.85rem;
    color: var(--jc-ink);
    white-space: pre-wrap;
    word-break: break-word;
}

.chat-attachments {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.chat-attachment img {
    width: 90px;
    height: 90px;
    object-fit: cover;
    border-radius: 6px;
    border: 1px solid var(--jc-border);
    display: block;
}

.chat-attachment-file {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    font-size: 0.78rem;
    background-color: var(--jc-surface);
    border: 1px solid var(--jc-border);
    border-radius: 6px;
    padding: 0.35rem 0.55rem;
    color: var(--jc-primary);
}

.chat-empty-state {
    text-align: center;
    color: var(--jc-muted);
    padding: 1.5rem;
    font-size: 0.85rem;
}

.chat-composer textarea {
    resize: vertical;
}

/* ============================================================
   Print -- strips the app chrome so "Print Item" (and any
   other page) prints just the content, not the navbar/sidebar/
   toasts/action buttons around it. Bootstrap's own .d-print-none
   handles hiding individual buttons; this handles the shell.
   ============================================================ */
@media print {
    .app-topbar,
    .app-sidebar,
    .sidebar-overlay,
    .jc-loader-overlay,
    .toast-container {
        display: none !important;
    }

    .app-shell {
        margin: 0 !important;
    }

    .app-content {
        padding: 0 !important;
    }
}

/* ============================================================
   Toasts
   ============================================================ */
.toast-container {
    z-index: 1080;
}

/* ============================================================
   Responsive: collapsible sidebar below lg breakpoint
   ============================================================ */
@media (max-width: 991.98px) {
    .app-sidebar {
        position: fixed;
        left: 0;
        top: var(--jc-topbar-height);
        transform: translateX(-100%);
        box-shadow: var(--jc-shadow-md);
    }

    .app-sidebar.sidebar-open {
        transform: translateX(0);
    }

    .sidebar-overlay.sidebar-open {
        display: block;
    }

    .app-content {
        padding: 1.25rem;
    }
}

@media (max-width: 575.98px) {
    .app-topbar .navbar-text {
        display: none;
    }
}
