/* Universe - Instagram-Style Social Media UI */

:root {
    --universe-white: #FFFFFF;
    --universe-bg: #FAFAFA;
    --universe-border: #DBDBDB;
    --universe-text: #262626;
    --universe-text-light: #8E8E8E;
    --universe-link: #00376B;
    --universe-primary: #0095F6;
    --universe-primary-hover: #1877F2;
    --universe-like: #ED4956;
    --universe-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
    --universe-shadow-md: 0 2px 8px rgba(0, 0, 0, 0.08);
}

/* Base Overrides */
body {
    background-color: var(--universe-bg) !important;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

/* Universe Layout Overrides */
.universe-container {
    max-width: 975px;
    margin: 0 auto;
    padding: 0 20px;
}

/* ============================================================
   STORIES STRIP
   ============================================================ */
.stories-container {
    background: var(--universe-white);
    border: 1px solid var(--universe-border);
    border-radius: 12px;
    padding: 12px 0;
    margin-bottom: 16px;
    box-shadow: var(--universe-shadow);
    overflow: hidden;
}

.story-scroll {
    display: flex;
    gap: 4px;
    overflow-x: auto;
    padding: 4px 12px;
    scrollbar-width: none;
    -ms-overflow-style: none;
    scroll-behavior: smooth;
}

.story-scroll::-webkit-scrollbar {
    display: none;
}

.story-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    cursor: pointer;
    min-width: 72px;
    background: transparent;
    border: none;
    padding: 4px 2px;
    border-radius: 8px;
    transition: background 0.15s;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.story-item:hover {
    background: rgba(0, 0, 0, 0.04);
}

/* Ring wrapper - default = seen (grey) */
.story-avatar-wrapper {
    position: relative;
    width: 64px;
    height: 64px;
    border-radius: 50%;
    padding: 2.5px;
    background: #dbdbdb;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s cubic-bezier(.18, .89, .32, 1.28);
}

/* Active unseen story = Instagram orange/pink gradient */
.story-avatar-wrapper.has-story.unseen {
    background: linear-gradient(45deg, #f09433 0%, #e6683c 25%, #dc2743 50%, #cc2366 75%, #bc1888 100%);
}

/* Seen but has stories = faded grey */
.story-avatar-wrapper.has-story:not(.unseen) {
    background: #c7c7c7;
}

.story-avatar-wrapper:hover {
    transform: scale(1.06);
}

/* Inner white ring + image */
.story-avatar-wrapper>img,
.story-placeholder {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    border: 2.5px solid #fff;
    object-fit: cover;
    background: #f0f0f0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    font-weight: 600;
    color: #8e8e8e;
}

/* Add Story (+) badge */
.story-add-btn {
    position: absolute;
    bottom: -1px;
    right: -1px;
    width: 22px;
    height: 22px;
    background: var(--universe-primary);
    border: 2.5px solid #fff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    box-shadow: 0 1px 4px rgba(0, 0, 0, .2);
    transition: transform 0.15s;
    cursor: pointer;
    z-index: 2;
}

.story-add-btn:hover {
    transform: scale(1.12);
}

.story-add-btn svg {
    width: 11px;
    height: 11px;
}

.story-username {
    font-size: 11px;
    color: var(--universe-text);
    max-width: 72px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    text-align: center;
    line-height: 14px;
}

/* ============================================================
   STORY VIEWER OVERLAY  —  Instagram-style
   ============================================================ */

/* ── Backdrop: fixed, dark + blur, background page stays scrollable ── */
.story-viewer-overlay {
    /* === VIEWPORT-LOCK: all four anchor methods for maximum compatibility === */
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    /* inset:0 as modern shorthand  */
    inset: 0;
    /* visual */
    background: rgba(0, 0, 0, 0.82);
    backdrop-filter: blur(8px) saturate(0.7);
    -webkit-backdrop-filter: blur(8px) saturate(0.7);
    /* z-index: high enough to clear Bootstrap navbars (z:1030) and all widgets */
    z-index: 99999 !important;
    /* layout */
    display: flex;
    align-items: center;
    justify-content: center;
    /* enter animation */
    animation: sv-backdrop-in 0.22s ease both;
    /* prevent the overlay itself from creating a transform stacking context
       that would re-trap child fixed elements */
    transform: none !important;
    will-change: opacity;
    overscroll-behavior: contain;
}

@keyframes sv-backdrop-in {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

/* ── Outer side navigation arrows (desktop) ── */
.story-viewer-prev-user,
.story-viewer-next-user {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 44px;
    height: 44px;
    background: rgba(255, 255, 255, 0.16);
    border: 1.5px solid rgba(255, 255, 255, 0.22);
    border-radius: 50%;
    color: #fff;
    font-size: 22px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 9010;
    transition: background 0.18s, transform 0.18s, opacity 0.18s;
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    user-select: none;
}

.story-viewer-prev-user {
    left: calc(50% - 240px);
}

.story-viewer-next-user {
    right: calc(50% - 240px);
}

.story-viewer-prev-user:hover,
.story-viewer-next-user:hover {
    background: rgba(255, 255, 255, 0.30);
    transform: translateY(-50%) scale(1.1);
}

@media (max-width: 540px) {

    .story-viewer-prev-user,
    .story-viewer-next-user {
        display: none;
    }
}

/* ── Story card (the popup) ── */
.story-content-wrapper {
    position: relative;
    /* card is positioned, NOT fixed → stays centered */
    width: min(390px, 92vw);
    /* 9:16 aspect — classic portrait story format */
    height: min(calc(min(390px, 92vw) * 16 / 9), 94svh, 94vh);
    background: #111;
    border-radius: 18px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow:
        0 24px 80px rgba(0, 0, 0, 0.75),
        0 4px 16px rgba(0, 0, 0, 0.5);
    /* entry: fade + scale from 92% → 100% */
    animation: sv-card-in 0.28s cubic-bezier(0.22, 1, 0.36, 1) both;
    /* card is NOT fixed so the overlay (fixed) handles the positioning */
    z-index: 9005;
}

@keyframes sv-card-in {
    from {
        opacity: 0;
        transform: scale(0.92);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* Full-screen on narrow mobile */
@media (max-width: 440px) {
    .story-content-wrapper {
        width: 100vw;
        height: 100svh;
        height: 100vh;
        /* fallback */
        border-radius: 0;
    }

    .story-viewer-overlay {
        align-items: flex-start;
    }
}

/* ── Progress bars ── */
.story-progress-bar {
    position: absolute;
    top: 12px;
    left: 10px;
    right: 10px;
    display: flex;
    gap: 5px;
    z-index: 20;
    pointer-events: none;
}

.story-progress-segment {
    flex: 1;
    height: 2.5px;
    background: rgba(255, 255, 255, 0.30);
    border-radius: 99px;
    overflow: hidden;
}

.story-progress-fill {
    height: 100%;
    width: 0%;
    background: #fff;
    border-radius: 99px;
    will-change: width;
    transition: none;
    /* driven by requestAnimationFrame */
}

.story-paused .story-progress-fill {
    opacity: 0.6;
}

/* ── Top header overlay ── */
.story-header {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    padding: 32px 14px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 15;
    /* gradient so text is readable over any media */
    background: linear-gradient(180deg,
            rgba(0, 0, 0, 0.60) 0%,
            rgba(0, 0, 0, 0.20) 70%,
            transparent 100%);
    pointer-events: none;
}

.story-user-info {
    display: flex;
    align-items: center;
    gap: 10px;
    color: #fff;
    pointer-events: auto;
}

.story-user-info img {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.85);
    object-fit: cover;
    flex-shrink: 0;
}

/* Fallback avatar placeholder inside story header */
.sv-avatar-placeholder {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.85);
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 700;
    color: #fff;
    flex-shrink: 0;
}

.story-viewer-name {
    font-size: 14px;
    font-weight: 600;
    color: #fff;
    letter-spacing: 0.1px;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
}

.story-viewer-time {
    font-size: 11.5px;
    font-weight: 400;
    color: rgba(255, 255, 255, 0.72);
    margin-left: 2px;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

.story-header-actions {
    display: flex;
    gap: 6px;
    align-items: center;
    pointer-events: auto;
}

/* Mute button */
.story-mute-btn {
    background: rgba(255, 255, 255, 0.16);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    border: 1px solid rgba(255, 255, 255, 0.18);
    color: #fff;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 15px;
    transition: background 0.18s, transform 0.15s;
}

.story-mute-btn:hover {
    background: rgba(255, 255, 255, 0.28);
    transform: scale(1.08);
}

/* Close (X) button */
.close-story-btn {
    background: rgba(255, 255, 255, 0.16);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    border: 1px solid rgba(255, 255, 255, 0.18);
    color: #fff;
    font-size: 20px;
    cursor: pointer;
    width: 34px;
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    line-height: 1;
    transition: background 0.18s, transform 0.15s;
}

.close-story-btn:hover {
    background: rgba(255, 255, 255, 0.30);
    transform: scale(1.08);
}

/* ── Media container ── */
.story-media-container {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #000;
    z-index: 1;
}

.story-media-container>img,
.story-media-container>video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    /* Instagram crops to fill, like portrait */
    display: block;
}

/* ── Tap navigation zones ── */
.story-tap-left,
.story-tap-right {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 38%;
    z-index: 10;
    cursor: pointer;
}

.story-tap-left {
    left: 0;
}

.story-tap-right {
    right: 0;
}

/* ── Pause dim overlay ── */
.story-pause-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.10);
    z-index: 9;
    opacity: 0;
    transition: opacity 0.12s;
    pointer-events: none;
}

.story-paused .story-pause-overlay {
    opacity: 1;
}

/* ── Reply bar ── */
.story-reply-bar {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 10px 14px 20px;
    display: flex;
    align-items: center;
    gap: 10px;
    background: linear-gradient(0deg,
            rgba(0, 0, 0, 0.60) 0%,
            rgba(0, 0, 0, 0.20) 70%,
            transparent 100%);
    z-index: 15;
}

.story-reply-input {
    flex: 1;
    background: rgba(255, 255, 255, 0.14);
    border: 1.5px solid rgba(255, 255, 255, 0.36);
    border-radius: 24px;
    color: #fff;
    font-size: 13px;
    padding: 9px 16px;
    outline: none;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    transition: background 0.2s, border-color 0.2s;
    caret-color: #fff;
}

.story-reply-input::placeholder {
    color: rgba(255, 255, 255, 0.60);
}

.story-reply-input:focus {
    background: rgba(255, 255, 255, 0.22);
    border-color: rgba(255, 255, 255, 0.65);
}

.story-reply-emoji-btn,
.story-reply-send-btn {
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid rgba(255, 255, 255, 0.18);
    color: #fff;
    font-size: 18px;
    cursor: pointer;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background 0.15s, transform 0.15s;
    flex-shrink: 0;
}

.story-reply-emoji-btn:hover,
.story-reply-send-btn:hover {
    background: rgba(255, 255, 255, 0.24);
    transform: scale(1.08);
}

/* ── Story-to-story transition animations ── */
@keyframes sv-next {
    from {
        opacity: 0;
        transform: translateX(6%) scale(0.97);
    }

    to {
        opacity: 1;
        transform: translateX(0) scale(1);
    }
}

@keyframes sv-prev {
    from {
        opacity: 0;
        transform: translateX(-6%) scale(0.97);
    }

    to {
        opacity: 1;
        transform: translateX(0) scale(1);
    }
}

.sv-anim-next .story-media-container>img,
.sv-anim-next .story-media-container>video {
    animation: sv-next 0.22s ease both;
}

.sv-anim-prev .story-media-container>img,
.sv-anim-prev .story-media-container>video {
    animation: sv-prev 0.22s ease both;
}

/* ── Visible scrollbar prevention (DO NOT use overflow:hidden on body)
   Instead we only block pointer-events on the overlay backdrop ── */
.story-viewer-overlay {
    /* pointer events only on the overlay itself — the body scroll
       is NOT locked so the page remains scrollable (req #4) */
    overscroll-behavior: contain;
}

/* ── Loading skeleton inside card ── */
.sv-skeleton {
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, #1a1a1a 25%, #2a2a2a 50%, #1a1a1a 75%);
    background-size: 200% 100%;
    animation: sv-shimmer 1.4s ease infinite;
    z-index: 2;
    display: none;
}

.sv-skeleton.visible {
    display: block;
}

@keyframes sv-shimmer {
    0% {
        background-position: 200% 0;
    }

    100% {
        background-position: -200% 0;
    }
}

/* ============================================================
   STORY VIEWER OVERLAY  (END)
   ============================================================ */




/* Modal Overlay Base Styles (Reusing existing or defining new) */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.65);
    /* Darker backdrop */
    z-index: 1500;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(4px);
}

