/* ============================================
   媒体库 v7 - 现代化设计 + 流畅动画
   ============================================ */

/* ===== CSS Variables ===== */
:root {
    --bg: #0f0f0f;
    --card-bg: #1a1a1a;
    --header-bg: rgba(20, 20, 20, 0.85);
    --accent: #ff8c00;
    --accent-hover: #ffaa33;
    --accent-glow: rgba(255, 140, 0, 0.3);
    --text: #e8e8e8;
    --text-muted: #888;
    --thumb-bg: #141414;
    --border: #2a2a2a;
    --shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
    --shadow-hover: 0 8px 32px rgba(0, 0, 0, 0.5);
    --radius: 12px;
    --radius-sm: 8px;
    --transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

[data-theme="light"] {
    --bg: #f8f9fa;
    --card-bg: #ffffff;
    --header-bg: rgba(255, 255, 255, 0.9);
    --accent: #ff8c00;
    --accent-hover: #e67e00;
    --accent-glow: rgba(255, 140, 0, 0.2);
    --text: #1a1a1a;
    --text-muted: #666;
    --thumb-bg: #f0f0f0;
    --border: #e0e0e0;
    --shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    --shadow-hover: 0 8px 32px rgba(0, 0, 0, 0.12);
}

[data-theme="dark"] {
    --bg: #000000;
    --card-bg: #0a0a0a;
    --header-bg: rgba(10, 10, 10, 0.9);
    --accent: #999;
    --accent-hover: #bbb;
    --accent-glow: rgba(150, 150, 150, 0.2);
    --text: #d0d0d0;
    --text-muted: #666;
    --thumb-bg: #050505;
    --border: #1a1a1a;
    --shadow: 0 4px 20px rgba(0, 0, 0, 0.6);
    --shadow-hover: 0 8px 32px rgba(0, 0, 0, 0.7);
}

/* ===== Reset & Base ===== */
* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    overflow-x: hidden;
    transition: background var(--transition), color var(--transition);
}

/* ===== Scrollbar ===== */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ===== Animations ===== */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes fadeInScale {
    from { opacity: 0; transform: scale(0.95); }
    to { opacity: 1; transform: scale(1); }
}

@keyframes slideInRight {
    from { opacity: 0; transform: translateX(20px); }
    to { opacity: 1; transform: translateX(0); }
}

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

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

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

@keyframes bounceIn {
    0% { opacity: 0; transform: scale(0.3); }
    50% { transform: scale(1.05); }
    70% { transform: scale(0.9); }
    100% { opacity: 1; transform: scale(1); }
}

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-6px); }
}

/* ===== Login ===== */
.login-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: var(--bg); display: flex; align-items: center; justify-content: center;
    z-index: 9999;
    animation: fadeIn 0.4s ease;
}

.login-box {
    background: var(--card-bg); border-radius: 20px; padding: 48px 40px;
    width: 380px; box-shadow: var(--shadow); text-align: center;
    border: 1px solid var(--border);
    animation: fadeInScale 0.5s ease;
    transition: box-shadow var(--transition);
}

.login-box:hover {
    box-shadow: var(--shadow-hover), 0 0 40px var(--accent-glow);
}

.login-box h2 {
    color: var(--accent); margin-bottom: 8px; font-size: 1.8em;
    font-weight: 700; letter-spacing: -0.5px;
}

.login-box .subtitle {
    color: var(--text-muted); font-size: 0.9em; margin-bottom: 32px;
}

.login-box input {
    width: 100%; padding: 14px 18px; border: 2px solid var(--border);
    border-radius: var(--radius-sm); background: var(--bg); color: var(--text);
    font-size: 15px; outline: none; margin-bottom: 18px;
    transition: border-color var(--transition), box-shadow var(--transition);
}

.login-box input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.login-box button {
    width: 100%; padding: 14px; background: var(--accent); color: #fff;
    border: none; border-radius: var(--radius-sm); font-size: 15px;
    cursor: pointer; font-weight: 600; letter-spacing: 0.5px;
    transition: all var(--transition);
    position: relative; overflow: hidden;
}

.login-box button::before {
    content: ''; position: absolute; top: 0; left: -100%; width: 100%; height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
    transition: left 0.5s;
}

