/* General reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: "Inter", system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}
.story-box-instance-wrapper button:focus,
.story-box-instance-wrapper .story-item:focus {
    outline: none;
}
.story-box-instance-wrapper {
    max-width: 1200px;
    margin: 1rem auto;
    padding: 0 1rem;
    direction: ltr;
    text-align: left;
    background-color: var(--story-box-bg-color, #fff);
}

.story-box-instance-wrapper.story-box-rtl-enabled {
    direction: rtl;
    text-align: right;
}

.story-box-instance-wrapper .stories-container {
    position: relative;
    padding: 1rem 0;
}

.story-box-instance-wrapper .stories-wrapper {
    display: flex;
    gap: 1rem;
    overflow-x: auto;
    scroll-behavior: smooth;
    padding: 0.5rem;
    scrollbar-width: none;
    -ms-overflow-style: none;
    mask-image: linear-gradient(to right, transparent, black 40px, black calc(100% - 40px), transparent);
    -webkit-mask-image: linear-gradient(to right, transparent, black 40px, black calc(100% - 40px), transparent);
}

.story-box-instance-wrapper.story-box-rtl-enabled .stories-wrapper {
    mask-image: linear-gradient(to left, transparent, black 40px, black calc(100% - 40px), transparent);
    -webkit-mask-image: linear-gradient(to left, transparent, black 40px, black calc(100% - 40px), transparent);
}

.story-box-instance-wrapper .stories-wrapper::-webkit-scrollbar {
    display: none;
}

.story-box-instance-wrapper .story-item {
    flex: 0 0 auto;
    width: 80px;
    text-align: center;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent; /* Removes tap highlight on mobile */
}

.story-box-instance-wrapper .story-title {
    font-size: 14px;
    font-weight: 500;
    color: #333;
    line-height: 1.4;
    height: 2.8em;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
    word-break: break-word;
}

.story-box-instance-wrapper.story-box-rtl-enabled .story-title {
    text-align: right;
}

.story-box-instance-wrapper .story-avatar-container {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    margin-bottom: 0.5rem;
    padding: 3px;
    background: linear-gradient(45deg, #f09433 0%, #e6683c 25%, #dc2743 50%, #cc2366 75%, #bc1888 100%);
}

.story-box-instance-wrapper .story-avatar {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid white;
}

.story-box-instance-wrapper .nav-button {
    position: absolute;
    top: 40px;
    transform: translateY(-50%);
    background: rgba(255, 255, 255, 0.9);
    border: none;
    border-radius: 50%;
    width: 32px;
    height: 32px;
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    z-index: 1;
}

.story-box-instance-wrapper .nav-button-left { left: 0; right: auto; }
.story-box-instance-wrapper .nav-button-right { right: 0; left: auto; }
.story-box-instance-wrapper.story-box-rtl-enabled .nav-button-left { left: auto; right: 0; }
.story-box-instance-wrapper.story-box-rtl-enabled .nav-button-right { right: auto; left: 0; }

.story-box-instance-wrapper .story-viewer-modal {
    display: none; position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.9); z-index: 1000;
    width: 100vw; height: 100vh; max-width: 100vw; max-height: 100vh;
}
.story-box-instance-wrapper .story-viewer-modal.active { display: flex; align-items: center; justify-content: center; }
.story-box-instance-wrapper .story-viewer {
    position: relative; display: flex; align-items: center; justify-content: center; width: 100%; height: 100%;
    perspective: 1200px;
}
.story-box-instance-wrapper .story-thumbnail { position: absolute; width: 180px; height: 300px; cursor: pointer; transition: transform 0.3s ease; opacity: 0.6; z-index: 10; }
.story-box-instance-wrapper .story-thumbnail:hover { opacity: 1; transform: scale(1.05); }
.story-box-instance-wrapper .story-thumbnail img { width: 100%; height: 100%; object-fit: cover; border-radius: 8px; }
.story-box-instance-wrapper .story-thumbnail-prev { left: 10%; right: auto; }
.story-box-instance-wrapper .story-thumbnail-next { right: 10%; left: auto; }
.story-box-instance-wrapper.story-box-rtl-enabled .story-thumbnail-prev { left: auto; right: 10%; }
.story-box-instance-wrapper.story-box-rtl-enabled .story-thumbnail-next { right: auto; left: 10%; }

