/* =========================================================
   PAGE LAYOUT
========================================================= */

.pl-page {
    display: flex;
    flex-direction: column;
    gap: 16px;
    height: calc(100vh - 90px);
    min-height: 0;
    padding: 15px;
}

.pl-content {
    flex: 1;
    min-height: 0;
}

/* =========================================================
   HEADER
========================================================= */

.pl-header {
    position: sticky;
    top: 0;
    z-index: 20;
    padding: 20px 22px;
    border-radius: 14px;
    background: white;
    box-shadow: 0 8px 24px rgba(16, 24, 40, 0.06);
    display: flex;
    flex-direction: column;
    gap: 20px;
    backdrop-filter: blur(6px);
}

.pl-header-top {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 20px;
    flex-wrap: wrap;
}

.pl-title-wrap {
    display: flex;
    flex-direction: column;
}

.pl-title {
    font-weight: 700;
    margin: 0;
    font-size: 1.35rem;
}

.pl-subtitle {
    font-size: 13px;
    color: #667085;
    margin-top: 4px;
}

/* =========================================================
   HEADER TOOLBAR
========================================================= */

.pl-header-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 18px;
    flex-wrap: wrap;
}

.pl-toolbar-left {
    display: flex;
    gap: 18px;
    align-items: end;
    flex-wrap: wrap;
}

.pl-filter {
    display: flex;
    align-items: end;
    gap: 10px;
}

    .pl-filter label {
        font-size: 12px;
        font-weight: 600;
        color: #475467;
        margin-bottom: 6px;
        display: block;
    }

.pl-search {
    min-width: 320px;
}

.pl-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: center;
}

/* =========================================================
   PREVIEW BAR
========================================================= */

.pl-summary {
    display: flex;
    gap: 12px;
    align-items: stretch;
    flex-wrap: wrap;
}

