/* Discover Page - TikTok Style Dark Theme */

#discover-app {
    min-height: 100vh;
    background: var(--bg-primary);
}

/* Header - Minimized */
.discover-header {
    background: transparent;
    padding: 12px 0 0 0;  /* Remove side padding, keep top padding */
    border-bottom: none;
}

.header-top {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.discover-header h1 {
    margin: 0;
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
}

/* Main Container */
.discover-main {
    max-width: 600px;
    margin: 0 auto;
    padding: 0;  /* No padding - filter is positioned absolutely */
    height: calc(100vh - 60px); /* Full viewport minus navbar */
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
    position: relative; /* For absolute positioned filter */
}

/* Video Container */
.video-container {
    background: transparent;
    border: none;
    border-radius: 16px;
    height: 100%;
    display: flex;
    flex-direction: column;
    position: relative;
}

/* Loading State */
.loading-state, .empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    padding: 40px;
    text-align: center;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 4px solid var(--bg-tertiary);
    border-top: 4px solid var(--accent-primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.empty-state p {
    font-size: 18px;
    color: var(--text-secondary);
    margin: 10px 0;
}

.empty-hint {
    font-size: 14px;
    color: var(--text-tertiary);
}

/* Video Card */
.video-card {
    display: flex;
    flex-direction: column;
    cursor: grab;
    user-select: none;
    touch-action: none;
    height: 100%;
}

.video-card:active {
    cursor: grabbing;
}

/* Video Embed */
#video-embed-container {
    width: 100%;
    flex: 1; /* Take up available space */
    max-height: calc(100vh - 200px); /* Leave room for header and info section */
    background: #1a1a1a; /* Darker gray, not pure black */
    position: relative;
    overflow: hidden; /* Contain the video */
    padding: 8px 8px 8px 8px; /* Add padding around video */
    box-sizing: border-box;
    display: flex;
    align-items: center;
    justify-content: center;
}

#video-embed-container iframe {
    width: 100%;
    max-width: 500px;
    height: auto;
    aspect-ratio: 9 / 16; /* TikTok aspect ratio */
    max-height: 100%; /* Fill the container */
    border: none;
    border-radius: 8px;
    display: block;
}

/* Swipe Overlay - Invisible layer on top half of video for swipe gestures */
.video-swipe-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 85%; /* Cover top 50% of video, leave bottom 50% for controls and interactions */
    z-index: 10; /* Above video iframe */
    cursor: grab;
    user-select: none;
    touch-action: none;
}

.video-swipe-overlay:active {
    cursor: grabbing;
}

/* Video Info */
.video-info {
    padding: 20px;
    background: var(--bg-primary); /* Solid background to ensure clear separation */
    height: auto;
    flex-shrink: 0;
    display: block;
    clear: both;
    border-top: 1px solid var(--border-color); /* Visual separator */
}

#video-title {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 8px;
    line-height: 1.4;
}

.video-creator {
    font-size: 14px;
    color: var(--text-tertiary);
    margin-bottom: 12px;
}

.video-tags {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: center; /* Center tags */
    align-items: center;
}

.tag,
.tag-badge {
    padding: 6px 12px;
    background: var(--bg-tertiary);
    border-radius: 16px;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-primary);
}

