/* ============================================
   Toolbar Sidebar Styles - ابزارک سمت چپ
   ============================================ */

/* Two sidebar layout */
.app-layout {
    display: flex;
    height: calc(100vh - var(--header-height, 56px));
    position: relative;
}

/* Left Sidebar - Tools (in RTL this goes to the LEFT visually) */
.tools-sidebar {
    width: 240px;
    min-width: 240px;
    background: var(--bg-sidebar, #f9fafb);
    border-left: 1px solid var(--border-color, #e5e7eb);
    order: 1; /* In RTL flex, order:1 = visually left side */
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: all var(--transition-normal, 0.25s ease);
    z-index: 10;
}

.tools-sidebar.closed {
    width: 0;
    min-width: 0;
    border-left: none;
    overflow: hidden;
    padding: 0;
}

.tools-sidebar-header {
    padding: 12px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.tools-sidebar-header h5 {
    font-size: 0.9rem;
    font-weight: 600;
    margin: 0;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 6px;
}

.tools-sidebar-body {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
}

/* Category Buttons */
.category-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 8px 10px;
    border: none;
    border-radius: var(--radius-sm, 6px);
    background: transparent;
    color: var(--text-secondary, #6b7280);
    font-size: 0.78rem;
    cursor: pointer;
    transition: all var(--transition-fast, 150ms);
    text-align: right;
    font-family: inherit;
}

.category-btn:hover {
    background: var(--bg-hover, #e5e5e9);
    color: var(--text-primary, #1a1a2e);
}

.category-btn.active {
    background: var(--accent-primary, #2563eb);
    color: white;
}

.category-btn .category-icon {
    font-size: 1rem;
    width: 24px;
    text-align: center;
}

.category-btn .category-count {
    margin-right: auto;
    font-size: 0.7rem;
    background: var(--bg-tertiary, #ececf1);
    padding: 1px 6px;
    border-radius: 10px;
    color: var(--text-muted, #9ca3af);
}

.category-btn.active .category-count {
    background: rgba(255,255,255,0.2);
    color: rgba(255,255,255,0.9);
}

/* Tool Buttons inside category */
.tools-list {
    display: none;
    padding: 4px 0 8px 16px;
}

.tools-list.open {
    display: block;
}

.tool-item {
    display: flex;
    align-items: center;
    gap: 6px;
    width: 100%;
    padding: 6px 8px;
    border: none;
    border-radius: var(--radius-sm, 6px);
    background: transparent;
    color: var(--text-secondary, #6b7280);
    font-size: 0.72rem;
    cursor: pointer;
    transition: all var(--transition-fast, 150ms);
    text-align: right;
    font-family: inherit;
    line-height: 1.4;
}

.tool-item:hover {
    background: var(--bg-sidebar-hover, #e5e7eb);
    color: var(--text-primary, #1a1a2e);
}

.tool-item .tool-icon {
    font-size: 0.85rem;
    width: 20px;
    text-align: center;
    flex-shrink: 0;
}

.tool-item .tool-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.tool-item .tool-source-badge {
    font-size: 0.6rem;
    background: var(--bg-tertiary, #ececf1);
    padding: 1px 4px;
    border-radius: 4px;
    color: var(--text-muted, #9ca3af);
}

/* Toggle buttons */
.tools-toggle {
    position: fixed;
    top: calc(var(--header-height, 56px) + 8px);
    right: 8px;
    z-index: 20;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 1px solid var(--border-color);
    background: var(--bg-primary);
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    transition: all var(--transition-fast);
}

.tools-toggle:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

/* Main content adjusts for left sidebar */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

/* Right sidebar (chat history) */
.sidebar {
    width: var(--sidebar-width, 280px);
    min-width: var(--sidebar-width, 280px);
}

/* Search input */
.tools-search {
    padding: 8px;
    border-bottom: 1px solid var(--border-color);
}

.tools-search-input {
    width: 100%;
    padding: 6px 10px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm, 6px);
    background: var(--bg-input, #fff);
    color: var(--text-primary);
    font-size: 0.75rem;
    font-family: inherit;
    outline: none;
    transition: border-color var(--transition-fast);
}

.tools-search-input:focus {
    border-color: var(--accent-primary, #2563eb);
}

/* Loading state */
.tools-loading {
    text-align: center;
    padding: 20px;
    color: var(--text-muted);
    font-size: 0.8rem;
}

.tools-loading .spinner {
    width: 24px;
    height: 24px;
    border: 2px solid var(--border-color);
    border-top-color: var(--accent-primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto 8px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Empty state */
.tools-empty {
    text-align: center;
    padding: 20px;
    color: var(--text-muted);
    font-size: 0.75rem;
}

/* Dark theme adjustments */
[data-theme="dark"] .tools-sidebar {
    background: var(--bg-sidebar, #1a1a2e);
}

[data-theme="dark"] .tools-toggle {
    background: var(--bg-primary, #212121);
    border-color: var(--border-color, #3a3a4a);
}

/* Responsive */
@media (max-width: 768px) {
    .tools-sidebar {
        position: fixed;
        top: var(--header-height, 56px);
        right: 0;
        bottom: 0;
        z-index: 100;
        box-shadow: var(--shadow-lg);
        transform: translateX(100%);
        transition: transform var(--transition-normal);
    }
    
    .tools-sidebar.open {
        transform: translateX(0);
    }
}