/* ==========================================
   MOBILE & TABLET RESPONSIVE STYLES
   Vibe Platform - Optimized for touch devices
   ========================================== */

/* ==========================================
   MOBILE-FIRST BASE ADJUSTMENTS
   ========================================== */

/* Ensure minimum font size to prevent zoom on iOS */
html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
}

/* Improve tap highlighting */
* {
    -webkit-tap-highlight-color: rgba(102, 126, 234, 0.2);
    -webkit-touch-callout: none;
}

/* ==========================================
   GLOBAL OVERRIDES
   ========================================== */

/* Hide report button on all devices - cleaner UI */
.report-btn {
    display: none !important;
}

/* Safety: Hide follow button in own video containers (backup to JS logic) */
.video-container[data-is-owner="true"] .btn-follow {
    display: none !important;
}

/* ==========================================
   BOTTOM NAVIGATION (Mobile Only)
   ========================================== */

@media (max-width: 767px) {
    .bottom-nav {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        height: 60px;
        background: rgba(10, 10, 15, 0.95);
        backdrop-filter: blur(20px);
        -webkit-backdrop-filter: blur(20px);
        border-top: 1px solid var(--color-border);
        display: flex !important;
        justify-content: space-around;
        align-items: center;
        padding: 0 var(--spacing-sm);
        z-index: var(--z-sticky);
        box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.3);
    }

    .bottom-nav-item {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        padding: var(--spacing-sm);
        min-width: 48px;
        min-height: 48px;
        color: var(--color-text-secondary);
        text-decoration: none;
        transition: all var(--transition-fast);
        position: relative;
        cursor: pointer;
        -webkit-user-select: none;
        user-select: none;
    }

    .bottom-nav-item:active {
        transform: scale(0.95);
        opacity: 0.7;
    }

    .bottom-nav-item.active {
        color: var(--color-primary);
    }

    .bottom-nav-item.active::before {
        content: '';
        position: absolute;
        top: 0;
        left: 50%;
        transform: translateX(-50%);
        width: 30px;
        height: 3px;
        background: var(--gradient-primary);
        border-radius: 0 0 3px 3px;
    }

    .bottom-nav-icon {
        font-size: 24px;
        margin-bottom: 2px;
    }

    .bottom-nav-label {
        font-size: 11px;
        font-weight: 500;
        margin-top: 2px;
    }

    /* Upload button - special styling */
    .bottom-nav-item.upload-btn {
        position: relative;
    }

    .bottom-nav-item.upload-btn .bottom-nav-icon {
        width: 48px;
        height: 32px;
        background: var(--gradient-primary);
        border-radius: var(--radius-md);
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 20px;
        color: white;
        box-shadow: var(--shadow-glow);
    }
}

/* Hide bottom nav on tablet and desktop */
@media (min-width: 768px) {
    .bottom-nav {
        display: none;
    }
}

/* ==========================================
   TOP NAVBAR - MOBILE ADJUSTMENTS
   ========================================== */

@media (max-width: 767px) {

    /* Hide top navbar completely on mobile - we have bottom nav */
    .navbar {
        display: none;
    }
}

/* ==========================================
   MAIN CONTENT - MOBILE SPACING
   ========================================== */

@media (max-width: 767px) {
    .main-content {
        padding-top: 0;
        /* No navbar on mobile */
        padding-bottom: 70px;
        /* Bottom nav height + spacing */
        padding-left: 0;
        padding-right: 0;
    }

    .container {
        padding: 0 var(--spacing-md);
    }
}

/* ==========================================
   VIDEO PLAYER - MOBILE OPTIMIZATION
   ========================================== */

