/* CSS Variables */
:root {
    --bg-app: #0f1115;
    --bg-header: #1a1d24;
    --bg-card: #1f2229;
    --bg-card-hover: #2a2e36;
    --bg-panel: #161920;

    --text-primary: #ffffff;
    --text-secondary: #9ca3af;
    --text-muted: #6b7280;

    --primary-color: #6366f1;
    --primary-hover: #4f46e5;
    --danger-color: #ef4444;
    --danger-hover: #dc2626;
    --success-color: #10b981;
    --warning-color: #f59e0b;

    --border-color: #2d3139;
    --border-hover: #3f444e;

    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.1);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.15);
    --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.2);

    --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

body {
    margin: 0;
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background-color: var(--bg-app);
    color: var(--text-primary);
    -webkit-font-smoothing: antialiased;
}

/* App Container */
.app-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    gap: 24px;
}

/* Header */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--bg-header);
    padding: 16px 24px;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-md);
    flex-wrap: wrap;
    gap: 16px;
    position: sticky;
    top: 20px;
    z-index: 100;
}

.header-left,
.header-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.logo-icon {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, var(--primary-color), var(--primary-hover));
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
}

.logo-icon svg {
    width: 24px;
    height: 24px;
}

.status-pill {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(16, 185, 129, 0.1);
    color: var(--success-color);
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 500;
}

.status-pill.secondary {
    background: var(--bg-card);
    color: var(--text-secondary);
}

.status-dot {
    width: 8px;
    height: 8px;
    background: currentColor;
    border-radius: 50%;
    animation: pulse 2s infinite;
}

.status-pill.offline {
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger-color);
}

.status-pill.offline .status-dot {
    animation: none;
}

/* Global Volume */
.volume-global {
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--bg-card);
    padding: 8px 16px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
}

.volume-global svg {
    width: 20px;
    height: 20px;
    color: var(--text-secondary);
}

.volume-global input[type="range"] {
    width: 120px;
    accent-color: var(--primary-color);
}

.volume-global span {
    width: 40px;
    text-align: right;
    font-size: 13px;
    color: var(--text-secondary);
}

/* Buttons */
.btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    border-radius: var(--radius-md);
    font-weight: 500;
    cursor: pointer;
    border: none;
    transition: var(--transition);
    font-size: 14px;
}

.btn svg {
    width: 18px;
    height: 18px;
}

.btn-primary {
    background: var(--primary-color);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
}

.btn-danger {
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger-color);
    border: 1px solid rgba(239, 68, 68, 0.2);
}

.btn-danger:hover {
    background: var(--danger-color);
    color: white;
}

/* Multi-Play Manager */
.multi-play-panel {
    background: var(--bg-panel);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
    overflow: hidden;
    animation: slideDown 0.3s ease;
}

.panel-header {
    padding: 16px 24px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(255, 255, 255, 0.02);
}

.panel-title {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
}

.panel-title svg {
    width: 20px;
    height: 20px;
    color: var(--primary-color);
}

.badge {
    background: var(--primary-color);
    color: white;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 12px;
    font-weight: 600;
}

.playing-grid {
    padding: 16px;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 16px;
    max-height: 400px;
    overflow-y: auto;
}

/* Playing Item Card */
.playing-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    position: relative;
    overflow: hidden;
    transition: var(--transition);
}

.playing-card:hover {
    border-color: var(--primary-color);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.playing-card::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 4px;
    background: var(--success-color);
}

.playing-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
}

.playing-info {
    flex: 1;
    min-width: 0;
}

.playing-name {
    font-weight: 600;
    font-size: 14px;
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--text-primary);
}

.playing-meta {
    font-size: 12px;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 8px;
}

/* 进度条样式 */
.playing-progress {
    display: flex;
    align-items: center;
    gap: 10px;
}

.progress-slider {
    flex: 1;
    height: 4px;
    -webkit-appearance: none;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 2px;
    outline: none;
    cursor: pointer;
}

.progress-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--primary-color);
    cursor: pointer;
    transition: transform 0.1s;
}

.progress-slider::-webkit-slider-thumb:hover {
    transform: scale(1.2);
}

.progress-time {
    font-size: 11px;
    color: var(--text-muted);
    font-variant-numeric: tabular-nums;
    width: 70px;
    text-align: right;
}

.playing-controls {
    display: flex;
    align-items: center;
    gap: 8px;
}

.icon-btn {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    border: none;
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.icon-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: white;
}

.icon-btn.active {
    background: var(--primary-color);
    color: white;
}

.icon-btn.stop:hover {
    background: var(--danger-color);
    color: white;
}

/* 循环按钮激活状态 */
.icon-btn.loop-active {
    background: rgba(99, 102, 241, 0.2);
    color: var(--primary-color);
    border: 1px solid rgba(99, 102, 241, 0.5);
}

/* Audio Library */
.library-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.library-header h2 {
    font-size: 20px;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 10px;
}

.count-badge {
    background: var(--bg-card);
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 14px;
    color: var(--text-secondary);
}

.search-bar {
    position: relative;
    width: 300px;
}

.search-bar svg {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    width: 18px;
    height: 18px;
    color: var(--text-muted);
}

.search-bar input {
    width: 100%;
    padding: 10px 10px 10px 40px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: white;
    font-size: 14px;
    transition: var(--transition);
}

