/**
 * Shoppable Reels — Frontend Styles
 * TikTok/Instagram-style vertical reel player with shoppable product overlays.
 *
 * @import Google Fonts: Inter
 */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

/* =========================================================
   CSS Custom Properties
   ========================================================= */
:root {
    --sr-pin-color:      #ffffff;
    --sr-primary:        #7c3aed;
    --sr-primary-dark:   #5b21b6;
    --sr-accent:         #f59e0b;
    --sr-success:        #10b981;
    --sr-danger:         #ef4444;
    --sr-dark:           #0f0f0f;
    --sr-dark-glass:     rgba(15,15,15,.7);
    --sr-font:           'Inter', sans-serif;
    --sr-radius-sm:      8px;
    --sr-radius:         14px;
    --sr-radius-lg:      20px;
    --sr-transition:     .3s cubic-bezier(.4,0,.2,1);
    --sr-shadow:         0 4px 24px rgba(0,0,0,.25);
    --sr-shadow-xl:      0 20px 60px rgba(0,0,0,.4);
}

/* =========================================================
   Wrapper Layouts
   ========================================================= */

/* --- Carousel --- */
.sr-reels-wrapper {
    font-family: var(--sr-font);
    box-sizing: border-box;
    position: relative;
    width: 100%;
}

.sr-layout-carousel {
    overflow: hidden;
    border-radius: var(--sr-radius-lg);
}

.sr-carousel-track {
    display: flex;
    gap: 16px;
    transition: transform var(--sr-transition);
    will-change: transform;
}

.sr-carousel-prev,
.sr-carousel-next {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 20;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: none;
    background: rgba(255,255,255,.9);
    color: #111;
    font-size: 24px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--sr-shadow);
    transition: all .2s;
    backdrop-filter: blur(6px);
}

.sr-carousel-prev { left: -16px; }
.sr-carousel-next { right: -16px; }

.sr-carousel-prev:hover,
.sr-carousel-next:hover {
    background: var(--sr-primary);
    color: #fff;
    transform: translateY(-50%) scale(1.1);
}

/* --- Grid --- */
.sr-layout-grid .sr-carousel-track {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 16px;
    transition: none;
}

/* --- Single --- */
.sr-layout-single .sr-carousel-track {
    justify-content: center;
}

/* =========================================================
   Reel Card
   ========================================================= */
.sr-reel-card {
    position: relative;
    flex-shrink: 0;
    width: 300px;
    border-radius: var(--sr-radius-lg);
    overflow: hidden;
    background: var(--sr-dark);
    box-shadow: var(--sr-shadow);
    transition: transform var(--sr-transition), box-shadow var(--sr-transition);
    user-select: none;
}

.sr-reel-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--sr-shadow-xl);
}

/* =========================================================
   Video Container
   ========================================================= */
.sr-video-container {
    position: relative;
    aspect-ratio: 9/16;
    overflow: hidden;
    background: #000;
}

.sr-video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* =========================================================
   Embed Container
   ========================================================= */
.sr-embed-container {
    width: 100%;
    height: 100%;
}

.sr-embed-placeholder {
    width: 100%;
    height: 100%;
    background-size: cover;
    background-position: center;
    background-color: #000;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.sr-embed-play-btn {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: rgba(255,255,255,.9);
    border: none;
    font-size: 24px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all .2s;
    color: #000;
    backdrop-filter: blur(6px);
}

.sr-embed-play-btn:hover {
    background: var(--sr-primary);
    color: #fff;
    transform: scale(1.1);
}

.sr-embed-container iframe {
    width: 100%;
    height: 100%;
    border: none;
}

/* =========================================================
   No Video State
   ========================================================= */
.sr-no-video {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: #555;
    gap: 12px;
}

.sr-no-video .dashicons {
    font-size: 48px;
    width: 48px;
    height: 48px;
}

/* =========================================================
   Video Controls Overlay
   ========================================================= */
.sr-controls {
    position: absolute;
    bottom: 16px;
    left: 12px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    z-index: 10;
    opacity: 0;
    transition: opacity var(--sr-transition);
}

