/**
 * LERP Grid
 * Internal reusable grid/table stylesheet for Luminary ERP.
 *
 * File: web/css/lerpgrid.css
 *
 * Safety rules:
 * - All styles are scoped under .lerp-grid-*.
 * - This file should not affect existing tables unless LerpGrid.init() is used
 *   or a table has data-lerpgrid="auto".
 */


/* ==========================================================================
   Grid variables
   ========================================================================== */

:root {
    --lerp-grid-gold: #cb982b;
    --lerp-grid-gold-dark: #b98622;
    --lerp-grid-border: #d9d9d9;
    --lerp-grid-border-soft: #ececec;
    --lerp-grid-text: #222222;
    --lerp-grid-muted: #666666;
    --lerp-grid-header-bg: #f7f4ec;
    --lerp-grid-row-alt: #fbfbfb;
    --lerp-grid-white: #ffffff;
    --lerp-grid-focus: rgba(203, 152, 43, 0.18);
    --lerp-grid-shadow: 0 8px 22px rgba(1, 1, 1, 0.06);
}


/* ==========================================================================
   Wrapper
   ========================================================================== */

/**
 * Outer grid wrapper.
 */
.lerp-grid-wrapper {
    width: 100%;
    margin-bottom: 16px;
    border: 1px solid var(--lerp-grid-border-soft);
    border-radius: 10px;
    background: var(--lerp-grid-white);
    box-shadow: var(--lerp-grid-shadow);
    overflow: hidden;
}

/**
 * Scroll container.
 *
 * Horizontal scrolling is enabled here so long report tables do not break layout.
 */
.lerp-grid-scroll {
    width: 100%;
    overflow-x: auto;
    overflow-y: visible;
    scrollbar-width: thin;
    scrollbar-color: var(--lerp-grid-gold) transparent;
}

.lerp-grid-scroll::-webkit-scrollbar {
    height: 8px;
}

.lerp-grid-scroll::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.lerp-grid-scroll::-webkit-scrollbar-thumb {
    background: var(--lerp-grid-gold);
    border-radius: 999px;
}

/**
 * Optional state when horizontal scroll is disabled.
 */
.lerp-grid-scroll-disabled {
    overflow-x: visible;
}


/* ==========================================================================
   Toolbar
   ========================================================================== */

/**
 * Toolbar area above table.
 */
.lerp-grid-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 12px;
    border-bottom: 1px solid var(--lerp-grid-border-soft);
    background: #ffffff;
}

/**
 * Toolbar left/right groups.
 */
.lerp-grid-toolbar-left,
.lerp-grid-toolbar-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

/**
 * Toolbar title.
 */
.lerp-grid-title {
    color: var(--lerp-grid-text);
    font-size: 15px;
    font-weight: 700;
}

/**
 * Search box.
 */
