/* =========================================
   LAYER 6: COMPONENTS -> CARDS
   Smart Minimal Glass Cards
   ========================================= */

.card,
.panel {
    background: var(--bg-glass);
    backdrop-filter: var(--blur-md);
    -webkit-backdrop-filter: var(--blur-md);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-xl);
    /* 24px for modern feel */
    padding: var(--space-5);
    margin-bottom: var(--space-6);
    box-shadow: var(--shadow-sm);
    transition: transform var(--transition-fast), box-shadow var(--transition-fast);
    position: relative;
    overflow: hidden;
}

/* Glass Variant (Stronger) */
.card-glass {
    background: var(--bg-glass-heavy);
    box-shadow: var(--shadow-lg);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

/* Hover Effect (Subtle Lift) */
.card:hover {
    box-shadow: var(--shadow-md);
    border-color: var(--color-gray-300);
}

/* Header/Body/Footer Structure */
.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-4);
    padding-bottom: var(--space-2);
    border-bottom: 1px solid transparent;
    /* Hidden by default */
}

.card-title {
    font-size: var(--text-lg);
    font-weight: var(--weight-bold);
    margin: 0;
}

/* .card-body {
    Default spacing
} */

.card-footer {
    margin-top: var(--space-4);
    padding-top: var(--space-3);
    border-top: 1px solid var(--color-gray-100);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

/* --- RADIANT FLOW FEED CARDS --- */
.feed-item {
    scroll-snap-align: start;
    height: 100vh;
    width: 100%;
    position: relative;
    display: flex;
    flex-direction: column;
    /* Mobile Default */
    justify-content: center;
    align-items: center;
    padding: 0;
    box-sizing: border-box;
    /* Ensure no background/border on wrapper */
    background: transparent;
    border: none;
    box-shadow: none;
    gap: 0;
    /* Space between card and comments on desktop */
}

@media (min-width: 1200px) {
    .feed-item {
        flex-direction: row;
        align-items: center;
        padding: 20px;
        gap: 20px;
        /* Center vertically on desktop too */
        /* Gap removed: Comments are now Fixed Overlay */
    }
}

.r-card {
    width: 100%;
    height: 100%;
    max-width: none;
    max-height: 92vh;
    /* Removed Visual Styles - Now in Wrapper */
    background: transparent;
    box-shadow: none;
    position: relative;
    overflow: visible !important;
    /* Allow buttons to float out */
    display: flex;
    flex-direction: column;
}

/* ---- MASTER TIKTOK NATIVE APP ARCHITECTURE ---- */
@media (max-width: 1199px) {

    /* 1. Viewport Foundation (Scroll Locked Flex Column) */
    .feed-item {
        height: 100vh !important;
        height: 100dvh !important;
        /* Fill viewport completely to prevent body background bleed */
        /* Cushion for the bottom nav bar dynamically matching iOS safe areas */
        padding-bottom: calc(85px + env(safe-area-inset-bottom, 0px)) !important;
        width: 100vw !important;
        overflow: hidden !important;
        scroll-snap-align: start !important;
        position: relative !important;
        display: flex !important;
        flex-direction: column !important;
        background: #fff !important;
        margin: 0 !important;
        border: none !important;
        box-sizing: border-box !important;
    }

    /* Force the entire feed container to be white to prevent ANY grey bleed from body */
    #feed-contenido,
    .col-feed {
        background: #fff !important;
    }

    /* 2. Intelligent Suggestion Module */
    /* Instead of hiding it, we let it flow naturally in the flex column.
       If it exists, .r-card will flex to fill the remaining visual space. */
    .interstitial-global-module {
        flex-shrink: 0 !important;
        /* Do not crush the suggestion module */
        width: 100% !important;
        display: block !important;
        margin: 0 !important;
        background: #fff !important;
        position: relative !important;
        z-index: 20 !important;
    }

    /* 3. The Dynamic Flex Core */
    .r-card {
        position: relative !important;
        flex: 1 !important;
        /* Fill all remaining space not used by suggestion modules */
        min-height: 0 !important;
        /* Allow flex shrinking vertically past min-content */
        width: 100% !important;
        margin: 0 !important;
        padding: 0 !important;
        border: none !important;
        border-radius: 0 !important;
        background: transparent !important;
        display: flex !important;
        flex-direction: column !important;
    }

    /* FIX: The -35px offset bug */
    .r-card .r-card-content {
        position: relative !important;
        top: 0 !important;
        left: 0 !important;
        flex: 1 !important;
        /* Fill .r-card */
        min-height: 0 !important;
        width: 100% !important;
        margin: 0 !important;
        padding: 0 !important;
        border: none !important;
        border-radius: 0 !important;
        background: transparent !important;
        display: flex !important;
        flex-direction: column !important;
    }

    /* Media Shell */
    .vis-media-shell {
        position: relative !important;
        flex: 1 !important;
        min-height: 0 !important;
        width: 100% !important;
        margin: 0 !important;
        padding: 0 !important;
        background: transparent !important;
        /* Let the container background show through */
        display: flex !important;
        flex-direction: column !important;
        align-items: center !important;
        justify-content: center !important;
    }

    .image-container,
    .video-container {
        position: relative !important;
        flex: 1 !important;
        min-height: 0 !important;
        width: 100% !important;
        background: transparent !important;
        display: grid !important;
        place-items: center !important;
    }

    /* The visual media perfectly framed AND centered */
    .vis-media {
        width: 100% !important;
        max-width: 100% !important;
        height: auto !important;
        max-height: 100% !important;
        /* Never overflow containing block */
        object-fit: contain !important;
        /* Zero crop */
        position: relative !important;
        border-radius: 0 !important;
        margin: 0 auto !important;
        display: block !important;
    }

    /* Override inline rounded corners strictly for primary feed content boxes */
    .media-text-section,
    .feed-item [class*="bg-gradient-"],
    .interstitial-global-module>div {
        border-radius: 0 !important;
    }

    /* 4. Cinematic Dark Gradient - REMOVED PER USER REQUEST */
    .r-card-content::after {
        display: none !important;
    }

    /* 5. Left Side - Text & Creator */
    .pub-t-content,
    .pub-long-body {
        position: absolute !important;
        bottom: calc(20px + env(safe-area-inset-bottom, 10px)) !important;
        left: 15px !important;
        /* Dynamic width limit to absolutely protect the right-side actions from text overlap */
        width: calc(100% - 90px) !important;
        z-index: 10 !important;
        color: #ffffff !important;
        text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8), 0 2px 8px rgba(0, 0, 0, 0.5) !important;
        text-align: left !important;
        padding: 0 !important;
        margin: 0 !important;
        background: transparent !important;
    }

    /* Target h1 specifically to ensure it's white with shadow */
    .pub-t-content h1,
    .pub-long-body h1,
    .vis-h1 {
        color: #ffffff !important;
        text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8), 0 2px 8px rgba(0, 0, 0, 0.5) !important;
    }

    .creator-badge {
        position: absolute !important;
        top: calc(20px + env(safe-area-inset-top, 0px)) !important;
        left: 15px !important;
        z-index: 10 !important;
        background: rgba(0, 0, 0, 0.4) !important;
        backdrop-filter: blur(12px) !important;
        -webkit-backdrop-filter: blur(12px) !important;
        border: 1px solid rgba(255, 255, 255, 0.15) !important;
        box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2) !important;
        color: #ffffff !important;
    }

    .creator-badge .cb-name {
        color: #ffffff !important;
        text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6) !important;
    }

    .creator-badge .cb-follow {
        color: var(--color-accent, #FF2E63) !important;
    }

    .rc-music-pill {
        display: none !important;
    }

    /* 6. Right Side - Floating Actions (Minimalist Clear Style) */
    .r-actions {
        position: absolute !important;
        right: 12px !important;
        bottom: calc(35px + env(safe-area-inset-bottom, 10px)) !important;
        top: auto !important;
        left: auto !important;
        display: flex !important;
        flex-direction: column !important;
        justify-content: flex-end !important;
        align-items: center !important;
        gap: 24px !important;
        z-index: 15 !important;
        background: transparent !important;
        border: none !important;
        box-shadow: none !important;
        width: 60px !important;
        padding: 0 !important;
    }

    .act-btn {
        width: 100% !important;
        height: auto !important;
        background: transparent !important;
        border: none !important;
        box-shadow: none !important;
        display: flex !important;
        flex-direction: column !important;
        align-items: center !important;
        gap: 6px !important;
        padding: 0 !important;
        margin: 0 !important;
    }

    .act-icon {
        width: 44px !important;
        height: 44px !important;
        border-radius: 0 !important;
        background: transparent !important;
        backdrop-filter: none !important;
        -webkit-backdrop-filter: none !important;
        border: none !important;
        box-shadow: none !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
    }

    .act-icon i {
        color: #ffffff !important;
        font-size: 1.8rem !important;
        text-shadow: none !important;
        filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.2)) !important;
    }

    .act-btn.active .act-icon i {
        color: #ff2e63 !important;
        text-shadow: 0 2px 10px rgba(255, 46, 99, 0.4) !important;
    }

    .act-lbl {
        color: #ffffff !important;
        font-size: 0.8rem !important;
        font-weight: 700 !important;
        text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2) !important;
        margin: 0 !important;
    }

    .act-lbl:not(.action-count) {
        display: none !important;
    }

    /* Hide any random elements like comments container or form that might pop up */
    .comment-input-area,
    .feed-comments-container {
        display: none !important;
    }
}

