/* /portal/css/portal.css */

/* --- Base Layout & Grid --- */
html,
body.portal-body {
    height: 100%;
    margin: 0;
    overflow: hidden;
    /* Stop the whole page from scrolling */
    background-color: var(--portal-background);
    color: var(--text-primary);
}

/* Base container for all portal pages */
.portal-grid-container {
    width: 100%;
    height: 100%;
    /* Fill viewport */
    max-width: 100%;
    margin: 0;
    display: flex;
    justify-content: center;
    overflow: hidden;
}

/* The main area becomes a Flex Column */
.portal-main-area {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: hidden;
    /* Contains the scroll within children */

    /* NEW: Add a subtle sales-friendly background gradient */
    background: radial-gradient(circle at 0% 0%, rgba(52, 152, 219, 0.08) 0%, transparent 50%),
                radial-gradient(circle at 100% 0%, rgba(24, 119, 242, 0.05) 0%, transparent 40%);
}

/* NEW: Decorative Blobs for "Pop" */
.portal-main-area::before {
    content: '';
    position: absolute;
    top: -10vh;
    left: -10vw;
    width: 50vw;
    height: 50vw;
    background: radial-gradient(circle, rgba(52, 152, 219, 0.1) 0%, transparent 70%);
    border-radius: 50%;
    pointer-events: none;
    z-index: 0;
}

/* --- Main 3-Column Layout (Desktop) --- */
/* This is now the SCROLLABLE container */
.content-grid {
    flex-grow: 1;
    /* Takes all remaining space */
    overflow-y: auto;
    /* Adds scrollbar here, not on body */
    overflow-x: hidden;

    /* Grid Setup */
    display: grid;
    grid-template-columns: 100%;
    gap: 25px;

    /* Crucial: Padding to ensure content isn't hidden behind fixed navs */
    padding-top: 15px;
    padding-bottom: 100px;
    /* Space for Mobile Nav */
    padding-left: 15px;
    padding-right: 15px;

    position: relative;
    z-index: 1; /* Ensure content sits above background blobs */
}

.main-column {
    order: 2;
}

.side-column {
    order: 1;
}

/* --- Reusable Card Styles --- */
.portal-card {
    background: var(--card-background);
    border-radius: var(--border-radius);
    margin-bottom: 20px;
    border: 1px solid rgba(255, 255, 255, 0.5); /* Glassy border */
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.05); /* Softer, larger shadow for depth */
    flex-shrink: 0;
    /* Prevent crushing */
    position: relative;
    overflow: hidden;
}

.portal-card .card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    border-bottom: 1px solid var(--border-light);
    background: #ffffff; /* Ensure header is solid */
}

.portal-card .card-header h4 {
    margin: 0;
    font-size: 18px;
    font-weight: 700;
}

.portal-card .card-header a {
    font-size: 14px;
    font-weight: 500;
    text-decoration: none;
    color: var(--primary-accent);
    transition: color 0.2s ease;
}

.portal-card .card-header a:hover {
    color: #1a8cd8;
}

.portal-card .card-content {
    padding: 20px;
}

/* --- General Helper Styles --- */
.help-text-widget {
    font-size: 14px;
    color: var(--text-secondary);
    line-height: 1.6;
    margin: 0;
}

.help-text-widget i {
    color: var(--primary-accent);
    margin-inline-end: 8px;
}

/* --- TOAST NOTIFICATIONS --- */
#toast-container {
    position: fixed;
    bottom: 80px;
    /* Above mobile nav */
    right: 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    z-index: 2000;
    pointer-events: none;
}

[dir="rtl"] #toast-container {
    right: auto;
    left: 20px;
}

.toast {
    background: #333;
    color: white;
    padding: 12px 20px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 14px;
    font-weight: 500;
    opacity: 0;
    transform: translateY(20px);
    transition: all 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    pointer-events: auto;
    min-width: 250px;
}

.toast.show {
    opacity: 1;
    transform: translateY(0);
}

.toast i {
    font-size: 18px;
}

.toast.success i {
    color: #2ecc71;
}

.toast.info i {
    color: #3498db;
}

.toast.error i {
    color: #e74c3c;
}

/* --- INSTAGRAM-STYLE STORY VIEWER --- */
/* (Kept identical to previous version, ensuring z-index is high) */
#story-viewer-overlay {
    position: fixed;
    inset: 0;
    background: #1a1a1a;
    z-index: 3000;
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease-in-out;
}

