/**
 * Web Stories CSS
 * Instagram/WhatsApp style story viewer
 */

/* Story Circle Icon (When Closed) */
.story-circle-icon {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 70px;
    height: 70px;
    border-radius: 50%;
    background: linear-gradient(45deg, #f09433 0%, #e6683c 25%, #dc2743 50%, #cc2366 75%, #bc1888 100%);
    padding: 3px;
    cursor: pointer;
    z-index: 9998;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    transition: transform 0.3s ease, bottom 0.3s ease;
    animation: pulse 2s infinite;
}

.story-circle-icon:hover {
    transform: scale(1.1);
}

.story-circle-icon.has-scroll-top {
    bottom: 110px; /* Adjust position when scroll-to-top button is present */
}

.story-circle-inner {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: #fff;
    padding: 3px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.story-circle-inner img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
}

.story-new-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    width: 25px;
    height: 25px;
    background: #ff4444;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 12px;
    font-weight: bold;
    border: 2px solid white;
}

@keyframes pulse {
    0%, 100% {
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    }
    50% {
        box-shadow: 0 4px 20px rgba(240, 148, 51, 0.6);
    }
}

/* Story Modal Overlay */
.story-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.95);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

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

/* Story Container */
.story-container {
    position: relative;
    width: 100%;
    max-width: 500px;
    height: 90vh;
    max-height: 800px;
    background: #000;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
}

/* Progress Bars - DIPERBESAR DAN LEBIH JELAS */
.story-progress-bars {
    position: absolute;
    top: 8px;
    left: 0;
    right: 0;
    display: flex;
    gap: 6px;
    padding: 12px 15px;
    z-index: 20;
    background: linear-gradient(to bottom, rgba(0,0,0,0.6) 0%, rgba(0,0,0,0) 100%);
}

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

.story-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #ffffff 0%, #f0f0f0 100%);
    width: 0%;
    transition: width 0.1s linear;
    box-shadow: 0 0 8px rgba(255, 255, 255, 0.8);
}

/* Story Header - POSISI LEBIH RENDAH AGAR TIDAK KEPOTONG */
.story-header {
    position: absolute;
    top: 55px;
    left: 10px;
    right: 10px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    z-index: 150;
    padding: 0 10px;
    pointer-events: auto;
    touch-action: manipulation;
}

.story-info {
    display: flex;
    align-items: center;
    gap: 10px;
    color: white;
}

.story-logo {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid white;
}

.story-title {
    font-weight: 600;
    font-size: 14px;
}

.story-time {
    font-size: 12px;
    opacity: 0.8;
}

.story-close {
    width: 40px;
    height: 40px;
    background: transparent;
    border: none;
    border-radius: 0;
    color: rgba(255, 255, 255, 0.9);
    font-size: 32px;
    font-weight: bold;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.8);
    line-height: 1;
    position: relative;
    z-index: 200;
    pointer-events: auto;
    touch-action: manipulation;
}

.story-close:hover {
    background: transparent;
    color: rgba(255, 255, 255, 1);
    transform: scale(1.15);
}

/* Story Content */
.story-content {
    width: 100%;
    height: 100%;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #000;
}

.story-media {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: none;
}

.story-media.active {
    display: block;
}

/* Navigation Arrows - SEMBUNYIKAN, gunakan click area saja */
.story-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 50px;
    height: 50px;
    background: transparent;
    border: none;
    border-radius: 0;
    color: transparent;
    font-size: 0;
    cursor: pointer;
    z-index: 10;
    display: none;
    visibility: hidden;
    opacity: 0;
}

.story-nav:hover {
    background: transparent;
}

.story-nav-prev {
    left: 10px;
}

.story-nav-next {
    right: 10px;
}

/* Click areas for navigation */
.story-click-area {
    position: absolute;
    top: 130px; /* Start well below header to avoid covering close button */
    bottom: 0;
    width: 50%;
    z-index: 5;
    cursor: pointer;
}

