/* Shared styling for the choices (combo lookup) dialogs used by the RML report designer:
   ChoicesSourcePicker (search/browse) and ChoicesEditor (edit options).

   This is a plain stylesheet rather than a scoped .razor.css because both components share the
   same rml-ch-* class vocabulary; scoped CSS applies only within the component that owns the
   markup, so a shared scoped file would silently fail for one of them. */

.rml-ch-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.35);
    display: flex;
    align-items: center;
    justify-content: center;
    /* Stacking is handled by .kailo-modal-backdrop in site.css, which promotes the host tile so
       this fixed backdrop can escape the tile's stacking context. */
    z-index: 500300;
}

.rml-ch-dialog {
    width: 720px;
    max-width: 92vw;
    height: 540px;
    max-height: 88vh;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.25);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.rml-ch-dialog-wide {
    width: 980px;
    height: 620px;
}

.rml-ch-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    border-bottom: 1px solid #eaeaea;
    font-weight: 600;
    font-size: 14px;
    flex-shrink: 0;
}

.rml-ch-header i {
    margin-right: 6px;
    color: #0078d4;
}

.rml-ch-close {
    border: none;
    background: transparent;
    color: #888;
    cursor: pointer;
    font-size: 15px;
    padding: 2px 6px;
    border-radius: 4px;
}

.rml-ch-close:hover {
    background: #f0f0f0;
    color: #333;
}

/* Organisation-wide edit warning */
.rml-ch-warning {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    background: #fff8e6;
    border-bottom: 1px solid #ffe2a8;
    color: #8a6100;
    font-size: 12px;
    flex-shrink: 0;
}

.rml-ch-warning i {
    color: #d69100;
}

.rml-ch-body {
    flex: 1;
    min-height: 0;
    display: flex;
}

.rml-ch-listpane {
    width: 300px;
    flex-shrink: 0;
    border-right: 1px solid #eaeaea;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.rml-ch-filter {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 10px;
    border-bottom: 1px solid #f0f0f0;
    color: #888;
}

.rml-ch-filter-input {
    flex: 1;
    border: none;
    outline: none;
    font-size: 13px;
}

.rml-ch-list {
    flex: 1;
    overflow-y: auto;
    min-height: 0;
}

.rml-ch-item {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 8px;
    border: none;
    background: transparent;
    text-align: left;
    padding: 8px 12px;
    font-size: 13px;
    cursor: pointer;
    border-bottom: 1px solid #f6f6f6;
}

.rml-ch-item:hover {
    background: #f5f9ff;
}

.rml-ch-item.active {
    background: #e8f0fe;
    color: #006fc4;
    font-weight: 600;
}

.rml-ch-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.rml-ch-previewpane {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 0;
}

.rml-ch-preview-title {
    padding: 8px 12px;
    border-bottom: 1px solid #f0f0f0;
    font-size: 12px;
    font-weight: 600;
    color: #555;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.rml-ch-preview-content {
    flex: 1;
    overflow: auto;
    padding: 8px 12px;
    font-size: 13px;
    color: #333;
    background: #fcfcfc;
}

.rml-ch-preview-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
}

.rml-ch-preview-table th {
    text-align: left;
    font-weight: 600;
    color: #666;
    border-bottom: 1px solid #e5e5e5;
    padding: 4px 6px;
    position: sticky;
    top: 0;
    background: #fcfcfc;
}

.rml-ch-preview-table td {
    padding: 4px 6px;
    border-bottom: 1px solid #f2f2f2;
}

.rml-ch-empty {
    color: #999;
    font-size: 12px;
    font-style: italic;
    padding: 12px;
    text-align: center;
}

/* ---- Editor table ---- */

.rml-ch-editor-body {
    flex: 1;
    min-height: 0;
    overflow: auto;
    padding: 0 14px;
}

.rml-ch-editor-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
}

.rml-ch-editor-table th {
    text-align: left;
    font-weight: 600;
    color: #666;
    border-bottom: 1px solid #e5e5e5;
    padding: 8px 6px;
    position: sticky;
    top: 0;
    background: #fff;
    z-index: 1;
}

.rml-ch-editor-table td {
    padding: 4px 6px;
    border-bottom: 1px solid #f4f4f4;
    vertical-align: middle;
}