.search-bar input:focus {
    outline: none;
    border-color: var(--primary-color);
    background: var(--bg-card-hover);
}

/* Audio Grid & Groups */
.audio-grid {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.audio-group {
    background: rgba(255, 255, 255, 0.02);
    border-radius: var(--radius-lg);
    border: 1px solid transparent;
    transition: var(--transition);
}

.audio-group.drag-over {
    border-color: var(--primary-color);
    background: rgba(99, 102, 241, 0.05);
}

.audio-group-header {
    padding: 12px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: var(--text-muted);
    font-size: 14px;
    font-weight: 600;
    user-select: none;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

.group-title {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
}

.group-title:hover {
    color: var(--text-primary);
}

.group-actions {
    opacity: 0;
    transition: opacity 0.2s;
    display: flex;
    gap: 8px;
}

.audio-group:hover .group-actions {
    opacity: 1;
}

.audio-group-content {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 16px;
    padding: 16px;
    min-height: 60px;
    /* Ensure drop target exists even if empty */
}

/* 拖拽时的样式 */
.audio-card.dragging {
    opacity: 0.5;
    border: 2px dashed var(--primary-color);
}

.audio-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 16px;
    cursor: pointer;
    transition: var(--transition);
    position: relative;
    group: audio-card;
}

.audio-card:hover {
    border-color: var(--border-hover);
    background: var(--bg-card-hover);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

/* 悬停显示循环播放按钮 */
.card-loop-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: var(--transition);
    backdrop-filter: blur(2px);
    z-index: 5;
    border-radius: var(--radius-md);
    pointer-events: none;
    /* 关键：让点击穿透遮罩层 */
}

.audio-card:hover .card-loop-overlay {
    opacity: 1;
}

.loop-play-btn {
    background: var(--primary-color);
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 20px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    transform: translateY(10px);
    transition: var(--transition);
    pointer-events: auto;
    /* 关键：按钮恢复可点击 */
}

.audio-card:hover .loop-play-btn {
    transform: translateY(0);
}

.loop-play-btn:hover {
    background: var(--primary-hover);
    transform: scale(1.05);
}

.audio-card.playing {
    border-color: var(--success-color);
    background: rgba(16, 185, 129, 0.05);
}

.audio-icon {
    width: 48px;
    height: 48px;
    background: linear-gradient(135deg, #3b82f6, #2563eb);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    margin-bottom: 12px;
}

.audio-card.video .audio-icon {
    background: linear-gradient(135deg, #ec4899, #db2777);
}

.audio-name {
    font-weight: 600;
    font-size: 15px;
    margin-bottom: 4px;
    color: var(--text-primary);
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.audio-meta {
    font-size: 12px;
    color: var(--text-muted);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.card-actions {
    position: absolute;
    top: 12px;
    right: 12px;
    opacity: 0;
    transition: var(--transition);
    display: flex;
    gap: 4px;
    z-index: 10;
}

.audio-card:hover .card-actions {
    opacity: 1;
}

.action-btn {
    width: 28px;
    height: 28px;
    border-radius: 6px;
    border: none;
    background: rgba(0, 0, 0, 0.4);
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(4px);
}

.action-btn:hover {
    background: var(--primary-color);
}

.action-btn.delete:hover {
    background: var(--danger-color);
}

/* Empty State */
.empty-state {
    grid-column: 1 / -1;
    text-align: center;
    padding: 60px;
    color: var(--text-muted);
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    border: 2px dashed var(--border-color);
}

.empty-icon {
    font-size: 48px;
    margin-bottom: 16px;
    opacity: 0.5;
}

/* Status Bar */
.quick-status-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--bg-header);
    border-top: 1px solid var(--border-color);
    padding: 8px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 12px;
    color: var(--text-muted);
    z-index: 90;
}

/* Animations */
@keyframes pulse {
    0% {
        opacity: 1;
    }

    50% {
        opacity: 0.5;
    }

    100% {
        opacity: 1;
    }
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Toast */
.toast-container {
    position: fixed;
    bottom: 50px;
    right: 20px;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    background: var(--bg-card);
    color: white;
    padding: 12px 20px;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 8px;
    animation: slideIn 0.3s ease;
    font-size: 14px;
}

.toast.success {
    border-left: 4px solid var(--success-color);
}

.toast.error {
    border-left: 4px solid var(--danger-color);
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }

    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* Modals & Overlays */
.drop-overlay {
    position: fixed;
    inset: 0;
    background: rgba(99, 102, 241, 0.9);
    z-index: 2000;
    display: none;
    align-items: center;
    justify-content: center;
    color: white;
}

body.drag-over .drop-overlay {
    display: flex;
}

.drop-content {
    text-align: center;
}

.drop-icon {
    font-size: 64px;
    margin-bottom: 20px;
}

.modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.8);
    z-index: 2000;
    display: none;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(4px);
}

.modal.active {
    display: flex;
}

.modal-content {
    background: var(--bg-card);
    padding: 30px;
    border-radius: var(--radius-lg);
    width: 400px;
    border: 1px solid var(--border-color);
    text-align: center;
}

.progress-container {
    height: 8px;
    background: var(--bg-app);
    border-radius: 4px;
    margin: 20px 0;
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    background: var(--primary-color);
    width: 0%;
    transition: width 0.2s linear;
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-app);
}

::-webkit-scrollbar-thumb {
    background: #3f444e;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #4b5563;
}