/* ========================================
   雅加达生活通 - 公共样式表
   包含：CSS变量、基础样式、公共组件
   ======================================== */

/* ---------- CSS 变量 ---------- */
:root {
    /* 主色系 - 活力橙红 */
    --primary: #FF552E;
    --primary-light: #FF8055;
    --primary-dark: #D93812;
    /* 辅助色系 - 暖金色 */
    --accent: #F5A623;
    --accent-light: #FFD175;
    /* 功能色 */
    --success: #22C55E;
    --success-light: #4ADE80;
    --warning: #FBBF24;
    --danger: #EF4444;
    --info: #0EA5E9;
    --purple: #A855F7;
    --teal: #14B8A6;
    --pink: #EC4899;
    /* 背景与卡片 */
    --bg: #FFFBF7;
    --bg-warm: #FFF5EE;
    --bg-card: #FFFFFF;
    /* 文本色 */
    --text-primary: #1A1A1A;
    --text-secondary: #525252;
    --text-muted: #9CA3AF;
    /* 边框与阴影 */
    --border: rgba(0,0,0,0.06);
    --shadow: 0 2px 12px rgba(0,0,0,0.04);
    --shadow-hover: 0 4px 20px rgba(0,0,0,0.08);
    --shadow-lg: 0 8px 40px rgba(0,0,0,0.12);
    /* 圆角 */
    --radius: 12px;
    --radius-sm: 8px;
    /* 字体 */
    --font-display: 'Noto Serif SC', serif;
    --font-body: 'Noto Sans SC', sans-serif;
}

/* ---------- 基础重置 ---------- */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-body);
    background: var(--bg);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* 背景纹理 */
body::before {
    content: '';
    position: fixed;
    inset: 0;
    background-image:
        radial-gradient(circle at 20% 80%, rgba(255, 85, 46, 0.03) 0%, transparent 50%),
        radial-gradient(circle at 80% 20%, rgba(245, 166, 35, 0.05) 0%, transparent 50%);
    pointer-events: none;
    z-index: -1;
}

/* ---------- 公共动画 ---------- */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

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

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

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

@keyframes float {
    0%, 100% { transform: translate(0, 0) rotate(0deg); }
    25% { transform: translate(20px, -30px) rotate(5deg); }
    50% { transform: translate(-10px, 20px) rotate(-5deg); }
    75% { transform: translate(-30px, -10px) rotate(3deg); }
}

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

@keyframes shimmer {
    0%, 100% { opacity: 0; transform: translateX(-100%); }
    50% { opacity: 1; transform: translateX(100%); }
}

@keyframes publishShine {
    0%, 100% { transform: translateX(-100%) rotate(45deg); }
    50% { transform: translateX(100%) rotate(45deg); }
}

@keyframes miniLogoShine {
    0%, 100% { transform: translateX(-100%) rotate(45deg); }
    50% { transform: translateX(100%) rotate(45deg); }
}

/* ---------- 迷你 Header ---------- */
.mini-header {
    position: sticky;
    top: 0;
    z-index: 150;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 16px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    border-bottom: none;
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    max-width: 680px;
    margin: 0 auto;
    width: 100%;
}

.mini-header::before {
    content: '';
    position: absolute;
    top: 0;
    bottom: 0;
    left: calc(50% - 50vw);
    right: calc(50% - 50vw);
    background: inherit;
    z-index: -1;
    pointer-events: none;
}

.mini-back-btn {
    flex-shrink: 0;
    width: 36px;
    height: 36px;
    background: rgba(255, 255, 255, 0.15);
    border: 1.5px solid rgba(255, 255, 255, 0.25);
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.mini-back-btn:hover {
    background: rgba(255, 255, 255, 0.25);
    transform: translateX(-2px);
}

.mini-back-btn svg {
    width: 20px;
    height: 20px;
    fill: white;
}

.mini-logo {
    flex-shrink: 0;
    width: 36px;
    height: 36px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 12px rgba(255, 85, 46, 0.35);
    position: relative;
    overflow: hidden;
}

.mini-logo::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: linear-gradient(45deg, transparent 40%, rgba(255,255,255,0.35) 50%, transparent 60%);
    animation: miniLogoShine 3s ease-in-out infinite;
}

