/* ==================== CSS 变量与重置 ==================== */
:root {
    --primary: #6366f1;
    --primary-dark: #4f46e5;
    --primary-light: #818cf8;
    --accent: #06b6d4;
    --accent-dark: #0891b2;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --bg: #0f172a;
    --bg-card: #1e293b;
    --bg-card-hover: #263348;
    --bg-input: #1a2332;
    --text: #e2e8f0;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --border: #334155;
    --border-light: #475569;
    --shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 12px 48px rgba(0, 0, 0, 0.55);
    --radius: 16px;
    --radius-sm: 10px;
    --radius-xs: 6px;
    --transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

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

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', 'Helvetica Neue', sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ==================== 背景粒子 ==================== */
.bg-particles {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
    overflow: hidden;
}

.particle {
    position: absolute;
    border-radius: 50%;
    background: var(--primary);
    opacity: 0.08;
    animation: floatUp linear infinite;
}

@keyframes floatUp {
    0% {
        transform: translateY(105vh) scale(0);
        opacity: 0;
    }
    10% {
        opacity: 0.1;
    }
    50% {
        opacity: 0.06;
    }
    90% {
        opacity: 0.02;
    }
    100% {
        transform: translateY(-10vh) scale(1.5);
        opacity: 0;
    }
}

/* ==================== 主容器 ==================== */
.app-container {
    position: relative;
    z-index: 1;
    max-width: 720px;
    margin: 0 auto;
    padding: 20px 16px 40px;
}

/* ==================== 头部 ==================== */
.app-header {
    text-align: center;
    padding: 28px 20px 20px;
}

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

.logo-icon {
    font-size: 2.2rem;
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
    0%,
    100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.15);
    }
}

.logo h1 {
    font-size: 2rem;
    font-weight: 700;
    background: linear-gradient(135deg, #818cf8, #06b6d4);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: -0.02em;
}

.logo-badge {
    font-size: 0.7rem;
    font-weight: 700;
    background: var(--accent);
    color: #fff;
    padding: 3px 10px;
    border-radius: 20px;
    letter-spacing: 0.05em;
    animation: badgeGlow 2s ease-in-out infinite;
}

@keyframes badgeGlow {
    0%,
    100% {
        box-shadow: 0 0 8px rgba(6, 182, 212, 0.4);
    }
    50% {
        box-shadow: 0 0 20px rgba(6, 182, 212, 0.7);
    }
}

.tagline {
    color: var(--text-secondary);
    font-size: 0.95rem;
    letter-spacing: 0.02em;
}

.connection-status {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-top: 10px;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.status-dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: var(--success);
    animation: statusPulse 2s ease-in-out infinite;
}

@keyframes statusPulse {
    0%,
    100% {
        box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.5);
    }
    50% {
        box-shadow: 0 0 0 10px rgba(16, 185, 129, 0);
    }
}

/* ==================== 模式切换 ==================== */
.mode-switch {
    display: flex;
    gap: 6px;
    background: var(--bg-card);
    border-radius: 30px;
    padding: 5px;
    margin-bottom: 24px;
    box-shadow: var(--shadow);
    position: sticky;
    top: 16px;
    z-index: 10;
}

.mode-btn {
    flex: 1;
    padding: 13px 20px;
    border: none;
    border-radius: 26px;
    cursor: pointer;
    font-size: 0.95rem;
    font-weight: 600;
    background: transparent;
    color: var(--text-secondary);
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    white-space: nowrap;
}

.mode-btn:hover {
    color: var(--text);
}

.mode-btn.active {
    background: var(--primary);
    color: #fff;
    box-shadow: 0 4px 16px rgba(99, 102, 241, 0.4);
}

.btn-icon {
    font-size: 1.1rem;
}

/* ==================== 面板 ==================== */
.panel {
    display: none;
    animation: fadeSlideIn 0.4s ease;
}

.panel.active {
    display: block;
}

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

/* ==================== 拖放区域 ==================== */
.drop-zone {
    background: var(--bg-card);
    border: 3px dashed var(--border);
    border-radius: var(--radius);
    padding: 40px 24px;
    text-align: center;
    cursor: pointer;
    transition: var(--transition);
    position: relative;
    overflow: hidden;
}

.drop-zone::before {
    content: '';
    position: absolute;
    inset: -2px;
    border-radius: var(--radius);
    background: linear-gradient(135deg, var(--primary), var(--accent));
    opacity: 0;
    z-index: -1;
    transition: opacity 0.35s ease;
}