.sr-video-container:hover .sr-controls {
    opacity: 1;
}

.sr-play-pause-btn,
.sr-mute-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--sr-dark-glass);
    border: 1px solid rgba(255,255,255,.2);
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all .2s;
    backdrop-filter: blur(8px);
    padding: 0;
}

.sr-play-pause-btn:hover,
.sr-mute-btn:hover {
    background: rgba(255,255,255,.2);
    transform: scale(1.1);
}

.sr-play-pause-btn svg,
.sr-mute-btn svg {
    width: 18px;
    height: 18px;
    fill: #fff;
    flex-shrink: 0;
}

/* =========================================================
   Reel Title
   ========================================================= */
.sr-reel-title {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 40px 16px 16px;
    background: linear-gradient(to top, rgba(0,0,0,.8) 0%, transparent 100%);
    color: #fff;
    font-size: 14px;
    font-weight: 600;
    font-family: var(--sr-font);
    z-index: 5;
}

/* =========================================================
   Product Pin Overlays
   ========================================================= */
.sr-pin {
    position: absolute;
    transform: translate(-50%, -50%);
    z-index: 15;
    cursor: pointer;
    background: none;
    border: none;
    padding: 0;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.sr-pin-dot {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--sr-pin-color);
    border: 2px solid rgba(255,255,255,.9);
    box-shadow: 0 2px 8px rgba(0,0,0,.4);
    position: relative;
    z-index: 2;
    transition: transform .2s;
}

.sr-pin-ring {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    background: rgba(255,255,255,.25);
    animation: sr-ping 2s cubic-bezier(0,0,.2,1) infinite;
}

@keyframes sr-ping {
    75%, 100% {
        transform: scale(2.5);
        opacity: 0;
    }
}

.sr-pin:hover .sr-pin-dot {
    transform: scale(1.4);
    background: var(--sr-primary);
}

.sr-pin:hover .sr-pin-ring {
    animation-play-state: paused;
}

/* =========================================================
   Product Panel (slides up from bottom)
   ========================================================= */
.sr-product-panel {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(15,15,15,.92);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-top-left-radius: var(--sr-radius-lg);
    border-top-right-radius: var(--sr-radius-lg);
    border-top: 1px solid rgba(255,255,255,.1);
    transform: translateY(100%);
    transition: transform var(--sr-transition);
    z-index: 20;
    max-height: 70%;
    display: flex;
    flex-direction: column;
}

.sr-product-panel.is-open {
    transform: translateY(0);
}

.sr-panel-handle {
    width: 36px;
    height: 4px;
    background: rgba(255,255,255,.3);
    border-radius: 2px;
    margin: 10px auto 0;
    flex-shrink: 0;
}

.sr-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    flex-shrink: 0;
}

.sr-panel-title {
    color: #fff;
    font-size: 14px;
    font-weight: 600;
    font-family: var(--sr-font);
    margin: 0;
}

.sr-panel-close {
    background: rgba(255,255,255,.1);
    border: none;
    border-radius: 50%;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: #fff;
    padding: 0;
    transition: background .2s;
}

.sr-panel-close:hover {
    background: rgba(255,255,255,.2);
}

.sr-panel-close svg {
    width: 16px;
    height: 16px;
    fill: #fff;
}

