/* ============================================
   TubeGrab - YouTube Downloader Styles
   Dark theme with vibrant accents
   ============================================ */

:root {
    /* Core Colors */
    --bg-primary: #0a0a0f;
    --bg-secondary: #12121a;
    --bg-tertiary: #1a1a24;
    --bg-elevated: #22222e;
    
    /* Text */
    --text-primary: #f0f0f5;
    --text-secondary: #9090a0;
    --text-muted: #606070;
    
    /* Accent Colors */
    --accent-primary: #ff3366;
    --accent-secondary: #ff6699;
    --accent-gradient: linear-gradient(135deg, #ff3366 0%, #ff6699 50%, #ff9966 100%);
    
    /* Status Colors */
    --status-success: #00cc88;
    --status-warning: #ffaa00;
    --status-error: #ff4455;
    --status-info: #3399ff;
    
    /* Borders & Shadows */
    --border-subtle: rgba(255, 255, 255, 0.06);
    --border-medium: rgba(255, 255, 255, 0.12);
    --shadow-soft: 0 4px 24px rgba(0, 0, 0, 0.4);
    --shadow-elevated: 0 8px 40px rgba(0, 0, 0, 0.6);
    
    /* Sizing */
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    
    /* Typography */
    --font-display: 'Outfit', sans-serif;
    --font-mono: 'JetBrains Mono', monospace;
}

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

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--font-display);
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.5;
}

/* Scrollbar Styling */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-secondary);
}

::-webkit-scrollbar-thumb {
    background: var(--bg-elevated);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* App Container */
.app-container {
    max-width: 1000px;
    margin: 0 auto;
    padding: 24px;
    min-height: 100vh;
}

/* Header */
.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 0;
    margin-bottom: 32px;
    border-bottom: 1px solid var(--border-subtle);
}

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

.logo-icon {
    width: 36px;
    height: 36px;
    color: var(--accent-primary);
}

.logo-text {
    font-size: 1.5rem;
    font-weight: 700;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: -0.02em;
}

.header-stats {
    display: flex;
    gap: 20px;
}

.stat {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.stat-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    animation: pulse 2s ease-in-out infinite;
}

.stat-dot.active {
    background: var(--status-info);
}

.stat-dot.completed {
    background: var(--status-success);
}

.stat-value {
    font-family: var(--font-mono);
    font-weight: 600;
    color: var(--text-primary);
}

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

/* Main Content */
.main-content {
    display: flex;
    flex-direction: column;
    gap: 32px;
}

/* URL Input Section */
.url-section {
    text-align: center;
}

.url-input-container {
    max-width: 700px;
    margin: 0 auto;
}

.url-input-wrapper {
    display: flex;
    align-items: center;
    background: var(--bg-secondary);
    border: 1px solid var(--border-medium);
    border-radius: var(--radius-lg);
    padding: 6px;
    transition: all 0.3s ease;
}

.url-input-wrapper:focus-within {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(255, 51, 102, 0.15);
}

.url-icon {
    width: 24px;
    height: 24px;
    margin-left: 16px;
    color: var(--text-muted);
    flex-shrink: 0;
}

.url-input {
    flex: 1;
    background: transparent;
    border: none;
    padding: 14px 16px;
    font-size: 1rem;
    font-family: var(--font-display);
    color: var(--text-primary);
    outline: none;
}

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

.analyze-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: var(--accent-gradient);
    border: none;
    border-radius: var(--radius-md);
    padding: 14px 28px;
    font-size: 0.95rem;
    font-weight: 600;
    font-family: var(--font-display);
    color: white;
    cursor: pointer;
    transition: all 0.2s ease;
    min-width: 120px;
}

.analyze-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(255, 51, 102, 0.4);
}

.analyze-btn:active {
    transform: translateY(0);
}

.analyze-btn.loading .btn-text {
    display: none;
}

.analyze-btn.loading .btn-spinner {
    display: block;
}

