/* 基础重置和变量定义 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent; /* 移除移动端点击高亮 */
}

:root {
    /* 主色调 */
    --primary-color: #FF8C42;
    --secondary-color: #4A90E2;
    --success-color: #27AE60;
    --warning-color: #E74C3C;
    
    /* 背景色 */
    --bg-primary: #FAFAFA;
    --bg-secondary: #FFFFFF;
    --bg-tertiary: #F5F5F5;
    
    /* 文字色 */
    --text-primary: #333333;
    --text-secondary: #666666;
    --text-muted: #999999;
    
    /* 边框色 */
    --border-light: #E5E5E5;
    --border-medium: #CCCCCC;
    
    /* 阴影 */
    --shadow-light: 0 2px 8px rgba(0, 0, 0, 0.1);
    --shadow-medium: 0 4px 16px rgba(0, 0, 0, 0.15);
    --shadow-hover: 0 8px 24px rgba(0, 0, 0, 0.2);
    
    /* 圆角 */
    --radius-small: 8px;
    --radius-medium: 12px;
    --radius-large: 16px;
    
    /* 间距 */
    --spacing-xs: 8px;
    --spacing-sm: 16px;
    --spacing-md: 24px;
    --spacing-lg: 32px;
    --spacing-xl: 48px;
    
    /* 字体 */
    --font-family: 'Inter', 'PingFang SC', 'Microsoft YaHei', sans-serif;
}

/* 基础样式 */
html {
    font-size: 16px; /* 基础字体大小 */
    height: 100%;
    width: 100%;
}

body {
    font-family: var(--font-family);
    background-color: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    overflow-x: hidden; /* 防止水平滚动 */
    -webkit-font-smoothing: antialiased; /* 字体平滑 */
    -moz-osx-font-smoothing: grayscale;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 var(--spacing-sm);
    width: 100%;
}

/* 头部布局 */
.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo-container {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
}

.logo {
    font-size: 28px;
    font-weight: 700;
    margin-bottom: 2px;
}

.slogan {
    font-size: 14px;
    color: rgba(255, 255, 255, 0.9);
    font-weight: 400;
    letter-spacing: 0.5px;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* 添加按钮 */
.add-btn {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    font-size: 24px;
    font-weight: 300;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    -webkit-tap-highlight-color: transparent;
}

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

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

/* 头部样式 */
.header {
    background: linear-gradient(135deg, var(--primary-color), #FF9D5C);
    color: white;
    padding: var(--spacing-sm) 0;
    box-shadow: var(--shadow-light);
    position: sticky;
    top: 0;
    z-index: 100;
}

/* 主要内容区域 */
.main {
    padding: var(--spacing-sm) 0;
}

/* 目标部分 */
.goals-section {
    margin-top: var(--spacing-xs);
}

/* 筛选标签 */
.filter-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: var(--spacing-md);
}

.filter-tab {
    background: var(--bg-secondary);
    border: 1px solid var(--border-light);
    padding: 8px var(--spacing-sm);
    border-radius: var(--radius-medium);
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 14px;
    touch-action: manipulation;
    user-select: none;
    -webkit-user-select: none;
}

.filter-tab:hover {
    background: var(--bg-tertiary);
}

.filter-tab.active {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

/* 目标网格 */
.goals-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: var(--spacing-md);
    margin-bottom: var(--spacing-lg);
}

/* 目标卡片 */
.goal-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-medium);
    padding: var(--spacing-sm);
    box-shadow: var(--shadow-light);
    transition: all 0.2s ease;
    position: relative;
    overflow: visible; /* 修改为visible，允许菜单溢出 */
}

.goal-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-hover);
}

.goal-card.completed {
    background: linear-gradient(135deg, #f8fff8, #e8f5e8);
    border-color: var(--success-color);
}

.goal-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
    position: relative;
}

.goal-icon {
    font-size: 24px;
}

.goal-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
    flex: 1;
    word-break: break-word; /* 防止长文本溢出 */
}

