/**
 * AMR Reels Frontend Styles
 * VERSION: 2.0.0
 */

/* ========== Variables ========== */
:root {
    --amr-reels-bg: #000;
    --amr-reels-text: #fff;
    --amr-reels-glass: rgba(0, 0, 0, 0.6);
    --amr-reels-glass-light: rgba(255, 255, 255, 0.15);
    --amr-reels-accent: #fe2c55;
    --amr-reels-success: #25d366;
}

/* ========== Grid View ========== */
.amr-reels-grid {
    display: grid;
    gap: 4px;
    direction: rtl;
}
.amr-reels-grid[data-columns="2"] { grid-template-columns: repeat(2, 1fr); }
.amr-reels-grid[data-columns="3"] { grid-template-columns: repeat(3, 1fr); }
.amr-reels-grid[data-columns="4"] { grid-template-columns: repeat(4, 1fr); }

.amr-reels-item {
    position: relative;
    aspect-ratio: 9/16;
    cursor: pointer;
    overflow: hidden;
    border-radius: 4px;
    background: #1a1a1a;
}

.amr-reels-thumb {
    width: 100%;
    height: 100%;
    position: relative;
}

.amr-reels-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.amr-reels-thumb-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #1a1a1a, #333);
    color: #666;
}

.amr-reels-thumb-placeholder svg {
    width: 40px;
    height: 40px;
}

.amr-reels-play-icon {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 50px;
    height: 50px;
    background: var(--amr-reels-glass);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    opacity: 0;
    transition: opacity 0.2s;
}

.amr-reels-item:hover .amr-reels-play-icon {
    opacity: 1;
}

.amr-reels-play-icon svg {
    width: 24px;
    height: 24px;
    margin-left: 3px;
}

/* ========== Fullscreen Container ========== */
.amr-reels-hidden { display: none !important; }

.amr-reels-fullscreen,
.amr-reels-fullscreen-direct {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--amr-reels-bg);
    z-index: 999999;
    overflow: hidden;
}

/* ========== Video Slider ========== */
.amr-reels-slider {
    width: 100%;
    height: 100%;
    overflow-y: scroll;
    scroll-snap-type: y mandatory;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.amr-reels-slider::-webkit-scrollbar {
    display: none;
}

.amr-reels-slide {
    width: 100%;
    height: 100%;
    scroll-snap-align: start;
    scroll-snap-stop: always;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ========== Video Player ========== */
.amr-reels-video-wrapper {
    width: 100%;
    height: 100%;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #000;
}

.amr-reels-video {
    width: 100%;
    height: 100%;
    object-fit: contain;
    background: #000;
}

/* ========== Top Bar (Mute + Close) ========== */
.amr-reels-top-bar {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    padding: 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 10;
    background: linear-gradient(to bottom, rgba(0,0,0,0.7), transparent);
}

.amr-reels-mute-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    background: var(--amr-reels-glass);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid var(--amr-reels-glass-light);
    border-radius: 24px;
    color: #fff;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
}

.amr-reels-mute-btn:hover {
    background: rgba(255,255,255,0.2);
}

.amr-reels-mute-btn svg {
    width: 20px;
    height: 20px;
}

.amr-reels-close-btn {
    width: 40px;
    height: 40px;
    background: var(--amr-reels-glass);
    backdrop-filter: blur(10px);
    border: 1px solid var(--amr-reels-glass-light);
    border-radius: 50%;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
}

.amr-reels-close-btn:hover {
    background: rgba(255,255,255,0.2);
}

.amr-reels-close-btn svg {
    width: 20px;
    height: 20px;
}

/* ========== Side Actions (Like, Share, Comment, Download) ========== */
.amr-reels-actions {
    position: absolute;
    right: 12px;
    bottom: 120px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    z-index: 10;
}

.amr-reels-action-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    color: #fff;
    cursor: pointer;
    transition: transform 0.2s;
}

.amr-reels-action-btn:active {
    transform: scale(0.9);
}

.amr-reels-action-icon {
    width: 48px;
    height: 48px;
    background: var(--amr-reels-glass);
    backdrop-filter: blur(10px);
    border: 1px solid var(--amr-reels-glass-light);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.amr-reels-action-icon svg {
    width: 24px;
    height: 24px;
}

.amr-reels-action-count {
    font-size: 12px;
    font-weight: 500;
    text-shadow: 0 1px 3px rgba(0,0,0,0.5);
}

/* Like Animation */
.amr-reels-action-btn.liked .amr-reels-action-icon {
    background: var(--amr-reels-accent);
    border-color: var(--amr-reels-accent);
}

.amr-reels-action-btn.liked svg {
    fill: #fff;
}

/* Double-tap Heart Animation */
.amr-reels-heart-animation {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0);
    width: 120px;
    height: 120px;
    color: var(--amr-reels-accent);
    pointer-events: none;
    z-index: 100;
}

.amr-reels-heart-animation.animate {
    animation: heartPop 0.8s ease-out forwards;
}