.login-box button:hover::before {
    left: 100%;
}

.login-box button:hover {
    background: var(--accent-hover); transform: translateY(-1px);
    box-shadow: 0 4px 15px var(--accent-glow);
}

.login-box button:active {
    transform: translateY(0);
}

.login-error {
    color: #e94560; font-size: 13px; margin-top: 14px; display: none;
    animation: fadeIn 0.3s ease;
}

/* ===== Header ===== */
header {
    background: var(--header-bg); backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
    padding: 14px 24px; position: sticky; top: 0; z-index: 100;
    border-bottom: 1px solid var(--border);
    display: flex; align-items: center; justify-content: space-between;
    animation: fadeIn 0.4s ease;
}

header h1 {
    font-size: 1.3em; color: var(--accent); font-weight: 700;
    letter-spacing: -0.3px;
}

.header-right {
    display: flex; align-items: center; gap: 12px;
}

#breadcrumb {
    display: flex; flex-wrap: wrap; align-items: center; gap: 4px; font-size: 0.85em;
}

.crumb {
    color: var(--accent); text-decoration: none; cursor: pointer;
    padding: 4px 8px; border-radius: 6px;
    transition: all var(--transition);
}

.crumb:hover {
    background: var(--accent-glow); text-decoration: none;
}

.crumb-sep { color: var(--text-muted); margin: 0 2px; }

/* ===== Search Box ===== */
.header-center {
    display: flex; align-items: center; gap: 12px; flex: 1; justify-content: center;
    max-width: 600px; margin: 0 20px;
}

.search-box {
    display: flex; align-items: center; background: var(--card-bg);
    border: 1px solid var(--border); border-radius: var(--radius-sm);
    overflow: hidden; flex: 1; max-width: 360px;
    transition: border-color var(--transition), box-shadow var(--transition);
}

.search-box:focus-within {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.search-box input {
    flex: 1; padding: 8px 12px; border: none; background: transparent;
    color: var(--text); font-size: 13px; outline: none; min-width: 0;
}

.search-box input::placeholder { color: var(--text-muted); }

.search-btn, .search-clear {
    background: none; border: none; color: var(--text-muted);
    padding: 8px 10px; cursor: pointer; font-size: 14px;
    transition: color var(--transition);
    flex-shrink: 0;
}

.search-btn:hover, .search-clear:hover { color: var(--accent); }

/* ===== Filter Bar ===== */
.filter-bar {
    display: flex; gap: 4px; flex-shrink: 0;
}

.filter-btn {
    background: none; border: 1px solid var(--border); color: var(--text-muted);
    padding: 5px 12px; border-radius: 20px; cursor: pointer;
    font-size: 12px; white-space: nowrap;
    transition: all var(--transition);
}

.filter-btn:hover {
    border-color: var(--accent); color: var(--accent);
}

.filter-btn.active {
    background: var(--accent); color: #fff; border-color: var(--accent);
}

.btn-sm {
    background: none; border: 1px solid var(--accent); color: var(--accent);
    padding: 6px 14px; border-radius: var(--radius-sm); cursor: pointer;
    font-size: 12px; font-weight: 500; text-decoration: none;
    transition: all var(--transition);
    position: relative; overflow: hidden;
}

.btn-sm::before {
    content: ''; position: absolute; top: 0; left: -100%; width: 100%; height: 100%;
    background: var(--accent); transition: left var(--transition); z-index: -1;
}

.btn-sm:hover {
    color: #fff; border-color: var(--accent);
}

.btn-sm:hover::before {
    left: 0;
}

/* ===== Theme Switcher ===== */
.theme-btn {
    font-size: 18px; cursor: pointer; padding: 6px 10px;
    border-radius: var(--radius-sm); background: var(--card-bg);
    border: 1px solid var(--border); transition: all var(--transition);
}

.theme-btn:hover {
    background: var(--accent-glow); border-color: var(--accent);
    transform: rotate(15deg);
}

/* ===== Grid ===== */
.media-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 16px; padding: 20px;
}