.story-click-prev {
    left: 0;
}

.story-click-next {
    right: 0;
}

/* Ensure header and its children can receive events */
.story-header,
.story-header * {
    pointer-events: auto !important;
    z-index: 150 !important;
}

/* Responsive Design */
@media (max-width: 768px) {
    .story-container {
        max-width: 100%;
        height: 100vh;
        max-height: none;
        border-radius: 0;
    }
    
    /* PROGRESS BAR LEBIH TEBAL DI MOBILE */
    .story-progress-bars {
        top: 10px;
        padding: 15px 20px;
        gap: 8px;
    }
    
    .story-progress-bar {
        height: 5px;
    }
    
    /* HEADER POSISI LEBIH RENDAH AGAR TIDAK KEPOTONG */
    .story-header {
        top: 65px;
        left: 15px;
        right: 15px;
        padding: 0;
        z-index: 100 !important; /* Ensure header is above everything */
        pointer-events: auto !important; /* Allow interaction with header elements */
    }
    
    .story-logo {
        width: 45px;
        height: 45px;
        border: 3px solid white;
    }
    
    .story-title {
        font-size: 15px;
        font-weight: 700;
    }
    
    .story-time {
        font-size: 13px;
    }
    
    .story-circle-icon {
        width: 60px;
        height: 60px;
        bottom: 20px;
        right: 20px;
    }
    
    .story-circle-icon.has-scroll-top {
        bottom: 90px;
    }
    
    /* SEMBUNYIKAN NAVIGATION ARROWS DI MOBILE - gunakan click area saja */
    .story-nav,
    button.story-nav,
    .story-nav-prev,
    .story-nav-next {
        display: none !important;
        visibility: hidden !important;
        opacity: 0 !important;
    }
    
    /* PASTIKAN CLICK AREAS AKTIF TAPI TIDAK MENUTUPI HEADER */
    .story-click-area {
        display: block !important;
        cursor: pointer !important;
        z-index: 5 !important; /* Lower than header */
        top: 130px !important; /* Start well below header */
    }
    
    /* CLOSE BUTTON - TANPA BACKGROUND, HANYA ICON */
    .story-close,
    button.story-close {
        display: flex !important;
        width: 50px !important;
        height: 50px !important;
        font-size: 42px !important;
        font-weight: bold !important;
        background: transparent !important;
        backdrop-filter: none !important;
        -webkit-backdrop-filter: none !important;
        border: none !important;
        color: rgba(255, 255, 255, 0.9) !important;
        text-shadow: 0 2px 8px rgba(0, 0, 0, 0.8) !important;
        z-index: 200 !important;
        opacity: 1 !important;
        visibility: visible !important;
        line-height: 1 !important;
        pointer-events: auto !important;
        touch-action: manipulation !important;
        -webkit-tap-highlight-color: transparent !important;
    }
    
    .story-close:hover,
    .story-close:active,
    button.story-close:hover,
    button.story-close:active {
        background: transparent !important;
        color: rgba(255, 255, 255, 1) !important;
        transform: scale(1.15);
    }
}

@media (max-width: 480px) {
    /* PROGRESS BAR EXTRA TEBAL DI LAYAR KECIL */
    .story-progress-bars {
        top: 12px;
        padding: 18px 20px;
    }
    
    .story-progress-bar {
        height: 6px;
    }
    
    /* HEADER LEBIH RENDAH LAGI */
    .story-header {
        top: 75px;
    }
    
    .story-logo {
        width: 40px;
        height: 40px;
    }
    
    .story-title {
        font-size: 14px;
    }
    
    .story-time {
        font-size: 12px;
    }
}

/* Loading State */
.story-loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: white;
    font-size: 16px;
}

.story-spinner {
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-top: 3px solid white;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin: 0 auto 10px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Hidden Class */
.story-hidden {
    display: none !important;
}
