/* 全局基础设置 */
body {
    background-color: #f0f2f5;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    font-family: 'Inter', 'Noto Sans SC', sans-serif;
    font-weight: 400;
    line-height: 1.6;
    min-height: 100vh;
}

html, body {
    height: 100%;
    margin: 0;
    padding: 0;
}

/* 字体优化 */
h1, h2, h3, h4, h5, h6 {
    font-weight: 600;
    letter-spacing: -0.02em;
}

p {
    font-size: 16px;
    color: #4b5563;
}

/* 增强毛玻璃效果 */
.glass-panel {
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.6);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.08);
    transition: all 0.3s ease;
}

.glass-panel:hover {
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.12);
    transform: translateY(-2px);
}

.glass-sidebar {
    background: rgba(15, 23, 42, 0.95);
    backdrop-filter: blur(30px);
    -webkit-backdrop-filter: blur(30px);
    border-right: 1px solid rgba(255, 255, 255, 0.15);
}

/* 极光背景动画 */
.aurora-bg {
    position: fixed;
    top: 0; left: 0; width: 100vw; height: 100vh;
    z-index: -1;
    overflow: hidden;
    background: #f8fafc;
}
.blob {
    position: absolute;
    filter: blur(80px);
    opacity: 0.6;
    animation: blob 10s infinite alternate cubic-bezier(0.4, 0, 0.2, 1);
}
.blob-1 { top: -10%; left: -10%; width: 50vw; height: 50vw; background: #d1fae5; animation-delay: 0s; }
.blob-2 { top: -10%; right: -10%; width: 50vw; height: 50vw; background: #e0e7ff; animation-delay: 2s; }
.blob-3 { bottom: -20%; left: 20%; width: 50vw; height: 50vw; background: #fef3c7; animation-delay: 4s; }

/* 毛玻璃效果 - 已合并到上方 */


/* 登录遮罩 */
.login-overlay {
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(8px);
}

/* 自定义滚动条 */
.scrollbar-hide::-webkit-scrollbar { display: none; }
.scrollbar-custom::-webkit-scrollbar { width: 6px; height: 6px; }
.scrollbar-custom::-webkit-scrollbar-track { background: transparent; }
.scrollbar-custom::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 10px; }
.scrollbar-custom::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

/* 卡片悬浮特效 */
.hover-card {
    transition: all 0.3s ease;
}
.hover-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 24px -10px rgba(0, 0, 0, 0.1);
}

/* 进度条流光效果 */
.progress-bar-shine {
    background: linear-gradient(90deg, #10B981, #34d399, #10B981);
    background-size: 200% 100%;
    animation: shimmer 2s linear infinite;
}

/* 移动端导航 */
.bottom-nav {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(20px);
    border-top: 1px solid rgba(0, 0, 0, 0.08);
    box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.04);
    display: none; /* 默认隐藏，在移动端显示 */
}

/* 移动端优化 */
@media (max-width: 768px) {
    body {
        font-size: 14px;
    }
    
    h1 {
        font-size: 24px;
    }
    
    h2 {
        font-size: 20px;
    }
    
    h3 {
        font-size: 18px;
    }
    
    p {
        font-size: 14px;
    }
    
    .glass-panel {
        margin: 0 16px;
        border-radius: 16px;
    }
    
    .blob-1, .blob-2, .blob-3 {
        width: 80vw;
        height: 80vw;
    }
}

/* 细节微调 */
.nav-active-indicator {
    background: linear-gradient(135deg, #10B981 0%, #059669 100%);
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.4);
}

/* 情绪晴雨表页面UI优化 */

/* 1. 日期选择器样式优化 */
input[type="date"] {
    /* 隐藏原生箭头 */
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: textfield;
    
    /* 添加自定义箭头 */
    background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="%236b7280" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="6 9 12 15 18 9"></polyline></svg>');
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 16px;
    
    /* 自定义样式 */
    transition: all 0.3s ease;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

input[type="date"]:focus {
    box-shadow: 0 4px 12px rgba(139, 92, 246, 0.15), 0 0 0 2px rgba(139, 92, 246, 0.2);
    transform: translateY(-1px);
}

/* 2. 心情指数滑块和表情动画优化 */
#emotion-emoji {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    transform-origin: center center;
    animation: emojiBounce 2s ease-in-out infinite;
}

/* 表情弹跳动画 */
@keyframes emojiBounce {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.05);
    }
}