.btn-spinner {
    display: none;
    width: 20px;
    height: 20px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

.url-hint {
    margin-top: 12px;
    font-size: 0.85rem;
    color: var(--text-muted);
}

/* Video Section */
.video-section {
    animation: fadeIn 0.4s ease;
}

.video-section.hidden {
    display: none;
}

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

.video-card {
    display: flex;
    gap: 24px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-xl);
    padding: 24px;
    box-shadow: var(--shadow-soft);
}

.video-thumbnail-container {
    position: relative;
    flex-shrink: 0;
    width: 280px;
    border-radius: var(--radius-md);
    overflow: hidden;
}

.video-thumbnail {
    width: 100%;
    aspect-ratio: 16/9;
    object-fit: cover;
    background: var(--bg-tertiary);
}

.video-duration {
    position: absolute;
    bottom: 8px;
    right: 8px;
    background: rgba(0, 0, 0, 0.85);
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    font-family: var(--font-mono);
    font-weight: 500;
}

.video-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.video-title {
    font-size: 1.25rem;
    font-weight: 600;
    line-height: 1.4;
    color: var(--text-primary);
}

.video-uploader {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

/* Format Selection */
.format-selection {
    margin-top: 8px;
}

.format-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
}

.format-tab {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 10px 18px;
    font-size: 0.9rem;
    font-weight: 500;
    font-family: var(--font-display);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s ease;
}

.format-tab svg {
    width: 18px;
    height: 18px;
}

.format-tab:hover {
    background: var(--bg-elevated);
    color: var(--text-primary);
}

.format-tab.active {
    background: var(--bg-elevated);
    border-color: var(--accent-primary);
    color: var(--text-primary);
}

.format-options {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.format-option {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    background: var(--bg-tertiary);
    border: 2px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 12px 20px;
    cursor: pointer;
    transition: all 0.2s ease;
    min-width: 90px;
}

.format-option:hover {
    border-color: var(--text-muted);
    transform: translateY(-2px);
}

.format-option.selected {
    border-color: var(--accent-primary);
    background: rgba(255, 51, 102, 0.1);
}

.format-option .format-label {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.format-option .format-size {
    font-size: 0.75rem;
    font-family: var(--font-mono);
    color: var(--text-muted);
}

/* Plex Toggle */
.plex-toggle-container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 12px 16px;
    margin-top: 12px;
}

.plex-toggle-container.hidden {
    display: none;
}

.plex-toggle {
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    user-select: none;
}

.plex-toggle input {
    display: none;
}

.plex-toggle-slider {
    position: relative;
    width: 44px;
    height: 24px;
    background: var(--bg-primary);
    border-radius: 12px;
    transition: all 0.3s ease;
    flex-shrink: 0;
}

.plex-toggle-slider::before {
    content: '';
    position: absolute;
    top: 3px;
    left: 3px;
    width: 18px;
    height: 18px;
    background: var(--text-muted);
    border-radius: 50%;
    transition: all 0.3s ease;
}

.plex-toggle input:checked + .plex-toggle-slider {
    background: rgba(229, 160, 21, 0.3);
}

.plex-toggle input:checked + .plex-toggle-slider::before {
    transform: translateX(20px);
    background: #e5a015;
}

.plex-toggle-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-secondary);
    transition: color 0.2s ease;
}

.plex-toggle-label svg {
    width: 18px;
    height: 18px;
    color: #e5a015;
}

.plex-toggle input:checked ~ .plex-toggle-label {
    color: var(--text-primary);
}

.plex-toggle-hint {
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* Download Button */
.download-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    background: var(--accent-gradient);
    border: none;
    border-radius: var(--radius-md);
    padding: 14px 28px;
    font-size: 1rem;
    font-weight: 600;
    font-family: var(--font-display);
    color: white;
    cursor: pointer;
    margin-top: auto;
    transition: all 0.2s ease;
    align-self: flex-start;
}

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

.download-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(255, 51, 102, 0.4);
}

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

/* Queue Section */
.queue-section {
    background: var(--bg-secondary);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-xl);
    padding: 24px;
}

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

.queue-actions {
    display: flex;
    gap: 10px;
    align-items: center;
}

