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

:root {
    --bg-primary: #0f0f0f;
    --bg-secondary: #1a1a2e;
    --bg-card: #16213e;
    --bg-input: #1a1a2e;
    --text-primary: #e4e4e4;
    --text-secondary: #a0a0a0;
    --accent: #e94560;
    --accent-hover: #c73650;
    --success: #00d474;
    --warning: #f5a623;
    --border: #2a2a4a;
    --shadow: rgba(0, 0, 0, 0.3);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
}

/* Navbar */
.navbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 2rem;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
}

.navbar-brand a {
    color: var(--text-primary);
    text-decoration: none;
    font-size: 1.4rem;
    font-weight: 700;
}

.navbar-links a {
    color: var(--text-secondary);
    text-decoration: none;
    margin-left: 1.5rem;
    transition: color 0.2s;
}

.navbar-links a:hover,
.navbar-links a.active {
    color: var(--accent);
}

/* Container */
.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 2rem;
}

/* Page Header */
.page-header {
    margin-bottom: 2rem;
}

.page-header h1 {
    font-size: 2rem;
    margin-bottom: 0.5rem;
}

.page-header p {
    color: var(--text-secondary);
}

/* Search Bar */
.search-bar {
    display: flex;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}

.search-bar.compact {
    flex: 1;
}

.search-bar input {
    flex: 1;
    padding: 0.75rem 1rem;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 1rem;
    outline: none;
    transition: border-color 0.2s;
}

.search-bar input:focus {
    border-color: var(--accent);
}

.search-bar button {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.95rem;
    font-weight: 600;
    transition: background 0.2s;
}

.search-bar button:not(.btn-secondary) {
    background: var(--accent);
    color: white;
}

.search-bar button:not(.btn-secondary):hover {
    background: var(--accent-hover);
}

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

.btn-secondary:hover {
    background: var(--border) !important;
}

/* Video Count */
.video-count {
    color: var(--text-secondary);
    margin-bottom: 1rem;
    font-size: 0.95rem;
}

/* Video Grid */
.video-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.5rem;
}

.video-card {
    background: var(--bg-card);
    border-radius: 12px;
    overflow: hidden;
    transition: transform 0.2s, box-shadow 0.2s;
    cursor: pointer;
}

.video-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 25px var(--shadow);
}

.video-thumbnail {
    position: relative;
    padding-top: 56.25%;
    background: #000;
    overflow: hidden;
}

.video-thumbnail img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.thumbnail-placeholder {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 3rem;
    background: var(--bg-secondary);
}

.duration-badge {
    position: absolute;
    bottom: 8px;
    right: 8px;
    background: rgba(0, 0, 0, 0.85);
    color: white;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.8rem;
    font-weight: 600;
}

.play-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.4);
    opacity: 0;
    transition: opacity 0.2s;
}

.video-thumbnail:hover .play-overlay {
    opacity: 1;
}

.play-icon {
    width: 50px;
    height: 50px;
    background: var(--accent);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    color: white;
}

.video-info {
    padding: 1rem;
}

.video-title {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 0.35rem;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.video-channel {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
}

.video-meta {
    display: flex;
    gap: 1rem;
    color: var(--text-secondary);
    font-size: 0.8rem;
}

/* Download Section */
.download-section {
    background: var(--bg-card);
    border-radius: 12px;
    padding: 2rem;
    margin-bottom: 2rem;
    border: 1px solid var(--border);
}

.download-section h2 {
    margin-bottom: 1.5rem;
    font-size: 1.3rem;
}

.download-form .form-group input {
    width: 100%;
    padding: 1rem;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 1rem;
    outline: none;
    margin-bottom: 1rem;
    transition: border-color 0.2s;
}

.download-form .form-group input:focus {
    border-color: var(--accent);
}

.form-actions {
    display: flex;
    gap: 1rem;
}

.form-actions button {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.95rem;
    font-weight: 600;
    transition: background 0.2s, opacity 0.2s;
}

.form-actions button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-info {
    background: var(--bg-secondary) !important;
    color: var(--text-primary) !important;
    border: 1px solid var(--border) !important;
}

.btn-info:hover:not(:disabled) {
    background: var(--border) !important;
}

#downloadBtn {
    background: var(--accent) !important;
    color: white !important;
}

#downloadBtn:hover:not(:disabled) {
    background: var(--accent-hover) !important;
}

/* Video Preview */
.video-preview {
    margin-top: 1.5rem;
}

.preview-content {
    display: flex;
    gap: 1.5rem;
    align-items: center;
    padding: 1rem;
    background: var(--bg-secondary);
    border-radius: 8px;
}

.preview-thumbnail {
    width: 240px;
    height: 135px;
    object-fit: cover;
    border-radius: 8px;
    flex-shrink: 0;
}

.preview-details h3 {
    margin-bottom: 0.5rem;
}

