/* =============================================
   UTOPIA APP CHROME
   Shared top-header + pill-nav styles for every
   authenticated page. Imported by home.html,
   my_collection.html, and future pages.
   ============================================= */

:root {
    --home-header-height: 64px;
    --home-pill-height: 64px;
    --home-pill-offset: 1.5rem;
    --home-transition: cubic-bezier(0.4, 0, 0.2, 1);
    --home-glass-bg: rgba(10, 14, 26, 0.82);
    --home-pill-shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
}

[data-theme="light"] {
    --home-glass-bg: rgba(255, 255, 255, 0.82);
    --home-pill-shadow: 0 12px 40px rgba(15, 23, 42, 0.14);
}

/* =============================================
   MATERIAL SYMBOLS DEFAULTS
   Base + filled variant. Imported alongside the
   chrome so every page gets identical icons.
   ============================================= */
.material-symbols-outlined {
    font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 24;
    vertical-align: middle;
    line-height: 1;
    user-select: none;
}
.material-symbols-outlined.fill,
.material-symbols-outlined.filled {
    font-variation-settings: 'FILL' 1, 'wght' 500, 'GRAD' 0, 'opsz' 24;
}

/* =============================================
   Chrome-scoped resets
   Mirrors the `a { color: inherit; text-decoration: none; }`
   global reset that home.html has in its inline <style>.
   Without this, pages that don't redefine the anchor base
   (like market_analysis.html) render the default browser
   underline beneath the Material Symbol glyphs and labels,
   plus inherit body line-height (1.6 in styles.css) which
   inflates the pill item height.
   ============================================= */
.top-header,
.top-header *,
.pill-nav-wrap,
.pill-nav-wrap * {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}
.top-header a,
.pill-nav-item,
.header-logo,
.header-icon-btn {
    text-decoration: none;
    color: inherit;
    line-height: 1;
}

/* =============================================
   GLASS TOP HEADER
   ============================================= */
.top-header {
    position: fixed;
    top: 0; left: 0; right: 0;
    height: var(--home-header-height);
    background: var(--home-glass-bg);
    backdrop-filter: blur(24px) saturate(140%);
    -webkit-backdrop-filter: blur(24px) saturate(140%);
    border-bottom: 1px solid var(--border-primary);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    z-index: 100;
    transition: background 0.3s ease, border-color 0.3s ease;
}

.header-logo { display: inline-flex; align-items: center; padding: 6px 4px; border-radius: var(--radius-full); transition: background 0.2s ease; text-decoration: none; color: inherit; }
.header-logo:hover { background: var(--bg-tertiary); }
.header-logo img { height: 30px; width: auto; display: block; }
[data-theme="light"] .header-logo img { height: auto; width: 75px; }

.header-actions { display: flex; align-items: center; gap: 6px; }

/* Back-button header variant: the logo is replaced by a back button on the
   left, a centred page title in the middle, and the existing header actions
   (notification bell) on the right. Mirrors the card-detail / activity
   back-button pattern so it's consistent with pages that already have one. */
.top-header.has-back {
    display: grid;
    grid-template-columns: 44px 1fr 44px;
    align-items: center;
    gap: 12px;
}
.header-back-btn {
    width: 44px; height: 44px;
    border: 0; padding: 0;
    background: transparent;
    border-radius: 50%;
    color: var(--blue-500);
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: background 0.2s ease, transform 0.15s ease;
}
.header-back-btn:hover { background: var(--bg-tertiary); }
.header-back-btn:active { transform: scale(0.92); }
.header-back-btn:focus-visible { outline: 2px solid var(--blue-500); outline-offset: 2px; }
.header-back-btn .material-symbols-outlined { font-size: 24px; }
.header-title {
    margin: 0;
    font-family: 'Manrope', system-ui, sans-serif;
    font-size: 1.0625rem;
    font-weight: 700;
    letter-spacing: -0.01em;
    color: var(--text-primary);
    text-align: center;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.header-icon-btn {
    /* Normalise: the bell is a <button> on every page. Without this the
       UA button border shows up as a ring on pages that don't have their
       own global button reset (collection_upload, market_analysis,
       trading, settings, watchlist). */
    appearance: none;
    -webkit-appearance: none;
    border: none;
    margin: 0;
    padding: 0;
    font: inherit;
    cursor: pointer;
    width: 44px; height: 44px;
    border-radius: 50%;
    background: transparent;
    color: var(--blue-500);
    display: flex; align-items: center; justify-content: center;
    position: relative;
    transition: background 0.2s ease, transform 0.15s ease;
    text-decoration: none;
}
.header-icon-btn:hover { background: var(--bg-tertiary); }
.header-icon-btn:active { transform: scale(0.92); }
.header-icon-btn .material-symbols-outlined { font-size: 26px; }

/* Notification bell: filled (solid) blue glyph — same size & position, just filled.
   Scoped to the bell (#notificationBtn) so other .header-icon-btn icons
   (e.g. messages' search/stats) stay outlined. Colour is already var(--blue-500). */
#notificationBtn .material-symbols-outlined {
    font-variation-settings: 'FILL' 1, 'wght' 400, 'GRAD' 0, 'opsz' 24;
}