.rml-ch-col-order {
    width: 54px;
    white-space: nowrap;
}

.rml-ch-col-num {
    width: 80px;
}

.rml-ch-col-flag {
    width: 70px;
    text-align: center;
}

.rml-ch-col-actions {
    width: 40px;
    text-align: center;
}

.rml-ch-input {
    width: 100%;
    box-sizing: border-box;
    border: 1px solid #ddd;
    border-radius: 3px;
    padding: 4px 6px;
    font-size: 12px;
    outline: none;
}

.rml-ch-input:focus {
    border-color: #0078d4;
}

.rml-ch-input-num {
    text-align: right;
}

.rml-ch-icon-btn {
    border: none;
    background: transparent;
    color: #888;
    cursor: pointer;
    padding: 2px 4px;
    border-radius: 3px;
    font-size: 11px;
}

.rml-ch-icon-btn:hover:not(:disabled) {
    background: #f0f0f0;
    color: #333;
}

.rml-ch-icon-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.rml-ch-icon-danger:hover:not(:disabled) {
    background: #fdeaea;
    color: #c62828;
}

.rml-ch-editor-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 14px;
    border-top: 1px solid #f0f0f0;
    flex-shrink: 0;
}

.rml-ch-add-btn {
    border: 1px solid #ddd;
    background: #fff;
    border-radius: 4px;
    padding: 5px 12px;
    font-size: 12px;
    cursor: pointer;
}

.rml-ch-add-btn:hover {
    background: #f5f9ff;
    border-color: #0078d4;
    color: #006fc4;
}

.rml-ch-error {
    color: #c62828;
    font-size: 12px;
}

.rml-ch-dirty {
    margin-right: auto;
    color: #a26b00;
    font-size: 12px;
    font-style: italic;
}

/* ---- Footer ---- */

.rml-ch-footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    padding: 10px 14px;
    border-top: 1px solid #eaeaea;
    flex-shrink: 0;
}

.rml-ch-cancel {
    border: 1px solid #ddd;
    background: #fff;
    border-radius: 4px;
    padding: 6px 14px;
    font-size: 13px;
    cursor: pointer;
}

.rml-ch-cancel:hover:not(:disabled) {
    background: #f5f5f5;
}

.rml-ch-confirm {
    border: 1px solid #0078d4;
    background: #0078d4;
    color: #fff;
    border-radius: 4px;
    padding: 6px 16px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
}

.rml-ch-confirm:disabled,
.rml-ch-cancel:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ---- Dark mode ---- */

[data-theme="dark"] .rml-ch-dialog { background: #2b2b2b; color: #e0e0e0; }
[data-theme="dark"] .rml-ch-header,
[data-theme="dark"] .rml-ch-footer,
[data-theme="dark"] .rml-ch-editor-actions { border-color: #444; }
[data-theme="dark"] .rml-ch-listpane { border-color: #444; }
[data-theme="dark"] .rml-ch-item { border-color: #383838; color: #ddd; }
[data-theme="dark"] .rml-ch-item:hover { background: #333; }
[data-theme="dark"] .rml-ch-item.active { background: #14384f; color: #69bae4; }
[data-theme="dark"] .rml-ch-preview-content { background: #262626; color: #ddd; }
[data-theme="dark"] .rml-ch-preview-table th { background: #262626; color: #aaa; border-color: #444; }
[data-theme="dark"] .rml-ch-preview-table td { border-color: #3a3a3a; }
[data-theme="dark"] .rml-ch-editor-table th { background: #2b2b2b; color: #aaa; border-color: #444; }
[data-theme="dark"] .rml-ch-editor-table td { border-color: #3a3a3a; }
[data-theme="dark"] .rml-ch-input { background: #333; border-color: #4a4a4a; color: #ddd; }
[data-theme="dark"] .rml-ch-filter-input { background: transparent; color: #ddd; }
[data-theme="dark"] .rml-ch-cancel,
[data-theme="dark"] .rml-ch-add-btn { background: #333; border-color: #4a4a4a; color: #ddd; }
[data-theme="dark"] .rml-ch-warning { background: #3a3020; border-color: #5c4a20; color: #e0be74; }