.preview-channel,
.preview-duration {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* Download Status */
.download-status {
    margin-top: 1.5rem;
    padding: 1rem;
    background: var(--bg-secondary);
    border-radius: 8px;
}

.status-content {
    display: flex;
    align-items: center;
    gap: 1rem;
}

/* Management Section */
.management-section {
    margin-top: 2rem;
}

.management-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 2rem;
    margin-bottom: 1rem;
}

.management-header h2 {
    font-size: 1.3rem;
}

/* Table */
.table-container {
    overflow-x: auto;
}

.video-table {
    width: 100%;
    border-collapse: collapse;
}

.video-table th,
.video-table td {
    padding: 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.video-table th {
    background: var(--bg-card);
    color: var(--text-secondary);
    font-weight: 600;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.video-table tbody tr {
    background: var(--bg-card);
    transition: background 0.2s;
}

.video-table tbody tr:hover {
    background: var(--bg-secondary);
}

.table-video-cell {
    display: flex;
    align-items: center;
    gap: 1rem;
    max-width: 400px;
}

.table-thumbnail {
    width: 120px;
    height: 68px;
    object-fit: cover;
    border-radius: 6px;
    flex-shrink: 0;
}

.table-thumbnail-placeholder {
    width: 120px;
    height: 68px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    background: var(--bg-secondary);
    border-radius: 6px;
    flex-shrink: 0;
}

.table-title {
    font-weight: 500;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.btn-delete {
    padding: 0.5rem 1rem;
    background: transparent;
    border: 1px solid var(--accent);
    color: var(--accent);
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.85rem;
    transition: background 0.2s, color 0.2s;
}

.btn-delete:hover {
    background: var(--accent);
    color: white;
}

.btn-danger {
    background: var(--accent) !important;
    color: white !important;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
}

.btn-danger:hover {
    background: var(--accent-hover) !important;
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-content {
    background: var(--bg-card);
    border-radius: 12px;
    padding: 2rem;
    max-width: 500px;
    width: 90%;
    position: relative;
}

.modal-large {
    max-width: 900px;
}

.modal-close {
    position: absolute;
    top: 1rem;
    right: 1.5rem;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-secondary);
    transition: color 0.2s;
}

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

.modal-channel {
    color: var(--text-secondary);
    margin-bottom: 1rem;
}

.modal-actions {
    display: flex;
    gap: 1rem;
    margin-top: 1.5rem;
    justify-content: flex-end;
}

.warning-text {
    color: var(--accent);
    font-size: 0.9rem;
    margin-top: 0.5rem;
}

.video-player-full {
    width: 100%;
    max-height: 500px;
    border-radius: 8px;
    margin-top: 1rem;
    background: #000;
}

/* Toast */
.toast {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    padding: 1rem 1.5rem;
    border-radius: 8px;
    color: white;
    font-weight: 500;
    z-index: 2000;
    animation: slideIn 0.3s ease;
}

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

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

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

/* Spinner */
.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto;
}

.small-spinner {
    width: 20px;
    height: 20px;
    border-width: 3px;
    margin: 0;
}

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

.loading {
    text-align: center;
    padding: 3rem;
    color: var(--text-secondary);
}

.loading .spinner {
    margin-bottom: 1rem;
}

.no-results {
    text-align: center;
    padding: 3rem;
    color: var(--text-secondary);
}

/* Hidden utility */
.hidden {
    display: none !important;
}

/* Console */
.console-section {
    margin-top: 1.5rem;
}

.console-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
}

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

.btn-small {
    padding: 0.4rem 0.8rem !important;
    font-size: 0.8rem !important;
}

.console-output {
    background: #0a0a0a;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1rem;
    max-height: 350px;
    overflow-y: auto;
    font-family: 'Courier New', Courier, monospace;
    font-size: 0.85rem;
    line-height: 1.5;
}

.console-line {
    word-break: break-all;
    padding: 2px 0;
}

.console-timestamp {
    color: #555;
    font-size: 0.75rem;
    margin-right: 0.5rem;
}

.console-info {
    color: #80cbc4;
}

.console-error {
    color: #ef5350;
}

.console-done {
    color: #66bb6a;
    font-weight: 600;
}

/* Console scrollbar */
.console-output::-webkit-scrollbar {
    width: 8px;
}

.console-output::-webkit-scrollbar-track {
    background: #0a0a0a;
    border-radius: 4px;
}

.console-output::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 4px;
}

.console-output::-webkit-scrollbar-thumb:hover {
    background: #3a3a5a;
}

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

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

    .preview-content {
        flex-direction: column;
    }

    .preview-thumbnail {
        width: 100%;
        height: auto;
    }

    .management-header {
        flex-direction: column;
        align-items: stretch;
    }

    .form-actions {
        flex-direction: column;
    }

    .navbar {
        padding: 1rem;
    }

    .table-video-cell {
        max-width: 200px;
    }

    .table-thumbnail,
    .table-thumbnail-placeholder {
        width: 80px;
        height: 45px;
    }
}