.notification-dot {
    position: absolute;
    top: 10px; right: 10px;
    width: 9px; height: 9px;
    background: #ef4444;
    border-radius: 50%;
    border: 2px solid var(--bg-primary);
    display: none;
}
.notification-dot.visible { display: block; }

/* =============================================
   FLOATING PILL BOTTOM NAV
   ============================================= */
.pill-nav-wrap {
    position: fixed;
    bottom: var(--home-pill-offset);
    left: 50%;
    transform: translateX(-50%);
    width: calc(100% - 32px);
    max-width: 28rem;
    z-index: 95;
    padding-bottom: env(safe-area-inset-bottom, 0px);
    pointer-events: none;
}
.pill-nav {
    pointer-events: auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 4px;
    height: var(--home-pill-height);
    padding: 0 18px;
    background: var(--home-glass-bg);
    backdrop-filter: blur(24px) saturate(160%);
    -webkit-backdrop-filter: blur(24px) saturate(160%);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-full);
    box-shadow: var(--home-pill-shadow);
}

.pill-nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    color: var(--text-muted);
    padding: 8px 0;
    position: relative;
    transition: color 0.2s ease, transform 0.15s ease;
    text-decoration: none;
    -webkit-tap-highlight-color: transparent;
}
.pill-nav-item:active { transform: scale(0.92); }
.pill-nav-item .material-symbols-outlined {
    font-size: 26px;
    transition: font-variation-settings 0.2s ease;
}
.pill-nav-item .pill-nav-label {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 0.5625rem;
    font-weight: 800;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    margin-top: 2px;
}
.pill-nav-item.active { color: var(--blue-500); }
.pill-nav-item.active .material-symbols-outlined {
    font-variation-settings: 'FILL' 1, 'wght' 600, 'GRAD' 0, 'opsz' 24;
}

.pill-nav-badge {
    position: absolute;
    top: 4px; right: calc(50% - 18px);
    min-width: 16px; height: 16px;
    padding: 0 4px;
    background: #ef4444;
    color: #ffffff;
    font-size: 0.5625rem;
    font-weight: 800;
    border-radius: 9px;
    display: none;
    align-items: center;
    justify-content: center;
    border: 2px solid var(--bg-secondary);
    font-family: 'Inter', sans-serif;
}
.pill-nav-badge.visible { display: flex; }

[data-theme="light"] .pill-nav { border-color: rgba(15, 23, 42, 0.08); }

/* =============================================
   SHARED PAGE CONTAINER
   Any page adopting the app chrome should wrap
   its main content in <main class="app-page">.
   Clears the fixed header and pill nav with safe
   spacing on every breakpoint.
   ============================================= */
.app-page {
    padding-top: calc(var(--home-header-height) + 12px);
    padding-bottom: calc(var(--home-pill-height) + var(--home-pill-offset) + 32px + env(safe-area-inset-bottom, 0px));
    padding-left: 20px;
    padding-right: 20px;
    max-width: 1200px;
    margin: 0 auto;
    width: 100%;
}

/* =============================================
   RESPONSIVE
   ============================================= */
