@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700&display=swap');

:root {
    --bg-dark: #090a0f;
    --bg-gradient: linear-gradient(135deg, #0d0e15 0%, #151827 100%);
    --card-bg: rgba(255, 255, 255, 0.03);
    --card-border: rgba(255, 255, 255, 0.06);
    --card-hover-border: rgba(124, 58, 237, 0.3);
    
    --primary: hsl(262, 83%, 58%);
    --primary-glow: rgba(124, 58, 237, 0.4);
    --secondary: hsl(192, 95%, 48%);
    --secondary-glow: rgba(6, 182, 212, 0.3);
    --success: hsl(142, 70%, 45%);
    --success-glow: rgba(16, 185, 129, 0.2);
    --error: hsl(350, 80%, 55%);
    
    --text-main: #f3f4f6;
    --text-muted: #9ca3af;
    
    --transition-smooth: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
    font-family: 'Outfit', sans-serif;
    background: var(--bg-dark);
    background-image: var(--bg-gradient);
    color: var(--text-main);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
    position: relative;
}

/* Background Glowing Orbs */
body::before, body::after {
    content: '';
    position: absolute;
    width: 300px;
    height: 300px;
    border-radius: 50%;
    z-index: 0;
    filter: blur(120px);
    opacity: 0.15;
    pointer-events: none;
}

body::before {
    top: 10%;
    left: 10%;
    background: var(--primary);
    animation: floatOrb 15s infinite alternate ease-in-out;
}

body::after {
    bottom: 15%;
    right: 10%;
    background: var(--secondary);
    animation: floatOrb 20s infinite alternate-reverse ease-in-out;
}

@keyframes floatOrb {
    0% { transform: translate(0, 0) scale(1); }
    100% { transform: translate(50px, 30px) scale(1.2); }
}

header {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 2.5rem 1.5rem 1.5rem;
    z-index: 10;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo-container {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.logo-icon {
    font-size: 2.25rem;
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    filter: drop-shadow(0 0 10px var(--primary-glow));
    animation: pulseGlow 3s infinite alternate ease-in-out;
}

@keyframes pulseGlow {
    0% { filter: drop-shadow(0 0 5px rgba(124, 58, 237, 0.2)); }
    100% { filter: drop-shadow(0 0 15px rgba(124, 58, 237, 0.6)); }
}

h1 {
    font-size: 1.8rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    background: linear-gradient(to right, #ffffff, #d8b4fe);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.badge {
    background: rgba(124, 58, 237, 0.1);
    border: 1px solid rgba(124, 58, 237, 0.2);
    color: #c084fc;
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

main {
    flex: 1;
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1.5rem 3rem;
    z-index: 10;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
}

@media (max-width: 900px) {
    main {
        grid-template-columns: 1fr;
    }
}

.card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-radius: 1.25rem;
    padding: 2rem;
    transition: var(--transition-smooth);
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.2);
}

.card:hover {
    border-color: var(--card-hover-border);
    box-shadow: 0 12px 40px 0 rgba(124, 58, 237, 0.08);
}

h2 {
    font-size: 1.3rem;
    font-weight: 600;
    margin-bottom: 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: #fff;
}

h2 svg {
    color: var(--secondary);
}

.input-group {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}

label {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-muted);
}

.url-input-wrapper {
    position: relative;
    display: flex;
    width: 100%;
}

input[type="text"] {
    width: 100%;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 0.75rem;
    padding: 1rem 1.25rem;
    color: #fff;
    font-family: inherit;
    font-size: 0.95rem;
    transition: var(--transition-smooth);
    outline: none;
}

input[type="text"]:focus {
    background: rgba(255, 255, 255, 0.05);
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-glow);
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    background: linear-gradient(135deg, var(--primary) 0%, #6d28d9 100%);
    color: #fff;
    border: none;
    border-radius: 0.75rem;
    padding: 1rem 1.75rem;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition-smooth);
    box-shadow: 0 4px 12px rgba(124, 58, 237, 0.3);
    user-select: none;
}

.btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(124, 58, 237, 0.5);
    background: linear-gradient(135deg, #8b5cf6 0%, #7c3aed 100%);
}

.btn:active:not(:disabled) {
    transform: translateY(0);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    box-shadow: none;
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #fff;
    box-shadow: none;
}

.btn-secondary:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.2);
    box-shadow: none;
    transform: translateY(-2px);
}

.btn-danger {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.2);
    color: #f87171;
    box-shadow: none;
}

.btn-danger:hover:not(:disabled) {
    background: rgba(239, 68, 68, 0.2);
    border-color: rgba(239, 68, 68, 0.4);
    box-shadow: none;
    transform: translateY(-2px);
}

/* Spinner Loader */
.spinner {
    width: 1.25rem;
    height: 1.25rem;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: #fff;
    animation: spin 0.8s linear infinite;
}

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

/* Info Section (Extracted details) */
.extracted-info {
    margin-top: 1.5rem;
    padding: 1.25rem;
    background: rgba(255, 255, 255, 0.015);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 0.75rem;
    display: none;
    animation: fadeIn 0.4s ease-out forwards;
}

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

.info-title {
    font-size: 1.05rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: #fff;
}

.info-detail {
    font-size: 0.85rem;
    color: var(--text-muted);
    word-break: break-all;
    margin-bottom: 1.25rem;
}

.stream-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    background: rgba(6, 182, 212, 0.1);
    border: 1px solid rgba(6, 182, 212, 0.2);
    color: #22d3ee;
    padding: 0.2rem 0.5rem;
    border-radius: 0.375rem;
    font-size: 0.75rem;
    font-weight: 600;
}

