/* --- Global Variables & Basic Reset --- */
:root {
    --video-bg: #000;
    --video-text-primary: #ffffff;
    --video-text-secondary: #e0e0e0;
    --video-accent-color: #fe2c55;
    /* TikTok-style accent */
    --video-action-icon-color: rgba(255, 255, 255, 0.9);
    --video-bottom-nav-bg: #1c1c1e;
    --video-tab-active-bg: rgba(255, 255, 255, 0.2);
    --video-tab-inactive-color: rgba(255, 255, 255, 0.7);
    --font-family-videos: "Cairo", sans-serif;
    --border-radius-videos: 8px;
    --danger-color-auth: #dc3545;
    /* From auth.css for consistency */
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font-family-videos);
    background-color: var(--video-bg);
    color: var(--video-text-primary);
    overscroll-behavior-y: contain;
    overflow: hidden;
    height: 100vh;
    width: 100vw;
    direction: rtl;
}

/* TikTok-style fixed header */
.video-global-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 200;
    padding: calc(12px + env(safe-area-inset-top)) 16px 10px;
    pointer-events: none;
    background: linear-gradient(180deg, rgba(0, 0, 0, 0.6) 0%, rgba(0, 0, 0, 0) 100%);
}

.video-global-header .video-header {
    pointer-events: auto;
}

.video-header {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
}

.video-header .live-indicator-container {
    flex: 1;
}

.video-header .video-tabs {
    flex: 1;
}

.video-search-icon-btn {
    flex: 0 0 auto;
    width: 42px;
    height: 42px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(145deg, rgba(255, 255, 255, 0.22), rgba(255, 255, 255, 0.06));
    border: 1px solid rgba(255, 255, 255, 0.34);
    border-radius: 14px;
    color: #fff;
    font-size: 1rem;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
    backdrop-filter: blur(8px) saturate(130%);
    -webkit-backdrop-filter: blur(8px) saturate(130%);
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.25);
}

.video-search-icon-btn i {
    background: linear-gradient(135deg, #ffffff, #c8d2ff);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.video-search-icon-btn:hover {
    background: linear-gradient(145deg, rgba(255, 255, 255, 0.28), rgba(255, 255, 255, 0.1));
    transform: translateY(-1px);
    box-shadow: 0 10px 22px rgba(0, 0, 0, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.35);
}

.video-search-icon-btn:focus-visible {
    outline: 2px solid rgba(255, 255, 255, 0.9);
    outline-offset: 2px;
}

.upload-open-btn {
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.4);
    padding: 6px 10px;
    border-radius: 18px;
    font-size: 0.85em;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    backdrop-filter: blur(6px);
}

.upload-open-btn:hover {
    background: rgba(255, 255, 255, 0.25);
}

/* Swiper - TikTok style vertical feed */
.video-swiper {
    width: 100%;
    height: 100vh !important;
    max-height: 100vh;
    position: relative;
    overflow: hidden;
}

.video-swiper .swiper-wrapper {
    height: 100% !important;
}

.video-swiper .swiper-slide {
    height: 100vh !important;
    max-height: 100vh !important;
    min-height: 100vh;
    overflow: hidden;
    background: #000;
    contain: layout style paint;
}

.video-player-container {
    width: 100%;
    height: 100vh;
    overflow-y: scroll;
    scroll-snap-type: y mandatory;
    position: relative;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.video-player-container::-webkit-scrollbar {
    display: none;
}

.video-slide {
    width: 100%;
    height: 100vh !important;
    max-height: 100vh !important;
    min-height: 0;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    contain: layout style paint;
}

.video-background {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-size: cover;
    background-position: center;
}

.video-background video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* TikTok-style overlay: gradient + flex layout - إصلاح ارتفاع 16777213 */
.video-overlay-content {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100vh !important;
    max-height: 100vh !important;
    min-height: 0;
    overflow: hidden;
    contain: layout style paint;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    padding: 15px 15px 80px 15px;
    background: linear-gradient(to top,
            rgba(0, 0, 0, 0.7) 0%,
            transparent 40%,
            transparent 60%,
            rgba(0, 0, 0, 0.2) 100%);
    z-index: 10;
    pointer-events: none;
}

.video-like-burst {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.4);
    font-size: 90px;
    color: rgba(255, 255, 255, 0.92);
    opacity: 0;
    z-index: 3;
    pointer-events: none;
}

.video-like-burst.active {
    animation: video-like-burst 0.65s ease forwards;
}

@keyframes video-like-burst {
    0% {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.3);
    }

    20% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1.05);
    }

    100% {
        opacity: 0;
        transform: translate(-50%, -50%) scale(1.4);
    }
}

