/* 移动端优化样式 */

/* 桌面端隐藏 FAB */
.fab-container {
    display: none !important;
}

/* 基础响应式设置 */
@media (max-width: 768px) {
    /* 移动端：隐藏侧边栏 */
    .sidebar {
        display: none !important;
    }
    
    /* 移动端：显示 FAB */
    .fab-container {
        display: flex !important;
    }
    
    /* 隐藏统计信息 */
    .stats-section {
        display: none !important;
    }
    
    /* 头部优化 */
    .header {
        padding: 10px 15px;
        height: auto;
        min-height: 60px;
    }
    
    .header h1 {
        font-size: 1.5rem;
        margin-bottom: 5px;
    }
    
    .header p {
        font-size: 0.9rem;
        display: none;
    }
    
    /* 搜索框优化 */
    .search-container {
        padding: 10px 15px;
        position: sticky;
        top: 0;
        z-index: 100;
        background: rgba(255, 255, 255, 0.95);
        backdrop-filter: blur(10px);
        border-bottom: 1px solid #e5e7eb;
    }
    
    .search-input {
        font-size: 16px; /* 防止iOS缩放 */
        padding: 12px 45px 12px 15px;
        border-radius: 25px;
    }
    
    .search-icon {
        right: 15px;
        top: 50%;
        transform: translateY(-50%);
    }
    
    /* 主内容区域 */
    .main-content {
        padding: 0;
        display: flex;
        flex-direction: column;
        align-items: center;
    }
    
    /* 内容头部优化 */
    .content-header {
        padding: 12px 15px;
        margin-bottom: 10px;
    }
    
    .content-title {
        font-size: 1.3rem;
        margin-bottom: 10px;
    }
    
    /* 账号卡片优化 */
    .account-card {
        margin: 10px 15px;
        padding: 15px;
        border-radius: 15px;
        box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    }
    
    .account-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }
    
    .account-info {
        flex: 1;
        width: 100%;
    }
    
    .account-name {
        font-size: 1.1rem;
        margin-bottom: 5px;
    }
    
    .account-stats {
        font-size: 0.85rem;
        gap: 15px;
    }
    
    .stat-item {
        display: flex;
        align-items: center;
        gap: 4px;
    }
    
    /* 内容网格优化 */
    .content-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
        margin-top: 15px;
        width: 100%;
        max-width: 600px;
        padding: 0 15px;
    }
    
    /* 内容项优化 */
    .content-item {
        border-radius: 10px;
        overflow: hidden;
        aspect-ratio: 1;
    }
    
    .content-item img,
    .content-item video {
        width: 100%;
        height: 100%;
        object-fit: cover;
    }
    
    /* 操作按钮优化 */
    .action-buttons {
        padding: 8px;
        background: linear-gradient(to top, rgba(0,0,0,0.8), transparent);
    }
    
    .action-btn {
        width: 32px;
        height: 32px;
        font-size: 14px;
        margin: 0 2px;
    }
    
    /* 下载按钮 */
    .download-btn {
        bottom: 8px;
        right: 8px;
        width: 36px;
        height: 36px;
        font-size: 16px;
    }
    
    /* 加载状态 */
    .loading {
        padding: 20px;
        font-size: 0.9rem;
        text-align: center;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        min-height: 200px;
    }
    
    /* 错误状态 */
    .error {
        padding: 20px;
        font-size: 0.9rem;
        text-align: center;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        min-height: 200px;
    }
    
    /* 空状态 */
    .empty-state {
        padding: 40px 20px;
        font-size: 0.9rem;
        text-align: center;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        min-height: 300px;
    }
    
    .empty-state h3 {
        font-size: 1.2rem;
    }
}