/* Tasks / Active downloads list */
.tasks-list {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    max-height: 380px;
    overflow-y: auto;
    padding-right: 0.5rem;
}

.tasks-list::-webkit-scrollbar {
    width: 6px;
}

.tasks-list::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.01);
    border-radius: 9999px;
}

.tasks-list::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.08);
    border-radius: 9999px;
}

.task-item {
    background: rgba(255, 255, 255, 0.015);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 0.75rem;
    padding: 1.25rem;
    position: relative;
    overflow: hidden;
}

.task-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
    margin-bottom: 0.75rem;
}

.task-title {
    font-size: 0.95rem;
    font-weight: 500;
    color: #fff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
}

.task-status-badge {
    font-size: 0.75rem;
    font-weight: 600;
    padding: 0.15rem 0.5rem;
    border-radius: 0.375rem;
    text-transform: uppercase;
}

.status-downloading {
    background: rgba(124, 58, 237, 0.15);
    border: 1px solid rgba(124, 58, 237, 0.3);
    color: #a78bfa;
}

.status-finished {
    background: rgba(16, 185, 129, 0.15);
    border: 1px solid rgba(16, 185, 129, 0.3);
    color: #34d399;
}

.status-failed {
    background: rgba(239, 68, 68, 0.15);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: #f87171;
}

.progress-container {
    width: 100%;
    height: 6px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 9999px;
    margin-bottom: 0.75rem;
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--primary) 0%, var(--secondary) 100%);
    border-radius: 9999px;
    width: 0%;
    transition: width 0.3s ease;
    box-shadow: 0 0 8px var(--primary-glow);
}

.task-details {
    display: flex;
    justify-content: space-between;
    font-size: 0.75rem;
    color: var(--text-muted);
}

.empty-state {
    text-align: center;
    color: var(--text-muted);
    padding: 3rem 1rem;
    font-size: 0.9rem;
}

/* Batch download section */
.batch-section {
    grid-column: 1 / -1;
    margin-top: 1rem;
}

@media (max-width: 900px) {
    .batch-section {
        grid-column: 1;
    }
}

.batch-list {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    margin-top: 1rem;
    margin-bottom: 1rem;
}

.batch-row {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 0.6rem;
    padding: 0.6rem 0.75rem;
    transition: var(--transition-smooth);
}

.batch-row:focus-within {
    border-color: rgba(124, 58, 237, 0.35);
}

.batch-url-input {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    color: #fff;
    font-family: inherit;
    font-size: 0.88rem;
    min-width: 0;
}

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

.batch-quality-select {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 0.4rem;
    padding: 0.35rem 0.6rem;
    color: #fff;
    font-family: inherit;
    font-size: 0.82rem;
    cursor: pointer;
    outline: none;
    white-space: nowrap;
    flex-shrink: 0;
}

.batch-row-status {
    font-size: 0.78rem;
    white-space: nowrap;
    flex-shrink: 0;
    min-width: 7rem;
    text-align: right;
    color: var(--text-muted);
}

.batch-row-status.status-analyzing {
    color: #f59e0b;
}

.batch-row-status.status-queued {
    color: #06b6d4;
}

.batch-row-status.status-done {
    color: #22c55e;
}

.batch-row-status.status-error {
    color: #f87171;
}

.batch-remove-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0.25rem 0.4rem;
    border-radius: 0.3rem;
    font-size: 1rem;
    line-height: 1;
    flex-shrink: 0;
    transition: var(--transition-smooth);
}

.batch-remove-btn:hover {
    color: #f87171;
    background: rgba(248, 113, 113, 0.1);
}

.batch-footer {
    display: flex;
    gap: 0.75rem;
    align-items: center;
    flex-wrap: wrap;
}

.batch-counter {
    margin-left: auto;
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* Downloaded files list */
.downloaded-section {
    grid-column: 1 / -1;
    margin-top: 1rem;
}

@media (max-width: 900px) {
    .downloaded-section {
        grid-column: 1;
    }
}

.files-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 1.5rem;
    margin-top: 1.5rem;
}

.file-card {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 1rem;
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    transition: var(--transition-smooth);
}

.file-card:hover {
    border-color: rgba(6, 182, 212, 0.2);
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(6, 182, 212, 0.04);
}

.file-title {
    font-size: 0.95rem;
    font-weight: 600;
    color: #fff;
    margin-bottom: 0.5rem;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    line-height: 1.4;
}

.file-meta {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 1.25rem;
    display: flex;
    gap: 1rem;
}

.file-actions {
    display: flex;
    gap: 0.75rem;
}

.file-actions .btn {
    flex: 1;
    padding: 0.6rem 1rem;
    font-size: 0.85rem;
}

/* Video Player Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(8px);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 2rem;
}

.modal-content {
    background: #0d0f17;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 1.25rem;
    width: 100%;
    max-width: 900px;
    padding: 1.5rem;
    position: relative;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
    animation: modalSlide 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

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

.close-btn {
    position: absolute;
    top: -1.25rem;
    right: -1.25rem;
    width: 2.5rem;
    height: 2.5rem;
    background: #ef4444;
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 1.25rem;
    font-weight: bold;
    box-shadow: 0 4px 10px rgba(239, 68, 68, 0.3);
    transition: var(--transition-smooth);
}

.close-btn:hover {
    transform: scale(1.1) rotate(90deg);
}

video {
    width: 100%;
    border-radius: 0.75rem;
    aspect-ratio: 16/9;
    outline: none;
    background: #000;
}

.video-modal-title {
    margin-top: 1rem;
    font-size: 1.1rem;
    font-weight: 600;
    color: #fff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