.priority-badge {
    padding: 4px 8px;
    border-radius: var(--radius-small);
    font-size: 12px;
    font-weight: 500;
    white-space: nowrap; /* 防止换行 */
}

.priority-high {
    background: #ffebee;
    color: var(--warning-color);
}

.priority-medium {
    background: #fff8e1;
    color: #f57c00;
}

.priority-low {
    background: #e8f5e8;
    color: var(--success-color);
}

.goal-description {
    color: var(--text-secondary);
    font-size: 14px;
    margin-bottom: 8px;
    line-height: 1.4;
    word-break: break-word;
}

.goal-deadline {
    font-size: 13px;
    color: var(--text-muted);
}

.goal-deadline.overdue {
    color: var(--warning-color);
    font-weight: 500;
}

/* 删除旧的目标卡片按钮样式 */
/* 目标卡片底部布局 */
.goal-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-top: var(--spacing-sm);
}

/* 目标卡片按钮样式优化 */
.goal-actions {
    display: none; /* 隐藏旧的按钮容器 */
}

.btn {
    padding: var(--spacing-xs) var(--spacing-sm);
    border: none;
    border-radius: var(--radius-small);
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s ease;
    /* 移动端优化 */
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    touch-action: manipulation;
    min-height: 36px; /* 增加触摸区域 */
}

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

.btn-primary:hover {
    background: #e67a36;
}

.btn-secondary {
    background: var(--bg-tertiary);
    color: var(--text-secondary);
}

.btn-secondary:hover {
    background: var(--border-medium);
}

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

.btn-success:hover {
    background: #229954;
}

.btn-danger {
    background: var(--warning-color);
    color: white;
}

.btn-danger:hover {
    background: #c0392b;
}

/* 空状态 */
.empty-state {
    text-align: center;
    padding: var(--spacing-xl);
    color: var(--text-muted);
    display: none;
}

.empty-state.show {
    display: block;
}

.empty-icon {
    font-size: 64px;
    margin-bottom: var(--spacing-md);
}

.empty-state h3 {
    font-size: 20px;
    margin-bottom: var(--spacing-sm);
    color: var(--text-secondary);
}

/* 模态框 */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.modal-overlay.show {
    opacity: 1;
    visibility: visible;
}

.modal {
    background: var(--bg-secondary);
    border-radius: var(--radius-medium);
    box-shadow: var(--shadow-medium);
    width: 90%;
    max-width: 480px;
    max-height: 85vh;
    overflow-y: auto;
    transform: scale(0.9);
    transition: transform 0.3s ease;
    margin: auto;
}

.modal-overlay.show .modal {
    transform: scale(1);
}

.modal-header {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border-light);
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    background: var(--bg-secondary);
    z-index: 10;
}

.modal-header h3 {
    font-size: 18px;
    font-weight: 600;
}

.close-btn {
    background: none;
    border: none;
    font-size: 22px;
    cursor: pointer;
    color: var(--text-muted);
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.2s ease;
    touch-action: manipulation;
}

.close-btn:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.modal-body {
    padding: 16px;
}

.modal-footer {
    padding: 12px 16px;
    border-top: 1px solid var(--border-light);
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    position: sticky;
    bottom: 0;
    background: var(--bg-secondary);
    z-index: 10;
}

/* 表单样式 */
.form-group {
    margin-bottom: 14px;
}

.form-group label {
    display: block;
    margin-bottom: 4px;
    font-weight: 500;
    color: var(--text-primary);
    font-size: 14px;
}

.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--border-light);
    border-radius: var(--radius-small);
    font-size: 15px;
    transition: border-color 0.2s ease;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    background-color: var(--bg-secondary);
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--primary-color);
}

.form-group textarea {
    resize: vertical;
    min-height: 60px;
}

/* 图标选择器 */
.icon-selector {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 4px;
}

.icon-option {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid var(--border-light);
    border-radius: var(--radius-small);
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 18px;
    touch-action: manipulation;
}