.drop-zone:hover {
    border-color: var(--primary-light);
    background: var(--bg-card-hover);
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.drop-zone:hover::before {
    opacity: 0.08;
}

.drop-zone.drag-over {
    border-color: var(--accent);
    background: rgba(6, 182, 212, 0.06);
    transform: scale(1.01);
    box-shadow: 0 0 40px rgba(6, 182, 212, 0.25);
}

.drop-zone.drag-over .drop-icon {
    animation: bounce 0.5s ease;
}

@keyframes bounce {
    0%,
    100% {
        transform: translateY(0);
    }
    30% {
        transform: translateY(-14px);
    }
    50% {
        transform: translateY(0);
    }
    70% {
        transform: translateY(-6px);
    }
}

.drop-icon {
    color: var(--primary-light);
    margin-bottom: 12px;
    transition: var(--transition);
}

.drop-zone h3 {
    font-size: 1.2rem;
    margin-bottom: 6px;
    color: var(--text);
}

.drop-zone p {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 2px;
}

.hint-text {
    font-size: 0.78rem !important;
    color: var(--text-muted) !important;
    margin-top: 6px !important;
}

/* 接收面板的拖放区 */
.receive-drop-zone {
    border-color: var(--border);
}

.receive-drop-zone:hover {
    border-color: var(--accent);
}

.receive-icon {
    color: var(--accent);
}

/* ==================== 文件列表 ==================== */
.file-list-container {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 20px 24px;
    margin-top: 16px;
    box-shadow: var(--shadow);
    display: none;
}

.file-list-container.visible {
    display: block;
}

.file-list-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 14px;
}

.file-list-header h3 {
    font-size: 1rem;
    color: var(--text);
}

.btn-clear {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-secondary);
    padding: 6px 14px;
    border-radius: 20px;
    cursor: pointer;
    font-size: 0.8rem;
    transition: var(--transition);
}

.btn-clear:hover {
    border-color: var(--danger);
    color: var(--danger);
    background: rgba(239, 68, 68, 0.08);
}

.file-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 320px;
    overflow-y: auto;
    padding-right: 4px;
}

.file-list::-webkit-scrollbar {
    width: 5px;
}

.file-list::-webkit-scrollbar-track {
    background: transparent;
}

.file-list::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 10px;
}

.file-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    background: var(--bg-input);
    border-radius: var(--radius-sm);
    transition: var(--transition);
    border: 1px solid transparent;
}

.file-item:hover {
    border-color: var(--border-light);
    background: var(--bg-card-hover);
}

.file-item-icon {
    width: 42px;
    height: 42px;
    border-radius: var(--radius-xs);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    flex-shrink: 0;
    background: var(--bg-card);
}

.file-item-icon.image {
    background: rgba(99, 102, 241, 0.15);
    color: #818cf8;
}

.file-item-icon.document {
    background: rgba(6, 182, 212, 0.15);
    color: #06b6d4;
}

.file-item-icon.video {
    background: rgba(245, 158, 11, 0.15);
    color: #f59e0b;
}

.file-item-icon.archive {
    background: rgba(16, 185, 129, 0.15);
    color: #10b981;
}

.file-item-icon.code {
    background: rgba(239, 68, 68, 0.15);
    color: #ef4444;
}

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

.file-item-name {
    font-weight: 600;
    font-size: 0.9rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--text);
}

.file-item-meta {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 2px;
    display: flex;
    gap: 10px;
}

.file-item-actions {
    display: flex;
    gap: 6px;
    flex-shrink: 0;
}

.btn-icon-sm {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 1px solid var(--border);
    background: transparent;
    cursor: pointer;
    font-size: 0.85rem;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
}

.btn-icon-sm:hover {
    background: var(--bg-card-hover);
    border-color: var(--border-light);
    color: var(--text);
}

.btn-icon-sm.danger:hover {
    border-color: var(--danger);
    color: var(--danger);
    background: rgba(239, 68, 68, 0.1);
}

.total-size {
    margin-top: 10px;
    font-size: 0.82rem;
    color: var(--text-muted);
    text-align: right;
    font-weight: 500;
}

/* ==================== 操作栏 ==================== */
.action-bar {
    display: flex;
    gap: 10px;
    margin-top: 16px;
    flex-wrap: wrap;
}

.btn {
    flex: 1;
    min-width: 140px;
    padding: 14px 22px;
    border: none;
    border-radius: 30px;
    cursor: pointer;
    font-size: 0.95rem;
    font-weight: 600;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    letter-spacing: 0.01em;
}

.btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
    pointer-events: none;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: #fff;
    box-shadow: 0 4px 16px rgba(99, 102, 241, 0.35);
}

.btn-primary:hover:not(:disabled) {
    box-shadow: 0 6px 24px rgba(99, 102, 241, 0.5);
    transform: translateY(-2px);
}

.btn-primary:active:not(:disabled) {
    transform: translateY(0);
    box-shadow: 0 2px 8px rgba(99, 102, 241, 0.3);
}

.btn-secondary {
    background: var(--bg-card);
    color: var(--text);
    border: 2px solid var(--border);
}

