/*
Theme Name: Flavor Video
Theme URI: https://example.com/flavor-video
Author: Custom Theme
Author URI: https://example.com
Description: A YouTube-style video theme for WordPress with Full Site Editing support. Features video grids, view counts, dark mode, and responsive design.
Version: 1.0.0
Requires at least: 6.0
Tested up to: 6.4
Requires PHP: 7.4
License: GNU General Public License v2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
Text Domain: flavor-video
Tags: full-site-editing, block-patterns, blog, entertainment, video, dark-mode

Flavor Video WordPress Theme, (C) 2024
Flavor Video is distributed under the terms of the GNU GPL.
*/

/* ===== CSS VARIABLES ===== */
:root {
    --fv-bg-primary: #0f0f0f;
    --fv-bg-secondary: #181818;
    --fv-bg-tertiary: #212121;
    --fv-bg-hover: #272727;
    --fv-text-primary: #f1f1f1;
    --fv-text-secondary: #aaaaaa;
    --fv-text-muted: #717171;
    --fv-accent: #ff0000;
    --fv-accent-hover: #cc0000;
    --fv-border: #303030;
    --fv-shadow: rgba(0, 0, 0, 0.4);
    --fv-card-radius: 12px;
    --fv-thumbnail-radius: 12px;
    --fv-transition: 0.2s ease;
    --fv-font-family: 'Roboto', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

/* ===== RESET & BASE ===== */
*,
*::before,
*::after {
    box-sizing: border-box;
}

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

body {
    margin: 0;
    padding: 0;
    font-family: var(--fv-font-family);
    background-color: var(--fv-bg-primary);
    color: var(--fv-text-primary);
    line-height: 1.5;
}

a {
    color: inherit;
    text-decoration: none;
    transition: color var(--fv-transition);
}

a:hover {
    color: var(--fv-text-primary);
}

img {
    max-width: 100%;
    height: auto;
    display: block;
}

/* ===== TYPOGRAPHY ===== */
h1, h2, h3, h4, h5, h6 {
    margin: 0 0 0.5em;
    font-weight: 500;
    line-height: 1.3;
    color: var(--fv-text-primary);
}

p {
    margin: 0 0 1em;
}

/* ===== LAYOUT ===== */
.fv-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 24px;
}

.fv-main {
    padding-top: 80px;
    min-height: 100vh;
}

/* ===== HEADER ===== */
.fv-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 56px;
    background: var(--fv-bg-primary);
    border-bottom: 1px solid var(--fv-border);
    z-index: 1000;
    display: flex;
    align-items: center;
    padding: 0 16px;
}

.fv-header__logo {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 20px;
    font-weight: 700;
    color: var(--fv-text-primary);
}