.video-overlay-content>* {
    pointer-events: auto;
}

.video-tabs {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    flex: 2;
}

.video-tab {
    background: none;
    border: none;
    color: var(--video-tab-inactive-color);
    font-family: var(--font-family-videos);
    font-size: 1.1em;
    font-weight: 600;
    padding: 5px 0;
    cursor: pointer;
    position: relative;
}

.video-tab.active {
    color: var(--video-text-primary);
}

.video-tab.active::after {
    content: "";
    position: absolute;
    bottom: -2px;
    right: 0;
    width: 100%;
    height: 2px;
    background-color: var(--video-text-primary);
}

/* TikTok-style right side actions column */
.video-side-actions {
    position: absolute;
    bottom: 120px;
    right: 12px;
    left: auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 18px;
    z-index: 15;
}

[dir="rtl"] .video-side-actions {
    right: auto;
    left: 12px;
}

/* زر الصوت - أعلى يسار (مثل TikTok) */
.video-mute-btn {
    position: absolute;
    top: calc(50px + env(safe-area-inset-top));
    left: 12px;
    right: auto;
    bottom: auto;
    z-index: 15;
    padding: 8px;
    background: rgba(0, 0, 0, 0.35);
    border-radius: 50%;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4em;
}

[dir="rtl"] .video-mute-btn {
    left: auto;
    right: 12px;
}

.video-mute-btn i {
    margin-bottom: 0;
}

.author-follow {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.author-avatar-link {
    display: block;
    line-height: 0;
}

.author-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: 2px solid white;
    object-fit: cover;
    display: block;
}

.follow-plus-btn {
    background-color: var(--video-accent-color);
    color: white;
    border: none;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8em;
    cursor: pointer;
    margin: 0 auto 5px auto;
    position: relative;
    z-index: 0;
}

.follow-text {
    display: block;
    font-size: 0.8em;
    color: var(--video-text-secondary);
}

.action-btn {
    background: none;
    border: none;
    color: var(--video-action-icon-color);
    text-align: center;
    cursor: pointer;
}

.action-btn i {
    font-size: 1.8em;
    margin-bottom: 5px;
    display: block;
}

.action-btn span {
    font-size: 0.85em;
    display: block;
    font-weight: 600;
}

.action-btn.like-btn.liked i {
    color: #ff4141;
}

/* TikTok-style bottom info block - ثابت في الأسفل */
.video-info-bottom {
    position: absolute;
    bottom: 100px;
    left: 15px;
    right: 75px;
    color: var(--video-text-primary);
    z-index: 12;
}

[dir="rtl"] .video-info-bottom {
    left: 75px;
    right: 15px;
}

.video-author-name {
    font-size: 1em;
    font-weight: 700;
    margin-bottom: 4px;
    color: white;
    text-decoration: none;
}

.video-author-name:hover {
    color: rgba(255, 255, 255, 0.9);
}

.video-caption {
    font-size: 0.9em;
    line-height: 1.5;
    margin-bottom: 8px;
    color: var(--video-text-secondary);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* زر رفع الفيديو - مثل TikTok */
.upload-video-btn {
    position: absolute;
    top: 50px;
    right: 15px;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    border: 2px solid white;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2em;
    text-decoration: none;
    z-index: 20;
}

.upload-video-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    color: white;
}

[dir="rtl"] .upload-video-btn {
    right: auto;
    left: 15px;
}

.sponsored-tag {
    background-color: rgba(255, 255, 255, 0.2);
    color: white;
    padding: 3px 8px;
    border-radius: var(--border-radius-videos);
    font-size: 0.75em;
    display: inline-block;
    margin-bottom: 10px;
}

.subscribe-bar-btn {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background-color: var(--video-accent-color);
    color: white;
    width: 100%;
    padding: 12px 15px;
    border: none;
    border-radius: var(--border-radius-videos);
    font-size: 1em;
    font-weight: 600;
    cursor: pointer;
    margin-top: 10px;
}

.subscribe-bar-btn i {
    font-size: 1.1em;
}

.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: calc(60px + env(safe-area-inset-bottom));
    padding-bottom: env(safe-area-inset-bottom);
    background-color: #ffffff;
    display: flex;
    justify-content: space-around;
    align-items: center;
    border-top: 1px solid #e6e6e6;
    z-index: 100;
    direction: ltr;
}

.bottom-nav .nav-item {
    color: #707070;
    text-align: center;
    flex-grow: 1;
    padding: 6px 0;
    text-decoration: none;
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    transition: opacity 0.2s, color 0.2s;
}