.modal-content {
    background: var(--universe-white);
    border-radius: 12px;
    width: 90%;
    max-width: 400px;
    max-height: 90vh;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
    border: none;
}

.modal-header {
    border-bottom: 1px solid var(--universe-border);
    padding: 12px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    text-align: center;
    flex: 1;
}

.modal-body {
    padding: 24px;
}

/* Upload Area specific */
.upload-area {
    border: 2px dashed var(--universe-border);
    border-radius: 8px;
    padding: 40px 20px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
    color: var(--universe-text-light);
}

.upload-area:hover {
    background: #fafafa;
    border-color: var(--universe-text-light);
}

.preview-container {
    position: relative;
    width: 100%;
    border-radius: 8px;
    overflow: hidden;
    margin-top: 16px;
}

.preview-container img,
.preview-container video {
    width: 100%;
    display: block;
}

.remove-preview {
    position: absolute;
    top: 8px;
    right: 8px;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    border: none;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.primary-btn {
    background: var(--universe-primary);
    color: white;
    border: none;
    border-radius: 4px;
    padding: 8px 16px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

.primary-btn:hover {
    background: var(--universe-primary-hover);
}

.primary-btn:disabled {
    opacity: 0.5;
    cursor: default;
}

.full-width {
    width: 100%;
}

/* Feed Section */
.feed-section {
    max-width: 614px;
    margin: 0 auto;
}

/* Post Card */
.post-card {
    background: var(--universe-white);
    border: 1px solid var(--universe-border);
    border-radius: 8px;
    margin-bottom: 24px;
    box-shadow: var(--universe-shadow);
}

.post-header {
    display: flex;
    align-items: center;
    padding: 14px 16px;
    gap: 12px;
}

.post-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    overflow: hidden;
    flex-shrink: 0;
    background: var(--universe-bg);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 14px;
    color: var(--universe-text);
}

.post-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.post-user-info {
    flex: 1;
    min-width: 0;
}

.post-username {
    font-weight: 600;
    font-size: 14px;
    color: var(--universe-text);
    text-decoration: none;
    display: inline-block;
}

.post-username:hover {
    color: var(--universe-text-light);
}

.post-time {
    font-size: 12px;
    color: var(--universe-text-light);
}

.post-menu {
    cursor: pointer;
    font-size: 20px;
    color: var(--universe-text);
    font-weight: bold;
    padding: 8px;
    line-height: 1;
}

.post-menu:hover {
    color: var(--universe-text-light);
}

/* Post Media */
.post-media {
    position: relative;
    width: 100%;
    background: var(--universe-bg);
    display: flex;
    align-items: center;
    justify-content: center;
}

.post-media img,
.post-media video {
    width: 100%;
    height: auto;
    display: block;
    max-height: 600px;
    object-fit: contain;
}

/* Post Actions */
.post-actions {
    display: flex;
    align-items: center;
    padding: 8px 16px;
    gap: 16px;
}

.action-left {
    flex: 1;
    display: flex;
    gap: 16px;
}

.action-btn {
    background: none;
    border: none;
    padding: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.action-btn:hover {
    opacity: 0.6;
}

.action-btn svg,
.action-btn i {
    width: 24px;
    height: 24px;
    color: var(--universe-text);
}

.action-btn.liked svg,
.action-btn.liked i {
    color: var(--universe-like);
    fill: var(--universe-like);
}

.action-btn.liked {
    animation: like-pulse 0.4s ease;
}

@keyframes like-pulse {
    0% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.2);
    }

    100% {
        transform: scale(1);
    }
}