.lerp-grid-search-input {
    min-width: 220px;
    height: 34px;
    padding: 6px 10px;
    border: 1px solid var(--lerp-grid-border);
    border-radius: 7px;
    color: var(--lerp-grid-text);
    font-size: 13px;
    outline: none;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.lerp-grid-search-input:focus {
    border-color: var(--lerp-grid-gold);
    box-shadow: 0 0 0 3px var(--lerp-grid-focus);
}

/**
 * Toolbar buttons.
 */
.lerp-grid-button {
    height: 34px;
    padding: 6px 12px;
    border: 1px solid var(--lerp-grid-gold);
    border-radius: 7px;
    background: #ffffff;
    color: var(--lerp-grid-gold);
    font-size: 13px;
    font-weight: 600;
    line-height: 1;
    cursor: pointer;
    transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.lerp-grid-button:hover,
.lerp-grid-button:focus {
    border-color: var(--lerp-grid-gold-dark);
    background: var(--lerp-grid-gold);
    color: #ffffff;
}


/* ==========================================================================
   Table base
   ========================================================================== */

/**
 * Enhanced table.
 *
 * Existing table classes remain intact; these styles are added only after initialization.
 */
.lerp-grid-table {
    width: 100%;
    min-width: max-content;
    margin-bottom: 0;
    border-collapse: separate;
    border-spacing: 0;
    color: var(--lerp-grid-text);
    background: var(--lerp-grid-white);
}

/**
 * Header cells.
 */
.lerp-grid-table > thead > tr > th,
.lerp-grid-table > thead > tr > td {
    border-bottom: 1px solid var(--lerp-grid-border);
    background: var(--lerp-grid-header-bg);
    color: var(--lerp-grid-text);
    font-size: 13px;
    font-weight: 700;
    white-space: nowrap;
}

/**
 * Body cells.
 */
.lerp-grid-table > tbody > tr > td,
.lerp-grid-table > tbody > tr > th {
    border-bottom: 1px solid var(--lerp-grid-border-soft);
    color: var(--lerp-grid-text);
    font-size: 13px;
    vertical-align: middle;
}

/**
 * Compact spacing for dense ERP data.
 */
.lerp-grid-table-compact > thead > tr > th,
.lerp-grid-table-compact > thead > tr > td,
.lerp-grid-table-compact > tbody > tr > td,
.lerp-grid-table-compact > tbody > tr > th {
    padding: 7px 9px;
}

/**
 * Alternate row background.
 */
.lerp-grid-table-striped > tbody > tr:nth-child(even):not(.lerp-grid-empty-row) {
    background: var(--lerp-grid-row-alt);
}

/**
 * Hover state.
 */
.lerp-grid-table > tbody > tr:not(.lerp-grid-empty-row):hover {
    background: rgba(203, 152, 43, 0.06);
}

/**
 * Sticky header support.
 *
 * Works when the table scrolls horizontally inside .lerp-grid-scroll.
 */
.lerp-grid-table-sticky > thead > tr > th,
.lerp-grid-table-sticky > thead > tr > td {
    position: sticky;
    top: 0;
    z-index: 2;
}


/* ==========================================================================
   Empty state
   ========================================================================== */

.lerp-grid-empty-row {
    background: #ffffff !important;
}

.lerp-grid-empty-cell {
    padding: 18px 12px !important;
    color: var(--lerp-grid-muted);
    font-size: 13px;
    text-align: center;
}


/* ==========================================================================
   Responsive
   ========================================================================== */

@media (max-width: 767px) {
    .lerp-grid-toolbar {
        align-items: stretch;
        flex-direction: column;
    }

    .lerp-grid-toolbar-left,
    .lerp-grid-toolbar-right {
        width: 100%;
        justify-content: flex-start;
        flex-wrap: wrap;
    }

    .lerp-grid-search-input {
        width: 100%;
        min-width: 0;
    }
}

/* ==========================================================================
   LERP Worksheet
   File: views/worksheet/ops.php
   ========================================================================== */

/**
 * Worksheet container.
 *
 * Keep position relative because the fill handle is absolutely positioned
 * inside this worksheet area.
 */
.lerp-worksheet {
    position: relative;
    width: 100%;
}

/**
 * Toolbar.
 *
 * Compact sizing is intentional because worksheet pages need more visible rows.
 */
.lerp-worksheet-toolbar {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 4px;
    min-height: 40px;
    padding: 5px 10px;
    border: 1px solid #cfcfcf;
    background: #f7f7f7;
}

/**
 * Toolbar buttons.
 *
 * Reduced from the earlier larger size to better match the old worksheet density.
 */
.lerp-worksheet-toolbar-button {
    width: 28px;
    height: 26px;
    padding: 0;
    border: 0;
    border-radius: 4px;
    background: #d9d9d9;
    color: #222222;
    font-size: 19px;
    line-height: 26px;
    text-align: center;
    cursor: pointer;
}

.lerp-worksheet-toolbar-button:hover,
.lerp-worksheet-toolbar-button:focus {
    background: #cfcfcf;
    color: #cb982b;
}

/**
 * Toolbar separator.
 */
.lerp-worksheet-toolbar-separator {
    width: 1px;
    height: 24px;
    margin: 0 5px;
    background: #d0d0d0;
}

/**
 * Toolbar selects.
 *
 * Keep these compact while still readable.
 */
.lerp-worksheet-toolbar-select {
    height: 28px;
    min-width: 62px;
    border: 0;
    background: transparent;
    color: #222222;
    font-size: 13px;
    outline: none;
}

/**
 * Color input wrapper.
 */
.lerp-worksheet-color-wrap {
    position: relative;
    width: 28px;
    height: 26px;
    margin: 0;
    border-radius: 4px;
    background: #d9d9d9;
    color: #222222;
    font-size: 19px;
    line-height: 26px;
    text-align: center;
    cursor: pointer;
}

.lerp-worksheet-color-wrap:hover {
    background: #cfcfcf;
    color: #cb982b;
}

.lerp-worksheet-color-input {
    position: absolute;
    inset: 0;
    width: 28px;
    height: 26px;
    opacity: 0;
    cursor: pointer;
}

/**
 * Scroll area.
 *
 * This is the worksheet viewport.
 *
 * tableWidth/tableHeight from JS are applied directly to this element.
 * - Horizontal scrolling is always available.
 * - Vertical scrolling becomes active when tableHeight is set.
 */
.lerp-worksheet-scroll {
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    overflow-y: visible;
    scrollbar-width: thin;
    scrollbar-color: #cb982b transparent;
    position: relative;
}

.lerp-worksheet-scroll::-webkit-scrollbar {
    width: 7px;
    height: 7px;
}

.lerp-worksheet-scroll::-webkit-scrollbar-thumb {
    background: #cb982b;
}

/**
 * Worksheet table.
 *
 * Width is controlled by JavaScript after responsive sizing is calculated.
 * Do not force width: 0 here anymore, because that can cause unnecessary
 * horizontal scrollbar behavior after column scaling.
 */
.lerp-worksheet-table {
    width: auto;
    border-collapse: collapse;
    table-layout: fixed;
    background: #ffffff;
}

/**
 * Column headers.
 *
 * More compact worksheet density.
 */
.lerp-worksheet-table thead th {
    position: sticky;
    top: 0;
    z-index: 3;
    width: 105px !important;
    min-width: 105px !important;
    max-width: 105px !important;
    height: 28px;
    border: 1px solid #cb982b;
    background: #ecb627;
    color: #000000;
    font-size: 13px;
    font-weight: normal;
    text-align: center;
    box-sizing: border-box;
}

/**
 * Top-left corner cell.
 */
.lerp-worksheet-table .lerp-worksheet-corner-cell {
    left: 0;
    z-index: 4;
    width: 55px !important;
    min-width: 55px !important;
    max-width: 55px !important;
}

/**
 * Row header.
 */
.lerp-worksheet-row-header {
    position: sticky;
    left: 0;
    z-index: 2;
    width: 55px !important;
    min-width: 55px !important;
    max-width: 55px !important;
    height: 24px;
    border: 1px solid #cb982b;
    background: #f8f8f8;
    color: #111111;
    font-size: 13px;
    font-weight: normal;
    text-align: center;
    box-sizing: border-box;
}

/**
 * Editable cells.
 *
 * Compact cell size so more worksheet content is visible.
 */
.lerp-worksheet-table tbody td {
    width: 105px !important;
    min-width: 105px !important;
    max-width: 105px !important;
    height: 24px;
    padding: 1px 4px;
    border: 1px solid #cb982b;
    background: #ffffff;
    color: #111111;
    font-family: Arial, sans-serif;
    font-size: 12px;
    line-height: 16px;
    white-space: nowrap;
    overflow: hidden;
    outline: none;
    vertical-align: middle;
    box-sizing: border-box;
}

.lerp-worksheet-table tbody td:focus {
    box-shadow: inset 0 0 0 2px #010101;
}

/**
 * Selected cell range.
 *
 * Softer selection style:
 * - Light gold background shows selected cells clearly.
 * - Very light inner border avoids the heavy black grid look.
 * - The active/focused cell still keeps a stronger border from the focus rule.
 */
.lerp-worksheet-cell-selected {
    background: rgba(203, 152, 43, 0.10) !important;
    box-shadow: inset 0 0 0 1px rgba(1, 1, 1, 0.22);
}

/**
 * Editing state.
 *
 * A selected cell is only editable after double click, F2, or direct typing.
 */
.lerp-worksheet-cell-editing {
    background: #ffffff !important;
    box-shadow: inset 0 0 0 2px #010101 !important;
    cursor: text;
    user-select: text;
}

/**
 * Excel-like fill handle.
 *
 * Small black square shown at the bottom-right of the selected cell/range.
 */
.lerp-worksheet-fill-handle {
    position: absolute;
    width: 7px;
    height: 7px;
    border: 1px solid #ffffff;
    background: #010101;
    box-sizing: border-box;
    z-index: 20;
    cursor: crosshair;
}

/**
 * Fill-dragging state.
 */
.lerp-worksheet-fill-dragging {
    cursor: crosshair;
}

/**
 * Target cells while dragging fill handle.
 *
 * Slightly softer than before so large fill ranges do not look too heavy.
 */
.lerp-worksheet-fill-preview {
    background: rgba(203, 152, 43, 0.14) !important;
    box-shadow: inset 0 0 0 1px rgba(1, 1, 1, 0.25);
}

/* ==========================================================================
   LERP Worksheet freeze headers
   ========================================================================== */

/**
 * Frozen column header.
 *
 * Works properly when the worksheet scroll container has vertical scrolling
 * through tableHeight.
 */
.lerp-worksheet-freeze-column-header .lerp-worksheet-table thead th {
    position: sticky;
    top: 0;
    z-index: 30;
}

/**
 * Frozen row header.
 *
 * Works when the worksheet scroll container has horizontal scrolling.
 */
.lerp-worksheet-freeze-row-header .lerp-worksheet-row-header {
    position: sticky;
    left: 0;
    z-index: 25;
}

/**
 * Top-left corner cell must stay above both sticky header areas.
 */
.lerp-worksheet-freeze-both-headers .lerp-worksheet-corner-cell {
    position: sticky;
    top: 0;
    left: 0;
    z-index: 40;
}

/**
 * If freezeColumnHeader is disabled, do not keep column headers sticky.
 */
.lerp-worksheet:not(.lerp-worksheet-freeze-column-header) .lerp-worksheet-table thead th {
    position: static !important;
    top: auto !important;
}

/**
 * If freezeRowHeader is disabled, do not keep row headers sticky.
 */
.lerp-worksheet:not(.lerp-worksheet-freeze-row-header) .lerp-worksheet-row-header {
    position: static !important;
    left: auto !important;
}

/**
 * Solid backgrounds prevent cells from visually passing under frozen headers.
 */
.lerp-worksheet-freeze-row-header .lerp-worksheet-row-header {
    background: #f8f8f8;
}

.lerp-worksheet-freeze-column-header .lerp-worksheet-column-header,
.lerp-worksheet-freeze-column-header .lerp-worksheet-corner-cell {
    background: #ecb627;
}

/**
 * Selected row/column header state.
 *
 * Used when user selects a full row, full column, multiple rows/columns,
 * or the entire worksheet.
 */
.lerp-worksheet-header-selected {
    background: #c99a25 !important;
    color: #000000 !important;
}

/**
 * Filter row under column headers.
 */
.lerp-worksheet-filter-row th {
    position: sticky;
    top: 28px;
    z-index: 3;
    height: 28px;
    padding: 0;
    border: 1px solid #cb982b;
    background: #ecb627;
    box-sizing: border-box;
}

/**
 * Old two-row filter layout should stay hidden/unused.
 *
 * This is kept as a safety rule in case old markup exists during cache refresh.
 */
.lerp-worksheet-filter-row {
    display: none !important;
}

/**
 * Top-left filter row blank cell.
 */
.lerp-worksheet-filter-corner-cell {
    left: 0;
    z-index: 4;
    width: 55px !important;
    min-width: 55px !important;
    max-width: 55px !important;
}

/**
 * Filter icon cell.
 */
.lerp-worksheet-filter-cell {
    text-align: right;
}

/**
 * Filter icon button inside main column header.
 */
.lerp-worksheet-filter-button {
    width: 22px;
    height: 22px;
    padding: 0;
    border: 0;
    background: transparent;
    color: #777777;
    font-size: 17px;
    line-height: 22px;
    cursor: pointer !important;
    opacity: 0.85;
}

.lerp-worksheet-filter-button:hover,
.lerp-worksheet-filter-button:focus {
    color: #010101;
    opacity: 1;
    outline: none;
}

/**
 * Active filter icon.
 *
 * Uses a stronger blue so filtered columns are clearly visible against
 * the gold worksheet header.
 */
.lerp-worksheet-filter-button.is-active {
    color: #0d6efd !important;
    opacity: 1;
    font-weight: bold;
}

/**
 * Keep active filter color visible even on hover/focus.
 */
.lerp-worksheet-filter-button.is-active:hover,
.lerp-worksheet-filter-button.is-active:focus {
    color: #0d6efd !important;
    opacity: 1;
}

/**
 * Filter dropdown.
 */
.lerp-worksheet-filter-dropdown {
    position: absolute;
    z-index: 99999;
    width: 320px;
    max-height: 300px;
    border: 1px solid #9bbcff;
    background: #ffffff;
    box-shadow: 2px 3px 7px rgba(1, 1, 1, 0.20);
    font-family: Arial, sans-serif;
    font-size: 14px;
}

/**
 * Filter search input.
 */
.lerp-worksheet-filter-search {
    width: 100%;
    height: 34px;
    padding: 6px 28px 6px 8px;
    border: 0;
    border-bottom: 1px solid #d6d6d6;
    outline: none;
    font-family: Arial, sans-serif;
    font-size: 14px;
}

/**
 * Filter value list.
 */
.lerp-worksheet-filter-list {
    max-height: 245px;
    overflow-y: auto;
}

/**
 * Filter item.
 */
.lerp-worksheet-filter-item {
    position: relative;
    display: block;
    width: 100%;
    min-height: 30px;
    padding: 6px 38px 6px 10px;
    border: 0;
    background: #ffffff;
    color: #010101;
    font-family: Arial, sans-serif;
    font-size: 14px;
    line-height: 18px;
    text-align: left;
    cursor: pointer;
}

.lerp-worksheet-filter-item:hover,
.lerp-worksheet-filter-item:focus,
.lerp-worksheet-filter-item.is-selected {
    background: #2b8ff0;
    color: #ffffff;
    outline: none;
}

/**
 * Tick mark for selected filter items.
 */
.lerp-worksheet-filter-item-tick {
    position: absolute;
    top: 4px;
    right: 12px;
    color: #ffffff;
    font-size: 22px;
    line-height: 22px;
}

/**
 * Empty filter list message.
 */
.lerp-worksheet-filter-empty {
    padding: 12px;
    color: #666666;
    font-size: 13px;
}

/**
 * Worksheet header cursor behavior.
 *
 * Normal row/column headers should not show a pointer cursor.
 * They are selectable, but visually they should behave like Excel headers,
 * where the cursor stays normal unless the user is on a resize handle.
 */
.lerp-worksheet-column-header,
.lerp-worksheet-row-header,
.lerp-worksheet-corner-cell,
.lerp-worksheet-table thead th {
    cursor: default !important;
}

/**
 * Header inner layout.
 */
.lerp-worksheet-column-header-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 4px;
    width: 100%;
    height: 100%;
    min-width: 0;
    box-sizing: border-box;
}

/**
 * Left side of header: label + sort indicator.
 */
.lerp-worksheet-column-header-text {
    display: flex;
    align-items: center;
    min-width: 0;
    overflow: hidden;
}

/**
 * Column resize handle.
 *
 * A small invisible drag zone on the right side of each column header.
 */
.lerp-worksheet-column-header {
    position: sticky;
}

/**
 * Header label.
 */
.lerp-worksheet-column-header-label {
    display: inline-block;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    vertical-align: middle;
}

/**
 * Right side of header: filter icon and future header actions.
 */
.lerp-worksheet-column-header-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    flex: 0 0 auto;
    height: 100%;
}