.fv-header__logo-icon {
    width: 32px;
    height: 32px;
    background: var(--fv-accent);
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.fv-header__logo-icon svg {
    width: 18px;
    height: 18px;
    fill: white;
}

.fv-header__search {
    flex: 1;
    max-width: 640px;
    margin: 0 40px;
    display: flex;
}

.fv-header__search-input {
    flex: 1;
    height: 40px;
    padding: 0 16px;
    background: var(--fv-bg-primary);
    border: 1px solid var(--fv-border);
    border-right: none;
    border-radius: 20px 0 0 20px;
    color: var(--fv-text-primary);
    font-size: 16px;
    outline: none;
}

.fv-header__search-input:focus {
    border-color: #1c62b9;
}

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

.fv-header__search-btn {
    width: 64px;
    height: 40px;
    background: var(--fv-bg-tertiary);
    border: 1px solid var(--fv-border);
    border-radius: 0 20px 20px 0;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.fv-header__search-btn svg {
    width: 24px;
    height: 24px;
    fill: var(--fv-text-primary);
}

.fv-header__search-btn:hover {
    background: var(--fv-bg-hover);
}

.fv-header__actions {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: auto;
}

.fv-header__btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: transparent;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background var(--fv-transition);
}

.fv-header__btn:hover {
    background: var(--fv-bg-hover);
}

.fv-header__btn svg {
    width: 24px;
    height: 24px;
    fill: var(--fv-text-primary);
}

/* ===== SIDEBAR ===== */
.fv-sidebar {
    position: fixed;
    top: 56px;
    left: 0;
    bottom: 0;
    width: 240px;
    background: var(--fv-bg-primary);
    overflow-y: auto;
    padding: 12px;
    z-index: 999;
    border-right: 1px solid var(--fv-border);
}

.fv-sidebar__section {
    padding: 12px 0;
    border-bottom: 1px solid var(--fv-border);
}

.fv-sidebar__section:last-child {
    border-bottom: none;
}

.fv-sidebar__title {
    font-size: 14px;
    font-weight: 500;
    color: var(--fv-text-secondary);
    padding: 8px 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.fv-sidebar__link {
    display: flex;
    align-items: center;
    gap: 24px;
    padding: 10px 12px;
    border-radius: 10px;
    color: var(--fv-text-primary);
    font-size: 14px;
    transition: background var(--fv-transition);
}

.fv-sidebar__link:hover {
    background: var(--fv-bg-hover);
}

.fv-sidebar__link.active {
    background: var(--fv-bg-tertiary);
}

.fv-sidebar__link svg {
    width: 24px;
    height: 24px;
    fill: var(--fv-text-primary);
    flex-shrink: 0;
}

/* ===== VIDEO GRID ===== */
.fv-video-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 16px;
    padding: 24px 0;
}

@media (min-width: 1200px) {
    .fv-video-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

@media (min-width: 900px) and (max-width: 1199px) {
    .fv-video-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (min-width: 600px) and (max-width: 899px) {
    .fv-video-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 599px) {
    .fv-video-grid {
        grid-template-columns: 1fr;
    }
}

/* ===== VIDEO WRAPPER (for embeds) ===== */
.fv-video-wrapper {
    position: relative;
    width: 100%;
    padding-top: 56.25%;
    background: #000;
    border-radius: var(--fv-thumbnail-radius);
    overflow: hidden;
    margin-bottom: 0;
}

.fv-video-wrapper iframe,
.fv-video-wrapper video,
.fv-video-wrapper embed,
.fv-video-wrapper object {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: none;
}

/* WordPress embed blocks */
.wp-block-embed,
.wp-block-video {
    margin: 0;
}

.wp-block-embed__wrapper {
    position: relative;
    padding-top: 56.25%;
}

.wp-block-embed__wrapper iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

/* AIYAP Video Plugin Support */
.aiyap-video-wrapper,
.aiyap_video,
[class*="aiyap"] {
    width: 100%;
    aspect-ratio: 16/9;
    border-radius: var(--fv-thumbnail-radius);
    overflow: hidden;
}

.aiyap-video-wrapper iframe,
.aiyap_video iframe {
    width: 100%;
    height: 100%;
    border: none;
}

/* ===== SINGLE POST VIDEO AREA ===== */
.fv-single-page .fv-player__video {
    margin-bottom: 0;
}

.fv-single-page .fv-player__video > * {
    margin-bottom: 0;
}

.fv-single-page .entry-content,
.fv-single-page .wp-block-post-content {
    margin: 0;
}

.fv-single-page .wp-block-post-content > .wp-block-embed:first-child,
.fv-single-page .wp-block-post-content > div:first-child {
    margin-top: 0;
}

/* ===== HEADER FIXED ===== */
.fv-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    background: var(--fv-bg-primary) !important;
}

/* Search bar styles */
.fv-search,
.fv-header .wp-block-search {
    max-width: 500px;
    flex: 1;
}

.fv-search .wp-block-search__inside-wrapper,
.fv-header .wp-block-search__inside-wrapper {
    background: var(--fv-bg-primary);
    border: 1px solid var(--fv-border);
    border-radius: 20px;
}

.fv-search .wp-block-search__input,
.fv-header .wp-block-search__input {
    background: transparent;
    border: none;
    color: var(--fv-text-primary);
    padding: 8px 16px;
}

.fv-search .wp-block-search__input::placeholder {
    color: var(--fv-text-muted);
}

.fv-search .wp-block-search__button,
.fv-header .wp-block-search__button {
    background: var(--fv-bg-tertiary);
    border: none;
    border-left: 1px solid var(--fv-border);
    padding: 8px 16px;
    color: var(--fv-text-primary);
}

.fv-search .wp-block-search__button:hover {
    background: var(--fv-bg-hover);
}

/* ===== VIDEO CARD ===== */
.fv-video-card {
    display: flex;
    flex-direction: column;
    cursor: pointer;
}

.fv-video-card__thumbnail {
    position: relative;
    width: 100%;
    padding-top: 56.25%; /* 16:9 aspect ratio */
    border-radius: var(--fv-thumbnail-radius);
    overflow: hidden;
    background: var(--fv-bg-secondary);
}

.fv-video-card__thumbnail img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform var(--fv-transition);
}

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

.fv-video-card__duration {
    position: absolute;
    bottom: 8px;
    right: 8px;
    background: rgba(0, 0, 0, 0.8);
    color: var(--fv-text-primary);
    padding: 3px 6px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 500;
}

.fv-video-card__progress {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: rgba(255, 255, 255, 0.3);
}

.fv-video-card__progress-bar {
    height: 100%;
    background: var(--fv-accent);
}

.fv-video-card__info {
    display: flex;
    gap: 12px;
    padding: 12px 0;
}

.fv-video-card__channel-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    overflow: hidden;
    flex-shrink: 0;
    background: var(--fv-bg-tertiary);
}