@media (max-width: 767px) {
    .video-container {
        width: 100%;
        max-width: 100%;
        margin: 0;
        border-radius: 0;
    }

    .video-card {
        border-radius: 0;
        margin-bottom: 0;
    }

    video {
        width: 100%;
        height: auto;
        max-height: calc(100vh - 126px);
        /* Screen height - navbar - bottom nav */
        object-fit: contain;
    }

    /* Video overlay controls */
    .video-overlay {
        padding: var(--spacing-md);
    }

    .video-info {
        padding: var(--spacing-md);
    }

    .video-creator {
        gap: var(--spacing-sm);
    }

    .video-creator img {
        width: 40px;
        height: 40px;
    }

    .video-title {
        font-size: 16px;
        line-height: 1.4;
    }

    .video-description {
        font-size: 14px;
    }

    /* Interaction buttons - larger for touch */
    .video-actions {
        gap: var(--spacing-lg);
        padding: var(--spacing-md);
    }

    .action-btn {
        min-width: 48px;
        min-height: 48px;
        padding: var(--spacing-sm);
        font-size: 28px;
    }

    .action-btn .count {
        font-size: 12px;
        margin-top: var(--spacing-xs);
    }
}

/* ==========================================
   FEED - MOBILE OPTIMIZATION
   ========================================== */

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

    .video-feed {
        gap: 0;
    }

    /* Video cards take full width */
    .feed-video-card {
        width: 100%;
        border-radius: 0;
        margin-bottom: 2px;
    }

    .video-thumbnail {
        height: 300px;
    }
}

/* ==========================================
   EXPLORE PAGE - MOBILE GRID
   ========================================== */

@media (max-width: 767px) {
    .explore-header {
        padding: var(--spacing-md);
    }

    .explore-header h1 {
        font-size: 24px;
    }

    .explore-tabs {
        padding: 0 var(--spacing-md);
        gap: var(--spacing-sm);
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .explore-tab {
        min-width: auto;
        padding: var(--spacing-sm) var(--spacing-md);
        font-size: 14px;
        white-space: nowrap;
    }

    /* Video grid - 2 columns on mobile */
    .explore-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 2px;
        padding: 0;
    }

    .explore-video-card {
        border-radius: 0;
    }

    .explore-video-thumbnail {
        height: 250px;
    }

    /* Creator cards - horizontal scroll */
    .creators-section {
        padding: var(--spacing-md);
    }

    .creators-grid {
        display: flex;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        gap: var(--spacing-md);
        padding-bottom: var(--spacing-sm);
    }

    .creator-card {
        min-width: 120px;
        flex-shrink: 0;
    }

    .creator-avatar {
        width: 80px;
        height: 80px;
    }
}

/* ==========================================
   COMMENTS DRAWER - MOBILE
   ========================================== */

@media (max-width: 767px) {
    .comments-drawer .drawer-content {
        width: 100%;
        max-width: 100%;
        height: 75vh;
        bottom: 0;
        top: auto;
        border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    }

    .drawer-header {
        padding: var(--spacing-md);
    }

    .drawer-header h3 {
        font-size: 18px;
    }

    .comments-list {
        padding: var(--spacing-md);
    }

    .comment-item {
        padding: var(--spacing-md) 0;
        gap: var(--spacing-sm);
    }

    .comment-input-container {
        padding: var(--spacing-md);
        gap: var(--spacing-sm);
    }

    .comment-input {
        font-size: 16px;
        /* Prevent zoom on iOS */
        padding: var(--spacing-sm) var(--spacing-md);
        min-height: 44px;
    }

    .post-comment {
        min-width: 60px;
        min-height: 44px;
    }
}

/* ==========================================
   MODALS - MOBILE FULLSCREEN
   ========================================== */

