/* Portal Layout & UI styles */
:root {
    --purple-primary: #9828c8;
    --purple-dark: #6d28d9;
    --purple-light: #f3e8ff;
    --bg-canvas: #f8f7fb;
    --card-bg: #ffffff;
    --text-main: #1e1731;
    --text-muted: #716b80;
    --border-color: #e9e5ef;
    --sidebar-width: 260px;
    --header-height: 68px;
}

.portal-wrapper {
    display: flex;
    min-height: 100vh;
    width: 100%;
    overflow-x: hidden;
    background: var(--bg-canvas);
    color: var(--text-main);
    font-family: 'Inter', sans-serif;
}

/* Sidebar */
.portal-sidebar {
    width: var(--sidebar-width);
    background: #ffffff;
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 100;
    transition: transform 0.3s ease;
}

.sidebar-header {
    height: var(--header-height);
    display: flex;
    align-items: center;
    padding: 0 24px;
    border-bottom: 1px solid var(--border-color);
}

.sidebar-logo {
    height: 38px;
}

.sidebar-nav {
    flex: 1;
    padding: 24px 16px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    overflow-y: auto;
}

.nav-section-title {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 1px;
    color: var(--text-muted);
    padding: 12px 12px 6px 12px;
    text-transform: uppercase;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-muted);
    text-decoration: none;
    transition: all 0.2s;
}

.nav-item:hover {
    background: var(--purple-light);
    color: var(--purple-primary);
}

.nav-item.active {
    background: linear-gradient(135deg, var(--purple-primary), var(--purple-dark));
    color: #ffffff;
    box-shadow: 0 4px 12px rgba(152, 40, 200, 0.25);
}

.nav-item.active svg {
    stroke: #ffffff;
}

.sidebar-user {
    padding: 16px;
    border-top: 1px solid var(--border-color);
    background: #faf9fd;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.user-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
    overflow: hidden;
}

.user-name {
    font-size: 13px;
    font-weight: 700;
    color: var(--text-main);
    white-space: nowrap;
    text-overflow: ellipsis;
    overflow: hidden;
}

.user-code {
    font-size: 11px;
    font-weight: 600;
    color: var(--purple-primary);
}

/* Main Content Area */
.portal-main {
    flex: 1;
    min-width: 0;
    margin-left: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.portal-topbar {
    height: var(--header-height);
    background: #ffffff;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 32px;
    position: sticky;
    top: 0;
    z-index: 90;
}

.topbar-title {
    font-size: 18px;
    font-weight: 800;
    color: var(--text-main);
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 16px;
}

.topbar-heading {
    display: flex;
    align-items: center;
    min-width: 0;
    gap: 12px;
}

.topbar-welcome {
    font-size: 13px;
    color: #716b80;
    font-weight: 600;
}

.mobile-menu-btn,
.portal-sidebar-backdrop {
    display: none;
}

.btn-logout {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: transparent;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.2s;
}

.btn-logout:hover {
    border-color: #dc2626;
    color: #dc2626;
    background: #fef2f2;
}

.portal-body {
    flex: 1;
    padding: 32px;
}

.portal-auth-loading { min-height:55vh;display:flex;align-items:center;justify-content:center;flex-direction:column;gap:12px;color:#716b80;font-size:13px; }
.portal-auth-loading span { width:32px;height:32px;border:3px solid #eadff0;border-top-color:#9828c8;border-radius:50%;animation:portalAuthSpin .75s linear infinite; }
@keyframes portalAuthSpin { to { transform:rotate(360deg); } }

@media (max-width: 900px) {
    .portal-sidebar {
        transform: translateX(-100%);
        width: min(82vw, 280px);
        box-shadow: 12px 0 30px rgba(30, 23, 49, 0.14);
    }
    .portal-sidebar.open {
        transform: translateX(0);
    }
    .portal-main {
        margin-left: 0;
        width: 100%;
    }
    .mobile-menu-btn {
        display: inline-grid;
        place-items: center;
        width: 40px;
        height: 40px;
        flex: 0 0 40px;
        padding: 0;
        border: 1px solid var(--border-color);
        border-radius: 10px;
        background: #ffffff;
        color: var(--text-main);
        cursor: pointer;
    }
    .portal-sidebar-backdrop {
        display: block;
        position: fixed;
        inset: 0;
        z-index: 99;
        padding: 0;
        border: 0;
        background: rgba(30, 23, 49, 0.42);
    }
    .portal-topbar {
        padding: 0 20px;
    }
    .portal-body {
        padding: 24px 20px;
    }
}

@media (max-width: 600px) {
    :root { --header-height: 60px; }
    .portal-topbar { padding: 0 12px; }
    .portal-body { padding: 16px 12px 24px; }
    .topbar-title { font-size: 15px; white-space: nowrap; }
    .topbar-welcome { display: none; }
    .topbar-actions { gap: 6px; }
    .topbar-actions .btn-logout { padding: 8px 10px; font-size: 12px; }
    .sidebar-header { padding: 0 18px; }
    .sidebar-nav { padding: 14px 12px; }
}

/* Per-member first-visit announcement */
.member-announcement-overlay {
    position: fixed;
    inset: 0;
    z-index: 2000;
    display: grid;
    place-items: center;
    padding: 24px;
    background: rgba(20, 13, 28, 0.72);
    backdrop-filter: blur(6px);
    animation: memberAnnouncementFade 180ms ease-out;
}

.member-announcement-dialog {
    position: relative;
    width: min(94vw, 960px);
    max-height: 90vh;
    padding: 8px;
    border: 1px solid rgba(255, 255, 255, 0.35);
    border-radius: 18px;
    background: #ffffff;
    box-shadow: 0 30px 90px rgba(14, 7, 22, 0.4);
    animation: memberAnnouncementEnter 220ms ease-out;
}

.member-announcement-dialog img {
    display: block;
    width: 100%;
    max-height: calc(90vh - 16px);
    border-radius: 12px;
    object-fit: contain;
}

.member-announcement-close {
    position: absolute;
    top: -15px;
    right: -15px;
    z-index: 1;
    display: grid;
    place-items: center;
    width: 38px;
    height: 38px;
    padding: 0;
    border: 3px solid #ffffff;
    border-radius: 50%;
    background: #1e1731;
    color: #ffffff;
    font: 700 24px/1 Arial, sans-serif;
    cursor: pointer;
    box-shadow: 0 6px 18px rgba(20, 13, 28, 0.3);
    transition: transform 150ms ease, background 150ms ease;
}

.member-announcement-close:hover {
    background: #9828c8;
    transform: scale(1.06);
}

.member-announcement-close:focus-visible {
    outline: 3px solid #f3e8ff;
    outline-offset: 2px;
}

@keyframes memberAnnouncementFade {
    from { opacity: 0; }
}

@keyframes memberAnnouncementEnter {
    from { opacity: 0; transform: translateY(12px) scale(0.98); }
}

@media (max-width: 600px) {
    .member-announcement-overlay { padding: 14px; }
    .member-announcement-dialog { width: 100%; padding: 5px; border-radius: 13px; }
    .member-announcement-dialog img { max-height: calc(88vh - 10px); border-radius: 9px; }
    .member-announcement-close { top: -12px; right: -8px; width: 36px; height: 36px; }
}
