/* Layout nativo — app Capacitor / ?app=1 / PWA standalone */

:root {
  --app-tab-height: 64px;
  --app-safe-top: env(safe-area-inset-top, 0px);
  --app-safe-bottom: env(safe-area-inset-bottom, 0px);
}

html.native-app {
  -webkit-tap-highlight-color: transparent;
}

html.native-app body {
  overscroll-behavior-y: none;
  padding-top: 0;
  padding-left: env(safe-area-inset-left, 0px);
  padding-right: env(safe-area-inset-right, 0px);
  font-size: 14px;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

html.native-app input,
html.native-app select,
html.native-app textarea {
  font-size: 16px;
}

html.native-app #home-screen {
  display: none !important;
}

html.native-app #auth-screen:not(.hidden) {
  padding-top: calc(24px + var(--app-safe-top));
  padding-bottom: calc(24px + var(--app-safe-bottom));
  background: var(--surface);
}

html.native-app .auth-card {
  width: min(100%, 420px);
  border-radius: 20px;
  box-shadow: 0 8px 32px rgba(15, 23, 42, 0.08);
}

html.native-app .auth-form input {
  font-size: 16px;
  min-height: 48px;
}

html.native-app #app-shell:not(.hidden) {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
}

html.native-app #app-shell .header {
  position: sticky;
  top: 0;
  z-index: 40;
  background: var(--brand);
  border-bottom: none;
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.06);
  padding-top: env(safe-area-inset-top, 0px);
  padding-left: env(safe-area-inset-left, 0px);
  padding-right: env(safe-area-inset-right, 0px);
}

html.native-app #app-shell .header-inner {
  padding: 10px 16px 12px;
  max-width: none;
}

html.native-app #app-shell .brand-icon {
  background: rgba(255, 255, 255, 0.2);
}

html.native-app #app-shell .brand h1,
html.native-app #app-shell .brand p {
  color: #fff;
}

html.native-app #app-shell .brand p {
  opacity: 0.85;
  font-size: 0.625rem;
}

html.native-app #app-shell .header-actions {
  display: none;
}

html.native-app #app-shell .main {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 12px 14px calc(var(--app-tab-height) + var(--app-safe-bottom) + 72px);
  max-width: none;
}

html.native-app #app-shell .filters {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--surface);
  padding-bottom: 8px;
  margin-bottom: 4px;
}

html.native-app #app-shell .search-wrap input {
  font-size: 16px;
  min-height: 44px;
  border-radius: 12px;
}

html.native-app #app-shell .filters-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

html.native-app #app-shell .filters select {
  display: block;
  width: 100%;
  min-width: 0;
  min-height: 44px;
  font-size: 16px;
  border-radius: 12px;
  padding: 8px 10px;
  appearance: auto;
}

html.native-app #app-shell .filter-check,
html.native-app #app-shell #btn-archive-delivered {
  display: none;
}

html.native-app #app-shell .purchase-menu-trigger {
  min-height: 44px;
  font-size: 0.9375rem;
}

html.native-app #app-shell .purchase-menu-item {
  font-size: 1rem;
  padding: 12px 14px;
}

html.native-app .app-footer {
  display: none;
}

html.native-app #app-shell .row-event-text {
  font-size: 0.8125rem;
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

html.native-app #app-shell .row-event-clickable {
  padding: 8px 10px;
  margin: 4px -10px 0;
}

html.native-app #app-shell .row-event-clickable::after {
  font-size: 0.6875rem;
  margin-top: 4px;
}

html.native-app #app-shell .stats {
  display: none !important;
}

html.native-app .mobile-tabbar {
  display: flex;
}

html.native-app .mobile-fab {
  display: flex;
}

/* Bottom tab bar */
.mobile-tabbar {
  display: none;
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 50;
  height: calc(var(--app-tab-height) + var(--app-safe-bottom));
  padding-bottom: var(--app-safe-bottom);
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--border);
  justify-content: space-around;
  align-items: flex-start;
  padding-top: 6px;
}

.mobile-tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 4px 0;
  border: none;
  background: none;
  color: var(--text-muted);
  font-size: 0.625rem;
  font-weight: 500;
  cursor: pointer;
}

.mobile-tab svg {
  width: 22px;
  height: 22px;
}

.mobile-tab.active {
  color: var(--brand);
}

.mobile-fab {
  display: none;
  position: fixed;
  right: 16px;
  bottom: calc(var(--app-tab-height) + var(--app-safe-bottom) + 12px);
  z-index: 51;
  width: 56px;
  height: 56px;
  border: none;
  border-radius: 50%;
  background: var(--brand);
  color: #fff;
  box-shadow: 0 4px 16px rgba(232, 93, 93, 0.45);
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.mobile-fab:active {
  transform: scale(0.96);
}

/* Account sheet */
.mobile-sheet-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 80;
  background: rgba(15, 23, 42, 0.4);
}

html.native-app .mobile-sheet-backdrop:not(.hidden) {
  display: block;
}

.mobile-sheet {
  display: none;
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 81;
  background: var(--surface-raised);
  border-radius: 20px 20px 0 0;
  padding: 12px 16px calc(16px + var(--app-safe-bottom));
  box-shadow: 0 -8px 32px rgba(15, 23, 42, 0.12);
}

html.native-app .mobile-sheet:not(.hidden) {
  display: block;
}

.mobile-sheet-handle {
  width: 36px;
  height: 4px;
  border-radius: 999px;
  background: var(--border);
  margin: 0 auto 16px;
}

.mobile-sheet-profile {
  text-align: center;
  padding: 8px 0 16px;
  border-bottom: 1px solid var(--border-subtle);
  margin-bottom: 8px;
}

.mobile-sheet-profile strong {
  display: block;
  font-size: 1rem;
  color: var(--text-strong);
}

.mobile-sheet-profile span {
  font-size: 0.8125rem;
  color: var(--text-muted);
}

.mobile-sheet-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 14px 8px;
  border: none;
  background: none;
  font-size: 0.9375rem;
  color: var(--text-strong);
  text-align: left;
  cursor: pointer;
  border-radius: 10px;
}

.mobile-sheet-item:active {
  background: var(--surface);
}

.mobile-sheet-item.danger {
  color: #dc2626;
}

.mobile-sheet-close {
  margin-top: 8px;
  width: 100%;
}

html.native-app body.sheet-open {
  overflow: hidden;
}

html.native-app .toast {
  bottom: calc(var(--app-tab-height) + var(--app-safe-bottom) + 12px);
}

html.native-app .import-tracking-banner {
  padding: 18px 16px;
}

html.native-app .import-tracking-banner-title {
  font-size: 1.125rem;
}

html.native-app .import-tracking-banner-eta {
  font-size: 1rem;
}

html.native-app .modal {
  padding-bottom: calc(var(--app-safe-bottom) + 8px);
}

@media (min-width: 768px) {
  html.native-app #app-shell .main {
    max-width: 720px;
    margin: 0 auto;
    width: 100%;
  }

  html.native-app .mobile-tabbar,
  html.native-app .mobile-fab {
    max-width: 720px;
    left: 50%;
    transform: translateX(-50%);
  }

  html.native-app .mobile-sheet {
    max-width: 720px;
    left: 50%;
    transform: translateX(-50%);
  }
}
