/* ===== 移动端优先设计 - 视觉增强版 ===== */

/* 基础移动端设置 */
* {
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
}

body {
    /* 优化移动端渲染 */
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

/* ===== 移动端导航栏 ===== */
@media (max-width: 768px) {
    /* 精简导航栏 */
    .navbar {
        padding: 8px 0;
        box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    }

    .nav-container {
        padding: 8px 12px;
        gap: 8px;
    }

    .logo {
        font-size: 18px;
        background: linear-gradient(135deg, #667eea, #764ba2);
        -webkit-background-clip: text;
        -webkit-text-fill-color: transparent;
        letter-spacing: 1px;
    }

    /* 移动端搜索框 */
    .nav-center {
        order: 3;
        flex-basis: 100%;
        padding: 8px 0;
    }

    .search-container {
        max-width: 100%;
    }

    .search-input {
        width: 100%;
        padding: 12px 45px 12px 15px;
        border-radius: 20px;
        border: 1px solid rgba(255, 255, 255, 0.3);
        background: rgba(255, 255, 255, 0.95);
        font-size: 14px;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    }

    .search-input:focus {
        background: white;
        box-shadow: 0 4px 15px rgba(102, 126, 234, 0.2);
    }

    .search-btn {
        right: 6px;
        width: 34px;
        height: 34px;
        border-radius: 50%;
    }

    /* 移动端导航菜单 - 底部固定式 */
    .nav-right {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        background: rgba(255, 255, 255, 0.98);
        backdrop-filter: blur(20px);
        padding: 8px 15px;
        padding-bottom: max(8px, env(safe-area-inset-bottom));
        box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.1);
        z-index: 999;
        display: flex;
        justify-content: space-around;
        align-items: center;
    }

    .nav-menu {
        display: flex;
        gap: 0;
        width: 100%;
        justify-content: space-around;
    }

    .nav-item {
        padding: 10px 15px;
        border-radius: 15px;
        font-size: 12px;
        flex: 1;
        text-align: center;
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 4px;
        min-width: 60px;
        position: relative;
        background: transparent !important;
        color: #666;
    }

    .nav-item::before {
        display: none;
    }

    .nav-item.active {
        color: #667eea;
        font-weight: 600;
    }

    .nav-item.active::after {
        content: '';
        position: absolute;
        bottom: -4px;
        left: 50%;
        transform: translateX(-50%);
        width: 4px;
        height: 4px;
        background: #667eea;
        border-radius: 50%;
    }

    /* 用户菜单按钮 */
    .user-menu {
        position: fixed;
        bottom: 70px;
        right: 15px;
        z-index: 998;
    }

    .user-btn {
        width: 50px;
        height: 50px;
        border-radius: 50%;
        background: linear-gradient(135deg, #667eea, #764ba2);
        color: white;
        box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .user-dropdown {
        bottom: 60px;
        right: 0;
        width: 200px;
    }

    /* 主内容区域 - 增加底部内边距以适应底部导航 */
    .main-content {
        padding: 20px 12px;
        margin-top: 60px;
        margin-bottom: 80px;
    }

    /* ===== 卡片式设计 ===== */

    /* 数学文化卡片 */
    .culture-grid {
        display: flex;
        flex-direction: column;
        gap: 16px;
    }

    .culture-card {
        background: white;
        border-radius: 16px;
        overflow: hidden;
        box-shadow: 0 4px 15px rgba(0, 0, 0, 0.08);
        transition: all 0.3s ease;
    }

    .culture-card:active {
        transform: scale(0.98);
        box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    }

    .culture-image {
        height: 160px;
        font-size: 56px;
        background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
        display: flex;
        align-items: center;
        justify-content: center;
        position: relative;
    }

    .culture-image::before {
        content: '';
        position: absolute;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: linear-gradient(to bottom, transparent 50%, rgba(0,0,0,0.1) 100%);
    }

    .culture-content {
        padding: 16px;
    }

    .culture-title {
        font-size: 17px;
        font-weight: 700;
        color: #1a202c;
        margin-bottom: 8px;
        line-height: 1.4;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
        overflow: hidden;
    }

    .culture-desc {
        font-size: 14px;
        color: #718096;
        line-height: 1.6;
        display: -webkit-box;
        -webkit-line-clamp: 3;
        -webkit-box-orient: vertical;
        overflow: hidden;
    }

    .culture-footer {
        display: flex;
        justify-content: space-between;
        align-items: center;
        margin-top: 12px;
        padding-top: 12px;
        border-top: 1px solid #f0f0f0;
    }

    .date {
        font-size: 12px;
        color: #a0aec0;
    }

    /* 操作按钮 - 移动端优化 */
    .culture-actions {
        display: flex;
        gap: 8px;
    }

    .icon-btn {
        padding: 8px 12px;
        border-radius: 20px;
        background: #f7fafc;
        color: #4a5568;
        font-size: 12px;
        display: inline-flex;
        align-items: center;
        gap: 4px;
        border: none;
        cursor: pointer;
        transition: all 0.2s;
    }

    .icon-btn:active {
        background: #e2e8f0;
        transform: scale(0.95);
    }

    .icon-btn svg {
        width: 14px;
        height: 14px;
    }

    /* ===== 习题卡片 ===== */
    .problems-list {
        display: flex;
        flex-direction: column;
        gap: 14px;
    }

    .problem-container {
        background: white;
        border-radius: 14px;
        padding: 16px;
        box-shadow: 0 3px 12px rgba(0, 0, 0, 0.06);
        border-left: 3px solid #667eea;
    }

    .problem-header {
        display: flex;
        justify-content: space-between;
        align-items: flex-start;
        gap: 10px;
        margin-bottom: 12px;
    }

    .problem-title {
        font-size: 15px;
        font-weight: 600;
        color: #1a202c;
        line-height: 1.4;
        flex: 1;
    }

    .problem-level {
        padding: 4px 10px;
        border-radius: 12px;
        font-size: 10px;
        font-weight: 600;
        flex-shrink: 0;
        text-transform: uppercase;
    }

    .level-advanced {
        background: linear-gradient(135deg, #dbeafe, #bfdbfe);
        color: #1e40af;
    }

    .problem-content {
        font-size: 13px;
        color: #4a5568;
        line-height: 1.6;
    }

    .problem-tags {
        display: flex;
        flex-wrap: wrap;
        gap: 6px;
        margin-top: 12px;
    }

    .tag {
        background: #f7fafc;
        padding: 4px 10px;
        border-radius: 12px;
        font-size: 11px;
        color: #718096;
    }

    .problem-footer {
        display: flex;
        justify-content: space-between;
        align-items: center;
        margin-top: 12px;
        padding-top: 12px;
        border-top: 1px solid #f0f0f0;
    }

    .problem-stats {
        display: flex;
        gap: 12px;
        font-size: 11px;
        color: #a0aec0;
    }

    /* ===== 视频卡片 ===== */
    .video-grid {
        display: flex;
        flex-direction: column;
        gap: 16px;
    }

    .video-card {
        background: white;
        border-radius: 14px;
        overflow: hidden;
        box-shadow: 0 3px 12px rgba(0, 0, 0, 0.06);
    }

    .video-thumbnail {
        height: 180px;
        background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 48px;
        color: white;
        position: relative;
    }

    .video-thumbnail::before {
        content: '';
        position: absolute;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
        width: 60px;
        height: 60px;
        background: rgba(255, 255, 255, 0.2);
        border-radius: 50%;
        transition: all 0.3s;
    }

    .video-thumbnail:active::before {
        transform: translate(-50%, -50%) scale(1.1);
        background: rgba(255, 255, 255, 0.3);
    }

    .video-info {
        padding: 14px;
    }

    .video-title {
        font-size: 15px;
        font-weight: 600;
        color: #1a202c;
        margin-bottom: 8px;
        line-height: 1.4;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
        overflow: hidden;
    }

    .video-desc {
        font-size: 13px;
        color: #718096;
        line-height: 1.5;
        margin-bottom: 10px;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
        overflow: hidden;
    }

    .video-stats {
        display: flex;
        flex-wrap: wrap;
        gap: 8px;
        font-size: 11px;
        color: #a0aec0;
    }

    .video-teacher {
        background: linear-gradient(135deg, #eef2ff, #e0e7ff);
        color: #4f46e5;
        padding: 4px 10px;
        border-radius: 12px;
        font-size: 11px;
        font-weight: 500;
    }

    /* ===== 筛选器 ===== */
    .filters {
        display: flex;
        gap: 8px;
        margin-top: 15px;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        padding-bottom: 5px;
    }

    .filters::-webkit-scrollbar {
        display: none;
    }

    .filter-select {
        padding: 8px 14px;
        border-radius: 20px;
        background: white;
        border: 1px solid #e2e8f0;
        color: #4a5568;
        font-size: 13px;
        cursor: pointer;
        white-space: nowrap;
        flex-shrink: 0;
    }

    /* ===== 标题区域 ===== */
    .culture-header,
    .problems-header,
    .videos-header {
        text-align: center;
        margin-bottom: 25px;
    }

    .culture-title-main,
    .problems-title-main,
    .videos-title-main {
        font-size: 28px;
        font-weight: 700;
        color: white;
        margin-bottom: 8px;
        text-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
    }

    .culture-subtitle,
    .problems-subtitle,
    .videos-subtitle {
        font-size: 14px;
        color: rgba(255, 255, 255, 0.85);
        font-weight: 400;
    }

    /* ===== 模态框优化 ===== */
    .modal {
        padding: 15px;
    }

    .modal-content {
        max-width: 100%;
        border-radius: 20px;
        max-height: 90vh;
        overflow-y: auto;
        padding: 24px 18px;
        box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    }

    .close-btn {
        top: 15px;
        right: 15px;
        width: 32px;
        height: 32px;
        font-size: 24px;
        background: #f7fafc;
        border-radius: 50%;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    /* ===== 认证表单 ===== */
    .auth-form h2 {
        font-size: 22px;
        font-weight: 700;
        text-align: center;
        margin-bottom: 25px;
        color: #1a202c;
    }

    .form-group {
        margin-bottom: 16px;
    }

    .form-label {
        font-size: 13px;
        font-weight: 600;
        color: #4a5568;
        margin-bottom: 6px;
    }

    .form-input,
    .form-textarea,
    .form-select {
        width: 100%;
        padding: 14px 16px;
        border: 1px solid #e2e8f0;
        border-radius: 12px;
        font-size: 15px;
        background: #f7fafc;
        transition: all 0.2s;
    }

    .form-input:focus,
    .form-textarea:focus,
    .form-select:focus {
        outline: none;
        border-color: #667eea;
        background: white;
        box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
    }

    .auth-btn,
    .upload-btn,
    .btn-primary {
        width: 100%;
        padding: 14px 24px;
        border-radius: 12px;
        background: linear-gradient(135deg, #667eea, #764ba2);
        color: white;
        font-size: 16px;
        font-weight: 600;
        border: none;
        cursor: pointer;
        box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
        transition: all 0.2s;
    }

    .auth-btn:active,
    .upload-btn:active,
    .btn-primary:active {
        transform: scale(0.98);
        box-shadow: 0 2px 10px rgba(102, 126, 234, 0.2);
    }

    .auth-switch {
        text-align: center;
        margin-top: 16px;
        font-size: 13px;
        color: #718096;
    }

    .auth-switch a {
        color: #667eea;
        font-weight: 600;
        text-decoration: none;
    }

    /* ===== Toast 通知 ===== */
    .toast {
        left: 15px;
        right: 15px;
        bottom: 90px;
        padding: 14px 20px;
        border-radius: 14px;
        font-size: 14px;
        text-align: center;
        box-shadow: 0 4px 15px rgba(0, 0, 0, 0.15);
        max-width: calc(100% - 30px);
    }

    /* ===== 评论区 ===== */
    .comments-modal-content {
        border-radius: 20px;
        max-height: 85vh;
        overflow: hidden;
        display: flex;
        flex-direction: column;
    }

    .comments-header {
        padding: 16px 18px;
        border-bottom: 1px solid #f0f0f0;
        display: flex;
        justify-content: space-between;
        align-items: center;
        flex-shrink: 0;
    }

    .comments-header h2 {
        font-size: 18px;
        font-weight: 700;
        color: #1a202c;
    }

    .comments-container {
        flex: 1;
        overflow-y: auto;
        padding: 16px 18px;
        -webkit-overflow-scrolling: touch;
    }

    .comment {
        margin-bottom: 16px;
        padding-bottom: 16px;
        border-bottom: 1px solid #f0f0f0;
    }

    .comment:last-child {
        border-bottom: none;
    }

    .comment-header {
        display: flex;
        align-items: center;
        gap: 10px;
        margin-bottom: 8px;
    }

    .comment-avatar {
        width: 36px;
        height: 36px;
        border-radius: 50%;
        background: linear-gradient(135deg, #667eea, #764ba2);
        display: flex;
        align-items: center;
        justify-content: center;
        color: white;
        font-weight: 600;
        font-size: 14px;
        flex-shrink: 0;
    }

    .comment-author {
        font-size: 14px;
        font-weight: 600;
        color: #1a202c;
    }

    .comment-date {
        font-size: 11px;
        color: #a0aec0;
    }

    .comment-content {
        font-size: 14px;
        color: #4a5568;
        line-height: 1.5;
        margin-left: 46px;
    }

    .comment-actions {
        display: flex;
        gap: 16px;
        margin-left: 46px;
        margin-top: 8px;
    }

    .comment-action {
        background: none;
        border: none;
        color: #718096;
        font-size: 12px;
        cursor: pointer;
        padding: 4px 0;
    }

    .comment-form {
        padding: 16px 18px;
        border-top: 1px solid #f0f0f0;
        flex-shrink: 0;
    }

    .comment-input {
        width: 100%;
        padding: 12px 14px;
        border: 1px solid #e2e8f0;
        border-radius: 12px;
        font-size: 14px;
        min-height: 80px;
        resize: none;
        font-family: inherit;
        margin-bottom: 10px;
    }

    .comment-submit-btn {
        width: 100%;
        padding: 12px 20px;
        background: linear-gradient(135deg, #667eea, #764ba2);
        color: white;
        border-radius: 10px;
        font-size: 14px;
        font-weight: 600;
        border: none;
    }

    /* ===== 管理员按钮 ===== */
    .admin-btn {
        bottom: 80px;
        right: 15px;
        padding: 12px 18px;
        border-radius: 25px;
        font-size: 12px;
        box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
    }

    /* ===== 加载动画 ===== */
    .loading .loading-spinner {
        width: 50px;
        height: 50px;
        border: 4px solid #f0f0f0;
        border-top-color: #667eea;
        border-radius: 50%;
        animation: spin 0.8s linear infinite;
    }

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

    /* ===== 内容详情 ===== */
    .content-detail {
        padding: 0;
    }

    .content-detail-title {
        font-size: 20px;
        font-weight: 700;
        color: #1a202c;
        margin-bottom: 12px;
        line-height: 1.4;
    }

    .content-detail-body {
        font-size: 15px;
        color: #4a5568;
        line-height: 1.7;
    }

    .content-detail-meta {
        display: flex;
        flex-wrap: wrap;
        gap: 12px;
        margin-top: 20px;
        padding-top: 16px;
        border-top: 1px solid #f0f0f0;
        font-size: 12px;
        color: #a0aec0;
    }

    /* ===== 备案号底部 - 移动端 ===== */
    .beian-footer {
        padding: 20px 15px;
        margin-top: 30px;
        margin-bottom: 80px;
    }

    .beian-footer a {
        font-size: 12px;
    }
}

/* 小屏手机优化 */
@media (max-width: 375px) {
    .logo {
        font-size: 16px;
    }

    .nav-item {
        padding: 8px 12px;
        font-size: 11px;
    }

    .culture-title-main,
    .problems-title-main,
    .videos-title-main {
        font-size: 24px;
    }

    .culture-title,
    .video-title {
        font-size: 16px;
    }

    .problem-title {
        font-size: 14px;
    }
}

/* 横屏优化 */
@media (max-width: 768px) and (orientation: landscape) {
    .main-content {
        margin-bottom: 70px;
        margin-top: 50px;
    }

    .culture-image,
    .video-thumbnail {
        height: 140px;
        font-size: 42px;
    }

    .modal-content {
        max-height: 95vh;
    }
}
