/* =========================
   STORIES SECTION
========================= */

.stories-section {
    background: var(--white);
    padding: 20px;
    border-radius: 14px;
    margin-bottom: 22px;
    overflow: hidden;
}

.stories-section h3 {
    margin-bottom: 18px;
    font-size: 17px;
}

.stories-container {
    display: flex;
    gap: 20px;
    overflow-x: auto;
    padding-bottom: 8px;
}

.stories-container::-webkit-scrollbar {
    display: none;
}

/* STORY VIEWS BUTTON */
.story-views-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    background: transparent;
    border: none;
    color: white;
    font-size: 14px;
    cursor: pointer;
    margin-left: auto;
    padding: 8px;
}

.story-views-btn i {
    width: 18px;
    height: 18px;
}

/* STORY VIEWS PANEL */
.story-views-panel {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    width: min(90%, 360px);
    max-height: 250px;
    overflow-y: auto;
    background: #1e1e1e;
    color: white;
    border-radius: 12px;
    padding: 14px;
    z-index: 20;
}

.story-views-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.story-views-panel-header button {
    background: none;
    border: none;
    color: white;
    font-size: 24px;
    cursor: pointer;
}

.story-views-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.story-viewer-item {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 14px;
}

.story-viewer-item img {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    object-fit: cover;
}

.story {
    flex: 0 0 auto;
    width: 65px;
    text-align: center;
    cursor: pointer;
}

.story-circle {
    width: 62px;
    height: 62px;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 22px;
    font-weight: 700;
    color: white;
    margin: auto;
    border: 3px solid #4c00ff;
    outline: 2px solid white;
    overflow: hidden;
    flex-shrink: 0;
    transition: border-color 0.2s ease;
}

/* At least one unseen story */
.story-circle.story-unseen {
    border: 3px solid #4c00ff;
}

/* All stories viewed */
.story-circle.story-seen {
    border: 3px solid #8c9097;
}

.story-profile-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
    display: block;
}

.story-viewer-avatar {
    width: 36px;
    height: 36px;
    background: var(--purple);
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    font-weight: 700;
}

.story-viewer-profile-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
    display: block;
}

.own-story {
    background: #F1F3F9;
    color: var(--purple);
    border: 2px dashed var(--purple);
}

.story-one {
    background: #2563EB;
}

.story-two {
    background: #DB2777;
}

.story-three {
    background: #059669;
}

.story-four {
    background: #D97706;
}

.story span {
    display: block;
    font-size: 12px;
    margin-top: 8px;
    overflow: hidden;
    text-overflow: ellipsis;
}


/* =========================
   CREATE STORY MODAL
========================= */

.story-create-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 10000;
    background: rgba(11, 16, 38, 0.7);
    justify-content: center;
    align-items: center;
    padding: 15px;
}

.story-create-modal {
    width: 100%;
    max-width: 430px;
    max-height: 90vh;
    overflow-y: auto;
    background: white;
    padding: 25px;
    border-radius: 16px;
}

.story-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 25px;
}

.story-modal-header button {
    border: none;
    background: var(--surface);
    border-radius: 50%;
    width: 32px;
    height: 32px;
    font-size: 22px;
    cursor: pointer;
}

.story-upload-area {
    text-align: center;
    padding: 35px 15px;
    background: var(--background);
    border: 2px dashed var(--border);
    border-radius: 12px;
}

.story-upload-area > i {
    width: 35px;
    height: 35px;
    color: var(--purple);
    margin-bottom: 12px;
}

.story-upload-area h3 {
    margin-bottom: 7px;
}

.story-upload-area p {
    color: var(--text-secondary);
    font-size: 13px;
    margin-bottom: 18px;
}

.story-upload-btn {
    display: inline-block;
    padding: 11px 18px;
    color: white;
    background: var(--purple);
    border-radius: 8px;
    cursor: pointer;
    font-size: 13px;
}

.story-image-preview {
    display: none;
    margin-top: 15px;
}

.story-image-preview img {
    width: 100%;
    max-height: 300px;
    object-fit: contain;
    border-radius: 10px;
    background: #111;
}

.story-caption-field {
    margin-top: 15px;
}

