/* =============================================
   PORTAL SIDEBAR NAVIGATION
   portal-sidebar.css
   ============================================= */

/* ===== iOS OVERSCROLL FIX (Capacitor App) ===== */
html.is-capacitor {
    overscroll-behavior: none;
    overflow: hidden;
    height: 100%;
}

body.is-capacitor {
    overflow-y: auto;
    height: 100%;
    overscroll-behavior-y: none;
    -webkit-overflow-scrolling: touch;
}

/* ===== SIDEBAR - DESKTOP ===== */
.portal-layout {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 260px;
    background: rgba(255, 255, 255, 0.55);
    backdrop-filter: blur(40px);
    -webkit-backdrop-filter: blur(40px);
    border-right: 1px solid rgba(255, 255, 255, 0.4);
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 100;
    display: flex;
    flex-direction: column;
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 2px 0 20px rgba(0, 0, 0, 0.04);
    overflow: hidden;
    padding-top: env(safe-area-inset-top, 0px);
}

.sidebar-header {
    padding: 24px 20px 20px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.04);
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    color: #1a1a1a;
}

.sidebar-logo-icon {
    width: 36px;
    height: 36px;
    background: linear-gradient(135deg, #d946ef, #8b5cf6);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
}

.sidebar-logo-icon img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    border-radius: 10px;
}

.sidebar-logo-text {
    font-size: 15px;
    font-weight: 700;
    letter-spacing: -0.3px;
    white-space: nowrap;
    overflow: hidden;
}

.sidebar-logo-text span {
    display: block;
    font-size: 10px;
    font-weight: 500;
    color: #9ca3af;
    letter-spacing: 0;
    margin-top: 1px;
}

/* ===== NAVIGATION ITEMS ===== */
.sidebar-nav {
    padding: 16px 12px;
    overflow-y: auto;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.sidebar-nav-section {
    margin-bottom: 24px;
}

/* Push Account section to bottom */
.sidebar-nav-section:last-child {
    margin-top: auto;
    margin-bottom: 0;
    padding-top: 16px;
    border-top: 1px solid rgba(0, 0, 0, 0.04);
}

.sidebar-nav-label {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: #9ca3af;
    padding: 0 8px;
    margin-bottom: 8px;
}

.sidebar-nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
    color: #6b7280;
    font-size: 13px;
    font-weight: 500;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
    position: relative;
    white-space: nowrap;
    overflow: hidden;
}

.sidebar-nav-item:hover {
    background: rgba(217, 70, 239, 0.06);
    color: #374151;
}

.sidebar-nav-item.active {
    background: linear-gradient(135deg, rgba(217, 70, 239, 0.1), rgba(139, 92, 246, 0.08));
    color: #7c3aed;
    font-weight: 600;
}

.sidebar-nav-item.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 20px;
    background: linear-gradient(135deg, #d946ef, #8b5cf6);
    border-radius: 0 4px 4px 0;
}

.sidebar-nav-icon {
    width: 20px;
    text-align: center;
    font-size: 16px;
    flex-shrink: 0;
}

