/**
 * 海角社区视频解析系统 - 移动端样式
 * 现代APP风格UI设计 - 2025设计趋势
 * 优化版 - 更像原生APP，使用统一的主题变量
 */

/* 移动端基础样式 */
@media (max-width: 991px) {
    :root {
        --header-height: 60px;
        --mobile-nav-height: var(--footer-height);
        --nav-icon-size: 24px;
        --nav-button-size: 56px;
        --safe-area-bottom: env(safe-area-inset-bottom, 0px);
        --mobile-padding: var(--spacing-md);
        --mobile-card-gap: var(--spacing-sm);
    }

    .container {
        padding: 0 var(--mobile-padding);
        max-width: 100%;
    }

    body {
        padding-bottom: calc(var(--mobile-nav-height) + var(--safe-area-bottom));
        font-size: var(--font-size-sm);
    }

    /* 移动端背景优化 */
    [data-theme="light"] body {
        background: linear-gradient(135deg, var(--bg-secondary) 0%, var(--bg-tertiary) 100%);
    }

    [data-theme="dark"] body {
        background: linear-gradient(135deg, var(--bg-primary) 0%, var(--bg-secondary) 100%);
    }

    /* 头部导航优化 - 更像APP */
    .app-header {
        background: rgba(255, 255, 255, 0.95);
        backdrop-filter: blur(20px);
        -webkit-backdrop-filter: blur(20px);
        box-shadow: var(--shadow-navbar);
        border-bottom: 1px solid var(--border-light);
        position: sticky;
        top: 0;
        z-index: 100;
        height: var(--header-height);
    }

    /* 深色模式移动端头部 */
    [data-theme="dark"] .app-header {
        background: rgba(15, 23, 42, 0.95);
        border-bottom-color: var(--border-color);
    }

    .header-container {
        padding: 0 var(--mobile-padding);
        height: 100%;
    }

    .app-logo {
        font-weight: 700;
        color: var(--text-primary);
        transition: var(--transition-base);
    }

    .app-logo:hover {
        color: var(--primary-color);
    }

    .logo-text {
        font-size: var(--font-size-lg);
        max-width: 180px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        background: var(--bg-gradient);
        -webkit-background-clip: text;
        -webkit-text-fill-color: transparent;
        background-clip: text;
        font-weight: 800;
    }

    .logo-img {
        height: 32px;
        width: 32px;
        margin-right: var(--spacing-sm);
        border-radius: var(--radius-md);
        object-fit: cover;
    }

    /* 隐藏PC端导航，显示移动端导航 */
    .desktop-only {
        display: none !important;
    }

    .app-nav {
        display: none !important;
    }

    .search-container {
        display: none;
    }
    
    /* 移动端底部导航栏 - 现代APP风格 */
    .mobile-nav {
        position: fixed;
        bottom: 0;
        left: 0;
        width: 100%;
        height: var(--mobile-nav-height);
        z-index: 950;
        display: flex;
        padding-bottom: var(--safe-area-bottom);
    }

    .mobile-nav-container {
        display: flex;
        align-items: center;
        justify-content: space-around;
        width: 100%;
        height: 100%;
        background: rgba(255, 255, 255, 0.95);
        backdrop-filter: blur(20px);
        -webkit-backdrop-filter: blur(20px);
        box-shadow: 0 -2px 20px rgba(0,0,0,0.1);
        border-top: 1px solid var(--border-light);
        padding: var(--spacing-sm) var(--spacing-md) 0;
        position: relative;
    }

    /* 深色模式底部导航 */
    [data-theme="dark"] .mobile-nav-container {
        background: rgba(15, 23, 42, 0.95);
        border-top-color: var(--border-color);
    }

    .mobile-nav-item {
        flex: 1;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        color: var(--text-light);
        text-decoration: none;
        padding: var(--spacing-xs);
        position: relative;
        transition: var(--transition-base);
        border-radius: var(--radius-lg);
        min-height: 56px;
        touch-action: manipulation;
        -webkit-tap-highlight-color: transparent;
    }

    .mobile-nav-item.active {
        color: var(--primary-color);
        background: var(--primary-transparent);
        transform: translateY(-2px);
    }

    .mobile-nav-item.active .mobile-nav-svg {
        transform: scale(1.1);
    }

    .mobile-nav-item:active {
        transform: scale(0.95);
        background: var(--state-active);
    }

    .mobile-nav-item:hover {
        color: var(--text-secondary);
        background: var(--state-hover);
    }

    .mobile-nav-svg {
        width: var(--nav-icon-size);
        height: var(--nav-icon-size);
        fill: currentColor;
        margin-bottom: var(--spacing-xs);
        transition: var(--transition-base);
    }

    .mobile-nav-text {
        font-size: var(--font-size-xs);
        font-weight: 500;
        line-height: 1;
        text-align: center;
    }

    /* 导航项徽章 */
    .mobile-nav-badge {
        position: absolute;
        top: 4px;
        right: 20%;
        background: var(--danger-color);
        color: var(--text-white);
        font-size: 10px;
        font-weight: 600;
        padding: 2px 6px;
        border-radius: var(--radius-full);
        min-width: 18px;
        height: 18px;
        display: flex;
        align-items: center;
        justify-content: center;
        transform: scale(0.9);
    }

    .mobile-nav-label {
        font-size: 10px;
        font-weight: 600;
        margin-top: 2px;
        letter-spacing: 0.5px;
    }

    .mobile-nav-action {
        position: absolute;
        top: -28px;
        left: 50%;
        transform: translateX(-50%);
        z-index: 10;
    }

    .mobile-parse-btn {
        width: 64px;
        height: 64px;
        border-radius: 20px;
        background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
        display: flex;
        align-items: center;
        justify-content: center;
        border: none;
        box-shadow: 0 8px 32px rgba(67, 97, 238, 0.4);
        cursor: pointer;
        transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        position: relative;
        overflow: hidden;
    }

    .mobile-parse-btn::before {
        content: '';
        position: absolute;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: linear-gradient(135deg, rgba(255,255,255,0.2), transparent);
        border-radius: inherit;
        opacity: 0;
        transition: opacity 0.3s ease;
    }

    .mobile-parse-btn:hover::before,
    .mobile-parse-btn:focus::before {
        opacity: 1;
    }

    .mobile-parse-btn:hover,
    .mobile-parse-btn:focus {
        transform: translateY(-4px) scale(1.05);
        box-shadow: 0 12px 40px rgba(67, 97, 238, 0.5);
    }

    .mobile-parse-btn:active {
        transform: translateY(-2px) scale(0.98);
    }

    .mobile-parse-svg {
        width: 28px;
        height: 28px;
        fill: white;
        z-index: 1;
    }

    .mobile-parse-btn.pulse {
        animation: pulse 0.6s cubic-bezier(0.4, 0, 0.2, 1);
    }

    @keyframes pulse {
        0% { transform: scale(1); }
        50% { transform: scale(1.15); }
        100% { transform: scale(1); }
    }
    
    /* 移动端解析表单 - 现代弹窗设计 */
    .mobile-parse-form {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        z-index: 1000;
        display: flex;
        opacity: 0;
        visibility: hidden;
        transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    }

    .mobile-parse-form.active {
        opacity: 1;
        visibility: visible;
    }

    .mobile-parse-overlay {
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: rgba(0, 0, 0, 0.6);
        backdrop-filter: blur(10px);
        -webkit-backdrop-filter: blur(10px);
    }

    .mobile-parse-container {
        position: absolute;
        bottom: 0;
        left: 0;
        width: 100%;
        background: rgba(255, 255, 255, 0.98);
        backdrop-filter: blur(20px);
        -webkit-backdrop-filter: blur(20px);
        border-radius: 24px 24px 0 0;
        padding: 24px;
        padding-bottom: calc(24px + var(--safe-area-bottom));
        transform: translateY(100%);
        transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
        box-shadow: 0 -8px 32px rgba(0,0,0,0.12);
    }

    .mobile-parse-form.active .mobile-parse-container {
        transform: translateY(0);
    }
    
    .mobile-parse-header {
        display: flex;
        align-items: center;
        justify-content: space-between;
        margin-bottom: 24px;
        position: relative;
    }

    .mobile-parse-header::after {
        content: '';
        position: absolute;
        bottom: -12px;
        left: 50%;
        transform: translateX(-50%);
        width: 40px;
        height: 4px;
        background: #e2e8f0;
        border-radius: 2px;
    }

    .mobile-parse-header h3 {
        font-size: 20px;
        font-weight: 700;
        margin: 0;
        color: var(--text-primary);
    }

    .mobile-parse-close {
        width: 40px;
        height: 40px;
        border-radius: 12px;
        background: rgba(0,0,0,0.05);
        border: none;
        display: flex;
        align-items: center;
        justify-content: center;
        cursor: pointer;
        transition: all 0.3s ease;
    }

    .mobile-parse-close:hover {
        background: rgba(0,0,0,0.1);
        transform: scale(1.05);
    }

    .mobile-parse-close svg {
        width: 20px;
        height: 20px;
        fill: #64748b;
    }

    .mobile-parse-input {
        width: 100%;
        height: 56px;
        padding: 0 20px;
        border: 2px solid #e2e8f0;
        border-radius: 16px;
        background: rgba(248, 250, 252, 0.8);
        font-size: 16px;
        margin-bottom: 16px;
        color: var(--text-primary);
        transition: all 0.3s ease;
    }

    .mobile-parse-input:focus {
        outline: none;
        border-color: var(--primary-color);
        background: white;
        box-shadow: 0 0 0 4px rgba(67, 97, 238, 0.1);
    }

    .mobile-parse-button {
        width: 100%;
        height: 56px;
        border: none;
        border-radius: 16px;
        background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
        color: white;
        font-size: 16px;
        font-weight: 700;
        cursor: pointer;
        margin-bottom: 20px;
        display: flex;
        align-items: center;
        justify-content: center;
        transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        box-shadow: 0 4px 16px rgba(67, 97, 238, 0.3);
    }

    .mobile-parse-button:hover {
        transform: translateY(-2px);
        box-shadow: 0 8px 24px rgba(67, 97, 238, 0.4);
    }

    .mobile-parse-button:active {
        transform: translateY(0);
    }

    .mobile-parse-button svg {
        width: 20px;
        height: 20px;
        fill: currentColor;
        margin-right: 8px;
    }
    
    .mobile-parse-sites {
        display: flex;
        flex-wrap: wrap;
        gap: 8px;
        margin-top: 16px;
    }

    .mobile-parse-site {
        padding: 8px 14px;
        border-radius: 20px;
        background: rgba(67, 97, 238, 0.1);
        font-size: 12px;
        font-weight: 600;
        color: var(--primary-color);
        border: 1px solid rgba(67, 97, 238, 0.2);
    }

    .mobile-parse-site-badge {
        padding: 10px 16px;
        border-radius: 20px;
        background: linear-gradient(135deg, rgba(67, 97, 238, 0.15), rgba(124, 58, 237, 0.15));
        font-size: 13px;
        font-weight: 700;
        color: var(--primary-color);
        border: 2px solid rgba(67, 97, 238, 0.3);
        transition: all 0.3s ease;
        display: inline-block;
        box-shadow: 0 4px 12px rgba(67, 97, 238, 0.1);
    }

    /* 移动端卡片优化 */
    .app-card {
        margin: var(--card-gap) 0;
        border-radius: 20px;
        background: rgba(255, 255, 255, 0.9);
        backdrop-filter: blur(10px);
        -webkit-backdrop-filter: blur(10px);
        box-shadow: 0 4px 20px rgba(0,0,0,0.08);
        border: 1px solid rgba(255,255,255,0.2);
        overflow: hidden;
    }

    .app-card-header {
        padding: 20px;
        background: linear-gradient(135deg, rgba(67, 97, 238, 0.05), rgba(76, 201, 240, 0.05));
        border-bottom: 1px solid rgba(0,0,0,0.05);
    }

    .app-card-title {
        font-size: 18px;
        font-weight: 700;
        color: var(--text-primary);
        display: flex;
        align-items: center;
        gap: 8px;
    }

    .app-card-body {
        padding: 20px;
    }

    /* 解析器卡片移动端优化 */
    .parser-card {
        border-radius: 24px;
        overflow: hidden;
        box-shadow: 0 8px 32px rgba(0,0,0,0.12);
    }

    .parser-header {
        padding: 32px 24px;
        background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
        position: relative;
        overflow: hidden;
    }

    .parser-header::before {
        content: '';
        position: absolute;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><circle cx="20" cy="20" r="2" fill="rgba(255,255,255,0.1)"/><circle cx="80" cy="40" r="1" fill="rgba(255,255,255,0.1)"/><circle cx="40" cy="80" r="1.5" fill="rgba(255,255,255,0.1)"/></svg>');
        opacity: 0.3;
    }

    .parser-title {
        font-size: 24px;
        font-weight: 800;
        margin-bottom: 8px;
        position: relative;
        z-index: 1;
    }

    .parser-description {
        font-size: 16px;
        margin-bottom: 24px;
        opacity: 0.9;
        position: relative;
        z-index: 1;
    }
    
    /* 移动端输入框优化 */
    .parser-input {
        height: 56px;
        padding: 0 24px;
        border-radius: 16px;
        font-size: 16px;
        border: 2px solid rgba(255,255,255,0.3);
        background: rgba(255,255,255,0.2);
    }

    .parser-input:focus {
        border-color: rgba(255,255,255,0.5);
        background: rgba(255,255,255,0.3);
    }

    .btn-parser {
        height: 48px;
        padding: 0 24px;
        border-radius: 14px;
        font-weight: 700;
        right: 4px;
        top: 50%;
        transform: translateY(-50%);
    }

    /* VIP特权卡片移动端优化 */
    .vip-features {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 16px;
    }

    .vip-feature {
        background: rgba(255,255,255,0.8);
        border-radius: 16px;
        padding: 20px;
        text-align: center;
        border: 1px solid rgba(67, 97, 238, 0.1);
        transition: all 0.3s ease;
    }

    .vip-feature:hover {
        transform: translateY(-4px);
        box-shadow: 0 8px 24px rgba(67, 97, 238, 0.15);
    }

    .vip-feature-icon {
        width: 48px;
        height: 48px;
        margin: 0 auto 12px;
        background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
        border-radius: 12px;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .vip-feature-icon svg {
        width: 24px;
        height: 24px;
        fill: white;
    }

    .vip-feature-title {
        font-size: 14px;
        font-weight: 700;
        margin-bottom: 4px;
        color: var(--text-primary);
    }

    .vip-feature-desc {
        font-size: 12px;
        color: var(--text-secondary);
        margin: 0;
    }

    /* 页面加载指示器 - 现代设计 */
    .loading-indicator {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 100%);
        z-index: 2000;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.4s ease;
    }

    .loading-indicator.active {
        opacity: 1;
        pointer-events: auto;
    }

    .spinner-container {
        position: relative;
    }

    .spinner {
        width: 48px;
        height: 48px;
        border: 4px solid rgba(67, 97, 238, 0.1);
        border-left: 4px solid var(--primary-color);
        border-radius: 50%;
        animation: spin 1s linear infinite;
    }

    @keyframes spin {
        0% { transform: rotate(0deg); }
        100% { transform: rotate(360deg); }
    }
    
    .spinner-container {
        display: flex;
        flex-direction: column;
        align-items: center;
    }
    
    .spinner {
        width: 40px;
        height: 40px;
        border: 3px solid transparent;
        border-top: 3px solid var(--primary-color);
        border-radius: 50%;
        animation: spin 1s linear infinite;
    }
    
    @keyframes spin {
        0% {
            transform: rotate(0deg);
    }
        100% {
            transform: rotate(360deg);
        }
    }
    
    /* 内容区适配底部导航 */
    .app-main {
        padding-bottom: calc(74px + env(safe-area-inset-bottom));
    }
    
    /* 视频播放器容器（移动端优化） */
    @media (max-width: 767.98px) {
        .video-container {
            padding: 10px;
            margin-bottom: 15px;
            border-radius: var(--radius-lg);
            overflow: hidden;
    }
    
        .video-player {
            border-radius: var(--radius-md);
            overflow: hidden;
        }
        
        .parser-form {
            padding: 15px;
            margin-top: 15px;
            border-radius: var(--radius-lg);
            margin-bottom: 15px;
    }
    
        .parser-form .form-control {
            border-radius: var(--radius-md);
            height: 48px;
        }
        
        .parser-form .btn-parser {
            height: 48px;
            border-radius: var(--radius-md);
    }
    
        /* 调整首页布局 */
        .section {
            padding: 15px;
            margin-bottom: 15px;
        }
        
        .section-title {
            font-size: 18px;
            margin-bottom: 15px;
        }
        
        /* 卡片样式优化 */
        .app-card {
            border-radius: var(--radius-lg);
            box-shadow: var(--shadow-sm);
            overflow: hidden;
        }
    }
    
    /* 工具条栏（移动优化） */
    @media (max-width: 767.98px) {
        .toolbar {
            padding: 12px;
            flex-wrap: nowrap;
            overflow-x: auto;
            -webkit-overflow-scrolling: touch;
            margin: 0 -15px;
            padding-left: 15px;
            padding-right: 15px;
            scroll-snap-type: x mandatory;
        }
        
        .toolbar::-webkit-scrollbar {
            display: none;
        }
        
        .tool-button {
            min-width: auto;
            padding: 8px 15px;
            margin: 0 4px;
            white-space: nowrap;
            scroll-snap-align: start;
            flex: 0 0 auto;
    }
    
        .tool-button:first-child {
            margin-left: 0;
        }
        
        .tool-button:last-child {
            margin-right: 0;
        }
    }
    
    /* App Modal (移动优化) */
    @media (max-width: 767.98px) {
        .app-modal-container {
            width: 90%;
            max-width: 450px;
            max-height: 85vh;
            border-radius: var(--radius-lg);
    }
    
        .app-modal-header {
            padding: 15px;
        }
        
        .app-modal-body {
            padding: 0 15px 15px;
        }
        
        .app-modal-footer {
            padding: 15px;
        }
    }
    
    /* 头部响应式调整 */
    @media (max-width: 767.98px) {
        .app-header {
        position: fixed;
        top: 0;
        left: 0;
            right: 0;
            z-index: 990;
            background-color: rgba(255, 255, 255, 0.9);
            backdrop-filter: blur(10px);
            -webkit-backdrop-filter: blur(10px);
            box-shadow: var(--shadow-navbar);
        }
        
        [data-theme="dark"] .app-header {
            background-color: rgba(31, 41, 55, 0.9);
        }
        
        .app-main {
            padding-top: calc(var(--header-height) + 15px);
    }
    
        .header-container {
            height: var(--header-height);
            padding: 0 15px;
    }
    
        .logo-img {
            height: 32px;
        }
        
        .logo-text {
            display: none;
        }
    }
    
    /* 辅助样式 */
    .sr-only {
        position: absolute;
        width: 1px;
        height: 1px;
        padding: 0;
        margin: -1px;
        overflow: hidden;
        clip: rect(0, 0, 0, 0);
        white-space: nowrap;
        border: 0;
    }
    
    .desktop-only {
        display: none;
    }
    
    @media (min-width: 768px) {
        .desktop-only {
            display: block;
    }
    
        .mobile-nav {
            display: none;
        }
    }
    
    /* 确保底部导航在移动端可见 */
    @media (max-width: 767.98px) {
    .app-footer {
            margin-bottom: calc(74px + env(safe-area-inset-bottom));
        }
    }
    
    /* 动态添加的返回顶部按钮 */
    .back-to-top {
        position: fixed;
        bottom: 90px;
        right: 20px;
        width: 44px;
        height: 44px;
        border-radius: 50%;
        background-color: var(--bg-card);
        box-shadow: var(--shadow-md);
        display: flex;
        align-items: center;
        justify-content: center;
        z-index: 100;
        cursor: pointer;
        transform: scale(0);
        transition: transform 0.3s, background-color 0.3s;
        border: 1px solid var(--border-light);
    }
    
    .back-to-top.visible {
        transform: scale(1);
    }
    
    .back-to-top:active {
        transform: scale(0.9);
    }
    
    .back-to-top svg {
        width: 20px;
        height: 20px;
        fill: var(--text-secondary);
    }
}