/**
 * Sort indicator shown beside sorted column headers.
 *
 * Examples:
 * ▲1
 * ▼2
 */
.lerp-worksheet-sort-indicator {
    display: inline-block;
    flex: 0 0 auto;
    margin-left: 4px;
    color: #010101;
    font-size: 11px;
    font-weight: bold;
    line-height: 1;
    vertical-align: middle;
}

.lerp-worksheet-column-resize-handle {
    position: absolute;
    top: 0;
    right: -3px;
    width: 7px;
    height: 100%;
    cursor: col-resize !important;
    z-index: 8;
}

/**
 * Show a subtle resize indicator on hover.
 */
.lerp-worksheet-column-resize-handle:hover {
    background: rgba(1, 1, 1, 0.08);
}

/**
 * Cursor while actively resizing.
 */
.lerp-worksheet-column-resizing,
.lerp-worksheet-column-resizing * {
    cursor: col-resize !important;
    user-select: none !important;
}

/**
 * Active column being resized.
 *
 * Uses the same gold color as the normal worksheet gridlines.
 * Slightly thicker than the normal 1px gridline so users can see
 * which column is being resized, without the heavy black dotted line.
 */
.lerp-worksheet-column-resizing-active {
    border-right: 2px solid #cb982b !important;
}

/**
 * LERP Worksheet context menu.
 *
 * Designed to look close to spreadsheet context menus while staying scoped
 * to our internal worksheet implementation.
 */
