/* 全局样式和CSS变量 */
:root {
    --primary-color: #6366f1;
    --secondary-color: #8b5cf6;
    --success-color: #22c55e;
    --danger-color: #ef4444;
    --bg-color: #f8fafc;
    --card-bg: #ffffff;
    --text-color: #1e293b;
    --text-secondary: #64748b;
    --border-color: #e2e8f0;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

body.dark-mode {
    --bg-color: #0f172a;
    --card-bg: #1e293b;
    --text-color: #f1f5f9;
    --text-secondary: #cbd5e1;
    --border-color: #334155;
}

* {
    transition: background-color 0.3s ease, color 0.3s ease;
}

body {
    margin: 0;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    line-height: 1.6;
    color: var(--text-color);
    background-color: var(--bg-color);
}

/* 头部样式 */
header {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    color: white;
    padding: 2rem 0;
    box-shadow: var(--shadow);
}

header .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

header h1 {
    margin: 0;
    font-size: 2rem;
}

.theme-btn {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border: 2px solid rgba(255, 255, 255, 0.3);
    padding: 0.5rem 1rem;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1rem;
    transition: all 0.3s ease;
}

.theme-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: translateY(-2px);
}

/* 导航栏 */
.nav-bar {
    background: var(--card-bg);
    box-shadow: var(--shadow);
    position: sticky;
    top: 0;
    z-index: 100;
}

.nav-bar .container {
    display: flex;
    gap: 1rem;
    padding: 1rem 0;
}

.nav-link {
    color: var(--text-color);
    text-decoration: none;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    transition: all 0.3s ease;
}

.nav-link:hover {
    background: var(--primary-color);
    color: white;
    transform: translateY(-2px);
}

.nav-link.active {
    background: var(--primary-color);
    color: white;
}

/* 容器 */
.container {
    width: 90%;
    max-width: 1200px;
    margin: auto;
}

/* 区块样式 */
.section {
    display: none;
    padding: 2rem 0;
    animation: fadeIn 0.5s ease;
}

.section.active {
    display: block;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* 卡片样式 */
.welcome-card,
.calculator-card,
.todo-card,
.gallery-card {
    background: var(--card-bg);
    border-radius: 12px;
    padding: 2rem;
    box-shadow: var(--shadow);
    margin-top: 1rem;
}

h2 {
    color: var(--text-color);
    margin: 1rem 0;
    font-size: 1.8rem;
}

h3 {
    color: var(--text-secondary);
    margin: 1rem 0;
}

ul {
    list-style: none;
    padding: 0;
}

ul li {
    padding: 0.5rem 0;
    font-size: 1.1rem;
}

/* 计数器演示 */
.counter-demo {
    margin-top: 2rem;
    text-align: center;
    padding: 1.5rem;
    background: var(--bg-color);
    border-radius: 8px;
}

#counterDisplay {
    font-size: 2rem;
    font-weight: bold;
    color: var(--primary-color);
}

/* 功能卡片布局 */
.feature-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 2rem;
    margin: 2rem 0;
}

.feature-card {
    background: var(--card-bg);
    padding: 2rem;
    border-radius: 12px;
    box-shadow: var(--shadow);
    text-align: center;
    transition: all 0.3s ease;
    cursor: pointer;
    border: 2px solid transparent;
}

.feature-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 20px rgba(0,0,0,0.15);
    border-color: var(--primary-color);
}

.feature-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
    animation: float 3s ease-in-out infinite;
}

@keyframes float {
    0%, 100% { transform: translateY(0px); }
    50% { transform: translateY(-10px); }
}

.feature-card h3 {
    color: var(--text-color);
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
}

.feature-card p {
    color: var(--text-secondary);
    margin-bottom: 1.5rem;
    font-size: 1rem;
}

.feature-btn {
    background: var(--primary-color);
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 600;
    transition: all 0.3s ease;
}

.feature-btn:hover {
    background: var(--secondary-color);
    transform: scale(1.05);
}

