/**
 * 金数网全局样式文件
 */

/* 基础样式重置 */
* {
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: 'Inter', system-ui, sans-serif;
}

/* 主题过渡 - 全局平滑切换 */
html {
    transition: background-color 0.4s ease, color 0.4s ease;
}

.theme-transition {
    transition: background-color 0.4s ease, color 0.4s ease, border-color 0.4s ease, box-shadow 0.4s ease;
}

.dark {
    color-scheme: dark;
}

/* 骨架屏动画 */
.shimmer {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
}

.dark .shimmer {
    background: linear-gradient(90deg, #374151 25%, #4b5563 50%, #374151 75%);
    background-size: 200% 100%;
}

@keyframes shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* 淡入动画 */
.animate-fade-in {
    animation: fadeIn 0.3s ease-out;
}

/* 价格变化动画 */
.price-up {
    animation: priceUpFlash 0.6s ease-out;
}

.price-down {
    animation: priceDownFlash 0.6s ease-out;
}

@keyframes priceUpFlash {
    0%, 100% { 
        background-color: transparent;
        color: inherit;
    }
    50% { 
        background-color: rgba(34, 197, 94, 0.3);
        color: #22c55e;
    }
}

@keyframes priceDownFlash {
    0%, 100% { 
        background-color: transparent;
        color: inherit;
    }
    50% { 
        background-color: rgba(239, 68, 68, 0.3);
        color: #ef4444;
    }
}

/* 深色模式下的价格动画 */
.dark .price-up {
    animation: priceUpFlashDark 0.6s ease-out;
}

.dark .price-down {
    animation: priceDownFlashDark 0.6s ease-out;
}

@keyframes priceUpFlashDark {
    0%, 100% { 
        background-color: transparent;
        color: inherit;
    }
    50% { 
        background-color: rgba(34, 197, 94, 0.2);
        color: #4ade80;
    }
}

@keyframes priceDownFlashDark {
    0%, 100% { 
        background-color: transparent;
        color: inherit;
    }
    50% { 
        background-color: rgba(239, 68, 68, 0.2);
        color: #f87171;
    }
}

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

/* 跑马灯广告 */
.marquee-ad {
    position: relative;
    overflow: hidden;
}

.marquee-container {
    display: flex;
    animation: marquee 10s linear infinite;
    white-space: nowrap;
}

.marquee-text {
    display: inline-block;
    padding-right: 50px; /* 文字间距 */
}

@keyframes marquee {
    0% {
        transform: translateX(100%);
    }
    100% {
        transform: translateX(-100%);
    }
}

/* 图片广告 */
.image-ad img {
    transition: transform 0.3s ease;
}

.image-ad:hover img {
    transform: scale(1.02);
}

/* 深色模式下广告样式 */
.dark .marquee-ad {
    background: linear-gradient(to right, #3b82f6, #2563eb);
}

/* 淡出动画 */
.page-transition {
    animation: pageSlideIn 0.35s ease-out;
}

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

/* 涨跌颜色 */
.bg-up {
    background-color: rgba(34, 197, 94, 0.1);
}

.bg-down {
    background-color: rgba(239, 68, 68, 0.1);
}

.text-up {
    color: #22c55e;
}

.text-down {
    color: #ef4444;
}

.dark .text-up {
    color: #4ade80;
}

.dark .text-down {
    color: #f87171;
}

/* 价格卡片涨跌背景增强 */
.card-flash-up {
    animation: cardFlashGreen 0.8s ease-out;
}

.card-flash-down {
    animation: cardFlashRed 0.8s ease-out;
}

@keyframes cardFlashGreen {
    0%, 100% { 
        background-color: inherit;
        border-color: inherit;
    }
    30% { 
        background-color: rgba(34, 197, 94, 0.15);
        border-color: rgba(34, 197, 94, 0.3);
    }
    50% { 
        background-color: rgba(34, 197, 94, 0.1);
        border-color: rgba(34, 197, 94, 0.2);
    }
}

@keyframes cardFlashRed {
    0%, 100% { 
        background-color: inherit;
        border-color: inherit;
    }
    30% { 
        background-color: rgba(239, 68, 68, 0.15);
        border-color: rgba(239, 68, 68, 0.3);
    }
    50% { 
        background-color: rgba(239, 68, 68, 0.1);
        border-color: rgba(239, 68, 68, 0.2);
    }
}

/* 价格变化动画 */
.price-flash-up {
    animation: textFlashGreen 0.6s ease-out;
}

.price-flash-down {
    animation: textFlashRed 0.6s ease-out;
}

@keyframes textFlashGreen {
    0%, 100% { color: inherit; }
    20% { color: #22c55e; text-shadow: 0 0 8px rgba(34, 197, 94, 0.5); }
    40% { color: #16a34a; text-shadow: 0 0 12px rgba(34, 197, 94, 0.6); }
    60% { color: #22c55e; text-shadow: 0 0 6px rgba(34, 197, 94, 0.4); }
    80% { color: #16a34a; text-shadow: 0 0 4px rgba(34, 197, 94, 0.2); }
}

@keyframes textFlashRed {
    0%, 100% { color: inherit; }
    20% { color: #ef4444; text-shadow: 0 0 8px rgba(239, 68, 68, 0.5); }
    40% { color: #dc2626; text-shadow: 0 0 12px rgba(239, 68, 68, 0.6); }
    60% { color: #ef4444; text-shadow: 0 0 6px rgba(239, 68, 68, 0.4); }
    80% { color: #dc2626; text-shadow: 0 0 4px rgba(239, 68, 68, 0.2); }
}

/* 数字滚动动画 */
.number-scroll {
    animation: numberScroll 0.5s ease-out;
}

@keyframes numberScroll {
    0% { 
        opacity: 0;
        transform: translateY(-10px);
    }
    100% { 
        opacity: 1;
        transform: translateY(0);
    }
}

/* 底部导航 */
.bottom-nav {
    padding-bottom: env(safe-area-inset-bottom, 0);
}

.nav-item-active {
    position: relative;
}

.nav-item-active::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 50%;
    transform: translateX(-50%);
    width: 20px;
    height: 2px;
    background: linear-gradient(90deg, #0ea5e9, #38bdf8);
    border-radius: 1px;
    animation: navIndicatorIn 0.3s ease-out;
}

@keyframes navIndicatorIn {
    from {
        width: 0;
        opacity: 0;
    }
    to {
        width: 20px;
        opacity: 1;
    }
}

/* 触摸反馈 */
.touch-feedback {
    transition: transform 0.15s ease, background-color 0.15s ease, opacity 0.15s ease;
    border-radius: 12px;
}

.touch-feedback:active {
    transform: scale(0.95);
    background-color: rgba(14, 165, 233, 0.1);
}

.dark .touch-feedback:active {
    background-color: rgba(14, 165, 233, 0.15);
}

/* 底部导航项触摸反馈增强 */
nav .touch-feedback:active {
    transform: scale(0.92);
    background-color: rgba(14, 165, 233, 0.15);
}

.dark nav .touch-feedback:active {
    background-color: rgba(14, 165, 233, 0.2);
}

/* 下拉刷新 */
.pull-refresh-container {
    position: relative;
    overflow: hidden;
}

.pull-refresh-indicator {
    position: absolute;
    top: -50px;
    left: 50%;
    transform: translateX(-50%);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, #0ea5e9, #38bdf8);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: top 0.3s ease, transform 0.3s ease;
    z-index: 10;
    box-shadow: 0 4px 12px rgba(14, 165, 233, 0.3);
}

.pull-refresh-indicator.pulling {
    top: 10px;
}

.pull-refresh-indicator.refreshing {
    top: 10px;
    animation: refreshSpin 1s linear infinite;
}

@keyframes refreshSpin {
    from { transform: translateX(-50%) rotate(0deg); }
    to { transform: translateX(-50%) rotate(360deg); }
}

.pull-refresh-indicator svg {
    width: 20px;
    height: 20px;
    color: white;
}

/* 加载状态提示 */
.loading-indicator {
    position: fixed;
    top: 70px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(14, 165, 233, 0.9);
    color: white;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
    z-index: 100;
    animation: loadingPulse 1s ease-in-out infinite;
    box-shadow: 0 4px 12px rgba(14, 165, 233, 0.4);
}

.dark .loading-indicator {
    background: rgba(14, 165, 233, 0.8);
}

@keyframes loadingPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

/* 详情弹窗 */
.detail-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 64px; /* 不覆盖底部导航 */
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    z-index: 1000;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    animation: modalFadeIn 0.3s ease-out;
}

.dark .detail-modal {
    background: rgba(0, 0, 0, 0.7);
}

@keyframes modalFadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

/* 弹窗内容容器 */
.detail-modal-content {
    background: white;
    border-radius: 20px 20px 0 0;
    width: 100%;
    max-width: 500px;
    max-height: 75vh;
    display: flex;
    flex-direction: column;
    animation: modalSlideUp 0.35s ease-out;
    position: relative;
    overflow: hidden;
}

.dark .detail-modal-content {
    background: #1f2937;
}

@keyframes modalSlideUp {
    from {
        transform: translateY(100%);
    }
    to {
        transform: translateY(0);
    }
}

/* 弹窗内部关闭按钮（右上角） */
.modal-close-inner {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.1);
    color: #6b7280;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.2s ease, color 0.2s ease, transform 0.2s ease;
    z-index: 10;
}

.modal-close-inner:hover {
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
    transform: scale(1.1);
}

.dark .modal-close-inner {
    background: rgba(255, 255, 255, 0.1);
    color: #9ca3af;
}

.dark .modal-close-inner:hover {
    background: rgba(239, 68, 68, 0.2);
    color: #f87171;
}

.modal-close-inner svg {
    width: 18px;
    height: 18px;
}

/* 弹窗头部 */
.detail-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px;
    padding-right: 48px; /* 为关闭按钮留空间 */
    border-bottom: 1px solid #e5e7eb;
}

.dark .detail-modal-header {
    border-bottom-color: #374151;
}

/* 弹窗内容区域 */
.detail-modal-body {
    padding: 20px;
    overflow-y: auto;
    flex: 1;
}

/* 底部按钮区域 */
.detail-modal-footer {
    padding: 16px 20px;
    border-top: 1px solid #e5e7eb;
    display: flex;
    justify-content: center;
}

.dark .detail-modal-footer {
    border-top-color: #374151;
}

/* 迷你走势图 */
.mini-chart {
    width: 60px;
    height: 30px;
    position: relative;
}

.mini-chart-line {
    stroke-width: 2;
    fill: none;
}

.mini-chart-line.up {
    stroke: #22c55e;
}

.mini-chart-line.down {
    stroke: #ef4444;
}

.mini-chart-area {
    opacity: 0.2;
}

.mini-chart-area.up {
    fill: #22c55e;
}

.mini-chart-area.down {
    fill: #ef4444;
}

/* 减少动画偏好 */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* 响应式 */
@media (max-width: 640px) {
    .max-w-lg {
        max-width: 100%;
    }
}

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

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 2px;
}

.dark ::-webkit-scrollbar-thumb {
    background: #4b5563;
}

/* 表单元素 */
input, button, textarea, select {
    font-family: inherit;
}

button {
    cursor: pointer;
    border: none;
    background: none;
    padding: 0;
}

a {
    text-decoration: none;
    color: inherit;
}

img {
    max-width: 100%;
    height: auto;
    display: block;
}

/* 骨架屏加载动画 */
.skeleton {
    background: linear-gradient(90deg, #f3f4f6 25%, #e5e7eb 50%, #f3f4f6 75%);
    background-size: 200% 100%;
    animation: skeleton-pulse 1.5s ease-in-out infinite;
}

.dark .skeleton {
    background: linear-gradient(90deg, #374151 25%, #4b5563 50%, #374151 75%);
    background-size: 200% 100%;
}

@keyframes skeleton-pulse {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* 离线提示样式 */
#offline-toast {
    animation: slideDown 0.3s ease-out;
}

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

/* 价格卡片样式 */
.price-card {
    transition: transform 0.2s ease, box-shadow 0.2s ease, background-color 0.4s ease;
}

.price-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.1);
}

.dark .price-card:hover {
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.3);
}

/* profile.php 联系弹窗容器样式 */
.contact-modal-container {
    position: relative;
    background: white;
    border-radius: 20px;
    shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    max-width: 360px;
    width: 100%;
    overflow: hidden;
}

.dark .contact-modal-container {
    background: #1f2937;
}