/**
 * 正清の导航页 - 样式文件
 * 
 * 主要包含：
 * - 基础样式重置
 * - 暗黑模式样式
 * - 搜索框样式
 * - 网站卡片样式
 * - 弹窗样式
 * - 响应式布局
 */

/* ==================== 基础样式重置 ==================== */

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

body {
    font-family: 'Arial', sans-serif;
    color: #333;
    overflow: hidden;
    transition: background-color 0.3s, color 0.3s;
}

/* 暗黑模式 */
body.dark-mode {
    background-color: #1a1a2e;
    color: #e0e0e0;
}

/* ==================== 页面容器 ==================== */

.app-container {
    width: 100%;
    height: 100vh;
}

.front-page {
    width: 100%;
    height: 100%;
}

/* 背景图片容器 */
.background {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-repeat: no-repeat;
    background-position: center center;
    background-size: cover;
    z-index: -1;
    transition: opacity 0.5s;
}

/* 主内容容器 */
.container {
    max-width: 1500px;
    margin: 0 auto;
    padding: 20px;
    height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
}

/* ==================== 加载动画 ==================== */

.loading {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.95);
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

body.dark-mode .loading {
    background: rgba(26, 26, 46, 0.95);
}

/* 加载旋转动画 */
.loading-spinner {
    width: 50px;
    height: 50px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #4a90e2;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

.loading p {
    margin-top: 15px;
    font-size: 16px;
    color: #666;
}

body.dark-mode .loading p {
    color: #aaa;
}

/* ==================== 提示消息 ==================== */

/* 错误提示 */
.error-toast {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: #ff4444;
    color: white;
    padding: 15px 30px;
    border-radius: 8px;
    z-index: 10000;
    animation: slideDown 0.3s ease;
}

/* 成功提示 */
.success-toast {
    background: #4caf50;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

/* ==================== 页面头部 ==================== */

.header-row {
    display: flex;
    align-items: flex-start;
    justify-content: center;
    gap: 20px;
    margin-bottom: 30px;
}

/* 时间日期区域 */
.time-date {
    text-align: center;
    color: white;
    text-shadow: 0 2px 4px rgba(0,0,0,0.5);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
}

.time {
    font-size: 36px;
    font-weight: bold;
}

.date {
    font-size: 16px;
}

.weather {
    font-size: 14px;
    opacity: 0.9;
}

/* 头部操作按钮区域 */
.header-actions {
    display: flex;
    gap: 8px;
}

/* 操作按钮（主题切换、壁纸切换、添加网站、设置） */
.action-btn {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    font-size: 18px;
    cursor: pointer;
    transition: all 0.3s;
    backdrop-filter: blur(10px);
}

.action-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.1);
}

/* ==================== 搜索框 ==================== */

.search-container {
    margin-bottom: 20px;
    width: 100%;
    max-width: 600px;
}

.search-box {
    position: relative;
    display: flex;
    align-items: center;
    background: rgba(255,255,255,0.9);
    border-radius: 30px;
    padding: 10px 20px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    transition: background-color 0.3s;
}

body.dark-mode .search-box {
    background: rgba(40, 40, 60, 0.95);
}

/* 搜索引擎选择器 */
.search-engine {
    position: relative;
    margin-right: 15px;
    cursor: pointer;
}

.search-engine img {
    width: 24px;
    height: 24px;
    border-radius: 50%;
}

/* 搜索引擎下拉菜单 */
.search-engines-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    margin-top: 10px;
    background: white;
    border-radius: 10px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
    padding: 15px;
    z-index: 1000;
    display: none;
    min-width: 405px;
    max-width: 90vw;
    grid-template-columns: repeat(3, 1fr);
    gap: 15px;
}

body.dark-mode .search-engines-dropdown {
    background: #2a2a4a;
}

.search-engines-dropdown.show {
    display: grid;
}

/* 搜索引擎选项 */
.search-engine-option {
    display: flex;
    align-items: center;
    padding: 10px 15px;
    border-radius: 6px;
    cursor: pointer;
    transition: background-color 0.2s;
    text-align: center;
    height: 40px;
}

.search-engine-option:hover {
    background-color: #f5f5f5;
}

body.dark-mode .search-engine-option:hover {
    background-color: #3a3a5a;
}

.search-engine-option img {
    width: 20px;
    height: 20px;
    margin-right: 10px;
}

/* 搜索输入框 */
.search-input {
    flex: 1;
    border: none;
    outline: none;
    background: transparent;
    font-size: 16px;
    padding: 8px 0;
    color: #333;
}

body.dark-mode .search-input {
    color: #e0e0e0;
}

.search-input::placeholder {
    color: #999;
}

