/* ============================================================
   BINGO Shell 2026 — Premium mobile-first social + SaaS chrome
   Extends existing app without removing features.
   ============================================================ */

:root {
  --shell-bg: #f4f6f8;
  --shell-surface: #ffffff;
  --shell-text: #0b1220;
  --shell-muted: #6b7a8c;
  --shell-border: rgba(15, 23, 42, 0.08);
  --shell-accent: #0d9488;
  --shell-accent-soft: rgba(13, 148, 136, 0.12);
  --shell-radius: 16px;
  --shell-radius-sm: 10px;
  --shell-shadow: 0 1px 2px rgba(11, 18, 32, 0.04), 0 8px 24px rgba(11, 18, 32, 0.04);
  --shell-header-h: 56px;
  --shell-bottom-h: calc(72px + env(safe-area-inset-bottom, 0px));
  --shell-font: 'Montserrat', system-ui, -apple-system, sans-serif;
  --shell-display: 'Montserrat', system-ui, sans-serif;
}

/* Theme tokens live in css/bingo-theme.css — do not force light here */

.theme-toggle,
#themeToggle {
  /* visible — styled in bingo-theme.css */
}


body.app-body {
  font-family: var(--shell-font);
  background: var(--shell-bg) !important;
  color: var(--shell-text);
  -webkit-tap-highlight-color: transparent;
}

/* —— Mobile top bar: logo only, full-width, centered —— */
.mobile-top-bar,
#mobileTopBar.mobile-top-bar {
  position: sticky;
  top: 0;
  z-index: 200;
  height: calc(var(--shell-header-h) + env(safe-area-inset-top, 0px));
  padding-top: env(safe-area-inset-top, 0px);
  display: flex !important;
  align-items: center;
  justify-content: center;
  padding-left: 12px;
  padding-right: 12px;
  background: color-mix(in srgb, var(--shell-surface) 88%, transparent) !important;
  backdrop-filter: blur(16px) saturate(1.2);
  -webkit-backdrop-filter: blur(16px) saturate(1.2);
  border-bottom: 1px solid var(--shell-border) !important;
  box-shadow: none !important;
  width: 100%;
  box-sizing: border-box;
}

.mobile-top-bar__slot { display: none !important; }

.mobile-top-bar__actions {
  position: absolute !important;
  right: 6px;
  top: calc(env(safe-area-inset-top, 0px) + 4px);
  z-index: 2;
  display: flex !important;
  align-items: center;
  gap: 2px;
}

.mobile-top-bar__actions .mobile-top-btn {
  position: relative;
  width: 42px;
  height: 42px;
}

.mobile-top-bar__actions .mobile-top-btn .icon-svg {
  width: 22px;
  height: 22px;
}

.mobile-top-bar__badge {
  position: absolute;
  top: 6px;
  right: 4px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 999px;
  background: #e11d48;
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  line-height: 16px;
  text-align: center;
  box-sizing: border-box;
}

/* Hide language switcher in mobile top bar (search + heart instead) */
.mobile-top-bar .bingo-lang--mobile,
#mobileTopBar .bingo-lang {
  display: none !important;
}

.mobile-top-bar .bingo-mark-center,
.mobile-top-bar__logo {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  text-decoration: none;
  color: var(--shell-text);
  margin: 0 auto;
}
.mobile-top-bar__logo .logo-icon,
.mobile-top-bar .logo-icon {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: linear-gradient(145deg, #0d9488, #0b1220);
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 12px;
  font-weight: 800;
}
.mobile-top-bar__logo .logo-full {
  height: 28px;
  width: auto;
  max-width: min(140px, 55vw);
  object-fit: contain;
  border-radius: 6px;
}
.mobile-top-bar .logo-text { display: none !important; }

.mobile-top-btn {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border: 0;
  background: transparent;
  color: var(--shell-text);
  border-radius: 50%;
  text-decoration: none;
  cursor: pointer;
}
.mobile-top-btn:active { background: var(--shell-accent-soft); }

.mobile-top-bar__back {
  position: absolute !important;
  left: 8px;
  top: calc(env(safe-area-inset-top, 0px) + 6px);
  z-index: 2;
}

.mobile-top-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  overflow: hidden;
  background: var(--shell-accent-soft);
  display: grid;
  place-items: center;
  font-size: 12px;
  font-weight: 700;
}
.mobile-top-avatar img { width: 100%; height: 100%; object-fit: cover; }

