/* ==========================================
   SELEPOWER STORIES ENGINE - CSS BASE
   ========================================== */

/* Bloqueio de Scroll do Body quando Modal aberto */
body.story-modal-open {
    overflow: hidden !important;
    touch-action: none;
}

/* Base de Cor Instagram e Lido/Não-Lido para a HUD */
.story-ring {
    background: linear-gradient(45deg, #facc15, #f43f5e, #c026d3); /* Rainbow IG Fiel */
    padding: 3px; /* Espessura do Arco-íris */
}
.story-ring.sp-story-read {
    background: linear-gradient(45deg, #d1d5db, #9ca3af); /* Cinza Escuro pra destacar do fundo branco */
}
.dark .story-ring.sp-story-read {
    background: linear-gradient(45deg, #4b5563, #374151); /* Cinza Noturno Tailwind Dark mais forte */
}

/* O fundo branco que isola o anel da foto */
.story-ring-inner {
    background-color: #ffffff;
    padding: 3px; /* Distância entre o arco-íris e a imagem principal */
    border-radius: 50%;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}
.dark .story-ring-inner {
    background-color: #111827; /* Fundo escuro do site */
}

/* Deixa o Avatar em Escala de Cinza se o Story já foi visto totalmente */
.story-bubble-btn.sp-story-read-btn img {
    filter: grayscale(100%) opacity(0.7);
    transition: filter 0.3s ease;
}
/* Se houver hover ou active nela, pode recuperar um teco de cor... opcional */
.story-bubble-btn.sp-story-read-btn:hover img {
    filter: grayscale(50%) opacity(0.9);
}

/* O Modal Principal (Backdrop imersivo Escuro) */
.sp-story-modal {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    z-index: 99999;
    background-color: #0f1115; /* Escuro moderno profundo */
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.sp-story-modal.active {
    opacity: 1;
    visibility: visible;
}

/* Container do Slide (Proporção de Celular - 9:16 approx) */
.sp-story-container {
    position: relative;
    width: 100%;
    height: 100%;
    max-width: 450px; /* Limite em telas gigantes (ex: Desktop) */
    background-color: #1a1d24;
    overflow: hidden;
    box-shadow: 0 0 40px rgba(0,0,0,0.5);
    display: flex;
    flex-direction: column;
}

/* Header Flutuante do Story (Sempre no topo) */
.sp-story-header {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    padding: 12px 16px;
    z-index: 50;
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: linear-gradient(to bottom, rgba(0,0,0,0.6) 0%, rgba(0,0,0,0) 100%);
}

/* Conjunto das Barrinhas de Tempo (Progress Bars) */
.sp-story-progress-wrapper {
    display: flex;
    gap: 4px;
    width: 100%;
}

.sp-story-progress-bar {
    flex: 1;
    height: 3px;
    background-color: rgba(255, 255, 255, 0.3);
    border-radius: 4px;
    overflow: hidden;
}

.sp-story-progress-fill {
    height: 100%;
    width: 0%;
    background-color: #ffffff;
    border-radius: 4px;
    /* A animação real da largura de 0 a 100% será injetada via JS dependendo da duração (ex: 5s) */
}

/* Identificação da Loja Flutuante */
.sp-story-info {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.sp-story-store-brand {
    display: flex;
    align-items: center;
    gap: 8px;
}

.sp-story-store-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 1px solid rgba(255,255,255,0.2);
    background: #fff;
    object-fit: contain;
}

.sp-story-store-name {
    color: #fff;
    font-weight: 700;
    font-size: 14px;
    text-shadow: 0 1px 2px rgba(0,0,0,0.5);
    font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

.sp-story-close-btn {
    color: #fff;
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
    opacity: 0.8;
    transition: opacity 0.2s;
    outline: none;
}
.sp-story-close-btn:hover { opacity: 1; }

/* Zonas Transparentes de Clique (Navegação Esquerda/Direita) */
.sp-story-touch-left,
.sp-story-touch-right {
    position: absolute;
    top: 50px;
    bottom: 80px; /* Deixa rodapé livre pro botão CTA */
    z-index: 40;
}

.sp-story-touch-left {
    left: 0;
    width: 35%; /* O clique na esquerda retrocede o slide */
}

.sp-story-touch-right {
    right: 0;
    width: 65%; /* Área maior para avançar naturalmente com o polegar */
}

/* 
   ==========================================
   TEMPLATES DINÂMICOS - MÍDIA (OFERTA / CUPOM)
   ========================================== 
*/

.sp-story-media-layer {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    z-index: 10;
    background-size: cover;
    background-position: center;
    background-color: #111;
}

/* Escurecimento sutil pra leitura de Cupons ou Fotos claras */
.sp-story-overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(to bottom, rgba(0,0,0,0.1) 0%, rgba(0,0,0,0.4) 50%, rgba(0,0,0,0.85) 100%);
    z-index: 15;
}

/* O Conteúdo Rico (Textos e Preços centrais) */
.sp-story-content {
    position: absolute;
    top: 75px; /* Espaço para o sp-story-header */
    bottom: 25px; /* Espaço para o rodapé */
    left: 0;
    width: 100%;
    padding: 0 20px;
    z-index: 30;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.sp-story-title {
    color: #fff;
    font-size: 18px;
    font-weight: 800;
    line-height: 1.3;
    text-shadow: 0 2px 4px rgba(0,0,0,0.5);
    display: -webkit-box;
    -webkit-line-clamp: 3;
    line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.sp-story-price-box {
    display: flex;
    flex-direction: column;
}

.sp-story-old-price {
    font-size: 14px;
    color: rgba(255,255,255,0.7);
    text-decoration: line-through;
    font-weight: 500;
}

.sp-story-current-price {
    font-size: 28px;
    font-weight: 900;
    color: #10b981; /* Indigo/Emerald Tailwind vibe */
    text-shadow: 0 2px 5px rgba(0,0,0,0.4);
}

.sp-story-code-badge {
    align-self: flex-start;
    background: rgba(255,255,255,0.15);
    border: 1px dashed rgba(255,255,255,0.4);
    padding: 6px 12px;
    border-radius: 8px;
    color: #fff;
    font-family: monospace;
    font-size: 16px;
    font-weight: bold;
    backdrop-filter: blur(4px);
    letter-spacing: 1px;
}

/* Botão Flutuante Giga Call To Action */
.sp-story-cta-btn {
    width: 100%;
    padding: 16px;
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
    color: #fff;
    font-weight: 800;
    text-align: center;
    border-radius: 12px;
    text-transform: uppercase;
    font-size: 16px;
    letter-spacing: 0.5px;
    text-decoration: none;
    box-shadow: 0 4px 15px rgba(37, 99, 235, 0.4);
    transition: transform 0.2s, box-shadow 0.2s;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    margin-top: auto; /* Empurra o botão pro bottom violentamente via Flexbox! */
    outline: none;
}

.sp-story-cta-btn:active {
    transform: scale(0.97);
}

.sp-story-center-product {
    width: 100%;
    aspect-ratio: 1 / 1;
    max-height: 48vh;
    background: #fff;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 15px 35px rgba(0,0,0,0.5);
    border: 1px solid rgba(255,255,255,0.1);
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.sp-story-center-product img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    padding: 8px; /* Respirar a imagem igual nos cards do feed */
}

/* Modificador de Embaçamento nativo de Fundo */
.sp-story-bg-blurred {
    filter: blur(25px) brightness(0.6);
}

/* Animações de Transição de Slides (Fade) */
.story-slide-anim-enter {
    animation: storySlideIn 0.3s forwards;
}

@keyframes storySlideIn {
    from { opacity: 0; transform: scale(1.25); }
    to { opacity: 1; transform: scale(1.15); }
}

/* Loader Spinner Center */
.sp-story-loader {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 99;
}
.sp-story-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid rgba(255,255,255,0.2);
    border-top-color: #fff;
    border-radius: 50%;
    animation: sp-spin 1s linear infinite;
}
@keyframes sp-spin { to { transform: rotate(360deg); } }
