/**
 * VideoHub Mobile-First Responsive Styles
 * 
 * This file implements a true mobile-first approach:
 * - Base styles are for mobile devices
 * - min-width media queries progressively enhance for larger screens
 */

/* ============================================
   CSS VARIABLES - Mobile Defaults
   ============================================ */
:root {
    --vh-header-height: 52px;
    --vh-card-radius: 8px;
    --vh-touch-target: 44px;
    --vh-spacing-xs: 8px;
    --vh-spacing-sm: 12px;
    --vh-spacing-md: 16px;
    --vh-spacing-lg: 24px;
    --vh-spacing-xl: 32px;
}

/* Tablet and up */
@media (min-width: 768px) {
    :root {
        --vh-header-height: 56px;
        --vh-card-radius: 12px;
    }
}

/* ============================================
   MOBILE BASE STYLES
   ============================================ */

/* Prevent horizontal scroll */
html, body {
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
}

/* Improve text rendering on mobile */
body {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-size-adjust: 100%;
    -webkit-text-size-adjust: 100%;
}

/* Touch-friendly defaults */
button, a, input, select, textarea {
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

/* Ensure minimum touch target size */
.vh-touch-target,
.vh-menu-toggle,
.vh-icon-btn,
.vh-user-btn,
.vh-chip,
.vh-action-btn,
.vh-page-btn,
.vh-page-num {
    min-width: var(--vh-touch-target);
    min-height: var(--vh-touch-target);
}

/* ============================================
   HEADER - Mobile First
   ============================================ */
.vh-header {
    padding: 0 var(--vh-spacing-xs);
    height: var(--vh-header-height);
}

.vh-header-inner {
    gap: var(--vh-spacing-xs);
}

.vh-header-left {
    gap: var(--vh-spacing-xs);
}

/* Hide search bar on mobile - show search icon instead */
.vh-header-center {
    display: none;
}

/* Show logo text on mobile if space permits */
.vh-logo-text {
    display: none;
    font-size: 1rem;
}

.vh-header-right {
    gap: var(--vh-spacing-xs);
}

/* Menu toggle - touch friendly */
.vh-menu-toggle {
    width: var(--vh-touch-target);
    height: var(--vh-touch-target);
}

.vh-menu-toggle svg {
    width: 22px;
    height: 22px;
}

/* Icon buttons */
.vh-icon-btn {
    width: var(--vh-touch-target);
    height: var(--vh-touch-target);
}

.vh-icon-btn svg {
    width: 22px;
    height: 22px;
}

/* User button */
.vh-user-btn {
    width: 32px;
    height: 32px;
}

/* Tablet and up */
@media (min-width: 768px) {
    .vh-header {
        padding: 0 var(--vh-spacing-md);
    }
    
    .vh-header-inner {
        gap: var(--vh-spacing-md);
    }
    
    .vh-header-left {
        gap: var(--vh-spacing-md);
    }
    
    .vh-logo-text {
        display: inline;
    }
    
    .vh-header-right {
        gap: var(--vh-spacing-xs);
    }
}

/* Desktop and up - show search bar */
@media (min-width: 900px) {
    .vh-header-center {
        display: flex;
        flex: 1;
        max-width: 500px;
    }
    
    .vh-mobile-search-btn {
        display: none !important;
    }
}

/* Large desktop */
@media (min-width: 1200px) {
    .vh-header {
        padding: 0 var(--vh-spacing-lg);
    }
    
    .vh-header-inner {
        gap: var(--vh-spacing-lg);
    }
    
    .vh-header-center {
        max-width: 640px;
    }
}

/* ============================================
   LAYOUT - Mobile First
   ============================================ */
.vh-layout {
    padding-top: var(--vh-header-height);
}

.vh-main,
.vh-main-content {
    padding: var(--vh-spacing-sm);
    min-width: 0;
}

/* Tablet */
@media (min-width: 768px) {
    .vh-main,
    .vh-main-content {
        padding: var(--vh-spacing-md);
    }
}

/* Desktop with sidebar */
@media (min-width: 1024px) {
    .vh-main,
    .vh-main-content {
        padding: var(--vh-spacing-lg);
    }
}

/* Large desktop with visible sidebar */
@media (min-width: 1312px) {
    .vh-main,
    .vh-main-content {
        margin-left: var(--vh-sidebar-width);
        padding: var(--vh-spacing-lg) var(--vh-spacing-xl);
    }
}

/* ============================================
   SIDEBAR - Mobile First
   ============================================ */
.vh-sidebar {
    position: fixed;
    top: var(--vh-header-height);
    left: 0;
    width: min(280px, 85vw);
    height: calc(100vh - var(--vh-header-height));
    background: var(--vh-surface);
    border-right: 1px solid var(--vh-border);
    transform: translateX(-100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 90;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
}

.vh-sidebar-open .vh-sidebar {
    transform: translateX(0);
    box-shadow: 4px 0 20px rgba(0, 0, 0, 0.4);
}

/* Sidebar overlay */
.vh-sidebar-overlay {
    position: fixed;
    top: var(--vh-header-height);
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
    z-index: 80;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.vh-sidebar-open .vh-sidebar-overlay {
    opacity: 1;
    visibility: visible;
}

/* Sidebar items - touch friendly */
.vh-sidebar-item {
    padding: 14px var(--vh-spacing-md);
    gap: var(--vh-spacing-md);
    border-radius: var(--vh-spacing-xs);
    min-height: 48px;
    display: flex;
    align-items: center;
}

.vh-sidebar-item svg {
    width: 22px;
    height: 22px;
    flex-shrink: 0;
}

.vh-sidebar-section-toggle {
    padding: 14px var(--vh-spacing-md);
    min-height: 48px;
}

/* Large desktop - always visible sidebar */
@media (min-width: 1312px) {
    .vh-sidebar {
        transform: translateX(0);
        width: var(--vh-sidebar-width);
        box-shadow: none;
    }
    
    .vh-sidebar-overlay {
        display: none;
    }
}

/* ============================================
   VIDEO GRID - Mobile First
   ============================================ */
.vh-video-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: var(--vh-spacing-md);
}

/* 2 columns on larger phones */
@media (min-width: 480px) {
    .vh-video-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: var(--vh-spacing-sm);
    }
}

/* 2-3 columns on tablets */
@media (min-width: 768px) {
    .vh-video-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: var(--vh-spacing-md);
    }
}

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