@keyframes heartPop {
    0% { transform: translate(-50%, -50%) scale(0); opacity: 1; }
    50% { transform: translate(-50%, -50%) scale(1.2); opacity: 1; }
    100% { transform: translate(-50%, -50%) scale(1); opacity: 0; }
}

/* ========== Bottom Info (Title, Description, CTA) ========== */
.amr-reels-info {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 20px 80px 20px 16px;
    background: linear-gradient(to top, rgba(0,0,0,0.8) 0%, rgba(0,0,0,0.4) 60%, transparent 100%);
    z-index: 10;
}

.amr-reels-title {
    font-size: 16px;
    font-weight: 600;
    color: #fff;
    margin-bottom: 8px;
    text-shadow: 0 1px 3px rgba(0,0,0,0.5);
}

.amr-reels-description {
    font-size: 14px;
    color: rgba(255,255,255,0.9);
    line-height: 1.5;
    max-height: 60px;
    overflow: hidden;
    text-shadow: 0 1px 3px rgba(0,0,0,0.5);
}

.amr-reels-cta {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-top: 12px;
    padding: 10px 20px;
    background: #fff;
    color: #000;
    font-size: 14px;
    font-weight: 600;
    border-radius: 8px;
    text-decoration: none;
    transition: all 0.2s;
}

.amr-reels-cta:hover {
    background: rgba(255,255,255,0.9);
    transform: scale(1.02);
}

/* ========== Progress Bar ========== */
.amr-reels-progress {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: rgba(255,255,255,0.3);
    z-index: 20;
}

.amr-reels-progress-bar {
    height: 100%;
    background: #fff;
    width: 0%;
    transition: width 0.1s linear;
}

/* ========== Loading Spinner ========== */
.amr-reels-loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 50px;
    height: 50px;
    border: 3px solid rgba(255,255,255,0.2);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: translate(-50%, -50%) rotate(360deg); }
}

/* ========== Popups ========== */
.amr-reels-popup {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000000;
    padding: 20px;
}

.amr-reels-popup-content {
    background: #fff;
    border-radius: 16px;
    padding: 24px;
    max-width: 360px;
    width: 100%;
    text-align: center;
    direction: rtl;
}

.amr-reels-popup-title {
    font-size: 18px;
    font-weight: 600;
    color: #000;
    margin-bottom: 12px;
}

.amr-reels-popup-text {
    font-size: 14px;
    color: #666;
    margin-bottom: 20px;
    line-height: 1.6;
}

.amr-reels-popup-btn {
    display: block;
    width: 100%;
    padding: 14px;
    border: none;
    border-radius: 10px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    margin-bottom: 10px;
    transition: all 0.2s;
}

.amr-reels-popup-btn.primary {
    background: var(--amr-reels-accent);
    color: #fff;
}

.amr-reels-popup-btn.secondary {
    background: #f0f0f0;
    color: #333;
}

.amr-reels-popup-btn:hover {
    opacity: 0.9;
    transform: scale(1.02);
}