/* 搜索按钮 */
.search-button {
    background: none;
    border: none;
    cursor: pointer;
    padding: 5px;
    font-size: 16px;
}

/* ==================== 搜索建议 ==================== */

.search-suggestions {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    margin-top: 5px;
    background: white;
    border-radius: 10px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
    z-index: 999;
    display: none;
    max-height: 300px;
    overflow-y: auto;
}

body.dark-mode .search-suggestions {
    background: #2a2a4a;
}

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

/* 搜索历史头部 */
.search-history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 20px;
    border-bottom: 1px solid #eee;
    font-size: 12px;
    color: #999;
}

body.dark-mode .search-history-header {
    border-bottom-color: #444;
}

.clear-history {
    background: none;
    border: none;
    color: #4a90e2;
    cursor: pointer;
    font-size: 12px;
}

.clear-history:hover {
    text-decoration: underline;
}

/* 搜索建议项 */
.search-suggestion-item {
    display: flex;
    align-items: center;
    padding: 10px 20px;
    cursor: pointer;
    transition: background-color 0.2s;
}

.search-suggestion-item:hover {
    background-color: #f5f5f5;
}

body.dark-mode .search-suggestion-item:hover {
    background-color: #3a3a5a;
}

.search-suggestion-item img {
    width: 20px;
    height: 20px;
    margin-right: 10px;
    border-radius: 50%;
}

.search-suggestion-item .suggestion-text {
    flex: 1;
}

.history-icon {
    margin-right: 10px;
}

/* ==================== 分类标签 ==================== */

.category-header {
    display: flex;
    align-items: center;
    gap: 20px;
    margin-bottom: 15px;
    flex-wrap: wrap;
    justify-content: center;
    width: 100%;
}

.category-tabs {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: center;
}

/* 分类标签按钮 */
.category-tab {
    padding: 8px 16px;
    border: none;
    border-radius: 20px;
    background: rgba(255,255,255,0.7);
    cursor: pointer;
    font-size: 14px;
    transition: all 0.3s;
}

body.dark-mode .category-tab {
    background: rgba(60, 60, 80, 0.8);
    color: #e0e0e0;
}

.category-tab:hover {
    background: rgba(255,255,255,0.9);
    transform: translateY(-2px);
}

body.dark-mode .category-tab:hover {
    background: rgba(80, 80, 100, 0.9);
}

/* 激活状态的分类标签 */
.category-tab.active {
    background: #4a90e2;
    color: white;
}

/* 网站筛选输入框 */
.website-search-box {
    width: 200px;
}

.website-search-input {
    width: 100%;
    padding: 8px 15px;
    border: none;
    border-radius: 20px;
    background: rgba(255,255,255,0.7);
    font-size: 14px;
    outline: none;
    transition: all 0.3s;
}

body.dark-mode .website-search-input {
    background: rgba(60, 60, 80, 0.8);
    color: #e0e0e0;
}

.website-search-input:focus {
    background: rgba(255,255,255,0.95);
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

body.dark-mode .website-search-input:focus {
    background: rgba(80, 80, 100, 0.95);
}

/* ==================== 网站列表 ==================== */

.websites-container {
    flex: 1;
    width: 100%;
    max-width: 1500px;
    background: rgba(255,255,255,0.5);
    border-radius: 20px;
    padding: 20px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.1);
    overflow-y: auto;
    transition: background-color 0.3s;
}

body.dark-mode .websites-container {
    background: rgba(30, 30, 50, 0.9);
}

/* 网站网格布局 */
.websites-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 20px;
}

/* ==================== 网站卡片 ==================== */

.website-item {
    display: flex;
    align-items: center;
    text-align: left;
    cursor: pointer;
    transition: transform 0.3s, box-shadow 0.3s;
    padding: 12px;
    border-radius: 12px;
    background: white;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    position: relative;
}

body.dark-mode .website-item {
    background: #2a2a4a;
}

.website-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

/* 置顶状态的网站卡片 */
.website-item.pinned {
    border: 2px solid #4a90e2;
}

.website-item.pinned::before {
    content: '📌';
    position: absolute;
    top: 5px;
    right: 5px;
    font-size: 12px;
}

/* 置顶按钮 */
.website-item .pin-btn {
    position: absolute;
    top: 5px;
    right: 5px;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 14px;
    opacity: 0;
    transition: opacity 0.2s;
}

.website-item:hover .pin-btn {
    opacity: 1;
}

/* 网站图标 */
.website-icon {
    width: 60px;
    height: 60px;
    border-radius: 8px;
    background: #f5f5f5;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 12px;
    flex-shrink: 0;
}

