/* ==========================================
   VIDR - TIKTOK-STYLE FULLSCREEN FEED
   ========================================== */

/* TikTok Mode - Full Screen Everything */
body.tiktok-mode {
    background: #000 !important;
    overflow: hidden !important;
}

body.tiktok-mode .app-container {
    background: #000 !important;
}

body.tiktok-mode #top-header {
    display: none !important;
}

body.tiktok-mode #stories-bar {
    display: none !important;
}

body.tiktok-mode .main-content {
    padding-bottom: 0 !important;
    padding-top: 0 !important;
    background: #000 !important;
    margin-left: 0 !important;
    max-width: 100% !important;
    height: 100vh !important;
    height: 100dvh !important;
    overflow: hidden !important;
}

body.tiktok-mode #tiktok-tabs {
    display: flex !important;
}

body.tiktok-mode #tiktok-search-btn {
    display: flex !important;
}

/* TikTok Tabs Overlay */
.tiktok-tabs {
    position: fixed;
    top: calc(env(safe-area-inset-top, 0px) + 12px);
    left: 50%;
    transform: translateX(-50%);
    z-index: 100;
    display: none;
    gap: 20px;
    background: transparent;
    padding: 0 16px;
}

.tiktok-tabs .tab-btn {
    background: none;
    border: none;
    color: rgba(255,255,255,0.6);
    font-size: 1rem;
    font-weight: 700;
    padding: 6px 8px;
    cursor: pointer;
    font-family: var(--font-primary);
    text-shadow: 0 1px 3px rgba(0,0,0,0.5);
    position: relative;
    transition: all 0.2s;
    white-space: nowrap;
}

.tiktok-tabs .tab-btn.active {
    color: white;
}

.tiktok-tabs .tab-btn.active::after {
    content: '';
    position: absolute;
    bottom: -4px;
    left: 50%;
    transform: translateX(-50%);
    width: 20px;
    height: 3px;
    background: white;
    border-radius: 2px;
}

/* Search Icon */
.tiktok-search-btn {
    position: fixed;
    top: calc(env(safe-area-inset-top, 0px) + 12px);
    right: 12px;
    z-index: 100;
    width: 36px;
    height: 36px;
    background: rgba(0,0,0,0.3);
    backdrop-filter: blur(10px);
    border: none;
    border-radius: 50%;
    color: white;
    font-size: 1.2rem;
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
}

/* TikTok Feed Container */
.tiktok-feed {
    height: 100vh !important;
    height: 100dvh !important;
    overflow-y: scroll !important;
    scroll-snap-type: y mandatory !important;
    scrollbar-width: none;
    -ms-overflow-style: none;
    background: #000 !important;
    position: relative;
    width: 100% !important;
}

.tiktok-feed::-webkit-scrollbar {
    display: none;
}

/* Only active feed shows */
.feed-container {
    display: none;
}

.feed-container.active {
    display: block;
}

body.tiktok-mode .feed-container.active {
    display: block !important;
    height: 100vh !important;
    height: 100dvh !important;
}

/* ==========================================
   TIKTOK POST - FULLSCREEN
   ========================================== */
.tiktok-post {
    height: 100vh !important;
    height: 100dvh !important;
    width: 100% !important;
    scroll-snap-align: start !important;
    scroll-snap-stop: always !important;
    position: relative !important;
    overflow: hidden !important;
    background: #000 !important;
}

/* Videos and Images - FULLSCREEN BACKGROUND */
.tiktok-post > video,
.tiktok-post > img {
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100% !important;
    object-fit: cover !important;
    background: #000 !important;
    z-index: 1 !important;
}