/* 滑块容器 */
input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    height: 12px;
    background: linear-gradient(to right, rgba(239, 68, 68, 0.2), rgba(250, 204, 21, 0.2), rgba(34, 197, 94, 0.2));
    border-radius: 6px;
    outline: none;
    position: relative;
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.1);
}

/* 滑块轨道 */
input[type="range"]::-webkit-slider-runnable-track {
    height: 12px;
    background: linear-gradient(to right, rgba(239, 68, 68, 0.2), rgba(250, 204, 21, 0.2), rgba(34, 197, 94, 0.2));
    border-radius: 6px;
    position: relative;
}

/* 滑块进度 */
input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 24px;
    height: 24px;
    background: white;
    border: 3px solid #8b5cf6;
    border-radius: 50%;
    cursor: pointer;
    margin-top: -6px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15), 0 0 0 1px rgba(139, 92, 246, 0.3);
    position: relative;
    z-index: 1;
    animation: thumbPulse 2s ease-in-out infinite;
}

/* 滑块悬停和拖动效果 */
input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.2);
    box-shadow: 0 4px 12px rgba(139, 92, 246, 0.3), 0 0 0 2px rgba(139, 92, 246, 0.4);
    animation: none;
}

input[type="range"]::-webkit-slider-thumb:active {
    transform: scale(1.1);
    box-shadow: 0 2px 6px rgba(139, 92, 246, 0.4), 0 0 0 2px rgba(139, 92, 246, 0.5);
    animation: none;
}

/* 滑块脉动动画 */
@keyframes thumbPulse {
    0%, 100% {
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15), 0 0 0 1px rgba(139, 92, 246, 0.3);
    }
    50% {
        box-shadow: 0 4px 16px rgba(139, 92, 246, 0.25), 0 0 0 2px rgba(139, 92, 246, 0.4);
    }
}

/* Firefox 滑块样式 */
input[type="range"]::-moz-range-thumb {
    width: 24px;
    height: 24px;
    background: white;
    border: 3px solid #8b5cf6;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15), 0 0 0 1px rgba(139, 92, 246, 0.3);
}

input[type="range"]::-moz-range-thumb:hover {
    transform: scale(1.2);
    box-shadow: 0 4px 12px rgba(139, 92, 246, 0.3), 0 0 0 2px rgba(139, 92, 246, 0.4);
}

/* 3. 页面布局优化，减少滚动 */
.h-full {
    height: 100vh; /* Fallback */
    height: 100dvh;
    overflow: hidden;
}

/* 主内容区域 */
.h-full > .flex-1 {
    max-height: calc(100vh - 4rem); /* Fallback */
    max-height: calc(100dvh - 4rem);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch; /* iOS smooth scrolling */
    scrollbar-width: thin;
    scrollbar-color: rgba(139, 92, 246, 0.3) transparent;
}

/* ... (scrollbar styles) ... */

/* 右侧面板 */
.lg\:w-96 {
    max-height: calc(100vh - 4rem);
    max-height: calc(100dvh - 4rem);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    scrollbar-color: rgba(139, 92, 246, 0.3) transparent;
}

/* ... (scrollbar styles) ... */

/* 响应式设计 */
@media (max-width: 1024px) {
    .h-full {
        height: auto;
        min-height: 100dvh;
        overflow: visible;
    }
    
    .h-full > .flex-1,
    .lg\:w-96 {
        max-height: none;
        overflow-y: auto;
    }
    
    /* Ensure body scrolls on mobile if content is long */
    body {
        overflow-x: hidden !important;
        overflow-y: auto !important;
        height: auto !important;
    }
}
.emotion-tag {
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    transform-origin: center center;
}

.emotion-tag:hover {
    transform: scale(1.05) translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.emotion-tag.bg-brand-500 {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(139, 92, 246, 0.2);
    animation: tagPulse 1s ease-in-out;
}

/* 标签选中动画 */
@keyframes tagPulse {
    0% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.1);
    }
    100% {
        transform: scale(1.05);
    }
}

/* 保存按钮动画优化 */
#btn-save-emotion {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    transform-origin: center center;
    position: relative;
    overflow: hidden;
}

#btn-save-emotion::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.3);
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s;
}

#btn-save-emotion:hover::before {
    width: 300px;
    height: 300px;
}

#btn-save-emotion:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
}

#btn-save-emotion:active {
    transform: translateY(0);
    box-shadow: 0 6px 15px rgba(0, 0, 0, 0.15);
}

