/**
 * 知其然亲子研学 - H5网站全局样式
 * 主题色: #FF6B35 (橙色)
 */

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

:root {
    --primary: #FF6B35;
    --primary-light: #FF8F66;
    --primary-dark: #E55A28;
    --text: #333;
    --text-light: #666;
    --text-gray: #999;
    --bg: #f5f5f5;
    --bg-white: #fff;
    --border: #eee;
    --danger: #ff4d4f;
    --success: #52c41a;
}

/* ==================== 动画和过渡 ==================== */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

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

@keyframes slideUp {
    from { opacity: 0; transform: translateY(100%); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes slideDown {
    from { opacity: 0; transform: translateY(-100%); }
    to { opacity: 1; transform: translateY(0); }
}

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

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

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

/* 滑动进入 */
.slide-up {
    animation: slideUp 0.3s ease-out;
}

/* 脉冲效果 */
.pulse {
    animation: pulse 2s infinite;
}

/* 过渡效果 */
.page {
    transition: opacity 0.3s ease;
}

.btn, .action-cart, .action-buy, .cart-submit, .footer-btn {
    transition: all 0.2s ease;
}

.btn:active, .action-cart:active, .action-buy:active {
    transform: scale(0.95);
    opacity: 0.9;
}

/* 购物车项目过渡 */
.cart-item {
    transition: all 0.3s ease;
}

.cart-item:active {
    background: #f9f9f9;
}

/* 商品卡片悬停/触摸效果 */
.goods-grid-item {
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.goods-grid-item:active {
    transform: scale(0.98);
}

/* 加载动画 */
.loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(255, 107, 53, 0.3);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto 10px;
}

/* Toast 提示动画 */
.global-toast {
    animation: fadeIn 0.3s ease-out;
}

/* 确认对话框动画 */
.confirm-modal {
    animation: fadeIn 0.2s ease-out;
}

.confirm-box {
    animation: slideUp 0.3s ease-out;
}

/* 空状态图标动画 */
.empty-icon {
    animation: pulse 2s infinite;
}

/* 图片加载过渡 */
img {
    transition: opacity 0.3s ease;
}

img[loading="lazy"] {
    opacity: 0;
}

img[loading="lazy"].loaded {
    opacity: 1;
}

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

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

::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 2px;
}

/* 安全区域适配 */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
    .tabbar {
        padding-bottom: env(safe-area-inset-bottom);
    }

    .order-footer, .cart-footer, .bottom-action {
        padding-bottom: calc(12px + env(safe-area-inset-bottom));
    }
}

/* 深色模式支持 */
@media (prefers-color-scheme: dark) {
    :root {
        --text: #e0e0e0;
        --text-light: #aaa;
        --text-gray: #777;
        --bg: #1a1a1a;
        --bg-white: #2a2a2a;
        --border: #3a3a3a;
    }

    body {
        background: var(--bg);
        color: var(--text);
    }
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
    font-size: 14px;
    color: var(--text);
    background: var(--bg);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

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

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

/* 容器 */
.container {
    max-width: 750px;
    margin: 0 auto;
    padding: 0 12px;
}

/* 头部 */
.header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    padding: 10px 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
}

.header-back {
    font-size: 15px;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.18);
    cursor: pointer;
    transition: background 0.2s;
    -webkit-tap-highlight-color: transparent;
}

.header-back:active {
    background: rgba(255, 255, 255, 0.35);
}

.header-back::before {
    content: '';
    display: block;
    width: 9px;
    height: 9px;
    border-top: 2.5px solid white;
    border-left: 2.5px solid white;
    transform: rotate(-45deg);
    margin-left: 3px;
}

.header-title {
    font-size: 17px;
    font-weight: 600;
    letter-spacing: 1px;
    flex: 1;
    text-align: center;
}

.header-right {
    min-width: 50px;
    text-align: right;
}

/* 底部导航 */
.tabbar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: white;
    display: flex;
    border-top: 1px solid var(--border);
    z-index: 100;
    max-width: 750px;
    margin: 0 auto;
}

.tabbar-item {
    flex: 1;
    padding: 8px 0;
    text-align: center;
    font-size: 11px;
    color: var(--text-gray);
}

.tabbar-item.active {
    color: var(--primary);
}

.tabbar-item::before {
    content: '';
    display: block;
    width: 24px;
    height: 24px;
    margin: 0 auto 4px;
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
}

