/* modernlv.css — Modern ListView Web Part styles (PLAN-1048) */
/* Replaces listview.css for lists rendered with EnableModernListView=true */

/* ===== Root container ===== */
.mlv-root {
    --mlv-accent: #0078d4;
    --mlv-border: #edebe9;
    --mlv-header-bg: #faf9f8;
    --mlv-row-hover: #f3f2f1;
    --mlv-row-selected: #deecf9;
    --mlv-row-selected-hover: #c7e0f4;
    --mlv-text: #323130;
    --mlv-text-secondary: #605e5c;
    --mlv-text-placeholder: #a19f9d;
    --mlv-font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    --mlv-font-size: 14px;
    --mlv-row-height: 40px;
    --mlv-header-height: 40px;
    --mlv-checkbox-size: 16px;
    --mlv-radius: 2px;
    --mlv-shadow: 0 1.6px 3.6px rgba(0,0,0,.132), 0 0.3px 0.9px rgba(0,0,0,.108);
    font-family: var(--mlv-font);
    font-size: var(--mlv-font-size);
    color: var(--mlv-text);
    background: #fff;
    border: 1px solid var(--mlv-border);
    border-radius: var(--mlv-radius);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-height: 200px;
}

/* Dark mode */
@media (prefers-color-scheme: dark) {
    .mlv-root {
        --mlv-accent: #2899f5;
        --mlv-border: #3b3a39;
        --mlv-header-bg: #292827;
        --mlv-row-hover: #323130;
        --mlv-row-selected: #1b3a5c;
        --mlv-row-selected-hover: #234f7a;
        --mlv-text: #f3f2f1;
        --mlv-text-secondary: #c8c6c4;
        --mlv-text-placeholder: #797775;
        background: #201f1e;
    }
}

/* ===== Command bar ===== */
.mlv-commandbar {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 6px 8px;
    border-bottom: 1px solid var(--mlv-border);
    background: #fff;
    flex-shrink: 0;
    min-height: 44px;
    flex-wrap: wrap;
}
@media (prefers-color-scheme: dark) {
    .mlv-commandbar { background: #201f1e; }
}
.mlv-commandbar-left { display: flex; align-items: center; gap: 4px; flex: 1; flex-wrap: wrap; }
.mlv-commandbar-right { display: flex; align-items: center; gap: 4px; margin-left: auto; }

.mlv-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 0 12px;
    height: 32px;
    border: 1px solid transparent;
    border-radius: var(--mlv-radius);
    background: transparent;
    color: var(--mlv-text);
    font-family: var(--mlv-font);
    font-size: 14px;
    cursor: pointer;
    white-space: nowrap;
    transition: background 80ms, border-color 80ms;
    text-decoration: none;
}
.mlv-btn:hover { background: var(--mlv-row-hover); }
.mlv-btn:active { background: var(--mlv-border); }
.mlv-btn:focus-visible { outline: 2px solid var(--mlv-accent); outline-offset: 1px; }

