/* ============================================
   ByteNChill - Tools Sidebar (ChatGPT-style)
   ============================================ */

/* ---- Sidebar Container ---- */
.ts-sidebar {
    position: fixed;
    top: 64px; /* navbar height */
    left: 0;
    bottom: 0;
    width: 280px;
    background: #ffffff;
    border-right: 1px solid #e2e8f0;
    z-index: 40;
    display: flex;
    flex-direction: column;
    transform: translateX(-100%);
    transition: transform .3s cubic-bezier(.4,0,.2,1);
    overflow: hidden;
}

.dark .ts-sidebar {
    background: #0f172a;
    border-right-color: #1e293b;
}

.ts-sidebar.ts-open {
    transform: translateX(0);
}

/* ---- Backdrop (mobile only) ---- */
.ts-backdrop {
    position: fixed;
    inset: 0;
    top: 64px;
    background: rgba(0,0,0,.4);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 35;
    opacity: 0;
    transition: opacity .3s;
}

.ts-backdrop.ts-backdrop-visible {
    opacity: 1;
}

/* ---- Main content offset ---- */
.ts-main {
    transition: margin-left .3s cubic-bezier(.4,0,.2,1);
}

/* Desktop: push content over when sidebar is open */
@media (min-width: 1024px) {
    .ts-main.ts-pushed {
        margin-left: 280px;
    }
}

/* ---- Toggle Button ---- */
.ts-toggle-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 10px;
    border: none;
    background: transparent;
    color: #64748b;
    cursor: pointer;
    transition: all .15s;
    flex-shrink: 0;
}

.ts-toggle-btn:hover {
    background: #f1f5f9;
    color: #0f172a;
}

.dark .ts-toggle-btn:hover {
    background: #1e293b;
    color: #f1f5f9;
}

/* ---- Sidebar Header ---- */
.ts-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    border-bottom: 1px solid #f1f5f9;
    flex-shrink: 0;
}

.dark .ts-header {
    border-bottom-color: #1e293b;
}

.ts-logo {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 700;
    color: #0f172a;
    text-decoration: none;
    transition: color .15s;
}

.dark .ts-logo {
    color: #f1f5f9;
}

.ts-logo:hover {
    color: #f59e0b;
}

.ts-close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    border: none;
    background: transparent;
    color: #94a3b8;
    cursor: pointer;
    transition: all .15s;
}

.ts-close:hover {
    background: #f1f5f9;
    color: #0f172a;
}

.dark .ts-close:hover {
    background: #1e293b;
    color: #f1f5f9;
}

/* ---- Search ---- */
.ts-search-wrap {
    position: relative;
    padding: 12px 14px;
    flex-shrink: 0;
}

.ts-search-icon {
    position: absolute;
    left: 26px;
    top: 50%;
    transform: translateY(-50%);
    width: 16px;
    height: 16px;
    color: #94a3b8;
    pointer-events: none;
}

.ts-search {
    width: 100%;
    padding: 8px 12px 8px 34px;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    background: #f8fafc;
    font-size: 13px;
    color: #0f172a;
    outline: none;
    transition: all .15s;
}

.ts-search:focus {
    border-color: #f59e0b;
    background: #fff;
    box-shadow: 0 0 0 3px rgba(245,158,11,.1);
}

.dark .ts-search {
    background: #1e293b;
    border-color: #334155;
    color: #f1f5f9;
}

.dark .ts-search:focus {
    border-color: #f59e0b;
    background: #0f172a;
    box-shadow: 0 0 0 3px rgba(245,158,11,.08);
}

.ts-search::placeholder {
    color: #94a3b8;
}

.dark .ts-search::placeholder {
    color: #475569;
}

/* ---- Nav ---- */
.ts-nav {
    flex: 1;
    overflow-y: auto;
    padding: 8px 10px 20px;
    scrollbar-width: thin;
    scrollbar-color: #cbd5e1 transparent;
}

.dark .ts-nav {
    scrollbar-color: #334155 transparent;
}

