/* ==========================================================================
   Ritza ERP - Professional Spreadsheet Grid Engine Styles
   ========================================================================== */

.erp-grid-container {
    position: relative;
    width: 100%;
    background-color: #ffffff;
    border: 1px solid #cfd8dc;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
    overflow: hidden;
    user-select: none;
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
}

/* Grid Toolbar */
.erp-grid-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 16px;
    background: #f8fafc;
    border-bottom: 1px solid #e2e8f0;
    font-size: 0.85rem;
}

/* Main Table Container */
.erp-grid-table-wrapper {
    width: 100%;
    max-height: 600px;
    overflow: auto;
    position: relative;
}

/* Grid Table */
.table-erp-grid {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 0.825rem;
    color: #1e293b;
    background: #ffffff;
    margin-bottom: 0;
}

.table-erp-grid th {
    position: sticky;
    top: 0;
    z-index: 10;
    background-color: #f1f5f9;
    color: #475569;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    font-size: 0.725rem;
    padding: 8px 10px;
    border-bottom: 2px solid #cbd5e1;
    border-right: 1px solid #e2e8f0;
    white-space: nowrap;
}

.table-erp-grid td {
    padding: 0;
    border-bottom: 1px solid #e2e8f0;
    border-right: 1px solid #e2e8f0;
    height: 36px;
    vertical-align: middle;
    position: relative;
    background: #ffffff;
}

/* Row states */
.table-erp-grid tr:hover td {
    background-color: #f8fafc;
}

.table-erp-grid tr.erp-grid-selected td {
    background-color: #e0f2fe !important;
}

.table-erp-grid tr.erp-grid-row-deleted td {
    opacity: 0.4;
    text-decoration: line-through;
    background-color: #fee2e2 !important;
}

/* Cell Editors */
.table-erp-grid .grid-cell {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    padding: 4px 8px;
    box-sizing: border-box;
    cursor: cell;
    position: relative;
}

.table-erp-grid .grid-cell-input {
    width: 100%;
    height: 32px;
    border: none;
    outline: none;
    background: transparent;
    font-family: inherit;
    font-size: 0.825rem;
    color: #0f172a;
    padding: 2px 6px;
    border-radius: 3px;
    box-sizing: border-box;
}

/* Focused Active Cell Indicator */
.table-erp-grid td.cell-active {
    outline: 2px solid #2563eb !important;
    outline-offset: -2px;
    z-index: 5;
    background-color: #eff6ff !important;
}

.table-erp-grid td.cell-active .grid-cell-input {
    background-color: #ffffff;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

/* Dirty Marker for unsaved changes */
.table-erp-grid td.grid-dirty::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 0;
    height: 0;
    border-top: 6px solid #f59e0b;
    border-right: 6px solid transparent;
    z-index: 6;
}

/* Auto-complete Dropdown Popover */
.erp-grid-autocomplete-menu {
    position: absolute;
    z-index: 1050;
    background: #ffffff;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.15), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
    max-height: 240px;
    overflow-y: auto;
    width: 280px;
    font-size: 0.825rem;
}

.erp-grid-autocomplete-item {
    padding: 8px 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid #f1f5f9;
    color: #334155;
    transition: background-color 0.15s ease;
}

.erp-grid-autocomplete-item:last-child {
    border-bottom: none;
}

.erp-grid-autocomplete-item:hover,
.erp-grid-autocomplete-item.active {
    background-color: #2563eb;
    color: #ffffff;
}

.erp-grid-autocomplete-item.active .text-muted,
.erp-grid-autocomplete-item:hover .text-muted {
    color: #e2e8f0 !important;
}

.erp-grid-autocomplete-create {
    background-color: #f0fdf4;
    color: #166534;
    font-weight: 600;
}

.erp-grid-autocomplete-create:hover,
.erp-grid-autocomplete-create.active {
    background-color: #16a34a;
    color: #ffffff;
}

/* Context Menu */
.erp-grid-context-menu {
    position: fixed;
    z-index: 2000;
    background: #ffffff;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.15);
    padding: 4px 0;
    min-width: 180px;
    font-size: 0.825rem;
}

.erp-grid-context-item {
    padding: 6px 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    color: #334155;
    transition: background 0.1s ease;
}

.erp-grid-context-item:hover {
    background: #f1f5f9;
    color: #0f172a;
}

.erp-grid-context-item.text-danger:hover {
    background: #fef2f2;
    color: #dc2626;
}

.erp-grid-context-divider {
    height: 1px;
    background: #e2e8f0;
    margin: 4px 0;
}

/* Selection Handle / Drag Fill */
.table-erp-grid td.cell-active::after {
    content: '';
    position: absolute;
    bottom: -3px;
    right: -3px;
    width: 6px;
    height: 6px;
    background-color: #2563eb;
    border: 1px solid #ffffff;
    cursor: crosshair;
    z-index: 7;
}