/**
 * Tree View Styles for Zen Smart Folders
 *
 * @package ZenSmartFolders
 */

.zensf-tree-sidebar {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    overflow: hidden;
    margin: 8px 10px 10px 0;
    width: 280px;
    flex-shrink: 0;
    animation: zensf-tree-in 0.3s ease-out;
    display: none;
}

.zensf-tree-sidebar.zensf-tree-sidebar--visible {
    display: block;
}

@keyframes zensf-tree-in {
    from {
        opacity: 0;
        transform: translateX(-8px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.zensf-tree-sidebar__header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 14px 16px;
    background: linear-gradient(135deg, #1e293b 0%, #334155 100%);
    color: #f8fafc;
    font-size: 14px;
    font-weight: 600;
}

.zensf-tree-sidebar__header svg {
    color: #d97706;
    flex-shrink: 0;
}

.zensf-tree-sidebar__toggle {
    margin-left: auto;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    border-radius: 6px;
    color: #94a3b8;
    cursor: pointer;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
}

.zensf-tree-sidebar__toggle:hover {
    background: rgba(255, 255, 255, 0.2);
    color: #f8fafc;
}

.zensf-tree-sidebar__toggle.zensf-tree-sidebar__toggle--collapsed svg {
    transform: rotate(-90deg);
}

.zensf-tree-sidebar__toggle svg {
    transition: transform 0.2s ease;
}

.zensf-tree-sidebar__body {
    padding: 8px;
    max-height: 520px;
    overflow-y: auto;
}

.zensf-tree-sidebar__body--collapsed {
    display: none;
}

.zensf-tree-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border-radius: 8px;
    text-decoration: none;
    color: #334155;
    font-size: 13px;
    font-weight: 500;
    transition: all 0.15s ease;
    position: relative;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.zensf-tree-item:hover {
    background: #f8fafc;
    color: #1e293b;
}

.zensf-tree-item--active {
    background: #fef3c7;
    color: #92400e;
    font-weight: 600;
}

.zensf-tree-item--active:hover {
    background: #fde68a;
    color: #78350f;
}

.zensf-tree-item__toggle {
    background: none;
    border: none;
    padding: 2px;
    cursor: pointer;
    color: #94a3b8;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

.zensf-tree-item__toggle:hover {
    background: #e2e8f0;
    color: #475569;
}

.zensf-tree-item__toggle[aria-expanded="false"] svg {
    transform: rotate(-90deg);
}

.zensf-tree-item__toggle svg {
    transition: transform 0.2s ease;
}

.zensf-tree-item__icon {
    color: #d97706;
    flex-shrink: 0;
}

.zensf-tree-item--active .zensf-tree-item__icon {
    color: #92400e;
}

.zensf-tree-item__name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
}

.zensf-tree-item__count {
    font-size: 11px;
    font-weight: 600;
    color: #94a3b8;
    background: #f1f5f9;
    padding: 1px 8px;
    border-radius: 20px;
    min-width: 24px;
    text-align: center;
    flex-shrink: 0;
}

.zensf-tree-item--active .zensf-tree-item__count {
    background: rgba(217, 119, 6, 0.15);
    color: #92400e;
}

.zensf-tree-item.zensf-drop-target {
    background: #ccfbf1;
    outline: 2px dashed #0d9488;
    outline-offset: -2px;
}

.zensf-tree-children {
    overflow: hidden;
    position: relative;
}

.zensf-tree-children::before {
    content: '';
    position: absolute;
    left: 18px;
    top: 0;
    bottom: 8px;
    width: 1px;
    background: #e2e8f0;
    border-radius: 1px;
}

.zensf-drag-helper {
    position: absolute;
    background: #fff;
    border: 1px solid #d97706;
    border-radius: 8px;
    padding: 6px 14px;
    font-size: 13px;
    font-weight: 600;
    color: #1e293b;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
    z-index: 100001;
    pointer-events: none;
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 6px;
}

.zensf-drag-helper svg {
    color: #d97706;
    flex-shrink: 0;
}

.zensf-drag-helper .zensf-drag-count {
    font-size: 11px;
    font-weight: 600;
    color: #fff;
    background: #d97706;
    padding: 1px 6px;
    border-radius: 10px;
    min-width: 20px;
    text-align: center;
}

@media screen and (max-width: 960px) {
    .zensf-tree-sidebar {
        width: 100%;
        margin: 0 0 12px;
    }
}

/* ── Drag Handle Column ── */
.column-zensf_drag {
    width: 28px;
    padding: 8px 4px !important;
    text-align: center;
}

.zensf-drag-handle:hover {
    color: #d97706 !important;
}

/* ── Quick Create ── */
.zensf-tree-sidebar__add {
    background: rgba(255, 255, 255, 0.1);
    border: none;
    border-radius: 6px;
    color: #94a3b8;
    cursor: pointer;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
}

.zensf-tree-sidebar__add:hover {
    background: rgba(255, 255, 255, 0.2);
    color: #f8fafc;
}

.zensf-quick-create-form {
    padding: 4px 8px;
    animation: zensf-quick-in 0.2s ease-out;
}

@keyframes zensf-quick-in {
    from {
        opacity: 0;
        transform: translateY(-4px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes zensf-tree-item-in {
    from {
        opacity: 0;
        transform: translateX(-6px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.zensf-quick-create-form__inner {
    display: flex;
    align-items: center;
    gap: 6px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 6px 8px;
}

.zensf-quick-create-form--loading .zensf-quick-create-form__inner {
    opacity: 0.7;
    pointer-events: none;
}

.zensf-quick-create-form__icon {
    color: #d97706;
    flex-shrink: 0;
}

.zensf-quick-create-input {
    flex: 1;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    padding: 5px 10px;
    font-size: 13px;
    background: #fff;
    color: #1e293b;
    outline: none;
    min-width: 0;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.zensf-quick-create-input:focus {
    border-color: #d97706;
    box-shadow: 0 0 0 2px rgba(217, 119, 6, 0.15);
}

.zensf-quick-create-input--error {
    border-color: #ef4444 !important;
    animation: zensf-shake 0.4s ease;
}

@keyframes zensf-shake {
    0%, 100% { transform: translateX(0); }
    20%, 60% { transform: translateX(-3px); }
    40%, 80% { transform: translateX(3px); }
}

.zensf-quick-create-submit,
.zensf-quick-create-cancel {
    background: none;
    border: none;
    cursor: pointer;
    width: 26px;
    height: 26px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    flex-shrink: 0;
    transition: all 0.15s ease;
}

.zensf-quick-create-submit {
    color: #0d9488;
}

.zensf-quick-create-submit:hover {
    background: #ccfbf1;
}

.zensf-quick-create-submit:disabled {
    opacity: 0.4;
    cursor: default;
}

.zensf-quick-create-cancel {
    color: #94a3b8;
}

.zensf-quick-create-cancel:hover {
    background: #f1f5f9;
    color: #475569;
}

.zensf-quick-create-error {
    font-size: 11px;
    color: #dc2626;
    padding: 4px 4px 0;
    line-height: 1.3;
}

.zensf-tree-item__add-subfolder {
    position: absolute;
    right: 4px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    cursor: pointer;
    color: transparent;
    width: 22px;
    height: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: all 0.15s ease;
    padding: 0;
}

.zensf-tree-item:hover .zensf-tree-item__add-subfolder {
    color: #94a3b8;
}

.zensf-tree-item__add-subfolder:hover {
    background: #e2e8f0;
    color: #475569;
}

/* ── Tree Search Bar ── */
.zensf-tree-search {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 8px;
    margin-bottom: 4px;
    border-bottom: 1px solid #f1f5f9;
}

.zensf-tree-search__icon {
    color: #94a3b8;
    flex-shrink: 0;
}

.zensf-tree-search__input {
    flex: 1;
    border: none;
    outline: none;
    font-size: 12px;
    color: #334155;
    background: transparent;
    padding: 2px 0;
    min-width: 0;
}

.zensf-tree-search__input::placeholder {
    color: #94a3b8;
}

.zensf-tree-search__clear {
    background: none;
    border: none;
    cursor: pointer;
    color: #94a3b8;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    flex-shrink: 0;
    padding: 0;
    transition: all 0.15s ease;
}

.zensf-tree-search__clear:hover {
    background: #f1f5f9;
    color: #475569;
}

/* ── Colored Folder Items ── */
.zensf-tree-item--colored {
    background: rgba(0, 0, 0, 0.03);
}

.zensf-tree-item--colored:hover {
    background: rgba(0, 0, 0, 0.06);
}

.zensf-tree-item--colored.zensf-tree-item--active {
    background: rgba(0, 0, 0, 0.08);
}

.zensf-tree-item--colored .zensf-tree-item__icon {
    color: var(--zensf-folder-color, #d97706);
}

.zensf-tree-item--colored .zensf-tree-item__name {
    color: var(--zensf-folder-color, #1e293b);
}

.zensf-tree-item--colored .zensf-tree-item__count {
    background: var(--zensf-folder-color, #f1f5f9);
    color: #fff;
    opacity: 0.85;
}