.ts-nav::-webkit-scrollbar {
    width: 4px;
}

.ts-nav::-webkit-scrollbar-thumb {
    border-radius: 4px;
    background: #cbd5e1;
}

.dark .ts-nav::-webkit-scrollbar-thumb {
    background: #334155;
}

/* ---- Category Group ---- */
.ts-group {
    margin-bottom: 4px;
}

.ts-group-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 9px 10px;
    border: none;
    border-radius: 10px;
    background: transparent;
    cursor: pointer;
    transition: all .15s;
    text-align: left;
}

.ts-group-btn:hover {
    background: #f1f5f9;
}

.dark .ts-group-btn:hover {
    background: #1e293b;
}

.ts-group-active {
    background: #f8fafc;
}

.dark .ts-group-active {
    background: rgba(30,41,59,.6);
}

.ts-group-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.ts-dot-rose { background: #f43f5e; }
.ts-dot-red { background: #ef4444; }
.ts-dot-emerald { background: #10b981; }
.ts-dot-amber { background: #f59e0b; }
.ts-dot-blue { background: #3b82f6; }
.ts-dot-teal { background: #14b8a6; }

.ts-group-label {
    flex: 1;
    font-size: 13px;
    font-weight: 600;
    color: #0f172a;
}

.dark .ts-group-label {
    color: #e2e8f0;
}

.ts-group-count {
    font-size: 11px;
    font-weight: 600;
    color: #94a3b8;
    background: #f1f5f9;
    padding: 1px 7px;
    border-radius: 9999px;
}

.dark .ts-group-count {
    color: #64748b;
    background: #1e293b;
}

.ts-chevron {
    width: 16px;
    height: 16px;
    color: #94a3b8;
    transition: transform .2s;
    flex-shrink: 0;
}

.ts-group-btn.ts-group-expanded .ts-chevron {
    transform: rotate(180deg);
}

/* ---- Tool Items ---- */
.ts-group-list {
    padding: 2px 0 4px 16px;
}

.ts-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    border-radius: 8px;
    font-size: 12.5px;
    font-weight: 500;
    color: #64748b;
    text-decoration: none;
    transition: all .12s;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ts-item:hover {
    background: #f1f5f9;
    color: #0f172a;
}

.dark .ts-item {
    color: #94a3b8;
}

.dark .ts-item:hover {
    background: #1e293b;
    color: #f1f5f9;
}

.ts-item-active {
    background: rgba(245,158,11,.1) !important;
    color: #d97706 !important;
    font-weight: 600;
}

.dark .ts-item-active {
    background: rgba(245,158,11,.12) !important;
    color: #fbbf24 !important;
}

.ts-item-dot {
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: #cbd5e1;
    flex-shrink: 0;
    transition: all .15s;
}

.dark .ts-item-dot {
    background: #475569;
}

.ts-item:hover .ts-item-dot {
    background: #f59e0b;
}

.ts-item-dot-active {
    background: #f59e0b !important;
    width: 6px;
    height: 6px;
}

.ts-badge {
    margin-left: auto;
    font-size: 9px;
    font-weight: 700;
    padding: 1px 6px;
    border-radius: 4px;
    background: rgba(245,158,11,.15);
    color: #d97706;
    flex-shrink: 0;
}

.dark .ts-badge {
    background: rgba(245,158,11,.12);
    color: #fbbf24;
}

/* ---- Search: no results ---- */
.ts-no-results {
    text-align: center;
    padding: 20px 16px;
    font-size: 13px;
    color: #94a3b8;
}

/* ---- Hidden utility ---- */
.ts-hidden-search {
    display: none !important;
}

/* ---- Mobile adjustments ---- */
@media (max-width: 1023px) {
    .ts-sidebar {
        width: 300px;
        box-shadow: 8px 0 30px rgba(0,0,0,.12);
    }

    .dark .ts-sidebar {
        box-shadow: 8px 0 30px rgba(0,0,0,.4);
    }
}
