/* Global mobile baseline for all platform apps */
@media (max-width: 900px) {
  html,
  body {
    max-width: 100%;
    overflow-x: hidden !important;
  }

  body {
    font-size: 16px;
    line-height: 1.4;
  }

  img,
  svg,
  video,
  canvas {
    max-width: 100%;
    height: auto;
  }

  .tabs-bar,
  .tab-bar,
  .table-wrap,
  .table-wrapper,
  .responsive-scroll,
  .scroll-wrap,
  .scroll-x {
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch;
  }

  table {
    display: block;
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  table thead,
  table tbody,
  table tr {
    width: max-content;
    min-width: 100%;
  }

  input:not([type="checkbox"]):not([type="radio"]),
  select,
  textarea,
  button {
    font-size: 16px !important;
  }

  button,
  .btn,
  a.btn,
  [role="button"],
  input[type="button"],
  input[type="submit"],
  input[type="reset"] {
    min-height: 44px;
  }

  a,
  button,
  [role="button"],
  input,
  select,
  textarea,
  label {
    touch-action: manipulation;
  }

  .toolbar,
  .filter-bar,
  .actions,
  .form-row,
  .row {
    gap: 8px;
  }
}

@media (max-width: 900px) {
  table.mobile-card-table {
    display: block !important;
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    border-collapse: separate !important;
    border-spacing: 0 !important;
    background: transparent !important;
  }

  table.mobile-card-table thead {
    display: none !important;
  }

  table.mobile-card-table tbody {
    display: block !important;
    width: 100% !important;
  }

  table.mobile-card-table tr {
    display: block !important;
    width: 100% !important;
    margin: 0 0 12px 0 !important;
    padding: 10px 12px !important;
    border: 1px solid rgba(100, 116, 139, 0.25) !important;
    border-radius: 12px !important;
    background: rgba(255, 255, 255, 0.95) !important;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.06) !important;
  }

  table.mobile-card-table td,
  table.mobile-card-table th {
    display: flex !important;
    width: 100% !important;
    align-items: flex-start !important;
    justify-content: space-between !important;
    gap: 10px !important;
    border: 0 !important;
    padding: 8px 0 !important;
    text-align: left !important;
    white-space: normal !important;
    overflow-wrap: anywhere !important;
    background: transparent !important;
  }

  table.mobile-card-table td::before {
    content: attr(data-label);
    display: inline-block;
    min-width: 42%;
    max-width: 48%;
    font-size: 12px;
    line-height: 1.3;
    font-weight: 700;
    color: #475569;
    text-transform: uppercase;
    letter-spacing: 0.2px;
    padding-top: 1px;
  }

  table.mobile-card-table td[data-label=""]::before {
    display: none;
  }

  table.mobile-card-table td > * {
    max-width: 56%;
  }

  table.mobile-card-table td .btn,
  table.mobile-card-table td button,
  table.mobile-card-table td a {
    min-height: 40px;
  }
}

/* ═══════════════════════════════════════════════════════════════
   MOBILE UX EXTENSIONS v2.0
   Bottom-Sheet, Bottom-Nav, FAB, Install-Banner
   ═══════════════════════════════════════════════════════════════ */

/* ── Bottom Sheet Modal ── */
.m-bottom-sheet-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 500;
  opacity: 0;
  pointer-events: none;
  transition: opacity 250ms ease;
}
.m-bottom-sheet-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.m-bottom-sheet {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--ds-bg-card, #fff);
  border-radius: 18px 18px 0 0;
  box-shadow: 0 -8px 32px rgba(0,0,0,0.2);
  max-height: 88vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  z-index: 501;
  transform: translateY(100%);
  transition: transform 300ms cubic-bezier(0.32, 0.72, 0, 1);
  padding-bottom: env(safe-area-inset-bottom, 0);
}
.m-bottom-sheet.active {
  transform: translateY(0);
}