/* Text-only post */
.tiktok-post.text-post {
    background: linear-gradient(135deg, #f8a4d0, #a8d8ea, #d5aaff) !important;
    padding: 40px 24px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
}

.tiktok-post.text-post .text-content {
    color: white;
    font-size: 1.6rem;
    font-weight: 700;
    text-align: center;
    line-height: 1.5;
    text-shadow: 0 2px 10px rgba(0,0,0,0.3);
    max-width: 400px;
    word-wrap: break-word;
    position: relative;
    z-index: 5;
}

/* ==========================================
   TIKTOK BOTTOM INFO
   ========================================== */
.tiktok-info {
    position: absolute !important;
    bottom: calc(var(--nav-height, 60px) + 20px) !important;
    left: 0 !important;
    right: 80px !important;
    padding: 16px !important;
    background: linear-gradient(to top, rgba(0,0,0,0.8), transparent) !important;
    color: white !important;
    z-index: 20 !important;
    pointer-events: auto;
}

.tiktok-info .username-line {
    display: flex !important;
    align-items: center !important;
    gap: 8px !important;
    margin-bottom: 8px !important;
    flex-wrap: wrap !important;
}

.tiktok-info .username {
    font-weight: 800 !important;
    font-size: 1rem !important;
    cursor: pointer;
    text-shadow: 0 1px 3px rgba(0,0,0,0.5);
    color: white !important;
}

.tiktok-info .verified {
    color: #60a5fa !important;
    font-size: 1rem !important;
    filter: drop-shadow(0 0 4px rgba(96,165,250,0.6));
    display: inline-block !important;
    width: auto !important;
    height: auto !important;
}

.tiktok-info .follow-btn {
    background: transparent;
    border: 1px solid white;
    color: white;
    padding: 3px 12px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 700;
    cursor: pointer;
    margin-left: 4px;
    font-family: var(--font-primary);
}

.tiktok-info .caption {
    font-size: 0.875rem !important;
    line-height: 1.4 !important;
    margin-bottom: 6px !important;
    color: white !important;
    text-shadow: 0 1px 2px rgba(0,0,0,0.5);
}

.tiktok-info .music-line {
    display: flex !important;
    align-items: center !important;
    gap: 6px !important;
    font-size: 0.8rem !important;
    margin-top: 4px !important;
    color: white !important;
    text-shadow: 0 1px 2px rgba(0,0,0,0.5);
}

.tiktok-info .user-tag {
    display: inline-flex !important;
    padding: 2px 8px !important;
    border-radius: 4px !important;
    font-size: 0.65rem !important;
    font-weight: 700 !important;
    text-transform: uppercase !important;
    margin-left: 4px !important;
    color: white !important;
}

.tiktok-info .user-tag.admin {
    background: linear-gradient(135deg, #ff6b6b, #ff8e53) !important;
}

.tiktok-info .user-tag.mod {
    background: linear-gradient(135deg, #60a5fa, #3b82f6) !important;
}

.tiktok-info .level-badge {
    background: rgba(248, 164, 208, 0.9) !important;
    color: white !important;
    padding: 2px 6px !important;
    border-radius: 4px !important;
    font-size: 0.65rem !important;
    font-weight: 700 !important;
}

/* ==========================================
   TIKTOK RIGHT SIDE ACTIONS
   ========================================== */
.tiktok-actions {
    position: absolute !important;
    right: 8px !important;
    bottom: calc(var(--nav-height, 60px) + 100px) !important;
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    gap: 20px !important;
    z-index: 20 !important;
}

.tiktok-action-btn {
    background: none !important;
    border: none !important;
    color: white !important;
    cursor: pointer !important;
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    gap: 4px !important;
    font-family: var(--font-primary) !important;
    padding: 0 !important;
}

.tiktok-action-btn .icon-circle {
    width: 44px !important;
    height: 44px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    font-size: 1.8rem !important;
    color: white !important;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.5));
    background: transparent !important;
    border-radius: 0 !important;
    padding: 0 !important;
}

.tiktok-action-btn.liked .icon-circle i {
    color: #ff3040 !important;
}

.tiktok-action-btn .count {
    font-size: 0.75rem !important;
    font-weight: 700 !important;
    color: white !important;
    text-shadow: 0 1px 3px rgba(0,0,0,0.5);
}

/* ==========================================
   AVATAR BUTTON - CRITICAL FIX
   ========================================== */
.tiktok-avatar-btn {
    position: relative !important;
    margin-bottom: 6px !important;
    width: 44px !important;
    height: 44px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    flex-shrink: 0 !important;
}

.tiktok-avatar-btn img {
    width: 44px !important;
    height: 44px !important;
    max-width: 44px !important;
    max-height: 44px !important;
    min-width: 44px !important;
    min-height: 44px !important;
    border-radius: 50% !important;
    border: 2px solid white !important;
    object-fit: cover !important;
    display: block !important;
    padding: 0 !important;
    margin: 0 !important;
    position: relative !important;
    inset: auto !important;
}

.tiktok-avatar-btn .follow-plus {
    position: absolute !important;
    bottom: -8px !important;
    left: 50% !important;
    transform: translateX(-50%) !important;
    width: 20px !important;
    height: 20px !important;
    background: #ff3040 !important;
    color: white !important;
    border-radius: 50% !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    font-size: 0.75rem !important;
    font-weight: 900 !important;
    border: none !important;
    cursor: pointer !important;
    padding: 0 !important;
    z-index: 5 !important;
}

/* ==========================================
   BUY BUTTON
   ========================================== */
.tiktok-buy-btn {
    position: absolute !important;
    bottom: calc(var(--nav-height, 60px) + 90px) !important;
    left: 16px !important;
    display: flex !important;
    align-items: center !important;
    gap: 8px !important;
    background: rgba(255, 193, 7, 0.95) !important;
    color: #333 !important;
    border: none !important;
    border-radius: 8px !important;
    padding: 10px 14px !important;
    font-weight: 700 !important;
    font-size: 0.875rem !important;
    cursor: pointer !important;
    box-shadow: 0 4px 15px rgba(255, 193, 7, 0.4);
    z-index: 20 !important;
}

/* ==========================================
   PLAY/PAUSE ICON
   ========================================== */
.play-pause-icon {
    position: absolute !important;
    top: 50% !important;
    left: 50% !important;
    transform: translate(-50%, -50%) !important;
    pointer-events: none !important;
    z-index: 10 !important;
    transition: opacity 0.2s !important;
    background: transparent !important;
}

.play-pause-icon i {
    font-size: 5rem !important;
    color: rgba(255,255,255,0.9) !important;
    filter: drop-shadow(0 2px 10px rgba(0,0,0,0.5));
}

/* ==========================================
   VOLUME BUTTON
   ========================================== */
.volume-toggle {
    position: absolute !important;
    top: calc(env(safe-area-inset-top, 0px) + 60px) !important;
    right: 12px !important;
    width: 40px !important;
    height: 40px !important;
    background: rgba(0,0,0,0.4) !important;
    backdrop-filter: blur(10px);
    border: none !important;
    border-radius: 50% !important;
    color: white !important;
    font-size: 1.2rem !important;
    cursor: pointer !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    z-index: 15 !important;
    padding: 0 !important;
}

/* ==========================================
   VIDEO PROGRESS BAR
   ========================================== */
.video-progress {
    position: absolute !important;
    bottom: var(--nav-height, 60px) !important;
    left: 0 !important;
    right: 0 !important;
    height: 3px !important;
    background: rgba(255,255,255,0.2) !important;
    z-index: 15 !important;
    pointer-events: none !important;
}

.video-progress .fill {
    height: 100% !important;
    background: white !important;
    width: 0% !important;
    transition: width 0.1s linear !important;
}

/* ==========================================
   LIVE BADGE
   ========================================== */
.tiktok-live-badge {
    position: absolute !important;
    top: calc(env(safe-area-inset-top, 0px) + 60px) !important;
    left: 16px !important;
    background: linear-gradient(135deg, #ff3040, #ff6b6b) !important;
    color: white !important;
    padding: 6px 16px !important;
    border-radius: 20px !important;
    font-size: 0.7rem !important;
    font-weight: 800 !important;
    display: flex !important;
    align-items: center !important;
    gap: 6px !important;
    z-index: 20 !important;
    animation: livePulse 1.5s ease-in-out infinite;
}

.tiktok-live-badge::before {
    content: '';
    width: 8px;
    height: 8px;
    background: white;
    border-radius: 50%;
}

@keyframes livePulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

/* ==========================================
   CAROUSEL DOTS
   ========================================== */
.tiktok-carousel-dots {
    position: absolute !important;
    top: calc(env(safe-area-inset-top, 0px) + 60px) !important;
    left: 50% !important;
    transform: translateX(-50%) !important;
    display: flex !important;
    gap: 4px !important;
    z-index: 15 !important;
}

.tiktok-carousel-dots .dot {
    width: 20px;
    height: 3px;
    background: rgba(255,255,255,0.4);
    border-radius: 2px;
}

.tiktok-carousel-dots .dot.active {
    background: white;
}

/* ==========================================
   DOUBLE TAP HEART
   ========================================== */
.double-tap-heart {
    position: absolute !important;
    top: 50% !important;
    left: 50% !important;
    transform: translate(-50%, -50%) !important;
    font-size: 5rem !important;
    z-index: 100 !important;
    pointer-events: none;
}

/* ==========================================
   DESKTOP LAYOUT
   ========================================== */
@media screen and (min-width: 768px) {
    body.tiktok-mode .main-content {
        margin-left: 240px !important;
    }
    
    .tiktok-feed {
        max-width: 500px !important;
        margin: 0 auto !important;
    }
    
    .tiktok-post {
        max-width: 500px !important;
        margin: 0 auto !important;
    }
    
    .tiktok-tabs {
        left: calc(50% + 120px) !important;
        transform: translateX(-50%) !important;
    }
    
    .tiktok-search-btn {
        right: calc(50% - 250px + 12px) !important;
    }
}

/* ==========================================
   FEED SKELETON
   ========================================== */
.feed-skeleton {
    width: 100%;
    height: 100vh;
    background: linear-gradient(135deg, #1a1a2e, #16213e);
    display: flex;
    align-items: center;
    justify-content: center;
    scroll-snap-align: start;
}

.feed-skeleton .skeleton-icon {
    font-size: 3rem;
    color: rgba(255,255,255,0.3);
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(255,255,255,0.2);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ==========================================
   DISCOVER GRID FIX
   ========================================== */
body:not(.tiktok-mode) #discover-feed.active {
    display: block !important;
}

.discover-grid {
    display: grid !important;
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 8px !important;
    padding: 16px !important;
}

@media screen and (min-width: 768px) {
    .discover-grid {
        grid-template-columns: repeat(3, 1fr) !important;
    }
}

@media screen and (min-width: 1024px) {
    .discover-grid {
        grid-template-columns: repeat(4, 1fr) !important;
    }
}