/* Hide old logo-left / avatar leftovers */
.mobile-top-bar > a.logo { display: none !important; }
.mobile-top-bar .mobile-top-avatar,
.mobile-top-bar a[aria-label="Profile"],
.mobile-top-bar a[aria-label="Sign in"] {
  display: none !important;
}

@media (max-width: 768px) {
  .app-layout {
    display: block !important;
    width: 100% !important;
    max-width: 100vw !important;
    overflow-x: hidden !important;
  }

  .app-sidebar {
    position: fixed !important;
  }

  #mobileTopBar.mobile-top-bar,
  body.has-mobile-chrome .mobile-top-bar {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    width: 100% !important;
    max-width: 100vw !important;
    margin: 0 !important;
    flex: none !important;
    z-index: 220 !important;
  }

  .app-main {
    display: block !important;
    width: 100% !important;
    max-width: 100% !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
    box-sizing: border-box !important;
  }

  .app-right {
    display: none !important;
  }

  body.has-mobile-chrome .app-main {
    padding-top: calc(var(--shell-header-h) + env(safe-area-inset-top, 0px) + 8px) !important;
  }
}

/* —— Bottom nav: Home · Marketplace · Create · Messages · Profile —— */
.bottom-nav,
#bottomNav.bottom-nav {
  height: auto !important;
  min-height: 56px;
  padding: 6px 8px calc(6px + env(safe-area-inset-bottom, 0px)) !important;
  background: color-mix(in srgb, var(--shell-surface) 72%, transparent) !important;
  border: 0 !important;
  border-top: 0 !important;
  backdrop-filter: saturate(180%) blur(28px) !important;
  -webkit-backdrop-filter: saturate(180%) blur(28px) !important;
  display: flex !important;
  align-items: center;
  justify-content: space-around;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.12) !important;
  border-radius: 28px !important;
  margin: 0 !important;
  left: 14px !important;
  right: 14px !important;
  bottom: calc(10px + env(safe-area-inset-bottom, 0px)) !important;
  width: auto !important;
  max-width: none !important;
  position: fixed !important;
  z-index: 220;
}

.bottom-nav-link {
  flex: 1;
  min-height: 44px;
  min-width: 44px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  color: var(--shell-muted);
  text-decoration: none;
  position: relative;
  border: 0;
  background: transparent;
  cursor: pointer;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.02em;
}
.bottom-nav-link.active { color: var(--shell-text); }
.bottom-nav-link .nav-icon svg { width: 24px; height: 24px; }
.bottom-nav-link--create {
  color: var(--shell-accent) !important;
}
.bottom-nav-link--create .bottom-nav-create-orb {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: #007AFF;
  color: #fff;
  display: grid;
  place-items: center;
  margin-top: 0;
  box-shadow: 0 6px 18px rgba(0, 122, 255, 0.35);
}
[data-theme="dark"] .bottom-nav-link--create .bottom-nav-create-orb {
  background: var(--shell-accent);
  color: #041210;
}
.bottom-nav-dot {
  position: absolute;
  top: 4px;
  right: calc(50% - 14px);
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--shell-accent);
  border: 2px solid var(--shell-surface);
}
.bottom-nav-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  overflow: hidden;
  display: grid;
  place-items: center;
  background: var(--shell-accent-soft);
  font-size: 11px;
  font-weight: 700;
}
.bottom-nav-avatar img { width: 100%; height: 100%; object-fit: cover; }
.bottom-nav-profile.active .bottom-nav-avatar {
  box-shadow: 0 0 0 2px var(--shell-surface), 0 0 0 3.5px var(--shell-accent);
}