.sidebar-nav-text {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-nav-badge {
    font-size: 10px;
    font-weight: 700;
    background: linear-gradient(135deg, #d946ef, #8b5cf6);
    color: white;
    padding: 2px 7px;
    border-radius: 10px;
    flex-shrink: 0;
}

/* ===== PORTAL SWITCHER IN SIDEBAR ===== */
.sidebar-portal-switcher {
    padding: 12px;
    margin: 0 12px 8px;
    background: rgba(255, 255, 255, 0.6);
    border: 1px solid rgba(217, 70, 239, 0.08);
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.sidebar-portal-switcher:hover {
    background: rgba(255, 255, 255, 0.9);
    border-color: rgba(217, 70, 239, 0.15);
}

.sidebar-portal-name {
    font-size: 13px;
    font-weight: 600;
    color: #374151;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-portal-date {
    font-size: 10px;
    color: #9ca3af;
    margin-top: 2px;
}

/* ===== SIDEBAR FOOTER ===== */
.sidebar-footer {
    margin-top: auto;
    padding: 16px;
    border-top: 1px solid rgba(0, 0, 0, 0.04);
}

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px;
    border-radius: 10px;
    transition: all 0.2s ease;
}

.sidebar-user:hover {
    background: rgba(0, 0, 0, 0.03);
}

.sidebar-user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: linear-gradient(135deg, #d946ef, #8b5cf6);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 12px;
    font-weight: 700;
    flex-shrink: 0;
}

.sidebar-user-info {
    flex: 1;
    min-width: 0;
    overflow: hidden;
}

.sidebar-user-name {
    font-size: 12px;
    font-weight: 600;
    color: #374151;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-user-email {
    font-size: 10px;
    color: #9ca3af;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-logout-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: #9ca3af;
    font-size: 16px;
    padding: 6px;
    border-radius: 6px;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.sidebar-logout-btn:hover {
    color: #ef4444;
    background: rgba(239, 68, 68, 0.06);
}

/* ===== MAIN CONTENT AREA ===== */
.portal-main {
    flex: 1;
    margin-left: 260px;
    min-height: 100vh;
    transition: margin-left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ===== BOTTOM NAV - APP ONLY (pill style) ===== */
.bottom-nav {
    display: none;
}

body.is-capacitor .bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 200;
    padding: 10px 16px;
    padding-bottom: max(10px, env(safe-area-inset-bottom));
    background: transparent;
    pointer-events: none;
}

body.is-capacitor .bottom-nav-items {
    display: flex;
    justify-content: space-around;
    align-items: center;
    background: #1c1c1e;
    border-radius: 40px;
    padding: 6px 8px;
    max-width: 460px;
    margin: 0 auto;
    pointer-events: all;
    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.25);
}

body.is-capacitor .bottom-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    padding: 8px 16px;
    border-radius: 30px;
    cursor: pointer;
    transition: all 0.2s ease;
    color: rgba(255, 255, 255, 0.55);
    background: none;
    border: none;
    font-size: 11px;
    font-weight: 600;
    -webkit-tap-highlight-color: transparent;
    flex: 1;
}

body.is-capacitor .bottom-nav-item:active {
    transform: scale(0.92);
}

body.is-capacitor .bottom-nav-item.active {
    background: #2c2c2e;
    color: #e879f9;
}

body.is-capacitor .bottom-nav-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

body.is-capacitor .bottom-nav-icon svg {
    width: 22px;
    height: 22px;
}

body.is-capacitor .bottom-nav-label {
    font-size: 10px;
    letter-spacing: 0.2px;
}

/* ===== RESPONSIVE ===== */

/* Tablet - narrower sidebar */
@media (max-width: 1024px) {
    .sidebar {
        width: 220px;
    }
    .portal-main {
        margin-left: 220px;
    }
}

/* Mobile - hide sidebar, show bottom nav */
@media (max-width: 768px) {
    .sidebar {
        display: none;
    }

    .portal-main {
        margin-left: 0;
        padding-top: env(safe-area-inset-top, 0px);
        padding-bottom: 20px;
    }

    /* Bottom nav only shows inside the Capacitor app, not mobile browser */
    body.is-capacitor .bottom-nav {
        display: block;
        padding-bottom: max(10px, env(safe-area-inset-bottom));
    }

    /* Extra bottom space in Capacitor app so content clears the bottom nav */
    body.is-capacitor .portal-main {
        padding-bottom: 120px;
    }

    /* Adjust container padding for mobile */
    .portal-main .container {
        padding: 20px 16px;
    }

    body.is-capacitor .portal-main .container {
        padding-bottom: 120px;
    }
}

/* Small mobile */
@media (max-width: 480px) {
    .portal-main .container {
        padding: 16px 12px;
    }

    body.is-capacitor .portal-main .container {
        padding-bottom: 120px;
    }
    
    .bottom-nav-item {
        padding: 6px 8px;
    }
}

/* ===== MOBILE TOP BAR ===== */
.mobile-top-bar {
    display: none;
}

@media (max-width: 768px) {
    .mobile-top-bar {
        display: flex;
        align-items: center;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        height: auto;
        min-height: 48px;
        padding: 0 16px;
        padding-top: env(safe-area-inset-top, 0px);
        background: rgba(255, 255, 255, 0.95);
        backdrop-filter: blur(20px);
        -webkit-backdrop-filter: blur(20px);
        border-bottom: 1px solid rgba(0, 0, 0, 0.06);
        z-index: 500;
        box-shadow: 0 1px 8px rgba(0, 0, 0, 0.06);
        transition: transform 0.3s ease;
    }

    .mobile-top-bar.hidden {
        transform: translateY(-100%);
    }

    .mobile-top-bar-btn {
        width: 40px;
        height: 40px;
        display: flex;
        align-items: center;
        justify-content: center;
        background: none;
        border: none;
        font-size: 22px;
        color: #374151;
        cursor: pointer;
        border-radius: 10px;
        flex-shrink: 0;
        -webkit-tap-highlight-color: transparent;
    }

    .mobile-top-bar-title {
        flex: 1;
        text-align: center;
        font-size: 16px;
        font-weight: 700;
        color: #1a1a1a;
        letter-spacing: -0.3px;
    }

    .mobile-top-bar-spacer {
        width: 40px;
        flex-shrink: 0;
    }

    /* Push portal-main content below the top bar */
    .portal-main {
        padding-top: calc(48px + env(safe-area-inset-top, 0px)) !important;
    }

    /* Hide the old standalone menu button */
    .mobile-menu-btn {
        display: none !important;
    }
}

/* ===== HIDE OLD TABS ON DESKTOP ===== */
.tabs {
    display: none !important;
}

/* ===== SKELETON LOADERS ===== */
@keyframes shimmer {
    0%   { background-position: -400px 0; }
    100% { background-position:  400px 0; }
}

.skeleton {
    background: linear-gradient(90deg,
        #f0f0f0 25%,
        #e8e8e8 37%,
        #f0f0f0 63%
    );
    background-size: 800px 100%;
    animation: shimmer 1.4s ease infinite;
    border-radius: 8px;
}

.skeleton-text        { height: 16px; margin-bottom: 8px; }
.skeleton-text.lg     { height: 24px; }
.skeleton-text.sm     { height: 12px; }
.skeleton-avatar      { width: 36px; height: 36px; border-radius: 50%; flex-shrink: 0; }

.skeleton-card {
    background: rgba(255, 255, 255, 0.85);
    border-radius: 16px;
    padding: 20px;
    margin-bottom: 16px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.04);
}