/* 表单区域优化 */
#emotion-form {
    gap: 1.25rem;
}

/* 每个表单区块优化 */
.bg-white\/50 {
    padding: 1.25rem;
    border-radius: 1.5rem;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.bg-white\/50:hover {
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
    transform: translateY(-1px);
}

/* 文本域优化 */
textarea {
    resize: vertical;
    min-height: 80px;
    max-height: 150px;
    transition: all 0.3s ease;
}

textarea:focus {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(139, 92, 246, 0.15), 0 0 0 2px rgba(139, 92, 246, 0.2);
}

/* 趋势图容器优化 */
.chart-container {
    min-height: 200px;
}

/* 最近记录卡片优化 */
#emotion-history-list > div {
    transition: all 0.3s ease;
}

#emotion-history-list > div:hover {
    transform: translateX(4px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

/* AI分析结果样式优化 */
.ai-result-container {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Arial, sans-serif;
    line-height: 1.6;
}

.ai-section {
    margin-bottom: 16px;
    padding: 12px;
    background-color: rgba(255, 255, 255, 0.8);
    border-radius: 12px;
    border-left: 4px solid #6366f1;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    transition: all 0.3s ease;
}

.ai-section:last-child {
    margin-bottom: 0;
}

.ai-section:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    transform: translateY(-1px);
}

.ai-section-title {
    font-size: 14px;
    font-weight: bold;
    color: #4f46e5;
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.ai-section-title::before {
    content: "🤖";
    font-size: 16px;
}

.ai-section-content {
    font-size: 13px;
    color: #374151;
    white-space: pre-wrap;
    line-height: 1.7;
}

.ai-section-content ul {
    margin: 8px 0;
    padding-left: 20px;
}

.ai-section-content li {
    margin: 4px 0;
    list-style-type: disc;
}

.ai-section-content strong {
    color: #1f2937;
    font-weight: 600;
}

/* 加载动画 */
@keyframes spin {
    to { transform: rotate(360deg); }
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

@keyframes shimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

.loading-spinner {
    display: inline-block;
    width: 40px;
    height: 40px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: #10B981;
    animation: spin 1s ease-in-out infinite;
}

.loading-spinner-sm {
    width: 20px;
    height: 20px;
    border-width: 2px;
}

.loading-dots {
    display: inline-flex;
    gap: 4px;
}

.loading-dots span {
    width: 8px;
    height: 8px;
    background-color: #10B981;
    border-radius: 50%;
    animation: pulse 1.4s ease-in-out infinite;
}

.loading-dots span:nth-child(1) { animation-delay: 0s; }
.loading-dots span:nth-child(2) { animation-delay: 0.2s; }
.loading-dots span:nth-child(3) { animation-delay: 0.4s; }

/* 骨架屏样式 */
.skeleton {
    background: linear-gradient(
        90deg,
        #f0f0f0 25%,
        #e0e0e0 50%,
        #f0f0f0 75%
    );
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: 4px;
}

.skeleton-text {
    height: 16px;
    margin-bottom: 8px;
}

.skeleton-text-lg {
    height: 24px;
    margin-bottom: 12px;
}

.skeleton-text-sm {
    height: 12px;
    margin-bottom: 6px;
}

.skeleton-block {
    height: 100px;
    border-radius: 8px;
}

.skeleton-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
}

.skeleton-card {
    background: white;
    padding: 16px;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.skeleton-heatmap {
    height: 32px;
    width: 100%;
    border-radius: 4px;
}

/* 页面加载遮罩 */
.page-loading {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.9);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    transition: opacity 0.3s ease;
}

.page-loading.hidden {
    opacity: 0;
    pointer-events: none;
}

.page-loading-text {
    margin-top: 16px;
    color: #6b7280;
    font-size: 14px;
}

/* 内容加载状态 */
.content-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px;
    min-height: 200px;
}

/* 按钮加载状态 */
.btn-loading {
    position: relative;
    pointer-events: none;
    opacity: 0.7;
}

.btn-loading::after {
    content: '';
    position: absolute;
    width: 16px;
    height: 16px;
    border: 2px solid transparent;
    border-top-color: currentColor;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
}

/* 响应式设计 */
/* 平板设备优化 (768px - 1024px) */
@media (max-width: 1024px) and (min-width: 768px) {
    .glass-panel {
        padding: 1.25rem;
    }
    
    .text-2xl {
        font-size: 1.5rem;
    }
    
    .text-xl {
        font-size: 1.25rem;
    }
}