/* 小屏幕手机优化 */
@media (max-width: 480px) {
    /* 内容网格改为单列 */
    .content-grid {
        grid-template-columns: 1fr;
        gap: 10px;
    }
    
    .content-item {
        aspect-ratio: 4/3;
    }
    
    /* 账号卡片间距减小 */
    .account-card {
        margin: 8px 10px;
        padding: 12px;
    }
    
    /* 搜索容器 */
    .search-container {
        padding: 8px 10px;
    }
    
    /* 头部 */
    .header {
        padding: 8px 10px;
    }
    
    .header h1 {
        font-size: 1.3rem;
    }
    
    /* 内容控制区域优化 */
    .content-controls {
        flex-wrap: wrap;
        gap: 8px;
    }
    
    /* 隐藏"卡片大小:"文字 */
    .card-size-buttons label {
        display: none !important;
    }
    
    /* 卡片大小按钮优化 */
    .card-size-buttons {
        display: flex;
        gap: 6px;
    }
    
    .size-btn {
        padding: 6px 12px;
        font-size: 0.85rem;
        min-width: 36px;
    }
    
    /* 筛选标签优化 */
    .filter-tabs {
        padding: 3px !important;
        margin-bottom: 15px !important;
        gap: 4px !important;
    }
    
    .filter-tab {
        padding: 8px 12px !important;
        font-size: 0.85rem !important;
        gap: 6px !important;
        flex: 1;
        justify-content: center;
    }
    
    .filter-count {
        padding: 2px 6px !important;
        font-size: 0.7rem !important;
    }
    
    /* 移动端控制栏优化 - 所有控件在一行 */
    .content-controls {
        display: flex;
        flex-wrap: nowrap !important;
        gap: 8px !important;
        align-items: center;
        overflow-x: auto;
    }
    
    .card-size-buttons {
        display: flex;
        gap: 4px;
        flex-shrink: 0;
    }
    
    .card-size-buttons label {
        display: none; /* 隐藏"卡片大小:"文字 */
    }
    
    .size-btn {
        padding: 6px 10px !important;
        font-size: 0.8rem !important;
        min-width: 32px;
    }
    
    .sort-select {
        flex: 1;
        min-width: 100px;
        padding: 6px 10px;
        font-size: 0.8rem;
    }
    
    .batch-download-wrapper {
        position: relative;
        flex-shrink: 0;
    }
    
    .batch-download-btn {
        padding: 6px 10px;
        font-size: 0.85rem;
        white-space: nowrap;
    }
    
    .batch-download-btn span {
        display: none; /* 隐藏文字，只显示图标 */
    }
    
    /* 移动端下拉菜单调整 */
    .download-menu {
        /* right和left由JavaScript动态设置，不在CSS中固定 */
        min-width: 200px;
    }
}

/* FAB悬浮按钮 */
.fab-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 1000;
    pointer-events: none;
}

.fab-btn {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: linear-gradient(135deg, #742581 0%, #8b5a8c 100%);
    border: none;
    color: white;
    font-size: 24px;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(116, 37, 129, 0.4);
    transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    animation: fabPulse 2s ease-in-out infinite;
    pointer-events: auto;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

.fab-btn svg {
    width: 24px;
    height: 24px;
    pointer-events: none;
}

/* 桌面端hover效果 */
@media (hover: hover) and (pointer: fine) {
    .fab-btn:hover {
        transform: scale(1.1);
        box-shadow: 0 6px 25px rgba(116, 37, 129, 0.5);
        animation: none;
    }
}

.fab-btn:active {
    transform: scale(0.95);
    animation: none;
}

/* 账号选择弹窗 - 底部全宽弹出 */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(8px);
    z-index: 2000;
    display: none;
    animation: fadeIn 0.3s ease;
}

.modal-overlay.active {
    display: block;
}

#accountModal .modal-content {
    position: fixed !important;
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
    top: auto !important;
    width: 100% !important;
    height: auto !important;
    background: #ffffff !important;
    border-radius: 24px 24px 0 0;
    max-height: 80vh;
    overflow: hidden;
    box-shadow: 0 -8px 32px rgba(0, 0, 0, 0.2), 0 -2px 8px rgba(0, 0, 0, 0.1);
    display: block !important;
    align-items: initial !important;
    justify-content: initial !important;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    transform: translateY(0);
}

/* 弹窗打开动画 */
.modal-overlay.active #accountModal .modal-content {
    animation: slideUp 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* 弹窗关闭动画 */
.modal-overlay.closing #accountModal .modal-content {
    animation: slideDown 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* 拖动时的样式 */
#accountModal .modal-content.dragging {
    transition: none;
}