.sr-panel-products {
    overflow-y: auto;
    padding: 8px 12px 16px;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* =========================================================
   Product Card in Panel
   ========================================================= */
.sr-product-card {
    display: flex;
    align-items: center;
    gap: 12px;
    background: rgba(255,255,255,.07);
    border: 1px solid rgba(255,255,255,.1);
    border-radius: var(--sr-radius-sm);
    padding: 10px 12px;
    transition: all .2s;
}

.sr-product-card:hover {
    background: rgba(255,255,255,.12);
    border-color: rgba(255,255,255,.25);
}

.sr-product-card-image {
    width: 56px;
    height: 56px;
    border-radius: var(--sr-radius-sm);
    object-fit: cover;
    background: rgba(255,255,255,.1);
    flex-shrink: 0;
}

.sr-product-card-image-placeholder {
    width: 56px;
    height: 56px;
    border-radius: var(--sr-radius-sm);
    background: rgba(255,255,255,.1);
    display: flex;
    align-items: center;
    justify-content: center;
    color: rgba(255,255,255,.4);
    flex-shrink: 0;
    font-size: 20px;
}

.sr-product-card-info {
    flex: 1;
    min-width: 0;
}

.sr-product-card-name {
    color: #fff;
    font-size: 13px;
    font-weight: 600;
    font-family: var(--sr-font);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 3px;
}

.sr-product-card-price {
    color: var(--sr-accent);
    font-size: 13px;
    font-weight: 700;
    font-family: var(--sr-font);
}

.sr-product-card-price del {
    color: rgba(255,255,255,.4);
    font-weight: 400;
    margin-right: 4px;
    font-size: 11px;
}

.sr-product-card-actions {
    display: flex;
    flex-direction: column;
    gap: 6px;
    flex-shrink: 0;
}

/* =========================================================
   CTA / Add to Cart Button
   ========================================================= */
.sr-btn-cart {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 7px 14px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    font-family: var(--sr-font);
    cursor: pointer;
    border: none;
    transition: all .2s;
    white-space: nowrap;
    text-decoration: none;
    outline: none;
    min-width: 90px;
}

.sr-btn-cart-primary {
    background: linear-gradient(135deg, var(--sr-primary) 0%, var(--sr-primary-dark) 100%);
    color: #fff;
    box-shadow: 0 2px 8px rgba(124,58,237,.4);
}

.sr-btn-cart-primary:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 4px 16px rgba(124,58,237,.5);
}

.sr-btn-cart-primary:disabled {
    opacity: .6;
    cursor: not-allowed;
    transform: none;
}

.sr-btn-cart-primary.is-loading {
    pointer-events: none;
}

.sr-btn-cart-primary.is-success {
    background: linear-gradient(135deg, var(--sr-success) 0%, #059669 100%);
    box-shadow: 0 2px 8px rgba(16,185,129,.4);
}

.sr-btn-cart-secondary {
    background: rgba(255,255,255,.1);
    color: #fff;
    border: 1px solid rgba(255,255,255,.2);
}

.sr-btn-cart-secondary:hover {
    background: rgba(255,255,255,.2);
}

.sr-btn-out-of-stock {
    background: rgba(239,68,68,.15);
    color: var(--sr-danger);
    border: 1px solid rgba(239,68,68,.3);
    cursor: not-allowed;
    font-size: 11px;
    padding: 6px 10px;
}

/* =========================================================
   Toast Notification
   ========================================================= */
.sr-toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(80px);
    background: #111;
    color: #fff;
    font-family: var(--sr-font);
    font-size: 14px;
    font-weight: 500;
    padding: 12px 20px;
    border-radius: 30px;
    box-shadow: var(--sr-shadow);
    z-index: 99999;
    transition: transform .4s cubic-bezier(.34,1.56,.64,1);
    white-space: nowrap;
    pointer-events: none;
    display: flex;
    align-items: center;
    gap: 8px;
}

.sr-toast.is-visible {
    transform: translateX(-50%) translateY(0);
}

.sr-toast-success::before { content: '✓'; color: var(--sr-success); }
.sr-toast-error::before   { content: '✕'; color: var(--sr-danger); }

/* =========================================================
   No Reels
   ========================================================= */
.sr-no-reels {
    font-family: var(--sr-font);
    color: #888;
    text-align: center;
    padding: 32px;
    font-size: 14px;
}

/* =========================================================
   Responsive
   ========================================================= */
@media (max-width: 600px) {
    .sr-reel-card { width: 85vw; }
    .sr-carousel-prev { left: -8px; }
    .sr-carousel-next { right: -8px; }
}

@media (max-width: 400px) {
    .sr-reel-card { width: 92vw; }
}
