/* ===== NESTED TREE STRUCTURE ===== */

/* Tree Container */
.tree-container {
    background: var(--primary-color);
    border-radius: var(--border-radius);
    padding: 1.5rem;
    box-shadow: var(--shadow-md);
    margin-top: 1.5rem;
}

/* Tree List */
.tree-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

/* Tree Item */
.tree-item {
    margin: 0.5rem 0;
    position: relative;
}

/* Tree Node */
.tree-node {
    display: flex;
    align-items: center;
    padding: 1rem 1.25rem;
    background: var(--tertiary-color);
    border-radius: var(--border-radius);
    border-left: 4px solid transparent;
    transition: all var(--transition-base);
    cursor: pointer;
    position: relative;
    gap: 0.75rem;
}

.tree-node:hover {
    background: #e0e7ff;
    border-left-color: var(--accent-color);
    transform: translateX(4px);
    box-shadow: var(--shadow-sm);
}

/* Level-specific colors */
.tree-node.level-menu {
    background: linear-gradient(135deg, #dbeafe 0%, #bfdbfe 100%);
    border-left-color: #3b82f6;
    font-weight: 600;
}

.tree-node.level-category {
    background: linear-gradient(135deg, #d1fae5 0%, #a7f3d0 100%);
    border-left-color: #10b981;
}

.tree-node.level-minor {
    background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
    border-left-color: #f59e0b;
}

.tree-node.level-sub {
    background: linear-gradient(135deg, #fce7f3 0%, #fbcfe8 100%);
    border-left-color: #ec4899;
}

.tree-node.level-food {
    background: linear-gradient(135deg, #e0e7ff 0%, #c7d2fe 100%);
    border-left-color: #6366f1;
}

/* Toggle Icon */
.tree-toggle {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--primary-color);
    border-radius: 50%;
    transition: all var(--transition-base);
    flex-shrink: 0;
}

.tree-toggle .material-symbols-outlined {
    font-size: 18px;
    transition: transform var(--transition-base);
}

.tree-item.expanded > .tree-node .tree-toggle .material-symbols-outlined {
    transform: rotate(90deg);
}

.tree-toggle:hover {
    background: var(--accent-color);
    color: var(--primary-color);
    transform: scale(1.1);
}

/* Tree Content */
.tree-content {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.tree-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background: var(--primary-color);
    border-radius: 8px;
    color: var(--accent-color);
    flex-shrink: 0;
}

.tree-label {
    flex: 1;
}

.tree-title {
    font-weight: 600;
    font-size: 1rem;
    color: var(--text-primary);
    margin: 0;
}

.tree-description {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin: 0.25rem 0 0 0;
}

/* Tree Actions */
.tree-actions {
    display: flex;
    gap: 0.5rem;
    opacity: 0;
    transition: opacity var(--transition-base);
}

.tree-node:hover .tree-actions {
    opacity: 1;
}

.tree-action-btn {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--primary-color);
    border: 2px solid var(--border-color);
    border-radius: 8px;
    cursor: pointer;
    transition: all var(--transition-base);
    color: var(--text-primary);
}

.tree-action-btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-sm);
}

.tree-action-btn.edit:hover {
    background: var(--accent-color);
    border-color: var(--accent-color);
    color: var(--primary-color);
}

.tree-action-btn.delete:hover {
    background: var(--danger-color);
    border-color: var(--danger-color);
    color: var(--primary-color);
}

.tree-action-btn.add:hover {
    background: var(--success-color);
    border-color: var(--success-color);
    color: var(--primary-color);
}

/* Nested Children */
.tree-children {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease-out;
    padding-left: 2rem;
    margin-top: 0.5rem;
}

.tree-item.expanded > .tree-children {
    max-height: 5000px;
    transition: max-height 0.5s ease-in;
}

/* Add Item Button */
.tree-add-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.875rem 1.25rem;
    background: var(--tertiary-color);
    border: 2px dashed var(--border-color);
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: all var(--transition-base);
    color: var(--text-secondary);
    margin-top: 0.75rem;
}

.tree-add-item:hover {
    background: var(--accent-color);
    border-color: var(--accent-color);
    color: var(--primary-color);
    transform: translateX(4px);
}

.tree-add-item .material-symbols-outlined {
    font-size: 20px;
}

/* Confirmation Dialog */
.confirm-dialog {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    animation: fadeIn 0.2s ease-out;
}

.confirm-dialog.show {
    display: flex;
}

.confirm-content {
    background: var(--primary-color);
    padding: 2rem;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-xl);
    max-width: 400px;
    width: 90%;
    animation: modalSlideIn 0.3s ease-out;
}

.confirm-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 1rem;
}

.confirm-message {
    color: var(--text-secondary);
    margin-bottom: 1.5rem;
}

.confirm-actions {
    display: flex;
    gap: 0.75rem;
    justify-content: flex-end;
}

.confirm-btn {
    padding: 0.625rem 1.5rem;
    border-radius: var(--border-radius);
    border: none;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-base);
}

.confirm-btn.cancel {
    background: var(--tertiary-color);
    color: var(--text-primary);
}

.confirm-btn.cancel:hover {
    background: var(--border-color);
}

.confirm-btn.confirm {
    background: var(--danger-color);
    color: var(--primary-color);
}

.confirm-btn.confirm:hover {
    background: #dc2626;
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

/* Empty State */
.tree-empty {
    text-align: center;
    padding: 3rem 2rem;
    color: var(--text-secondary);
}

.tree-empty .material-symbols-outlined {
    font-size: 64px;
    color: var(--border-color);
    margin-bottom: 1rem;
}

/* Loading State for Tree */
.tree-loading {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    padding: 1rem;
}

.tree-skeleton-item {
    height: 60px;
    background: var(--tertiary-color);
    border-radius: var(--border-radius);
    animation: skeleton-loading 1.5s infinite ease-in-out;
}

