/**
 * Hierarchy Picker Styles
 * Tri-state checkboxes and tree navigation
 */

/* Tree container */
.hierarchy-tree {
    font-size: 0.9rem;
}

/* Individual tree item */
.tree-item {
    user-select: none;
}

/* Row styling */
.tree-row {
    padding: 4px 8px;
    border-radius: 4px;
    min-height: 36px;
    transition: background-color 0.15s ease;
}

.tree-row:hover {
    background-color: rgba(0, 0, 0, 0.04);
}

/* Expand/collapse button */
.tree-expand-btn {
    width: 20px;
    height: 20px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--wellness-deep-forest, #40513B);
    text-decoration: none;
}

.tree-expand-btn:hover {
    color: var(--wellness-sage-green, #628141);
}

.tree-expand-btn i {
    font-size: 0.75rem;
}

/* Spacer for leaf nodes (alignment) */
.tree-spacer {
    width: 20px;
    display: inline-block;
}

/* Tri-state checkbox */
.tri-checkbox {
    width: 22px;
    height: 22px;
    min-width: 22px;
    min-height: 22px;
    border: 2px solid #adb5bd;
    border-radius: 4px;
    background: #ffffff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.15s ease;
    padding: 0;
    flex-shrink: 0;
}

.tri-checkbox:hover {
    border-color: var(--wellness-sage-green, #628141);
}

.tri-checkbox:focus {
    outline: 2px solid var(--wellness-sage-green, #628141);
    outline-offset: 2px;
}

/* None state (unchecked) */
.tri-checkbox[data-state="none"] {
    background: #ffffff;
    border-color: #adb5bd;
}

/* All state (fully checked) */
.tri-checkbox[data-state="all"] {
    background: var(--wellness-sage-green, #628141);
    border-color: var(--wellness-sage-green, #628141);
    color: #ffffff;
}

.tri-checkbox[data-state="all"] i {
    font-size: 14px;
    font-weight: bold;
}

/* Mixed state (partial/indeterminate) */
.tri-checkbox[data-state="mixed"] {
    background: #ffc107;
    border-color: #ffc107;
    color: #000000;
}

.tri-checkbox[data-state="mixed"] i {
    font-size: 14px;
    font-weight: bold;
}

/* Tree label */
.tree-label {
    flex: 1;
    line-height: 1.3;
}

/* Children container */
.tree-children {
    /* Children are indented via padding-left in JS */
}

/* Hierarchy container (collapsible wrapper) */
.hierarchy-container {
    border: 1px solid rgba(0, 0, 0, 0.125);
    border-radius: 0.375rem;
    margin-top: 0.5rem;
}

.hierarchy-container .hierarchy-tree {
    max-height: 300px;
    overflow-y: auto;
    padding: 0.5rem;
}

/* Toggle button styling */
.hierarchy-toggle {
    font-size: 0.85rem;
}

.hierarchy-toggle.active {
    background-color: var(--wellness-sage-green, #628141);
    border-color: var(--wellness-sage-green, #628141);
    color: #ffffff;
}

/* Selection count badge */
.selection-count {
    font-size: 0.75rem;
}

/* Mobile-friendly tap targets */
@media (max-width: 576px) {
    .tree-row {
        min-height: 44px;
        padding: 8px;
    }

    .tri-checkbox {
        width: 28px;
        height: 28px;
        min-width: 28px;
        min-height: 28px;
    }

    .tri-checkbox[data-state="all"] i,
    .tri-checkbox[data-state="mixed"] i {
        font-size: 16px;
    }

    .tree-expand-btn {
        width: 28px;
        height: 28px;
    }

    .tree-expand-btn i {
        font-size: 0.9rem;
    }

    .tree-label {
        font-size: 0.95rem;
    }
}

/* Pill styling for inherited selections */
.ingredient-pill-inherited {
    opacity: 0.7;
}

.ingredient-pill-inherited .via-label {
    font-size: 0.7em;
    font-style: italic;
}

/* Scrollbar styling for tree */
.hierarchy-tree::-webkit-scrollbar {
    width: 8px;
}

.hierarchy-tree::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

.hierarchy-tree::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 4px;
}

.hierarchy-tree::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

/* Toolbar for tree controls */
.hierarchy-toolbar {
    display: flex;
    gap: 0.5rem;
    padding: 0.5rem;
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
    background: #f8f9fa;
}

.hierarchy-toolbar .btn {
    font-size: 0.75rem;
    padding: 0.25rem 0.5rem;
}