/* Post Stats & Content */
.post-likes {
    padding: 0 16px 8px;
    font-weight: 600;
    font-size: 14px;
    color: var(--universe-text);
}

.post-caption {
    padding: 0 16px 8px;
    font-size: 14px;
    line-height: 18px;
    color: var(--universe-text);
}

.caption-username {
    font-weight: 600;
    margin-right: 6px;
    text-decoration: none;
    color: var(--universe-text);
}

.caption-username:hover {
    color: var(--universe-text-light);
}

.caption-text {
    color: var(--universe-text);
}

.post-comments-link {
    padding: 0 16px 8px;
    font-size: 14px;
    color: var(--universe-text-light);
    cursor: pointer;
    text-decoration: none;
    display: inline-block;
}

.post-comments-link:hover {
    color: var(--universe-text);
}

.post-timestamp {
    padding: 0 16px 16px;
    font-size: 10px;
    color: var(--universe-text-light);
    text-transform: uppercase;
    letter-spacing: 0.2px;
}

/* Comment Section */
.post-comment-box {
    border-top: 1px solid var(--universe-border);
    padding: 12px 16px;
    display: flex;
    gap: 12px;
}

.comment-input {
    flex: 1;
    border: none;
    outline: none;
    font-size: 14px;
    color: var(--universe-text);
}