.card {
    background: var(--card-bg); border-radius: var(--radius);
    overflow: hidden; cursor: pointer;
    transition: all var(--transition);
    border: 1px solid var(--border);
    animation: fadeInUp 0.4s ease backwards;
}

.card:nth-child(1) { animation-delay: 0.02s; }
.card:nth-child(2) { animation-delay: 0.04s; }
.card:nth-child(3) { animation-delay: 0.06s; }
.card:nth-child(4) { animation-delay: 0.08s; }
.card:nth-child(5) { animation-delay: 0.10s; }
.card:nth-child(6) { animation-delay: 0.12s; }
.card:nth-child(7) { animation-delay: 0.14s; }
.card:nth-child(8) { animation-delay: 0.16s; }
.card:nth-child(9) { animation-delay: 0.18s; }
.card:nth-child(10) { animation-delay: 0.20s; }
.card:nth-child(n+11) { animation-delay: 0.22s; }

.card:hover {
    transform: translateY(-6px) scale(1.02);
    box-shadow: var(--shadow-hover), 0 0 30px var(--accent-glow);
    border-color: var(--accent);
}

.card:active {
    transform: translateY(-2px) scale(1.01);
}

.card-thumb {
    width: 100%; aspect-ratio: 1; background: var(--thumb-bg);
    display: flex; align-items: center; justify-content: center;
    overflow: hidden; position: relative;
}

.card-thumb::after {
    content: ''; position: absolute; inset: 0;
    background: linear-gradient(180deg, transparent 60%, rgba(0,0,0,0.3) 100%);
    opacity: 0; transition: opacity var(--transition);
}

.card:hover .card-thumb::after {
    opacity: 1;
}

