/**
 * Tablet + PWA layout tuning for tab-based app pages.
 * Applies to pages with body.app-tab-page.
 */

:root {
  --app-gutter-mobile: 0.875rem;
  --app-gutter-tablet: 1.25rem;
  --app-max-width: 1220px;
}

body.app-tab-page {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  overscroll-behavior-y: contain;
}

body.app-tab-page main {
  width: min(100%, var(--app-max-width));
  margin-inline: auto;
}

@media (max-width: 767px) {
  body.app-tab-page main {
    padding-left: var(--app-gutter-mobile) !important;
    padding-right: var(--app-gutter-mobile) !important;
  }
}

@media (min-width: 768px) and (max-width: 1024px) {
  body.app-tab-page main {
    padding-left: var(--app-gutter-tablet) !important;
    padding-right: var(--app-gutter-tablet) !important;
  }

  body.app-tab-page .container,
  body.app-tab-page .max-w-7xl {
    max-width: 100% !important;
    padding-left: var(--app-gutter-tablet) !important;
    padding-right: var(--app-gutter-tablet) !important;
  }

  /* Better card spacing on tablets */
  body.app-tab-page .rounded-xl,
  body.app-tab-page .rounded-2xl,
  body.app-tab-page .rounded-lg {
    border-radius: 0.875rem;
  }

  /* Rechnungserstellung: rows stack cleaner on tablet than dense 12-col grid */
  body.app-tab-page #invoice-items .invoice-item-row {
    display: grid !important;
    grid-template-columns: 1fr !important;
    gap: 0.875rem !important;
    padding: 1rem !important;
  }

  body.app-tab-page #invoice-items .invoice-item-row > * {
    grid-column: auto !important;
  }
}

/* PWA standalone: safe-area aware top/bottom spacing */
@media (display-mode: standalone), (display-mode: fullscreen) {
  body.app-tab-page {
    padding-top: max(0.5rem, env(safe-area-inset-top));
  }

  body.app-tab-page main {
    padding-bottom: calc(6.25rem + env(safe-area-inset-bottom, 0px)) !important;
  }
}

/* Top navigation (desktop/tablet) */
.app-top-nav {
  display: flex;
  align-items: center;
  gap: 0.375rem;
}

.app-nav-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2.5rem;
  padding: 0.5rem 0.85rem;
  border-radius: 0.625rem;
  color: #4b5563;
  font-size: 0.98rem;
  font-weight: 500;
  text-decoration: none;
  transition:
    background-color 0.2s ease,
    color 0.2s ease;
}

.app-nav-link:hover,
.app-nav-link:focus-visible {
  background: #f3f4f6;
  color: #1f2937;
}

.app-nav-link.active {
  background: #eaf3ff;
  color: #2563eb;
  font-weight: 700;
}

.app-nav-link--primary {
  background: #4a90e2;
  color: #fff;
  font-weight: 700;
}

.app-nav-link--primary:hover,
.app-nav-link--primary:focus-visible {
  background: #357abd;
  color: #fff;
}

.app-nav-logout {
  margin-left: 0.4rem;
  border: 1px solid #e5e7eb;
  background: #fff;
}

.app-nav-more {
  position: relative;
}

.app-nav-more summary {
  list-style: none;
  cursor: pointer;
}

.app-nav-more summary::-webkit-details-marker {
  display: none;
}

.app-nav-more[open] > summary {
  background: #f3f4f6;
  color: #1f2937;
}

.app-nav-more-menu {
  position: absolute;
  top: calc(100% + 0.5rem);
  right: 0;
  min-width: 13.5rem;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 0.75rem;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.12);
  padding: 0.4rem;
  z-index: 60;
}

.app-nav-more-menu a {
  display: block;
  color: #374151;
  text-decoration: none;
  border-radius: 0.5rem;
  padding: 0.55rem 0.7rem;
  font-size: 0.94rem;
}

.app-nav-more-menu a:hover,
.app-nav-more-menu a:focus-visible {
  background: #f3f4f6;
  color: #111827;
}

.app-nav-more-menu a.active {
  background: #eaf3ff;
  color: #2563eb;
  font-weight: 700;
}