.fv-video-card__channel-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.fv-video-card__details {
    flex: 1;
    min-width: 0;
}

.fv-video-card__title {
    font-size: 14px;
    font-weight: 500;
    line-height: 1.4;
    color: var(--fv-text-primary);
    margin: 0 0 4px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.fv-video-card__title a {
    color: inherit;
}

.fv-video-card__title a:hover {
    color: var(--fv-text-primary);
}

.fv-video-card__channel {
    font-size: 12px;
    color: var(--fv-text-secondary);
    margin: 0 0 2px;
}

.fv-video-card__channel:hover {
    color: var(--fv-text-primary);
}

.fv-video-card__meta {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    color: var(--fv-text-secondary);
}

.fv-video-card__meta-separator {
    display: inline-block;
}

.fv-video-card__meta-separator::before {
    content: "•";
}

/* ===== VIEW COUNT BADGE ===== */
.fv-views {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.fv-views__icon {
    width: 14px;
    height: 14px;
    fill: var(--fv-text-secondary);
}

/* ===== CATEGORY CHIPS ===== */
.fv-chips {
    display: flex;
    gap: 12px;
    padding: 12px 0;
    overflow-x: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.fv-chips::-webkit-scrollbar {
    display: none;
}

.fv-chip {
    padding: 8px 16px;
    background: var(--fv-bg-tertiary);
    border-radius: 8px;
    font-size: 14px;
    color: var(--fv-text-primary);
    white-space: nowrap;
    cursor: pointer;
    transition: background var(--fv-transition);
    border: none;
}

.fv-chip:hover {
    background: var(--fv-bg-hover);
}

.fv-chip.active {
    background: var(--fv-text-primary);
    color: var(--fv-bg-primary);
}

/* ===== SINGLE VIDEO PAGE ===== */
.fv-single {
    display: grid;
    grid-template-columns: 1fr 400px;
    gap: 24px;
    padding: 24px 0;
}

@media (max-width: 1100px) {
    .fv-single {
        grid-template-columns: 1fr;
    }
}

.fv-player {
    width: 100%;
}

.fv-player__wrapper {
    position: relative;
    width: 100%;
    padding-top: 56.25%;
    background: #000;
    border-radius: var(--fv-thumbnail-radius);
    overflow: hidden;
}

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

.fv-player__title {
    font-size: 20px;
    font-weight: 600;
    margin: 16px 0 8px;
    color: var(--fv-text-primary);
}

.fv-player__stats {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 16px;
    padding: 12px 0;
    border-bottom: 1px solid var(--fv-border);
}

.fv-player__views-date {
    font-size: 14px;
    color: var(--fv-text-secondary);
}

.fv-player__actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.fv-action-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 16px;
    background: var(--fv-bg-tertiary);
    border: none;
    border-radius: 20px;
    color: var(--fv-text-primary);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: background var(--fv-transition);
}

.fv-action-btn:hover {
    background: var(--fv-bg-hover);
}

.fv-action-btn svg {
    width: 20px;
    height: 20px;
    fill: currentColor;
}

.fv-action-btn--like {
    border-radius: 20px 0 0 20px;
    padding-right: 12px;
}

.fv-action-btn--dislike {
    border-radius: 0 20px 20px 0;
    padding-left: 12px;
    border-left: 1px solid var(--fv-border);
}

/* ===== CHANNEL INFO ===== */
.fv-channel-info {
    display: flex;
    align-items: flex-start;
    gap: 16px;
    padding: 16px 0;
}

.fv-channel-info__avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    overflow: hidden;
    flex-shrink: 0;
    background: var(--fv-bg-tertiary);
}

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

.fv-channel-info__details {
    flex: 1;
}

.fv-channel-info__name {
    font-size: 16px;
    font-weight: 500;
    color: var(--fv-text-primary);
    margin: 0 0 4px;
}

.fv-channel-info__subscribers {
    font-size: 12px;
    color: var(--fv-text-secondary);
}

.fv-subscribe-btn {
    padding: 10px 20px;
    background: var(--fv-text-primary);
    color: var(--fv-bg-primary);
    border: none;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: opacity var(--fv-transition);
}

.fv-subscribe-btn:hover {
    opacity: 0.9;
}

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

/* ===== VIDEO DESCRIPTION ===== */
.fv-description {
    background: var(--fv-bg-tertiary);
    border-radius: var(--fv-card-radius);
    padding: 16px;
    margin-top: 16px;
}

.fv-description__header {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 500;
    color: var(--fv-text-primary);
    margin-bottom: 8px;
}

.fv-description__content {
    font-size: 14px;
    color: var(--fv-text-primary);
    white-space: pre-wrap;
    overflow: hidden;
}

.fv-description__content.collapsed {
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
}

.fv-description__toggle {
    background: none;
    border: none;
    color: var(--fv-text-secondary);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    padding: 8px 0;
}

.fv-description__toggle:hover {
    color: var(--fv-text-primary);
}

/* ===== RELATED VIDEOS SIDEBAR ===== */
.fv-related {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.fv-related__title {
    font-size: 16px;
    font-weight: 500;
    margin-bottom: 8px;
}

.fv-related-card {
    display: flex;
    gap: 8px;
    cursor: pointer;
}

.fv-related-card__thumbnail {
    position: relative;
    width: 168px;
    height: 94px;
    flex-shrink: 0;
    border-radius: 8px;
    overflow: hidden;
    background: var(--fv-bg-secondary);
}

.fv-related-card__thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.fv-related-card__duration {
    position: absolute;
    bottom: 4px;
    right: 4px;
    background: rgba(0, 0, 0, 0.8);
    color: var(--fv-text-primary);
    padding: 2px 4px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 500;
}

.fv-related-card__info {
    flex: 1;
    min-width: 0;
}

.fv-related-card__title {
    font-size: 14px;
    font-weight: 500;
    line-height: 1.3;
    color: var(--fv-text-primary);
    margin: 0 0 4px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.fv-related-card__channel {
    font-size: 12px;
    color: var(--fv-text-secondary);
    margin: 0 0 2px;
}

.fv-related-card__meta {
    font-size: 12px;
    color: var(--fv-text-secondary);
}

/* ===== COMMENTS SECTION ===== */
.fv-comments {
    margin-top: 24px;
    padding-top: 24px;
    border-top: 1px solid var(--fv-border);
}

.fv-comments__header {
    display: flex;
    align-items: center;
    gap: 32px;
    margin-bottom: 24px;
}

.fv-comments__count {
    font-size: 16px;
    font-weight: 500;
}

.fv-comments__sort {
    display: flex;
    align-items: center;
    gap: 8px;
    background: none;
    border: none;
    color: var(--fv-text-primary);
    font-size: 14px;
    cursor: pointer;
}

.fv-comments__sort svg {
    width: 20px;
    height: 20px;
    fill: currentColor;
}

.fv-comment {
    display: flex;
    gap: 16px;
    margin-bottom: 24px;
}

.fv-comment__avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    overflow: hidden;
    flex-shrink: 0;
    background: var(--fv-bg-tertiary);
}

.fv-comment__avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.fv-comment__content {
    flex: 1;
}

.fv-comment__header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
}

.fv-comment__author {
    font-size: 13px;
    font-weight: 500;
    color: var(--fv-text-primary);
}

.fv-comment__date {
    font-size: 12px;
    color: var(--fv-text-secondary);
}

.fv-comment__text {
    font-size: 14px;
    color: var(--fv-text-primary);
    line-height: 1.5;
    margin-bottom: 8px;
}

.fv-comment__actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.fv-comment__action {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: none;
    border: none;
    color: var(--fv-text-secondary);
    font-size: 12px;
    cursor: pointer;
    padding: 8px;
    margin: -8px;
    border-radius: 20px;
}

.fv-comment__action:hover {
    background: var(--fv-bg-hover);
}

.fv-comment__action svg {
    width: 20px;
    height: 20px;
    fill: currentColor;
}

/* ===== PAGINATION ===== */
.fv-pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    padding: 32px 0;
}