.card-thumb img {
    width: 100%; height: 100%; object-fit: cover;
    transition: transform 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

.card:hover .card-thumb img {
    transform: scale(1.08);
}

.card-icon {
    width: 100%; aspect-ratio: 1; display: flex; align-items: center; justify-content: center;
    font-size: 3em; background: var(--thumb-bg);
    transition: transform var(--transition);
}

.card:hover .card-icon {
    transform: scale(1.1);
    animation: float 2s ease-in-out infinite;
}

.card-info { padding: 10px 12px; }

.card-name {
    font-size: 0.85em; font-weight: 500;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.card-meta {
    font-size: 0.72em; color: var(--text-muted); margin-top: 4px;
}

/* ===== Loading ===== */
.loading {
    text-align: center; padding: 60px 20px; color: var(--text-muted);
    animation: pulse 1.5s ease-in-out infinite;
}

.loading::before {
    content: ''; display: block; width: 40px; height: 40px;
    margin: 0 auto 16px; border: 3px solid var(--border);
    border-top-color: var(--accent); border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

/* ===== Modal ===== */
.modal {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.95); z-index: 1000;
    display: flex; align-items: center; justify-content: center; flex-direction: column;
    animation: fadeIn 0.3s ease;
    backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
}

.modal-main {
    flex: 1; display: flex; align-items: center; justify-content: center;
    width: 100%; position: relative; overflow: hidden;
}

.modal-main img {
    max-width: 92vw; max-height: 82vh; object-fit: contain; display: block;
    user-select: none; -webkit-user-drag: none;
    animation: fadeInScale 0.4s ease;
    transition: transform 0.3s ease;
}

.modal-main img.zoomed {
    transform: scale(2); cursor: zoom-out;
}

.modal-main video {
    max-width: 92vw; max-height: 82vh; outline: none;
    border-radius: var(--radius-sm);
}

.modal-info {
    padding: 14px 20px; color: #bbb; font-size: 0.85em; text-align: center;
    background: rgba(0, 0, 0, 0.7); width: 100%; min-height: 44px;
    display: flex; align-items: center; justify-content: center; gap: 8px;
    backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
}

.modal-close {
    position: absolute; top: 0; right: 0; color: #fff; font-size: 28px;
    cursor: pointer; z-index: 1010;
    background: rgba(0, 0, 0, 0.5); border: none; line-height: 1;
    width: 52px; height: 52px; display: flex; align-items: center; justify-content: center;
    border-radius: 0 0 0 12px; transition: all var(--transition);
    backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
}

.modal-close:hover {
    background: rgba(255, 255, 255, 0.15);
    transform: scale(1.1);
}

.modal-nav {
    position: absolute; top: 50%; color: #fff; font-size: 36px;
    cursor: pointer; z-index: 1010; transform: translateY(-50%);
    background: rgba(0, 0, 0, 0.5); border: none; line-height: 1;
    width: 56px; height: 56px; display: flex; align-items: center; justify-content: center;
    border-radius: 50%; transition: all var(--transition);
    -webkit-tap-highlight-color: transparent; user-select: none;
    backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
}

.modal-prev { left: 16px; }
.modal-next { right: 16px; }

.modal-nav:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: translateY(-50%) scale(1.1);
}

.modal-nav:active {
    background: rgba(255, 255, 255, 0.3);
    transform: translateY(-50%) scale(0.95);
}

.modal-error {
    color: #e94560; font-size: 1em; text-align: center; padding: 40px 20px;
    animation: fadeIn 0.3s ease;
}

/* ===== Upload Pages ===== */
.upload-page { min-height: 100vh; background: var(--bg); }

.upload-container {
    max-width: 800px; margin: 20px auto; padding: 0 16px;
    animation: fadeInUp 0.5s ease;
}

.upload-box {
    border: 2px dashed var(--border); border-radius: var(--radius);
    padding: 48px; text-align: center; background: var(--card-bg);
    cursor: pointer; transition: all var(--transition);
}

.upload-box:hover {
    border-color: var(--accent); background: var(--accent-glow);
    transform: translateY(-2px);
}

.upload-box.dragover {
    border-color: #2196F3; background: rgba(33, 150, 243, 0.08);
    transform: scale(1.02);
}

.upload-icon {
    font-size: 3.5em; margin-bottom: 16px;
    animation: float 3s ease-in-out infinite;
}

.upload-text {
    font-size: 1.1em; color: var(--text-muted); margin-bottom: 20px;
}

.upload-btn {
    background: var(--accent); color: #fff; padding: 12px 32px; border: none;
    border-radius: var(--radius-sm); font-size: 15px; cursor: pointer;
    font-weight: 600; transition: all var(--transition);
    position: relative; overflow: hidden;
}

.upload-btn::before {
    content: ''; position: absolute; top: 0; left: -100%; width: 100%; height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
    transition: left 0.5s;
}

.upload-btn:hover::before {
    left: 100%;
}

.upload-btn:hover {
    background: var(--accent-hover); transform: translateY(-2px);
    box-shadow: 0 4px 15px var(--accent-glow);
}

.upload-progress-area { margin-top: 24px; animation: fadeIn 0.3s ease; }

.progress-bar {
    width: 100%; height: 8px; background: var(--thumb-bg); border-radius: 4px;
    overflow: hidden; position: relative;
}

.progress-fill {
    height: 100%; background: linear-gradient(90deg, var(--accent), #4CAF50);
    width: 0%; transition: width 0.3s ease; border-radius: 4px;
    position: relative;
}

.progress-fill::after {
    content: ''; position: absolute; inset: 0;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.3), transparent);
    animation: shimmer 1.5s infinite;
}

.progress-info {
    display: flex; justify-content: space-between; align-items: center;
    margin-top: 10px; font-size: 0.82em; color: var(--text-muted);
}

.upload-controls {
    display: flex; gap: 12px; margin-top: 14px; justify-content: center;
}

.btn-pause, .btn-cancel {
    padding: 10px 28px; border: none; border-radius: var(--radius-sm);
    cursor: pointer; font-size: 14px; font-weight: 500;
    transition: all var(--transition);
}

.btn-pause {
    background: #FF9800; color: #fff;
}

.btn-pause:hover {
    background: #F57C00; transform: translateY(-1px);
}

.btn-cancel {
    background: #f44336; color: #fff;
}

.btn-cancel:hover {
    background: #d32f2f; transform: translateY(-1px);
}

.status {
    margin-top: 14px; color: var(--text-muted); font-size: 0.9em;
    animation: fadeIn 0.3s ease;
}

.file-list { margin-top: 28px; }

.file-list h2 {
    color: var(--text); font-size: 1.1em; margin-bottom: 14px;
    font-weight: 600;
}

