/* ============================================================
   WooCommerce Shoppable Reels – Frontend Styles
   ============================================================ */

:root {
    --wsr-accent:     #e91e63;
    --wsr-accent-dk:  #c2185b;
    --wsr-reel-w:     220px;
    --wsr-reel-h:     390px;
    --wsr-radius:     16px;
    --wsr-shadow:     0 8px 30px rgba(0,0,0,.18);
    --wsr-panel-bg:   rgba(20,20,20,.92);
    --wsr-text:       #fff;
    --wsr-overlay-bg: linear-gradient(to top, rgba(0,0,0,.7) 30%, transparent 70%);
    --wsr-transition: .25s ease;
}

/* ── Widget wrapper ─────────────────────────────────────── */
.wsr-widget { margin: 30px 0; }
.wsr-widget-title {
    font-size: 20px;
    font-weight: 700;
    margin-bottom: 16px;
    color: #222;
}

/* ── Reel item (shared) ──────────────────────────────────── */
.wsr-reel-item {
    position: relative;
    width: var(--wsr-reel-w);
    min-width: var(--wsr-reel-w);
    border-radius: var(--wsr-radius);
    overflow: hidden;
    box-shadow: var(--wsr-shadow);
    background: #000;
    flex-shrink: 0;
    cursor: pointer;
    transition: transform var(--wsr-transition), box-shadow var(--wsr-transition);
}
.wsr-reel-item:hover { transform: translateY(-4px); box-shadow: 0 16px 40px rgba(0,0,0,.26); }