#accountModal .modal-header {
    padding: 24px 20px 16px;
    border-bottom: 1px solid #e5e7eb;
    display: flex;
    justify-content: center;
    align-items: center;
    background: #ffffff;
    position: relative;
    cursor: grab;
    -webkit-user-select: none;
    user-select: none;
}

#accountModal .modal-header:active {
    cursor: grabbing;
}

/* 拖动条指示器 */
#accountModal .modal-header::before {
    content: '';
    position: absolute;
    top: 8px;
    left: 50%;
    transform: translateX(-50%);
    width: 36px;
    height: 4px;
    background: rgba(116, 37, 129, 0.3);
    border-radius: 2px;
    transition: background 0.2s ease;
}

#accountModal .modal-header:active::before {
    background: rgba(116, 37, 129, 0.5);
}

#accountModal .modal-title {
    font-size: 1.3rem;
    font-weight: 700;
    color: #742581;
    letter-spacing: -0.5px;
    text-align: center;
    margin: 0;
}

#accountModal .modal-close {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: none;
    background: rgba(116, 37, 129, 0.1);
    color: #742581;
    font-size: 18px;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    justify-content: center;
    position: absolute;
    right: 20px;
    top: auto;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

/* 桌面端hover效果 */
@media (hover: hover) and (pointer: fine) {
    #accountModal .modal-close:hover {
        background: rgba(116, 37, 129, 0.15);
        transform: rotate(90deg);
        color: #742581;
    }
}

#accountModal .modal-body {
    padding: 16px;
    overflow-y: auto;
    max-height: calc(80vh - 80px);
    background: #f9fafb;
    -webkit-overflow-scrolling: touch;
}

/* 账号列表样式 - 全宽垂直布局 */
.account-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding-bottom: 8px;
}

.account-list-item {
    width: 100%;
    padding: 16px;
    border: none;
    border-radius: 16px;
    background: #ffffff;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    gap: 12px;
    border: 2px solid #e5e7eb;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    will-change: transform;
}

/* 桌面端hover效果 */
@media (hover: hover) and (pointer: fine) {
    .account-list-item:not(.active):hover {
        transform: translateY(-2px);
        box-shadow: 0 4px 16px rgba(116, 37, 129, 0.12), 0 2px 8px rgba(0, 0, 0, 0.06);
        background: #ffffff;
        border-color: rgba(116, 37, 129, 0.2);
    }
}

.account-list-item.active {
    background: #f3f4f6;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    border-color: #742581;
    transform: scale(1.0);
}

.account-list-item-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: white;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 700;
    font-size: 1.2rem;
    transition: all 0.3s ease;
    text-transform: uppercase;
    border: 2px solid #e5e7eb;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    letter-spacing: 0.5px;
}

.account-list-item.active .account-list-item-avatar {
    border: 2px solid #742581;
    box-shadow: 0 2px 8px rgba(116, 37, 129, 0.2);
    transform: scale(1.0);
}

.account-list-item-info {
    flex: 1;
    min-width: 0;
}