/* —— Responsive nav: mobile bottom · PC left sidebar —— */
@media (max-width: 768px) {
  body.app-body .app-sidebar,
  .app-layout > .app-sidebar,
  #appSidebar {
    /* drawer only — off-canvas until .sidebar-open */
  }

  body.app-body .app-main,
  .app-layout .app-main {
    margin-left: 0 !important;
  }

  body.app-body .bottom-nav,
  body.app-body #bottomNav.bottom-nav,
  .bottom-nav,
  #bottomNav {
    display: flex !important;
    visibility: visible !important;
    pointer-events: auto !important;
    opacity: 1 !important;
    height: auto !important;
  }

  body.app-body .app-main {
    padding-bottom: calc(var(--bottom-nav-float, 76px) + 16px) !important;
  }
}

@media (min-width: 769px) {
  body.app-body .app-sidebar,
  .app-layout > .app-sidebar,
  #appSidebar {
    display: flex !important;
    visibility: visible !important;
    pointer-events: auto !important;
  }

  body.app-body .app-main,
  .app-layout .app-main {
    margin-left: var(--sidebar-width, 244px) !important;
  }

  body.app-body .bottom-nav,
  body.app-body #bottomNav.bottom-nav,
  .bottom-nav,
  #bottomNav {
    display: none !important;
    visibility: hidden !important;
    pointer-events: none !important;
    height: 0 !important;
    min-height: 0 !important;
    padding: 0 !important;
    margin: 0 !important;
    opacity: 0 !important;
  }

  body.app-body .app-main {
    padding-bottom: 32px !important;
  }
}

/* —— Desktop sidebar calm —— */
@media (min-width: 1025px) {
  .app-sidebar {
    background: var(--shell-surface) !important;
    border-right: 1px solid var(--shell-border) !important;
    box-shadow: none !important;
  }
  .app-sidebar-header .logo-text,
  .app-sidebar .logo-text {
    font-family: var(--shell-display);
    font-weight: 800;
    letter-spacing: -0.04em;
  }
  .app-nav-section {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--shell-muted);
    padding: 16px 16px 6px;
  }
  .app-nav-link {
    border-radius: var(--shell-radius-sm);
    margin: 2px 8px;
    min-height: 44px;
  }
  .app-nav-link.active {
    background: var(--shell-accent-soft) !important;
    color: var(--shell-accent) !important;
  }
}

