/* 基础样式 - 不依赖主题的通用样式 */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    line-height: 1.6;
    overflow: hidden;
}

/* 应用容器 */
.app-container {
    height: 100vh;
    display: flex;
    flex-direction: column;
    position: relative;
    z-index: 1;
}

/* 工具栏 */
.toolbar {
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    border-bottom: 1px solid var(--border-color);
    background: var(--toolbar-bg);
}

.toolbar-left {
    display: flex;
    align-items: center;
    gap: 8px;
}

.toolbar-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* 按钮样式 */
.btn-icon {
    width: 32px;
    height: 32px;
    border: none;
    border-radius: 4px;
    background: transparent;
    color: var(--text-color);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.btn-icon:hover {
    background: var(--hover-bg);
}

.btn-icon:active {
    transform: scale(0.95);
}

.btn-icon.active {
    background: var(--primary-color);
    color: var(--primary-text);
}

/* 面包屑导航 */
.breadcrumb {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-left: 16px;
}

.breadcrumb-item {
    padding: 4px 8px;
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.2s ease;
    font-size: 14px;
}

.breadcrumb-item:hover {
    background: var(--hover-bg);
}

.breadcrumb-item.active {
    background: var(--primary-color);
    color: var(--primary-text);
}

.breadcrumb-separator {
    color: var(--text-secondary);
    margin: 0 4px;
}

/* 视图控制 */
.view-controls {
    display: flex;
    gap: 4px;
}

/* 主题选择器 */
.theme-selector {
    position: relative;
}

.theme-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    background: var(--bg-color);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    min-width: 120px;
    z-index: 1000;
    display: none;
}

.theme-dropdown.show {
    display: block;
}

.theme-option {
    padding: 8px 16px;
    cursor: pointer;
    transition: background 0.2s ease;
    font-size: 14px;
}

.theme-option:hover {
    background: var(--hover-bg);
}

.theme-option:first-child {
    border-radius: 8px 8px 0 0;
}

.theme-option:last-child {
    border-radius: 0 0 8px 8px;
}

/* 搜索容器 */
.search-container {
    padding: 16px;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-color);
    display: none;
}

.search-container.show {
    display: block;
}

.search-box {
    position: relative;
    max-width: 400px;
    margin: 0 auto;
}

.search-box input {
    width: 100%;
    padding: 8px 40px 8px 16px;
    border: 1px solid var(--border-color);
    border-radius: 20px;
    background: var(--input-bg);
    color: var(--text-color);
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s ease;
}

.search-box input:focus {
    border-color: var(--primary-color);
}

.search-box #clear-search {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
}

/* 主内容区域 */
.main-content {
    flex: 1;
    display: flex;
    overflow: hidden;
}

/* 侧边栏 */
.sidebar {
    width: 250px;
    background: var(--sidebar-bg);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    transition: width 0.3s ease;
}

.sidebar.collapsed {
    width: 0;
    overflow: hidden;
}

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

.sidebar-header h3 {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-color);
}

.sidebar-toggle {
    transition: transform 0.3s ease;
}

.sidebar.collapsed .sidebar-toggle {
    transform: rotate(180deg);
}

/* 侧边栏展开按钮 */
.sidebar-expand-btn {
    position: fixed;
    left: 8px;
    top: 50%;
    transform: translateY(-50%);
    width: 32px;
    height: 32px;
    border: none;
    border-radius: 4px;
    background: var(--primary-color);
    color: var(--primary-text);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    transition: all 0.2s ease;
}

.sidebar-expand-btn:hover {
    background: var(--primary-color);
    opacity: 0.9;
    transform: translateY(-50%) scale(1.05);
}

.sidebar-content {
    flex: 1;
    padding: 16px;
    overflow-y: auto;
}

/* 快速访问 */
.quick-access {
    margin-bottom: 24px;
}

.quick-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 12px;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.2s ease;
    margin-bottom: 4px;
}

.quick-item:hover {
    background: var(--hover-bg);
}

.quick-item i {
    width: 16px;
    color: var(--text-secondary);
}

.quick-item span {
    font-size: 14px;
    color: var(--text-color);
}

/* 统计信息 */
.stats h4 {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-color);
    margin-bottom: 12px;
}

.stat-item {
    display: flex;
    justify-content: space-between;
    padding: 4px 0;
    font-size: 13px;
}