.btn-secondary:hover:not(:disabled) {
    border-color: var(--primary-light);
    background: var(--bg-card-hover);
    transform: translateY(-2px);
}

/* ==================== 进度条 ==================== */
.progress-container {
    margin-top: 16px;
    display: none;
}

.progress-container.visible {
    display: block;
}

.progress-bar {
    height: 8px;
    background: var(--bg-card);
    border-radius: 10px;
    overflow: hidden;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.3);
}

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

.progress-fill::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(90deg,
            transparent,
            rgba(255, 255, 255, 0.25),
            transparent);
    animation: shimmer 1.6s infinite;
}

@keyframes shimmer {
    0% {
        transform: translateX(-100%);
    }
    100% {
        transform: translateX(100%);
    }
}

.progress-text {
    text-align: center;
    margin-top: 8px;
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-weight: 500;
}

/* ==================== 传输记录 ==================== */
.history-container {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 20px 24px;
    margin-top: 16px;
    box-shadow: var(--shadow);
}

.history-container h3 {
    font-size: 1rem;
    margin-bottom: 12px;
    color: var(--text);
}

.history-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 240px;
    overflow-y: auto;
}

.history-empty {
    text-align: center;
    color: var(--text-muted);
    padding: 20px;
    font-size: 0.9rem;
}

.history-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    background: var(--bg-input);
    border-radius: var(--radius-xs);
    font-size: 0.85rem;
    gap: 10px;
    flex-wrap: wrap;
}

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

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

.history-item-meta {
    font-size: 0.72rem;
    color: var(--text-muted);
    margin-top: 2px;
}

.history-item-badge {
    font-size: 0.7rem;
    padding: 4px 10px;
    border-radius: 14px;
    font-weight: 600;
    white-space: nowrap;
}

.history-item-badge.sent {
    background: rgba(99, 102, 241, 0.2);
    color: #818cf8;
}

.history-item-badge.received {
    background: rgba(6, 182, 212, 0.2);
    color: #06b6d4;
}

/* ==================== Toast ==================== */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
}

.toast {
    padding: 14px 20px;
    border-radius: var(--radius-sm);
    color: #fff;
    font-weight: 600;
    font-size: 0.9rem;
    box-shadow: var(--shadow-lg);
    animation: slideInRight 0.35s ease, fadeOut 0.3s ease 2.2s forwards;
    pointer-events: auto;
    max-width: 380px;
}

.toast.success {
    background: var(--success);
}

.toast.error {
    background: var(--danger);
}

.toast.info {
    background: var(--accent);
}

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

@keyframes fadeOut {
    to {
        opacity: 0;
        transform: translateY(-10px);
    }
}

/* ==================== 模态框 ==================== */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    z-index: 999;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    backdrop-filter: blur(4px);
}

.modal-overlay.visible {
    opacity: 1;
    pointer-events: auto;
}

.modal {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 24px;
    max-width: 560px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.modal-header h3 {
    color: var(--text);
    font-size: 1.1rem;
}

.modal-close {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    border: 1px solid var(--border);
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 1rem;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-close:hover {
    border-color: var(--danger);
    color: var(--danger);
    background: rgba(239, 68, 68, 0.1);
}

.modal-body img {
    max-width: 100%;
    border-radius: var(--radius-xs);
}

.modal-body pre {
    background: var(--bg-input);
    padding: 14px;
    border-radius: var(--radius-xs);
    overflow-x: auto;
    font-size: 0.8rem;
    color: var(--text-secondary);
    max-height: 300px;
    overflow-y: auto;
}

/* ==================== 响应式 ==================== */
@media (max-width: 600px) {
    .app-container {
        padding: 10px 10px 30px;
    }

    .app-header {
        padding: 16px 8px 10px;
    }

    .logo h1 {
        font-size: 1.5rem;
    }

    .logo-icon {
        font-size: 1.6rem;
    }

    .drop-zone {
        padding: 28px 16px;
    }

    .drop-zone h3 {
        font-size: 1rem;
    }

    .drop-icon svg {
        width: 44px;
        height: 44px;
    }

    .mode-btn {
        padding: 10px 14px;
        font-size: 0.85rem;
    }

    .btn {
        padding: 12px 16px;
        font-size: 0.85rem;
        min-width: 120px;
    }

    .file-item {
        padding: 10px;
        gap: 8px;
    }

    .file-item-icon {
        width: 34px;
        height: 34px;
        font-size: 1.1rem;
    }

    .file-item-name {
        font-size: 0.8rem;
    }

    .toast {
        max-width: 280px;
        font-size: 0.8rem;
        padding: 10px 16px;
    }

    .action-bar {
        flex-direction: column;
    }

    .history-item {
        flex-direction: column;
        align-items: flex-start;
    }
}