/* ═══════════════════════════════════════════════════════════════════════════
   KrümelBot — Dashboard mobile UX (fixes & touch-friendly layout)
   ═══════════════════════════════════════════════════════════════════════════ */

:root {
  --dash-mobile-top: 52px;
  --dash-safe-bottom: env(safe-area-inset-bottom, 0px);
}

html {
  -webkit-text-size-adjust: 100%;
}

body[data-app="dashboard"] #app,
#app[data-app="dashboard"] {
  max-width: 100vw;
  overflow-x: hidden;
}

/* Legacy FAB aus — gdb-menu-btn übernimmt */
body:has(.guild-layout.gdb-ui:not(.hidden)) .guild-rail-toggle {
  display: none !important;
}

/* ── Topnav / Profil-Dropdown ── */
@media (max-width: 900px) {
  .topnav.tnv {
    position: sticky;
    top: 0;
    z-index: 100;
  }

  .topnav-user-wrap,
  .tnv-user.topnav-user-wrap {
    position: static;
  }

  .topnav.tnv .profile-drop.tnv-drop:not(.hidden) {
    display: flex !important;
    flex-direction: column;
    position: fixed;
    left: 12px;
    right: 12px;
    top: auto;
    bottom: calc(12px + var(--dash-safe-bottom));
    width: auto;
    max-width: none;
    max-height: min(72vh, 520px);
    overflow-y: auto;
    border-radius: 18px;
    box-shadow: 0 24px 64px rgba(0, 0, 0, 0.55);
    animation: tnv-drop-sheet-in 0.26s cubic-bezier(0.22, 1, 0.36, 1);
  }

  @keyframes tnv-drop-sheet-in {
    from {
      opacity: 0;
      transform: translateY(12px);
    }
    to {
      opacity: 1;
      transform: none;
    }
  }

  .tnv-context {
    max-width: min(42vw, 160px);
  }
}

/* ── Server-Auswahl (hsv) ── */
@media (max-width: 900px) {
  .home-layout.hsv-ui.dash-view {
    min-height: calc(100dvh - var(--dash-mobile-top));
    overflow-x: hidden;
  }

  .home-layout.hsv-ui .hsv-main {
    height: auto;
    min-height: calc(100dvh - var(--dash-mobile-top));
    overflow-x: hidden;
    padding-bottom: calc(24px + var(--dash-safe-bottom));
  }

  .home-layout.hsv-ui .hsv-wrap {
    padding-left: max(16px, env(safe-area-inset-left, 0px));
    padding-right: max(16px, env(safe-area-inset-right, 0px));
  }

  .home-layout.hsv-ui .hsv-hero {
    flex-direction: column;
    align-items: stretch;
    gap: 14px;
  }

  .home-layout.hsv-ui .hsv-view-toggle {
    align-self: flex-end;
  }

  .home-layout.hsv-ui .hsv-toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .home-layout.hsv-ui .hsv-filters {
    width: 100%;
    justify-content: stretch;
  }

  .home-layout.hsv-ui .sv3-filter {
    flex: 1;
    min-height: 40px;
  }

  .home-layout.hsv-ui .sv3-search input {
    min-height: 44px;
    font-size: 16px;
  }

  .home-layout.hsv-ui .svc {
    padding: 16px;
  }

  .home-layout.hsv-ui .svc-btn {
    min-height: 44px;
  }
}

/* ── Konto (acb) ── */
@media (max-width: 900px) {
  .account-layout.acb-ui.dash-view {
    min-height: calc(100dvh - var(--dash-mobile-top));
    overflow-x: hidden;
  }

  .account-layout.acb-ui .acb-shell {
    min-height: calc(100dvh - var(--dash-mobile-top));
  }

  .account-layout.acb-ui .account-rail.acb {
    height: auto;
    max-height: none;
    border-bottom: 1px solid var(--acb-border, rgba(255, 255, 255, 0.08));
  }

  .account-layout.acb-ui .acb-nav-scroll {
    max-height: min(42vh, 320px);
  }

  .account-layout.acb-ui .account-nav-btn {
    min-height: 44px;
  }

  .account-layout.acb-ui .acb-main {
    height: auto;
    min-height: 0;
    overflow-x: hidden;
    padding-bottom: calc(32px + var(--dash-safe-bottom));
    padding-left: max(16px, env(safe-area-inset-left, 0px));
    padding-right: max(16px, env(safe-area-inset-right, 0px));
  }

  .account-layout.acb-ui .account-page-head {
    padding: 16px;
  }

  .account-layout.acb-ui .shop-layout {
    grid-template-columns: 1fr;
  }

  .account-layout.acb-ui .shop-hero {
    position: static;
  }

  .account-layout.acb-ui .account-profile-card {
    flex-direction: column;
    align-items: flex-start;
    text-align: left;
  }

  .account-layout.acb-ui .account-setting-row {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
  }

  .account-layout.acb-ui .account-pill-group {
    width: 100%;
  }

  .account-layout.acb-ui .account-pill {
    flex: 1;
    justify-content: center;
    min-height: 42px;
  }

  .account-layout.acb-ui .st-shell {
    grid-template-columns: 1fr;
    min-height: 420px;
  }

  .account-layout.acb-ui .st-inbox {
    border-right: none;
    border-bottom: 1px solid rgba(255, 255, 255, 0.09);
    max-height: 240px;
  }

  .account-layout.acb-ui .st-inbox-list {
    max-height: 200px;
  }

  .account-layout.acb-ui .admin-voucher-table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
}