.queue-title {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.queue-title svg {
    width: 22px;
    height: 22px;
    color: var(--accent-primary);
}

.clear-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    background: transparent;
    border: 1px solid var(--border-medium);
    border-radius: var(--radius-md);
    padding: 8px 16px;
    font-size: 0.85rem;
    font-weight: 500;
    font-family: var(--font-display);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s ease;
}

.clear-btn svg {
    width: 16px;
    height: 16px;
}

.clear-btn:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.stop-all-btn {
    border-color: rgba(255, 87, 87, 0.3);
    color: #ff5757;
}

.stop-all-btn:hover {
    background: rgba(255, 87, 87, 0.1);
    border-color: rgba(255, 87, 87, 0.5);
    color: #ff5757;
}

.queue-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.queue-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 48px 24px;
    color: var(--text-muted);
    text-align: center;
}

.queue-empty svg {
    width: 48px;
    height: 48px;
    margin-bottom: 16px;
    opacity: 0.5;
}

.queue-empty p {
    font-size: 1rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.queue-empty span {
    font-size: 0.85rem;
}

/* Queue Item */
.queue-item {
    display: flex;
    align-items: center;
    gap: 16px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 14px 18px;
    transition: all 0.2s ease;
}

.queue-item:hover {
    background: var(--bg-elevated);
}

.queue-item-thumbnail {
    width: 80px;
    height: 45px;
    border-radius: var(--radius-sm);
    object-fit: cover;
    background: var(--bg-primary);
    flex-shrink: 0;
}

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

.queue-item-title {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 4px;
}

.queue-item-meta {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.queue-item-format {
    font-family: var(--font-mono);
    background: var(--bg-primary);
    padding: 2px 8px;
    border-radius: var(--radius-sm);
}

.queue-item-progress {
    width: 160px;
    flex-shrink: 0;
}

.progress-bar-container {
    height: 6px;
    background: var(--bg-primary);
    border-radius: 3px;
    overflow: hidden;
    margin-bottom: 4px;
}

.progress-bar {
    height: 100%;
    background: var(--accent-gradient);
    border-radius: 3px;
    transition: width 0.3s ease;
}

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

.queue-item-status {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
    font-weight: 500;
    min-width: 100px;
    justify-content: center;
}

.queue-item-status.queued {
    background: rgba(255, 170, 0, 0.15);
    color: var(--status-warning);
}

.queue-item-status.downloading {
    background: rgba(51, 153, 255, 0.15);
    color: var(--status-info);
}

.queue-item-status.processing {
    background: rgba(153, 51, 255, 0.15);
    color: #9933ff;
}

.queue-item-status.converting {
    background: rgba(255, 170, 0, 0.2);
    color: var(--status-warning);
    animation: pulse 2s ease-in-out infinite;
}

.queue-item-status.completed {
    background: rgba(0, 204, 136, 0.15);
    color: var(--status-success);
}

.queue-item-status.failed {
    background: rgba(255, 68, 85, 0.15);
    color: var(--status-error);
}

.queue-item-status.cancelled {
    background: rgba(96, 96, 112, 0.15);
    color: var(--text-muted);
}

.queue-item-status-wrapper {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 6px;
    min-width: 100px;
}

.queue-item-error {
    display: flex;
    align-items: flex-start;
    gap: 6px;
    padding: 8px 10px;
    background: rgba(255, 68, 85, 0.1);
    border: 1px solid rgba(255, 68, 85, 0.3);
    border-radius: var(--radius-sm);
    color: var(--status-error);
    font-size: 0.75rem;
    line-height: 1.4;
    max-width: 300px;
    cursor: help;
}

.queue-item-error .error-icon {
    width: 14px;
    height: 14px;
    flex-shrink: 0;
    margin-top: 1px;
}

.queue-item-error .error-text {
    word-break: break-word;
}

.queue-item-actions {
    display: flex;
    gap: 8px;
}

.queue-action-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background: var(--bg-primary);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s ease;
}

.queue-action-btn svg {
    width: 16px;
    height: 16px;
}

.queue-action-btn:hover {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

.queue-action-btn.cancel:hover {
    background: rgba(255, 68, 85, 0.15);
    color: var(--status-error);
    border-color: var(--status-error);
}

.queue-action-btn.retry:hover {
    background: rgba(51, 153, 255, 0.15);
    color: var(--status-info);
    border-color: var(--status-info);
}

.queue-action-btn.download-file {
    background: rgba(0, 204, 136, 0.1);
    border-color: var(--status-success);
    color: var(--status-success);
}

.queue-action-btn.download-file:hover {
    background: rgba(0, 204, 136, 0.25);
    transform: scale(1.05);
}

/* Modal */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    animation: fadeIn 0.2s ease;
}

.modal-overlay.hidden {
    display: none;
}

.modal {
    background: var(--bg-secondary);
    border: 1px solid var(--border-medium);
    border-radius: var(--radius-xl);
    width: 90%;
    max-width: 500px;
    max-height: 80vh;
    overflow: hidden;
    box-shadow: var(--shadow-elevated);
    animation: slideUp 0.3s ease;
}

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

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-subtle);
}

