/* D365 Editable Grid Styles - for input/entry grids */

.d365-editable-grid-container {
    font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 12px;
    border: 1px solid #e1e1e1;
    background: #fff;
}

.d365-editable-grid-toolbar {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-bottom: 1px solid #e1e1e1;
    background: #fafafa;
    height: 28px;
}

.d365-editable-grid-toolbar button {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    border: 1px solid transparent;
    background: transparent;
    color: #0078d4;
    font-size: 12px;
    cursor: pointer;
}

.d365-editable-grid-toolbar button:focus {
    outline: none;
    border-color: #0078d4;
    border-radius: 2px;
    background: #e8f4fd;
}

.d365-editable-grid-toolbar button i {
    font-size: 14px;
}

.d365-editable-grid-toolbar button:hover {
    background: #e8f4fd;
    border-radius: 2px;
}

.d365-editable-grid-toolbar button:disabled {
    color: #999;
    cursor: not-allowed;
}

.d365-editable-grid-toolbar button:disabled:hover {
    background: transparent;
}

.d365-editable-grid-toolbar .separator {
    width: 1px;
    height: 14px;
    background: #d0d0d0;
    margin: 0 2px;
}

.d365-editable-grid-toolbar select {
    padding: 0 4px;
    border: none;
    background: transparent;
    font-size: 12px;
    height: 20px;
    cursor: pointer;
    color: #333;
}

.d365-editable-grid-toolbar select:hover {
    background: #e8f4fd;
}

.d365-editable-grid-toolbar select:focus {
    outline: none;
    background: #e8f4fd;
}

.d365-editable-grid-toolbar span {
    font-size: 12px;
    color: #333;
}

/* Main Grid Table */
.d365-input-grid {
    width: 100%;
    border-collapse: collapse;
}

.d365-input-grid th {
    background: #f8f8f8;
    border: 1px solid #e1e1e1;
    padding: 4px 6px;
    text-align: left;
    font-weight: 600;
    font-size: 11px;
    color: #333;
    position: sticky;
    top: 0;
    z-index: 10;
    white-space: nowrap;
    height: 24px;
}

.d365-input-grid th .header-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 4px;
}

.d365-input-grid th .filter-icon {
    opacity: 0;
    cursor: pointer;
    color: #666;
    font-size: 10px;
}

.d365-input-grid th:hover .filter-icon {
    opacity: 1;
}

.d365-input-grid td {
    border: 1px solid #e1e1e1;
    padding: 0;
    height: 22px;
    vertical-align: middle;
}

.d365-input-grid tr.selected {
    background: #e6f2fb !important;
}

.d365-input-grid tr:hover {
    background: #f5f5f5;
}

.d365-input-grid tr.editing {
    background: #fff9e6;
}

/* Grid Cells */
.d365-grid-cell {
    padding: 1px 6px;
    height: 22px;
    display: flex;
    align-items: center;
}

.d365-grid-cell-checkbox {
    justify-content: center;
    width: 32px;
}

.d365-grid-cell input[type="text"],
.d365-grid-cell input[type="number"],
.d365-grid-cell input[type="date"] {
    width: 100%;
    border: none;
    background: transparent;
    padding: 1px 4px;
    font-size: 12px;
    outline: none;
    height: 20px;
}

.d365-grid-cell input:focus {
    background: #fff;
    box-shadow: inset 0 0 0 1px #0078d4;
}

.d365-grid-cell-editable {
    cursor: text;
}

.d365-grid-cell-editable:hover {
    background: #f0f0f0;
}

.d365-grid-cell-numeric {
    text-align: right;
    justify-content: flex-end;
}

.d365-grid-cell input[type="radio"],
.d365-grid-cell input[type="checkbox"] {
    width: 14px;
    height: 14px;
    margin: 0;
}

/* Select/Dropdown Styling */
.d365-grid-cell select,
.d365-input-grid select {
    width: 100%;
    border: none;
    background-color: transparent;
    padding: 1px 18px 1px 4px;
    font-size: 12px;
    outline: none;
    height: 20px;
    cursor: pointer;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    /* Use a thin chevron arrow - wider and lighter */
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath fill='none' stroke='%23999' stroke-width='1' stroke-linecap='round' stroke-linejoin='round' d='M1 1l4 4 4-4'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 5px center;
    background-size: 10px 6px;
}