/* ── Server-Dashboard (gdb) ── */
@media (max-width: 900px) {
  .app.app--guild {
    height: 100dvh;
    max-height: 100dvh;
    overflow: hidden;
  }

  .guild-layout.gdb-ui {
    flex: 1;
    flex-direction: row;
    min-height: 0;
    height: calc(100dvh - var(--dash-mobile-top));
    max-height: calc(100dvh - var(--dash-mobile-top));
    overflow: hidden;
  }

  .guild-layout.gdb-ui .guild-rail.gsb {
    position: fixed;
    top: var(--dash-mobile-top);
    left: 0;
    bottom: 0;
    width: min(300px, 88vw);
    min-width: 0;
    max-width: 88vw;
    z-index: 95;
    height: auto;
    transform: translateX(-105%);
    transition: transform 0.28s cubic-bezier(0.22, 1, 0.36, 1);
    box-shadow: 12px 0 40px rgba(0, 0, 0, 0.5);
  }

  body.guild-rail-open .guild-layout.gdb-ui .guild-rail.gsb {
    transform: translateX(0);
  }

  body.guild-rail-open {
    overflow: hidden;
    touch-action: none;
  }

  .guild-rail-backdrop {
    top: var(--dash-mobile-top);
    z-index: 94;
  }

  .guild-layout.gdb-ui .guild-work {
    flex: 1;
    min-width: 0;
    min-height: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }

  .guild-layout.gdb-ui .guild-body {
    flex: 1;
    min-height: 0;
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 12px 12px calc(80px + var(--dash-safe-bottom));
  }

  .guild-layout.gdb-ui .gdb-topbar {
    padding: 10px 12px;
    gap: 10px;
    flex-shrink: 0;
  }

  .guild-layout.gdb-ui .gdb-menu-btn {
    display: grid;
    min-width: 44px;
    min-height: 44px;
  }

  .guild-layout.gdb-ui .mod-page-header {
    flex-wrap: wrap;
    padding: 16px;
  }

  .guild-layout.gdb-ui .welcome-grid,
  .guild-layout.gdb-ui .giveaway-grid {
    grid-template-columns: 1fr !important;
  }

  .guild-layout.gdb-ui .guild-nav-btn,
  .guild-layout.gdb-ui .gsb-nav .guild-nav-btn {
    min-height: 44px;
  }
}

@media (max-width: 480px) {
  .tnv-inner {
    padding: 0 10px;
  }

  .home-layout.hsv-ui .sv3-title {
    font-size: 1.22rem;
  }

  .account-layout.acb-ui .account-page-title {
    font-size: 1.2rem;
  }

  .guild-layout.gdb-ui .gdb-topbar-name {
    font-size: 0.95rem;
  }

  .guild-layout.gdb-ui .gdb-topbar-icon {
    width: 36px;
    height: 36px;
  }
}

/* Override legacy styles.css guild mobile that breaks gdb layout */
@media (max-width: 900px) {
  .guild-layout.gdb-ui.guild-layout {
    flex-direction: row;
    overflow: hidden;
  }

  .app.app--guild:has(.guild-layout.gdb-ui:not(.hidden)) {
    height: 100dvh;
    overflow: hidden;
  }

  body.is-guild-view .guild-layout.gdb-ui .guild-rail {
    transform: translateX(-105%);
  }

  body.is-guild-view.guild-rail-open .guild-layout.gdb-ui .guild-rail.gsb {
    transform: translateX(0);
  }

  .guild-layout.gdb-ui .guild-work {
    min-height: calc(100dvh - var(--dash-mobile-top));
    overflow: visible;
  }

  .guild-layout.gdb-ui .guild-body {
    overflow-y: auto;
  }
}