.file-item {
    display: flex; justify-content: space-between; align-items: center;
    padding: 14px 16px; background: var(--card-bg);
    border: 1px solid var(--border); border-radius: var(--radius-sm);
    margin-bottom: 10px; transition: all var(--transition);
    animation: fadeInUp 0.4s ease backwards;
}

.file-item:hover {
    background: var(--thumb-bg); border-color: var(--accent);
    transform: translateX(4px);
}

.file-info { flex: 1; min-width: 0; }

.file-name {
    font-weight: 500; color: var(--text);
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.file-meta { color: var(--text-muted); font-size: 0.82em; margin-top: 4px; }

.file-actions { display: flex; gap: 10px; margin-left: 12px; }

.btn-action {
    padding: 7px 16px; font-size: 12px; border-radius: var(--radius-sm);
    cursor: pointer; border: 1px solid var(--border);
    background: var(--card-bg); color: var(--text); text-decoration: none;
    display: inline-block; transition: all var(--transition);
}

.btn-action:hover {
    background: var(--accent); color: #fff; border-color: var(--accent);
    transform: translateY(-1px);
}

.btn-danger { border-color: #f44336; color: #f44336; }

.btn-danger:hover {
    background: #f44336; color: #fff; border-color: #f44336;
}

.empty-msg {
    color: var(--text-muted); text-align: center; padding: 40px;
    animation: fadeIn 0.5s ease;
}

/* ===== Video Controls Bar ===== */
.video-controls-bar {
    position: absolute; bottom: 0; left: 0; right: 0;
    display: flex; align-items: center; justify-content: flex-end; gap: 12px;
    padding: 10px 18px; background: linear-gradient(transparent, rgba(0,0,0,0.7));
    z-index: 1020;
    opacity: 0; transition: opacity var(--transition);
}

.modal-main:hover .video-controls-bar {
    opacity: 1;
}

.quality-btn {
    background: rgba(255,255,255,0.15); color: #fff;
    border: 1px solid rgba(255,255,255,0.3);
    padding: 5px 14px; border-radius: var(--radius-sm);
    font-size: 12px; cursor: pointer; font-weight: 500;
    transition: all var(--transition);
}

.quality-btn:hover {
    background: rgba(255,255,255,0.25);
}

.hls-status {
    color: #aaa; font-size: 11px;
}

/* ===== Thumbnail ===== */
.file-thumb {
    width: 68px; height: 68px; border-radius: var(--radius-sm);
    overflow: hidden; background: var(--thumb-bg); flex-shrink: 0;
    margin-right: 14px; display: flex; align-items: center; justify-content: center;
    font-size: 2em; transition: all var(--transition);
}

.file-item:hover .file-thumb {
    transform: scale(1.05);
    box-shadow: 0 0 15px var(--accent-glow);
}

.file-thumb img {
    width: 100%; height: 100%; object-fit: cover;
    transition: transform 0.5s ease;
}

.file-item:hover .file-thumb img {
    transform: scale(1.1);
}

.file-thumb-audio {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    font-size: 1.8em;
}

.file-thumb-other {
    background: var(--card-bg); font-size: 1.8em;
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
    .media-grid {
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
        gap: 12px; padding: 12px;
    }

    header {
        padding: 12px 16px; flex-wrap: wrap; gap: 10px;
    }

    header h1 { font-size: 1.1em; }

    .header-center {
        order: 3; flex-basis: 100%; max-width: 100%; margin: 0;
    }

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

    .header-right { gap: 8px; }

    .modal-nav {
        width: 48px; height: 48px; font-size: 30px;
    }

    .modal-prev { left: 8px; }
    .modal-next { right: 8px; }

    .modal-close { width: 48px; height: 48px; font-size: 26px; }

    .modal-main img { max-width: 98vw; max-height: 78vh; }
    .modal-main video { max-width: 98vw; max-height: 78vh; }

    .file-thumb {
        width: 56px; height: 56px; margin-right: 10px;
    }
}

@media (max-width: 480px) {
    .media-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px; padding: 10px;
    }

    .login-box {
        width: 90%; padding: 32px 24px;
    }
}
