/* ═══════════════════════════════════════════════════════════════════════
   mobile.css — VidShare Mobile Optimization
   Production-ready responsive design for vidshare.live
   
   ⚠️ IMPORTANT: This file loads AFTER style.css (line 119 in header.php)
   All rules here override base styles safely without breaking desktop.
   
   Stack: Dark theme (#e53935 accent, #0a0a0f background)
   Fonts: Bebas Neue (headings), DM Sans (body)
   ═══════════════════════════════════════════════════════════════════════ */

/* ─────────────────────────────────────────────────────────────────────
   GLOBAL SAFETY NET — Prevents horizontal scroll
   ───────────────────────────────────────────────────────────────────── */
html, body {
    overflow-x: hidden;
    max-width: 100vw;
}

* {
    box-sizing: border-box;
}

img, video, iframe, svg {
    max-width: 100%;
    height: auto;
}

/* ─────────────────────────────────────────────────────────────────────
   RESPONSIVE VIDEO PLAYER — 16:9 aspect ratio on mobile
   Replaces fixed 500px height from desktop
   ───────────────────────────────────────────────────────────────────── */
@media (max-width: 900px) {
    .player-wrap iframe,
    .player-wrap video,
    .player-wrap {
        height: auto !important;
        aspect-ratio: 16 / 9;
        width: 100%;
    }
    
    /* Click-to-play overlay */
    .player-wrap .play-overlay {
        aspect-ratio: 16 / 9;
        height: auto !important;
    }
}

/* ═══════════════════════════════════════════════════════════════════════
   TABLET OPTIMIZATIONS (768px - 900px)
   ═══════════════════════════════════════════════════════════════════════ */
@media (max-width: 900px) {
    /* Reduce section padding */
    .section {
        padding: 24px 16px 40px;
    }
    
    .watch-layout {
        padding: 16px;
    }
    
    /* Video grid: 3 columns → 2 columns */
    .video-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 14px;
    }
    
    /* Playlist grid */
    .pl-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 14px;
    }
    
    /* Trending hero banner */
    .trending-hero {
        height: 220px;
        padding: 24px;
    }
    
    .trending-hero h2 {
        font-size: 28px;
    }
    
    /* Tables scroll horizontally */
    .table-wrap,
    table {
        display: block;
        overflow-x: auto;
        max-width: 100%;
        -webkit-overflow-scrolling: touch;
    }
    
    /* Code blocks wrap */
    pre, code {
        white-space: pre-wrap;
        word-break: break-word;
    }
}

/* ═══════════════════════════════════════════════════════════════════════
   MOBILE OPTIMIZATIONS (380px - 768px)
   ═══════════════════════════════════════════════════════════════════════ */