#story-viewer-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.story-viewer-container {
    width: 100%;
    height: 100%;
    position: relative;
    background: #000;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 0 50px rgba(0, 0, 0, 0.5);
}

.story-content-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    position: absolute;
    inset: 0;
    z-index: 1;
}

.story-viewer-container::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 100px;
    background: linear-gradient(to bottom, rgba(0, 0, 0, 0.6), transparent);
    z-index: 2;
}

.story-viewer-container::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 150px;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.8), transparent);
    z-index: 2;
}

.story-progress-container {
    position: absolute;
    top: 15px;
    left: 10px;
    right: 10px;
    display: flex;
    gap: 4px;
    z-index: 10;
    height: 2px;
}

.story-progress-segment {
    background: rgba(255, 255, 255, 0.3);
    flex: 1;
    border-radius: 2px;
    overflow: hidden;
    height: 100%;
}

.story-progress-fill {
    height: 100%;
    background: white;
    width: 0%;
    transition: width 0s;
}

.story-progress-segment.completed .story-progress-fill {
    width: 100%;
}

.story-progress-segment.active .story-progress-fill {
    transition: width 4s linear;
    width: 100%;
}

.story-header {
    position: absolute;
    top: 25px;
    left: 15px;
    right: 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 10;
    color: white;
}

.story-user-info {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
}

.story-user-info img {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 1px solid rgba(255, 255, 255, 0.5);
}

.story-text-info {
    display: flex;
    flex-direction: column;
    line-height: 1.1;
}

.story-username {
    font-weight: 600;
    font-size: 14px;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

.story-time {
    font-size: 11px;
    opacity: 0.8;
    font-weight: 400;
}

.story-close-btn {
    background: none;
    border: none;
    color: white;
    font-size: 24px;
    cursor: pointer;
    opacity: 0.8;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: flex-end;
}

.story-close-btn:hover {
    opacity: 1;
}

.story-nav-zone {
    position: absolute;
    top: 70px;
    bottom: 80px;
    z-index: 5;
}

.story-nav-left {
    left: 0;
    width: 30%;
}

.story-nav-right {
    right: 0;
    width: 30%;
}

.story-footer {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 10;
    padding: 15px;
    display: flex;
    align-items: center;
    gap: 15px;
}

.story-reply-input {
    flex-grow: 1;
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.6);
    border-radius: 25px;
    padding: 12px 20px;
    color: white;
    font-size: 14px;
    outline: none;
    backdrop-filter: blur(5px);
}

.story-reply-input::placeholder {
    color: rgba(255, 255, 255, 0.7);
}

.story-reply-input:focus {
    border-color: white;
    background: rgba(0, 0, 0, 0.2);
}

.story-footer-btn {
    background: none;
    border: none;
    color: white;
    font-size: 24px;
    cursor: pointer;
    transition: transform 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.story-footer-btn:active {
    transform: scale(0.8);
}

.story-footer-btn.liked {
    color: #e74c3c;
    animation: pop 0.3s ease;
}


/* --- DESKTOP STYLES (min-width: 992px) --- */
@media (min-width: 992px) {

    /* Main area shifts right to accommodate fixed sidebar */
    .portal-main-area {
        width: calc(100% - 280px);
        transition: margin-inline-start 0.3s ease;
    }

    [dir="ltr"] .portal-main-area {
        margin-left: 280px;
    }

    [dir="rtl"] .portal-main-area {
        margin-right: 280px;
    }

    .content-grid {
        /* Grid Layout */
        grid-template-columns: minmax(0, 1fr) 340px;
        padding: 30px;
        gap: 30px;
        padding-bottom: 30px;
        /* No bottom nav needed */
    }

    .main-column,
    .side-column {
        order: initial;
    }

    /* Toast positioning desktop */
    #toast-container {
        bottom: 30px;
        right: 30px;
    }

    [dir="rtl"] #toast-container {
        right: auto;
        left: 30px;
    }

    /* Story Viewer desktop size */
    .story-viewer-container {
        height: 85vh;
        aspect-ratio: 9 / 18;
        width: auto;
        border-radius: 16px;
    }
}

@media (max-width: 991px) {

    /* Ensure content grid stacks */
    .content-grid {
        grid-template-columns: 100%;
        display: block;
        /* Fallback to block stacking for mobile */
    }

    .main-column {
        margin-bottom: 20px;
    }
}