/* 移动设备优化 (小于768px) */
@media (max-width: 768px) {
    .h-full {
        height: auto;
        min-height: 100dvh;
        overflow: visible;
    }
    
    .h-full > .flex-1,
    .lg\:w-96 {
        max-height: none;
        overflow-y: visible;
    }
    
    /* Ensure body scrolls on mobile if content is long */
    body {
        overflow-y: auto !important;
        height: auto !important;
    }
    
    /* 字体大小调整 */
    h1 { font-size: 1.75rem; }
    h2 { font-size: 1.5rem; }
    h3 { font-size: 1.25rem; }
    p { font-size: 14px; }
    
    /* 按钮和交互元素优化 */
    button, .btn {
        min-height: 44px;
        padding: 0.75rem 1rem;
        font-size: 14px;
    }
    
    /* 输入框优化 */
    input, textarea, select {
        min-height: 44px;
        font-size: 16px; /* 防止iOS自动缩放 */
    }
    
    /* 卡片间距优化 */
    .glass-panel {
        margin-bottom: 1rem;
        padding: 1rem;
    }
    
    /* 热力图网格优化 */
    #heatmap-container {
        grid-template-columns: repeat(6, 1fr);
        gap: 0.5rem;
    }
    
    /* 图表容器优化 */
    .chart-container {
        min-height: 150px;
    }
    
    /* 侧边栏隐藏（使用底部导航） */
    .glass-sidebar {
        display: none;
    }
    
    /* 底部导航栏 */
    .bottom-nav {
        display: flex;
    }
    
    /* 内容区域底部空间优化 */
    #content-area {
        padding-bottom: 80px !important; /* 为底部导航留出空间 */
    }
}

/* 小屏幕设备优化 (小于480px) */
@media (max-width: 480px) {
    /* 更紧凑的布局 */
    .glass-panel {
        padding: 0.75rem;
        margin-bottom: 0.75rem;
    }
    
    /* 热力图进一步优化 */
    #heatmap-container {
        grid-template-columns: repeat(4, 1fr);
        gap: 0.25rem;
    }
    
    /* 按钮全宽 - 仅对主要操作按钮 */
    .glass-panel button.btn-full-width {
        width: 100%;
        margin-bottom: 0.5rem;
    }
    
    /* 表单元素全宽 */
    .glass-panel input,
    .glass-panel textarea,
    .glass-panel select {
        width: 100%;
    }
    
    /* 文本大小调整 */
    .text-sm {
        font-size: 12px;
    }
    
    .text-xs {
        font-size: 10px;
    }
}

/* 触摸设备优化 */
@media (hover: none) and (pointer: coarse) {
    /* 增大可点击区域 */
    button, a, .clickable {
        min-width: 44px;
        min-height: 44px;
    }
    
    /* 移除悬停效果 */
    .glass-panel:hover,
    button:hover,
    a:hover {
        transform: none;
    }
    
    /* 添加触摸反馈 */
    button:active,
    a:active {
        opacity: 0.7;
        transform: scale(0.98);
    }
}

/* 横屏模式优化 */
@media (max-height: 500px) and (orientation: landscape) {
    /* 减少垂直间距 */
    .glass-panel {
        padding: 0.5rem;
        margin-bottom: 0.5rem;
    }
    
    /* 调整图表高度 */
    .chart-container {
        min-height: 120px;
    }
    
    /* 调整热力图 */
    #heatmap-container {
        grid-template-rows: repeat(2, 1fr);
    }
}

/* 高分辨率屏幕优化 */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    /* 更清晰的边框 */
    .glass-panel {
        border-width: 0.5px;
    }
    
    /* 更清晰的文字 */
    body {
        -webkit-font-smoothing: antialiased;
        -moz-osx-font-smoothing: grayscale;
    }
}

/* 打印样式优化 */
@media print {
    /* 隐藏不必要的元素 */
    .bottom-nav,
    .glass-sidebar,
    #confetti-canvas,
    .aurora-bg,
    button:not(.print-button) {
        display: none !important;
    }
    
    /* 调整背景 */
    body {
        background: white;
    }
    
    .glass-panel {
        background: white;
        box-shadow: none;
        border: 1px solid #ccc;
        page-break-inside: avoid;
    }
    
    /* 确保文本可读 */
    * {
        color: black !important;
    }
}