.stat-item span:first-child {
    color: var(--text-secondary);
}

.stat-item span:last-child {
    color: var(--text-color);
    font-weight: 500;
}

/* 内容区域 */
.content-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.content-header {
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-color);
}

.item-count {
    font-size: 14px;
    color: var(--text-secondary);
}

.sort-controls select {
    padding: 4px 8px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    background: var(--input-bg);
    color: var(--text-color);
    font-size: 14px;
    outline: none;
}

/* 书签容器 */
.bookmark-container {
    flex: 1;
    padding: 16px;
    overflow-y: auto;
    background: var(--bg-color);
}

/* 网格视图 */
.bookmark-container.grid-view {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 16px;
}

/* 列表视图 */
.bookmark-container.list-view {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* 书签项目 */
.bookmark-item {
    padding: 12px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: var(--card-bg);
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
}

.bookmark-item:hover {
    border-color: var(--primary-color);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    transform: translateY(-1px);
}

.bookmark-item.folder {
    border-left: 4px solid var(--folder-color);
}

.bookmark-item.bookmark {
    border-left: 4px solid var(--bookmark-color);
}

/* 网格视图中的书签项目 */
.grid-view .bookmark-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    min-height: 120px;
    max-height: 180px;
    justify-content: center;
}

.grid-view .bookmark-icon {
    font-size: 32px;
    margin-bottom: 8px;
    color: var(--icon-color);
}

.grid-view .bookmark-name {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-color);
    margin-bottom: 4px;
    word-break: break-word;
}

.grid-view .bookmark-url {
    display: none;
}

/* 列表视图中的书签项目 */
.list-view .bookmark-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 12px;
}

.list-view .bookmark-icon {
    font-size: 20px;
    color: var(--icon-color);
    width: 24px;
    text-align: center;
}

.list-view .bookmark-info {
    flex: 1;
    min-width: 0;
}

.list-view .bookmark-name {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-color);
    margin-bottom: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.list-view .bookmark-url {
    font-size: 12px;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.list-view .bookmark-meta {
    font-size: 12px;
    color: var(--text-secondary);
    white-space: nowrap;
}

/* 状态栏 */
.status-bar {
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    background: var(--status-bar-bg);
    border-top: 1px solid var(--border-color);
    font-size: 12px;
    color: var(--text-secondary);
}

/* 模态框 */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}

.modal.show {
    display: flex;
}

.modal-content {
    background: var(--bg-color);
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
    max-width: 500px;
    width: 90%;
    max-height: 80vh;
    overflow: hidden;
}

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

.modal-header h3 {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-color);
}

.modal-body {
    padding: 20px;
    overflow-y: auto;
}

/* 响应式设计 */
@media (max-width: 768px) {
    .sidebar {
        position: absolute;
        left: 0;
        top: 0;
        height: 100%;
        z-index: 100;
        transform: translateX(-100%);
        transition: transform 0.3s ease;
    }
    
    .sidebar.show {
        transform: translateX(0);
    }
    
    .bookmark-container.grid-view {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
        gap: 12px;
    }
    
    .toolbar {
        padding: 0 8px;
    }
    
    .breadcrumb {
        display: none;
    }
    
    .content-header {
        padding: 0 8px;
    }
    
    .bookmark-container {
        padding: 8px;
    }
}

@media (max-width: 480px) {
    .bookmark-container.grid-view {
        grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
        gap: 8px;
    }
    
    .grid-view .bookmark-item {
        min-height: 100px;
        padding: 8px;
    }
    
    .grid-view .bookmark-icon {
        font-size: 24px;
    }
    
    .grid-view .bookmark-name {
        font-size: 13px;
    }
    
    .modal-content {
        width: 95%;
        margin: 20px;
    }
}

/* 滚动条样式 */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--scrollbar-track);
}

::-webkit-scrollbar-thumb {
    background: var(--scrollbar-thumb);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--scrollbar-thumb-hover);
}

/* 动画 */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.bookmark-item {
    animation: fadeIn 0.3s ease;
}

/* 加载状态 */
.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px;
    color: var(--text-secondary);
}

.loading::after {
    content: '';
    width: 20px;
    height: 20px;
    border: 2px solid var(--border-color);
    border-top: 2px solid var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-left: 8px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}