/**
 * Cimahi Muncul - Instagram-like Stories CSS
 */

/* Main Container */
.cm-stories-container {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 15px;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    z-index: 999;
}

/* Stories List (Horizontal Scrolling) */
.cm-stories-list {
    display: flex;
    overflow-x: auto;
    padding: 10px 0;
    gap: 15px;
    scrollbar-width: none; /* Firefox */
    -ms-overflow-style: none; /* IE and Edge */
}

.cm-stories-list::-webkit-scrollbar {
    display: none; /* Chrome, Safari, Opera */
}

.cm-story-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    cursor: pointer;
    min-width: 80px;
}

.cm-story-avatar {
    width: 70px;
    height: 70px;
    border-radius: 50%;
    padding: 3px;
    background: linear-gradient(45deg, #00CCCC, #FFDF00, #00AAFF);
    margin-bottom: 5px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

/* Unseen Ring Style */
.cm-story-avatar.unseen {
    background: linear-gradient(45deg, #00CCCC, #FFDF00, #00AAFF);
}

/* Seen Ring Style */
.cm-story-avatar.seen {
    background: #808080;
}

.cm-story-avatar img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    border: 2px solid #1E1E2E;
    object-fit: cover;
    background-color: #1E1E2E;
}

.cm-story-username {
    font-size: 12px;
    text-align: center;
    max-width: 80px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: #FFDF00;
    font-weight: 500;
}

/* Stories Viewer (Fullscreen) */
.cm-stories-viewer {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 9999;
    display: none;
}

.cm-stories-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.9);
}

.cm-stories-content {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
}

/* Center content for desktop (9:16 ratio) */
@media (min-width: 768px) {
    .cm-stories-content {
        width: 375px; /* Standard mobile width */
        height: 667px; /* Maintain 9:16 ratio */
        max-height: 90vh;
        margin: auto;
        background-color: #000;
        overflow: hidden;
        border-radius: 10px;
    }
}

/* Header */
.cm-stories-header {
    padding: 15px;
    position: relative;
    z-index: 10;
}

.cm-story-progress-container {
    display: flex;
    gap: 5px;
    margin-bottom: 10px;
}

.cm-story-progress {
    flex: 1;
    height: 3px;
    background-color: rgba(255, 255, 255, 0.3);
    border-radius: 3px;
    overflow: hidden;
}

.cm-story-progress-bar {
    height: 100%;
    width: 0;
    background-color: #fff;
    border-radius: 3px;
    transition: width linear;
}

.cm-story-user-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.cm-story-user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    overflow: hidden;
}

.cm-story-user-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.cm-story-user-name {
    color: #fff;
    font-weight: 600;
    flex: 1;
    display: flex;
    align-items: center;
}

.cm-story-user-name a {
    color: #fff;
    text-decoration: none;
    margin-right: 8px;
}

.cm-story-user-views {
    display: flex;
    align-items: center;
    background-color: rgba(255, 255, 255, 0.2);
    border-radius: 12px;
    padding: 2px 8px;
    font-size: 12px;
    color: #fff;
    margin-left: 6px;
}

.cm-story-user-views-icon {
    margin-right: 4px;
    font-size: 11px;
}

.cm-story-timestamp {
    color: rgba(255, 255, 255, 0.7);
    font-size: 12px;
}