.bottom-nav .nav-item i {
    font-size: 1.7rem;
    display: block;
    line-height: 1;
}

.bottom-nav .nav-item.active,
.bottom-nav .nav-item:not(.upload-nav-btn):hover {
    color: #007bff;
}

.bottom-nav .nav-item .notification-badge {
    position: absolute;
    top: 2px;
    right: calc(50% - 15px);
    background-color: var(--danger-color-auth);
    color: white;
    font-size: 0.7em;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.bottom-nav .upload-nav-btn {
    width: 54px;
    height: 36px;
    min-width: 54px;
    padding: 0 !important;
    margin: 0 4px;
    flex-grow: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
    background: #ffffff;
    position: relative;
    isolation: isolate;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.45);
}

.bottom-nav .upload-nav-btn::before,
.bottom-nav .upload-nav-btn::after {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: 12px;
    z-index: -1;
}

.bottom-nav .upload-nav-btn::before {
    background: #25f4ee;
    transform: translateX(-3px);
}

.bottom-nav .upload-nav-btn::after {
    background: #fe2c55;
    transform: translateX(3px);
}

.upload-nav-btn .upload-plus {
    width: 16px;
    height: 16px;
    position: relative;
    display: block;
}

.upload-nav-btn .upload-plus::before,
.upload-nav-btn .upload-plus::after {
    content: "";
    position: absolute;
    background: #111111;
    border-radius: 2px;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

.upload-nav-btn .upload-plus::before {
    width: 14px;
    height: 3px;
}

.upload-nav-btn .upload-plus::after {
    width: 3px;
    height: 14px;
}

.bottom-nav .upload-nav-btn:hover {
    transform: translateY(-1px);
}

.bottom-nav .upload-nav-btn:focus-visible {
    outline: 2px solid #ffffff;
    outline-offset: 3px;
}

.bottom-nav .profile-nav-icon {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
    border: 1px solid #d9d9d9;
}

.bottom-nav .nav-item.active .profile-nav-icon {
    border-color: #007bff;
}

.share-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 1005;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.share-modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.share-modal-sheet {
    position: fixed;
    bottom: -100%;
    left: 0;
    right: 0;
    background-color: var(--video-bottom-nav-bg);
    border-top-left-radius: 15px;
    border-top-right-radius: 15px;
    padding: 10px 0 20px 0;
    max-height: 70vh;
    overflow-y: auto;
    z-index: 1006;
    transition: bottom 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    box-shadow: 0 -5px 20px rgba(0, 0, 0, 0.2);
}

.share-modal-sheet.active {
    bottom: 0;
}

.sheet-header {
    display: flex;
    justify-content: center;
    padding-bottom: 10px;
}

.sheet-handle {
    width: 40px;
    height: 5px;
    background-color: rgba(255, 255, 255, 0.3);
    border-radius: 3px;
}

.sheet-content {
    padding: 0 15px;
}

.sheet-content h4 {
    font-size: 1em;
    margin-bottom: 15px;
    color: var(--video-text-secondary);
}

.send-to-users {
    display: flex;
    gap: 15px;
    overflow-x: auto;
    padding-bottom: 15px;
    margin-bottom: 15px;
    border-bottom: 1px solid #333;
}

.send-to-users::-webkit-scrollbar {
    height: 3px;
}

.send-to-users::-webkit-scrollbar-thumb {
    background: #555;
}

.user-share-item {
    text-align: center;
    min-width: 60px;
}

.user-share-item img {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    margin-bottom: 5px;
}

.user-share-item span {
    font-size: 0.75em;
    display: block;
    color: var(--video-text-secondary);
}

.send-to-more {
    background: none;
    border: 1px solid #555;
    color: var(--video-text-secondary);
    width: 50px;
    height: 50px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2em;
    flex-shrink: 0;
}

.share-via-apps,
.additional-share-options {
    display: flex;
    overflow-x: auto;
    gap: 5px;
    padding: 10px 0;
    margin-bottom: 10px;
    border-bottom: 1px solid #333;
}

.share-via-apps::-webkit-scrollbar,
.additional-share-options::-webkit-scrollbar {
    display: none;
}

.app-share-item,
.option-share-item {
    text-align: center;
    min-width: 70px;
}

.app-icon,
.option-icon {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 5px auto;
    font-size: 1.5em;
    background-color: #333;
}

.app-share-item span,
.option-share-item span {
    font-size: 0.75em;
    display: block;
    color: var(--video-text-secondary);
}

.app-icon.whatsapp {
    background-color: #25d366;
}

.app-icon.telegram {
    background-color: #0088cc;
}

.app-icon.snapchat {
    background-color: #fffc00;
    color: #000;
}

.app-icon.copy-link,
.app-icon.repost {
    background-color: #555;
}

.option-icon {
    background-color: #444;
    font-size: 1.3em;
}

.comments-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.3);
    z-index: 1003;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.comments-modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.comments-modal-sheet {
    position: fixed;
    bottom: -100%;
    left: 0;
    right: 0;
    background-color: #28282b;
    border-top-left-radius: 15px;
    border-top-right-radius: 15px;
    padding-bottom: 0;
    max-height: 65vh;
    overflow: hidden;
    z-index: 1004;
    transition: bottom 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    box-shadow: 0 -5px 20px rgba(0, 0, 0, 0.2);
    display: flex;
    flex-direction: column;
}