.comment-input::placeholder {
    color: var(--universe-text-light);
}

.comment-post-btn {
    color: var(--universe-primary);
    font-weight: 600;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 14px;
    padding: 0;
}

.comment-post-btn:hover {
    color: var(--universe-primary-hover);
}

.comment-post-btn:disabled {
    opacity: 0.3;
    cursor: default;
}

/* Create Post Button */
.create-post-btn {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--universe-primary);
    color: white;
    border: none;
    box-shadow: var(--universe-shadow-md);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    transition: all 0.3s;
    z-index: 1000;
}

.create-post-btn:hover {
    background: var(--universe-primary-hover);
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

/* Reaction Icons */
.reaction-icon {
    font-size: 12px;
    margin-left: 4px;
}

/* Empty State */
.empty-feed {
    text-align: center;
    padding: 60px 20px;
    background: var(--universe-white);
    border: 1px solid var(--universe-border);
    border-radius: 8px;
    box-shadow: var(--universe-shadow);
}

.empty-feed-icon {
    font-size: 64px;
    margin-bottom: 16px;
    opacity: 0.3;
}

.empty-feed-title {
    font-size: 22px;
    font-weight: 300;
    color: var(--universe-text);
    margin-bottom: 8px;
}

.empty-feed-text {
    font-size: 14px;
    color: var(--universe-text-light);
}

/* Responsive Design */
@media (max-width: 768px) {
    .universe-container {
        padding: 0;
    }

    .stories-section,
    .post-card {
        border-radius: 0;
        border-left: none;
        border-right: none;
    }

    .feed-section {
        max-width: 100%;
    }

    .create-post-btn {
        bottom: 80px;
    }
}

/* Sidebar Updates for Instagram Style */
.universe-sidebar {
    position: sticky;
    top: 80px;
}

.universe-sidebar .card {
    box-shadow: var(--universe-shadow);
    border: 1px solid var(--universe-border);
}

.universe-sidebar .list-group-item {
    border: none;
    padding: 12px 16px;
    transition: background-color 0.2s;
}

.universe-sidebar .list-group-item:hover {
    background-color: var(--universe-bg);
}

.universe-sidebar .list-group-item.active {
    background-color: var(--universe-bg);
    color: var(--universe-text);
    font-weight: 600;
}

/* Loading Skeleton */
.skeleton {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s infinite;
}

@keyframes skeleton-loading {
    0% {
        background-position: 200% 0;
    }

    100% {
        background-position: -200% 0;
    }
}

.skeleton-post {
    height: 500px;
    margin-bottom: 24px;
    border-radius: 8px;
}

/* ===========================================================================
   ADVANCED FEATURES - Reaction Picker, Comments, Save Button
   =========================================================================== */

/* Reaction Picker */
.reaction-picker-container {
    position: relative;
    display: inline-block;
}

.reaction-picker {
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%) scale(0);
    background: white;
    border-radius: 30px;
    padding: 8px 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    display: flex;
    gap: 4px;
    margin-bottom: 8px;
    z-index: 100;
    opacity: 0;
    pointer-events: none;
    transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.reaction-picker.show {
    transform: translateX(-50%) scale(1);
    opacity: 1;
    pointer-events: all;
}

.reaction-option {
    font-size: 28px;
    cursor: pointer;
    transition: transform 0.15s ease;
    padding: 4px;
    line-height: 1;
    user-select: none;
}

.reaction-option:hover {
    transform: scale(1.3);
}

.reaction-option:active {
    transform: scale(1.1);
}

/* Comments Section */
.comments-section {
    border-top: 1px solid var(--universe-border);
    padding-top: 8px;
    margin-top: 8px;
}

.comments-toggle {
    color: var(--universe-text-light);
    font-size: 14px;
    cursor: pointer;
    padding: 4px 16px;
    user-select: none;
}

.comments-toggle:hover {
    color: var(--universe-text);
}

.comments-list {
    margin: 0;
    padding: 0 16px;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
}

.comments-list.expanded {
    max-height: 500px;
    overflow-y: auto;
}

.comment-item {
    display: flex;
    gap: 12px;
    margin-bottom: 12px;
    padding: 8px 0;
}

.comment-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--universe-primary);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 600;
    flex-shrink: 0;
}

