/* level-order.css — shared drag-to-reorder list for category levels / groups.
   Pairs with shared/js/level_order_utils.js (window.LevelOrder). */

.lvl-order-root {
    display: block;
}

.lvl-order-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.lvl-order-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    background: var(--app-card-bg, #ffffff);
    border: 1px solid var(--app-border, #d6dfea);
    border-radius: 8px;
    font-size: 0.92rem;
    color: var(--app-text, #1f2a37);
}

.lvl-order-item:hover {
    border-color: var(--app-accent, #2a7de1);
}

.lvl-order-handle {
    flex: 0 0 auto;
    cursor: grab;
    color: var(--app-muted, #5f6b7a);
    font-size: 1.05rem;
    line-height: 1;
    padding: 4px 6px;
    border-radius: 6px;
    -webkit-user-select: none;
    user-select: none;
    touch-action: none;
}

.lvl-order-handle:hover {
    color: var(--app-accent, #2a7de1);
    background: rgba(42, 125, 225, 0.08);
}

.lvl-order-handle:active {
    cursor: grabbing;
}

.lvl-order-handle:focus-visible {
    outline: 2px solid var(--app-accent, #2a7de1);
    outline-offset: 2px;
}

.lvl-order-label {
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.lvl-order-input {
    flex: 1 1 auto;
    min-width: 0;
    padding: 5px 8px;
    font: inherit;
    color: inherit;
    border: 1px solid var(--app-border, #d6dfea);
    border-radius: 6px;
    background: #fff;
}

.lvl-order-input:focus-visible {
    outline: 2px solid var(--app-accent, #2a7de1);
    outline-offset: 1px;
}

.lvl-order-meta {
    flex: 0 0 auto;
    font-size: 0.82rem;
    color: var(--app-muted, #5f6b7a);
    font-variant-numeric: tabular-nums;
}

/* SortableJS drag states */
.lvl-order-ghost {
    opacity: 0.45;
    background: rgba(42, 125, 225, 0.1);
    border-style: dashed;
}

.lvl-order-chosen {
    box-shadow: 0 2px 8px rgba(31, 42, 55, 0.16);
}

/* Fallback when SortableJS is unavailable — keyboard reordering still works */
.lvl-order-no-drag .lvl-order-handle {
    cursor: default;
}

/* Screen-reader-only live region for keyboard move announcements */
.lvl-order-live {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Preset sort buttons */
.lvl-order-presets {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    margin-bottom: 8px;
}

.lvl-order-presets-title {
    font-size: 0.82rem;
    color: var(--app-muted, #5f6b7a);
    margin-right: 2px;
}

.lvl-order-preset-btn {
    font: inherit;
    font-size: 0.8rem;
    padding: 4px 10px;
    border-radius: 999px;
    border: 1px solid var(--app-border, #d6dfea);
    background: var(--app-card-bg, #ffffff);
    color: var(--app-text, #1f2a37);
    cursor: pointer;
}

.lvl-order-preset-btn:hover {
    border-color: var(--app-accent, #2a7de1);
    color: var(--app-accent-dark, #1a5fb4);
}

.lvl-order-preset-btn:focus-visible {
    outline: 2px solid var(--app-accent, #2a7de1);
    outline-offset: 2px;
}

/* Selected state — for preset bars used as a mode switch rather than one-shot actions */
.lvl-order-preset-btn.is-active {
    background: var(--app-accent, #2a7de1);
    border-color: var(--app-accent, #2a7de1);
    color: #fff;
}

.lvl-order-preset-btn.is-active:hover {
    color: #fff;
}

/* Notice shown when a natural order was auto-applied */
.lvl-order-notice {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 8px 0;
    padding: 8px 12px;
    border-radius: 8px;
    border: 1px solid rgba(42, 125, 225, 0.35);
    background: rgba(42, 125, 225, 0.08);
    color: var(--app-text, #1f2a37);
    font-size: 0.85rem;
}

.lvl-order-notice-dismiss {
    margin-left: auto;
    background: none;
    border: none;
    color: var(--app-muted, #5f6b7a);
    cursor: pointer;
    font-size: 1rem;
    line-height: 1;
    padding: 2px 6px;
    border-radius: 4px;
}

.lvl-order-notice-dismiss:hover {
    color: var(--app-text, #1f2a37);
}

.lvl-order-notice-dismiss:focus-visible {
    outline: 2px solid var(--app-accent, #2a7de1);
    outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
    .lvl-order-item {
        transition: none !important;
    }
}