@media (max-width: 767px) {
    .modal-content {
        width: 100%;
        max-width: 100%;
        height: 100vh;
        margin: 0;
        border-radius: 0;
        max-height: 100vh;
    }

    .modal-header {
        padding: var(--spacing-md);
        position: sticky;
        top: 0;
        background: var(--color-bg-secondary);
        z-index: 10;
    }

    .modal-body {
        padding: var(--spacing-md);
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    .modal-footer {
        padding: var(--spacing-md);
        position: sticky;
        bottom: 0;
        background: var(--color-bg-secondary);
    }
}

/* ==========================================
   FORMS - MOBILE OPTIMIZATION
   ========================================== */

@media (max-width: 767px) {
    .form-group {
        margin-bottom: var(--spacing-md);
    }

    .input,
    .textarea,
    select {
        font-size: 16px;
        /* Prevent zoom on iOS */
        padding: var(--spacing-md);
        min-height: 48px;
    }

    .textarea {
        min-height: 120px;
    }

    .btn {
        min-height: 48px;
        padding: var(--spacing-md) var(--spacing-lg);
        font-size: 16px;
    }

    .btn-block {
        width: 100%;
    }

    label {
        font-size: 14px;
        margin-bottom: var(--spacing-sm);
    }
}

/* ==========================================
   PROFILE PAGE - MOBILE
   ========================================== */

@media (max-width: 767px) {
    .profile-header {
        padding: var(--spacing-md);
    }

    .profile-avatar {
        width: 100px;
        height: 100px;
    }

    .profile-stats {
        gap: var(--spacing-lg);
    }

    .stat-item {
        min-width: auto;
    }

    .stat-value {
        font-size: 20px;
    }

    .stat-label {
        font-size: 12px;
    }

    .profile-actions {
        flex-direction: column;
        gap: var(--spacing-sm);
    }

    .profile-actions .btn {
        width: 100%;
    }

    /* Video grid */
    .profile-videos-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 2px;
    }
}

/* ==========================================
   SEARCH - MOBILE
   ========================================== */

@media (max-width: 767px) {
    .search-container {
        padding: var(--spacing-md);
    }

    .search-header input {
        font-size: 16px;
        padding: var(--spacing-md);
        min-height: 48px;
    }

    .search-tabs {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .search-tab {
        min-width: auto;
        padding: var(--spacing-sm) var(--spacing-md);
        font-size: 14px;
        white-space: nowrap;
    }

    .search-results {
        padding: var(--spacing-md) 0;
    }

    /* User result cards */
    .user-result {
        padding: var(--spacing-md);
        gap: var(--spacing-md);
    }

    .user-result img {
        width: 50px;
        height: 50px;
    }

    /* Video results - 2 column grid */
    .search-video-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 2px;
    }
}

/* ==========================================
   UPLOAD PAGE - MOBILE
   ========================================== */

@media (max-width: 767px) {
    .upload-container {
        padding: var(--spacing-md);
    }

    .upload-zone {
        min-height: 200px;
        padding: var(--spacing-lg);
    }

    .upload-icon {
        font-size: 48px;
    }

    .upload-title {
        font-size: 18px;
    }

    .upload-subtitle {
        font-size: 14px;
    }

    /* Video preview */
    .video-preview {
        max-height: 400px;
    }

    /* Upload form */
    .upload-form {
        padding: var(--spacing-md);
    }
}

/* ==========================================
   NOTIFICATIONS - MOBILE
   ========================================== */

@media (max-width: 767px) {
    .notifications-dropdown {
        position: fixed;
        top: 56px;
        right: 0;
        left: 0;
        width: 100%;
        max-height: calc(100vh - 126px);
        border-radius: 0;
    }

    .notification-item {
        padding: var(--spacing-md);
    }

    .notification-avatar {
        width: 44px;
        height: 44px;
    }
}

/* ==========================================
   TOAST MESSAGES - MOBILE
   ========================================== */

@media (max-width: 767px) {
    .toast {
        bottom: 70px;
        /* Above bottom nav */
        left: var(--spacing-md);
        right: var(--spacing-md);
        width: auto;
        min-width: 0;
    }
}

/* ==========================================
   TABLET PORTRAIT (768px - 1023px)
   ========================================== */