.story-box-instance-wrapper .story-viewer-content {
    position: relative;
    display: flex;
    width: 100%;
    max-width: 450px;
    max-height: calc(100vh - 70px);
    aspect-ratio: 9 / 16;
    background: #000;
    border-radius: 12px;
    overflow: hidden;
    z-index: 5;
    opacity: 1;
    user-select: none; -webkit-user-select: none; touch-action: pan-y;
    direction: ltr; text-align: left;
    transform: scale(1);
    transition: transform .2s ease-out, opacity .2s ease-out;
    transform-style: preserve-3d;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
}
.story-box-instance-wrapper.story-box-rtl-enabled .story-viewer-content { direction: rtl; text-align: right; }

.story-box-instance-wrapper .story-viewer-content.is-paused {
    transform: scale(0.95);
    opacity: 0.8;
}
.story-box-instance-wrapper .story-viewer-content.is-paused .story-progress-bar,
.story-box-instance-wrapper .story-viewer-content.is-paused .story-viewer-header {
    opacity: 0;
}

.story-box-instance-wrapper .story-viewer-header {
    position: absolute; top: 0; left: 0; right: 0; padding: 25px 20px;
    display: flex; justify-content: space-between; align-items: center; z-index: 1;
    background: linear-gradient(to bottom, rgba(0, 0, 0, 0.5), transparent);
    user-select: none; -webkit-user-select: none;
    transition: opacity .2s ease-out;
}
.story-box-instance-wrapper.story-box-rtl-enabled .story-viewer-header { flex-direction: row-reverse; }
.story-box-instance-wrapper .story-viewer-user-info { display: flex; align-items: center; gap: 1rem; color: white; }
.story-box-instance-wrapper.story-box-rtl-enabled .story-viewer-user-info { flex-direction: row-reverse; }
.story-box-instance-wrapper .story-viewer-avatar { width: 40px; height: 40px; border-radius: 50%; object-fit: cover; }