@media (min-width: 768px) {
    :root { --home-header-height: 68px; }
    .app-page { padding-left: 28px; padding-right: 28px; }
}

@media (min-width: 1024px) {
    :root {
        --home-header-height: 72px;
        --home-pill-offset: 2rem;
    }
    .app-page { padding-left: 32px; padding-right: 32px; }
    .pill-nav-wrap { max-width: 32rem; }
}

/* Mobile/tablet: icon-only pill nav (labels hidden, desktop untouched) */
@media (max-width: 1023px) {
    .pill-nav-item .pill-nav-label { display: none; }
}

@media (max-width: 380px) {
    .app-page { padding-left: 16px; padding-right: 16px; }
}

/* =============================================
   NOTIFICATION CENTER
   Shared bell badge + dropdown (desktop) /
   bottom-sheet (mobile). Injected by
   /static/js/notification-center.js into every
   page that has #notificationBtn.
   ============================================= */

/* Count badge on the bell (supersedes .notification-dot) */
.nc-badge {
    position: absolute;
    top: 5px; right: 4px;
    min-width: 17px; height: 17px;
    padding: 0 4px;
    background: #ef4444;
    color: #fff;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 0.625rem;
    font-weight: 800;
    line-height: 1;
    border-radius: 9px;
    border: 2px solid var(--bg-primary);
    display: none;
    align-items: center;
    justify-content: center;
    pointer-events: none;
}
.nc-badge.visible { display: flex; }

/* Bell attention animation when a new notification arrives */
@keyframes nc-swing {
    0%   { transform: rotate(0); }
    15%  { transform: rotate(14deg); }
    30%  { transform: rotate(-12deg); }
    45%  { transform: rotate(9deg); }
    60%  { transform: rotate(-6deg); }
    75%  { transform: rotate(3deg); }
    100% { transform: rotate(0); }
}
@keyframes nc-badge-pulse {
    0%, 100% { transform: scale(1); }
    50%      { transform: scale(1.28); }
}
.header-icon-btn.nc-has-new .material-symbols-outlined {
    animation: nc-swing 1s var(--home-transition) 0s 2;
    transform-origin: 50% 12%;
}
.header-icon-btn.nc-has-new .nc-badge {
    animation: nc-badge-pulse 1s ease-in-out 0s 2;
}

/* Click-away / mobile backdrop */
.nc-overlay {
    position: fixed;
    inset: 0;
    z-index: 199;
    background: transparent;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
}
.nc-overlay.open { pointer-events: auto; }

/* Panel */
.nc-panel {
    position: fixed;
    top: calc(var(--home-header-height) + 8px);
    right: 14px;
    width: 384px;
    max-width: calc(100vw - 28px);
    max-height: calc(100vh - var(--home-header-height) - 32px);
    display: flex;
    flex-direction: column;
    background: var(--home-glass-bg);
    backdrop-filter: blur(28px) saturate(150%);
    -webkit-backdrop-filter: blur(28px) saturate(150%);
    border: 1px solid var(--border-primary);
    border-radius: 20px;
    box-shadow: var(--home-pill-shadow);
    z-index: 200;
    overflow: hidden;
    opacity: 0;
    transform: translateY(-10px) scale(0.98);
    transform-origin: top right;
    pointer-events: none;
    transition: opacity 0.2s ease, transform 0.2s var(--home-transition);
}
.nc-panel.open {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

.nc-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border-primary);
    flex-shrink: 0;
}
.nc-head h3 {
    margin: 0;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 0.95rem;
    font-weight: 800;
    color: var(--text-primary);
    letter-spacing: 0.01em;
}
.nc-head-actions { display: flex; align-items: center; gap: 4px; }
.nc-textbtn {
    background: none;
    border: none;
    cursor: pointer;
    font-family: 'Inter', sans-serif;
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--blue-500);
    padding: 6px 8px;
    border-radius: 8px;
    transition: background 0.15s ease;
}
.nc-textbtn:hover { background: var(--bg-tertiary); }
.nc-iconbtn {
    background: none; border: none; cursor: pointer;
    color: var(--text-muted);
    width: 32px; height: 32px;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    transition: background 0.15s ease, color 0.15s ease;
}
.nc-iconbtn:hover { background: var(--bg-tertiary); color: var(--text-primary); }
.nc-iconbtn .material-symbols-outlined { font-size: 20px; }