.mlv-btn-primary {
    background: var(--mlv-accent);
    color: #fff;
    border-color: var(--mlv-accent);
}
.mlv-btn-primary:hover { background: #106ebe; border-color: #106ebe; }
.mlv-btn-primary:active { background: #005a9e; border-color: #005a9e; }

.mlv-btn-icon {
    padding: 0 6px;
    font-size: 16px;
}

.mlv-viewpicker {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 0 10px;
    height: 32px;
    border: 1px solid var(--mlv-border);
    border-radius: var(--mlv-radius);
    background: transparent;
    color: var(--mlv-text);
    font-family: var(--mlv-font);
    font-size: 14px;
    cursor: pointer;
    min-width: 120px;
    max-width: 240px;
}
.mlv-viewpicker:hover { border-color: #8a8886; }
.mlv-viewpicker-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }

.mlv-search {
    display: flex;
    align-items: center;
    border: 1px solid var(--mlv-border);
    border-radius: var(--mlv-radius);
    padding: 0 8px;
    height: 32px;
    gap: 6px;
    background: #fff;
    min-width: 180px;
    max-width: 280px;
    transition: border-color 80ms;
}
@media (prefers-color-scheme: dark) { .mlv-search { background: #201f1e; } }
.mlv-search:focus-within { border-color: var(--mlv-accent); }
.mlv-search input {
    border: none;
    background: transparent;
    outline: none;
    font-family: var(--mlv-font);
    font-size: 14px;
    color: var(--mlv-text);
    width: 100%;
    min-width: 0;
}
.mlv-search input::placeholder { color: var(--mlv-text-placeholder); }
.mlv-search-icon { color: var(--mlv-text-secondary); font-size: 16px; flex-shrink: 0; }

/* Selection mode command bar morphing */
.mlv-commandbar.has-selection .mlv-btn-primary { opacity: 0.6; }
.mlv-commandbar .mlv-selection-cmds { display: none; }
.mlv-commandbar.has-selection .mlv-selection-cmds { display: inline-flex; align-items: center; gap: 4px; }

/* ===== PLAN-1730: command-bar restyle (modern-ui scope) =====
   On modern pages the global tokens.css reset `body[data-modern-ui="true"] button:not(.btn)`
   (specificity 0,0,2,2) flattens every .mlv-btn / .mlv-viewpicker (0,0,1,0) to
   borderless/padless/transparent text — beating modernlv.css's base rules — so the bar read
   as bare "developer stylish" text with no resting affordance. These body-scoped rules
   (specificity 0,0,3,1) win over the reset: a clear tinted command-bar surface, secondary
   buttons with an outline resting affordance, one filled primary, restored view-picker chrome,
   harmonized icon sizing. */
body[data-modern-ui="true"] .mlv-commandbar {
    gap: 6px;
    padding: 8px 12px;
    background: var(--mlv-header-bg);
    border-bottom: 1px solid var(--mlv-border);
}
@media (prefers-color-scheme: dark) {
    body[data-modern-ui="true"] .mlv-commandbar { background: #292827; }
}

body[data-modern-ui="true"] .mlv-commandbar .mlv-btn {
    height: 32px;
    padding: 0 12px;
    gap: 6px;
    border: 1px solid var(--mlv-border);
    border-radius: var(--mlv-radius);
    background: #fff;
    color: var(--mlv-text);
    font-size: 14px;
}
@media (prefers-color-scheme: dark) {
    body[data-modern-ui="true"] .mlv-commandbar .mlv-btn { background: #201f1e; }
}
body[data-modern-ui="true"] .mlv-commandbar .mlv-btn:hover {
    background: var(--mlv-row-hover);
    border-color: var(--mlv-text-secondary);
}
body[data-modern-ui="true"] .mlv-commandbar .mlv-btn:active {
    background: var(--mlv-border);
}
body[data-modern-ui="true"] .mlv-commandbar .mlv-btn:focus-visible {
    outline: 2px solid var(--mlv-accent);
    outline-offset: 1px;
}

/* One filled primary action ("New item" / quick-edit Save). */
body[data-modern-ui="true"] .mlv-commandbar .mlv-btn-primary {
    background: var(--mlv-accent);
    border-color: var(--mlv-accent);
    color: #fff;
}
body[data-modern-ui="true"] .mlv-commandbar .mlv-btn-primary:hover {
    background: #106ebe;
    border-color: #106ebe;
}
body[data-modern-ui="true"] .mlv-commandbar .mlv-btn-primary:active {
    background: #005a9e;
    border-color: #005a9e;
}

/* View picker — restore the chrome the reset stripped. */
body[data-modern-ui="true"] .mlv-commandbar .mlv-viewpicker {
    height: 32px;
    padding: 0 10px;
    border: 1px solid var(--mlv-border);
    border-radius: var(--mlv-radius);
    background: #fff;
    color: var(--mlv-text);
}
@media (prefers-color-scheme: dark) {
    body[data-modern-ui="true"] .mlv-commandbar .mlv-viewpicker { background: #201f1e; }
}
body[data-modern-ui="true"] .mlv-commandbar .mlv-viewpicker:hover {
    border-color: var(--mlv-text-secondary);
    background: var(--mlv-row-hover);
}

/* Preserve the toggled-active affordance (Filter / Edit-in-grid pressed) — the base
   `.mlv-btn.active` rule (0,0,2,0) loses to the body-scoped restyle above, so re-assert it. */
body[data-modern-ui="true"] .mlv-commandbar .mlv-btn.active {
    background: var(--mlv-row-selected);
    color: var(--mlv-accent);
    border-color: var(--mlv-accent);
}

/* Harmonize SVG icon sizing inside command-bar buttons. */
body[data-modern-ui="true"] .mlv-commandbar .mlv-btn .sp-icon {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

/* ===== Inline filter row (BUG-0319) ===== */
.mlv-filter-row th.mlv-filter-cell {
    padding: 2px 4px;
    background: var(--mlv-header-bg, #f3f2f1);
    border-bottom: 2px solid var(--mlv-accent, #0078d4);
}
.mlv-filter-input {
    width: 100%;
    box-sizing: border-box;
    padding: 2px 5px;
    border: 1px solid var(--mlv-border, #edebe9);
    border-radius: 2px;
    font-size: 12px;
    background: #fff;
    outline: none;
    min-width: 0;
}
.mlv-filter-input:focus { border-color: var(--mlv-accent, #0078d4); box-shadow: 0 0 0 1px var(--mlv-accent, #0078d4); }
.ms-ribbon-btn.active { background: #ddeeff; color: #0055a5; font-weight: 600; }
@media print { .mlv-filter-row { display: none !important; } }

/* ===== Filter chips ===== */
.mlv-filter-chips {
    display: none;
    align-items: center;
    gap: 6px;
    padding: 4px 8px;
    border-bottom: 1px solid var(--mlv-border);
    flex-wrap: wrap;
    flex-shrink: 0;
    /* BUG-0627: on narrow viewports the filter pane (z-index:10000) is full-width and
       covers the chips row. position:relative + z-index:10001 ensures the chips row
       participates in the root stacking context above the filter pane. */
    position: relative;
    z-index: 10001;
    background: var(--mlv-header-bg, #faf9f8);
}
.mlv-filter-chips.visible { display: flex; }
.mlv-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    border: 1px solid var(--mlv-accent);
    border-radius: 12px;
    font-size: 12px;
    color: var(--mlv-accent);
    background: #eff6fc;
    white-space: nowrap;
}
@media (prefers-color-scheme: dark) { .mlv-chip { background: #1b3a5c; } }
.mlv-chip-remove {
    cursor: pointer;
    border: none;
    background: none;
    padding: 0;
    line-height: 1;
    color: inherit;
    font-size: 14px;
    display: flex;
    align-items: center;
}

/* ===== Grid scroll container ===== */
.mlv-grid-wrapper {
    flex: 1;
    overflow: auto;
    position: relative;
    min-height: 80px;
}

/* ===== Grid table ===== */
.mlv-table {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
}
.mlv-table th,
.mlv-table td {
    padding: 0 8px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    vertical-align: middle;
    border-bottom: 1px solid var(--mlv-border);
}

/* Checkbox column */
.mlv-col-check {
    width: 36px;
    min-width: 36px;
    max-width: 36px;
    text-align: center;
    padding: 0 4px;
}
.mlv-checkbox {
    width: var(--mlv-checkbox-size);
    height: var(--mlv-checkbox-size);
    cursor: pointer;
    accent-color: var(--mlv-accent);
}

/* ===== Column headers ===== */
.mlv-thead { position: sticky; top: 0; z-index: 10; background: var(--mlv-header-bg); }
.mlv-table th {
    height: var(--mlv-header-height);
    font-weight: 600;
    font-size: 12px;
    color: var(--mlv-text-secondary);
    text-transform: none;
    border-bottom: 2px solid var(--mlv-border);
    user-select: none;
    white-space: nowrap;
    position: relative;
}
.mlv-table th.mlv-col-sorted-asc .mlv-sort-indicator::after { content: " ↑"; color: var(--mlv-accent); }
.mlv-table th.mlv-col-sorted-desc .mlv-sort-indicator::after { content: " ↓"; color: var(--mlv-accent); }

.mlv-th-content {
    display: flex;
    align-items: center;
    gap: 4px;
    height: 100%;
    cursor: pointer;
}
.mlv-th-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; min-width: 0; }
.mlv-th-chevron {
    flex-shrink: 0;
    font-size: 10px;
    color: var(--mlv-text-placeholder);
    opacity: 0;
    transition: opacity 80ms;
}
.mlv-table th:hover .mlv-th-chevron { opacity: 1; }

/* Column resize handle */
.mlv-resize-handle {
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    width: 6px;
    cursor: col-resize;
    background: transparent;
    z-index: 1;
}
.mlv-resize-handle:hover,
.mlv-resize-handle.resizing { background: var(--mlv-accent); opacity: 0.5; }

/* Column drag-reorder */
.mlv-table th.mlv-col-dragging { opacity: 0.4; }
.mlv-table th.mlv-col-drag-over { border-left: 2px solid var(--mlv-accent); background: #eff6fc; }
@media (prefers-color-scheme: dark) { .mlv-table th.mlv-col-drag-over { background: #1b3a5c; } }

/* ===== Data rows ===== */
.mlv-table tbody tr {
    height: var(--mlv-row-height);
    transition: background 60ms;
    position: relative;
}
.mlv-table tbody tr:hover { background: var(--mlv-row-hover); }
.mlv-table tbody tr.selected { background: var(--mlv-row-selected); }
.mlv-table tbody tr.selected:hover { background: var(--mlv-row-selected-hover); }

/* Row actions cell (ⓘ + ⋯) */
.mlv-row-actions-cell {
    width: 64px;
    min-width: 64px;
    max-width: 64px;
    text-align: right;
    padding: 0 4px;
    white-space: nowrap;
}
.mlv-row-details-btn,
.mlv-row-actions {
    visibility: hidden;
}
.mlv-table tbody tr:hover .mlv-row-details-btn,
.mlv-table tbody tr:hover .mlv-row-actions,
.mlv-table tbody tr.selected .mlv-row-details-btn,
.mlv-table tbody tr.selected .mlv-row-actions,
.mlv-table tbody tr.mlv-row-details-open .mlv-row-details-btn,
/* BUG-1061: keep ⋯ visible while its context menu is open */
.mlv-table tbody tr.mlv-row-menu-open .mlv-row-actions { visibility: visible; }
.mlv-table tbody tr.mlv-row-details-open .mlv-row-details-btn { color: var(--mlv-accent); }

/* Row keyboard focus */
.mlv-table tbody tr.mlv-row-focused {
    outline: 2px solid var(--mlv-accent);
    outline-offset: -2px;
}
.mlv-table tbody tr.mlv-row-focused:focus { outline: 2px solid var(--mlv-accent); }

/* ===== Density variants ===== */
.mlv-root.density-compact { --mlv-row-height: 28px; --mlv-header-height: 28px; --mlv-font-size: 12px; }
.mlv-root.density-spacious { --mlv-row-height: 52px; --mlv-header-height: 52px; }

/* ===== Loading skeleton ===== */
.mlv-skeleton {
    display: flex;
    flex-direction: column;
    gap: 1px;
    padding: 0;
}
.mlv-skeleton-row {
    display: flex;
    align-items: center;
    height: var(--mlv-row-height);
    padding: 0 8px;
    gap: 12px;
    border-bottom: 1px solid var(--mlv-border);
    animation: mlv-pulse 1.5s ease-in-out infinite;
}
.mlv-skeleton-cell {
    height: 12px;
    border-radius: 6px;
    background: linear-gradient(90deg, #edebe9 25%, #d2d0ce 50%, #edebe9 75%);
    background-size: 200% 100%;
    animation: mlv-shimmer 1.5s ease-in-out infinite;
}
@media (prefers-color-scheme: dark) {
    .mlv-skeleton-cell {
        background: linear-gradient(90deg, #3b3a39 25%, #484644 50%, #3b3a39 75%);
        background-size: 200% 100%;
    }
}
@keyframes mlv-shimmer {
    0%   { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}
.mlv-skeleton-check { width: 16px; height: 16px; border-radius: 3px; flex-shrink: 0; }
.mlv-skeleton-title { flex: 2; }
.mlv-skeleton-col  { flex: 1; }
.mlv-skeleton-col-sm { flex: 0.6; }

/* ===== Empty state ===== */
.mlv-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 24px;
    color: var(--mlv-text-secondary);
    text-align: center;
    gap: 16px;
}
.mlv-empty-icon {
    font-size: 48px;
    opacity: 0.4;
    line-height: 1;
}
.mlv-empty-title { font-size: 18px; font-weight: 600; color: var(--mlv-text); }
.mlv-empty-msg { font-size: 14px; max-width: 360px; line-height: 1.5; }
.mlv-empty-actions { display: flex; gap: 8px; margin-top: 8px; }

/* ===== Error banner ===== */
.mlv-error-banner {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: #fed9cc;
    color: #a4262c;
    border-bottom: 1px solid #f3b8b5;
    font-size: 13px;
    flex-shrink: 0;
}
@media (prefers-color-scheme: dark) {
    .mlv-error-banner { background: #442726; color: #f4b9b2; border-color: #5c3232; }
}
.mlv-error-banner button {
    margin-left: auto;
    border: none;
    background: transparent;
    cursor: pointer;
    color: inherit;
    font-size: 16px;
    padding: 0 4px;
}

/* ===== Pagination ===== */
.mlv-pagination {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 12px;
    padding: 8px 12px;
    border-top: 1px solid var(--mlv-border);
    font-size: 13px;
    color: var(--mlv-text-secondary);
    flex-shrink: 0;
    background: var(--mlv-header-bg);
}
.mlv-pager { display: flex; align-items: center; gap: 4px; }
.mlv-pager button {
    width: 28px;
    height: 28px;
    border: 1px solid var(--mlv-border);
    border-radius: var(--mlv-radius);
    background: transparent;
    cursor: pointer;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--mlv-text);
}
.mlv-pager button:hover:not(:disabled) { background: var(--mlv-row-hover); }
.mlv-pager button:disabled { opacity: 0.4; cursor: default; }
.mlv-pager-info { white-space: nowrap; }

/* ===== Column header menu (Phase 2 — pre-styled) ===== */
.mlv-col-menu {
    position: fixed;
    min-width: 200px;
    background: #fff;
    border: 1px solid var(--mlv-border);
    border-radius: 4px;
    box-shadow: var(--mlv-shadow);
    z-index: 9999;
    padding: 4px 0;
    font-size: 14px;
    display: none;
    overflow-y: auto;
}
.mlv-col-menu.open { display: block; }
@media (prefers-color-scheme: dark) { .mlv-col-menu { background: #292827; } }
.mlv-col-menu-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 12px;
    cursor: pointer;
    color: var(--mlv-text);
    transition: background 60ms;
}
/* BUG-1063: menu items changed to <button> — reset browser button defaults */
button.mlv-col-menu-item {
    width: 100%;
    border: none;
    background: none;
    text-align: left;
    font: inherit;
    font-size: 14px;
}
.mlv-col-menu-item:hover { background: var(--mlv-row-hover); }
.mlv-col-menu-item:focus { outline: none; background: var(--mlv-row-hover); }
.mlv-col-menu-sep { height: 1px; background: var(--mlv-border); margin: 4px 0; }
.mlv-col-menu-icon { width: 16px; text-align: center; color: var(--mlv-text-secondary); }

/* ===== Show/hide columns panel — BUG-1009, BUG-1011 ===== */
.mlv-colvis-panel {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: #fff;
    border: 1px solid var(--mlv-border);
    border-radius: 6px;
    box-shadow: 0 8px 32px rgba(0,0,0,.18);
    z-index: 10001;
    min-width: 280px;
    max-width: 400px;
    width: 90%;
    display: flex;
    flex-direction: column;
    max-height: 80vh;
    font-size: 14px;
}
.mlv-colvis-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px 8px;
    border-bottom: 1px solid var(--mlv-border);
    font-weight: 600;
    font-size: 14px;
}
.mlv-colvis-close {
    background: none;
    border: none;
    cursor: pointer;
    padding: 2px 6px;
    font-size: 16px;
    color: var(--mlv-text-secondary);
    border-radius: 3px;
}
.mlv-colvis-close:hover { background: var(--mlv-row-hover); }
.mlv-colvis-content { overflow-y: auto; flex: 1; padding: 4px 0; }
.mlv-colvis-list { list-style: none; margin: 0; padding: 0; }
.mlv-colvis-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 5px 16px;
    cursor: pointer;
}
.mlv-colvis-item:hover { background: var(--mlv-row-hover); }
.mlv-colvis-item input[type="checkbox"] { cursor: pointer; }
.mlv-colvis-item label { cursor: pointer; flex: 1; }
.mlv-colvis-loading, .mlv-colvis-empty { padding: 16px; color: var(--mlv-text-secondary); text-align: center; }
.mlv-colvis-footer {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding: 8px 16px 12px;
    border-top: 1px solid var(--mlv-border);
}
.mlv-colvis-cancel, .mlv-colvis-apply {
    padding: 5px 14px;
    border-radius: 3px;
    border: 1px solid var(--mlv-border);
    cursor: pointer;
    font-size: 13px;
}
.mlv-colvis-apply { background: var(--mlv-accent, #0072c6); color: #fff; border-color: var(--mlv-accent, #0072c6); }
.mlv-colvis-apply:hover { opacity: .9; }
.mlv-colvis-cancel { background: #fff; color: var(--mlv-text); }
.mlv-colvis-cancel:hover { background: var(--mlv-row-hover); }

/* ===== View picker dropdown (Phase 5 pre-styled) ===== */
.mlv-dropdown {
    position: fixed;
    min-width: 180px;
    /* BUG-0724: cap height to viewport so items are never out of reach */
    max-height: calc(100vh - 64px);
    overflow-y: auto;
    background: #fff;
    border: 1px solid var(--mlv-border);
    border-radius: 4px;
    box-shadow: var(--mlv-shadow);
    z-index: 10100; /* BUG-0755: must exceed filter-chips z-index (10001) */
    padding: 4px 0;
    display: none;
}
.mlv-dropdown.open { display: block; }
@media (prefers-color-scheme: dark) { .mlv-dropdown { background: #292827; } }
.mlv-dropdown-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 12px;
    cursor: pointer;
    color: var(--mlv-text);
    font-size: 14px;
    transition: background 60ms;
}
.mlv-dropdown-item:hover { background: var(--mlv-row-hover); }
.mlv-dropdown-item.active { color: var(--mlv-accent); font-weight: 600; }
.mlv-dropdown-sep { height: 1px; background: var(--mlv-border); margin: 4px 0; }
/* ik ux7h / General Topic: section label inside the command-bar "More" overflow menu */
.mlv-dropdown-header {
    padding: 6px 12px 2px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--mlv-text-secondary, #605e5c);
    cursor: default;
    user-select: none;
}
@media (prefers-color-scheme: dark) { .mlv-dropdown-header { color: #c8c6c4; } }

/* ===== Add column button ===== */
.mlv-add-column-th {
    width: 120px;
    min-width: 80px;
}
.mlv-add-column-btn {
    display: flex;
    align-items: center;
    gap: 4px;
    color: var(--mlv-text-secondary);
    background: none;
    border: none;
    cursor: pointer;
    font-size: 12px;
    font-family: var(--mlv-font);
    padding: 0 4px;
    white-space: nowrap;
}
.mlv-add-column-btn:hover { color: var(--mlv-accent); }

/* ===== Responsive (Phase 8) ===== */
@media (max-width: 768px) {
    .mlv-commandbar { flex-wrap: wrap; gap: 4px; min-height: 36px; }
    .mlv-commandbar-left { flex-wrap: wrap; gap: 2px; }
    .mlv-search { min-width: 120px; max-width: 160px; }
    .mlv-table td, .mlv-table th { padding: 0 4px; font-size: 12px; }
    /* Hide secondary columns (not title, not checkbox) on narrow viewports */
    .mlv-table th:not(:nth-child(1)):not(:nth-child(2)):nth-child(n+5),
    .mlv-table td:not(:nth-child(1)):not(:nth-child(2)):nth-child(n+5) { display: none; }
    .mlv-details-pane { width: 100%; right: -100vw; max-width: 100vw; }
    .mlv-filterpane   { width: 100%; right: -100vw; max-width: 100vw; }
}
@media (max-width: 480px) {
    .mlv-commandbar-right { display: none; } /* Hide search + view picker on very small */
    .mlv-viewpicker { display: none; }
    .mlv-btn span { display: none; } /* Icon-only buttons */
}

/* ===== Cell value types ===== */
.mlv-cell-link { color: var(--mlv-accent); text-decoration: none; }
.mlv-cell-link:hover { text-decoration: underline; }
.mlv-cell-bool-yes { color: #107c10; }
.mlv-cell-bool-no  { color: var(--mlv-text-secondary); }
.mlv-cell-choice {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 1px 6px;
    border-radius: 10px;
    font-size: 12px;
    background: #edebe9;
    color: var(--mlv-text);
    white-space: nowrap;
}
@media (prefers-color-scheme: dark) { .mlv-cell-choice { background: #3b3a39; } }
.mlv-cell-number { text-align: right; }
.mlv-cell-date { white-space: nowrap; }
.mlv-cell-person {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}
.mlv-cell-avatar {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--mlv-accent);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 600;
    flex-shrink: 0;
    overflow: hidden;
}

/* ===== Loading overlay ===== */
.mlv-loading-overlay {
    position: absolute;
    inset: 0;
    background: rgba(255,255,255,0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 50;
}
@media (prefers-color-scheme: dark) {
    .mlv-loading-overlay { background: rgba(32,31,30,0.7); }
}
.mlv-spinner {
    width: 28px;
    height: 28px;
    border: 3px solid var(--mlv-border);
    border-top-color: var(--mlv-accent);
    border-radius: 50%;
    animation: mlv-spin 0.8s linear infinite;
}
@keyframes mlv-spin { to { transform: rotate(360deg); } }

/* ===== Real-time toast (Phase 7) ===== */
.mlv-realtime-toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    background: var(--mlv-accent, #0078d4);
    color: #fff;
    padding: 8px 16px;
    border-radius: 4px;
    font-family: var(--mlv-font, sans-serif);
    font-size: 13px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
    z-index: 20000;
    opacity: 1;
    transition: opacity 0.4s ease;
    pointer-events: none;
}
.mlv-realtime-toast.fade { opacity: 0; }

/* ===== Details pane (Phase 3) ===== */
.mlv-details-pane {
    position: fixed;
    top: 0;
    right: -400px;
    width: 360px;
    max-width: 90vw;
    height: 100%;
    background: #fff;
    box-shadow: -4px 0 16px rgba(0,0,0,0.14);
    z-index: 10001;
    display: flex;
    flex-direction: column;
    font-family: var(--mlv-font, sans-serif);
    font-size: 14px;
    color: var(--mlv-text, #323130);
    transition: right 0.22s ease;
}
.mlv-details-pane.mlv-details-open { right: 0; }
@media (prefers-color-scheme: dark) {
    .mlv-details-pane { background: #201f1e; box-shadow: -4px 0 16px rgba(0,0,0,0.5); }
}
.mlv-details-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--mlv-border, #edebe9);
    flex-shrink: 0;
}
.mlv-details-title {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
    min-width: 0;
}
.mlv-details-close {
    border: none;
    background: none;
    cursor: pointer;
    font-size: 20px;
    padding: 0 4px;
    color: var(--mlv-text-secondary, #605e5c);
    flex-shrink: 0;
}
.mlv-details-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px 20px;
}
.mlv-details-field {
    margin-bottom: 14px;
}
.mlv-details-field-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--mlv-text-secondary, #605e5c);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 3px;
}
.mlv-details-field-value {
    font-size: 14px;
    color: var(--mlv-text, #323130);
    overflow-wrap: break-word;
    word-break: break-word;
}
.mlv-details-loading,
.mlv-details-error,
.mlv-details-empty {
    color: var(--mlv-text-secondary);
    font-style: italic;
    padding: 20px 0;
    text-align: center;
}
.mlv-details-footer {
    display: flex;
    gap: 8px;
    padding: 12px 20px;
    border-top: 1px solid var(--mlv-border, #edebe9);
    flex-shrink: 0;
}

/* ===== Filter pane (Phase 5) ===== */
.mlv-filterpane {
    position: fixed;
    top: 0;
    right: -320px;
    width: 300px;
    max-width: 90vw;
    height: 100%;
    background: #fff;
    box-shadow: -4px 0 16px rgba(0,0,0,0.14);
    z-index: 10000;
    display: flex;
    flex-direction: column;
    font-family: var(--mlv-font, sans-serif);
    font-size: 14px;
    color: var(--mlv-text, #323130);
    transition: right 0.22s ease;
}
.mlv-filterpane.mlv-filterpane-open { right: 0; }
/* BUG-0171: push the entire list view container left so filter chips and
   command bar are never covered by the fixed-position filter pane */
body.mlv-pane-open .mlv-root {
    margin-right: 310px;
    transition: margin-right 0.22s ease;
}
body.mlv-pane-open .mlv-filter-chips {
    margin-right: 0;
    transition: none;
}
@media (prefers-color-scheme: dark) { .mlv-filterpane { background: #201f1e; } }
.mlv-filterpane-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--mlv-border, #edebe9);
    flex-shrink: 0;
}
.mlv-filterpane-title { margin: 0; font-size: 16px; font-weight: 600; }
.mlv-filterpane-body { flex: 1; overflow-y: auto; }
.mlv-filterpane-section { border-bottom: 1px solid var(--mlv-border, #edebe9); }
.mlv-filterpane-section-hdr {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    padding: 10px 20px;
    background: none;
    border: none;
    cursor: pointer;
    font-family: inherit;
    font-size: 13px;
    font-weight: 600;
    color: var(--mlv-text);
    text-align: left;
}
.mlv-filterpane-section-hdr:hover { background: var(--mlv-row-hover); }
.mlv-filterpane-chevron { font-size: 10px; color: var(--mlv-text-secondary); }
.mlv-filterpane-section-body { padding: 4px 20px 12px; }
.mlv-filterpane-val-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 3px 0;
    cursor: pointer;
    font-size: 13px;
}
.mlv-filterpane-val-row:hover { color: var(--mlv-accent); }

/* Search match highlight */
mark.mlv-search-match {
    background: #fff100;
    color: #323130;
    border-radius: 2px;
    padding: 0 1px;
}
@media (prefers-color-scheme: dark) { mark.mlv-search-match { background: #9d8b00; color: #fff; } }

/* ===== Grouping (Phase 6) ===== */
.mlv-group-header td { background: var(--mlv-header-bg); }
.mlv-group-header-cell { padding: 0 !important; }
.mlv-group-toggle {
    display: flex;
    align-items: center;
    gap: 6px;
    width: 100%;
    padding: 6px 12px;
    background: none;
    border: none;
    cursor: pointer;
    font-family: inherit;
    font-size: 13px;
    font-weight: 600;
    color: var(--mlv-text);
    text-align: left;
}
.mlv-group-toggle:hover { background: var(--mlv-row-hover); }
.mlv-group-label { font-weight: 600; }
.mlv-group-header.collapsed .mlv-group-toggle { color: var(--mlv-text-secondary); }

/* ===== Column totals footer (Phase 6) ===== */
.mlv-tfoot td {
    padding: 4px 8px;
    font-size: 12px;
    font-weight: 600;
    border-top: 2px solid var(--mlv-border);
    background: var(--mlv-header-bg);
    white-space: nowrap;
}
.mlv-aggregate-label { color: var(--mlv-text-secondary); font-weight: 400; }
.mlv-aggregate-value { color: var(--mlv-accent); }

/* ===== Inline edit mode (Phase 6 + BUG-0490) ===== */
.mlv-root.edit-mode .mlv-table td:not(.mlv-col-check) {
    cursor: cell;
    background-color: #fffbe6;
}
.mlv-root.edit-mode .mlv-table td:not(.mlv-col-check):hover {
    outline: 2px solid var(--mlv-accent);
    outline-offset: -1px;
    background-color: #fff3cd;
}
.mlv-btn.active { background: var(--mlv-row-selected); color: var(--mlv-accent); }
.mlv-inline-input {
    width: 100%;
    height: 100%;
    border: none;
    outline: 2px solid var(--mlv-accent);
    outline-offset: -2px;
    background: #fff;
    font-family: var(--mlv-font);
    font-size: 14px;
    color: var(--mlv-text);
    padding: 0 6px;
    box-sizing: border-box;
}
@media (prefers-color-scheme: dark) { .mlv-inline-input { background: #292827; } }

/* ===== Gantt View (D4) ===== */
#spGanttLayout {
    font-size: 13px;
    background: #fff;
    min-height: 200px;
    user-select: none;
}

/* Toolbar: zoom buttons */
.sp-gantt-zoom-btn {
    padding: 3px 10px;
    border: 1px solid #c8c6c4;
    border-radius: 3px;
    background: #fff;
    font-size: 12px;
    color: #333;
    cursor: pointer;
    font-weight: 500;
}
.sp-gantt-zoom-btn:hover { background: #f4f4f4; }
.sp-gantt-zoom-active {
    background: #0072c6 !important;
    color: #fff !important;
    border-color: #0072c6 !important;
}

/* Left panel — task table */
.sp-gantt-table {
    border-collapse: collapse;
    width: 100%;
    table-layout: fixed;
}
.sp-gantt-table th {
    background: #f4f4f4;
    border-bottom: 2px solid #c8c6c4;
    border-right: 1px solid #e1e1e1;
    padding: 6px 8px;
    font-weight: 600;
    color: #333;
    font-size: 12px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.sp-gantt-th-title { width: auto; }
.sp-gantt-td-title, .sp-gantt-th-title { padding-left: 10px; }
.sp-gantt-td-date, .sp-gantt-th-date { text-align: center; font-size: 11px; color: #666; padding: 0 4px; }
.sp-gantt-td-pct, .sp-gantt-th-pct { text-align: center; font-size: 10px; color: #666; padding: 2px 4px; }
.sp-gantt-row td {
    height: 36px;
    border-bottom: 1px solid #f4f4f4;
    border-right: 1px solid #e1e1e1;
    padding: 4px 8px;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    vertical-align: middle;
}
.sp-gantt-row a { color: #0072c6; text-decoration: none; font-size: 12px; }
.sp-gantt-row a:hover { text-decoration: underline; }
.sp-gantt-row-hover td { background: #f0f9ff !important; }
.sp-gantt-row-overdue td:first-child { border-left: 3px solid #c00; }

/* Mini percent complete bar in left table */
.sp-gantt-pct-mini {
    display: inline-block;
    width: 28px;
    height: 6px;
    background: #e1e1e1;
    border-radius: 3px;
    overflow: hidden;
    vertical-align: middle;
    margin-right: 2px;
}
.sp-gantt-pct-mini-fill { height: 100%; background: #0072c6; border-radius: 3px; }
.sp-gantt-pct-text { font-size: 10px; color: #666; }

/* Primary header (month/year row) */
.sp-gantt-primary-hdr {
    min-height: 28px;
    line-height: 28px;
    padding: 0 8px;
    font-size: 11px;
    font-weight: 600;
    color: #333;
    border-right: 1px solid #c8c6c4;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    background: #faf9f8;
    flex-shrink: 0;
}

/* Secondary headers: day/week/month cells */
.sp-gantt-day-hdr, .sp-gantt-week-hdr, .sp-gantt-month-hdr {
    min-height: 28px;
    line-height: 28px;
    font-size: 10px;
    font-weight: 500;
    color: #666;
    border-right: 1px solid #e1e1e1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    text-align: center;
    flex-shrink: 0;
    box-sizing: border-box;
}
.sp-gantt-week-hdr { padding: 0 4px; font-size: 11px; font-weight: 600; color: #333; }
.sp-gantt-month-hdr { padding: 0 8px; font-size: 11px; font-weight: 600; color: #333; background: #faf9f8; }
.sp-gantt-day-hdr.sp-gantt-weekend { background: #f9f0f0; color: #a19f9d; }

/* Grid lines */
.sp-gantt-grid-line { position: absolute; top: 0; width: 1px; background: #e1e1e1; pointer-events: none; }
.sp-gantt-weekend-bg { position: absolute; top: 0; background: rgba(0,0,0,0.02); pointer-events: none; }

/* Gantt bar */
.sp-gantt-bar {
    background: #0072c6;
    border-radius: 3px;
    box-sizing: border-box;
    overflow: hidden;
    position: absolute;
    transition: filter 0.1s;
    z-index: 2;
}
.sp-gantt-bar-overdue { background: #d13438; }
.sp-gantt-bar-hover { filter: brightness(1.15); outline: 2px solid #004578; z-index: 3; }
.sp-gantt-bar-fill {
    position: absolute;
    left: 0; top: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.25);
    border-radius: 3px 0 0 3px;
    pointer-events: none;
}
.sp-gantt-bar-label {
    position: absolute;
    left: 6px;
    right: 4px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 11px;
    color: #fff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    pointer-events: none;
    font-weight: 500;
}

/* Tooltip */
.sp-gantt-tooltip {
    display: none;
    position: fixed;
    z-index: 10000;
    background: #fff;
    border: 1px solid #c8c6c4;
    border-radius: 4px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    padding: 10px 14px;
    font-size: 12px;
    color: #333;
    max-width: 300px;
    pointer-events: none;
    line-height: 1.5;
}
.sp-gantt-tt-row { margin-top: 2px; }
.sp-gantt-tt-label { color: #666; font-weight: 600; }
.sp-gantt-tt-overdue { margin-top: 4px; color: #c00; font-weight: 600; font-size: 11px; }

/* Dependency lines (SVG) */
.sp-gantt-dep-line { fill: none; stroke: #8a8886; stroke-width: 1.5; stroke-dasharray: 4 2; }
.sp-gantt-dep-arrow { fill: #8a8886; }