@media (max-width: 768px) {
    
    /* ───────────────────────────────────────────────────────────────
       NAVIGATION BAR
       ─────────────────────────────────────────────────────────────── */
    nav {
        padding: 8px 12px;
        gap: 8px;
        flex-wrap: nowrap;
    }
    
    /* Logo shrink */
    .logo {
        font-size: 20px !important;
        letter-spacing: 1.5px;
        white-space: nowrap;
    }
    
    /* Hide navigation links on very small screens */
    .nav-links {
        display: none;
    }
    
    /* Search bar: smaller, expandable on focus */
    .search-bar {
        min-width: 100px;
        max-width: 140px;
        transition: all 0.3s ease;
    }
    
    .search-bar:focus-within {
        max-width: 180px;
    }
    
    .search-bar input {
        font-size: 13px;
    }
    
    /* Right nav items compact */
    .nav-right {
        gap: 6px;
        flex-wrap: nowrap;
    }
    
    /* Notification & message icons smaller */
    .nav-notif-btn,
    .nav-msg-btn {
        width: 32px !important;
        height: 32px !important;
    }
    
    .nav-notif-btn svg,
    .nav-msg-btn svg {
        width: 13px;
        height: 13px;
    }
    
    /* User menu compact */
    .user-menu {
        display: flex;
        gap: 6px;
        align-items: center;
    }
    
    .user-pill {
        padding: 4px 8px !important;
        font-size: 13px;
    }
    
    .user-avatar-sm {
        width: 24px;
        height: 24px;
        font-size: 10px;
    }
    
    /* Hide username text on very small screens */
    .user-pill span:last-child {
        display: none;
    }
    
    /* Login/Register buttons */
    .nav-login {
        font-size: 13px;
        padding: 6px 10px;
    }
    
    .btn-secondary {
        font-size: 13px;
        padding: 6px 12px;
    }
    
    /* Submit button compact */
    .btn-upload {
        font-size: 12px;
        padding: 6px 10px;
        gap: 4px;
    }
    
    .btn-upload svg {
        width: 11px;
        height: 11px;
    }
    
    /* ───────────────────────────────────────────────────────────────
       CONTENT SECTIONS
       ─────────────────────────────────────────────────────────────── */
    .section {
        padding: 20px 12px 32px;
    }
    
    .section-header {
        flex-wrap: wrap;
        gap: 10px;
        margin-bottom: 16px;
    }
    
    .section-title {
        font-size: 20px;
        letter-spacing: 1.5px;
    }
    
    .page-count {
        font-size: 12px;
    }
    
    /* ───────────────────────────────────────────────────────────────
       VIDEO GRID — 2 columns
       ─────────────────────────────────────────────────────────────── */
    .video-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }
    
    /* Video card adjustments */
    .video-card {
        border-radius: 8px;
    }
    
    .video-card-thumb {
        border-radius: 8px 8px 0 0;
        height: auto;
        aspect-ratio: 16 / 9;
    }
    
    .video-card-body {
        padding: 10px;
    }
    
    .video-card-title {
        font-size: 13px;
        line-height: 1.3;
        margin-bottom: 6px;
        /* Clamp to 2 lines */
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
        overflow: hidden;
    }
    
    .video-card-meta {
        font-size: 11px;
        gap: 6px;
    }
    
    .video-card-meta span {
        display: inline-flex;
        align-items: center;
        gap: 3px;
    }
    
    /* ───────────────────────────────────────────────────────────────
       FILTER BAR
       ─────────────────────────────────────────────────────────────── */
    .filter-bar {
        padding: 10px 12px;
    }
    
    .filter-bar-inner {
        flex-wrap: wrap;
        gap: 6px;
    }
    
    .filter-pill {
        font-size: 12px;
        padding: 5px 12px;
    }
    
    /* ───────────────────────────────────────────────────────────────
       WATCH PAGE (video.php)
       ─────────────────────────────────────────────────────────────── */
    .watch-layout {
        padding: 12px;
    }
    
    .video-info-box {
        padding: 14px;
        border-radius: 10px;
    }
    
    .video-info-box h1 {
        font-size: 18px;
        line-height: 1.3;
        letter-spacing: 0.5px;
        margin-bottom: 10px;
    }
    
    .video-meta-row {
        flex-wrap: wrap;
        gap: 8px;
        font-size: 12px;
    }
    
    .video-actions {
        flex-wrap: wrap;
        gap: 6px;
        margin-top: 12px;
    }
    
    .video-actions .btn-icon,
    .video-actions button {
        font-size: 12px;
        padding: 7px 12px;
        gap: 4px;
    }
    
    .video-actions svg {
        width: 13px;
        height: 13px;
    }
    
    /* Tag pills */
    .tag-pills {
        flex-wrap: wrap;
        gap: 6px;
        margin-top: 10px;
    }
    
    .tag-pill {
        font-size: 11px;
        padding: 4px 10px;
    }
    
    /* ───────────────────────────────────────────────────────────────
       COMMENTS SECTION
       ─────────────────────────────────────────────────────────────── */
    .comments-box {
        padding: 14px;
    }
    
    .comment-form textarea {
        font-size: 13px;
        min-height: 80px;
    }
    
    .comment-item {
        padding: 12px;
        gap: 10px;
    }
    
    .comment-avatar {
        width: 32px;
        height: 32px;
        font-size: 12px;
    }
    
    .comment-author {
        font-size: 13px;
    }
    
    .comment-body {
        font-size: 13px;
        line-height: 1.5;
    }
    
    .comment-meta {
        font-size: 11px;
        gap: 8px;
    }
    
    /* ───────────────────────────────────────────────────────────────
       PLAYLIST GRID
       ─────────────────────────────────────────────────────────────── */
    .pl-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }
    
    .pl-card {
        border-radius: 10px;
    }
    
    .pl-card-title {
        font-size: 14px;
    }
    
    .pl-card-count {
        font-size: 11px;
    }
    
    /* ───────────────────────────────────────────────────────────────
       PAGINATION
       ─────────────────────────────────────────────────────────────── */
    .pagination {
        gap: 4px;
        margin-top: 24px;
    }
    
    .pagination a,
    .pagination span {
        width: 34px;
        height: 34px;
        font-size: 13px;
    }
    
    /* Hide page numbers on very small screens, keep only prev/next */
    .pagination .page-num {
        display: none;
    }
    
    .pagination .page-num.active,
    .pagination .page-num:first-of-type,
    .pagination .page-num:last-of-type {
        display: flex;
    }
    
    /* ───────────────────────────────────────────────────────────────
       MODALS
       ─────────────────────────────────────────────────────────────── */
    .modal-content {
        max-width: 95%;
        margin: 20px auto;
        max-height: calc(100vh - 40px);
        overflow-y: auto;
    }
    
    .modal-header h3 {
        font-size: 18px;
    }
    
    .modal-body {
        padding: 16px;
    }
    
    /* ───────────────────────────────────────────────────────────────
       BULK SELECTION BAR
       ─────────────────────────────────────────────────────────────── */
    .bulk-bar {
        padding: 12px;
        flex-wrap: wrap;
        gap: 8px;
    }
    
    .bulk-bar-count {
        font-size: 13px;
    }
    
    .bulk-bar button {
        font-size: 12px;
        padding: 6px 12px;
    }
    
    /* ───────────────────────────────────────────────────────────────
       FORMS
       ─────────────────────────────────────────────────────────────── */
    .form-group label {
        font-size: 13px;
    }
    
    .form-group input,
    .form-group textarea,
    .form-group select {
        font-size: 14px;
        padding: 10px 12px;
    }
    
    .btn-primary,
    .btn-secondary {
        font-size: 14px;
        padding: 10px 16px;
    }
    
    /* ───────────────────────────────────────────────────────────────
       PROFILE TABS
       ─────────────────────────────────────────────────────────────── */
    .profile-tabs {
        flex-wrap: wrap;
        gap: 6px;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    .profile-tab {
        font-size: 13px;
        padding: 8px 14px;
        white-space: nowrap;
    }
    
    /* ───────────────────────────────────────────────────────────────
       TRENDING HERO
       ─────────────────────────────────────────────────────────────── */
    .trending-hero {
        height: 180px;
        padding: 20px;
    }
    
    .trending-hero h2 {
        font-size: 24px;
        letter-spacing: 2px;
    }
    
    .trending-hero p {
        font-size: 13px;
    }
    
    /* ───────────────────────────────────────────────────────────────
       TOAST NOTIFICATIONS
       ─────────────────────────────────────────────────────────────── */
    .tag-toast-msg,
    .toast-msg {
        bottom: 70px !important;
        padding: 10px 20px;
        font-size: 13px;
        max-width: 90%;
    }
    
    /* ───────────────────────────────────────────────────────────────
       AD CONTAINERS (preserve responsiveness)
       ─────────────────────────────────────────────────────────────── */
    .ad-wrap {
        padding: 10px 12px;
        overflow: hidden;
    }
    
    .ad-wrap iframe,
    .ad-wrap > div {
        max-width: 100%;
    }
}