.lerp-worksheet-context-menu {
    position: absolute;
    z-index: 99999;
    min-width: 280px;
    padding: 8px 0;
    border: 1px solid #d0d0d0;
    background: #ffffff;
    box-shadow: 2px 3px 7px rgba(1, 1, 1, 0.20);
    font-family: Arial, sans-serif;
    font-size: 14px;
    color: #444444;
}

.lerp-worksheet-context-menu-item {
    position: relative;
    display: block;
    width: 100%;
    min-height: 40px;
    padding: 9px 22px;
    border: 0;
    background: transparent;
    color: #444444;
    font-family: Arial, sans-serif;
    font-size: 14px;
    line-height: 20px;
    text-align: left;
    cursor: pointer;
}

.lerp-worksheet-context-menu-item:hover,
.lerp-worksheet-context-menu-item:focus {
    background: #eeeeee;
    outline: none;
}

.lerp-worksheet-context-menu-item.is-disabled,
.lerp-worksheet-context-menu-item:disabled {
    color: #aaaaaa;
    cursor: not-allowed;
}

.lerp-worksheet-context-menu-shortcut {
    float: right;
    margin-left: 24px;
    color: #666666;
    font-size: 12px;
}

.lerp-worksheet-context-menu-separator {
    height: 1px;
    margin: 6px 0;
    background: #d6d6d6;
}