.icon-option:hover {
    border-color: var(--primary-color);
    background: #fff5f0;
}

.icon-option.active {
    border-color: var(--primary-color);
    background: var(--primary-color);
    color: white;
}

/* 庆祝动画 */
.celebration {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
    z-index: 9999;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.celebration.show {
    opacity: 1;
}

.confetti {
    width: 100%;
    height: 100%;
    background: radial-gradient(circle, transparent 20%, rgba(255, 140, 66, 0.3) 20.1%, rgba(255, 140, 66, 0.3) 40%, transparent 40.1%),
                radial-gradient(circle at 75% 25%, transparent 20%, rgba(74, 144, 226, 0.3) 20.1%, rgba(74, 144, 226, 0.3) 40%, transparent 40.1%),
                radial-gradient(circle at 25% 75%, transparent 20%, rgba(39, 174, 96, 0.3) 20.1%, rgba(39, 174, 96, 0.3) 40%, transparent 40.1%);
    animation: confetti-fall 3s ease-out;
}

@keyframes confetti-fall {
    0% {
        transform: translateY(-100vh) rotate(0deg);
    }
    100% {
        transform: translateY(100vh) rotate(360deg);
    }
}

/* Toast 通知 */
.toast {
    position: fixed;
    bottom: var(--spacing-md);
    left: 50%;
    transform: translateX(-50%) translateY(100%);
    background: var(--success-color);
    color: white;
    padding: var(--spacing-sm) var(--spacing-md);
    border-radius: var(--radius-medium);
    box-shadow: var(--shadow-medium);
    z-index: 1001;
    transition: transform 0.3s ease, opacity 0.3s ease;
    text-align: center;
    max-width: 90%;
    width: auto;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.toast.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
    visibility: visible;
}

.toast.error {
    background: var(--warning-color);
}

/* 响应式设计 */
@media (max-width: 768px) {
    :root {
        /* 调整移动端间距 */
        --spacing-lg: 24px;
        --spacing-xl: 32px;
    }
    
    .container {
        padding: 0 var(--spacing-sm);
    }
    
    .goals-grid {
        grid-template-columns: 1fr;
        gap: var(--spacing-sm);
    }
    
    .progress-stats {
        gap: var(--spacing-md);
    }
    
    .filter-tabs {
        gap: 6px;
        margin-bottom: var(--spacing-md);
    }
    
    .filter-tab {
        flex: 1;
        text-align: center;
        white-space: nowrap;
        padding: 8px 12px;
    }
    
    .modal {
        width: 95%;
        margin: var(--spacing-sm);
        max-height: 85vh;
    }
    
    .goal-actions {
        flex-wrap: wrap;
        gap: 8px;
    }
    
    .icon-selector {
        justify-content: center;
        gap: 12px;
    }
    
    .icon-option {
        width: 44px;
        height: 44px;
    }
    
    /* 改进移动端按钮布局 */
    .goal-actions .btn {
        flex: 1;
        min-width: calc(50% - 4px);
        justify-content: center;
        display: flex;
        align-items: center;
    }
    
    /* 导出/导入按钮样式优化 */
    #exportBtn, 
    label[for="importFile"] {
        padding: 8px 12px !important;
        font-size: 14px !important;
    }
    
    /* 头部导出/导入按钮容器 */
    .header .container > div > div {
        justify-content: center;
        margin-top: 12px;
    }
    
    /* 模态框全屏显示 */
    @media (max-height: 600px) {
        .modal {
            height: 100vh;
            max-height: 100vh;
            width: 100%;
            margin: 0;
            border-radius: 0;
        }
    }
}

@media (max-width: 480px) {
    html {
        font-size: 15px; /* 稍微缩小基础字体 */
    }
    
    .logo {
        font-size: 22px;
    }

    .slogan {
        font-size: 12px;
        letter-spacing: 0.3px;
    }
    
    .add-goal-btn {
        font-size: 16px;
        padding: var(--spacing-sm) var(--spacing-md);
        width: 90%;
        justify-content: center;
    }
    
    .progress-card {
        padding: var(--spacing-sm);
    }
    
    .progress-overview h2,
    .goals-section h2 {
        font-size: 20px;
    }
    
    .goal-card {
        padding: var(--spacing-sm);
    }
    
    .progress-stats {
        justify-content: space-around;
    }
    
    .goal-header {
        flex-wrap: wrap;
    }
    
    .goal-title {
        font-size: 17px;
        margin-right: 8px;
    }
    
    .modal-header h3 {
        font-size: 18px;
    }
    
    .btn {
        min-height: 42px; /* 更大的触摸区域 */
    }
    
    /* 全宽按钮 */
    .goal-actions .btn {
        flex: 1 0 100%;
        margin: 2px 0;
    }
    
    /* 调整表单元素大小 */
    .form-group input,
    .form-group select {
        height: 44px;
    }
    
    /* 移动端按钮样式优化 */
    .goal-actions {
        flex-wrap: nowrap;
        gap: 6px;
    }
    
    .goal-actions .btn {
        flex: 0 1 auto; /* 覆盖之前的全宽设置 */
        min-width: auto; /* 移除最小宽度限制 */
        margin: 0; /* 移除边距 */
    }
}

/* 安全区适配（针对全面屏手机） */
@supports (padding: max(0px)) {
    .header, 
    .modal-header,
    .modal-footer {
        padding-left: max(var(--spacing-md), env(safe-area-inset-left));
        padding-right: max(var(--spacing-md), env(safe-area-inset-right));
    }
    
    .container {
        padding-left: max(var(--spacing-sm), env(safe-area-inset-left));
        padding-right: max(var(--spacing-sm), env(safe-area-inset-right));
    }
    
    .toast {
        bottom: max(var(--spacing-md), env(safe-area-inset-bottom));
    }
}

/* 添加移动端触摸反馈 */
@media (hover: none) {
    .btn:active,
    .filter-tab:active,
    .icon-option:active,
    .add-goal-btn:active {
        opacity: 0.7;
    }
    
    /* 移除悬停效果，改为触摸反馈 */
    .goal-card:hover {
        transform: none;
        box-shadow: var(--shadow-light);
    }
    
    .goal-card:active {
        transform: scale(0.98);
    }
}

/* 动画增强 */
.goal-card {
    animation: slideInUp 0.3s ease-out;
}

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

/* 完成状态动画 */
.goal-card.completing {
    animation: completeGoal 0.6s ease-out;
}

@keyframes completeGoal {
    0% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.05);
    }
    100% {
        transform: scale(1);
    }
}