@media (min-width: 768px) and (max-width: 1180px) {

    /* Show regular navbar, hide bottom nav */
    .bottom-nav {
        display: none;
    }

    .navbar {
        display: flex;
    }

    .main-content {
        padding-top: 80px;
        padding-bottom: var(--spacing-md);
        max-width: 90vw;
    }

    /* === TABLET SPLIT VIEW FEED === */
    .feed-container {
        max-width: 100%;
        padding: 0 var(--spacing-md);
    }

    .video-container {
        display: grid;
        grid-template-columns: 60% 40%;
        grid-template-rows: 1fr auto;
        height: 600px;
        max-height: 70vh;
        max-width: 900px;
        margin: 0 auto 40px auto;
        background: #000;
        border-radius: var(--radius-xl);
        overflow: hidden;
        box-shadow: var(--shadow-2xl);
        border: 1px solid var(--color-border);
    }

    /* Left Col: Video */
    .video-player {
        grid-column: 1;
        grid-row: 1 / -1;
        width: 100%;
        height: 100%;
        object-fit: contain;
        background: black;
    }

    /* Right Col: Info (Top) */
    .video-info-overlay {
        grid-column: 2;
        grid-row: 1;
        position: relative;
        bottom: auto;
        left: auto;
        width: 100%;
        height: 100%;
        background: var(--color-bg-secondary);
        background: linear-gradient(to bottom, var(--color-bg-secondary), var(--color-bg-tertiary));
        padding: var(--spacing-lg);
        overflow-y: auto;
        background-image: none !important;
        /* Remove mobile gradient */
    }

    .video-caption {
        font-size: 1rem;
        line-height: 1.5;
        margin-top: var(--spacing-md);
        color: var(--color-text-primary);
    }

    .video-user-info {
        margin-bottom: var(--spacing-lg);
    }

    /* Right Col: Actions (Bottom) */
    .video-actions {
        grid-column: 2;
        grid-row: 2;
        position: relative;
        right: auto;
        bottom: auto;
        flex-direction: row;
        justify-content: space-around;
        padding: var(--spacing-md);
        background: var(--color-bg-tertiary);
        border-top: 1px solid var(--color-border);
        width: 100%;
    }

    .action-btn {
        flex-direction: column;
    }

    /* Other Grids */
    .explore-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: var(--spacing-md);
    }

    .profile-videos-grid {
        grid-template-columns: repeat(4, 1fr);
    }

    .search-video-grid {
        grid-template-columns: repeat(3, 1fr);
    }

    .modal-content {
        max-width: 600px;
        height: auto;
        max-height: 90vh;
        border-radius: var(--radius-xl);
    }
}

/* ==========================================
   TABLET LANDSCAPE (1024px - 1279px)
   ========================================== */

@media (min-width: 1024px) and (max-width: 1279px) {
    .explore-grid {
        grid-template-columns: repeat(4, 1fr);
    }

    .profile-videos-grid {
        grid-template-columns: repeat(5, 1fr);
    }

    .search-video-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

/* ==========================================
   TOUCH IMPROVEMENTS (ALL DEVICES)
   ========================================== */

/* Increase touch target sizes */
button,
a,
.clickable {
    min-width: 44px;
    min-height: 44px;
}

/* Add touch feedback */
button:active,
.btn:active,
a:active {
    opacity: 0.7;
    transform: scale(0.98);
}

/* Improve scrolling on touch devices */
.scrollable {
    -webkit-overflow-scrolling: touch;
    overflow-scrolling: touch;
}

/* ==========================================
   LANDSCAPE ORIENTATION OPTIMIZATION
   ========================================== */

@media (max-width: 767px) and (orientation: landscape) {

    /* Hide bottom nav in landscape for more screen space */
    .bottom-nav {
        display: none;
    }

    .main-content {
        padding-bottom: var(--spacing-md);
    }

    /* Video takes more space */
    video {
        max-height: calc(100vh - 56px);
    }

    /* Compact navbar */
    .navbar {
        height: 48px;
        padding: var(--spacing-xs) var(--spacing-md);
    }

    .main-content {
        padding-top: 48px;
    }
}

/* ==========================================
   ACCESSIBILITY - LARGER TEXT OPTION
   ========================================== */

@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 support */
@media (prefers-contrast: high) {
    :root {
        --color-border: rgba(255, 255, 255, 0.3);
        --color-text-secondary: #d4d4d8;
    }
}