/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    line-height: 1.6;
    color: #333;
    background-color: #fafafa;
}

/* Container */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

/* Header */
.header {
    background: #fff;
    border-bottom: 1px solid #e5e7eb;
    padding: 1rem 0;
    position: sticky;
    top: 0;
    z-index: 100;
}

.header .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo a {
    font-size: 1.5rem;
    font-weight: bold;
    color: #1f2937;
    text-decoration: none;
}

.nav {
    display: flex;
    gap: 2rem;
}

.nav-link {
    color: #6b7280;
    text-decoration: none;
    padding: 0.5rem 1rem;
    border-radius: 0.375rem;
    transition: all 0.2s;
}

.nav-link:hover,
.nav-link.active {
    color: #1f2937;
    background: #f3f4f6;
}

/* Main content */
.main {
    padding: 2rem 0;
}

/* Feed header */
.feed-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid #e5e7eb;
}

.feed-header h2 {
    color: #1f2937;
    font-size: 1.875rem;
    font-weight: 600;
}

.feed-count {
    color: #6b7280;
    font-size: 0.875rem;
}

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

/* Video card */
.video-card {
    background: #fff;
    border-radius: 0.5rem;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    transition: all 0.2s;
}

.video-card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    transform: translateY(-2px);
}

.video-card-link {
    display: block;
    text-decoration: none;
    color: inherit;
    height: 100%;
}

/* Video thumbnail */
.video-thumbnail {
    position: relative;
    aspect-ratio: 16 / 9;
    overflow: hidden;
}

.video-thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.2s;
}

.video-card:hover .video-thumbnail img {
    transform: scale(1.05);
}

.video-duration-overlay {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    opacity: 0;
    transition: opacity 0.2s;
}

.video-card:hover .video-duration-overlay {
    opacity: 1;
}

.watch-btn {
    background: rgba(0, 0, 0, 0.8);
    color: #fff;
    border: none;
    border-radius: 50%;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
}

.watch-btn:hover {
    background: #10b981;
    transform: scale(1.1);
}

/* Video info */
.video-info {
    padding: 1rem;
}

.video-title {
    margin-bottom: 0.5rem;
}

.video-title a {
    color: #1f2937;
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 500;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.video-title a:hover {
    color: #2563eb;
}

.video-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.75rem;
    color: #6b7280;
}

.channel-name {
    font-weight: 500;
}

.published-date {
    font-size: 0.75rem;
}

/* Empty state */
.empty-state {
    text-align: center;
    padding: 4rem 2rem;
    color: #6b7280;
}

.empty-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
}

.empty-state h3 {
    color: #374151;
    font-size: 1.25rem;
    margin-bottom: 0.5rem;
}

.empty-state p {
    margin-bottom: 2rem;
    max-width: 400px;
    margin-left: auto;
    margin-right: auto;
}

/* Button */
.btn {
    display: inline-block;
    padding: 0.75rem 1.5rem;
    border-radius: 0.375rem;
    text-decoration: none;
    font-weight: 500;
    transition: all 0.2s;
    border: none;
    cursor: pointer;
}

.btn-primary {
    background: #2563eb;
    color: #fff;
}

.btn-primary:hover {
    background: #1d4ed8;
    transform: translateY(-1px);
}

/* Animation for watched videos */
.video-card.watched {
    opacity: 0.5;
    transform: scale(0.95);
    transition: all 0.3s ease-out;
}

.video-card.removing {
    animation: slideOut 0.3s ease-out forwards;
}

@keyframes slideOut {
    to {
        opacity: 0;
        transform: translateX(-100%);
        margin-right: -100%;
    }
}

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

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

    .feed-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }

    .nav {
        gap: 1rem;
    }

    .nav-link {
        padding: 0.5rem;
    }
}

/* Channels page styles */
.channels-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid #e5e7eb;
}

.channels-header h2 {
    color: #1f2937;
    font-size: 1.875rem;
    font-weight: 600;
}

.channels-count {
    color: #6b7280;
    font-size: 0.875rem;
}