/* 小屏幕设备优化 */
@media (max-width: 575px) {
    :root {
        --nav-icon-size: 22px;
        --nav-button-size: 52px;
    }
    
    .parser-title {
        font-size: 1.5rem;
    }
    
    .parser-description {
        font-size: 0.9rem;
    }
    
    .app-card-title {
        font-size: 1.25rem;
    }
    
    .usage-step {
        flex-direction: column;
        align-items: center;
        text-align: center;
    }
    
    .usage-step-number {
        margin-right: 0;
        margin-bottom: 1rem;
    }
    
    /* 用户下拉菜单优化 */
    .user-dropdown {
        right: -15px;
        width: 280px;
    }
    
    /* 底部导航进一步缩小 */
    .mobile-nav-item {
        padding: 6px 0;
    }
    
    .mobile-nav-text {
        font-size: 0.65rem;
    }
}

/* PC端样式 */
@media (min-width: 992px) {
    .mobile-nav {
        display: none !important;
    }
}

/* 移动端额外优化 - APP风格增强 */
@media (max-width: 991px) {
    /* 移动端按钮优化 */
    .btn {
        min-height: 48px;
        padding: 12px 24px;
        border-radius: 12px;
        font-weight: 600;
        transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    }

    .btn-primary {
        background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
        border: none;
        box-shadow: 0 4px 16px rgba(67, 97, 238, 0.3);
    }

    .btn-primary:hover {
        transform: translateY(-2px);
        box-shadow: 0 8px 24px rgba(67, 97, 238, 0.4);
    }

    .btn-primary:active {
        transform: translateY(0);
    }

    /* 移动端警告提示优化 */
    .alert {
        border-radius: 16px;
        padding: 16px;
        margin: 16px 0;
        border: 1px solid rgba(245, 158, 11, 0.2);
    }

    .alert-warning {
        background: linear-gradient(135deg, rgba(245, 158, 11, 0.1), rgba(245, 158, 11, 0.05));
    }

    /* 触摸优化 */
    .mobile-nav-item,
    .mobile-parse-btn,
    .btn,
    .faq-question {
        -webkit-tap-highlight-color: transparent;
        touch-action: manipulation;
    }

    /* 安全区域适配 */
    @supports (padding: max(0px)) {
        .mobile-nav-container {
            padding-bottom: max(8px, env(safe-area-inset-bottom));
        }

        .mobile-parse-container {
            padding-bottom: max(24px, calc(24px + env(safe-area-inset-bottom)));
        }
    }
}