@media (min-width: 1200px) {
    .r-card {
        max-width: 600px;
        margin: 0 auto;
        position: static;
        /* Surrender relative context to .feed-item so action buttons can center to the absolute 100vh viewport */
    }

    .interstitial-global-module {
        margin: 0 auto;
        /* Restore standard horizontal centering strictly for wider desktop viewports */
    }
}

/* Inner Content Wrapper (The real "Card") */
.r-card-content {
    background: white;
    border-radius: 0;
    box-shadow: none;
    /* Shadow is here now */
    overflow: hidden;
    /* Inline styles handling size/position, repeated here for robustness */
    width: 100%;
    height: 100%;
    position: relative;
    top: -35px;
    /* Pull up to clear bottom nav */
    display: flex;
    flex-direction: column;
}

@media (min-width: 1200px) {
    .r-card-content {
        border-radius: 30px;
        box-shadow: 0 20px 60px rgba(0, 0, 0, 0.08);
        top: 0;
        /* Reset for desktop */
    }
}

/* INTERACTIONS OVERLAY */
.r-actions {
    position: absolute;
    right: 15px;
    /* Default Mobile: Inside */
    bottom: 15px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    z-index: 10;
}

/* Move OUTSIDE on Desktop */
@media (min-width: 1200px) {
    .r-actions {
        left: calc(50% + 325px);
        /* 300px (half card) + exactly 25px margin */
        bottom: auto;
        /* Override mobile bottom positioning */
        top: 50%;
        /* Push to middle */
        transform: translateY(-50%);
        /* Perfectly center vertically relative to the fixed 100vh .feed-item parent */
        z-index: 5;
    }

}