/* ── Video wrapper ───────────────────────────────────────── */
.wsr-video-wrapper {
    position: relative;
    width: 100%;
    height: var(--wsr-reel-h);
    overflow: hidden;
    background: #111;
}
.wsr-video, .wsr-video-iframe {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
.wsr-video-iframe { border: none; }

/* ── Overlay ─────────────────────────────────────────────── */
.wsr-video-overlay {
    position: absolute;
    inset: 0;
    background: var(--wsr-overlay-bg);
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    align-items: flex-start;
    padding: 14px;
    opacity: 0;
    transition: opacity var(--wsr-transition);
}
.wsr-reel-item:hover .wsr-video-overlay,
.wsr-reel-item.wsr-active .wsr-video-overlay { opacity: 1; }

.wsr-play-pause, .wsr-mute-toggle {
    position: absolute;
    top: 12px;
    background: rgba(0,0,0,.45);
    border: none;
    color: #fff;
    width: 34px; height: 34px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 14px;
    display: flex; align-items: center; justify-content: center;
    transition: background var(--wsr-transition);
}
.wsr-play-pause { right: 12px; }
.wsr-mute-toggle { right: 54px; }
.wsr-play-pause:hover, .wsr-mute-toggle:hover { background: var(--wsr-accent); }

.wsr-reel-title {
    font-size: 14px;
    font-weight: 600;
    color: #fff;
    text-shadow: 0 1px 4px rgba(0,0,0,.7);
    margin-bottom: 8px;
    line-height: 1.3;
}

.wsr-shop-btn {
    background: var(--wsr-accent);
    color: #fff;
    border: none;
    padding: 7px 14px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: background var(--wsr-transition), transform var(--wsr-transition);
    white-space: nowrap;
}
.wsr-shop-btn:hover { background: var(--wsr-accent-dk); transform: scale(1.04); }

/* ── Product panel ───────────────────────────────────────── */
.wsr-product-panel {
    background: var(--wsr-panel-bg);
    backdrop-filter: blur(10px);
    padding: 12px;
    display: none;
    flex-direction: column;
    gap: 8px;
    border-radius: 0 0 var(--wsr-radius) var(--wsr-radius);
}
.wsr-product-panel.wsr-panel-open { display: flex; }

.wsr-product-card {
    display: flex;
    align-items: center;
    gap: 10px;
    background: rgba(255,255,255,.08);
    border-radius: 10px;
    padding: 8px;
    transition: background var(--wsr-transition);
}
.wsr-product-card:hover { background: rgba(255,255,255,.14); }
.wsr-product-card img { width: 44px; height: 44px; object-fit: cover; border-radius: 6px; flex-shrink: 0; }

.wsr-product-info { flex: 1; min-width: 0; }
.wsr-product-name {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: #fff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.wsr-product-price { font-size: 11px; color: var(--wsr-accent); font-weight: 700; }

.wsr-add-to-cart {
    background: var(--wsr-accent) !important;
    color: #fff !important;
    border: none !important;
    padding: 6px 12px !important;
    border-radius: 20px !important;
    font-size: 11px !important;
    font-weight: 700 !important;
    cursor: pointer !important;
    white-space: nowrap;
    flex-shrink: 0;
    transition: background var(--wsr-transition), transform var(--wsr-transition) !important;
}
.wsr-add-to-cart:hover { background: var(--wsr-accent-dk) !important; transform: scale(1.05); }
.wsr-add-to-cart.wsr-added { background: #4caf50 !important; }

/* ── Toast notification ──────────────────────────────────── */
.wsr-toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: #222;
    color: #fff;
    padding: 12px 24px;
    border-radius: 30px;
    font-size: 14px;
    font-weight: 500;
    z-index: 99999;
    opacity: 0;
    transition: opacity .3s, transform .3s;
    pointer-events: none;
    white-space: nowrap;
}
.wsr-toast.wsr-toast-visible { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ── CAROUSEL ────────────────────────────────────────────── */
.wsr-carousel { position: relative; }
.wsr-carousel-track {
    display: flex;
    gap: 16px;
    overflow-x: auto;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
    padding: 10px 4px 16px;
    scrollbar-width: none;
}
.wsr-carousel-track::-webkit-scrollbar { display: none; }

.wsr-arrow {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 10;
    background: #fff;
    border: none;
    width: 40px; height: 40px;
    border-radius: 50%;
    box-shadow: 0 3px 12px rgba(0,0,0,.18);
    font-size: 22px;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: background var(--wsr-transition), box-shadow var(--wsr-transition);
}
.wsr-arrow:hover { background: var(--wsr-accent); color: #fff; }
.wsr-prev { left: -20px; }
.wsr-next { right: -20px; }

/* ── GRID ────────────────────────────────────────────────── */
.wsr-grid {
    display: grid;
    grid-template-columns: repeat(var(--wsr-cols, 3), var(--wsr-reel-w));
    gap: 16px;
    justify-content: center;
}

/* ── STACKED (TikTok-style) ──────────────────────────────── */
.wsr-stacked { display: flex; flex-direction: column; gap: 24px; align-items: center; }
.wsr-stacked-item { width: min(var(--wsr-reel-w), 90vw); }
.wsr-stacked-item .wsr-video-wrapper { height: 500px; }

/* ── STORIES BUBBLES ─────────────────────────────────────── */
.wsr-stories-bubbles {
    display: flex;
    gap: 16px;
    overflow-x: auto;
    padding: 8px 4px 16px;
    scrollbar-width: none;
}
.wsr-stories-bubbles::-webkit-scrollbar { display: none; }

.wsr-story-bubble {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    flex-shrink: 0;
}
.wsr-story-ring {
    width: 72px; height: 72px;
    border-radius: 50%;
    padding: 3px;
    background: linear-gradient(135deg, var(--wsr-accent), #ff9800, #ffeb3b);
    transition: transform var(--wsr-transition);
}
.wsr-story-ring:hover { transform: scale(1.08); }
.wsr-story-ring img {
    width: 100%; height: 100%;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid #fff;
    display: block;
}
.wsr-story-label { font-size: 11px; color: #444; text-align: center; max-width: 72px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ── STORIES LIGHTBOX ────────────────────────────────────── */
.wsr-stories-lightbox { position: fixed; inset: 0; z-index: 99990; display: flex; align-items: center; justify-content: center; }
.wsr-stories-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,.85); }
.wsr-stories-player {
    position: relative;
    z-index: 1;
    width: min(360px, 92vw);
    border-radius: var(--wsr-radius);
    overflow: hidden;
    background: #000;
    box-shadow: 0 20px 60px rgba(0,0,0,.6);
}

.wsr-stories-progress {
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 3px;
    background: rgba(255,255,255,.35);
    z-index: 10;
}
.wsr-stories-progress-bar {
    height: 100%;
    background: #fff;
    transition: width linear;
}

.wsr-stories-close {
    position: absolute;
    top: 14px; right: 14px;
    z-index: 20;
    background: rgba(0,0,0,.5);
    border: none;
    color: #fff;
    width: 36px; height: 36px;
    border-radius: 50%;
    font-size: 20px;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: background var(--wsr-transition);
}
.wsr-stories-close:hover { background: var(--wsr-accent); }

.wsr-story-slide video, .wsr-story-slide iframe {
    width: 100%;
    height: 520px;
    object-fit: cover;
    display: block;
}

.wsr-stories-nav {
    position: absolute;
    top: 50%; transform: translateY(-50%);
    background: rgba(255,255,255,.2);
    border: none;
    color: #fff;
    font-size: 28px;
    width: 44px; height: 44px;
    border-radius: 50%;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: background var(--wsr-transition);
    z-index: 20;
}
.wsr-stories-nav:hover { background: var(--wsr-accent); }
.wsr-stories-prev { left: 10px; }
.wsr-stories-next { right: 10px; }

/* ── POPUP ───────────────────────────────────────────────── */
.wsr-popup-widget { position: fixed; inset: 0; z-index: 99980; display: flex; align-items: center; justify-content: center; }
.wsr-popup-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,.7); }
.wsr-popup-container {
    position: relative;
    z-index: 1;
    background: #fff;
    border-radius: var(--wsr-radius);
    overflow: hidden;
    max-width: 92vw;
    box-shadow: var(--wsr-shadow);
}
.wsr-popup-close {
    position: absolute;
    top: 12px; right: 12px;
    z-index: 10;
    background: rgba(0,0,0,.5);
    border: none; color: #fff;
    width: 34px; height: 34px;
    border-radius: 50%;
    font-size: 20px;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
}
.wsr-popup-close:hover { background: var(--wsr-accent); }
.wsr-popup-track { display: flex; gap: 0; }
.wsr-popup-reel { width: min(300px, 88vw); min-width: unset; }
.wsr-popup-reel .wsr-video-wrapper { height: 500px; }

/* ── Product-page auto-inject ────────────────────────────── */
.wsr-product-reels-section { margin: 24px 0; }
.wsr-product-reels-title { font-size: 18px; font-weight: 700; margin-bottom: 14px; }

/* ── Empty state ─────────────────────────────────────────── */
.wsr-empty { color: #888; font-style: italic; }
.wsr-no-video { background: #111; color: #666; height: 200px; display: flex; align-items: center; justify-content: center; font-size: 13px; }

/* ── Responsive ──────────────────────────────────────────── */
@media (max-width: 768px) {
    :root { --wsr-reel-w: 180px; --wsr-reel-h: 320px; }
    .wsr-grid { grid-template-columns: repeat(2, var(--wsr-reel-w)); }
    .wsr-arrow { display: none; }
}
@media (max-width: 480px) {
    :root { --wsr-reel-w: 155px; --wsr-reel-h: 275px; }
}
