/* Generic Tree Card Styles - Framework Agnostic */
/* Can be used for any hierarchical data structure */

/* === Tree Card Panel === */
.tree-card-panel {
    background-color: #f8f9fa;
    padding: 16px;
    overflow-y: auto;
    overflow-x: hidden;
    max-height: calc(100vh - 180px);
    height: 100%;
}

.tree-card-panel-loading {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 200px;
}

.tree-card-panel-empty {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 200px;
    padding: 32px;
}

.tree-card-panel-header {
    margin-bottom: 16px;
}

.tree-card-panel-content {
    display: flex;
    flex-direction: column;
    gap: 12px;
    min-height: min-content;
    width: 100%;
}

/* === Tree Card === */
.tree-card {
    background: white;
    border-radius: 12px;
    padding: 12px 16px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
    border: 3px solid transparent;
    min-height: 72px;
}

.tree-card-loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(255, 255, 255, 0.8);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
}

.tree-card-loading-overlay .spinner-border {
    width: 1.5rem;
    height: 1.5rem;
}

.tree-card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    transform: translateY(-2px);
}

.tree-card.selected {
    border-color: #0d6efd;
    box-shadow: 0 4px 16px rgba(13, 110, 253, 0.2);
}

/* === Badge === */
.tree-card-badge {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 14px;
    flex-shrink: 0;
    text-transform: uppercase;
}

/* === Content === */
.tree-card-content {
    flex: 1;
    min-width: 0;
    overflow: hidden;
}

/* === Action Buttons === */
.tree-card-actions {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-shrink: 0;
}

.tree-card-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    color: white;
    font-size: 14px;
    padding: 0;
}

.tree-card-btn:hover:not(.disabled) {
    transform: scale(1.1);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.tree-card-btn:active:not(.disabled) {
    transform: scale(0.95);
}

.tree-card-btn.disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.tree-card-btn-expand {
    background-color: #6b5b95;
}

.tree-card-btn-expand i {
    transition: transform 0.2s ease;
}

.tree-card-btn-expand.expanded i {
    transform: rotate(90deg);
}

.tree-card-btn-add {
    background-color: #5a5a5a;
}

.tree-card-btn-delete {
    background-color: #8b4c4c;
}

/* === Children Container === */
.tree-card-children {
    overflow: hidden;
    transition: max-height 0.3s ease-in-out, opacity 0.2s ease;
}

.tree-card-children.collapsed {
    max-height: 0;
    opacity: 0;
}

.tree-card-children.expanded {
    max-height: 5000px;
    opacity: 1;
}

/* === Custom Scrollbar === */
.tree-card-panel::-webkit-scrollbar {
    width: 8px;
}

.tree-card-panel::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

.tree-card-panel::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 4px;
}

.tree-card-panel::-webkit-scrollbar-thumb:hover {
    background: #555;
}

/* === Responsive === */
@media (max-width: 767px) {
    .tree-card-panel {
        max-height: calc(100vh - 220px);
        padding: 12px;
    }

    .tree-card {
        padding: 10px 12px;
        min-height: 64px;
    }

    .tree-card-badge {
        width: 40px;
        height: 40px;
        font-size: 12px;
    }

    .tree-card-btn {
        width: 32px;
        height: 32px;
        font-size: 12px;
    }

    .tree-card-actions {
        gap: 6px;
    }
}

/* ============================================================================
   Dark Mode Overrides
   ============================================================================ */
[data-theme="dark"] {
    /* Tree card panel */
    .tree-card-panel {
        background-color: var(--bs-secondary-bg);
    }

    .tree-card-panel-loading,
    .tree-card-panel-empty {
        color: var(--bs-body-color);
    }

    /* Tree cards */
    .tree-card {
        background: var(--bs-tertiary-bg);
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
        border-color: rgba(161, 206, 173, 0.2);
    }

    .tree-card:hover {
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
    }

    .tree-card.selected {
        border-color: var(--bs-nucor-lightgreen);
        box-shadow: 0 4px 16px rgba(0, 132, 79, 0.4);
    }

    /* Loading overlay */
    .tree-card-loading-overlay {
        background-color: rgba(0, 0, 0, 0.6);
    }

    .tree-card-loading-overlay .spinner-border {
        color: var(--bs-nucor-lightgreen);
    }

    /* Action buttons in dark mode */
    .tree-card-btn-expand {
        background-color: var(--bs-nucor-mediumgreen);
    }

    .tree-card-btn-expand:hover:not(.disabled) {
        background-color: var(--bs-nucor-lightgreen);
    }

    .tree-card-btn-add {
        background-color: rgba(161, 206, 173, 0.3);
    }

    .tree-card-btn-add:hover:not(.disabled) {
        background-color: rgba(161, 206, 173, 0.5);
    }

    .tree-card-btn-delete {
        background-color: #d9534f;
    }

    .tree-card-btn-delete:hover:not(.disabled) {
        background-color: #c9302c;
    }

    /* Scrollbar in dark mode */
    .tree-card-panel::-webkit-scrollbar-track {
        background: var(--bs-secondary-bg);
    }

    .tree-card-panel::-webkit-scrollbar-thumb {
        background: var(--bs-nucor-mediumgreen);
    }

    .tree-card-panel::-webkit-scrollbar-thumb:hover {
        background: var(--bs-nucor-lightgreen);
    }
}