.mini-logo svg {
    width: 20px;
    height: 20px;
    fill: white;
    position: relative;
    z-index: 1;
}

.mini-search {
    flex: 1;
    position: relative;
    min-width: 0;
}

.mini-search .search-input {
    width: 100%;
    height: 36px;
    padding: 0 14px 0 38px;
    font-size: 0.8rem;
    font-family: var(--font-body);
    color: white;
    background: rgba(255, 255, 255, 0.15);
    border: 1.5px solid rgba(255, 255, 255, 0.25);
    border-radius: 20px;
    outline: none;
    transition: all 0.3s ease;
}

.mini-search .search-input::placeholder {
    color: rgba(255, 255, 255, 0.7);
}

.mini-search .search-input:focus {
    background: rgba(255, 255, 255, 0.25);
    border-color: rgba(255, 255, 255, 0.5);
    box-shadow: 0 0 0 4px rgba(255, 255, 255, 0.15);
}

.mini-search .search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    width: 16px;
    height: 16px;
    fill: rgba(255, 255, 255, 0.7);
    transition: fill 0.2s;
    pointer-events: none;
}

.mini-search .search-input:focus + .search-icon {
    fill: white;
}

.mini-publish-btn {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border: 1.5px solid rgba(255, 255, 255, 0.3);
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.mini-publish-btn::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(45deg, transparent 30%, rgba(255,255,255,0.25) 50%, transparent 70%);
    transform: translateX(-100%);
    transition: transform 0.5s;
}

.mini-publish-btn:hover::before {
    transform: translateX(100%);
}

.mini-publish-btn:hover {
    background: rgba(255, 255, 255, 0.35);
    transform: scale(1.08);
}

.mini-publish-btn:active {
    transform: scale(0.95);
    background: rgba(255, 255, 255, 0.25);
}

.mini-publish-btn svg {
    width: 18px;
    height: 18px;
    fill: currentColor;
}

/* ---------- 底部悬浮导航 ---------- */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--bg-card);
    border-top: 1px solid var(--border);
    z-index: 100;
    padding: 0;
}

.bottom-nav-inner {
    max-width: 680px;
    margin: 0 auto;
    display: flex;
    justify-content: space-around;
    padding: 6px 0 max(6px, env(safe-area-inset-bottom));
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 3px 16px;
    line-height: 1;
    cursor: pointer;
    transition: all 0.2s;
    border: none;
    background: transparent;
    font-family: var(--font-body);
    text-decoration: none;
    color: inherit;
}

.nav-item-icon svg,
.nav-item svg {
    width: 20px;
    height: 20px;
    fill: var(--text-muted);
    transition: fill 0.2s;
}

.nav-item-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.nav-item-label,
.nav-item span {
    font-size: 0.6rem;
    color: var(--text-muted);
    transition: color 0.2s;
}

.nav-item.active .nav-item-icon svg,
.nav-item.active svg {
    fill: var(--primary);
}

.nav-item.active .nav-item-label,
.nav-item.active span {
    color: var(--primary);
    font-weight: 600;
}

.nav-item:hover .nav-item-icon svg,
.nav-item:hover svg {
    fill: var(--primary);
}

/* 发布按钮 - 红色背景 */
.nav-item.publish {
    margin-top: -13px;
}

.nav-item.publish .nav-item-icon {
    width: 38px;
    height: 38px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
    border-radius: 50%;
    box-shadow: 0 4px 16px rgba(255, 85, 46, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
}

.nav-item.publish .nav-item-icon::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: linear-gradient(45deg, transparent 40%, rgba(255,255,255,0.3) 50%, transparent 60%);
    animation: publishShine 3s ease-in-out infinite;
}

@keyframes publishShine {
    0%, 100% { transform: translateX(-100%) rotate(45deg); }
    50% { transform: translateX(100%) rotate(45deg); }
}

.nav-item.publish .nav-item-icon svg {
    width: 22px;
    height: 22px;
    fill: white;
    filter: drop-shadow(0 1px 2px rgba(0,0,0,0.2));
}

