@media (max-width: 768px) {
  html,
  body {
    overflow-x: hidden;
  }

  body {
    -webkit-text-size-adjust: 100%;
    -ms-text-size-adjust: 100%;
  }

  main {
    margin: 0;
    padding: 0;
  }

  input,
  textarea,
  select {
    font-size: 16px !important;
    -webkit-appearance: none;
    appearance: none;
  }

  input[type="checkbox"],
  input[type="radio"] {
    width: 20px;
    height: 20px;
    cursor: pointer;
    min-height: auto;
    min-width: auto;
  }

  button,
  .btn,
  a[role="button"] {
    min-height: 44px;
    display: inline-block;
  }

  button.inline-flex,
  button.inline-block,
  button[class*="flex"] {
    min-height: auto;
  }

  .rounded-lg {
    border-radius: 0.5rem;
  }

  .p-4 {
    padding: 1rem;
  }

  .px-4 {
    padding-left: 1rem;
    padding-right: 1rem;
  }

  .py-4 {
    padding-top: 0.75rem;
    padding-bottom: 0.75rem;
  }

  .gap-2 {
    gap: 0.5rem;
  }

  .gap-3 {
    gap: 0.75rem;
  }

  .gap-4 {
    gap: 1rem;
  }

  .h-10 {
    height: auto;
    min-height: 44px;
  }

  footer {
    margin-bottom: 1rem;
  }

  /* Modal overlays - Sidebar hat eigene z-index Werte */

  .modal,
  [role="dialog"] {
    max-height: 90vh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  textarea {
    min-height: 100px;
    resize: vertical;
  }

  select {
    padding-right: 2rem;
  }

  /* Dropdowns bleiben relativ zum Parent */

  .flex-col {
    flex-direction: column;
  }

  .flex-row {
    flex-direction: row;
  }

  .w-full {
    width: 100%;
  }

  .max-w-\[1200px\],
  .max-w-xs,
  .max-w-sm,
  .max-w-md {
    max-width: 100%;
  }

  .grid {
    gap: 1rem;
  }

  .shadow-lg,
  .shadow-xl,
  .shadow-card {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  }
}

@media (max-width: 640px) {
  .text-lg {
    font-size: 1rem;
  }

  .text-xl {
    font-size: 1.125rem;
  }

  .px-4 {
    padding-left: 1rem;
    padding-right: 1rem;
  }

  .px-6 {
    padding-left: 1.25rem;
    padding-right: 1.25rem;
  }

  .py-3 {
    padding-top: 0.75rem;
    padding-bottom: 0.75rem;
  }

  .py-4 {
    padding-top: 1rem;
    padding-bottom: 1rem;
  }

  .gap-2 {
    gap: 0.5rem;
  }

  .gap-4 {
    gap: 1rem;
  }

  h1,
  h2,
  h3,
  h4 {
    word-break: break-word;
    overflow-wrap: break-word;
  }

  table {
    font-size: 0.875rem;
  }

  table th,
  table td {
    padding: 0.75rem 0.5rem;
  }

  .space-y-4 > * + * {
    margin-top: 1rem;
  }

  .w-full {
    width: 100%;
  }

  .max-w-xs {
    max-width: 100%;
  }

  .max-w-sm {
    max-width: 100%;
  }

  .max-w-md {
    max-width: 100%;
  }

  .col-span-2,
  .col-span-3,
  .col-span-4 {
    grid-column: span 1;
  }
}

@media (max-width: 480px) {
  h1 {
    font-size: 1.5rem;
  }

  h2 {
    font-size: 1.25rem;
  }

  h3 {
    font-size: 1.125rem;
  }

  .text-base {
    font-size: 0.95rem;
  }

  .text-sm {
    font-size: 0.875rem;
  }

  .text-xs {
    font-size: 0.8rem;
  }

  .mx-auto {
    margin-left: auto;
    margin-right: auto;
    max-width: 100%;
  }

  .shadow-lg {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  }

  .shadow-xl {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  }

  .truncate {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  button,
  .btn,
  a[role="button"] {
    width: 100%;
    display: block;
  }

  button.w-auto,
  button.inline-block {
    width: auto;
    display: inline-block;
  }

  .grid-cols-2 {
    grid-template-columns: 1fr;
  }

  .grid-cols-3 {
    grid-template-columns: 1fr;
  }

  .flex-row {
    flex-direction: column;
  }

  .flex-row.sm\:flex-row {
    flex-direction: column;
  }
}

@supports (padding: max(0px)) {
  /* Body nur Safe-Area ohne extra Padding */
  body {
    padding-left: env(safe-area-inset-left, 0);
    padding-right: env(safe-area-inset-right, 0);
    padding-top: env(safe-area-inset-top, 0);
    padding-bottom: env(safe-area-inset-bottom, 0);
  }

  .safe-area-top {
    padding-top: env(safe-area-inset-top, 0);
  }

  .safe-area-bottom {
    padding-bottom: env(safe-area-inset-bottom, 0);
  }

  .safe-area-left {
    padding-left: env(safe-area-inset-left, 0);
  }

  .safe-area-right {
    padding-right: env(safe-area-inset-right, 0);
  }
}

@media (hover: none) and (pointer: coarse) {
  button:hover,
  a:hover {
    background-color: inherit;
  }

  button:active,
  a:active {
    opacity: 0.7;
  }
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="tel"],
input[type="url"],
textarea,
select {
  -webkit-appearance: none;
  appearance: none;
  border-radius: 0.375rem;
}

@media (max-width: 768px) {
  .hide-mobile {
    display: none !important;
  }

  .show-mobile {
    display: block !important;
  }
}

@media (min-width: 769px) {
  .hide-desktop {
    display: none !important;
  }

  .show-desktop {
    display: block !important;
  }
}

@media print {
  .no-print,
  .no-print * {
    display: none !important;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

@media (prefers-color-scheme: dark) {
  input,
  textarea,
  select {
    background-color: #1f2937;
    color: #f3f4f6;
  }

  input::placeholder,
  textarea::placeholder {
    color: #9ca3af;
  }
}