.story-box-instance-wrapper .story-viewer-title {
    font-size: 1rem;
    font-weight: bold;
    color: #fff;
    max-width: 150px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.story-box-instance-wrapper .story-viewer-close { background: none; border: none; color: white; font-size: 2rem; cursor: pointer; }
.story-box-instance-wrapper .story-viewer-controls { display: flex; align-items: center; gap: 5px; }
.story-box-instance-wrapper.story-box-rtl-enabled .story-viewer-controls { flex-direction: row-reverse; }
.story-box-instance-wrapper .story-control-button { background: none; border: none; color: white; font-size: 1.5rem; cursor: pointer; padding: 0.5rem; transition: opacity 0.2s; padding: 0; }
.story-box-instance-wrapper .story-control-button svg { width: 22px; height: 22px; stroke: white; fill: white; stroke-width: 1.5; }
.story-box-instance-wrapper .story-control-button:hover { opacity: 0.8; }
.story-box-instance-wrapper .story-viewer-controls button { display: flex; align-items: center; justify-content: center; transition: opacity 0.2s; width: 40px; height: 40px; padding: 0; }
.story-box-instance-wrapper .story-viewer-controls button:focus { outline: none; }

.story-box-instance-wrapper .story-progress-bar { position: absolute; top: 10px; left: 20px; right: 20px; display: flex; gap: 4px; z-index: 2; transition: opacity .2s ease-out; }
.story-box-instance-wrapper.story-box-rtl-enabled .story-progress-bar { flex-direction: row-reverse; }
.story-box-instance-wrapper .story-progress { flex: 1; height: 3px; background: rgba(255, 255, 255, 0.3); border-radius: 2px; overflow: hidden; }
.story-box-instance-wrapper .story-progress-inner { height: 100%; width: 0; background: white; }

.story-box-instance-wrapper .story-viewer-footer { position: absolute; bottom: 0; left: 0; right: 0; padding: 20px; background: linear-gradient(to top, rgba(0, 0, 0, 0.7), transparent); z-index: 2; user-select: none; -webkit-user-select: none; }
.story-box-instance-wrapper .story-viewer-footer-content { max-width: 600px; margin: 0 auto; text-align: left; color: white; }
.story-box-instance-wrapper.story-box-rtl-enabled .story-viewer-footer-content { text-align: right; }

.story-box-instance-wrapper .story-viewer-footer-title {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
    font-weight: bold;
    color: #fff;
}

.story-box-instance-wrapper .story-viewer-footer-content p { font-size: 1rem; margin-bottom: 1rem; color: #f0f0f0; }
.story-box-instance-wrapper .story-cta-button { background-color: white; color: black; border: none; padding: 0.8rem 2rem; border-radius: 10px; width: 100%; font-size: 1rem; font-weight: 600; cursor: pointer; transition: transform 0.2s, background-color 0.2s; display: flex; align-items: center; justify-content: center; gap: 1rem; }
.story-box-instance-wrapper.story-box-rtl-enabled .story-cta-button { flex-direction: row-reverse; }
.story-box-instance-wrapper .story-cta-button img { width: 45px; height: 45px; border-radius: 8px; object-fit: cover; }
.story-box-instance-wrapper .story-cta-button:hover { transform: scale(1.05); background-color: #f0f0f0; }

.story-box-instance-wrapper .story-viewer-media { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; background-color: black; overflow: hidden; position: relative; user-select: none; -webkit-user-select: none; pointer-events: none; }
.story-box-instance-wrapper .story-viewer-media img, .story-box-instance-wrapper .story-viewer-media video { width: 100%; height: 100%; object-fit: cover; pointer-events: none; user-drag: none; -webkit-user-drag: none; }

.story-box-instance-wrapper .story-nav-button { position: absolute; top: 50%; transform: translateY(-50%); background: rgba(255, 255, 255, 0.2); border: none; border-radius: 50%; width: 40px; height: 40px; cursor: pointer; display: flex; align-items: center; justify-content: center; color: white; padding: 0; }
.story-box-instance-wrapper .story-nav-button:focus { outline: none; }
.story-box-instance-wrapper .story-nav-prev { left: 1rem; right: auto; }
.story-box-instance-wrapper .story-nav-next { right: 1rem; left: auto; }
.story-box-instance-wrapper.story-box-rtl-enabled .story-nav-prev { left: auto; right: 1rem; }
.story-box-instance-wrapper.story-box-rtl-enabled .story-nav-next { right: auto; left: 1rem; }

@keyframes storyFadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes storyFadeOut { from { opacity: 1; } to { opacity: 0; } }

.story-box-instance-wrapper .slide-in-from-right,
.story-box-instance-wrapper .slide-in-from-left {
    animation: storyFadeIn 0.35s forwards ease-out;
}
.story-box-instance-wrapper .slide-out-left,
.story-box-instance-wrapper .slide-out-right {
    animation: storyFadeOut 0.35s forwards ease-in;
}


@media (max-width: 768px) {
    .story-box-instance-wrapper .stories-wrapper { mask-image: none; -webkit-mask-image: none; }
    .story-box-instance-wrapper .story-item { width: 70px; }
    .story-box-instance-wrapper .story-avatar-container { width: 70px; height: 70px; }
    .story-box-instance-wrapper .story-viewer-content {
        width: 100%;
        height: 100%;
        max-height: 100%;
        border-radius: 0;
        max-width: 100%;
        aspect-ratio: unset;
    }
    .story-box-instance-wrapper .story-thumbnail, .story-box-instance-wrapper .story-nav-button { display: none !important; }
    .story-box-instance-wrapper .story-viewer-modal.active { background: black; max-height: 100% !important;}
    .story-box-instance-wrapper .story-viewer { width: 100%; height: 100%; }
    .story-box-instance-wrapper .story-viewer-media { width: 100%; height: 100%; }
    .story-box-instance-wrapper .story-viewer-header { padding: max(env(safe-area-inset-top), 15px) 15px 15px; }
    .story-box-instance-wrapper .story-viewer-footer { padding: 15px 15px max(env(safe-area-inset-bottom), 15px); }
    .story-box-instance-wrapper .story-viewer-content.is-paused { transform: none; opacity: 1; }

    @keyframes storyCubeOutToLeft {
        from { transform: translateX(0) rotateY(0deg); }
        to { transform: translateX(-50%) rotateY(90deg); }
    }
    @keyframes storyCubeInFromRight {
        from { transform: translateX(50%) rotateY(-90deg); }
        to { transform: translateX(0) rotateY(0deg); }
    }
    @keyframes storyCubeOutToRight {
        from { transform: translateX(0) rotateY(0deg); }
        to { transform: translateX(50%) rotateY(-90deg); }
    }
    @keyframes storyCubeInFromLeft {
        from { transform: translateX(-50%) rotateY(90deg); }
        to { transform: translateX(0) rotateY(0deg); }
    }

    .story-box-instance-wrapper .slide-out-left {
        animation: storyCubeOutToLeft 0.4s forwards ease-in-out;
        transform-origin: center;
    }
    .story-box-instance-wrapper .slide-in-from-right {
        animation: storyCubeInFromRight 0.4s forwards ease-in-out;
        transform-origin: center;
    }
    .story-box-instance-wrapper .slide-out-right {
        animation: storyCubeOutToRight 0.4s forwards ease-in-out;
        transform-origin: center;
    }
    .story-box-instance-wrapper .slide-in-from-left {
        animation: storyCubeInFromLeft 0.4s forwards ease-in-out;
        transform-origin: center;
    }
}

.story-box-instance-wrapper .story-viewer-content.dragging { transition: none; }
.story-box-instance-wrapper .story-viewer-content.closing { opacity: 0; transform: translateY(50%); }
.story-box-instance-wrapper .fade-out { opacity: 0 !important; }
.story-box-instance-wrapper .fade-in { opacity: 1 !important; }

/* Product Modal Styles */
.story-box-instance-wrapper .product-modal-overlay { display: none; position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0, 0, 0, 0.7); z-index: 1050; }
.story-box-instance-wrapper .product-modal-overlay.active { display: block; }
.story-box-instance-wrapper .product-modal { display: none; position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%); background: white; border-radius: 16px; padding: 2rem; width: 90%; max-width: 500px; max-height: 80vh; overflow-y: auto; z-index: 1100; overflow-x: hidden; }
.story-box-instance-wrapper .product-modal.active { display: block; }
.story-box-instance-wrapper .product-modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1.5rem; }
.story-box-instance-wrapper .product-modal-title { font-size: 1.5rem; font-weight: bold; color: #333; }
.story-box-instance-wrapper .product-modal-close { background: none; border: none; font-size: 1.5rem; cursor: pointer; color: #666; }
.story-box-instance-wrapper .product-modal-image { width: 100%; height: 300px; object-fit: cover; border-radius: 12px; margin-bottom: 1.5rem; }
.story-box-instance-wrapper .product-modal-price { font-size: 1.5rem; font-weight: bold; color: #333; margin-bottom: 1rem; }
.story-box-instance-wrapper .product-modal-price * { font-size: inherit; color: inherit; }
.story-box-instance-wrapper .product-modal-description { color: #666; line-height: 1.6; margin-bottom: 1.5rem; }
.story-box-instance-wrapper .product-modal-button { background-color: #000; color: white; border: none; padding: 1rem 2rem; border-radius: 10px; width: 100%; font-size: 1rem; font-weight: 600; cursor: pointer; transition: transform 0.2s, background-color 0.2s; }
.story-box-instance-wrapper .product-modal-button:hover { transform: scale(1.05); background-color: #333; }

@keyframes loading {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

.story-box-instance-wrapper .story-item.skeleton .story-avatar-container {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: loading 1.5s infinite;
    padding: 0;
}

.story-box-instance-wrapper .story-item.skeleton .story-avatar-container > * {
    visibility: hidden;
}

.story-box-instance-wrapper .story-item.skeleton .story-title {
    width: 90%;
    margin: 0 auto;
    -webkit-line-clamp: unset;
}

.story-box-instance-wrapper .story-item.skeleton .story-title::before,
.story-box-instance-wrapper .story-item.skeleton .story-title::after {
    content: '';
    display: block;
    height: 14px;
    border-radius: 4px;
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: loading 1.5s infinite;
}

.story-box-instance-wrapper .story-item.skeleton .story-title::before {
    width: 100%;
    margin-bottom: 8px;
}

.story-box-instance-wrapper .story-item.skeleton .story-title::after {
    width: 60%;
}

.story-box-instance-wrapper .story-viewer-media.skeleton {
    background: linear-gradient(90deg, #222 25%, #333 50%, #222 75%);
    background-size: 200% 100%;
    animation: loading 1.5s infinite;
}
.story-box-instance-wrapper .story-viewer-media.skeleton > * {
    visibility: hidden;
}