/* Add channel form */
.add-channel-section {
    background: #fff;
    border-radius: 0.5rem;
    padding: 1.5rem;
    margin-bottom: 2rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.add-channel-section h3 {
    color: #1f2937;
    font-size: 1.125rem;
    font-weight: 600;
    margin-bottom: 1rem;
}

/* Import tabs */
.import-tabs {
    display: flex;
    border-bottom: 1px solid #e5e7eb;
    margin-bottom: 1.5rem;
}

.tab-btn {
    background: none;
    border: none;
    padding: 0.75rem 1.5rem;
    cursor: pointer;
    color: #6b7280;
    font-weight: 500;
    border-bottom: 2px solid transparent;
    transition: all 0.2s;
}

.tab-btn.active {
    color: #2563eb;
    border-bottom-color: #2563eb;
}

.tab-btn:hover {
    color: #374151;
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

.add-channel-form {
    display: grid;
    grid-template-columns: 1fr 1fr auto;
    gap: 1rem;
    align-items: end;
}

/* CSV Import styles */
.csv-import-instructions {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 0.375rem;
    padding: 1rem;
    margin-bottom: 1.5rem;
}

.csv-import-instructions h4 {
    color: #1e293b;
    font-size: 0.875rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.csv-import-instructions ol {
    margin-left: 1.25rem;
    color: #475569;
    font-size: 0.875rem;
}

.csv-import-instructions li {
    margin-bottom: 0.25rem;
}

.csv-import-instructions a {
    color: #2563eb;
    text-decoration: none;
}

.csv-import-instructions a:hover {
    text-decoration: underline;
}

.csv-import-instructions code {
    background: #e2e8f0;
    padding: 0.125rem 0.25rem;
    border-radius: 0.25rem;
    font-size: 0.75rem;
}

.csv-import-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

/* File input styling */
.file-input-wrapper {
    position: relative;
}

.file-input-wrapper input[type="file"] {
    position: absolute;
    opacity: 0;
    width: 100%;
    height: 100%;
    cursor: pointer;
}

.file-input-display {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem;
    border: 2px dashed #d1d5db;
    border-radius: 0.375rem;
    cursor: pointer;
    transition: all 0.2s;
    background: #fafafa;
}

.file-input-display:hover {
    border-color: #2563eb;
    background: #f8faff;
}

.file-input-wrapper.has-file .file-input-display {
    border-color: #10b981;
    background: #f0fdf4;
    border-style: solid;
}

.file-input-display svg {
    color: #6b7280;
    flex-shrink: 0;
}

.file-text {
    color: #374151;
    font-size: 0.875rem;
}

/* Import options */
.import-options {
    margin: 1rem 0;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    font-size: 0.875rem;
    color: #374151;
}

.checkbox-label input[type="checkbox"] {
    position: absolute;
    opacity: 0;
}

.checkmark {
    width: 18px;
    height: 18px;
    border: 2px solid #d1d5db;
    border-radius: 0.25rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.checkbox-label input[type="checkbox"]:checked + .checkmark {
    background: #2563eb;
    border-color: #2563eb;
}

.checkbox-label input[type="checkbox"]:checked + .checkmark::after {
    content: "✓";
    color: white;
    font-size: 12px;
    font-weight: bold;
}

/* Progress styles */
.import-progress {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 0.5rem;
    padding: 1.5rem;
    margin-top: 1.5rem;
}

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

.progress-header h4 {
    color: #1e293b;
    font-size: 1rem;
    font-weight: 600;
    margin: 0;
}

.progress-text {
    color: #6b7280;
    font-size: 0.875rem;
}

.progress-bar {
    width: 100%;
    height: 8px;
    background: #e2e8f0;
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 1rem;
}

.progress-fill {
    height: 100%;
    background: #10b981;
    transition: width 0.3s ease;
    width: 0%;
}

.progress-stats {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

.stat {
    font-size: 0.875rem;
    color: #475569;
    font-weight: 500;
}

.form-group {
    display: flex;
    flex-direction: column;
}

.form-group label {
    color: #374151;
    font-size: 0.875rem;
    font-weight: 500;
    margin-bottom: 0.5rem;
}

.form-group input {
    padding: 0.75rem;
    border: 1px solid #d1d5db;
    border-radius: 0.375rem;
    font-size: 0.875rem;
    transition: border-color 0.2s;
}

.form-group input:focus {
    outline: none;
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.form-group input:invalid {
    border-color: #ef4444;
}

.form-help {
    color: #6b7280;
    font-size: 0.75rem;
    margin-top: 0.25rem;
}

/* Channels grid */
.channels-list h3 {
    color: #1f2937;
    font-size: 1.125rem;
    font-weight: 600;
    margin-bottom: 1rem;
}

.channels-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
    gap: 1rem;
}

.channel-card {
    background: #fff;
    border-radius: 0.5rem;
    padding: 1rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: all 0.2s;
}

.channel-card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.channel-info {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex: 1;
}

.channel-avatar {
    position: relative;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    overflow: hidden;
    background: #f3f4f6;
}

.channel-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.channel-avatar-fallback {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #2563eb;
    color: #fff;
    font-weight: 600;
    font-size: 0.875rem;
}

.channel-details {
    flex: 1;
}

.channel-name {
    color: #1f2937;
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.channel-id {
    color: #6b7280;
    font-size: 0.75rem;
    font-family: monospace;
    margin-bottom: 0.25rem;
}

.channel-date {
    color: #9ca3af;
    font-size: 0.75rem;
}

.channel-actions {
    display: flex;
    gap: 0.5rem;
}

.btn-sm {
    padding: 0.5rem 0.75rem;
    font-size: 0.75rem;
}

.btn-secondary {
    background: #f3f4f6;
    color: #374151;
}

.btn-secondary:hover {
    background: #e5e7eb;
}

.btn-danger {
    background: #ef4444;
    color: #fff;
}

.btn-danger:hover {
    background: #dc2626;
}

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

.modal-content {
    background: #fff;
    border-radius: 0.5rem;
    padding: 2rem;
    max-width: 400px;
    width: 90%;
    box-shadow: 0 20px 25px rgba(0, 0, 0, 0.15);
}

.modal-content h3 {
    color: #1f2937;
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 1rem;
}

.modal-content p {
    color: #6b7280;
    margin-bottom: 1rem;
}

.warning-text {
    color: #ef4444;
    font-size: 0.875rem;
}

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

/* Loading states */
.btn[disabled] {
    opacity: 0.6;
    cursor: not-allowed;
}

.btn-loading {
    display: none;
}

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

.btn.loading .btn-loading {
    display: inline;
}

/* Animation for removed channels */
.channel-card.removing {
    animation: slideOut 0.3s ease-out forwards;
}

@media (max-width: 768px) {
    .add-channel-form {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

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

    .channel-card {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }

    .channel-info {
        width: 100%;
    }

    .channel-actions {
        width: 100%;
        justify-content: flex-end;
    }
}

@media (max-width: 480px) {
    .main {
        padding: 1rem 0;
    }

    .feed-header h2,
    .channels-header h2 {
        font-size: 1.5rem;
    }

    .video-info {
        padding: 0.75rem;
    }

    .add-channel-section {
        padding: 1rem;
    }

    .modal-content {
        padding: 1.5rem;
    }
}

/* Watch page styles */
.watch-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0;
}

.video-player {
    background: #000;
    border-radius: 0.5rem;
    overflow: hidden;
    margin-bottom: 1.5rem;
}

.video-wrapper {
    position: relative;
    width: 100%;
    height: 0;
    padding-bottom: 56.25%; /* 16:9 aspect ratio */
}

.video-wrapper iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

.video-details {
    background: #fff;
    border-radius: 0.5rem;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

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

.video-title {
    color: #1f2937;
    font-size: 1.5rem;
    font-weight: 600;
    line-height: 1.4;
    margin: 0;
    flex: 1;
}

.video-actions {
    display: flex;
    gap: 0.5rem;
    flex-shrink: 0;
}

.video-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
}

.channel-info {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex: 1;
}

.channel-details h3 {
    color: #1f2937;
    font-size: 1rem;
    font-weight: 600;
    margin: 0 0 0.25rem 0;
}

.video-date {
    color: #6b7280;
    font-size: 0.875rem;
    margin: 0;
}

.video-status {
    flex-shrink: 0;
}

.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.375rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 500;
}

.status-badge.watched {
    background: #dcfce7;
    color: #166534;
}

.status-badge.unwatched {
    background: #fef3c7;
    color: #92400e;
}

.navigation-actions {
    text-align: center;
}

.auto-watch-notification {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: #1f2937;
    color: #fff;
    border-radius: 0.5rem;
    padding: 1rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    max-width: 300px;
    z-index: 1000;
}

.notification-content {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.notification-content p {
    margin: 0;
    font-size: 0.875rem;
}

.notification-content button {
    align-self: flex-end;
}

@media (max-width: 768px) {
    .watch-container {
        padding: 0;
    }

    .video-player {
        margin-bottom: 1.5rem;
        border-radius: 0;
    }

    .video-details {
        margin: 0 1rem 1.5rem;
    }

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

    .video-actions {
        justify-content: center;
    }

    .video-meta {
        flex-direction: column;
        align-items: stretch;
        gap: 1rem;
    }

    .video-title {
        font-size: 1.25rem;
    }

    .auto-watch-notification {
        bottom: 10px;
        right: 10px;
        left: 10px;
        max-width: none;
    }
}

@media (max-width: 480px) {
    .video-details {
        padding: 1rem;
        margin: 0 0.5rem 1.5rem;
    }

    .video-title {
        font-size: 1.125rem;
    }

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

/* DeArrow styles */
.title-container {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    flex: 1;
}

.title-toggle {
    display: flex;
    justify-content: flex-start;
}

.toggle-title-btn,
.toggle-thumbnail-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.375rem 0.75rem;
    font-size: 0.75rem;
    border: 1px solid #d1d5db;
    background: #f9fafb;
    color: #374151;
    border-radius: 0.375rem;
    cursor: pointer;
    transition: all 0.2s;
}

.toggle-title-btn:hover,
.toggle-thumbnail-btn:hover {
    background: #f3f4f6;
    border-color: #9ca3af;
}

.btn-outline {
    background: transparent;
    border: 1px solid #d1d5db;
    color: #374151;
}

.btn-outline:hover {
    background: #f3f4f6;
    border-color: #9ca3af;
}

.thumbnail-preview {
    background: #fff;
    border-radius: 0.5rem;
    padding: 1rem;
    margin-bottom: 1.5rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

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

.thumbnail-header h3 {
    color: #1f2937;
    font-size: 1.125rem;
    font-weight: 600;
    margin: 0;
}

.thumbnail-container {
    display: flex;
    justify-content: center;
}

.thumbnail-image {
    max-width: 100%;
    max-height: 300px;
    border-radius: 0.375rem;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

@media (max-width: 768px) {
    .thumbnail-preview {
        margin: 0 1rem 1.5rem;
    }

    .thumbnail-header {
        flex-direction: column;
        align-items: stretch;
        gap: 0.75rem;
    }

    .title-container {
        margin-bottom: 1rem;
    }
}

/* Audio Player Styles */
.audio-player-section {
    background: #fff;
    border-radius: 0.5rem;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    border-left: 4px solid #10b981;
}

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

.audio-player-header h3 {
    color: #1f2937;
    font-size: 1.125rem;
    font-weight: 600;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.audio-player-header h3::before {
    content: "🎵";
    font-size: 1rem;
}

.audio-player-container {
    margin-bottom: 1rem;
}

.audio-player-container audio {
    width: 100%;
    border-radius: 0.375rem;
    background: #f8fafc;
}

.audio-status {
    text-align: center;
}

.audio-info {
    color: #10b981;
    font-size: 0.875rem;
    font-weight: 500;
    margin: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.audio-info::before {
    content: "✓";
    font-weight: bold;
}

/* Audio Download Status */
.audio-download-status {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: #1f2937;
    color: #fff;
    border-radius: 0.5rem;
    padding: 1rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    max-width: 300px;
    z-index: 1000;
}

.download-content {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.download-spinner {
    animation: spin 1s linear infinite;
}

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

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

/* Button variants */
.btn-success {
    background: #10b981;
    color: #fff;
    border: 1px solid #10b981;
}

.btn-success:hover {
    background: #059669;
    border-color: #059669;
}

.btn-info {
    background: #3b82f6;
    color: #fff;
    border: 1px solid #3b82f6;
}

.btn-info:hover {
    background: #2563eb;
    border-color: #2563eb;
}

/* Audio download button states */
.audio-download-btn[disabled] {
    opacity: 0.6;
    cursor: not-allowed;
}

.audio-download-btn.downloading {
    background: #6b7280;
    color: #fff;
    border-color: #6b7280;
}

/* Mobile responsiveness for audio player */
@media (max-width: 768px) {
    .audio-player-section {
        margin: 0 1rem 1.5rem;
    }

    .audio-download-status {
        bottom: 10px;
        right: 10px;
        left: 10px;
        max-width: none;
    }

    .audio-player-header {
        flex-direction: column;
        align-items: stretch;
        gap: 0.75rem;
    }
}

@media (max-width: 480px) {
    .audio-player-section {
        padding: 1rem;
        margin: 0 0.5rem 1.5rem;
    }

    .download-content {
        flex-direction: column;
        text-align: center;
        gap: 0.5rem;
    }
}