/* 设置菜单 */
.settings-menu {
    position: relative;
}

.settings-btn {
    background: none;
    border: none;
    color: white;
    font-size: 24px;
    cursor: pointer;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s ease;
    -webkit-tap-highlight-color: transparent;
}

.settings-btn:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

.settings-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    background: var(--bg-secondary);
    border-radius: var(--radius-medium);
    box-shadow: var(--shadow-medium);
    min-width: 160px;
    padding: 8px 0;
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px);
    transition: all 0.2s ease;
    z-index: 1000;
}

.settings-dropdown.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.dropdown-item {
    display: flex;
    align-items: center;
    padding: 10px 16px;
    color: var(--text-primary);
    font-size: 14px;
    background: none;
    border: none;
    width: 100%;
    cursor: pointer;
    transition: background-color 0.2s ease;
    text-align: left;
}

.dropdown-item:hover {
    background-color: var(--bg-tertiary);
}

.item-icon {
    margin-right: 8px;
    font-size: 16px;
}

/* 移动端适配 */
@media (max-width: 480px) {
    .settings-dropdown {
        right: -8px; /* 调整下拉菜单位置 */
    }
    
    .dropdown-item {
        padding: 12px 16px; /* 增加点击区域 */
    }
}

/* 配置弹窗样式 */
.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    user-select: none;
    padding: 4px 0;
}