.amr-reels-popup-close {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 30px;
    height: 30px;
    background: rgba(0,0,0,0.5);
    border-radius: 50%;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

/* ========== Share Popup ========== */
.amr-reels-share-options {
    display: flex;
    justify-content: center;
    gap: 16px;
    margin-bottom: 20px;
}

.amr-reels-share-option {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    cursor: pointer;
}

.amr-reels-share-icon {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.amr-reels-share-icon.telegram { background: #0088cc; }
.amr-reels-share-icon.whatsapp { background: #25d366; }
.amr-reels-share-icon.copy { background: #666; }

.amr-reels-share-icon svg {
    width: 24px;
    height: 24px;
    color: #fff;
}

.amr-reels-share-label {
    font-size: 12px;
    color: #666;
}

/* ========== Comments Panel ========== */
/* (base rules overridden by glassmorphism section below) */

/* ========== VPN Warning ========== */
.amr-reels-vpn-warning {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: #ff9800;
    color: #000;
    padding: 12px 20px;
    border-radius: 10px;
    font-size: 14px;
    z-index: 1000002;
    max-width: 90%;
    text-align: center;
    box-shadow: 0 4px 20px rgba(0,0,0,0.3);
}

/* ========== Responsive ========== */
@media (max-width: 768px) {
    .amr-reels-grid[data-columns="3"],
    .amr-reels-grid[data-columns="4"] {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .amr-reels-actions {
        right: 8px;
        bottom: 100px;
        gap: 16px;
    }
    
    .amr-reels-action-icon {
        width: 44px;
        height: 44px;
    }
    
    .amr-reels-info {
        right: 60px;
        padding: 16px 12px;
    }
}

/* ========== Empty State ========== */
.amr-reels-empty {
    text-align: center;
    padding: 40px 20px;
    color: #666;
    font-size: 16px;
}

/* ========== Play/Pause Indicator ========== */
.amr-reels-play-indicator {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0);
    width: 80px;
    height: 80px;
    background: var(--amr-reels-glass);
    backdrop-filter: blur(10px);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    pointer-events: none;
    z-index: 50;
    opacity: 0;
    transition: all 0.2s ease;
}

.amr-reels-play-indicator.show {
    transform: translate(-50%, -50%) scale(1);
    opacity: 1;
}

.amr-reels-play-indicator svg {
    width: 40px;
    height: 40px;
}

/* ========== Share Icons Colors ========== */
.amr-reels-share-icon.rubika { background: #f7931e; }
.amr-reels-share-icon.eitaa { background: #ee7623; }
.amr-reels-share-icon.bale { background: #00a884; }
.amr-reels-share-icon.sms { background: #4caf50; }

/* ========== Share Options Grid ========== */
.amr-reels-share-options {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    margin-bottom: 20px;
}

/* ========== Like Popup Icon ========== */
.amr-reels-popup-icon {
    width: 60px;
    height: 60px;
    margin: 0 auto 16px;
    color: var(--amr-reels-accent);
}

.amr-reels-popup-icon svg {
    width: 100%;
    height: 100%;
}

/* ========== Glassmorphism Comments Panel (Dark - More Transparent) ========== */
.amr-reels-comments-panel {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 60%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(40px);
    -webkit-backdrop-filter: blur(30px);
    border-radius: 20px 20px 0 0;
    z-index: 1000001;
    transform: translateY(100%);
    transition: transform 0.3s ease;
    display: flex;
    flex-direction: column;
    border-top: 1px solid rgba(255, 255, 255, 0.2);
}

.amr-reels-comments-panel.open {
    transform: translateY(0);
}

.amr-reels-comments-header {
    padding: 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 20px 20px 0 0;
}

.amr-reels-comments-title {
    color: #fff;
}

.amr-reels-comments-header .amr-reels-close-btn {
    width: 32px;
    height: 32px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: #fff;
    border: none;
}

.amr-reels-comments-header .amr-reels-close-btn svg {
    width: 18px;
    height: 18px;
}

.amr-reels-comments-list {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    background: transparent;
}

.amr-reels-comment-author {
    color: #fff;
}

.amr-reels-comment-text {
    color: rgba(255, 255, 255, 0.9);
}

.amr-reels-comment-time {
    color: rgba(255, 255, 255, 0.5);
}

.amr-reels-comments-input {
    padding: 12px 16px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    gap: 10px;
    background: rgba(0, 0, 0, 0.3);
}

.amr-reels-comments-input input {
    flex: 1;
    padding: 12px 16px;
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 24px;
    font-size: 16px;
    outline: none;
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    transition: border-color 0.2s, background 0.2s;
}

.amr-reels-comments-input input:focus {
    border-color: rgba(255, 255, 255, 0.35);
    background: rgba(255, 255, 255, 0.12);
}

.amr-reels-comments-input input::placeholder {
    color: rgba(255, 255, 255, 0.4);
}

.amr-reels-comments-input button {
    padding: 12px 20px;
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 24px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    transition: background 0.2s;
}

.amr-reels-comments-input button:hover {
    background: rgba(255, 255, 255, 0.25);
}

/* ========== Comment Items Styling ========== */
.amr-reels-comment {
    margin-bottom: 16px;
    padding: 10px 12px;
    background: rgba(255, 255, 255, 0.06);
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.amr-reels-comment-author {
    font-size: 13px;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.9);
    margin-bottom: 4px;
}

.amr-reels-comment-text {
    font-size: 14px;
    color: rgba(255, 255, 255, 0.8);
    line-height: 1.6;
    direction: rtl;
}

.amr-reels-comment-time {
    font-size: 11px;
    color: rgba(255, 255, 255, 0.35);
    margin-top: 6px;
}

.amr-reels-comment-pending {
    border-color: rgba(255, 255, 255, 0.15);
    opacity: 0.7;
}

.amr-reels-comments-title {
    font-size: 16px;
    font-weight: 600;
}

/* ========== Prevent Safari Zoom on Input Focus ========== */
@supports (-webkit-touch-callout: none) {
    input, textarea, select {
        font-size: 16px !important;
    }
}

/* ========== Loading Fix - Hide when video ready ========== */
.amr-reels-loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 50px;
    height: 50px;
    border: 3px solid rgba(255,255,255,0.2);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    display: none; /* Hidden by default */
}

.amr-reels-slide.loading .amr-reels-loading {
    display: block;
}

/* ========== Popup Close Button Fix ========== */
.amr-reels-popup .amr-close-share-popup {
    margin-top: 10px;
}

/* ========== Actions on RIGHT side ========== */
.amr-reels-actions {
    right: 12px;
    left: auto;
}

.amr-reels-info {
    right: 70px;
    left: 0;
}

@media (max-width: 768px) {
    .amr-reels-info {
        right: 60px;
    }
    
    .amr-reels-actions {
        right: 8px;
    }
    
    .amr-reels-share-options {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* ========== Prevent Body Scroll When Fullscreen ========== */
body.amr-reels-open {
    overflow: hidden !important;
    position: fixed;
    width: 100%;
}

/* ========== Touch Action for Better Mobile Experience ========== */
.amr-reels-video-wrapper {
    touch-action: pan-y;
}

.amr-reels-slider {
    touch-action: pan-y;
    overscroll-behavior: contain;
}