.comment-content {
    flex: 1;
    min-width: 0;
}

.comment-header {
    display: flex;
    align-items: baseline;
    gap: 8px;
    margin-bottom: 4px;
}

.comment-username {
    font-weight: 600;
    font-size: 14px;
    color: var(--universe-text);
    text-decoration: none;
}

.comment-username:hover {
    text-decoration: underline;
}

.comment-time {
    font-size: 12px;
    color: var(--universe-text-light);
}

.comment-body {
    font-size: 14px;
    color: var(--universe-text);
    word-wrap: break-word;
    margin: 0;
}

/* Comment Input */
.comment-input-container {
    display: flex;
    gap: 12px;
    align-items: center;
    padding: 12px 16px;
    border-top: 1px solid var(--universe-border);
    margin-top: 8px;
}

.comment-input-box {
    flex: 1;
    border: none;
    outline: none;
    font-size: 14px;
    font-family: inherit;
    resize: none;
    min-height: 20px;
    max-height: 80px;
    overflow-y: auto;
}

.comment-input-box::placeholder {
    color: var(--universe-text-light);
}

.comment-submit {
    background: none;
    border: none;
    color: var(--universe-primary);
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    padding: 0;
    opacity: 0.3;
    pointer-events: none;
    transition: opacity 0.2s;
}

.comment-submit.active {
    opacity: 1;
    pointer-events: all;
}

.comment-submit.active:hover {
    color: #0081d6;
}

/* Save button saved state */
.action-btn.saved svg {
    fill: currentColor;
}

/* Loading states */
.action-btn.loading {
    opacity: 0.5;
    pointer-events: none;
}

/* Smooth scrolling for comments */
.comments-list {
    scroll-behavior: smooth;
}

.comments-list::-webkit-scrollbar {
    width: 6px;
}

.comments-list::-webkit-scrollbar-track {
    background: var(--universe-bg);
    border-radius: 3px;
}

.comments-list::-webkit-scrollbar-thumb {
    background: var(--universe-border);
    border-radius: 3px;
}