/* 4 columns on desktop */
@media (min-width: 1200px) {
    .vh-video-grid {
        grid-template-columns: repeat(4, 1fr);
        gap: var(--vh-spacing-md);
    }
}

/* 5 columns on large desktop */
@media (min-width: 1600px) {
    .vh-video-grid {
        grid-template-columns: repeat(5, 1fr);
        gap: var(--vh-spacing-lg);
    }
}

/* ============================================
   VIDEO CARD - Mobile First
   ============================================ */
.vh-video-card {
    margin-bottom: var(--vh-spacing-xs);
}

.vh-thumbnail-wrapper {
    border-radius: var(--vh-card-radius);
}

.vh-video-info {
    padding: var(--vh-spacing-sm) 4px;
    gap: var(--vh-spacing-sm);
}

.vh-video-title {
    font-size: 0.9375rem;
    line-height: 1.35;
    margin-bottom: 4px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.vh-video-meta {
    font-size: 0.8125rem;
    color: var(--vh-text-muted);
}

/* Show play overlay on mobile (no hover) */
.vh-play-overlay {
    opacity: 0.8;
    width: 48px;
    height: 48px;
}

.vh-play-overlay svg {
    width: 22px;
    height: 22px;
}

/* Tablet and up */
@media (min-width: 768px) {
    .vh-video-info {
        padding: var(--vh-spacing-sm) 0;
    }
    
    .vh-video-title {
        font-size: 0.9375rem;
    }
}

/* Desktop - hover effects */
@media (min-width: 1024px) {
    .vh-video-card {
        transition: transform 0.2s ease;
    }
    
    .vh-video-card:hover {
        transform: translateY(-4px);
    }
    
    .vh-play-overlay {
        opacity: 0;
        width: 56px;
        height: 56px;
    }
    
    .vh-video-card:hover .vh-play-overlay {
        opacity: 1;
    }
    
    .vh-video-title {
        font-size: 1rem;
    }
}

/* ============================================
   TAGS/CHIPS FILTER - Mobile First
   ============================================ */
.vh-tags-filter {
    padding: 0;
    margin: 0 calc(-1 * var(--vh-spacing-sm));
    padding-left: var(--vh-spacing-sm);
    padding-right: var(--vh-spacing-sm);
    margin-bottom: var(--vh-spacing-md);
    overflow-x: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
    -webkit-overflow-scrolling: touch;
}

.vh-tags-filter::-webkit-scrollbar {
    display: none;
}

.vh-tags-scroll {
    display: flex;
    gap: var(--vh-spacing-xs);
    flex-wrap: nowrap;
    padding-bottom: var(--vh-spacing-xs);
}

.vh-chip {
    padding: 10px 14px;
    font-size: 0.8125rem;
    border-radius: 16px;
    flex-shrink: 0;
    min-height: var(--vh-touch-target);
    display: inline-flex;
    align-items: center;
}

/* Tablet and up */
@media (min-width: 768px) {
    .vh-tags-filter {
        margin: 0;
        margin-bottom: var(--vh-spacing-lg);
        padding-left: 0;
        padding-right: 0;
    }
    
    .vh-tags-scroll {
        gap: var(--vh-spacing-sm);
    }
    
    .vh-chip {
        padding: var(--vh-spacing-sm) var(--vh-spacing-md);
        font-size: 0.875rem;
        border-radius: var(--vh-spacing-xs);
    }
}

/* ============================================
   FEATURED AREA / HERO - Mobile First
   ============================================ */
.videohub-flexslider,
.videohub-inline-featured-area {
    margin: 0;
    margin-bottom: 0;
}

.videohub-featured-slide {
    min-height: 200px;
    margin: 0;
}

.slider-container {
    min-height: 200px;
    padding: var(--vh-spacing-md);
    margin: 0;
}

.sliderTitle {
    font-size: 1.25rem;
    margin-bottom: var(--vh-spacing-sm);
}

.sliderDescription {
    font-size: 0.875rem;
    margin-bottom: var(--vh-spacing-md);
}

.videohub-featured-slide-content .button {
    padding: 10px 20px;
    font-size: 0.875rem;
}

/* Tablet */
@media (min-width: 768px) {
    .videohub-featured-slide {
        min-height: 300px;
    }
    
    .slider-container {
        min-height: 300px;
        padding: calc(var(--vh-spacing-lg) + var(--vh-spacing-md));
    }
    
    .sliderTitle {
        font-size: 1.75rem;
    }
    
    .sliderDescription {
        font-size: 1rem;
    }
}

/* Desktop */
@media (min-width: 1024px) {
    .videohub-featured-slide {
        min-height: 400px;
    }
    
    .slider-container {
        min-height: 400px;
        padding: calc(var(--vh-spacing-xl) + var(--vh-spacing-md)) calc(var(--vh-spacing-xl) * 1.5);
    }
    
    .sliderTitle {
        font-size: 2.5rem;
    }
    
    .sliderDescription {
        font-size: 1.1rem;
        margin-bottom: var(--vh-spacing-lg);
    }
    
    .videohub-featured-slide-content .button {
        padding: 12px 28px;
        font-size: 1rem;
    }
}

/* ============================================
   PAGINATION - Mobile First
   ============================================ */
.vh-pagination {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: var(--vh-spacing-xs);
    padding: var(--vh-spacing-lg) 0;
}

.vh-page-btn {
    padding: var(--vh-spacing-sm) var(--vh-spacing-md);
    font-size: 0.8125rem;
    min-height: var(--vh-touch-target);
    display: inline-flex;
    align-items: center;
    gap: var(--vh-spacing-xs);
}

.vh-page-num {
    min-width: var(--vh-touch-target);
    height: var(--vh-touch-target);
    padding: 0 var(--vh-spacing-sm);
    font-size: 0.875rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.vh-page-numbers {
    display: flex;
    gap: var(--vh-spacing-xs);
}

.vh-load-more-btn {
    width: 100%;
    max-width: 300px;
    min-height: var(--vh-touch-target);
    padding: var(--vh-spacing-sm) var(--vh-spacing-lg);
}

/* Desktop */
@media (min-width: 768px) {
    .vh-page-btn {
        padding: var(--vh-spacing-sm) calc(var(--vh-spacing-md) * 1.67);
    }
    
    .vh-load-more-btn {
        width: auto;
    }
}

/* ============================================
   WATCH PAGE - Mobile First
   ============================================ */
.vh-watch-page {
    padding-top: var(--vh-spacing-sm);
}

.vh-watch-layout {
    display: flex;
    flex-direction: column;
    gap: var(--vh-spacing-md);
}

.vh-watch-title {
    font-size: 1.125rem;
    line-height: 1.35;
    margin-bottom: var(--vh-spacing-sm);
}

.vh-watch-meta {
    gap: var(--vh-spacing-sm);
    padding: var(--vh-spacing-sm) 0;
    font-size: 0.8125rem;
    flex-wrap: wrap;
}

/* Action buttons - horizontal scroll on mobile */
.vh-watch-actions {
    display: flex;
    gap: 6px;
    padding: var(--vh-spacing-sm) 0;
    overflow-x: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
    margin: 0 calc(-1 * var(--vh-spacing-sm));
    padding-left: var(--vh-spacing-sm);
    padding-right: var(--vh-spacing-sm);
    -webkit-overflow-scrolling: touch;
}

.vh-watch-actions::-webkit-scrollbar {
    display: none;
}

.vh-action-btn {
    padding: 10px 14px;
    font-size: 0.8125rem;
    min-height: var(--vh-touch-target);
    white-space: nowrap;
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    gap: var(--vh-spacing-xs);
}

.vh-action-btn svg {
    width: 18px;
    height: 18px;
}

/* Related videos - vertical list on mobile */
.vh-related-videos {
    position: static;
    max-height: none;
    overflow: visible;
    margin-top: var(--vh-spacing-lg);
    padding: 0;
}

.vh-related-list {
    display: flex;
    flex-direction: column;
    gap: var(--vh-spacing-sm);
}

.vh-related-item {
    flex-direction: row;
    padding: var(--vh-spacing-xs);
    min-height: 48px;
    border-radius: var(--vh-spacing-xs);
}

.vh-related-thumb {
    width: 120px;
    flex-shrink: 0;
}

.vh-related-info {
    padding: 4px 0;
}

.vh-related-item-title {
    font-size: 0.8125rem;
    margin: 0 0 4px 0;
}

/* Tablet */
@media (min-width: 768px) {
    .vh-watch-title {
        font-size: 1.25rem;
    }
    
    .vh-watch-actions {
        margin: 0;
        padding-left: 0;
        padding-right: 0;
        overflow: visible;
        flex-wrap: wrap;
    }
    
    .vh-action-btn {
        padding: var(--vh-spacing-sm) var(--vh-spacing-md);
    }
    
    .vh-related-thumb {
        width: 140px;
    }
}

/* Desktop - side by side layout */
@media (min-width: 1200px) {
    .vh-watch-layout {
        flex-direction: row;
        gap: var(--vh-spacing-lg);
    }
    
    .vh-watch-player {
        flex: 1;
        min-width: 0;
    }
    
    .vh-related-videos {
        width: 400px;
        flex-shrink: 0;
        position: sticky;
        top: calc(var(--vh-header-height) + var(--vh-spacing-lg));
        max-height: calc(100vh - var(--vh-header-height) - var(--vh-spacing-xl));
        overflow-y: auto;
        margin-top: 0;
    }
    
    .vh-watch-title {
        font-size: 1.5rem;
    }
    
    .vh-action-btn {
        padding: var(--vh-spacing-sm) 20px;
    }
}

/* ============================================
   FOOTER - Mobile First
   ============================================ */
.vh-footer {
    padding: var(--vh-spacing-lg) var(--vh-spacing-sm);
    margin-top: var(--vh-spacing-xl);
}

.vh-footer-inner {
    flex-direction: column;
    text-align: center;
    gap: var(--vh-spacing-md);
}

.vh-footer-links {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: var(--vh-spacing-md);
}

.vh-footer-links a {
    min-height: var(--vh-touch-target);
    display: inline-flex;
    align-items: center;
}

/* Desktop */
@media (min-width: 768px) {
    .vh-footer {
        padding: var(--vh-spacing-xl) var(--vh-spacing-lg);
    }
    
    .vh-footer-inner {
        flex-direction: row;
        justify-content: space-between;
        text-align: left;
    }
}

/* ============================================
   MODALS - Mobile First
   ============================================ */
.vh-modal {
    padding: 0;
}

.vh-modal-content {
    border-radius: 0;
    max-height: 100vh;
    max-width: 100vw;
    width: 100%;
    margin: 0;
}

.vh-modal-close {
    top: var(--vh-spacing-sm);
    right: var(--vh-spacing-sm);
    width: var(--vh-touch-target);
    height: var(--vh-touch-target);
    z-index: 10;
}

/* Tablet and up */
@media (min-width: 768px) {
    .vh-modal {
        padding: var(--vh-spacing-lg);
    }
    
    .vh-modal-content {
        border-radius: var(--vh-card-radius);
        max-width: 800px;
        margin: auto;
    }
}

/* ============================================
   MOBILE SEARCH OVERLAY
   ============================================ */
.vh-mobile-search {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background: var(--vh-surface);
    padding: var(--vh-spacing-xs) var(--vh-spacing-sm);
    z-index: 110;
    border-bottom: 1px solid var(--vh-border);
}

.vh-mobile-search.active {
    display: flex;
    gap: var(--vh-spacing-sm);
    align-items: center;
}

.vh-mobile-search .vh-search-wrapper {
    flex: 1;
}

.vh-mobile-search .vh-search-input {
    border-radius: 24px;
    padding: var(--vh-spacing-sm) var(--vh-spacing-md);
    font-size: 1rem;
}

.vh-mobile-search-close {
    width: var(--vh-touch-target);
    height: var(--vh-touch-target);
    flex-shrink: 0;
}

/* Mobile search button - only on mobile */
.vh-mobile-search-btn {
    display: flex;
}

@media (min-width: 900px) {
    .vh-mobile-search-btn {
        display: none !important;
    }
}

/* ============================================
   SAFE AREA INSETS (Notched Devices)
   ============================================ */
@supports (padding: max(0px)) {
    .vh-header {
        padding-left: max(var(--vh-spacing-xs), env(safe-area-inset-left));
        padding-right: max(var(--vh-spacing-xs), env(safe-area-inset-right));
    }
    
    .vh-main,
    .vh-main-content {
        padding-left: max(var(--vh-spacing-sm), env(safe-area-inset-left));
        padding-right: max(var(--vh-spacing-sm), env(safe-area-inset-right));
        padding-bottom: max(var(--vh-spacing-lg), env(safe-area-inset-bottom));
    }
    
    .vh-sidebar {
        padding-bottom: max(var(--vh-spacing-lg), env(safe-area-inset-bottom));
    }
    
    .vh-footer {
        padding-bottom: max(var(--vh-spacing-xl), env(safe-area-inset-bottom));
    }
    
    .vh-mobile-search {
        padding-top: max(var(--vh-spacing-xs), env(safe-area-inset-top));
        padding-left: max(var(--vh-spacing-sm), env(safe-area-inset-left));
        padding-right: max(var(--vh-spacing-sm), env(safe-area-inset-right));
    }
}

/* ============================================
   ACCESSIBILITY & PERFORMANCE
   ============================================ */

/* Focus visible states */
*:focus-visible {
    outline: 2px solid var(--vh-primary);
    outline-offset: 2px;
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    
    .vh-sidebar {
        transition: none;
    }
}

/* High contrast mode */
@media (prefers-contrast: high) {
    :root {
        --vh-border: #666666;
        --vh-text-muted: #cccccc;
    }
    
    .vh-chip,
    .vh-action-btn,
    .vh-page-btn,
    .vh-page-num {
        border: 1px solid var(--vh-border);
    }
}

/* Hide keyboard shortcuts hint on touch devices */
@media (hover: none) and (pointer: coarse) {
    .vh-shortcuts-hint {
        display: none !important;
    }
    
    /* Always show play overlay on touch devices */
    .vh-play-overlay {
        opacity: 0.9;
    }
}

/* ============================================
   ADMIN BAR ADJUSTMENTS
   ============================================ */
.admin-bar .vh-header {
    top: 46px;
}

.admin-bar .vh-sidebar {
    top: calc(var(--vh-header-height) + 46px);
    height: calc(100vh - var(--vh-header-height) - 46px);
}

.admin-bar .vh-sidebar-overlay {
    top: calc(var(--vh-header-height) + 46px);
}

.admin-bar .vh-layout {
    padding-top: calc(var(--vh-header-height) + 46px);
}

@media (min-width: 783px) {
    .admin-bar .vh-header {
        top: 32px;
    }
    
    .admin-bar .vh-sidebar {
        top: calc(var(--vh-header-height) + 32px);
        height: calc(100vh - var(--vh-header-height) - 32px);
    }
    
    .admin-bar .vh-sidebar-overlay {
        top: calc(var(--vh-header-height) + 32px);
    }
    
    .admin-bar .vh-layout {
        padding-top: calc(var(--vh-header-height) + 32px);
    }
}