body.dark-mode .website-icon {
    background: #3a3a5a;
}

.website-icon img {
    width: 40px;
    height: 40px;
    object-fit: contain;
}

/* 网站信息 */
.website-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-width: 0;
    max-width: 100%;
}

.website-name {
    font-size: 14px;
    font-weight: 500;
    color: #333;
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    width: 100%;
    max-width: 140px;
}

body.dark-mode .website-name {
    color: #e0e0e0;
}

/* 无结果提示 */
.no-results {
    grid-column: 1 / -1;
    text-align: center;
    padding: 40px;
    color: #999;
}

body.dark-mode .no-results {
    color: #777;
}

/* ==================== 弹窗样式 ==================== */

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

.modal.show {
    display: flex;
}

.modal-content {
    background: white;
    border-radius: 12px;
    width: 90%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
}

body.dark-mode .modal-content {
    background: #2a2a4a;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border-bottom: 1px solid #eee;
}

body.dark-mode .modal-header {
    border-bottom-color: #444;
}

.modal-header h3 {
    margin: 0;
    font-size: 18px;
}

body.dark-mode .modal-header h3 {
    color: #e0e0e0;
}

.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: #999;
}

.modal-close:hover {
    color: #333;
}

body.dark-mode .modal-close:hover {
    color: #fff;
}

.modal-body {
    padding: 20px;
}

/* ==================== 设置弹窗 ==================== */

.settings-section {
    margin-bottom: 20px;
}

.settings-section h4 {
    margin-bottom: 10px;
    font-size: 14px;
    color: #666;
}

body.dark-mode .settings-section h4 {
    color: #aaa;
}

.settings-row {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.settings-btn {
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    background: #4a90e2;
    color: white;
    cursor: pointer;
    font-size: 14px;
    transition: background 0.2s;
}

.settings-btn:hover {
    background: #3a7bc8;
}

/* 危险操作按钮（清除数据） */
.settings-btn.danger {
    background: #ff4444;
}

.settings-btn.danger:hover {
    background: #cc3333;
}

/* ==================== 表单样式 ==================== */

.form-group {
    margin-bottom: 15px;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-size: 14px;
    color: #666;
}

body.dark-mode .form-group label {
    color: #aaa;
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 14px;
}

body.dark-mode .form-group input,
body.dark-mode .form-group select {
    background: #3a3a5a;
    border-color: #555;
    color: #e0e0e0;
}

.form-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 20px;
}

.btn-primary {
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    background: #4a90e2;
    color: white;
    cursor: pointer;
    font-size: 14px;
}

.btn-primary:hover {
    background: #3a7bc8;
}

.btn-secondary {
    padding: 10px 20px;
    border: 1px solid #ddd;
    border-radius: 8px;
    background: white;
    cursor: pointer;
    font-size: 14px;
}

body.dark-mode .btn-secondary {
    background: #3a3a5a;
    border-color: #555;
    color: #e0e0e0;
}

/* ==================== 页脚 ==================== */

.footer {
    margin-top: 15px;
    color: white;
    text-shadow: 0 2px 4px rgba(0,0,0,0.5);
    font-size: 12px;
    text-align: center;
}

/* ==================== 响应式布局 ==================== */

/* 大屏幕（<=1500px）：4列 */
@media (max-width: 1500px) {
    .websites-grid {
        grid-template-columns: repeat(4, 1fr);
        gap: 15px;
    }
}

/* 中等屏幕（<=992px）：3列 */
@media (max-width: 992px) {
    .websites-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 15px;
    }
    
    .website-search-box {
        width: 150px;
    }
}

/* 平板（<=768px）：2列 */
@media (max-width: 768px) {
    .container {
        padding: 10px;
    }
    
    .header-row {
        flex-direction: column;
        align-items: center;
    }
    
    .time {
        font-size: 28px;
    }
    
    .search-box {
        padding: 8px 15px;
    }
    
    .category-header {
        flex-direction: column;
        gap: 10px;
    }
    
    .website-search-box {
        width: 100%;
        max-width: 300px;
    }
    
    .websites-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }
    
    .website-icon {
        width: 50px;
        height: 50px;
    }
    
    .website-icon img {
        width: 30px;
        height: 30px;
    }
    
    .website-name {
        font-size: 12px;
        max-width: 120px;
    }
    
    .header-actions {
        gap: 5px;
    }
    
    .action-btn {
        width: 35px;
        height: 35px;
        font-size: 16px;
    }
}

/* 手机（<=480px）：1列 */
@media (max-width: 480px) {
    .websites-grid {
        grid-template-columns: 1fr;
        gap: 10px;
    }
    
    .website-name {
        max-width: 200px;
    }
}
