/* ===================================
   Sidebar Widget Manager v2.0
   添加 / 删除 / 拖拽排序 / 隐藏恢复
   =================================== */

/* ---- Widget Pool（隐藏容器） ---- */
.sidebar-widget-pool {
    display: none !important;
}

/* ---- 基础 item ---- */
.sidebar-sortable-item {
    position: relative;
    transition: opacity 0.2s, transform 0.2s;
    cursor: default;
}

.sidebar-sortable-item.item-hidden {
    max-height: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
    opacity: 0;
    overflow: hidden;
    pointer-events: none;
    border: none !important;
}

.sidebar-sortable-item.dragging {
    opacity: 0.4;
    transform: scale(0.98);
}

.sidebar-sortable-item.drag-over {
    border-top: 2px solid #6366f1;
}

/* ---- 控件按钮组（拖拽 + 删除） ---- */
.sidebar-sortable-item .sortable-controls {
    position: absolute;
    top: 6px;
    right: 6px;
    display: flex;
    gap: 2px;
    z-index: 2;
    opacity: 0;
    transition: opacity 0.2s;
}

.sidebar-sortable-item:hover .sortable-controls {
    opacity: 1;
}

.sidebar-sortable-item .sortable-controls button {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    color: #94a3b8;
    background: rgba(255, 255, 255, 0.92);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
    transition: background 0.15s, color 0.15s;
    padding: 0;
}

.sidebar-sortable-item .sortable-controls button:hover {
    background: #e2e8f0;
    color: #475569;
}

.sidebar-sortable-item .sortable-controls .btn-delete:hover {
    background: #fef2f2;
    color: #ef4444;
}

.sidebar-sortable-item .sortable-controls .btn-hide:hover {
    background: #fffbeb;
    color: #f59e0b;
}

.sidebar-sortable-item .sortable-controls .drag-handle-btn:active {
    cursor: grabbing;
}

.sidebar-sortable-item > *:first-child {
    position: relative;
}

/* ---- 添加组件按钮 ---- */
.sidebar-add-widget {
    position: relative;
    margin-top: 12px;
}

.sidebar-add-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    width: 100%;
    padding: 10px 16px;
    background: transparent;
    border: 2px dashed #d1d5db;
    border-radius: 10px;
    color: #9ca3af;
    font-size: 13px;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.2s;
    box-sizing: border-box;
}

.sidebar-add-btn:hover {
    border-color: #6366f1;
    color: #6366f1;
    background: #f5f3ff;
}

.sidebar-add-btn svg {
    flex-shrink: 0;
}

/* ---- 组件选择面板（下拉） ---- */
.sidebar-widget-picker {
    position: absolute;
    bottom: calc(100% + 8px);
    left: 0;
    right: 0;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
    padding: 6px;
    display: none;
    z-index: 100;
    max-height: 260px;
    overflow-y: auto;
}

.sidebar-widget-picker.show {
    display: block;
    animation: pickerSlideIn 0.15s ease;
}

@keyframes pickerSlideIn {
    from { opacity: 0; transform: translateY(4px); }
    to   { opacity: 1; transform: translateY(0); }
}

.picker-item {
    display: block;
    width: 100%;
    text-align: left;
    padding: 9px 12px;
    border: none;
    background: transparent;
    border-radius: 7px;
    font-size: 13px;
    color: #374151;
    font-family: inherit;
    cursor: pointer;
    transition: background 0.15s;
    box-sizing: border-box;
}

.picker-item:hover {
    background: #f3f4f6;
    color: #6366f1;
}

.picker-empty {
    text-align: center;
    color: #9ca3af;
    font-size: 12px;
    padding: 12px;
    margin: 0;
}

/* ---- 恢复已隐藏组件 ---- */
.sidebar-restore-bar {
    text-align: center;
    padding: 8px;
    margin-top: 8px;
}

.sidebar-restore-bar button {
    font-size: 12px;
    color: #6366f1;
    background: #eef2ff;
    border: 1px solid #c7d2fe;
    border-radius: 7px;
    padding: 6px 14px;
    cursor: pointer;
    font-family: inherit;
    transition: background 0.15s;
}

.sidebar-restore-bar button:hover {
    background: #e0e7ff;
}

/* ---- 标签云样式（pool 中可能用到） ---- */
.sidebar-sortable-item .tags-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.sidebar-sortable-item .tag-badge {
    display: inline-block;
    padding: 3px 10px;
    background: #f3f4f6;
    color: #6b7280;
    border-radius: 6px;
    font-size: 12px;
    text-decoration: none;
    transition: background 0.15s, color 0.15s;
}

.sidebar-sortable-item .tag-badge:hover {
    background: #e0e7ff;
    color: #6366f1;
}

/* ---- 响应式 ---- */
@media (max-width: 768px) {
    .sidebar-sortable-item .sortable-controls {
        opacity: 1;
    }

    .sidebar-add-btn {
        font-size: 12px;
        padding: 8px 12px;
    }
}