.nc-list {
    list-style: none;
    margin: 0;
    padding: 6px;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    flex: 1;
}

.nc-row {
    display: flex;
    gap: 12px;
    align-items: flex-start;
    padding: 12px 12px;
    border-radius: 14px;
    cursor: pointer;
    transition: background 0.15s ease;
    position: relative;
}
.nc-row:hover { background: var(--bg-tertiary); }
.nc-row.unread { background: rgba(59, 130, 246, 0.10); }
.nc-row.unread:hover { background: rgba(59, 130, 246, 0.16); }
.nc-row + .nc-row { margin-top: 2px; }

.nc-ic {
    flex-shrink: 0;
    width: 40px; height: 40px;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    background: var(--bg-tertiary);
    color: var(--blue-500);
    overflow: hidden;
}
.nc-ic img { width: 100%; height: 100%; object-fit: cover; }
.nc-ic .material-symbols-outlined { font-size: 22px; }
.nc-ic.cat-trade    { background: rgba(59,130,246,0.16);  color: #3b82f6; }
.nc-ic.cat-message  { background: rgba(139,92,246,0.16);  color: #8b5cf6; }
.nc-ic.cat-social   { background: rgba(236,72,153,0.16);  color: #ec4899; }
.nc-ic.cat-activity { background: rgba(16,185,129,0.16);  color: #10b981; }
.nc-ic.cat-system   { background: rgba(100,116,139,0.16); color: #64748b; }

.nc-body { flex: 1; min-width: 0; }
.nc-title {
    font-family: 'Inter', sans-serif;
    font-size: 0.825rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0 0 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.nc-text {
    font-family: 'Inter', sans-serif;
    font-size: 0.78rem;
    color: var(--text-secondary);
    margin: 0;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.nc-time {
    font-family: 'Inter', sans-serif;
    font-size: 0.68rem;
    color: var(--text-muted);
    margin-top: 4px;
    font-weight: 600;
    letter-spacing: 0.02em;
}
.nc-unread-dot {
    flex-shrink: 0;
    align-self: center;
    width: 8px; height: 8px;
    border-radius: 50%;
    background: var(--blue-500);
}

.nc-empty {
    padding: 48px 24px;
    text-align: center;
    color: var(--text-muted);
}
.nc-empty .material-symbols-outlined { font-size: 40px; opacity: 0.5; }
.nc-empty p {
    font-family: 'Inter', sans-serif;
    font-size: 0.85rem;
    margin: 12px 0 0;
}

.nc-foot {
    flex-shrink: 0;
    border-top: 1px solid var(--border-primary);
    padding: 8px;
}
.nc-foot a {
    display: block;
    text-align: center;
    padding: 10px;
    border-radius: 12px;
    font-family: 'Inter', sans-serif;
    font-size: 0.8rem;
    font-weight: 800;
    color: var(--blue-500);
    text-decoration: none;
    transition: background 0.15s ease;
}
.nc-foot a:hover { background: var(--bg-tertiary); }

/* Mobile: bottom sheet */
@media (max-width: 1023px) {
    .nc-overlay.open { background: rgba(0, 0, 0, 0.5); opacity: 1; }
    .nc-panel {
        top: auto;
        right: 0; left: 0; bottom: 0;
        width: 100%;
        max-width: 100%;
        max-height: 82vh;
        border-radius: 22px 22px 0 0;
        transform: translateY(100%);
        transform-origin: bottom center;
        padding-bottom: env(safe-area-inset-bottom, 0px);
    }
    .nc-panel.open { transform: translateY(0); }
}

@media (prefers-reduced-motion: reduce) {
    .header-icon-btn.nc-has-new .material-symbols-outlined,
    .header-icon-btn.nc-has-new .nc-badge { animation: none; }
    .nc-panel { transition: opacity 0.15s ease; transform: none; }
    .nc-panel.open { transform: none; }
}