.d365-grid-cell select:focus,
.d365-input-grid select:focus {
    background-color: #fff;
    box-shadow: inset 0 0 0 1px #0078d4;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath fill='none' stroke='%230078d4' stroke-width='1' stroke-linecap='round' stroke-linejoin='round' d='M1 1l4 4 4-4'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 5px center;
    background-size: 10px 6px;
}

.d365-grid-cell select:hover,
.d365-input-grid select:hover {
    background-color: #f5f5f5;
}

/* Fix select option styling */
.d365-grid-cell select option,
.d365-input-grid select option {
    background-color: #fff;
    color: #323130;
    padding: 4px 8px;
}

/* Hide native dropdown arrow in IE/Edge */
.d365-grid-cell select::-ms-expand,
.d365-input-grid select::-ms-expand {
    display: none;
}

/* Lookup Cell */
.d365-grid-lookup-cell {
    position: relative;
}

.d365-grid-lookup-input {
    display: flex;
    align-items: center;
    gap: 2px;
}

.d365-grid-lookup-input input {
    flex: 1;
}

.d365-grid-lookup-btn {
    padding: 0 8px;
    border: none;
    background: transparent;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
}

.d365-grid-lookup-btn:hover {
    color: #666;
}

.d365-grid-lookup-btn:focus {
    outline: none;
    box-shadow: inset 0 0 0 1px #0078d4;
}

.d365-grid-lookup-btn .dropdown-arrow {
    width: 0;
    height: 0;
    border-left: 4px solid transparent;
    border-right: 4px solid transparent;
    border-top: 4px solid #999;
}

.d365-grid-lookup-btn:hover .dropdown-arrow {
    border-top-color: #666;
}

.d365-grid-lookup-btn i {
    font-weight: 100;
}

.d365-grid-lookup-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    min-width: 300px;
    background: white;
    border: 1px solid #d0d0d0;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    z-index: 1000;
    max-height: 180px;
    overflow-y: auto;
}

.d365-grid-lookup-dropdown table {
    width: 100%;
    border-collapse: collapse;
}

.d365-grid-lookup-dropdown th {
    background: #f8f8f8;
    padding: 4px 8px;
    text-align: left;
    font-weight: 600;
    font-size: 11px;
    color: #666;
    border-bottom: 1px solid #e1e1e1;
    position: sticky;
    top: 0;
    height: 22px;
}

.d365-grid-lookup-dropdown td {
    padding: 4px 8px;
    border-bottom: 1px solid #f0f0f0;
    font-size: 12px;
    height: auto;
}

.d365-grid-lookup-dropdown tr:hover {
    background: #e6f2fb;
    cursor: pointer;
}

.d365-grid-lookup-dropdown tr.selected {
    background: #cce4f7;
}

/* Action buttons in grid */
.d365-grid-action-btn {
    padding: 1px 4px;
    border: none;
    background: transparent;
    cursor: pointer;
    color: #666;
    font-size: 12px;
}

.d365-grid-action-btn:hover {
    color: #0078d4;
}

.d365-grid-action-btn.delete:hover {
    color: #d13438;
}

/* Grid scroll container */
.d365-grid-scroll {
    overflow-x: auto;
    overflow-y: auto;
}

/* Disable browser autofill styling for grid controls */
.d365-grid-cell select:-webkit-autofill,
.d365-grid-cell input:-webkit-autofill,
.d365-input-grid select:-webkit-autofill,
.d365-input-grid input:-webkit-autofill {
    -webkit-box-shadow: 0 0 0 30px white inset !important;
    -webkit-text-fill-color: #323130 !important;
    background-color: transparent !important;
}

/* Hide datalist/autocomplete suggestions in grid */
.d365-grid-cell input::-webkit-calendar-picker-indicator,
.d365-input-grid input::-webkit-calendar-picker-indicator {
    display: none !important;
}

/* Prevent datalist dropdown from showing */
.d365-grid-cell input::-webkit-list-button,
.d365-input-grid input::-webkit-list-button {
    display: none !important;
}

/* Validation error styling */
.d365-grid-cell.validation-error {
    background-color: #fde7e9 !important;
}

.d365-grid-cell.validation-error input {
    color: #a4262c;
}

.d365-grid-cell.validation-error:hover {
    background-color: #fcd4d8 !important;
}

/* Input with validation state */
.d365-grid-cell input.invalid {
    background-color: #fde7e9;
    color: #a4262c;
}

.d365-grid-cell input.valid {
    background-color: #dff6dd;
}

/* Uppercase text transform for container numbers */
.d365-grid-cell input[style*="text-transform:uppercase"] {
    text-transform: uppercase;
}
