/* استایل‌های اختصاصی صفحه تاریخچه Omni Browser */
.history-layout {
    display: grid;
    grid-template-columns: 280px 1fr;
    height: calc(100vh - 140px); /* ارتفاع کل صفحه منهای هدر و فوتر */
    background-color: var(--bg-color);
    border-radius: var(--radius-lg);
    overflow: hidden;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
}

/* --- نوار ابزار بالا (Toolbar) --- */
.history-toolbar {
    grid-column: 1 / -1;
    padding: 16px 24px;
    background-color: var(--surface-color);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
}

.toolbar-group {
    display: flex;
    align-items: center;
    gap: 12px;
}

.search-box {
    position: relative;
    flex-grow: 1;
    max-width: 400px;
}

.search-box input {
    width: 100%;
    padding: 10px 16px 10px 40px;
    border-radius: var(--radius-full);
    border: 1px solid var(--border-color);
    background-color: var(--bg-color);
    color: var(--text-color);
    font-family: inherit;
    transition: all 0.2s;
}

.search-box input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: var(--shadow-focus);
    background-color: var(--surface-color);
}

.search-icon {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    pointer-events: none;
}

.btn-danger {
    background-color: #ef4444;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: background 0.2s;
}

.btn-danger:hover { background-color: #dc2626; }

.btn-secondary {
    background-color: var(--bg-color);
    color: var(--text-color);
    border: 1px solid var(--border-color);
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 13px;
    transition: all 0.2s;
}

.btn-secondary:hover { background-color: var(--border-color); }

/* --- سایدبار درختی (Tree Sidebar) --- */
.history-sidebar {
    background-color: var(--surface-color);
    border-left: 1px solid var(--border-color);
    overflow-y: auto;
    padding: 10px 0;
    user-select: none;
}

.tree-item {
    cursor: pointer;
    padding: 8px 16px;
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-color);
    font-size: 14px;
    transition: background 0.15s;
    position: relative;
}

.tree-item:hover { background-color: var(--bg-color); }
.tree-item.active { background-color: var(--primary-light); color: var(--primary-color); font-weight: 600; border-right: 3px solid var(--primary-color); }

.tree-toggle {
    width: 16px;
    height: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    color: var(--text-muted);
    transition: transform 0.2s;
}

.tree-item.expanded > .tree-toggle { transform: rotate(90deg); }
.tree-item.leaf > .tree-toggle { visibility: hidden; }

.tree-children {
    display: none;
    padding-right: 12px; /* تورفتگی */
}

.tree-item.expanded > .tree-children { display: block; }

.tree-year { font-weight: 700; font-size: 15px; margin-top: 8px; }
.tree-month { font-weight: 600; }
.tree-day { font-weight: 400; font-size: 13px; }

/* --- محتوای اصلی (History List) --- */
.history-content {
    padding: 24px;
    overflow-y: auto;
    background-color: var(--bg-color);
}

.history-list-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border-color);
}

.history-list-header h2 { margin: 0; font-size: 18px; color: var(--text-color); }

.history-item {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 12px;
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    margin-bottom: 8px;
    transition: transform 0.2s, box-shadow 0.2s;
}

.history-item:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-sm);
    border-color: var(--primary-color);
}

.h-checkbox { width: 18px; height: 18px; cursor: pointer; accent-color: var(--primary-color); }

.h-icon {
    width: 32px;
    height: 32px;
    background: var(--bg-color);
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
}

.h-details { flex-grow: 1; min-width: 0; }
.h-title { font-weight: 600; font-size: 14px; color: var(--text-color); margin-bottom: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.h-url { font-size: 12px; color: var(--text-muted); direction: ltr; text-align: right; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.h-time { font-size: 11px; color: var(--text-muted); margin-right: 8px; flex-shrink: 0; }

.h-actions {
    display: flex;
    gap: 8px;
    opacity: 0;
    transition: opacity 0.2s;
}

.history-item:hover .h-actions { opacity: 1; }

.action-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 6px;
    border-radius: 4px;
    color: var(--text-muted);
    transition: all 0.2s;
}

.action-btn:hover { background-color: var(--bg-color); color: var(--primary-color); }
.action-btn.delete:hover { background-color: #fee2e2; color: #ef4444; }

/* --- Pagination --- */
.pagination {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-top: 24px;
}

.page-btn {
    padding: 6px 12px;
    border: 1px solid var(--border-color);
    background: var(--surface-color);
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
    color: var(--text-color);
}

.page-btn:hover:not(:disabled) { border-color: var(--primary-color); color: var(--primary-color); }
.page-btn.active { background: var(--primary-color); color: white; border-color: var(--primary-color); }
.page-btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* --- مودال حذف پیشرفته --- */
.modal-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.5); backdrop-filter: blur(4px);
    z-index: 3000; display: none; align-items: center; justify-content: center;
}
.modal-overlay.show { display: flex; }

.clear-modal {
    background: var(--surface-color);
    width: 90%; max-width: 500px;
    border-radius: var(--radius-lg);
    padding: 24px;
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border-color);
}

.clear-options-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin: 20px 0;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    color: var(--text-color);
    cursor: pointer;
    padding: 8px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
}
.checkbox-label:hover { background-color: var(--bg-color); }

/* ریسپانسیو */
@media (max-width: 768px) {
    .history-layout { grid-template-columns: 1fr; }
    .history-sidebar { display: none; /* در موبایل می‌توان از دراپ‌داون استفاده کرد */ }
    .history-sidebar.mobile-visible { display: block; position: fixed; inset: 0; z-index: 2000; }
}