.story-caption-field textarea {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 9px;
    resize: vertical;
    font-family: inherit;
}

.publish-story-btn {
    width: 100%;
    padding: 13px;
    margin-top: 15px;
    background: var(--purple);
    color: white;
    border: none;
    border-radius: 9px;
    font-weight: 700;
    cursor: pointer;
}


/* =========================
   STORY VIEWER
========================= */

.story-viewer-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 10001;
    background: rgba(0, 0, 0, 0.95);
    justify-content: center;
    align-items: center;
    padding: 15px;
}

.story-viewer {
    width: 100%;
    max-width: 420px;
    height: min(90vh, 750px);
    background: #111;
    border-radius: 14px;
    overflow: hidden;
    position: relative;
}

.story-progress-container {
    position: absolute;
    top: 12px;
    left: 12px;
    right: 12px;
    display: flex;
    gap: 5px;
    z-index: 5;
}

.story-progress-segment {
    height: 3px;
    flex: 1;
    background: rgba(255,255,255,0.35);
    border-radius: 5px;
    overflow: hidden;
}

.story-progress-fill {
    height: 100%;
    width: 0%;
    background: white;
}

.story-viewer-header {
    position: absolute;
    top: 25px;
    left: 15px;
    right: 15px;
    z-index: 5;
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: white;
}

.story-viewer-user {
    display: flex;
    align-items: center;
    gap: 10px;
}

.story-viewer-user strong,
.story-viewer-user small {
    display: block;
}

.story-viewer-user small {
    font-size: 11px;
    color: #ddd;
    margin-top: 3px;
}

.story-viewer-avatar {
    width: 36px;
    height: 36px;
    background: var(--purple);
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    font-weight: 700;
}

.story-viewer-header > button {
    border: none;
    background: transparent;
    color: white;
    font-size: 30px;
    cursor: pointer;
}

.story-viewer-content {
    height: 100%;
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
}

.story-viewer-content > img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.story-navigation {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 4;
    width: 35px;
    height: 45px;
    border: none;
    border-radius: 8px;
    background: rgba(0,0,0,0.25);
    color: white;
    cursor: pointer;
}

.story-navigation.prev {
    left: 8px;
}

.story-navigation.next {
    right: 8px;
}

.story-viewer-caption {
    position: absolute;
    bottom: 25px;
    left: 20px;
    right: 20px;
    color: white;
    text-align: center;
    font-size: 14px;
    overflow-wrap: anywhere;
}


/* MOBILE */

@media (max-width: 480px) {

    .stories-section {
        padding: 15px;
    }

    .stories-container {
        gap: 15px;
    }

    .story-viewer-overlay {
        padding: 0;
    }

    .story-viewer {
        width: 100%;
        height: 100%;
        max-width: none;
        border-radius: 0;
    }

    .story-create-modal {
        padding: 20px;
    }

}

.story-like-btn {
    position: absolute;
    bottom: 25px;
    right: 20px;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    border: none;
    border-radius: 25px;
    background: rgba(0, 0, 0, 0.65);
    color: #fff;
    font-size: 16px;
    cursor: pointer;
    z-index: 5;
}

.story-like-btn i {
    width: 22px;
    height: 22px;
}

.story-like-btn.liked {
    color: #ff4d6d;
}

.story-activity-section {
    margin-bottom: 16px;
}

.story-activity-section > strong {
    display: block;
    margin-bottom: 10px;
    font-size: 14px;
}

.story-likers-list,
.story-views-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-height: 180px;
    overflow-y: auto;
}

.story-activity-section .story-viewer-item {
    display: flex;
    align-items: center;
    gap: 10px;
}

.story-circle .story-initial {
    position: absolute !important;
    inset: 0 !important;

    width: 100% !important;
    height: 100% !important;

    margin: 0 !important;
    padding: 0 !important;

    display: flex !important;
    align-items: center !important;
    justify-content: center !important;

    background: linear-gradient(135deg, #2563eb, #7c3aed);
    color: #ffffff !important;

    font-family: Arial, sans-serif !important;
    font-size: 28px !important;
    font-weight: 700 !important;
    line-height: 1 !important;

    border-radius: 50%;
    z-index: 2;
    overflow: hidden;
}