.comments-modal-sheet.active {
    bottom: 0;
}

.comments-modal-sheet .sheet-header {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 12px 15px;
    border-bottom: 1px solid #444;
    position: relative;
    flex-shrink: 0;
}

.comments-count-header {
    font-size: 0.95em;
    font-weight: 600;
    color: var(--video-text-secondary);
}

.close-comments-modal-btn {
    position: absolute;
    left: 15px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    font-size: 1.5em;
    color: var(--video-text-secondary);
    cursor: pointer;
}

.close-comments-modal-btn:hover {
    color: var(--video-text-primary);
}

.comments-list-container {
    padding: 15px;
    overflow-y: auto;
    flex-grow: 1;
}

.comment-item {
    display: flex;
    gap: 10px;
    margin-bottom: 18px;
}

.comment-avatar {
    width: 35px;
    height: 35px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}

.comment-body {
    flex-grow: 1;
}

.comment-author-info {
    margin-bottom: 3px;
}

.comment-author-info strong {
    font-size: 0.85em;
    color: var(--video-text-primary);
    font-weight: 600;
    margin-left: 8px;
}

.comment-author-info .comment-timestamp {
    font-size: 0.75em;
    color: #aaa;
}

.comment-text {
    font-size: 0.9em;
    color: var(--video-text-secondary);
    line-height: 1.5;
    margin-bottom: 5px;
    word-break: break-word;
}

.comment-actions {
    display: flex;
    align-items: center;
    gap: 15px;
}

.reply-to-comment-btn,
.like-single-comment-btn {
    background: none;
    border: none;
    color: #aaa;
    font-size: 0.8em;
    cursor: pointer;
    font-family: var(--font-family-videos);
}

.reply-to-comment-btn:hover,
.like-single-comment-btn:hover {
    color: var(--video-text-primary);
}

.like-single-comment-btn i {
    margin-left: 4px;
}

.like-single-comment-btn .fa-heart.liked {
    color: #ff4141;
}

.add-comment-footer {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 15px;
    border-top: 1px solid #444;
    background-color: #28282b;
    flex-shrink: 0;
}

.my-avatar-add-comment {
    width: 30px;
    height: 30px;
    border-radius: 50%;
}

.add-comment-input {
    flex-grow: 1;
    background-color: #3a3a3c;
    border: none;
    border-radius: 18px;
    padding: 8px 15px;
    color: var(--video-text-primary);
    font-size: 0.9em;
    font-family: var(--font-family-videos);
}

.add-comment-input::placeholder {
    color: #8e8e93;
}

.send-comment-btn {
    background: none;
    border: none;
    color: var(--video-accent-color);
    font-size: 1.4em;
    cursor: pointer;
    padding: 5px;
}

.send-comment-btn:hover {
    opacity: 0.8;
}

/* Responsive */
@media (max-width: 360px) {
    .video-tabs .video-tab {
        font-size: 1em;
    }

    .action-btn i {
        font-size: 1.6em;
    }

    .action-btn span {
        font-size: 0.75em;
    }

    .video-author-name {
        font-size: 1em;
    }

    .video-caption {
        font-size: 0.85em;
    }

    .bottom-nav i {
        font-size: 1.3em;
    }

    .bottom-nav .upload-nav-btn {
        width: 50px;
        height: 34px;
        min-width: 50px;
    }

    .send-to-users {
        gap: 10px;
    }

    .user-share-item {
        min-width: 50px;
    }

    .user-share-item img {
        width: 40px;
        height: 40px;
    }

    .app-share-item,
    .option-share-item {
        min-width: 60px;
    }

    .app-icon,
    .option-icon {
        width: 40px;
        height: 40px;
        font-size: 1.2em;
    }
}