.comments-list::-webkit-scrollbar-thumb:hover {
    background: #c0c0c0;
}

/* ===========================================================================
   PROFILE PAGE STYLES
   =========================================================================== */

.profile-container {
    max-width: 935px;
    margin: 0 auto;
    padding: 30px 20px 0;
}

/* Profile Header */
.profile-header {
    margin-bottom: 44px;
}

.profile-avatar-container {
    width: 150px;
    height: 150px;
    cursor: pointer;
}

.profile-avatar {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    overflow: hidden;
    border: 1px solid var(--universe-border);
}

.profile-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.avatar-placeholder {
    width: 100%;
    height: 100%;
    background: var(--universe-bg);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 60px;
    color: var(--universe-text-light);
    font-weight: 300;
}

.profile-username {
    font-size: 28px;
    font-weight: 300;
    color: var(--universe-text);
}

.profile-stats {
    font-size: 16px;
    color: var(--universe-text);
}

.stat-item {
    margin-right: 40px;
}

.stat-item:last-child {
    margin-right: 0;
}

.profile-bio {
    font-size: 14px;
    line-height: 24px;
    color: var(--universe-text);
}

.btn-text {
    background: none;
    border: none;
    padding: 0;
    color: var(--universe-text);
    font-size: 24px;
}

/* Profile Tabs */
.profile-tabs-container {
    border-top: 1px solid var(--universe-border);
    display: flex;
    justify-content: center;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 1px;
    color: var(--universe-text-light);
}

.profile-tab {
    height: 52px;
    display: flex;
    align-items: center;
    cursor: pointer;
    margin-top: -1px;
    border-top: 1px solid transparent;
    transition: all 0.2s;
}

.profile-tab.active {
    border-top: 1px solid var(--universe-text);
    color: var(--universe-text);
}

.profile-tab i {
    font-size: 14px;
}

/* Profile Grid */
.profile-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 28px;
    margin-bottom: 30px;
}

.grid-item {
    position: relative;
    background: var(--universe-bg);
    aspect-ratio: 1 / 1;
    overflow: hidden;
    cursor: pointer;
}

.grid-image-container {
    width: 100%;
    height: 100%;
    position: relative;
}

.grid-image-container img,
.grid-image-container video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.video-indicator {
    position: absolute;
    top: 10px;
    right: 10px;
    color: white;
    font-size: 20px;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

/* Grid Overlay */
.grid-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.2s;
}

.grid-item:hover .grid-overlay {
    opacity: 1;
}

.overlay-stats {
    color: white;
    font-weight: 600;
    font-size: 16px;
    display: flex;
    gap: 30px;
}

.overlay-stats i {
    margin-right: 5px;
}

/* Empty State */
.empty-profile-state {
    padding: 60px 0;
    color: var(--universe-text);
}

.empty-icon {
    margin-bottom: 20px;
}

/* Text Post Placeholder */
.text-post-placeholder {
    width: 100%;
    height: 100%;
    background: #efefef;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    color: var(--universe-text);
    font-size: 14px;
    padding: 10px;
    font-weight: 500;
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .profile-container {
        padding: 20px 0 0;
    }

    .profile-header {
        margin-bottom: 24px;
        padding: 0 16px;
    }

    .profile-avatar-container {
        width: 77px;
        height: 77px;
        margin: 0;
    }

    .profile-username {
        font-size: 22px;
    }

    .profile-stats {
        border-top: 1px solid var(--universe-border);
        padding: 12px 0;
        margin-bottom: 0;
        justify-content: space-around;
        font-size: 14px;
    }

    .stat-item {
        margin-right: 0;
        text-align: center;
        display: flex;
        flex-direction: column;
    }

    .stat-item span {
        display: block;
    }

    .profile-grid {
        gap: 3px;
    }

    .profile-tab span {
        display: none;
    }
}

/* ============================================================
   INSTAGRAM-STYLE CREATE BAR
   ============================================================ */
.ig-create-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--universe-white);
    border: 1px solid var(--universe-border);
    border-radius: 12px;
    padding: 10px 14px;
    box-shadow: var(--universe-shadow);
}

.ig-create-bar__avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    flex-shrink: 0;
    overflow: hidden;
    background: var(--universe-bg);
    display: flex;
    align-items: center;
    justify-content: center;
}

.ig-create-bar__avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.ig-create-bar__initials {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--universe-primary);
    color: #fff;
    font-weight: 700;
    font-size: 16px;
    border-radius: 50%;
}

.ig-create-bar__input {
    flex: 1;
    background: var(--universe-bg);
    border: 1px solid var(--universe-border);
    border-radius: 24px;
    padding: 9px 18px;
    color: var(--universe-text-light);
    font-size: 14px;
    cursor: pointer;
    display: block;
    transition: background 0.15s, border-color 0.15s;
}

