/* ========================================
   响应式增强样式
   优化触摸目标、过渡动画、无障碍访问
   ======================================== */

/* --- 触摸目标优化 (最小 44x44px) --- */
@media (pointer: coarse) {
    .login-btn,
    .username,
    .dropdown-item,
    .btn,
    .modal-btn,
    #search-btn {
        min-height: 44px;
        min-width: 44px;
    }

    .suggestion-item {
        padding: 14px 20px;
    }

    .scrolling-item {
        padding: 0 15px;
    }

    .tag {
        padding: 8px 16px;
    }
}

/* --- 平滑过渡动画 --- */
.scrolling-item {
    transition: background-color 0.2s ease, transform 0.15s ease;
}

.scrolling-item:active {
    transform: scale(0.98);
    background-color: #e8e8e8;
}

.btn {
    transition: all 0.2s ease, transform 0.15s ease;
}

.btn:active {
    transform: scale(0.95);
}

#search-btn:active {
    transform: scale(0.95);
}

.tag {
    transition: all 0.2s ease;
}

.tag:active {
    transform: scale(0.95);
}

/* --- 焦点状态 (键盘导航) --- */
.btn:focus-visible,
.modal-btn:focus-visible,
#search-btn:focus-visible,
.login-btn:focus-visible,
.username:focus-visible,
.suggestion-item:focus-visible,
.scrolling-item:focus-visible,
.tag:focus-visible {
    outline: 3px solid #667eea;
    outline-offset: 2px;
}

/* --- 加载骨架屏 --- */
.skeleton {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s infinite;
    border-radius: 4px;
}

@keyframes skeleton-loading {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

.skeleton-row {
    display: flex;
    padding: 16px 25px;
    border-bottom: 1px solid #eee;
}

.skeleton-cell {
    height: 16px;
    margin: 0 12px;
}

.skeleton-cell.id { flex: 0.5; }
.skeleton-cell.name { flex: 2; }
.skeleton-cell.other { flex: 1; }

/* --- Toast 通知 --- */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.toast {
    padding: 12px 20px;
    border-radius: 8px;
    color: white;
    font-size: 14px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    animation: toast-in 0.3s ease;
    max-width: 300px;
}

.toast.success { background-color: #52c41a; }
.toast.error { background-color: #e74c3c; }
.toast.warning { background-color: #faad14; }
.toast.info { background-color: #667eea; }

@keyframes toast-in {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

.toast-out {
    animation: toast-out 0.3s ease forwards;
}

@keyframes toast-out {
    from { transform: translateX(0); opacity: 1; }
    to { transform: translateX(100%); opacity: 0; }
}

/* --- 下拉刷新提示 --- */
.pull-refresh {
    text-align: center;
    padding: 10px;
    color: #999;
    font-size: 13px;
    display: none;
}

.pull-refresh.active {
    display: block;
    animation: pulse 1s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* --- 改进的搜索建议 --- */
.suggestion-item {
    transition: background-color 0.15s ease;
}

.suggestion-item:active {
    background-color: #e8e8e8;
}

.suggestion-item.highlighted {
    background-color: #f0f0f0;
}

/* --- 响应式表格优化 --- */
@media (max-width: 768px) {
    .scrolling-header {
        position: sticky;
        top: 0;
        z-index: 10;
    }

    .scrolling-container {
        -webkit-overflow-scrolling: touch;
    }
}

/* --- 暗色模式支持 --- */
@media (prefers-color-scheme: dark) {
    :root {
        --bg-primary: #1a1a2e;
        --bg-secondary: #16213e;
        --text-primary: #eee;
        --text-secondary: #aaa;
        --border-color: #333;
    }

    body {
        background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    }

    .card {
        background: #1a1a2e;
        color: var(--text-primary);
    }

    #search-input {
        background: #16213e;
        border-color: #333;
        color: var(--text-primary);
    }

    #search-input::placeholder {
        color: #666;
    }

    .scrolling-container {
        background: #16213e;
        border-color: #333;
    }

    .scrolling-item {
        border-bottom-color: #333;
    }

    .scrolling-item:hover {
        background-color: #1f2b47;
    }

    .scrolling-cell {
        color: #ccc;
    }

    .scrolling-cell.name {
        color: #eee;
    }

    .suggestion-item:hover {
        background-color: #1f2b47;
    }

    .login-modal {
        background-color: #1a1a2e;
    }

    .form-group input {
        background: #16213e;
        border-color: #333;
        color: var(--text-primary);
    }

    .stat-item,
    .ranking-item,
    .basic-info-section {
        background-color: #16213e;
    }

    .tag {
        background-color: #16213e;
        color: #ccc;
    }

    .modal-btn-secondary {
        background-color: #333;
        color: #eee;
    }
}

/* --- 减少动画 (无障碍) --- */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }

    .scrolling-content {
        animation: none;
    }
}

/* --- 高对比度模式 --- */
@media (prefers-contrast: high) {
    .btn {
        border: 2px solid currentColor;
    }

    .scrolling-header {
        border-bottom: 2px solid #333;
    }

    .scrolling-item {
        border-bottom: 1px solid #666;
    }

    .tag {
        border: 1px solid #666;
    }
}

/* --- 打印样式 --- */
@media print {
    body {
        background: white;
    }

    .card {
        box-shadow: none;
        border: 1px solid #ddd;
    }

    .login-area,
    .actions,
    .search-row {
        display: none;
    }

    .scrolling-container {
        height: auto;
        overflow: visible;
    }

    .scrolling-content {
        height: auto;
    }
}