/* ═══════════════════════════════════════════════════════════════════════
   SMALL PHONE OPTIMIZATIONS (380px - 600px)
   ═══════════════════════════════════════════════════════════════════════ */
@media (max-width: 600px) {
    
    /* Navigation even more compact */
    nav {
        padding: 6px 10px;
    }
    
    .logo {
        font-size: 18px !important;
        letter-spacing: 1px;
    }
    
    /* Hide search bar on very small phones, show search icon button instead */
    .search-bar {
        display: none;
    }
    
    /* Optional: Add mobile search toggle button (requires JS) */
    .mobile-search-toggle {
        display: flex !important;
        width: 32px;
        height: 32px;
        align-items: center;
        justify-content: center;
        background: var(--surface2);
        border: 1px solid var(--border);
        border-radius: 8px;
        color: var(--muted2);
        cursor: pointer;
    }
    
    /* Video grid: force 2 columns */
    .video-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 8px;
    }
    
    /* Video card even more compact */
    .video-card-body {
        padding: 8px;
    }
    
    .video-card-title {
        font-size: 12px;
    }
    
    .video-card-meta {
        font-size: 10px;
    }
    
    /* Playlist grid: 2 columns */
    .pl-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 10px;
    }
    
    /* Section padding tighter */
    .section {
        padding: 16px 10px 28px;
    }
    
    /* Watch page compact */
    .video-info-box {
        padding: 12px;
    }
    
    .video-info-box h1 {
        font-size: 16px;
    }
    
    /* Buttons smaller */
    .video-actions .btn-icon,
    .video-actions button {
        font-size: 11px;
        padding: 6px 10px;
    }
    
    /* Tag subscribe buttons */
    .tag-subscribe-btn {
        width: 20px !important;
        height: 20px !important;
    }
    
    .tag-subscribe-btn svg {
        width: 12px;
        height: 12px;
    }
    
    /* Bulk selection bar stack vertically */
    .bulk-bar {
        flex-direction: column;
        align-items: stretch;
    }
    
    .bulk-bar button {
        width: 100%;
        justify-content: center;
    }
    
    /* Modal full screen on very small phones */
    .modal-content {
        max-width: 100%;
        margin: 0;
        max-height: 100vh;
        border-radius: 0;
    }
    
    /* Form inputs full width */
    .form-group input,
    .form-group textarea,
    .form-group select,
    .form-group button {
        width: 100%;
    }
    
    /* Trending hero more compact */
    .trending-hero {
        height: 150px;
        padding: 16px;
    }
    
    .trending-hero h2 {
        font-size: 20px;
    }
    
    /* Profile tabs scroll horizontally */
    .profile-tabs {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none; /* Firefox */
    }
    
    .profile-tabs::-webkit-scrollbar {
        display: none; /* Chrome/Safari */
    }
}