.nav-item.publish .nav-item-label {
    color: var(--primary);
    font-weight: 600;
    margin-top: 3px;
    font-size: 0.55rem;
}

.nav-item.publish:hover .nav-item-icon {
    transform: scale(1.05);
    box-shadow: 0 6px 20px rgba(255, 85, 46, 0.5);
}

.nav-item.publish:active .nav-item-icon {
    transform: scale(0.95);
}

/* ---------- 返回顶部按钮 ---------- */
.back-to-top {
    position: fixed;
    bottom: 200px;
    right: 16px;
    width: 44px;
    height: 44px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
    color: white;
    border: none;
    border-radius: 50%;
    box-shadow: 0 4px 16px rgba(255, 85, 46, 0.4);
    cursor: pointer;
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px);
    transition: all 0.3s ease;
    z-index: 90;
    display: flex;
    align-items: center;
    justify-content: center;
}

.back-to-top.visible {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.back-to-top:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(255, 85, 46, 0.5);
}

.back-to-top svg {
    width: 22px;
    height: 22px;
    fill: currentColor;
}

/* ---------- Toast 提示 ---------- */
.toast {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%) translateY(-100px);
    padding: 14px 24px;
    background: var(--bg-card);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border);
    font-size: 0.9rem;
    color: var(--text-primary);
    z-index: 1000;
    opacity: 0;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 10px;
}

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

.toast.success {
    border-left: 4px solid var(--success);
}

.toast.error {
    border-left: 4px solid #FF4757;
}

.toast svg {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

.toast.success svg {
    fill: var(--success);
}

.toast.error svg {
    fill: #FF4757;
}

/* ---------- 底部版权 ---------- */
.footer {
    padding: 20px 16px 24px;
    text-align: center;
    background: var(--bg-card);
    border-top: 1px solid var(--border);
    margin-bottom: 88px;
}

.footer-links {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 8px 16px;
    margin-bottom: 12px;
}

.footer-links a {
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.8rem;
    transition: color 0.2s;
}

.footer-links a:hover {
    color: var(--primary);
}

.footer-copyright {
    font-size: 0.7rem;
    color: var(--text-muted);
}

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

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

::-webkit-scrollbar-thumb {
    background: var(--primary-light);
    border-radius: 4px;
}

/* ---------- 深色模式 ---------- */
@media (prefers-color-scheme: dark) {
    :root {
        --bg: #0F0F0F;
        --bg-warm: #141414;
        --bg-card: #1A1A1A;
        --text-primary: #F5F5F5;
        --text-secondary: #AAAAAA;
        --text-muted: #666666;
        --border: rgba(255,255,255,0.08);
        --shadow: 0 2px 12px rgba(0,0,0,0.3);
        --shadow-hover: 0 4px 20px rgba(0,0,0,0.4);
        --shadow-lg: 0 8px 40px rgba(0,0,0,0.5);
    }

    body::before {
        background-image:
            radial-gradient(circle at 20% 80%, rgba(255, 85, 46, 0.08) 0%, transparent 50%),
            radial-gradient(circle at 80% 20%, rgba(245, 166, 35, 0.1) 0%, transparent 50%);
    }

    .mini-header {
        background: linear-gradient(135deg, #B82F12 0%, #8C1F0C 100%);
        box-shadow: 0 4px 24px rgba(0, 0, 0, 0.35);
    }

    .mini-search .search-input {
        background: rgba(0, 0, 0, 0.25);
        border-color: rgba(255, 255, 255, 0.15);
    }

    .mini-search .search-input:focus {
        background: rgba(0, 0, 0, 0.35);
        border-color: rgba(255, 255, 255, 0.3);
    }

    .mini-publish-btn {
        background: rgba(0, 0, 0, 0.25);
        border-color: rgba(255, 255, 255, 0.15);
    }

    .mini-publish-btn:hover {
        background: rgba(255, 255, 255, 0.15);
    }

    .bottom-nav {
        background: var(--bg-card);
        border-top-color: var(--border);
    }
}

/* ---------- 响应式 ---------- */
@media (min-width: 768px) {
    .footer {
        margin-bottom: 88px;
    }
}