/**
 * Hidden worksheet columns.
 *
 * Used by refactored screens that need hidden data columns such as IDs.
 */
.lerp-worksheet-hidden-column {
    display: none !important;
}

/**
 * Read-only worksheet cells.
 */
.lerp-worksheet-table tbody td.readonly {
    color: #666666;
    background-color: #f7f7f7;
}

/**
 * Action cells are usually narrow button columns.
 */
.lerp-worksheet-action-cell {
    text-align: center !important;
    padding: 1px 2px !important;
}

/**
 * Client list worksheet should allow long text to be readable.
 */
.lerp-client-list-grid .lerp-worksheet-table tbody td {
    white-space: nowrap;
    text-overflow: ellipsis;
}

/**
 * Default worksheet cell cursor.
 *
 * Cells should not show the text cursor simply because the mouse is hovering
 * over cell text. The cell becomes text-editable only after double click,
 * F2, or direct typing while selected.
 */
.lerp-worksheet-table tbody td,
.lerp-worksheet-table tbody td.lerp-worksheet-cell {
    cursor: default !important;
}

/**
 * Read-only cells should also keep default cursor.
 */
.lerp-worksheet-table tbody td.readonly {
    cursor: default !important;
}

/**
 * Action/button cells should not show text cursor.
 */
.lerp-worksheet-action-cell {
    cursor: default !important;
}

/**
 * Actual buttons inside action cells keep pointer cursor.
 */
.lerp-worksheet-action-cell button,
.lerp-worksheet-table tbody td button {
    cursor: pointer !important;
}

/**
 * Editing state.
 *
 * Only when a cell is actually editable should the cursor become a text cursor.
 */
.lerp-worksheet-cell-editing {
    background: #ffffff !important;
    box-shadow: inset 0 0 0 2px #010101 !important;
    cursor: text !important;
    user-select: text;
}

/**
 * Any content inside an editing cell should also show text cursor.
 */
.lerp-worksheet-cell-editing * {
    cursor: text !important;
}

/**
 * Default worksheet cell cursor.
 *
 * Cells should not show the text cursor simply because the mouse is hovering
 * over cell text. The cell becomes text-editable only after double click,
 * F2, or direct typing while selected.
 */
.lerp-worksheet-table tbody td,
.lerp-worksheet-table tbody td.lerp-worksheet-cell {
    cursor: default !important;
}

/**
 * Read-only cells should also keep default cursor.
 */
.lerp-worksheet-table tbody td.readonly {
    cursor: default !important;
}

/**
 * Action/button cells should not show text cursor.
 */
.lerp-worksheet-action-cell {
    cursor: default !important;
}

/**
 * Actual buttons inside action cells keep pointer cursor.
 */