.cm-story-close {
    position: absolute;
    top: 15px;
    right: 15px;
    width: 30px;
    height: 30px;
    color: #fff;
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Body */
.cm-stories-body {
    flex: 1;
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.cm-story-image {
    flex: 1;
    background-color: #000;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.cm-story-image img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.cm-story-details {
    position: absolute !important;
    bottom: 0 !important;
    left: 0 !important;
    width: 100% !important;
    padding: 15px !important;
    background: rgba(0, 0, 0, 0.6) !important; 
    color: #fff !important;
    backdrop-filter: blur(2px) !important;
}

.cm-story-quest-title {
    font-weight: 600;
    margin-bottom: 5px;
    font-size: 18px;
}

.cm-story-notes {
    margin-bottom: 10px;
    font-size: 14px;
}

.cm-story-reward {
    display: flex;
    align-items: center;
    gap: 15px;
}

.cm-story-coin-icon {
    font-size: 20px;
}

.cm-story-coin-amount {
    font-weight: 600;
    color: #FFD700;
}

.cm-story-xp {
    font-weight: 600;
    color: #00FFAA;
}

/* Navigation */
.cm-stories-navigation {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
}

.cm-story-prev, .cm-story-next {
    flex: 1;
    height: 100%;
    cursor: pointer;
}

/* Empty State */
.cm-stories-empty {
    text-align: center;
    padding: 20px;
    background-color: #f5f5f5;
    border-radius: 8px;
    color: #777;
}

/* Transition Animation */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.cm-fade-in {
    animation: fadeIn 0.3s ease-in-out;
}

/* Pause Indicator */
.cm-story-paused {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 50px;
    height: 50px;
    background-color: rgba(0, 0, 0, 0.5);
    border-radius: 50%;
    display: none;
    align-items: center;
    justify-content: center;
}

.cm-story-paused::before {
    content: "❙❙";
    color: #fff;
    font-size: 20px;
}

/* Loading Indicator */
.cm-story-loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 40px;
    height: 40px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: #fff;
    animation: spin 1s linear infinite;
    display: none;
}

@keyframes spin {
    to { transform: translate(-50%, -50%) rotate(360deg); }
}

/* View Count - Now moved next to username */
.cm-story-user-views {
    display: flex;
    align-items: center;
    background-color: rgba(255, 255, 255, 0.2);
    border-radius: 12px;
    padding: 2px 8px;
    font-size: 12px;
    color: #fff;
}

.cm-story-user-views-icon {
    font-size: 14px;
    margin-right: 4px;
}

.cm-story-user-views-number {
    font-weight: 600;
}

/* Navigation Indicators */
.cm-stories-navigation .cm-story-prev, 
.cm-stories-navigation .cm-story-next {
    position: relative;
}

.cm-stories-navigation .cm-story-prev::after,
.cm-stories-navigation .cm-story-next::after {
    content: "";
    position: absolute;
    top: 50%;
    width: 20px;
    height: 20px;
    border-top: 3px solid rgba(255, 255, 255, 0.5);
    border-left: 3px solid rgba(255, 255, 255, 0.5);
    opacity: 0;
    transition: opacity 0.3s;
}

.cm-stories-navigation .cm-story-prev::after {
    left: 20px;
    transform: translateY(-50%) rotate(-45deg);
}

.cm-stories-navigation .cm-story-next::after {
    right: 20px;
    transform: translateY(-50%) rotate(135deg);
}

.cm-stories-navigation .cm-story-prev:hover::after,
.cm-stories-navigation .cm-story-next:hover::after {
    opacity: 1;
}

/* Swipe Instructions */
.cm-swipe-instruction {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background-color: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 10px 15px;
    border-radius: 20px;
    font-size: 14px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
    z-index: 100;
    white-space: nowrap;
}

.cm-swipe-left-instruction {
    transform: translate(-100%, -50%);
    left: 30%;
}

.cm-swipe-right-instruction {
    transform: translate(0, -50%);
    left: 70%;
}

.cm-swipe-instruction.show {
    opacity: 1;
    animation: fadeInOut 1.5s ease-in-out;
}

@keyframes fadeInOut {
    0% { opacity: 0; }
    20% { opacity: 1; }
    80% { opacity: 1; }
    100% { opacity: 0; }
}

/* Hold Indicator */
.cm-story-hold-indicator {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background-color: rgba(0, 0, 0, 0.6);
    color: white;
    padding: 8px 12px;
    border-radius: 15px;
    font-size: 12px;
    opacity: 0;
    pointer-events: none;
    z-index: 50;
}

.cm-story-hold-indicator.active {
    opacity: 1;
    animation: pulse 1s infinite alternate;
}

@keyframes pulse {
    0% { transform: translate(-50%, -50%) scale(1); }
    100% { transform: translate(-50%, -50%) scale(1.1); }
}