.act-btn {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(10px);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
    cursor: pointer;
    transition: 0.2s;
}

.act-btn:hover {
    transform: scale(1.1);
    background: white;
}

.act-icon {
    font-size: 1.4rem;
    line-height: 1;
    margin-bottom: 0;
    transition: filter 0.3s ease, transform 0.2s ease;
}

/* Specific to Like Button: Default is Grey */
.like-btn .act-icon {
    filter: grayscale(100%) contrast(0.5);
    opacity: 0.7;
}

.act-lbl {
    font-size: 0.6rem;
    font-weight: 700;
    margin-top: 2px;
    color: #333;
}

/* Active State (e.g. Liked) */
.act-btn.active {
    box-shadow: 0 5px 20px rgba(255, 46, 99, 0.4);
    background: white;
}

.act-btn.active .act-icon {
    animation: pulse-heart 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
    filter: grayscale(0%) contrast(1);
    opacity: 1;
}

/* CREATOR BADGE */
.creator-badge {
    position: absolute;
    top: 20px;
    left: 20px;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(10px);
    padding: 5px 15px 5px 5px;
    border-radius: 30px;
    display: flex;
    align-items: center;
    gap: 10px;
    z-index: 20;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}

.cb-av {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background-size: cover;
    background-position: center;
}

.cb-name {
    font-weight: 700;
    font-size: 0.9rem;
    color: #333;
    text-decoration: none;
}

.cb-follow {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--color-accent);
    text-transform: uppercase;
    cursor: pointer;
}

/* =========================================
   TEXT POST BACKGROUND COLORS (INSTAGRAM STYLE)
   ========================================= */
.bg-gradient-insta {
    background: linear-gradient(45deg, #f09433 0%, #e6683c 25%, #dc2743 50%, #cc2366 75%, #bc1888 100%) !important;
}

.bg-gradient-ocean {
    background: linear-gradient(45deg, #02aab0, #00cdac) !important;
}

.bg-gradient-midnight {
    background: linear-gradient(45deg, #232526, #414345) !important;
}

.bg-gradient-sunset {
    background: linear-gradient(45deg, #ff512f, #dd2476) !important;
}

.bg-gradient-purple {
    background: linear-gradient(45deg, #DA22FF, #9733EE) !important;
}

.bg-gradient-green {
    background: linear-gradient(45deg, #11998e, #38ef7d) !important;
}

/* Ensure text is white and legible inside these gradients */
.feed-item [class*="bg-gradient-"] p,
.feed-item [class*="bg-gradient-"] a.hashtag,
.feed-item [class*="bg-gradient-"] .text-mentioned {
    color: #ffffff !important;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

.feed-item [class*="bg-gradient-"] {
    color: #ffffff !important;
    min-height: 250px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    border-radius: 12px;
    padding: 30px 20px !important;
    text-align: center;
    margin: 10px 0;
}

.feed-item [class*="bg-gradient-"] p,
.feed-item [class*="bg-gradient-"] .p-desc-text {
    font-size: 1.5rem !important;
    font-weight: 700 !important;
    line-height: 1.3 !important;
}

/* Post Composer Modal Fixes & Text Sizing */
.rc-text-input.grand {
    font-size: 1.8rem;
    line-height: 1.25;
}

.rc-text-input.medium {
    font-size: 1.3rem;
    line-height: 1.4;
}

.rc-text-input.small {
    font-size: 1rem;
    line-height: 1.5;
}

/* Post Composer Modal Fixes */
.rc-text-input.has-bg::placeholder {
    color: rgba(255, 255, 255, 0.9) !important;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

.rc-text-input.has-bg {
    caret-color: #ffffff;
}