.tag.quick,
.tag-badge.quick { background: #FFA500; color: #000; }
.tag.healthy,
.tag-badge.healthy { background: #32CD32; color: #000; }
.tag.vegetarian,
.tag-badge.vegetarian { background: #7CFC00; color: #000; }
.tag.dessert,
.tag-badge.dessert { background: #FFB6C1; color: #000; }

/* Swipe Controls */
.swipe-controls {
    display: flex;
    justify-content: space-around;
    padding: 16px 20px;
    background: transparent;
    border-top: none;
    gap: 12px;
}

.swipe-controls button {
    flex: 1;
    padding: 14px 20px;
    border: none;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

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

.btn-skip:hover {
    background: var(--bg-hover);
    transform: translateY(-2px);
}

.btn-add {
    background: var(--accent-primary);
    color: white;
}

.btn-add:hover {
    background: var(--accent-hover);
    transform: translateY(-2px);
}

.btn-save {
    background: var(--success);
    color: white;
}

.btn-save:hover {
    background: #28a745;
    transform: translateY(-2px);
}

.btn-save.saved {
    background: var(--bg-tertiary);
    color: var(--text-tertiary);
}

.btn-secondary {
    padding: 10px 20px;
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-secondary:hover {
    background: var(--bg-hover);
    border-color: var(--accent-primary);
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 20px;
    box-sizing: border-box;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 32px;
    max-width: 500px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    box-sizing: border-box;
}

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

.close {
    position: absolute;
    top: 16px;
    right: 16px;
    font-size: 28px;
    color: var(--text-tertiary);
    cursor: pointer;
    transition: color 0.2s;
}

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

.modal-content h2 {
    color: var(--text-primary);
    margin-bottom: 20px;
    font-size: 24px;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    color: var(--text-secondary);
    font-weight: 600;
    font-size: 14px;
}

.form-group input,
.form-group textarea {
    width: 100%;
    padding: 12px;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 14px;
}

.form-group input:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--accent-primary);
}

.categories-container {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.category-item {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    cursor: pointer;
}

.category-item input {
    width: auto;
}

.form-actions {
    display: flex;
    gap: 12px;
    margin-top: 24px;
}

.btn-primary {
    flex: 1;
    padding: 12px 24px;
    background: var(--accent-primary);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-primary:hover {
    background: var(--accent-hover);
    transform: translateY(-2px);
}

/* Saved Videos List */
.saved-videos-list {
    display: grid;
    gap: 16px;
}

.saved-video-item {
    display: flex;
    gap: 16px;
    padding: 16px;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
}

.saved-video-item:hover {
    background: var(--bg-tertiary);
    border-color: var(--accent-primary);
}

.saved-video-thumbnail {
    width: 80px;
    height: 140px;
    border-radius: 6px;
    object-fit: cover;
    background: var(--bg-tertiary);
}

.saved-video-info {
    flex: 1;
}

.saved-video-title {
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.saved-video-creator {
    font-size: 14px;
    color: var(--text-tertiary);
}

/* Notification */
.notification {
    position: fixed;
    top: 80px;
    right: 20px;
    background: var(--accent-primary);
    color: white;
    padding: 16px 24px;
    border-radius: 8px;
    box-shadow: 0 4px 12px var(--shadow);
    z-index: 2000;
    animation: slideIn 0.3s ease;
    display: none;
}

.notification.show {
    display: block;
}

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

/* Responsive */
@media (max-width: 768px) {
    .discover-main {
        padding: 0 8px;
        height: calc(100vh - 60px); /* Account for mobile navbar */
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .video-container {
        border-radius: 8px;
        width: 100%;
        max-width: 100%;
        margin: 0 auto;
    }

    #video-embed-container {
        border-radius: 8px;
        padding: 4px 4px 4px 4px; /* Reduce padding on mobile */
        max-height: calc(100vh - 180px); /* Leave room for navbar and info on mobile */
        margin: 0 auto;
    }

    #video-embed-container iframe {
        max-width: 100%; /* Full width on mobile */
        margin: 0 auto;
    }

    .video-info {
        padding: 12px 16px; /* Reduce padding on mobile */
        padding-bottom: 60px; /* Make room for buttons at bottom */
    }

    #video-title {
        font-size: 16px; /* Slightly smaller on mobile */
    }

    .video-creator {
        font-size: 13px; /* Smaller creator name on mobile */
    }

    .swipe-controls {
        flex-direction: column;
    }

    .swipe-controls button {
        width: 100%;
    }
}

/* ==================== How-To Help Button & Modal ==================== */
.help-btn {
    position: absolute;
    bottom: 16px;
    right: 16px;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--bg-secondary);
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    z-index: 998;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    pointer-events: auto; /* Ensure it's clickable */
}

.help-btn:hover {
    background: var(--bg-tertiary);
    color: var(--accent-primary);
    border-color: var(--accent-primary);
}

/* ==================== Feedback Button (Discover Page) ==================== */
.feedback-btn-discover {
    position: absolute;
    bottom: 16px;
    left: 16px;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--accent-primary);
    color: white;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 16px rgba(254, 44, 85, 0.4);
    transition: all 0.2s;
    z-index: 998;
    pointer-events: auto; /* Ensure it's clickable */
}

.feedback-btn-discover:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(254, 44, 85, 0.5);
}

.howto-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    z-index: 2001;
    align-items: center;
    justify-content: center;
    padding: 20px;
    box-sizing: border-box;
}

.howto-modal.active {
    display: flex;
}

.howto-modal-content {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 32px;
    max-width: 480px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    box-sizing: border-box;
}

.howto-modal-content h2 {
    color: var(--text-primary);
    margin: 0 0 24px 0;
    font-size: 24px;
    text-align: center;
}

.howto-close {
    position: absolute;
    top: 16px;
    right: 16px;
    background: none;
    border: none;
    color: var(--text-tertiary);
    font-size: 28px;
    cursor: pointer;
    transition: color 0.2s;
    line-height: 1;
}

.howto-close:hover {
    color: var(--accent-primary);
}

.howto-section {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.howto-item {
    display: flex;
    align-items: flex-start;
    gap: 16px;
}

.howto-icon {
    width: 56px;
    height: 56px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.howto-icon.swipe-left {
    background: rgba(239, 68, 68, 0.2);
    color: #ef4444;
}

.howto-icon.swipe-right {
    background: rgba(34, 197, 94, 0.2);
    color: #22c55e;
}

.howto-icon.calendar {
    background: rgba(254, 44, 85, 0.2);
    color: var(--accent-primary);
}

.howto-text h3 {
    color: var(--text-primary);
    margin: 0 0 4px 0;
    font-size: 16px;
    font-weight: 600;
}

.howto-text p {
    color: var(--text-secondary);
    margin: 0;
    font-size: 14px;
    line-height: 1.5;
}

.howto-tip {
    margin-top: 24px;
    padding: 16px;
    background: var(--bg-tertiary);
    border-radius: 8px;
    font-size: 14px;
    color: var(--text-secondary);
    line-height: 1.5;
}

.howto-tip strong {
    color: var(--accent-primary);
}

.howto-got-it {
    width: 100%;
    margin-top: 24px;
    padding: 14px 24px;
    background: var(--accent-primary);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.howto-got-it:hover {
    background: var(--accent-hover);
}

@media (max-width: 768px) {
    .help-btn {
        bottom: 16px;
        right: 16px;
        width: 40px;
        height: 40px;
        z-index: 1000; /* Above other content */
    }

    .feedback-btn-discover {
        bottom: 16px;
        left: 16px;
        width: 40px;
        height: 40px;
        z-index: 1000; /* Above other content */
        box-shadow: 0 2px 8px rgba(254, 44, 85, 0.3);
    }

    .video-tags {
        margin: 0 50px; /* Make room for buttons on both sides */
    }

    .video-info {
        text-align: center; /* Center text on mobile */
    }
}

/* ==================== Filter Panel Styles ==================== */

.filter-panel {
    position: absolute;
    top: 8px; /* Just below navbar */
    left: 50%;
    transform: translateX(-50%);
    z-index: 1000;
    width: 75%; /* 75% of screen width */
    max-width: 600px; /* Cap at 600px for large screens */
}

.filter-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 8px 16px; /* Shorter height */
    background: var(--bg-secondary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: 20px; /* Less rounded */
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    width: 100%; /* Full width of parent (75%) */
}

.filter-toggle:hover {
    background: var(--bg-tertiary);
    border-color: var(--accent-primary);
}

.filter-toggle svg {
    width: 18px;
    height: 18px;
}

.filter-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    background: var(--accent-primary);
    color: white;
    border-radius: 10px;
    font-size: 12px;
    font-weight: 700;
}

.filter-dropdown {
    display: none;
    position: absolute;
    top: calc(100% + 8px); /* 8px below the filter button */
    left: 0;
    width: 100%; /* Same width as filter panel (75%) */
    z-index: 1001;
    animation: slideDown 0.2s ease-out;
}

.filter-dropdown.show {
    display: block;
}

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

.filter-dropdown-inner {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    max-height: 70vh;
    width: 100%;
    overflow-y: auto;
}

.filter-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px;
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    background: var(--bg-secondary);
    z-index: 1;
}

.filter-header h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 700;
    color: var(--text-primary);
}

.clear-filters-btn {
    padding: 6px 12px;
    background: transparent;
    color: var(--accent-primary);
    border: 1px solid var(--accent-primary);
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.clear-filters-btn:hover {
    background: var(--accent-primary);
    color: white;
}

.filter-content {
    padding: 16px;
}

.filter-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px;
    text-align: center;
    color: var(--text-secondary);
}

.spinner-small {
    width: 30px;
    height: 30px;
    border: 3px solid var(--bg-tertiary);
    border-top: 3px solid var(--accent-primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 12px;
}

.filter-category {
    margin-bottom: 20px;
}

.filter-category:last-child {
    margin-bottom: 0;
}

.filter-category-title {
    font-size: 13px;
    font-weight: 700;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 10px;
}

.filter-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.filter-tag {
    padding: 8px 14px;
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    user-select: none;
}

.filter-tag:hover {
    background: var(--bg-primary);
    border-color: var(--accent-primary);
}

.filter-tag.active {
    background: var(--accent-primary);
    color: white;
    border-color: var(--accent-primary);
}

.filter-tag.active:hover {
    background: var(--accent-hover);
}

/* No results message */
.no-filtered-results {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    padding: 40px;
    text-align: center;
}

.no-filtered-results svg {
    width: 64px;
    height: 64px;
    color: var(--text-tertiary);
    margin-bottom: 16px;
}

.no-filtered-results h3 {
    margin: 0 0 8px 0;
    font-size: 20px;
    color: var(--text-primary);
}

.no-filtered-results p {
    margin: 0;
    font-size: 14px;
    color: var(--text-secondary);
}

@media (max-width: 768px) {
    .filter-panel {
        position: absolute;
        top: 8px;
        left: 50%;
        transform: translateX(-50%);
        width: 85%; /* Slightly wider on mobile */
        max-width: none;
    }

    .filter-toggle {
        padding: 8px 16px;
        font-size: 13px;
    }

    .filter-dropdown {
        max-height: 60vh; /* Shorter on mobile */
    }

    .filter-dropdown-inner {
        max-height: 60vh;
        border-radius: 12px;
    }

    .filter-content {
        padding: 12px;
    }

    .filter-tag {
        padding: 8px 14px;
        font-size: 13px;
    }

    .filter-category-title {
        font-size: 12px;
    }
}