.checkbox-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    margin: 0;
    cursor: pointer;
    accent-color: var(--primary-color);
    position: relative;
    vertical-align: middle;
}

.checkbox-label:hover {
    color: var(--primary-color);
}

.checkbox-label input[type="checkbox"]:focus {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

/* 表单控件样式 */
.form-control {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--border-light);
    border-radius: var(--radius-small);
    font-size: 15px;
    transition: border-color 0.2s ease;
    background-color: var(--bg-secondary);
}

.form-control:focus {
    outline: none;
    border-color: var(--primary-color);
}

/* 确保在移动端有足够的点击区域 */
@media (max-width: 480px) {
    .checkbox-label {
        padding: 8px 0;
    }

    .checkbox-label input[type="checkbox"] {
        width: 20px;
        height: 20px;
    }

    .form-control {
        font-size: 16px; /* 防止iOS缩放 */
    }
}

/* 确保配置弹窗在其他弹窗之上 */
#configModalOverlay {
    z-index: 1001;
}

/* 自定义复选框样式 */
.checkbox-label input[type="checkbox"] {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    background-color: var(--bg-secondary);
    border: 2px solid var(--border-medium);
    border-radius: 4px;
    position: relative;
    transition: all 0.2s ease;
}

.checkbox-label input[type="checkbox"]:checked {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
}

.checkbox-label input[type="checkbox"]:checked::after {
    content: '';
    position: absolute;
    left: 5px;
    top: 2px;
    width: 5px;
    height: 10px;
    border: solid white;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

.checkbox-label:hover input[type="checkbox"]:not(:checked) {
    border-color: var(--primary-color);
}

/* 卡片菜单样式 */
.card-menu {
    position: relative;
    margin-left: auto;
    z-index: 110; /* 提高z-index确保菜单在其他元素之上 */
}

.card-menu-btn {
    width: 28px;
    height: 28px;
    font-size: 18px;
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    padding: 0;
}

.card-menu-btn:hover {
    background-color: var(--bg-tertiary);
    color: var(--text-primary);
}

.card-menu-dropdown {
    position: absolute;
    top: calc(100% + 2px);
    right: -5px;
    width: auto;
    min-width: 140px;
    max-width: 80vw;
    border-radius: var(--radius-medium);
    transform: translateY(0);
    box-shadow: var(--shadow-medium);
    padding: 4px 0;
    background: var(--bg-secondary);
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s ease;
    z-index: 120; /* 提高z-index确保下拉菜单在其他元素之上 */
    overflow: visible;
    border: 1px solid var(--border-light);
}

/* 当菜单显示在上方时的样式 */
.card-menu-dropdown.top {
    top: auto;
    bottom: calc(100% + 2px);
}

.card-menu-dropdown.show {
    opacity: 1;
    visibility: visible;
}

.card-menu-dropdown .dropdown-item {
    display: flex;
    align-items: center;
    padding: 10px 14px;
    color: var(--text-primary);
    font-size: 15px;
    background: none;
    border: none;
    width: 100%;
    cursor: pointer;
    transition: background-color 0.2s ease;
    text-align: left;
    white-space: nowrap; /* 防止文本换行 */
}

.card-menu-dropdown .dropdown-item:hover {
    background-color: var(--bg-tertiary);
}

.card-menu-dropdown .dropdown-item .item-icon {
    margin-right: 8px;
    font-size: 15px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
}

/* 确保菜单不会超出屏幕边界 */
.card-menu {
    position: relative;
    margin-left: auto;
}

.card-menu-btn {
    width: 28px;
    height: 28px;
    font-size: 18px;
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    padding: 0;
}

.card-menu-btn:hover {
    background-color: var(--bg-tertiary);
    color: var(--text-primary);
}

/* 移动端适配 */
@media (max-width: 480px) {
    .card-menu-btn {
        width: 32px;
        height: 32px;
        font-size: 20px;
    }
} 