/* ═══════════════════════════════════════════════════════════════════════
   TINY PHONE OPTIMIZATIONS (< 380px)
   For very small devices like iPhone SE (1st gen)
   ═══════════════════════════════════════════════════════════════════════ */
@media (max-width: 380px) {
    
    /* Video grid: SINGLE COLUMN */
    .video-grid {
        grid-template-columns: 1fr !important;
        gap: 10px;
    }
    
    /* Playlist grid: SINGLE COLUMN */
    .pl-grid {
        grid-template-columns: 1fr !important;
        gap: 10px;
    }
    
    /* Logo super compact */
    .logo {
        font-size: 16px !important;
        letter-spacing: 0.5px;
    }
    
    /* Hide all non-essential nav items */
    .nav-links {
        display: none !important;
    }
    
    .search-bar {
        display: none !important;
    }
    
    /* Stack nav items vertically if needed */
    .nav-right {
        flex-wrap: wrap;
    }
    
    /* Section title smaller */
    .section-title {
        font-size: 18px;
    }
    
    /* Video info box minimal padding */
    .video-info-box {
        padding: 10px;
    }
    
    .video-info-box h1 {
        font-size: 15px;
    }
    
    /* Comment avatars smaller */
    .comment-avatar {
        width: 28px;
        height: 28px;
        font-size: 11px;
    }
    
    /* Pagination simplified */
    .pagination a,
    .pagination span {
        width: 30px;
        height: 30px;
        font-size: 12px;
    }
    
    /* Modal actions stack */
    .modal-actions {
        flex-direction: column;
    }
    
    .modal-actions button {
        width: 100%;
    }
}

/* ═══════════════════════════════════════════════════════════════════════
   LANDSCAPE MODE ADJUSTMENTS
   For phones in landscape orientation
   ═══════════════════════════════════════════════════════════════════════ */
@media (max-width: 900px) and (orientation: landscape) {
    
    /* Navigation compact in landscape */
    nav {
        padding: 6px 12px;
    }
    
    /* Video player takes more height in landscape */
    .player-wrap {
        max-height: 80vh;
    }
    
    /* Reduce section padding in landscape */
    .section {
        padding: 16px 12px 24px;
    }
    
    /* Video grid: 3 columns in landscape on tablets */
    @media (min-width: 600px) {
        .video-grid {
            grid-template-columns: repeat(3, 1fr) !important;
        }
        
        .pl-grid {
            grid-template-columns: repeat(3, 1fr) !important;
        }
    }
}

/* ═══════════════════════════════════════════════════════════════════════
   TOUCH OPTIMIZATIONS
   Larger tap targets for better mobile UX
   ═══════════════════════════════════════════════════════════════════════ */
@media (pointer: coarse) {
    
    /* Minimum 44x44px tap targets (Apple HIG) */
    button,
    a,
    .btn-icon,
    .filter-pill,
    .tag-pill {
        min-height: 44px;
        min-width: 44px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }
    
    /* Checkbox/radio inputs */
    input[type="checkbox"],
    input[type="radio"] {
        min-width: 24px;
        min-height: 24px;
    }
    
    /* Select dropdowns */
    select {
        min-height: 44px;
    }
}

/* ═══════════════════════════════════════════════════════════════════════
   ACCESSIBILITY IMPROVEMENTS
   ═══════════════════════════════════════════════════════════════════════ */

/* Focus visible for keyboard navigation */
*:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

/* Reduced motion for users with motion sensitivity */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* High contrast mode adjustments */
@media (prefers-contrast: high) {
    * {
        border-width: 2px;
    }
    
    button,
    a {
        font-weight: 600;
    }
}

/* ═══════════════════════════════════════════════════════════════════════
   PRINT STYLES (bonus)
   ═══════════════════════════════════════════════════════════════════════ */
@media print {
    nav,
    .filter-bar,
    .video-actions,
    .bulk-bar,
    footer,
    .ad-wrap {
        display: none !important;
    }
    
    .section {
        padding: 0;
    }
    
    .video-grid {
        display: block;
    }
    
    .video-card {
        page-break-inside: avoid;
        margin-bottom: 20px;
    }
}

/* ═══════════════════════════════════════════════════════════════════════
   END OF MOBILE.CSS
   Total rules: ~250 (comprehensive mobile optimization)
   Compatible with: Chrome, Safari, Firefox, Edge (all mobile versions)
   Last updated: <?= date('Y-m-d') ?>
   ═══════════════════════════════════════════════════════════════════════ */