.modal-title {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.1rem;
    font-weight: 600;
}

.modal-title svg {
    width: 22px;
    height: 22px;
    color: var(--accent-primary);
}

.modal-close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background: transparent;
    border: none;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.2s ease;
}

.modal-close:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.modal-close svg {
    width: 20px;
    height: 20px;
}

.modal-body {
    padding: 24px;
}

.playlist-info {
    text-align: center;
    margin-bottom: 24px;
    color: var(--text-secondary);
}

.playlist-info strong {
    color: var(--accent-primary);
    font-family: var(--font-mono);
}

.playlist-options {
    display: flex;
    gap: 12px;
    margin-bottom: 24px;
}

.playlist-option {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    background: var(--bg-tertiary);
    border: 2px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: 24px 16px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.playlist-option svg {
    width: 36px;
    height: 36px;
    color: var(--text-secondary);
    transition: color 0.2s ease;
}

.playlist-option span {
    font-weight: 500;
    color: var(--text-secondary);
    transition: color 0.2s ease;
}

.playlist-option:hover {
    border-color: var(--accent-primary);
    transform: translateY(-2px);
}

.playlist-option:hover svg,
.playlist-option:hover span {
    color: var(--text-primary);
}

.playlist-preview {
    max-height: 200px;
    overflow-y: auto;
    border-top: 1px solid var(--border-subtle);
    padding-top: 16px;
}

.playlist-preview-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 0;
    border-bottom: 1px solid var(--border-subtle);
}

.playlist-preview-item:last-child {
    border-bottom: none;
}

.playlist-preview-index {
    font-family: var(--font-mono);
    font-size: 0.85rem;
    color: var(--text-muted);
    min-width: 28px;
}

.playlist-preview-title {
    flex: 1;
    font-size: 0.9rem;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Toast Notifications */
.toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    z-index: 2000;
}

.toast {
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--bg-elevated);
    border: 1px solid var(--border-medium);
    border-radius: var(--radius-md);
    padding: 14px 18px;
    box-shadow: var(--shadow-elevated);
    animation: slideIn 0.3s ease;
    min-width: 280px;
}

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

.toast.success {
    border-left: 3px solid var(--status-success);
}

.toast.error {
    border-left: 3px solid var(--status-error);
}

.toast.info {
    border-left: 3px solid var(--status-info);
}

.toast-icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

.toast.success .toast-icon {
    color: var(--status-success);
}

.toast.error .toast-icon {
    color: var(--status-error);
}

.toast.info .toast-icon {
    color: var(--status-info);
}

.toast-message {
    flex: 1;
    font-size: 0.9rem;
    color: var(--text-primary);
}

.toast-close {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px;
}

.toast-close:hover {
    color: var(--text-primary);
}

/* Responsive */
@media (max-width: 768px) {
    .app-container {
        padding: 16px;
    }

    .video-card {
        flex-direction: column;
    }

    .video-thumbnail-container {
        width: 100%;
    }

    .queue-item {
        flex-wrap: wrap;
    }

    .queue-item-progress {
        width: 100%;
        order: 10;
    }

    .playlist-options {
        flex-direction: column;
    }
}