.tabbar-item.home::before { background-image: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M12 2.1L2.5 9.6c-.3.3-.4.7-.2 1 .1.4.5.6.9.5h.8V20c0 .6.4 1 1 1h4c.6 0 1-.4 1-1v-5h4v5c0 .6.4 1 1 1h4c.6 0 1-.4 1-1v-8.9h.8c.4 0 .8-.3.9-.6.1-.4 0-.8-.3-1L12 2.1z" fill="%23999" fill-opacity=".2"/><path d="M3 9l9-7 9 7v11a2 2 0 01-2 2H5a2 2 0 01-2-2z" fill="none" stroke="%23999" stroke-width="1.8" stroke-linejoin="round"/><path d="M9 22V12h6v10" fill="none" stroke="%23999" stroke-width="1.8" stroke-linejoin="round"/></svg>'); }
.tabbar-item.home.active::before { background-image: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M12 2.1L2.5 9.6c-.3.3-.4.7-.2 1 .1.4.5.6.9.5h.8V20c0 .6.4 1 1 1h4c.6 0 1-.4 1-1v-5h4v5c0 .6.4 1 1 1h4c.6 0 1-.4 1-1v-8.9h.8c.4 0 .8-.3.9-.6.1-.4 0-.8-.3-1L12 2.1z" fill="%23FF6B35" fill-opacity=".15"/><path d="M3 9l9-7 9 7v11a2 2 0 01-2 2H5a2 2 0 01-2-2z" fill="none" stroke="%23FF6B35" stroke-width="1.8" stroke-linejoin="round"/><path d="M9 22V12h6v10" fill="none" stroke="%23FF6B35" stroke-width="1.8" stroke-linejoin="round"/></svg>'); }

.tabbar-item.goods::before { background-image: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><rect x="1" y="4" width="22" height="16" rx="2" fill="%23999" fill-opacity=".15"/><rect x="1" y="4" width="22" height="5" rx="2" fill="%23999" fill-opacity=".25"/><rect x="1" y="4" width="22" height="16" rx="2" fill="none" stroke="%23999" stroke-width="1.8"/><line x1="1" y1="9.5" x2="23" y2="9.5" stroke="%23999" stroke-width="1.8"/><line x1="8" y1="13" x2="8" y2="19" stroke="%23999" stroke-width="1.6" stroke-linecap="round"/><line x1="16" y1="13" x2="16" y2="19" stroke="%23999" stroke-width="1.6" stroke-linecap="round"/></svg>'); }
.tabbar-item.goods.active::before { background-image: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><rect x="1" y="4" width="22" height="16" rx="2" fill="%23FF6B35" fill-opacity=".1"/><rect x="1" y="4" width="22" height="5" rx="2" fill="%23FF6B35" fill-opacity=".2"/><rect x="1" y="4" width="22" height="16" rx="2" fill="none" stroke="%23FF6B35" stroke-width="1.8"/><line x1="1" y1="9.5" x2="23" y2="9.5" stroke="%23FF6B35" stroke-width="1.8"/><line x1="8" y1="13" x2="8" y2="19" stroke="%23FF6B35" stroke-width="1.6" stroke-linecap="round"/><line x1="16" y1="13" x2="16" y2="19" stroke="%23FF6B35" stroke-width="1.6" stroke-linecap="round"/></svg>'); }

.tabbar-item.space::before { background-image: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M12 2l1.5 4.5L18 5l-2.5 4L19 11h-4.5L13 15.5 11.5 11H7l3.5-2L8 5l4.5 1.5z" fill="%23999" fill-opacity=".2"/><path d="M12 2l1.5 4.5L18 5l-2.5 4L19 11h-4.5L13 15.5 11.5 11H7l3.5-2L8 5l4.5 1.5z" fill="none" stroke="%23999" stroke-width="1.8" stroke-linejoin="round"/><circle cx="12" cy="12" r="10" fill="none" stroke="%23999" stroke-width=".8" stroke-dasharray="3 3" opacity=".4"/><circle cx="18" cy="6" r="1.2" fill="%23999" opacity=".4"/><circle cx="5" cy="16" r=".8" fill="%23999" opacity=".3"/></svg>'); }
.tabbar-item.space.active::before { background-image: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M12 2l1.5 4.5L18 5l-2.5 4L19 11h-4.5L13 15.5 11.5 11H7l3.5-2L8 5l4.5 1.5z" fill="%23FF6B35" fill-opacity=".2"/><path d="M12 2l1.5 4.5L18 5l-2.5 4L19 11h-4.5L13 15.5 11.5 11H7l3.5-2L8 5l4.5 1.5z" fill="none" stroke="%23FF6B35" stroke-width="1.8" stroke-linejoin="round"/><circle cx="12" cy="12" r="10" fill="none" stroke="%23FF6B35" stroke-width=".8" stroke-dasharray="3 3" opacity=".3"/><circle cx="18" cy="6" r="1.2" fill="%23FF6B35" opacity=".35"/><circle cx="5" cy="16" r=".8" fill="%23FF6B35" opacity=".25"/></svg>'); }

.tabbar-item.cart::before { background-image: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M6 2L3 6v14a2 2 0 002 2h14a2 2 0 002-2V6l-3-4H6z" fill="%23999" fill-opacity=".15"/><path d="M3 6h18M6 2v4m12-4v4" fill="none" stroke="%23999" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"/><circle cx="9" cy="20" r="1.5" fill="%23999"/><circle cx="20" cy="20" r="1.5" fill="%23999"/><path d="M1 1h4l2.68 13.39a2 2 0 002 1.61h9.72a2 2 0 002-1.61L23 6H6" fill="none" stroke="%23999" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"/></svg>'); }
.tabbar-item.cart.active::before { background-image: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M6 2L3 6v14a2 2 0 002 2h14a2 2 0 002-2V6l-3-4H6z" fill="%23FF6B35" fill-opacity=".1"/><path d="M3 6h18M6 2v4m12-4v4" fill="none" stroke="%23FF6B35" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"/><circle cx="9" cy="20" r="1.5" fill="%23FF6B35"/><circle cx="20" cy="20" r="1.5" fill="%23FF6B35"/><path d="M1 1h4l2.68 13.39a2 2 0 002 1.61h9.72a2 2 0 002-1.61L23 6H6" fill="none" stroke="%23FF6B35" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"/></svg>'); }

.tabbar-item.user::before { background-image: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><circle cx="12" cy="8" r="4" fill="%23999" fill-opacity=".15"/><path d="M4 22c0-4.4 3.6-8 8-8s8 3.6 8 8" fill="%23999" fill-opacity=".1"/><circle cx="12" cy="8" r="4" fill="none" stroke="%23999" stroke-width="1.8"/><path d="M4 22c0-4.4 3.6-8 8-8s8 3.6 8 8" fill="none" stroke="%23999" stroke-width="1.8" stroke-linecap="round"/></svg>'); }
.tabbar-item.user.active::before { background-image: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><circle cx="12" cy="8" r="4" fill="%23FF6B35" fill-opacity=".15"/><path d="M4 22c0-4.4 3.6-8 8-8s8 3.6 8 8" fill="%23FF6B35" fill-opacity=".1"/><circle cx="12" cy="8" r="4" fill="none" stroke="%23FF6B35" stroke-width="1.8"/><path d="M4 22c0-4.4 3.6-8 8-8s8 3.6 8 8" fill="none" stroke="%23FF6B35" stroke-width="1.8" stroke-linecap="round"/></svg>'); }

/* 页面容器 */
.page {
    padding-bottom: 70px;
}

/* 卡片 */
.card {
    background: white;
    border-radius: 8px;
    margin: 12px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

.card-header {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    font-size: 15px;
    font-weight: 500;
}

.card-body {
    padding: 16px;
}

/* 按钮 */
.btn {
    display: inline-block;
    padding: 10px 24px;
    border-radius: 4px;
    font-size: 14px;
    text-align: center;
    border: none;
    cursor: pointer;
}

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

.btn-primary:active {
    background: var(--primary-dark);
}

.btn-outline {
    background: white;
    border: 1px solid var(--primary);
    color: var(--primary);
}

.btn-block {
    display: block;
    width: 100%;
}

/* 表单 */
.form-item {
    padding: 12px 16px;
    background: white;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
}

.form-item:last-child {
    border-bottom: none;
}

.form-label {
    width: 80px;
    font-size: 14px;
    color: var(--text);
}

.form-input {
    flex: 1;
    border: none;
    outline: none;
    font-size: 14px;
    background: transparent;
}

.form-textarea {
    width: 100%;
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 10px;
    font-size: 14px;
    resize: vertical;
    min-height: 80px;
}

/* 列表 */
.list-item {
    padding: 12px 16px;
    background: white;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
}

.list-item:active {
    background: #f9f9f9;
}

.list-item:last-child {
    border-bottom: none;
}

/* 空状态 */
.empty {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-gray);
}

.empty-icon {
    font-size: 60px;
    margin-bottom: 16px;
}

.empty-text {
    font-size: 14px;
}

/* 加载更多 */
.load-more {
    text-align: center;
    padding: 16px;
    color: var(--text-gray);
    font-size: 13px;
}

/* 商品卡片 */
.goods-list {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    padding: 10px;
}

.goods-item {
    background: white;
    border-radius: 8px;
    overflow: hidden;
}

.goods-image {
    width: 100%;
    aspect-ratio: 1;
    object-fit: cover;
}

.goods-info {
    padding: 10px;
}

.goods-name {
    font-size: 13px;
    color: var(--text);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    height: 36px;
    line-height: 18px;
}

.goods-price {
    color: var(--primary);
    font-size: 16px;
    font-weight: bold;
    margin-top: 8px;
}

.goods-price::before {
    content: '¥';
    font-size: 12px;
}

/* 订单卡片 */
.order-item {
    background: white;
    border-radius: 8px;
    margin: 10px;
    overflow: hidden;
}

.order-header {
    padding: 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border);
}

.order-status {
    color: var(--primary);
    font-size: 13px;
}

.order-goods {
    padding: 12px;
}

.order-goods-item {
    display: flex;
    padding: 8px 0;
}

.order-goods-img {
    width: 60px;
    height: 60px;
    border-radius: 4px;
    object-fit: cover;
    margin-right: 10px;
}

.order-goods-info {
    flex: 1;
}

.order-goods-name {
    font-size: 13px;
    color: var(--text);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.order-goods-price {
    color: var(--primary);
    font-size: 14px;
    margin-top: 4px;
}

.order-footer {
    padding: 12px;
    text-align: right;
    border-top: 1px solid var(--border);
}

.order-total {
    font-size: 14px;
    color: var(--text);
}

.order-total strong {
    color: var(--primary);
    font-size: 16px;
}

/* 底部操作栏 */
.bottom-bar {
    position: fixed;
    bottom: 60px;
    left: 0;
    right: 0;
    background: white;
    padding: 10px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-top: 1px solid var(--border);
    max-width: 750px;
    margin: 0 auto;
    z-index: 99;
}

.bottom-bar-price {
    font-size: 18px;
    color: var(--primary);
    font-weight: bold;
}

.bottom-bar-price::before {
    content: '¥';
    font-size: 12px;
}

/* 分类标签 */
.category-tabs {
    display: flex;
    overflow-x: auto;
    background: white;
    padding: 10px 12px;
    gap: 10px;
    -webkit-overflow-scrolling: touch;
}

.category-tab {
    flex-shrink: 0;
    padding: 6px 16px;
    border-radius: 16px;
    font-size: 13px;
    background: #f5f5f5;
    color: var(--text);
}

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

/* 搜索框 */
.search-box {
    display: flex;
    background: white;
    padding: 10px 12px;
    gap: 10px;
}

.search-input {
    flex: 1;
    height: 36px;
    border: 1px solid var(--border);
    border-radius: 18px;
    padding: 0 16px;
    font-size: 13px;
    outline: none;
}

.search-input:focus {
    border-color: var(--primary);
}

/* 轮播图 */
.banner {
    width: 100%;
    aspect-ratio: 16/9;
    overflow: hidden;
}

.banner img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* 间距工具类 */
.mt-10 { margin-top: 10px; }
.mt-15 { margin-top: 15px; }
.mb-10 { margin-bottom: 10px; }
.mb-15 { margin-bottom: 15px; }
.p-12 { padding: 12px; }
.p-16 { padding: 16px; }

/* 文字工具类 */
.text-primary { color: var(--primary); }
.text-gray { color: var(--text-gray); }
.text-center { text-align: center; }
.text-right { text-align: right; }
.font-bold { font-weight: bold; }
.font-12 { font-size: 12px; }
.font-13 { font-size: 13px; }
.font-14 { font-size: 14px; }
.font-16 { font-size: 16px; }

/* Flex工具类 */
.flex { display: flex; }
.flex-1 { flex: 1; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.justify-center { justify-content: center; }
