/* ========================================
   移动端响应式样式
   ======================================== */

@media screen and (max-width: 768px) {
    :root {
        --mobile-primary: #4a90e2;
    }
    
    body { 
        overflow-x: hidden;
        background: #f5f7fa;
        color: #333;
    }
    
    .sidebar, .mobile-header { display: none !important; }
    .app-container { flex-direction: column; min-height: 100vh; }
    
    /* ===== 顶部导航栏 ===== */
    .mobile-nav {
        position: fixed;
        top: 0; left: 0; right: 0;
        height: 48px;
        background: #fff;
        display: flex !important;
        justify-content: space-between;
        align-items: center;
        padding: 0 12px;
        box-shadow: 0 1px 4px rgba(0,0,0,0.08);
        z-index: 1000;
    }
    
    .mobile-nav-logo { display: flex; align-items: center; gap: 8px; text-decoration: none; }
    .mobile-nav-logo img { width: 26px; height: 26px; border-radius: 6px; }
    .mobile-nav-title { font-size: 15px; font-weight: 600; color: #333; text-decoration: none; }
    
    .hamburger-btn {
        width: 32px; height: 32px;
        background: none; border: none;
        cursor: pointer;
        display: flex; flex-direction: column;
        justify-content: center; align-items: center;
        gap: 3px; padding: 4px; border-radius: 6px;
    }
    
    .hamburger-btn span {
        display: block;
        width: 16px; height: 2px;
        background: #333; border-radius: 2px;
        transition: all 0.3s;
    }
    
    .hamburger-btn.active span:nth-child(1) { transform: rotate(45deg) translate(3px, 3px); }
    .hamburger-btn.active span:nth-child(2) { opacity: 0; }
    .hamburger-btn.active span:nth-child(3) { transform: rotate(-45deg) translate(3px, -3px); }
    
    /* ===== 左侧抽屉 ===== */
    .category-drawer {
        position: fixed;
        top: 0; left: -240px;
        width: 240px; height: 100vh;
        background: #2c3e50;
        box-shadow: 2px 0 12px rgba(0,0,0,0.15);
        z-index: 1001;
        transition: left 0.25s ease;
        overflow-y: auto;
        padding-top: 48px;
        display: block !important;
    }
    
    .category-drawer.open { left: 0; }
    .drawer-header { padding: 16px; background: var(--mobile-primary); color: #fff; }
    .drawer-header h3 { margin: 0 0 4px; font-size: 15px; }
    .drawer-header p { margin: 0; font-size: 11px; opacity: 0.85; }
    
    .drawer-category {
        display: flex; align-items: center;
        padding: 11px 16px;
        cursor: pointer;
        border-left: 3px solid transparent;
        color: #ecf0f1;
    }
    
    .drawer-category:hover, .drawer-category.active {
        background: rgba(255,255,255,0.1);
        border-left-color: var(--mobile-primary);
    }
    
    .drawer-category-name { flex: 1; font-size: 13px; }
    .drawer-category-count {
        background: rgba(255,255,255,0.15);
        padding: 2px 6px;
        border-radius: 8px;
        font-size: 10px; color: #bbb;
    }
    .drawer-arrow {
        font-size: 12px;
        color: #cfd8dc;
        margin-left: 8px;
    }
    .drawer-sublist {
        display: none;
        background: rgba(0, 0, 0, 0.18);
    }
    .drawer-sublist.open {
        display: block;
    }
    .drawer-subcategory {
        display: flex;
        align-items: center;
        padding: 9px 16px 9px 44px;
        color: #dce3e7;
        cursor: pointer;
        border-left: 3px solid transparent;
    }
    .drawer-subcategory.active,
    .drawer-subcategory:hover {
        background: rgba(255, 255, 255, 0.08);
        border-left-color: var(--mobile-primary);
    }
    .drawer-subcategory-dot {
        margin-right: 8px;
        color: #9fb3c1;
    }
    .drawer-subcategory-name {
        flex: 1;
        font-size: 12px;
    }
    .drawer-subcategory-count {
        font-size: 10px;
        color: #9fb3c1;
    }
    
    .drawer-overlay {
        position: fixed; inset: 0;
        background: rgba(0,0,0,0.45);
        z-index: 999;
        opacity: 0; visibility: hidden;
        transition: all 0.25s;
        display: block !important;
    }
    .drawer-overlay.show { opacity: 1; visibility: visible; }
    
    /* ===== 主内容 ===== */
    .content-wrapper { margin-top: 48px; }
    
    /* ===== Banner ===== */
    .banner {
        display: flex;
        align-items: center;
        justify-content: center;
        padding: 30px 16px;
        min-height: 100px;
        background-size: cover;
        background-position: center;
        color: #fff;
        position: relative;
    }
    
    .banner-content { text-align: center; flex: 1; }
    .banner-title { font-size: 1.3rem; }
    .banner-subtitle { font-size: 0.8rem; opacity: 0.9; }
    
    .banner-time { display: none; }
    
    /* ===== 搜索框 ===== */
    .search-container {
        padding: 10px 12px;
        background: #fff;
        box-shadow: 0 2px 8px rgba(0,0,0,0.06);
    }
    
    .search-input-wrapper { display: flex; gap: 6px; align-items: center; }
    
    .search-select {
        width: 65px;
        padding: 8px 4px;
        border: 1px solid #e0e0e0;
        border-radius: 5px;
        font-size: 12px;
        background: #fff;
        color: #333;
        flex-shrink: 0;
    }
    
    .search-input-box { flex: 1; position: relative; }
    
    .search-input {
        width: 100%;
        padding: 8px 10px;
        border: 1px solid #e0e0e0;
        border-radius: 5px;
        font-size: 13px;
        background: #fff;
        color: #333;
    }
    
    .theme-toggle-inline { display: none !important; }
    
    .search-buttons-mobile {
        display: flex;
        gap: 4px;
        flex-shrink: 0;
    }
    
    .search-btn-mobile, .netdisk-btn-mobile {
        width: 36px;
        height: 36px;
        display: flex;
        align-items: center;
        justify-content: center;
        border: none;
        border-radius: 5px;
        font-size: 16px;
        cursor: pointer;
        background: var(--mobile-primary);
        color: #fff;
    }
    
    .netdisk-btn-mobile {
        background: #1a1a1a;
    }
    
    .search-btn { display: none !important; }
    .search-engines { display: none !important; }
    .netdisk-search-btn { display: none !important; }
    
    /* ===== 分类标签页 - 移动端样式 ===== */
    .subcategory-tabs {
        gap: 12px !important;
        padding: 0 8px !important;
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }
    
    .subcategory-tabs::-webkit-scrollbar {
        display: none;
    }
    
    .subcategory-tab {
        padding: 8px 0 !important;
        font-size: 0.85rem !important;
        white-space: nowrap;
    }
    
    /* 移动端下划线指示器 - 确保丝滑过渡 */
    .underline-indicator {
        transition: all 0.35s cubic-bezier(0.25, 0.46, 0.45, 0.94) !important;
    }
    
    /* ===== 卡片网格 双列 ===== */
    .mobile-card-grid {
        padding: 10px;
        background: #f5f7fa;
        min-height: calc(100vh - 100px);
    }
    
    .category-section {
        margin-bottom: 25px;
    }
    
    .category-title {
        font-size: 14px;
        font-weight: 600;
        color: #333;
        margin-bottom: 12px;
        padding-left: 8px;
        border-left: 3px solid var(--mobile-primary);
        line-height: 1.2;
    }
    
    .card-row {
        display: grid !important;
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 10px !important;
        width: 100% !important;
    }
    
    .card {
        background: #fff;
        border-radius: 8px;
        padding: 8px;
        box-shadow: 0 1px 4px rgba(0,0,0,0.05);
        border: 1px solid #eee;
        display: flex !important;
        flex-direction: column !important;
        height: auto !important;
        min-height: auto !important;
        overflow: hidden;
    }
    
    .card-header {
        display: flex;
        align-items: center;
        gap: 8px;
        margin-bottom: 8px;
        width: 100%;
    }
    
    .card-icon {
        width: 28px;
        height: 28px;
        border-radius: 6px;
        background: #f8f9fa;
        display: flex;
        align-items: center;
        justify-content: center;
        overflow: hidden;
        flex-shrink: 0;
    }
    
    .card-icon img { 
        width: 100%; 
        height: 100%; 
        object-fit: contain; 
        padding: 2px;
    }
    
    .card-title {
        flex: 1;
        font-size: 13px;
        font-weight: 600;
        color: #333;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
    
    .card-desc {
        font-size: 11px;
        color: #777;
        line-height: 1.4;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        margin-top: 4px;
        height: 16px; /* 固定一行高度 */
    }
    
    .share-btn { display: none !important; }
    
    /* ===== 悬浮按钮 ===== */
    .mobile-float-btns {
        position: fixed;
        right: 16px;
        bottom: 20px;
        display: flex;
        flex-direction: column;
        gap: 10px;
        z-index: 1000;
    }
    
    .float-btn {
        width: 42px;
        height: 42px;
        border-radius: 50%;
        border: none;
        background: #fff;
        box-shadow: 0 2px 10px rgba(0,0,0,0.15);
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 18px;
        cursor: pointer;
        color: #333;
    }
    
    .float-top {
        background: var(--mobile-primary);
        color: #fff;
    }
    
    .scroll-top-btn { display: none !important; }
    
    /* ===== 底部 ===== */
    .site-footer {
        padding: 16px;
        background: #fff;
        border-top: 1px solid #eee;
    }
    
    .friend-links { flex-wrap: wrap; justify-content: center; gap: 8px; }
    .copyright { font-size: 10px; color: #999; text-align: center; margin-top: 10px; }
    
    /* ===== 编辑控件 ===== */
    .edit-controls {
        position: fixed;
        right: 16px;
        left: auto;
        bottom: 120px; /* 位于暗色按钮上方 */
        top: auto;
        background: transparent;
        border-radius: 0;
        padding: 0;
        box-shadow: none;
        min-width: auto;
        max-width: none;
    }
    .edit-controls .controls-title { display: none; }
    .edit-controls .btn-group {
        display: flex;
        flex-direction: column;
        gap: 8px;
    }
    .edit-controls .btn-group .action-btn {
        width: 42px;
        height: 42px;
        border-radius: 50%;
        padding: 0;
        margin: 0;
        font-size: 0;
        line-height: 0;
        box-shadow: 0 2px 10px rgba(0,0,0,0.15);
    }
    .edit-controls .btn-group .action-btn::before {
        font-size: 18px;
        line-height: 1;
    }
    .edit-controls .btn-add::before { content: "➕"; }
    .edit-controls .btn-netdisk-config::before { content: "⚙️"; }
    .edit-controls .btn-check-links::before { content: "🔍"; }
    .edit-controls .btn-refresh-icons::before { content: "🔄"; }
    .edit-controls .btn-export::before { content: "📤"; }
    .edit-controls .btn-import::before { content: "📥"; }
    .edit-controls .btn-save::before { content: "💾"; }
    .edit-controls .btn-cancel::before { content: "✖"; }
    
    .shortcut-hint { display: none; }
    .toast { bottom: 80px; font-size: 13px; padding: 10px 16px; }
    
    /* ===== 暗色模式 ===== */
    body.dark-mode .mobile-nav { background: #1a1a1a; }
    body.dark-mode .mobile-nav-title, body.dark-mode .hamburger-btn span { color: #e0e0e0; }
    body.dark-mode .search-container, body.dark-mode .card, body.dark-mode .site-footer { background: #222; }
    body.dark-mode .search-input, body.dark-mode .search-select { background: #333; border-color: #444; color: #e0e0e0; }
    body.dark-mode .card { background: #2a2a2a; border-color: #333; }
    body.dark-mode .card-title, body.dark-mode .category-title { color: #e0e0e0; }
    body.dark-mode .card-icon { background: #333; }
    body.dark-mode .site-footer { border-color: #333; }
    body.dark-mode .drawer-category { color: #ddd; }
    body.dark-mode .mobile-card-grid { background: #1a1a1a; }
    body.dark-mode .float-btn { background: #333; color: #e0e0e0; box-shadow: 0 2px 10px rgba(0,0,0,0.4); }
    body.dark-mode .float-top { background: var(--mobile-primary); color: #fff; }
}

/* 手机设备 (≤480px) */
@media screen and (max-width: 480px) {
    .banner { padding: 20px 10px; min-height: 80px; }
    .banner-title { font-size: 1.1rem; }
    .time-clock { font-size: 0.95rem; }
    
    .search-container { padding: 6px 8px; }
    .search-select { width: 55px; padding: 6px 2px; font-size: 11px; }
    .search-input { padding: 6px 8px; font-size: 12px; }
    
    .card-row { gap: 8px !important; }
    .card { padding: 8px; min-height: auto !important; }
    .card-icon { width: 24px; height: 24px; }
    .card-title { font-size: 11px; }
    .card-desc { font-size: 9px; height: 14px; }
}

/* 超小屏幕 (≤360px) */
@media screen and (max-width: 360px) {
    .mobile-nav-logo img { width: 22px; height: 22px; }
    .mobile-nav-title { font-size: 14px; }
    .category-drawer { width: 220px; left: -220px; }
    .mobile-card-grid { gap: 5px; padding: 6px 8px; }
}
