/* ============================================================================
 * assets/ribbon2_mobile.css
 *
 * Zweck:
 * - Responsive Mobile-Shell fuer Ribbon2.
 * - Der Inhalt wird serverseitig aus demselben $ribbonState wie Classic/Modern
 *   erzeugt; CSS entscheidet nur, ob Desktop- oder Mobile-Ribbon sichtbar ist.
 * - Keine formularspezifische Menue-Rekonstruktion im Browser.
 * ============================================================================ */

.wh-mobile-ribbon {
  display: none;
}

/*
 * Zentrale Embedded-Regel:
 * Wird eine komplette WH27-Seite in einem iframe/Popup geladen, blendet die
 * eingebettete Seite ihre eigene Navigations-Shell aus. Die Erkennung wird
 * in inc/layout.php frueh auf <html> gesetzt und funktioniert damit auch dann,
 * wenn Proxy/Webserver Sec-Fetch-Dest nicht an PHP weiterreicht.
 */
html.wh-embedded-frame .wh-ribbon2,
html.wh-embedded-frame .wh-topbar,
html.wh-embedded-frame .wh-drawer,
html.wh-embedded-frame .wh-drawer-overlay,
html.wh-embedded-frame #whDrawerToggle,
html.wh-embedded-frame .wh-drawer-toggle,
html.wh-embedded-frame .wh-mobile-ribbon,
html.wh-embedded-frame .wh-mobile-nav {
  display: none !important;
}

html.wh-embedded-frame body {
  padding-bottom: 0 !important;
}