.skeleton-row {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}

.skeleton-block { border-radius: 8px; }

/* Auth overlay — gradient bg so there's no flash when content appears */
#authLoadingOverlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: linear-gradient(135deg,
        #FFF5F0 0%, #FFE8E8 25%, #FFD4E5 50%, #F5E8FF 75%, #E8F5FF 100%
    );
    display: flex;
    align-items: flex-start;
    justify-content: center;
    z-index: 10000;
    transition: opacity 0.4s ease;
    overflow-y: auto;
}

#authLoadingOverlay.hide {
    opacity: 0;
    pointer-events: none;
}

/* ===== PAGE TRANSITIONS ===== */
@keyframes pageSlideIn {
    from { opacity: 0; transform: translateX(24px); }
    to   { opacity: 1; transform: translateX(0); }
}

@keyframes pageSlideOut {
    from { opacity: 1; transform: translateX(0); }
    to   { opacity: 0; transform: translateX(-24px); }
}

.portal-layout.page-enter {
    animation: pageSlideIn 0.28s cubic-bezier(0.25, 0.46, 0.45, 0.94) both;
}

body.page-exit .portal-layout {
    animation: pageSlideOut 0.2s cubic-bezier(0.55, 0, 1, 0.45) both;
    pointer-events: none;
}

/* Suppress transitions on desktop — only mobile needs them */
@media (min-width: 769px) {
    .portal-layout.page-enter,
    body.page-exit .portal-layout {
        animation: none;
    }
}

/* ===== GLOBAL FONT SMOOTHING & TAP BEHAVIOUR ===== */
* {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

a, button {
    -webkit-tap-highlight-color: transparent;
}

/* ===== BOTTOM NAV ICON BOUNCE ===== */
body.is-capacitor .bottom-nav-item .bottom-nav-icon {
    transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

body.is-capacitor .bottom-nav-item:active .bottom-nav-icon {
    transform: scale(0.85);
    transition: transform 0.1s ease;
}

/* ===== NATIVE APP TOUCH FEEL ===== */
body.is-capacitor {
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
    user-select: none;
    -webkit-user-select: none;
    scroll-behavior: smooth;
}

/* Allow text selection in inputs and content areas */
body.is-capacitor input,
body.is-capacitor textarea,
body.is-capacitor .modal,
body.is-capacitor .event-card-body {
    user-select: text;
    -webkit-user-select: text;
}

/* Cards should feel tappable — spring bounce on release */
body.is-capacitor .stat-trio-card,
body.is-capacitor .dashboard-section-card,
body.is-capacitor .dashboard-chart-card {
    transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

body.is-capacitor .stat-trio-card:active,
body.is-capacitor .dashboard-section-card:active,
body.is-capacitor .dashboard-chart-card:active {
    transform: scale(0.98);
    transition: transform 0.1s ease;
}

/* Event cards active state */
body.is-capacitor .event-card {
    transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

body.is-capacitor .event-card:active {
    transform: scale(0.98);
    transition: transform 0.1s ease;
}

/* ===== CAPACITOR SUB-PAGE CONSISTENCY ===== */
@media (max-width: 768px) {
    /* portal-main already handles top-bar clearance via padding-top: calc(48px + env(safe-area-inset-top)).
       content-area / container just need a small breathing gap — NOT another safe-area offset. */
    body.is-capacitor .content-area {
        padding-top: 16px !important;
        padding-bottom: 120px !important;
    }
    body.is-capacitor .portal-main > .container {
        padding-top: 16px !important;
    }
}

/* Hide website navigation in Capacitor app */
body.is-capacitor .mobile-menu-btn,
body.is-capacitor .mobile-sidebar,
body.is-capacitor .mobile-sidebar-overlay {
    display: none !important;
}

/* Hide website footer & cookie banner in Capacitor */
body.is-capacitor footer { display: none !important; }
body.is-capacitor .cookie-banner { display: none !important; }

/* Universal button touch feedback */
body.is-capacitor button:not(.bottom-nav-item):active,
body.is-capacitor .btn-primary:active,
body.is-capacitor .btn-secondary:active {
    opacity: 0.7;
    transition: opacity 0.1s ease;
}

/* Universal card tap feedback */
body.is-capacitor .card:active,
body.is-capacitor .vendor-card:active,
body.is-capacitor .guest-card:active,
body.is-capacitor .category-card:active {
    transform: scale(0.98);
    transition: transform 0.1s ease;
}