.preview-item {
    min-width: 110px;
    background: linear-gradient(135deg, #f8fafc, #eef2f7);
    border: 1px solid #e4e7ec;
    border-radius: 12px;
    padding: 10px 14px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    box-shadow: 0 2px 6px rgba(16, 24, 40, 0.04);
}

.preview-label {
    font-size: 11px;
    color: #667085;
    margin-bottom: 4px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .3px;
}

.preview-value {
    font-size: 20px;
    font-weight: 700;
    color: #101828;
}

.preview-item.highlight {
    background: linear-gradient(135deg, #eff8ff, #dbeafe);
    border-color: #bfdbfe;
}

    .preview-item.highlight .preview-value {
        color: #1d4ed8;
    }

.preview-item.size {
    background: linear-gradient(135deg, #fefce8, #fef3c7);
    border-color: #fde68a;
}

    .preview-item.size .preview-value {
        color: #92400e;
    }

.pl-preview-hint {
    font-size: 12px;
    color: #667085;
    margin-top: -6px;
}

/* =========================================================
   TREE PANEL
========================================================= */

.pl-tree-panel {
    height: 100%;
    min-height: 0;
    padding: 16px;
    border-radius: 14px;
    box-shadow: 0 8px 24px rgba(16, 24, 40, 0.05);
    overflow: hidden;
}

.pl-tree {
    height: 100%;
    overflow-y: auto;
    overflow-x: auto;
    padding-right: 6px;
    font-size: 14px;
}

/* =========================
   TREE STRUCTURE
========================= */

.pl-line,
.pl-category,
.pl-sub {
    position: relative;
}

    /* indentación real de nodos */

    .pl-line > .node-card {
        margin-left: 20px;
    }

    .pl-category > .node-card {
        margin-left: 40px;
    }

    .pl-sub > .node-card {
        margin-left: 50px;
    }

    /* líneas verticales */

    .pl-line::before,
    .pl-category::before,
    .pl-sub::before {
        content: "";
        position: absolute;
        top: -6px;
        bottom: -6px;
        width: 1px;
        background: #e6e9ef;
    }

    .pl-line::before {
        left: 10px;
    }

    .pl-category::before {
        left: 30px;
    }

    .pl-sub::before {
        left: -5px;
    }

/* =========================================================
   TREE NODES
========================================================= */

.node-card {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 8px;
    border-radius: 8px;
    transition: all .15s ease;
    margin: 4px 0;
}

    .node-card:hover {
        background: #f5f7fb;
    }

.pl-node-title,
.sub-title {
    cursor: pointer;
}

.node-icon {
    width: 18px;
    text-align: center;
    opacity: .85;
}

.node-badge {
    margin-left: auto;
    background: #eef2f7;
    color: #475467;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 600;
}

.expand {
    cursor: pointer;
    user-select: none;
    font-size: 12px;
    color: #667085;
    width: 16px;
    text-align: center;
}

/* =========================================================
   LOADING / EMPTY
========================================================= */

.pl-loading,
.pl-empty {
    padding: 32px;
    text-align: center;
    border-radius: 14px;
    box-shadow: 0 8px 24px rgba(16, 24, 40, 0.05);
    color: #475467;
}

/* =========================================================
   MODAL
========================================================= */

.pl-modal-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
    margin-bottom: 16px;
}

.pl-modal-stats {
    font-size: 14px;
    color: #475467;
    white-space: nowrap;
}

.pl-products-table {
    width: 100%;
    border-collapse: collapse;
}

    .pl-products-table th {
        text-align: left;
        border-bottom: 2px solid #eaecf0;
        padding: 10px;
        background: #fafafa;
        position: sticky;
        top: 0;
    }

    .pl-products-table td {
        padding: 10px;
        border-bottom: 1px solid #f2f4f7;
        vertical-align: middle;
    }

    .pl-products-table tr:hover {
        background: #f9fafb;
    }

/* PRODUCT CARD */

.pl-product-image {
    width: 60px;
    height: 60px;
    object-fit: contain;
    border-radius: 8px;
    background: #fff;
    border: 1px solid #eaecf0;
}

    .pl-product-image.ph {
        display: flex;
        align-items: center;
        justify-content: center;
        color: #98a2b3;
        font-size: 18px;
    }

.pl-product-code {
    font-weight: 700;
    color: #101828;
}

.pl-product-desc {
    font-size: 12px;
    color: #667085;
    margin-top: 2px;
}

/* =========================================================
   RESPONSIVE
========================================================= */

@media (max-width: 1200px) {

    .pl-header-top {
        flex-direction: column;
        align-items: stretch;
    }

    .pl-summary {
        width: 100%;
    }

    .pl-header-toolbar {
        flex-direction: column;
        align-items: stretch;
    }

    .pl-toolbar-left {
        width: 100%;
    }

    .pl-actions {
        width: 100%;
    }
}

@media (max-width: 768px) {

    .preview-item {
        min-width: calc(50% - 6px);
    }

    .pl-search {
        min-width: 100%;
    }
}

.tree-children {
    overflow: hidden;
    transition: all .22s ease;
}

.tree-open {
    opacity: 1;
    max-height: 2000px;
}

.tree-closed {
    opacity: 0;
    max-height: 0;
}

.expand {
    transition: transform .18s ease;
}

    .expand.open {
        transform: rotate(90deg);
    }

.pl-tree::-webkit-scrollbar {
    width: 10px;
}

.pl-tree::-webkit-scrollbar-thumb {
    background: #d0d5dd;
    border-radius: 6px;
}

    .pl-tree::-webkit-scrollbar-thumb:hover {
        background: #98a2b3;
    }

.pl-active-search {
    font-size: 12px;
    color: #667085;
}

/* =========================================================
   LISTA PRODUCTOS SIN SUBCATEGORIA (PREMIUM)
========================================================= */

.apm-list {
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* ITEM CARD */

.apm-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 12px;
    border-radius: 14px;
    background: #ffffff;
    border: 1px solid #eef2f7;
    transition: all 0.2s ease;
    cursor: pointer;
}

    .apm-item:hover {
        transform: translateY(-3px);
        box-shadow: 0 10px 24px rgba(15, 23, 42, 0.08);
        border-color: #dbeafe;
    }

/* INFO PRODUCTO */

.apm-item-info {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

/* IMAGEN */

.apm-img {
    width: 42px;
    height: 42px;
    object-fit: contain;
    border-radius: 10px;
    background: #f1f5f9;
    padding: 4px;
}

/* TEXTO */

.apm-text {
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.apm-code {
    font-size: 11px;
    font-weight: 700;
    color: #2563eb;
    letter-spacing: 0.3px;
}

.apm-name {
    font-size: 12px;
    color: #475569;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* BOTÓN */

.apm-btn {
    border-radius: 999px;
    padding: 6px 14px;
    font-size: 12px;
    font-weight: 600;
    border: none;
    transition: all 0.2s ease;
}

.apm-btn-assign {
    background: linear-gradient(135deg, #22c55e, #16a34a);
    color: white;
}

    .apm-btn-assign:hover {
        transform: scale(1.05);
        box-shadow: 0 6px 14px rgba(34, 197, 94, 0.4);
    }

/* HEADER MODAL */

.apm-header {
    padding: 18px 20px;
    border-bottom: 1px solid #e5e7eb;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

    .apm-header h5 {
        margin: 0;
        font-weight: 700;
    }

.apm-subtitle {
    font-size: 13px;
    color: #64748b;
}

/* SCROLL PERSONALIZADO */

.apm-list::-webkit-scrollbar {
    width: 6px;
}

.apm-list::-webkit-scrollbar-thumb {
    background: #cbd5f5;
    border-radius: 10px;
}

    .apm-list::-webkit-scrollbar-thumb:hover {
        background: #94a3b8;
    }

/* EMPTY */

.apm-empty {
    padding: 24px;
    text-align: center;
    color: #94a3b8;
    font-size: 14px;
}