.fv-pagination__btn {
    min-width: 40px;
    height: 40px;
    padding: 0 16px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--fv-bg-tertiary);
    border: none;
    border-radius: 20px;
    color: var(--fv-text-primary);
    font-size: 14px;
    cursor: pointer;
    transition: background var(--fv-transition);
}

.fv-pagination__btn:hover {
    background: var(--fv-bg-hover);
}

.fv-pagination__btn.active {
    background: var(--fv-text-primary);
    color: var(--fv-bg-primary);
}

.fv-pagination__btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ===== FOOTER ===== */
.fv-footer {
    background: var(--fv-bg-secondary);
    border-top: 1px solid var(--fv-border);
    padding: 24px;
    margin-top: 48px;
}

.fv-footer p {
    margin: 0;
}

/* ===== RESPONSIVE ADJUSTMENTS ===== */
@media (max-width: 1024px) {
    .fv-sidebar {
        display: none;
    }

    .fv-main {
        margin-left: 0;
    }
}

@media (max-width: 768px) {
    .fv-header__search {
        display: none;
    }

    .fv-container {
        padding: 0 12px;
    }

    .fv-video-grid {
        gap: 12px;
    }

    .fv-player__stats {
        flex-direction: column;
        align-items: flex-start;
    }

    .fv-player__actions {
        width: 100%;
        overflow-x: auto;
    }
}

/* ===== LOADING SKELETON ===== */
.fv-skeleton {
    background: linear-gradient(90deg, var(--fv-bg-tertiary) 25%, var(--fv-bg-hover) 50%, var(--fv-bg-tertiary) 75%);
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s infinite;
    border-radius: 4px;
}

@keyframes skeleton-loading {
    0% {
        background-position: 200% 0;
    }
    100% {
        background-position: -200% 0;
    }
}

/* ===== UTILITY CLASSES ===== */
.fv-sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.fv-text-truncate {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* WordPress Core Styles Override */
.wp-block-post-title {
    margin: 0;
}

.wp-block-post-featured-image {
    margin: 0;
}

.wp-block-post-content {
    margin: 0;
}

.entry-content > * {
    margin-top: 0;
    margin-bottom: 1rem;
}

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

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

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

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