.lerp-worksheet-action-cell button,
.lerp-worksheet-table tbody td button {
    cursor: pointer !important;
}

/**
 * Editing state.
 *
 * This selector is intentionally more specific than:
 * .lerp-worksheet-table tbody td.lerp-worksheet-cell
 *
 * Without this stronger selector, the normal default cursor rule can override
 * the edit-mode text cursor.
 */
.lerp-worksheet-table tbody td.lerp-worksheet-cell-editing,
.lerp-worksheet-table tbody td.lerp-worksheet-cell.lerp-worksheet-cell-editing {
    background: #ffffff !important;
    box-shadow: inset 0 0 0 2px #010101 !important;
    cursor: text !important;
    user-select: text;
}

/**
 * Any content inside an editing cell should also show text cursor.
 */
.lerp-worksheet-table tbody td.lerp-worksheet-cell-editing *,
.lerp-worksheet-table tbody td.lerp-worksheet-cell.lerp-worksheet-cell-editing * {
    cursor: text !important;
}

/**
 * Dropdown display cells.
 *
 * LERP Worksheet dropdown support is currently display-only:
 * - raw stored value remains in the data array
 * - display label is shown in the cell
 */
.lerp-worksheet-dropdown-cell {
    color: #6c757d;
}

/**
 * Keep dropdown display text aligned with normal worksheet cell behavior.
 */
