/* Tree Column Styles */
.fi-ta-tree-column {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.fi-ta-tree-column .tree-content {
    min-width: 0;
    flex: 1;
}

/* Drag Handle */
.tree-drag-handle {
    display: flex;
    height: 1.5rem;
    width: 1.5rem;
    flex-shrink: 0;
    cursor: grab;
    align-items: center;
    justify-content: center;
    border-radius: 0.25rem;
    color: rgb(156 163 175);
    transition: color 150ms, background-color 150ms;
}

.tree-drag-handle:hover {
    background-color: rgb(249 250 251);
    color: rgb(107 114 128);
}

.dark .tree-drag-handle {
    color: rgb(107 114 128);
}

.dark .tree-drag-handle:hover {
    background-color: rgb(255 255 255 / 0.05);
    color: rgb(156 163 175);
}

/* Expand/Collapse Toggle */
.tree-expand-toggle {
    display: flex;
    height: 1.5rem;
    width: 1.5rem;
    flex-shrink: 0;
    cursor: pointer;
    align-items: center;
    justify-content: center;
    border-radius: 0.25rem;
    color: rgb(156 163 175);
    transition: color 150ms, background-color 150ms;
}

.tree-expand-toggle:hover {
    background-color: rgb(249 250 251);
    color: rgb(107 114 128);
}

.dark .tree-expand-toggle {
    color: rgb(107 114 128);
}

.dark .tree-expand-toggle:hover {
    background-color: rgb(255 255 255 / 0.05);
    color: rgb(156 163 175);
}

/* Drag States - Row being dragged */
tr.tree-row-dragging {
    opacity: 0.4;
    background-color: rgb(243 244 246) !important;
}

.dark tr.tree-row-dragging {
    background-color: rgb(31 41 55) !important;
}

.tree-dragging {
    opacity: 0.5;
}

.tree-ghost {
    background-color: rgb(var(--primary-50, 239 246 255));
    opacity: 0.5;
}

.dark .tree-ghost {
    background-color: rgb(var(--primary-950, 23 37 84));
}

.tree-chosen {
    background-color: rgb(249 250 251);
}

.dark .tree-chosen {
    background-color: rgb(255 255 255 / 0.05);
}

.tree-drag {
    box-shadow: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
}

/* Drop Zone Indicators - Applied to TR elements */
tr.tree-drop-above,
tr.tree-drop-below,
tr.tree-drop-child {
    position: relative;
}

tr.tree-drop-above::before {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    top: 0;
    height: 3px;
    background-color: #3b82f6;
    z-index: 50;
    pointer-events: none;
}

tr.tree-drop-below::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 3px;
    background-color: #3b82f6;
    z-index: 50;
    pointer-events: none;
}

tr.tree-drop-child {
    background-color: rgba(59, 130, 246, 0.1) !important;
    box-shadow: inset 0 0 0 2px #3b82f6;
}

.dark tr.tree-drop-child {
    background-color: rgba(59, 130, 246, 0.2) !important;
}

/* Hidden rows (collapsed children) */
tr.tree-row-hidden {
    display: none;
}

/* Table container for tree mode */
[data-tree-table] tbody tr {
    transition: background-color 150ms, opacity 150ms;
}

/* Undo Banner */
.tree-undo-banner {
    position: fixed;
    bottom: 1rem;
    left: 50%;
    transform: translateX(-50%);
    z-index: 50;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    border-radius: 0.5rem;
    background-color: rgb(17 24 39);
    padding: 0.75rem 1rem;
    color: white;
    box-shadow: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    animation: slide-in-from-bottom 300ms ease-out;
}

@keyframes slide-in-from-bottom {
    from {
        transform: translateX(-50%) translateY(100%);
        opacity: 0;
    }
    to {
        transform: translateX(-50%) translateY(0);
        opacity: 1;
    }
}

.dark .tree-undo-banner {
    background-color: rgb(31 41 55);
}

.tree-undo-banner button {
    border-radius: 0.25rem;
    background-color: rgb(255 255 255 / 0.1);
    padding: 0.25rem 0.75rem;
    font-size: 0.875rem;
    font-weight: 500;
    transition: background-color 150ms;
}

.tree-undo-banner button:hover {
    background-color: rgb(255 255 255 / 0.2);
}

/* Tree Mode Toggle Button */
.tree-mode-toggle {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    border-radius: 0.5rem;
    padding: 0.5rem 0.75rem;
    font-size: 0.875rem;
    font-weight: 500;
    transition: background-color 150ms, color 150ms;
}

.tree-mode-toggle.active {
    background-color: rgb(var(--primary-50, 239 246 255));
    color: rgb(var(--primary-600, 37 99 235));
}

.dark .tree-mode-toggle.active {
    background-color: rgb(var(--primary-950, 23 37 84));
    color: rgb(var(--primary-400, 96 165 250));
}

/* Loading state for tree operations */
[data-tree-table].tree-loading {
    pointer-events: none;
    opacity: 0.5;
}

/* Animation for expand/collapse */
.tree-expand-toggle svg {
    transition: transform 150ms;
}

/* =========================================
   OrderPage Styles
   ========================================= */

/* Order Tree Node */
.order-tree-node {
    position: relative;
    transition: background-color 150ms, opacity 150ms;
}

.order-tree-node-dragging {
    opacity: 0.3;
    background: repeating-linear-gradient(
        45deg,
        transparent,
        transparent 5px,
        rgba(0, 0, 0, 0.03) 5px,
        rgba(0, 0, 0, 0.03) 10px
    );
}

.dark .order-tree-node-dragging {
    background: repeating-linear-gradient(
        45deg,
        transparent,
        transparent 5px,
        rgba(255, 255, 255, 0.03) 5px,
        rgba(255, 255, 255, 0.03) 10px
    );
}

/* Order Tree Drag Handle */
.order-tree-drag-handle {
    touch-action: none;
}

.order-tree-drag-handle:active {
    cursor: grabbing;
}

/* Floating clone styles */
#order-tree-drag-clone {
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2), 0 4px 12px rgba(0, 0, 0, 0.1) !important;
    border-radius: 8px !important;
    transform: rotate(1deg) !important;
}

.dark #order-tree-drag-clone {
    background: rgb(31 41 55) !important;
}

/* Undo banner animation */
@keyframes order-tree-undo-slide-in {
    from {
        transform: translateX(-50%) translateY(100%);
        opacity: 0;
    }
    to {
        transform: translateX(-50%) translateY(0);
        opacity: 1;
    }
}

/* Touch-friendly tap targets */
@media (pointer: coarse) {
    .order-tree-node {
        min-height: 48px;
    }

    .order-tree-drag-handle,
    .order-tree-node button {
        min-width: 44px;
        min-height: 44px;
    }
}