.ig-create-bar__input:hover {
    background: #efefef;
    border-color: #c0c0c0;
    color: var(--universe-text);
}

.ig-create-bar__icon-btn {
    width: 38px;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    color: var(--universe-text);
    text-decoration: none;
    transition: background 0.15s;
    flex-shrink: 0;
}

.ig-create-bar__icon-btn:hover {
    background: var(--universe-bg);
    color: var(--universe-primary);
}

/* ============================================================
   FEED TOGGLES
   ============================================================ */
.feed-toggles {
    display: flex;
    gap: 0;
    border-bottom: 1px solid var(--universe-border);
    margin-bottom: 16px;
    background: var(--universe-white);
    border-radius: 8px 8px 0 0;
    overflow: hidden;
}

.feed-toggle {
    flex: 1;
    text-align: center;
    padding: 12px 0;
    font-size: 13px;
    font-weight: 600;
    color: var(--universe-text-light);
    text-decoration: none;
    border-bottom: 2px solid transparent;
    transition: color 0.15s, border-color 0.15s;
    letter-spacing: .2px;
}

.feed-toggle:hover {
    color: var(--universe-text);
}

.feed-toggle.active {
    color: var(--universe-text);
    border-bottom-color: var(--universe-text);
}

/* ============================================================
   HEART POPUP ANIMATION (Double Tap Like)
   ============================================================ */
.heart-popup {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0);
    color: rgba(255, 255, 255, 0.9);
    font-size: 80px;
    line-height: 1;
    z-index: 50;
    pointer-events: none;
    opacity: 0;
    filter: drop-shadow(0 4px 12px rgba(0, 0, 0, 0.5));
}

.heart-popup.animate {
    animation: heart-pop 0.8s cubic-bezier(0.17, 0.89, 0.32, 1.28) forwards;
}

@keyframes heart-pop {
    0% {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0);
    }

    15% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1.2);
    }

    30% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }

    70% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }

    100% {
        opacity: 0;
        transform: translate(-50%, -60%) scale(1.1);
    }
}
 
 

/* === Instagram Layout Variables and Overrides === */
.insta-sidebar {
    position: fixed;
    top: 65px;
    left: 0;
    width: 244px;
    height: calc(100vh - 65px);
    background-color: var(--universe-bg);
    border-right: 1px solid var(--universe-border);
    display: flex;
    flex-direction: column;
    padding: 20px 12px;
    z-index: 1020;
    transition: transform 0.3s ease, width 0.3s ease;
    overflow-y: auto;
}

.insta-sidebar::-webkit-scrollbar {
    display: none;
}
.insta-sidebar {
    -ms-overflow-style: none;  /* IE and Edge */
    scrollbar-width: none;  /* Firefox */
}

.insta-sidebar-header {
    padding: 10px 12px 30px;
    display: flex;
    align-items: center;
}

.insta-logo {
    font-size: 24px;
    font-weight: 700;
    color: var(--universe-text);
    text-decoration: none;
    letter-spacing: 0.5px;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    display: flex;
    align-items: center;
    gap: 8px;
}
.insta-logo i {
    font-size: 28px;
    color: var(--universe-primary);
}

.insta-sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex-grow: 1;
}

.insta-nav-item {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 12px;
    text-decoration: none !important;
    color: var(--universe-text) !important;
    border-radius: 8px;
    transition: background-color 0.2s ease, transform 0.2s ease;
}

.insta-nav-item i {
    font-size: 26px;
    transition: transform 0.2s ease;
}

.insta-nav-item span {
    font-size: 16px;
    font-weight: 400;
    white-space: nowrap;
}

/* Hover and Active States */
.insta-nav-item:hover {
    background-color: rgba(0,0,0,0.05);
}

.insta-nav-item:hover i {
    transform: scale(1.05);
}

.insta-nav-item:active {
    transform: scale(0.97);
}

.insta-nav-item.active {
    font-weight: 700;
}

.insta-nav-item.active i {
    transform: scale(1.05);
}

.insta-nav-item.active span {
    font-weight: 700;
}

.insta-sidebar-footer {
    padding-top: 20px;
    border-top: 1px solid var(--universe-border);
    margin-top: auto;
}

/* Main Dynamic Content Area */
.insta-main-content {
    margin-left: 244px;
    min-height: 100vh;
    position: relative;
    padding: 40px 20px;
    max-width: 935px; /* Common Instagram wrapper width */
    margin-right: auto;
    transition: margin-left 0.3s ease;
}

/* Specific inner content overrides for Universe components */
.insta-main-content .universe-container {
    max-width: 100%;
    padding: 0;
}