/* 按钮样式 */
.action-btn {
    background: var(--primary-color);
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.3s ease;
    margin: 0.5rem;
}

.action-btn:hover {
    background: var(--secondary-color);
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

/* 计算器样式 */
.calc-display {
    background: var(--bg-color);
    padding: 1.5rem;
    text-align: right;
    font-size: 2rem;
    border-radius: 8px;
    margin-bottom: 1rem;
    min-height: 3rem;
    font-weight: bold;
    color: var(--text-color);
}

.calc-buttons {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.5rem;
}

.calc-btn {
    padding: 1.5rem;
    font-size: 1.2rem;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    background: var(--card-bg);
    color: var(--text-color);
    border: 2px solid var(--border-color);
    transition: all 0.2s ease;
}

.calc-btn:hover {
    background: var(--primary-color);
    color: white;
    transform: scale(1.05);
}

.calc-btn.operator {
    background: var(--primary-color);
    color: white;
}

.calc-btn.equals {
    background: var(--success-color);
    color: white;
}

.calc-btn.clear {
    grid-column: span 4;
    background: var(--danger-color);
    color: white;
}

/* 待办事项样式 */
.todo-input-group {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

#todoInput {
    flex: 1;
    padding: 0.75rem;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 1rem;
    background: var(--bg-color);
    color: var(--text-color);
}

#todoInput:focus {
    outline: none;
    border-color: var(--primary-color);
}

.todo-list {
    list-style: none;
    padding: 0;
}

.todo-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    background: var(--bg-color);
    border-radius: 8px;
    margin-bottom: 0.5rem;
    transition: all 0.3s ease;
}

.todo-item:hover {
    transform: translateX(5px);
    box-shadow: var(--shadow);
}

.todo-item.completed {
    opacity: 0.6;
}

.todo-item.completed .todo-text {
    text-decoration: line-through;
}

.todo-checkbox {
    width: 20px;
    height: 20px;
    cursor: pointer;
}

.todo-text {
    flex: 1;
    color: var(--text-color);
}

.todo-delete {
    background: var(--danger-color);
    color: white;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.todo-delete:hover {
    transform: scale(1.1);
}

.todo-stats {
    display: flex;
    justify-content: space-around;
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 2px solid var(--border-color);
    font-weight: bold;
    color: var(--text-secondary);
}

/* 图片画廊样式 */
.gallery-controls {
    margin-bottom: 1rem;
}

.gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1rem;
}

.gallery-item {
    height: 200px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1.2rem;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    animation: slideIn 0.5s ease;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: scale(0.8);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.gallery-item:hover {
    transform: scale(1.05) rotate(2deg);
    box-shadow: var(--shadow-lg);
}

/* 页脚样式 */
footer {
    background: var(--card-bg);
    color: var(--text-secondary);
    text-align: center;
    padding: 2rem 0;
    margin-top: 3rem;
    box-shadow: 0 -4px 6px -1px rgba(0, 0, 0, 0.1);
}

footer p {
    margin: 0;
}

/* 通知动画 */
@keyframes slideInRight {
    from {
        transform: translateX(400px);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* API 连接状态指示器 */
.api-status {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--success-color);
    margin-right: 0.5rem;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

.api-status.offline {
    background: var(--danger-color);
}

/* 待办事项加载状态 */
.loading {
    text-align: center;
    padding: 2rem;
    color: var(--text-secondary);
}

.loading::after {
    content: '...';
    animation: dots 1.5s infinite;
}

@keyframes dots {
    0%, 20% { content: '.'; }
    40% { content: '..'; }
    60%, 100% { content: '...'; }
}

/* 响应式设计 */
@media (max-width: 768px) {
    header .container {
        flex-direction: column;
        gap: 1rem;
    }
    
    .nav-bar .container {
        flex-wrap: wrap;
    }
    
    .calc-buttons {
        grid-template-columns: repeat(4, 1fr);
    }
    
    .gallery-grid {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    }
}