@media (max-width: 800px) {
  body .wh-ribbon2,
  body .wh-topbar,
  body .wh-drawer,
  body .wh-drawer-overlay,
  body #whDrawerToggle,
  body .wh-drawer-toggle {
    display: none !important;
  }

  body .wh-mobile-ribbon {
    display: block;
  }

  body[data-wh-form-key="start"] {
    padding-bottom: 0 !important;
  }

  .wh-mobile-pagebar {
    position: sticky;
    top: 0;
    z-index: 8000;
    display: grid;
    grid-template-columns: 46px minmax(0, 1fr) 46px;
    align-items: center;
    gap: 6px;
    min-height: 66px;
    padding: 7px 8px;
    box-sizing: border-box;
    background: var(--wh-panel);
    border-bottom: 1px solid var(--wh-border);
    box-shadow: 0 3px 12px var(--wh-shadow-12);
  }

  .wh-mobile-pagebar.is-start {
    grid-template-columns: 46px minmax(0, 1fr) 46px;
  }

  .wh-mobile-pagebar-home {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    color: var(--wh-primary);
    font-size: 27px;
    line-height: 1;
  }

  .wh-mobile-pagebar-spacer {
    display: block;
    width: 44px;
    height: 44px;
  }

  /*
   * Mobile Datensatz-Identitaet:
   * Kunden- und Flaschenbuchformular liefern den Datensatznamen bereits als
   * Seitentitel an die zentrale Mobile-Shell. Die doppelte Identitaetszeile
   * im Formular wird mobil ausgeblendet; Suche und restliche Kopf-Funktionen
   * bleiben erhalten.
   */
  body[data-wh-form-key="kundenformular"] .headerline > .personico,
  body[data-wh-form-key="kundenformular"] .headerline > .headline,
  body[data-wh-form-key="flaschenbuch"] .headerline > .personico,
  body[data-wh-form-key="flaschenbuch"] .headerline > .headline {
    display: none !important;
  }

  .wh-mobile-pagebar-back {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    min-width: 0;
    min-height: 44px;
    color: var(--wh-text);
    text-decoration: none;
    font-size: 14.5px;
    font-weight: 600;
  }

  .wh-mobile-pagebar-back-icon {
    color: var(--wh-primary);
    font-size: 34px;
    line-height: .8;
  }

  .wh-mobile-pagebar-center {
    min-width: 0;
    text-align: center;
  }

  .wh-mobile-pagebar-title {
    overflow: hidden;
    color: var(--wh-headline, var(--wh-text));
    font-size: 17px;
    font-weight: 750;
    line-height: 1.15;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .wh-mobile-pagebar-status {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin-top: 4px;
    padding: 2px 8px;
    border: 1px solid var(--wh-border);
    border-radius: 999px;
    background: var(--wh-panel2);
    color: var(--wh-text);
    font-size: 11px;
    line-height: 1.25;
  }

  .wh-mobile-pagebar-status[hidden] {
    display: none !important;
  }

  .wh-mobile-pagebar-status.is-locked {
    color: var(--wh-danger);
  }

  .wh-mobile-pagebar-status.is-open {
    color: var(--wh-primary);
  }

  .wh-mobile-pagebar-more {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    padding: 0;
    border: 0;
    border-radius: 12px;
    background: transparent;
    color: var(--wh-primary);
    cursor: pointer;
    font: inherit;
    font-size: 30px;
    line-height: 1;
  }

  .wh-mobile-pagebar-more:active,
  .wh-mobile-more-back:active,
  .wh-mobile-more-tab:active,
  .wh-mobile-more-item:active {
    background: var(--wh-panel2);
  }

  .wh-mobile-more-menu {
    position: absolute;
    top: calc(100% - 3px);
    right: 8px;
    z-index: 2;
    width: min(390px, calc(100vw - 16px));
    height: calc(100vh - 74px);
    height: calc(100dvh - 74px);
    max-height: calc(100vh - 74px);
    max-height: calc(100dvh - 74px);
    overflow: hidden;
    padding: 6px;
    box-sizing: border-box;
    border: 1px solid var(--wh-border);
    border-radius: 14px;
    background: var(--wh-panel);
    box-shadow: 0 12px 34px var(--wh-shadow-18);
  }

  .wh-mobile-more-menu.is-from-bottom {
    position: fixed;
    top: 8px;
    right: 8px;
    bottom: calc(73px + env(safe-area-inset-bottom, 0px));
    z-index: 8002;
    height: auto;
    max-height: none;
  }

  .wh-mobile-footer-more {
    flex: 1 1 0;
    width: 0;
    min-width: 0;
    padding: 0;
    font: inherit;
    font-size: 28px;
    line-height: 1;
  }

  .wh-mobile-footer-more[aria-expanded="true"] {
    background: var(--wh-panel2);
    color: var(--wh-primary);
  }

  .wh-mobile-more-menu[hidden],
  .wh-mobile-more-panel[hidden] {
    display: none !important;
  }

  .wh-mobile-more-root {
    position: relative;
    height: 100%;
    min-height: 0;
  }

  .wh-mobile-more-tabs,
  .wh-mobile-more-actions {
    display: grid;
    gap: 0;
  }

  .wh-mobile-more-tabs {
    width: 132px;
    max-height: 100%;
    overflow-y: auto;
    padding: 0 7px 0 0;
    box-sizing: border-box;
    border-right: 1px solid var(--wh-border);
  }

  .wh-mobile-more-tab {
    position: relative;
    display: flex;
    align-items: center;
    gap: 7px;
    width: 100%;
    min-height: 38px;
    padding: 4px 7px;
    box-sizing: border-box;
    border: 0;
    border-left: 3px solid transparent;
    border-radius: 7px 0 0 7px;
    background: transparent;
    color: var(--wh-text);
    cursor: pointer;
    font: inherit;
    font-size: 13px;
    font-weight: 700;
    line-height: 1.12;
    text-align: left;
    text-decoration: none;
    white-space: nowrap;
  }

  .wh-mobile-more-tab + .wh-mobile-more-tab {
    border-top: 1px solid var(--wh-line-08);
  }

  .wh-mobile-more-tab.is-active {
    padding-left: 5px;
    border-left-color: var(--wh-primary);
    background: var(--wh-panel2);
    color: var(--wh-headline, var(--wh-text));
    font-weight: 800;
  }

  .wh-mobile-more-root.has-open-tab .wh-mobile-more-tab.is-active::after {
    content: "";
    position: absolute;
    top: 0;
    right: -8px;
    bottom: 0;
    width: 8px;
    background: var(--wh-panel2);
  }

  .wh-mobile-more-tab.is-disabled {
    opacity: .42;
    cursor: default;
  }

  .wh-mobile-more-tab-icon {
    display: inline-flex;
    flex: 0 0 16px;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    color: var(--wh-primary);
  }

  .wh-mobile-more-tab-icon svg,
  .wh-mobile-more-tab-icon img {
    display: block;
    width: 16px;
    height: 16px;
    object-fit: contain;
  }

  .wh-mobile-more-tab.is-active .wh-mobile-more-tab-icon {
    color: var(--wh-headline, var(--wh-primary));
  }

  .wh-mobile-more-tab-label {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .wh-mobile-more-content {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    left: 132px;
    display: none;
    padding-left: 7px;
    box-sizing: border-box;
  }

  .wh-mobile-more-root.has-open-tab .wh-mobile-more-content {
    display: block;
  }

  .wh-mobile-more-panel {
    min-width: 0;
    height: 100%;
    max-height: none;
    overflow: auto;
    padding: 4px;
    box-sizing: border-box;
    border: 1px solid var(--wh-border);
    border-radius: 0 10px 10px 10px;
    background: var(--wh-panel);
    box-shadow: 0 8px 24px var(--wh-shadow-18);
  }

  .wh-mobile-more-group + .wh-mobile-more-group {
    margin-top: 5px;
    padding-top: 5px;
    border-top: 1px solid var(--wh-border);
  }

  .wh-mobile-more-group-title,
  .wh-mobile-more-menu-caption {
    padding: 4px 8px 2px;
    color: var(--wh-muted, var(--wh-text));
    font-size: 10.5px;
    font-weight: 700;
  }

  .wh-mobile-more-menu-caption:not(:first-child) {
    margin-top: 3px;
  }

  .wh-mobile-more-item {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    min-height: 38px;
    padding: 5px 8px;
    box-sizing: border-box;
    border: 0;
    border-radius: 7px;
    background: transparent;
    color: var(--wh-text);
    cursor: pointer;
    font: inherit;
    font-size: 13px;
    line-height: 1.15;
    text-align: left;
    text-decoration: none;
  }

  .wh-mobile-more-item + .wh-mobile-more-item {
    border-top: 1px solid var(--wh-line-08);
  }

  .wh-mobile-more-item.is-disabled {
    opacity: .42;
    cursor: default;
    pointer-events: none;
  }

  .wh-mobile-action-icon {
    flex: 0 0 20px;
    width: 20px;
    height: 20px;
    object-fit: contain;
  }

  .wh-mobile-action-label {
    min-width: 0;
  }

  .wh-mobile-nav .mob-btn.is-disabled,
  .wh-mobile-nav .mob-btn.is-unavailable {
    opacity: .38;
    pointer-events: none;
  }

  .wh-mobile-nav .mob-btn.is-unavailable {
    visibility: hidden;
  }
}

@media (max-width: 390px) {
  .wh-mobile-pagebar {
    grid-template-columns: 48px minmax(0, 1fr) 44px;
  }

  .wh-mobile-pagebar-back-text {
    display: none;
  }
}