.account-list-item-name {
    font-weight: 600;
    color: #1f2937;
    margin-bottom: 4px;
    font-size: 1rem;
    transition: color 0.3s ease;
    letter-spacing: -0.3px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.account-list-item.active .account-list-item-name {
    color: #1f2937;
    font-weight: 700;
}

.account-list-item-stats {
    font-size: 0.85rem;
    color: #6b7280;
    transition: color 0.3s ease;
    font-weight: 500;
}

.account-list-item.active .account-list-item-stats {
    color: #6b7280;
}

.account-list-item-badge {
    background: #742581;
    color: white;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 0.7rem;
    font-weight: 600;
    box-shadow: 0 2px 6px rgba(116, 37, 129, 0.2);
    flex-shrink: 0;
}

.account-list-item.active .account-list-item-badge {
    background: #742581;
    color: white;
    box-shadow: 0 2px 8px rgba(116, 37, 129, 0.3);
}

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

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

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

@keyframes fabPulse {
    0%, 100% {
        box-shadow: 0 4px 20px rgba(116, 37, 129, 0.4);
    }
    50% {
        box-shadow: 0 4px 20px rgba(116, 37, 129, 0.4), 0 0 0 10px rgba(116, 37, 129, 0.15);
    }
}

/* 移动端脉冲动画优化 */
@media (hover: none) and (pointer: coarse) {
    @keyframes fabPulse {
        0%, 100% {
            box-shadow: 0 6px 24px rgba(116, 37, 129, 0.45), 0 2px 8px rgba(0, 0, 0, 0.15);
        }
        50% {
            box-shadow: 0 6px 24px rgba(116, 37, 129, 0.45), 0 2px 8px rgba(0, 0, 0, 0.15), 0 0 0 12px rgba(116, 37, 129, 0.2);
        }
    }
}

/* 触摸优化 */
@media (hover: none) and (pointer: coarse) {
    .account-list-item:not(.active):active {
        background: rgba(116, 37, 129, 0.05);
        transform: scale(0.98);
        box-shadow: 0 1px 4px rgba(116, 37, 129, 0.1);
    }
    
    .account-list-item.active:active {
        background: #e5e7eb;
        transform: scale(0.98);
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    }
    
    .fab-btn:active {
        transform: scale(0.88);
        box-shadow: 0 2px 12px rgba(116, 37, 129, 0.3);
    }
    
    .content-item:active {
        transform: scale(0.95);
        opacity: 0.9;
    }
    
    .modal-close:active {
        transform: scale(0.88);
        background: rgba(116, 37, 129, 0.2);
    }
    
    /* 移动端FAB按钮优化 */
    .fab-container {
        bottom: 24px;
        right: 16px;
    }
    
    .fab-btn {
        width: 60px;
        height: 60px;
        box-shadow: 0 6px 24px rgba(116, 37, 129, 0.45), 0 2px 8px rgba(0, 0, 0, 0.15);
    }
}

/* 横屏优化 */
@media (max-width: 768px) and (orientation: landscape) {
    #accountModal .modal-content {
        max-height: 90vh;
        border-radius: 20px 20px 0 0;
    }
    
    #accountModal .modal-body {
        max-height: calc(90vh - 70px);
    }
    
    #accountModal .modal-header {
        padding: 16px 20px 12px;
    }
    
    #accountModal .modal-title {
        font-size: 1.1rem;
    }
    
    .content-grid {
        grid-template-columns: repeat(3, 1fr);
    }
    
    .fab-container {
        bottom: 16px;
        right: 16px;
    }
}

/* 移动端内容头部 */
.mobile-content-header {
    padding: 15px;
    background: white;
    border-bottom: 1px solid #e5e7eb;
    position: sticky;
    top: 60px;
    z-index: 90;
    width: 100%;
    max-width: 600px;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}

.mobile-content-header h2 {
    font-size: 1.2rem;
    font-weight: 600;
    color: #1f2937;
    margin: 0 0 8px 0;
}

.mobile-account-stats {
    display: flex;
    gap: 12px;
    font-size: 0.85rem;
    color: #6b7280;
    justify-content: center;
}

.mobile-account-stats span {
    display: flex;
    align-items: center;
    gap: 4px;
}

/* 内容项信息 */
.content-info {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 8px;
    background: linear-gradient(to top, rgba(0,0,0,0.8), transparent);
    color: white;
    font-size: 0.75rem;
}

.content-info .account-name {
    font-weight: 600;
    margin-bottom: 2px;
}

.content-info .content-meta {
    display: flex;
    justify-content: space-between;
    opacity: 0.9;
}

/* 安全区域适配 */
@supports (padding: max(0px)) {
    .fab-container {
        bottom: calc(20px + env(safe-area-inset-bottom));
        right: calc(20px + env(safe-area-inset-right));
    }
    
    #accountModal .modal-content {
        padding-bottom: env(safe-area-inset-bottom);
        border-radius: 28px 28px 0 0;
    }
    
    #accountModal .modal-body {
        padding-bottom: calc(16px + env(safe-area-inset-bottom));
    }
    
    .mobile-content-header {
        top: calc(60px + env(safe-area-inset-top));
    }
    
    .search-container {
        top: env(safe-area-inset-top);
        padding-top: calc(10px + env(safe-area-inset-top));
    }
    
    /* 移动端触摸设备的安全区域 */
    @media (hover: none) and (pointer: coarse) {
        .fab-container {
            bottom: calc(24px + env(safe-area-inset-bottom));
            right: calc(16px + env(safe-area-inset-right));
        }
    }
}
