/* 推特媒体解析器 - 深色极简风格 */

:root {
    --bg-primary: #0a0a0f;
    --bg-secondary: #12121a;
    --bg-card: #1a1a24;
    --accent-primary: #ff4757;
    --accent-secondary: #ff6b81;
    --accent-gradient: linear-gradient(135deg, #ff4757 0%, #ff6b81 100%);
    --text-primary: #f0f0f5;
    --text-secondary: #8b8b9a;
    --text-muted: #5a5a6a;
    --border-color: #2a2a3a;
    --success: #2ed573;
    --error: #ff4757;
    --shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    --radius: 16px;
    --radius-sm: 8px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Noto Sans SC', 'JetBrains Mono', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
}

/* 背景效果 */
.noise-overlay {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    opacity: 0.03;
    pointer-events: none;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)'/%3E%3C/svg%3E");
    z-index: 1000;
}

.scan-line {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 2px;
    background: var(--accent-gradient);
    opacity: 0.3;
    animation: scan 4s linear infinite;
    z-index: 999;
}

@keyframes scan {
    0% { transform: translateY(-100%); }
    100% { transform: translateY(100vh); }
}

/* 布局 */
.container {
    flex: 1;
    max-width: 800px;
    margin: 0 auto;
    padding: 60px 24px;
    width: 100%;
}

/* 头部 */
.header {
    text-align: center;
    margin-bottom: 48px;
    animation: fadeInUp 0.6s ease-out;
}

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

.logo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    margin-bottom: 14px;
}

.logo-icon {
    width: 44px; height: 44px;
    color: var(--accent-primary);
    filter: drop-shadow(0 0 20px rgba(255,71,87,.5));
}

.logo-text {
    font-size: 30px;
    font-weight: 600;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.subtitle {
    color: var(--text-secondary);
    font-size: 15px;
    font-weight: 300;
    letter-spacing: .5px;
}

/* ========== 输入区域（重构） ========== */
.input-section {
    margin-bottom: 36px;
    animation: fadeInUp 0.6s ease-out 0.1s both;
}

/* 输入框独占一行 */
.input-box {
    position: relative;
}

.url-input {
    display: block;
    width: 100%;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    outline: none;
    padding: 18px 22px;
    font-size: 15px;
    font-family: 'JetBrains Mono', monospace;
    color: var(--text-primary);
    caret-color: var(--accent-primary);
    transition: border-color .25s, box-shadow .25s;
}

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

.url-input:focus {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 4px rgba(255,71,87,.15);
}

/* 按钮行：解析 + 粘贴/清除 */
.btn-row {
    display: flex;
    gap: 12px;
    margin-top: 12px;
}

.parse-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 14px 28px;
    background: var(--accent-gradient);
    border: none;
    border-radius: var(--radius-sm);
    color: white;
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    transition: all .25s ease;
    white-space: nowrap;
}

.parse-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(255,71,87,.4);
}

.parse-btn:active:not(:disabled) { transform: translateY(0); }
.parse-btn:disabled { opacity: .55; cursor: not-allowed; transform: none; }

.btn-icon { width: 18px; height: 18px; }

/* 粘贴/清除切换按钮 */
.toggle-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    padding: 14px 24px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all .25s ease;
    white-space: nowrap;
}

.toggle-btn:hover:not(:disabled) {
    border-color: var(--text-muted);
    color: var(--text-primary);
}

.toggle-btn:disabled { opacity: .45; cursor: not-allowed; }

/* 粘贴模式（默认） */
.toggle-btn.paste-mode:hover:not(:disabled) {
    border-color: var(--success);
    color: var(--success);
}

/* 清除模式 */
.toggle-btn.clear-mode:hover:not(:disabled) {
    border-color: var(--error);
    color: var(--error);
}

.toggle-icon { width: 17px; height: 17px; transition: transform .2s ease; }
.toggle-btn:hover .toggle-icon { transform: scale(1.12); }

.hidden { display: none !important; }

/* ========== 结果区域 ========== */
.result-section {
    animation: fadeInUp .4s ease-out;
}
.result-section.hidden,
.loading-section.hidden,
.error-section.hidden { display: none; }

.result-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
}

.result-badge {
    display: inline-flex;
    align-items: center;
    padding: 6px 16px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: .5px;
}

.video-badge { background: linear-gradient(135deg, #ff4757, #ff6b81); color: #fff; }
.image-badge { background: linear-gradient(135deg, #2ed573, #7bed9f); color: #fff; }

.media-count { color: var(--text-secondary); font-size: 14px; }

/* 媒体网格 */
.media-grid {
    display: grid;
    gap: 20px;
}

/* 图片区用多列布局 */
.image-grid {
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
}

.media-item {
    background: var(--bg-card);
    border-radius: var(--radius);
    overflow: hidden;
    border: 1px solid var(--border-color);
    animation: slideIn .4s ease-out backwards;
}

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

.media-preview {
    position: relative;
    width: 100%;
    aspect-ratio: 16/9;
    background: var(--bg-primary);
    overflow: hidden;
}

.media-preview img,
.media-preview video {
    width: 100%; height: 100%;
    object-fit: cover;
}

/* 媒体底部：标签 + 下载按钮 */
.media-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 18px;
    gap: 12px;
}

.media-label {
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 400;
    flex-shrink: 0;
    max-width: 50%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.download-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 9px 20px;
    background: var(--accent-gradient);
    border: none;
    border-radius: var(--radius-sm);
    color: white;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    transition: all .2s ease;
    white-space: nowrap;
    flex-shrink: 0;
}

.download-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 16px rgba(255,71,87,.35);
}

.download-btn svg { width: 15px; height: 15px; }

/* ========== 加载状态 ========== */
.loading-section {
    display: flex;
    justify-content: center;
    padding: 60px 0;
}

.loader {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 24px;
}

.loader-ring {
    width: 56px; height: 56px;
    border: 3px solid var(--border-color);
    border-top-color: var(--accent-primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

.loader-text {
    color: var(--text-secondary);
    font-size: 14px;
    animation: pulse 1.5s ease-in-out infinite;
}

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

/* ========== 错误状态 ========== */
.error-section {
    display: flex;
    justify-content: center;
    padding: 40px 0;
}

.error-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    padding: 40px;
    background: var(--bg-card);
    border: 1px solid var(--error);
    border-radius: var(--radius);
    max-width: 400px;
    text-align: center;
}

.error-icon { width: 46px; height: 46px; color: var(--error); }

.error-message {
    color: var(--text-secondary);
    font-size: 15px;
    line-height: 1.6;
}

.retry-btn {
    padding: 11px 32px;
    background: transparent;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 14px;
    cursor: pointer;
    transition: all .2s ease;
}

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

/* 页脚 */
.footer {
    text-align: center;
    padding: 30px;
    color: var(--text-muted);
    font-size: 13px;
}

/* ========== 响应式 ========== */
@media (max-width: 640px) {
    .container { padding: 36px 16px; }
    .logo-text { font-size: 24px; }
    .logo-icon  { width: 34px; height: 34px; }

    .url-input { padding: 15px 16px; font-size: 14px; }

    .btn-row { flex-direction: row; }
    .parse-btn { padding: 13px 20px; font-size: 14px; }
    .toggle-btn { padding: 13px 18px; font-size: 13px; }

    .image-grid { grid-template-columns: 1fr; }

    .media-footer {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }

    .media-label {
        max-width: 100%;
        text-align: center;
    }

    .download-btn { justify-content: center; }
}