.m-bottom-sheet-handle {
  width: 36px;
  height: 4px;
  background: var(--ds-line, #ddd);
  border-radius: 2px;
  margin: 10px auto 6px;
  display: block;
}

/* ── Bottom Navigation Bar ── */
@media (max-width: 768px) {
  .m-bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 64px;
    padding-bottom: env(safe-area-inset-bottom, 0);
    background: var(--ds-bg-card, #fff);
    border-top: 1px solid var(--ds-line, #e5e7eb);
    display: flex;
    align-items: center;
    justify-content: space-around;
    z-index: 90;
    box-shadow: 0 -2px 12px rgba(0,0,0,0.06);
  }

  .m-bottom-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    flex: 1;
    padding: 6px 0;
    color: var(--ds-text-subtle, #94a3b8);
    text-decoration: none;
    font-size: 10px;
    font-weight: 600;
    border: none;
    background: none;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    transition: color 150ms ease;
    min-height: 48px;
  }

  .m-bottom-nav-item svg {
    width: 22px;
    height: 22px;
    stroke: currentColor;
    fill: none;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
  }

  .m-bottom-nav-item.active {
    color: var(--ds-brand, #2563eb);
  }

  .m-bottom-nav-item.active svg {
    stroke-width: 2.5;
  }

  /* Platz fuer Bottom-Nav */
  body.has-bottom-nav {
    padding-bottom: calc(64px + env(safe-area-inset-bottom, 0));
  }
}

/* ── Floating Action Button ── */
@media (max-width: 768px) {
  .m-fab {
    position: fixed;
    right: 16px;
    bottom: calc(80px + env(safe-area-inset-bottom, 0));
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--ds-brand, #2563eb);
    color: #fff;
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(0,0,0,0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 80;
    transition: transform 200ms ease, box-shadow 200ms ease;
    -webkit-tap-highlight-color: transparent;
  }

  .m-fab:active {
    transform: scale(0.92);
  }

  .m-fab svg {
    width: 24px;
    height: 24px;
    stroke: currentColor;
    fill: none;
    stroke-width: 2.5;
    stroke-linecap: round;
  }

  /* FAB ohne Bottom-Nav */
  body:not(.has-bottom-nav) .m-fab {
    bottom: calc(20px + env(safe-area-inset-bottom, 0));
  }
}

/* ── Enhanced Touch Targets (48px fuer Outdoor/Monteure) ── */
@media (max-width: 768px) {
  .m-touch-lg button,
  .m-touch-lg .btn,
  .m-touch-lg a.btn,
  .m-touch-lg [role="button"],
  .m-touch-lg input[type="button"],
  .m-touch-lg input[type="submit"] {
    min-height: 48px !important;
  }

  .m-touch-lg input:not([type="checkbox"]):not([type="radio"]),
  .m-touch-lg select,
  .m-touch-lg textarea {
    min-height: 48px !important;
    padding: 12px !important;
  }
}

/* ── Pull-to-Refresh Indicator ── */
@media (max-width: 768px) {
  .m-pull-indicator {
    position: fixed;
    top: 0;
    left: 50%;
    transform: translateX(-50%) translateY(-60px);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--ds-bg-card, #fff);
    box-shadow: 0 2px 12px rgba(0,0,0,0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
    transition: transform 200ms ease;
  }

  .m-pull-indicator.visible {
    transform: translateX(-50%) translateY(16px);
  }

  .m-pull-indicator.refreshing svg {
    animation: m-spin 800ms linear infinite;
  }

  @keyframes m-spin {
    to { transform: rotate(360deg); }
  }
}

/* ── PWA Install Banner ── */
@media (max-width: 768px) {
  .m-install-banner {
    position: fixed;
    bottom: calc(72px + env(safe-area-inset-bottom, 0));
    left: 12px;
    right: 12px;
    background: var(--ds-bg-card, #fff);
    border: 1px solid var(--ds-line, #e5e7eb);
    border-radius: 14px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.15);
    padding: 14px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    z-index: 85;
    animation: ds-slide-up 300ms ease;
  }

  .m-install-banner-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    flex-shrink: 0;
  }

  .m-install-banner-text {
    flex: 1;
    font-size: 13px;
    line-height: 1.3;
    color: var(--ds-text-strong, #1a1a2e);
  }

  .m-install-banner-text strong {
    display: block;
    font-weight: 700;
    margin-bottom: 2px;
  }

  .m-install-banner-btn {
    padding: 8px 16px;
    border-radius: 999px;
    background: var(--ds-brand, #2563eb);
    color: #fff;
    border: none;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
  }

  .m-install-banner-close {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: none;
    background: transparent;
    color: var(--ds-text-subtle, #999);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
  }
}

/* ── Swipe Action Hints ── */
@media (max-width: 768px) {
  .m-swipeable {
    position: relative;
    overflow: hidden;
  }

  .m-swipe-action {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 12px;
    font-weight: 600;
  }

  .m-swipe-action-right {
    right: -80px;
    background: var(--ds-danger, #ef4444);
  }

  .m-swipe-action-left {
    left: -80px;
    background: var(--ds-ok, #22c55e);
  }
}