.lerp-worksheet-table tbody td.lerp-worksheet-dropdown-cell {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ==========================================================================
   LERP Worksheet frozen data columns
   ========================================================================== */

/**
 * Frozen body/header data columns.
 *
 * Why this exists:
 * - Native table borders on position: sticky cells can disappear while scrolling,
 *   especially when border-collapse is used.
 * - These cells draw their own reliable gridlines using inset box-shadow.
 */
.lerp-worksheet-frozen-column {
    background-clip: padding-box;
}

/**
 * Frozen header data columns must keep the same header background and visible gridlines.
 */
.lerp-worksheet-frozen-column-header {
    background: #ecb627 !important;
    border-color: transparent !important;

    /**
     * Draw reliable header gridlines independent of table border-collapse.
     */
    box-shadow:
        inset 1px 0 0 #cb982b,
        inset 0 1px 0 #cb982b,
        inset 0 -1px 0 #cb982b,
        inset -1px 0 0 #cb982b !important;
}

/**
 * Frozen body data columns must stay solid while normal columns scroll behind.
 */
.lerp-worksheet-frozen-column-cell {
    background: #ffffff !important;
    border-color: transparent !important;

    /**
     * Draw reliable body gridlines independent of table border-collapse.
     */
    box-shadow:
        inset 1px 0 0 #cb982b,
        inset 0 1px 0 #cb982b,
        inset 0 -1px 0 #cb982b,
        inset -1px 0 0 #cb982b !important;
}

/**
 * If a frozen cell is readonly, keep readonly background.
 */
.lerp-worksheet-frozen-column-cell.readonly {
    background: #f7f7f7 !important;
}

/**
 * If a frozen dropdown cell has display text styling, keep its background solid.
 */
.lerp-worksheet-frozen-column-cell.lerp-worksheet-dropdown-cell {
    background: #ffffff !important;
}

/**
 * If a frozen selected cell is selected, preserve selected background and selection border.
 */
.lerp-worksheet-frozen-column-cell.lerp-worksheet-cell-selected {
    background: rgba(203, 152, 43, 0.10) !important;
    box-shadow:
        inset 1px 0 0 #cb982b,
        inset 0 1px 0 #cb982b,
        inset 0 -1px 0 #cb982b,
        inset -1px 0 0 #cb982b,
        inset 0 0 0 1px rgba(1, 1, 1, 0.22) !important;
}

/**
 * Active/focused frozen cell must keep the strong black active-cell border.
 */
.lerp-worksheet-frozen-column-cell:focus {
    box-shadow:
        inset 1px 0 0 #cb982b,
        inset 0 1px 0 #cb982b,
        inset 0 -1px 0 #cb982b,
        inset -1px 0 0 #cb982b,
        inset 0 0 0 2px #010101 !important;
}

/**
 * Add a stronger divider after the last frozen column.
 *
 * This visually separates frozen columns from horizontally scrolling columns.
 */
.lerp-worksheet-last-frozen-column {
    box-shadow:
        inset 1px 0 0 #cb982b,
        inset 0 1px 0 #cb982b,
        inset 0 -1px 0 #cb982b,
        inset -2px 0 0 #cb982b !important;
}

/**
 * If the last frozen column is selected/focused, keep both the divider and active border.
 */
.lerp-worksheet-last-frozen-column.lerp-worksheet-cell-selected {
    box-shadow:
        inset 1px 0 0 #cb982b,
        inset 0 1px 0 #cb982b,
        inset 0 -1px 0 #cb982b,
        inset -2px 0 0 #cb982b,
        inset 0 0 0 1px rgba(1, 1, 1, 0.22) !important;
}

.lerp-worksheet-last-frozen-column:focus {
    box-shadow:
        inset 1px 0 0 #cb982b,
        inset 0 1px 0 #cb982b,
        inset 0 -1px 0 #cb982b,
        inset -2px 0 0 #cb982b,
        inset 0 0 0 2px #010101 !important;
}

/**
 * Keep frozen column content clipped neatly.
 */
.lerp-worksheet-frozen-column-cell,
.lerp-worksheet-frozen-column-header {
    overflow: hidden;
}

/* ==========================================================================
   LERP Worksheet row-header sticky border and corner masking fixes
   ========================================================================== */

/**
 * Frozen row header reliable borders.
 *
 * Native table borders can disappear when sticky row headers overlap scrolling
 * cells. Draw row header gridlines using inset shadows instead.
 */
.lerp-worksheet-freeze-row-header .lerp-worksheet-row-header-cell {
    background: #f8f8f8 !important;
    border-color: transparent !important;
    box-shadow:
        inset 1px 0 0 #cb982b,
        inset 0 1px 0 #cb982b,
        inset 0 -1px 0 #cb982b,
        inset -1px 0 0 #cb982b !important;
    background-clip: padding-box;
}

/**
 * Selected row header should keep selected look and still show reliable borders.
 */
.lerp-worksheet-freeze-row-header .lerp-worksheet-row-header-cell.lerp-worksheet-header-selected {
    background: #c99a25 !important;
    color: #000000 !important;
    border-color: transparent !important;
    box-shadow:
        inset 1px 0 0 #cb982b,
        inset 0 1px 0 #cb982b,
        inset 0 -1px 0 #cb982b,
        inset -1px 0 0 #cb982b !important;
}

/**
 * Top-left corner mask.
 *
 * This cell sits where the row header and column header intersect.
 * It must hide/mask horizontally scrolling column headers behind it.
 */
.lerp-worksheet-corner-mask {
    background: #ecb627 !important;
    border-color: transparent !important;
    background-clip: padding-box;
    overflow: hidden !important;

    /**
     * Reliable corner gridlines independent of border-collapse behavior.
     */
    box-shadow:
        inset 1px 0 0 #cb982b,
        inset 0 1px 0 #cb982b,
        inset 0 -1px 0 #cb982b,
        inset -1px 0 0 #cb982b !important;
}

/**
 * When both headers are frozen, the top-left corner must be above:
 * - column headers
 * - row headers
 * - frozen data columns
 * - normal scrolling cells
 */
.lerp-worksheet-freeze-both-headers .lerp-worksheet-corner-mask {
    position: sticky !important;
    top: 0 !important;
    left: 0 !important;
    z-index: 80 !important;
}

/**
 * Add a pseudo mask layer over the top-left corner.
 *
 * This prevents text/icons from scrolled column headers showing through the
 * corner area during horizontal scrolling.
 */
.lerp-worksheet-corner-mask::after {
    content: "";
    position: absolute;
    inset: 0;
    z-index: 1;
    pointer-events: none;
    background: #ecb627;
}

/**
 * Keep top-left corner content above its masking layer if content is ever added.
 */
.lerp-worksheet-corner-mask > * {
    position: relative;
    z-index: 2;
}

/**
 * Make sure normal column headers stay below the top-left corner mask.
 */
.lerp-worksheet-freeze-column-header .lerp-worksheet-column-header {
    z-index: 30;
}

/**
 * Frozen data column headers should still stay below the top-left corner mask.
 */
.lerp-worksheet-freeze-column-header .lerp-worksheet-frozen-column-header {
    z-index: 36 !important;
}

/**
 * Row headers should stay below top-left corner but above normal body cells.
 */
.lerp-worksheet-freeze-row-header .lerp-worksheet-row-header-cell {
    z-index: 35 !important;
}

/**
 * Masked display cells.
 *
 * Example:
 * raw value: 2000000.00
 * display:   2,000,000.00
 */
.lerp-worksheet-masked-cell {
    color: #6c757d;
}

/**
 * Masked values are usually numeric and should stay on one line.
 */
.lerp-worksheet-table tbody td.lerp-worksheet-masked-cell {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/**
 * LERP Worksheet dropdown editor.
 */
.lerp-worksheet-dropdown-editor {
    width: 100%;
    height: 24px;
    min-height: 24px;
    padding: 2px 6px;
    border: 0;
    border-radius: 0;
    font-size: 13px;
    line-height: 1.2;
    box-shadow: none;
    background: #ffffff;
}

/**
 * LERP Worksheet calendar display cell.
 */
.lerp-worksheet-calendar-cell {
    position: relative;
    padding-right: 24px !important;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.jcalendar {
    z-index: 99999 !important;
}

/**
 * Dropdown display cell.
 */
.lerp-worksheet-dropdown-cell {
    position: relative;
    padding-right: 22px !important;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.lerp-worksheet-dropdown-value {
    display: inline-block;
    max-width: calc(100% - 18px);
    overflow: hidden;
    text-overflow: ellipsis;
    vertical-align: middle;
}

.lerp-worksheet-dropdown-icon {
    position: absolute;
    right: 3px;
    top: 50%;
    transform: translateY(-50%);
    color: #6c757d;
    font-size: 18px;
    pointer-events: none;
}

/**
 * Dropdown popup.
 *
 * Appended to document.body so it is not clipped by worksheet scroll containers
 * or Bootstrap modal internals.
 */
.lerp-worksheet-dropdown-popup {
    position: fixed;
    z-index: 99999;
    max-height: 220px;
    overflow-y: auto;
    border: 1px solid #cb982b;
    background: #ffffff;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.16);
    font-size: 13px;
}

.lerp-worksheet-dropdown-option {
    display: block;
    width: 100%;
    padding: 6px 9px;
    border: 0;
    border-bottom: 1px solid #eeeeee;
    background: #ffffff;
    color: #212529;
    text-align: left;
    cursor: pointer;
}

.lerp-worksheet-dropdown-option:hover,
.lerp-worksheet-dropdown-option.is-selected {
    background: #fff4d8;
}

.lerp-worksheet-dropdown-empty {
    padding: 7px 9px;
    color: #777777;
    font-style: italic;
}

/**
 * LERP Worksheet dropdown editor.
 */
.lerp-worksheet-dropdown-editor {
    width: 100%;
    height: 24px;
    min-height: 24px;
    padding: 2px 6px;
    border: 0;
    border-radius: 0;
    font-size: 13px;
    line-height: 1.2;
    box-shadow: none;
    background: #ffffff;
}

/**
 * LERP Worksheet calendar display cell.
 */
.lerp-worksheet-calendar-cell {
    position: relative;
    padding-right: 24px !important;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.lerp-worksheet-calendar-value {
    display: inline-block;
    max-width: calc(100% - 20px);
    overflow: hidden;
    text-overflow: ellipsis;
    vertical-align: middle;
}

.lerp-worksheet-calendar-icon {
    position: absolute;
    right: 4px;
    top: 50%;
    transform: translateY(-50%);
    color: #6c757d;
    font-size: 16px;
    pointer-events: none;
}

/**
 * Calendar editor used only while editing the cell.
 */
.lerp-worksheet-calendar-editor {
    width: 100%;
    height: 24px;
    min-height: 24px;
    padding: 2px 6px;
    border: 0;
    border-radius: 0;
    font-size: 13px;
    line-height: 1.2;
    box-shadow: none;
}

/**
 * LERP Worksheet calendar popup.
 *
 * Appended to document.body so it is not clipped by worksheet scroll containers
 * or Bootstrap modal internals.
 */
.lerp-worksheet-calendar-popup {
    position: fixed;
    z-index: 99999;
    width: 270px;
    border: 1px solid #d8d8d8;
    background: #ffffff;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.18);
    font-size: 13px;
    color: #212529;
}

.lerp-worksheet-calendar-popup-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    min-height: 42px;
    padding: 6px 12px;
    border-bottom: 1px solid #eeeeee;
}

.lerp-worksheet-calendar-popup-action {
    border: 0;
    background: transparent;
    color: #007bff;
    font-weight: 700;
    cursor: pointer;
}

.lerp-worksheet-calendar-popup-nav {
    display: grid;
    grid-template-columns: 38px 1fr 38px;
    align-items: center;
    padding: 10px 12px 6px 12px;
}

.lerp-worksheet-calendar-nav-button {
    width: 32px;
    height: 32px;
    border: 0;
    background: transparent;
    color: #010101;
    cursor: pointer;
}

.lerp-worksheet-calendar-month-label {
    text-align: center;
    font-weight: 700;
    font-size: 15px;
}

.lerp-worksheet-calendar-weekdays {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    padding: 4px 12px;
    background: #fafafa;
}

.lerp-worksheet-calendar-weekday {
    text-align: center;
    font-weight: 700;
    color: #333333;
    padding: 5px 0;
}

.lerp-worksheet-calendar-days {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 2px;
    padding: 8px 12px 12px 12px;
}

.lerp-worksheet-calendar-day {
    min-height: 30px;
    border: 0;
    background: #ffffff;
    color: #333333;
    cursor: pointer;
}

.lerp-worksheet-calendar-day:hover {
    background: #fff4d8;
}

.lerp-worksheet-calendar-day.is-outside-month {
    color: #bbbbbb;
}

.lerp-worksheet-calendar-day.is-today {
    box-shadow: inset 0 0 0 1px #cb982b;
}

.lerp-worksheet-calendar-day.is-selected {
    background: #ecb627;
    color: #010101;
    font-weight: 700;
}

/**
 * Invalid fill preview.
 *
 * Used when fill-handle drag crosses readonly cells or incompatible data types.
 * The operation will be ignored when mouse is released.
 */
.lerp-worksheet-fill-preview-invalid {
    background: rgba(220, 53, 69, 0.12) !important;
    box-shadow: inset 0 0 0 1px rgba(220, 53, 69, 0.75) !important;
}

/**
 * Readonly dropdown cells.
 *
 * These still use dropdown display-value mapping, but they must not show the
 * dropdown arrow because the user cannot edit them.
 */
.lerp-worksheet-dropdown-cell.lerp-worksheet-dropdown-readonly {
    padding-right: 4px !important;
}

.lerp-worksheet-dropdown-cell.lerp-worksheet-dropdown-readonly .lerp-worksheet-dropdown-value {
    max-width: 100%;
}