/* Mobile & Tablet Toggle Elements */
.insta-menu-toggle {
    display: none;
    position: fixed;
    top: 15px;
    left: 15px;
    z-index: 1030;
    background-color: var(--universe-bg);
    border: 1px solid var(--universe-border);
    color: var(--universe-text);
    font-size: 28px;
    cursor: pointer;
    width: 44px;
    height: 44px;
    border-radius: 8px;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.insta-sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: calc(100vh - 65px);
    background-color: rgba(0, 0, 0, 0.6);
    z-index: 1010;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    cursor: pointer;
}

/* Tablet view styling */
@media (max-width: 1024px) {
    .insta-sidebar {
        width: 72px; /* collapsed left sidebar mode */
        align-items: center;
        padding-top: 20px;
    }
    
    .insta-sidebar-header {
        padding: 5px 0 25px 0;
    }
    
    .insta-sidebar-header span {
        display: none;
    }

    .insta-nav-item span {
        display: none; /* hide labels */
    }

    .insta-nav-item {
        justify-content: center;
        padding: 14px;
        width: 100%;
        margin-bottom: 5px;
    }

    .insta-main-content {
        margin-left: 72px; 
    }
    
    .insta-sidebar-footer {
        padding-top: 10px;
        border-top: none;
        width: 100%;
    }
}

/* Mobile perspective */
@media (max-width: 768px) {
    .insta-sidebar {
        /* Full slide-out behaviour offscreen */
        transform: translateX(-100%);
        width: 244px;
        align-items: flex-start;
        padding: 20px 12px;
    }
    
    .insta-sidebar-header {
        padding: 10px 12px 30px;
        display: flex;
    }
    
    .insta-sidebar-header span {
        display: inline;
    }

    .insta-nav-item span {
        display: inline-block;
    }
    
    .insta-nav-item {
        justify-content: flex-start;
        width: 100%;
    }
    
    .insta-sidebar-footer {
        padding-top: 20px;
        border-top: 1px solid var(--universe-border);
        width: 100%;
    }

    .insta-main-content {
        margin-left: 0;
        padding-top: 80px; 
    }

    .insta-menu-toggle {
        display: flex;
    }

    .insta-sidebar.open {
        transform: translateX(0); /* slide in */
    }

    .insta-sidebar-overlay {
        display: block; /* present in DOM */
    }

    .insta-sidebar-overlay.show {
        visibility: visible;
        opacity: 1; /* trigger fade overlay effect */
    }
}

/* Added for Profile Link Active State */
.profile-active-ring {
    border: 2px solid var(--universe-text) !important;
}


/* ADVANCED ANIMATIONS AND INTERACTIVE FIXES */

/* Fix pointer events blocking clicks when sidebar is closed */
.insta-sidebar-overlay {
    pointer-events: none; /* Crucial fix for unclickable elements */
}

.insta-sidebar-overlay.show {
    pointer-events: auto; /* Re-enable clicks when overlay is active */
    backdrop-filter: blur(2px); /* Add a subtle blur effect for a premium feel */
}

/* Fancy Hover Effects for Navigation Items */
.insta-nav-item {
    position: relative;
    overflow: hidden; /* For ripple or slide effects */
}

/* Add an Instagram-like subtle slide background on hover */
.insta-nav-item::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    background-color: rgba(0, 0, 0, 0.04);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    transition: width 0.4s ease, height 0.4s ease;
    z-index: -1;
}

.insta-nav-item:hover::before {
    width: 200%;
    height: 200%;
}

/* Menu Toggle Button Enhancement */
.insta-menu-toggle {
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275), background-color 0.2s;
}

.insta-menu-toggle:hover {
    transform: scale(1.08); /* Bouncy hover scale */
    background-color: var(--universe-bg);
}

.insta-menu-toggle:active {
    transform: scale(0.92);
}

/* Sidebar Slide Animation Enhancement */
.insta-sidebar {
    transition: transform 0.4s cubic-bezier(0.19, 1, 0.22, 1), width 0.3s ease; /* Snappier, smoother slide out */
}

/* Add a subtle shadow when sidebar is open on mobile */
@media (max-width: 768px) {
    .insta-sidebar.open {
        box-shadow: 4px 0 24px rgba(0,0,0,0.15);
    }
}

/* Fix overlap for main content based on top navbar */
.insta-main-content {
    /* Set margin to prevent overlap */
    margin-left: 244px;
    padding-top: 40px !important;
}

@media (max-width: 1024px) {
    .insta-main-content {
        margin-left: 72px;
    }
}

@media (max-width: 768px) {
    .insta-main-content {
        margin-left: 0;
        padding-top: 80px !important;
    }
}

/* Base top position relative to new parent container Navbar */
.insta-sidebar {
    /* Offset by the height of the modern top navbar */
    top: 65px; 
    height: calc(100vh - 65px);
}
@media (max-width: 991px) { /* Match standard Bootstrap navbar breakpoint */
    .insta-sidebar {
        top: 0;
        height: 100vh;
    }
}
