/* =============================================
   Ferrasol Category Tree — estilo Mouser/Digi-Key
   ============================================= */

@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Sans:wght@300;400;500;600&display=swap');

.fct-wrapper {
    font-family: 'IBM Plex Sans', system-ui, sans-serif;
    font-size: 13px;
    color: #1a1a2e;
    background: #fff;
    border: 1px solid #e0e4ea;
    border-radius: 4px;
    overflow: hidden;
    user-select: none;
    min-width: 220px;
    max-width: 320px;
}

/* ── Header ── */
.fct-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    background: #f4f6f9;
    border-bottom: 1px solid #e0e4ea;
    gap: 8px;
}

.fct-title {
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #4a5568;
}

.fct-collapse-all {
    display: flex;
    align-items: center;
    gap: 5px;
    background: none;
    border: 1px solid #c8cfd8;
    border-radius: 3px;
    padding: 3px 8px;
    font-size: 11px;
    color: #6b7280;
    cursor: pointer;
    font-family: inherit;
    transition: all 0.15s ease;
    white-space: nowrap;
}

.fct-collapse-all:hover {
    background: #e8ecf1;
    color: #374151;
    border-color: #9ca3af;
}

/* ── Contenedor árbol ── */
.fct-tree-container {
    padding: 6px 0;
    max-height: 70vh;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: #cbd5e0 transparent;
}

.fct-tree-container::-webkit-scrollbar {
    width: 5px;
}
.fct-tree-container::-webkit-scrollbar-track {
    background: transparent;
}
.fct-tree-container::-webkit-scrollbar-thumb {
    background: #cbd5e0;
    border-radius: 3px;
}

/* ── Listas ── */
.fct-tree-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.fct-tree-list[data-depth="0"] > .fct-tree-item {
    padding-left: 0;
}

/* ── Item ── */
.fct-tree-item {
    position: relative;
    margin: 0;
    padding: 0;
}

.fct-tree-item > .fct-term-link {
    display: flex;
    align-items: baseline;
    gap: 4px;
    padding: 5px 14px 5px 32px;
    text-decoration: none;
    color: #2563eb;
    transition: background 0.1s ease, color 0.1s ease;
    line-height: 1.4;
}

.fct-tree-item > .fct-term-link:hover {
    background: #eff6ff;
    color: #1d4ed8;
}

.fct-tree-item.fct-active > .fct-term-link {
    background: #dbeafe;
    color: #1e40af;
    font-weight: 500;
}

/* Nombre del término */
.fct-term-name {
    flex: 1;
}

/* Contador */
.fct-term-count {
    font-size: 11px;
    color: #9ca3af;
    flex-shrink: 0;
}

.fct-tree-item.fct-active .fct-term-count {
    color: #6b9fd4;
}

/* ── Toggle +/- ── */
.fct-toggle {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    width: 14px;
    height: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid #d1d5db;
    border-radius: 2px;
    background: #fff;
    cursor: pointer;
    color: #6b7280;
    transition: all 0.15s ease;
    z-index: 1;
    flex-shrink: 0;
}

.fct-toggle:hover {
    border-color: #2563eb;
    color: #2563eb;
    background: #eff6ff;
}

.fct-toggle.fct-leaf {
    border: none;
    background: none;
    cursor: default;
}

/* Cuando está expandido: ocultar la línea vertical del + */
.fct-tree-item.fct-open > .fct-toggle .fct-plus-v {
    opacity: 0;
}

/* ── Hijos ── */
.fct-children {
    padding-left: 14px;
    border-left: 1px solid #e5e7eb;
    margin-left: 17px;
}

.fct-children .fct-tree-item > .fct-term-link {
    padding-left: 24px;
    font-size: 12.5px;
}

/* Tercer nivel */
.fct-children .fct-children .fct-tree-item > .fct-term-link {
    padding-left: 22px;
    font-size: 12px;
}

/* ── Estado vacío ── */
.fct-empty {
    padding: 16px;
    color: #6b7280;
    font-size: 13px;
    line-height: 1.5;
}

.fct-empty a {
    color: #2563eb;
    text-decoration: underline;
}

/* ── Animación expansión ── */
.fct-children {
    overflow: hidden;
}

/* ── Responsive ── */
@media (max-width: 768px) {
    .fct-wrapper {
        max-width: 100%;
        min-width: 0;
    }
    .fct-tree-container {
        max-height: 50vh;
    }
}