/* —— Profile: identity first —— */
.profile-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 12px;
}
.profile-actions .btn {
  min-height: 40px;
  border-radius: 999px;
  padding: 0 18px;
  font-weight: 600;
}
.profile-actions .profile-more-btn {
  width: 40px;
  min-width: 40px;
  padding: 0;
  border-radius: 50%;
}
.profile-meta {
  color: var(--shell-muted);
  font-size: 0.9rem;
}
.profile-name {
  font-family: var(--shell-display);
  font-weight: 700;
  letter-spacing: -0.02em;
}
.profile-cover {
  height: 140px !important;
  border-radius: var(--shell-radius) !important;
  background: linear-gradient(135deg, #0f766e 0%, #0b1220 55%, #0369a1 100%) !important;
}
.ig-profile .profile-cover,
.ig-profile__cover.profile-cover {
  height: 148px !important;
  max-height: 148px !important;
  border-radius: 0 !important;
  background: linear-gradient(135deg, #0f766e, #134e4a 45%, #115e59) !important;
  overflow: hidden !important;
}

/* —— Chat premium —— */
.messages-layout {
  display: grid;
  grid-template-columns: minmax(280px, 360px) 1fr;
  height: calc(100dvh - var(--shell-header-h) - var(--shell-bottom-h) - 8px);
  max-height: calc(100dvh - env(safe-area-inset-top) - var(--shell-bottom-h));
  background: var(--shell-surface);
  border-radius: var(--shell-radius);
  overflow: hidden;
  border: 1px solid var(--shell-border);
}

.chat-list {
  border-right: 1px solid var(--shell-border);
  overflow-y: auto;
  background: var(--shell-surface);
}
.chat-list-header {
  position: sticky;
  top: 0;
  z-index: 2;
  padding: 16px 16px 12px;
  font-family: var(--shell-display);
  font-weight: 700;
  font-size: 1.25rem;
  letter-spacing: -0.03em;
  background: var(--shell-surface);
  border-bottom: 1px solid var(--shell-border);
}
.chat-list-search {
  margin: 0 12px 10px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  background: var(--shell-bg);
  border-radius: 12px;
  border: 1px solid transparent;
}
.chat-list-search input {
  flex: 1;
  border: 0;
  outline: 0;
  background: transparent;
  font: inherit;
  color: var(--shell-text);
  min-width: 0;
}
.chat-item {
  display: grid;
  grid-template-columns: 48px 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 12px 14px;
  cursor: pointer;
  min-height: 72px;
  border: 0;
  background: transparent;
  width: 100%;
  text-align: left;
  transition: background 0.15s ease;
}
.chat-item:hover,
.chat-item.active { background: var(--shell-accent-soft); }
.chat-item.unread .chat-item-name { font-weight: 700; }
.chat-item-name {
  font-weight: 600;
  font-size: 0.95rem;
  display: flex;
  align-items: center;
  gap: 6px;
}
.chat-item-preview {
  font-size: 0.82rem;
  color: var(--shell-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 180px;
}
.chat-item-time {
  font-size: 0.72rem;
  color: var(--shell-muted);
  align-self: start;
  margin-top: 4px;
}
.chat-item-unread {
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--shell-accent);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  display: inline-grid;
  place-items: center;
}
.chat-item--pinned { background: rgba(13, 115, 119, 0.06); }
.chat-support-badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 999px;
  background: #0d7377;
  color: #fff;
  vertical-align: middle;
  margin-left: 4px;
}
.avatar--admin {
  background: linear-gradient(135deg, #0d7377, #14a085);
  font-size: 18px;
}
.chat-online-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #16a34a;
  box-shadow: 0 0 0 2px var(--shell-surface);
}

.chat-window {
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--shell-bg);
}
.chat-window-header {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 56px;
  padding: 8px 12px;
  background: var(--shell-surface);
  border-bottom: 1px solid var(--shell-border);
}
.chat-window-header strong {
  font-family: var(--shell-display);
  font-weight: 700;
  letter-spacing: -0.02em;
}
.chat-header-meta {
  font-size: 0.75rem;
  color: var(--shell-muted);
}
.chat-header-meta.is-online { color: #16a34a; }
.chat-back-btn {
  width: 44px;
  height: 44px;
  border: 0;
  background: transparent;
  border-radius: 50%;
  font-size: 1.25rem;
  cursor: pointer;
  color: var(--shell-text);
}
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px 14px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  -webkit-overflow-scrolling: touch;
}
.chat-day-sep {
  align-self: center;
  font-size: 0.72rem;
  color: var(--shell-muted);
  background: var(--shell-surface);
  border: 1px solid var(--shell-border);
  padding: 4px 10px;
  border-radius: 999px;
  margin: 8px 0;
}
.chat-bubble {
  max-width: min(78%, 420px);
  padding: 10px 14px;
  border-radius: 18px;
  font-size: 0.95rem;
  line-height: 1.4;
  position: relative;
  word-break: break-word;
  animation: chat-in 0.18s ease;
}
@keyframes chat-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}
.chat-bubble.sent {
  align-self: flex-end;
  background: var(--shell-text);
  color: #fff;
  border-bottom-right-radius: 6px;
}
[data-theme="dark"] .chat-bubble.sent {
  background: var(--shell-accent);
  color: #041210;
}
.chat-bubble.received {
  align-self: flex-start;
  background: var(--shell-surface);
  color: var(--shell-text);
  border: 1px solid var(--shell-border);
  border-bottom-left-radius: 6px;
}
.chat-bubble img {
  max-width: 100%;
  border-radius: 12px;
  margin-top: 6px;
  display: block;
}
.chat-bubble-meta {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
  margin-top: 4px;
  font-size: 0.65rem;
  opacity: 0.7;
}
.chat-bubble.received .chat-bubble-meta { justify-content: flex-start; }
.chat-ticks { letter-spacing: -0.05em; }
.chat-ticks.read { color: #38bdf8; }
.chat-bubble.pending { opacity: 0.65; }
.chat-bubble.failed { outline: 1px solid #ef4444; }

.chat-typing {
  padding: 0 16px 6px;
  font-size: 0.8rem;
  color: var(--shell-muted);
  min-height: 20px;
}

.chat-input-bar {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 10px 12px calc(10px + env(safe-area-inset-bottom, 0px));
  background: var(--shell-surface);
  border-top: 1px solid var(--shell-border);
}
.chat-input-bar textarea,
.chat-input-bar #msgInput {
  flex: 1;
  min-height: 44px;
  max-height: 120px;
  resize: none;
  border: 1px solid var(--shell-border);
  border-radius: 22px;
  padding: 12px 16px;
  font: inherit;
  background: var(--shell-bg);
  color: var(--shell-text);
  outline: none;
}
.chat-input-bar textarea:focus,
.chat-input-bar #msgInput:focus {
  border-color: var(--shell-accent);
  box-shadow: 0 0 0 3px var(--shell-accent-soft);
}
.chat-input-bar .btn,
.chat-composer-btn {
  width: 44px;
  height: 44px;
  min-width: 44px;
  border-radius: 50%;
  padding: 0;
  display: grid;
  place-items: center;
  border: 0;
  cursor: pointer;
}
.chat-composer-btn {
  background: transparent;
  color: var(--shell-muted);
}
#sendMsg {
  background: var(--shell-text) !important;
  color: #fff !important;
}
[data-theme="dark"] #sendMsg {
  background: var(--shell-accent) !important;
  color: #041210 !important;
}
.chat-templates {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding: 8px 12px 0;
  scrollbar-width: none;
}
.chat-template-btn {
  flex-shrink: 0;
  border: 1px solid var(--shell-border);
  background: var(--shell-surface);
  color: var(--shell-muted);
  border-radius: 999px;
  padding: 8px 12px;
  font-size: 0.78rem;
  cursor: pointer;
  min-height: 36px;
}
.chat-window-empty {
  flex: 1;
  display: grid;
  place-items: center;
  text-align: center;
  color: var(--shell-muted);
  padding: 24px;
}
.chat-conn {
  font-size: 0.7rem;
  color: var(--shell-muted);
  padding: 4px 12px;
  text-align: center;
}
.chat-conn.is-live { color: #16a34a; }

/* Mobile chat panes */
@media (max-width: 768px) {
  .messages-layout {
    grid-template-columns: 1fr;
    height: calc(100dvh - var(--shell-header-h) - var(--shell-bottom-h));
    border-radius: 0;
    border: 0;
  }
  .messages-layout.chat-mobile-list .chat-window { display: none; }
  .messages-layout.chat-mobile-active .chat-list { display: none; }
  .messages-layout.chat-mobile-active .chat-window { display: flex; }
  body.chat-thread-open .bottom-nav { display: none !important; }
  body.chat-thread-open .app-main {
    padding-bottom: 0 !important;
  }
  body.chat-thread-open .messages-layout {
    height: calc(100dvh - var(--shell-header-h));
  }
}

/* Settings organized */
.settings-nav-card {
  display: grid;
  gap: 4px;
  margin-bottom: 20px;
}
.settings-nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 52px;
  padding: 12px 14px;
  border-radius: var(--shell-radius-sm);
  background: var(--shell-surface);
  border: 1px solid var(--shell-border);
  text-decoration: none;
  color: var(--shell-text);
  font-weight: 600;
}
.settings-nav-item span.meta {
  margin-left: auto;
  color: var(--shell-muted);
  font-weight: 400;
  font-size: 0.85rem;
}

@media (prefers-reduced-motion: reduce) {
  .chat-bubble { animation: none; }
}
