/* Responsive CSS für das Speditionstool */
/* Erweiterte Media Queries und responsive Anpassungen für moderne mobile Geräte */

/* Base responsive settings */
html {
  box-sizing: border-box;
  -webkit-tap-highlight-color: rgba(0, 0, 0, 0);
}

*, *:before, *:after {
  box-sizing: inherit;
}

body {
  overflow-x: hidden;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

img {
  max-width: 100%;
  height: auto;
}

/* Bessere Lesbarkeit auf kleinen Geräten */
@media (max-width: 576px) {
  body {
    font-size: 14px;
  }
  
  h1 {
    font-size: 1.8rem;
    margin-bottom: 0.75rem;
  }
  
  h2 {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
  }
  
  h3 {
    font-size: 1.2rem;
    margin-bottom: 0.5rem;
  }
}

/* Optimierungen für neuere iPhone und Android Modelle */
@media only screen and (device-width: 428px) and (device-height: 926px), /* iPhone 13 Pro Max, 12 Pro Max */
       only screen and (device-width: 390px) and (device-height: 844px), /* iPhone 13 Pro, 13, 12 Pro, 12 */
       only screen and (device-width: 375px) and (device-height: 812px), /* iPhone 11 Pro, XS, X */
       only screen and (min-width: 390px) and (max-width: 767px) { /* Neuere Android-Modelle */
  .card {
    border-radius: 16px;
    margin-bottom: 16px;
  }
  
  .form-control, .form-select, .btn {
    height: 48px;
    font-size: 16px; /* Prevent zoom on iOS */
  }

  .btn {
    padding-top: 12px;
    padding-bottom: 12px;
  }

  select.form-select {
    background-position: right 12px center;
  }
}

/* Responsive Tabellen */
.table-responsive {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

@media (max-width: 767px) {
  .table-mobile-cards thead {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
  }
  
  .table-mobile-cards tr {
    display: block;
    border: 1px solid #dee2e6;
    border-radius: 0.25rem;
    margin-bottom: 0.75rem;
    background-color: #fff;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  }
  
  .table-mobile-cards td {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #eee;
    padding: 0.75rem !important;
    min-height: 2.5rem;
  }
  
  .table-mobile-cards td:last-child {
    border-bottom: none;
  }
  
  .table-mobile-cards td::before {
    content: attr(data-label);
    font-weight: 600;
    margin-right: 1rem;
    width: 40%;
    color: #444;
    font-size: 0.9rem;
    text-align: left;
  }
  
  /* Verbesserte Darstellung von Badges und Icons in Tabellenzellen */
  .table-mobile-cards td .badge {
    margin-left: auto;
  }
  
  .table-mobile-cards td .btn {
    margin-left: auto;
    padding: 0.3rem 0.6rem;
  }
}

/* Navigation auf kleinen Geräten */
@media (max-width: 767px) {
  .navbar-brand-autodark {
    font-size: 1.2rem;
  }
  
  .navbar .container-xl {
    padding-left: 0.5rem;
    padding-right: 0.5rem;
  }
  
  .navbar-toggler {
    padding: 0.5rem;
    margin-right: 0.5rem;
  }
  
  .nav-link {
    padding: 0.75rem 1rem;
  }
  
  .dropdown-menu {
    margin-top: 0.25rem;
    padding: 0.25rem 0;
    border-radius: 12px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
  }
  
  .dropdown-item {
    padding: 0.75rem 1.25rem;
    border-radius: 8px;
    margin: 2px 4px;
  }

  /* Verbesserte Touch-Bereiche */
  .nav-link, .dropdown-item, .btn {
    min-height: 44px; /* Apple's empfohlene Mindesthöhe für Touch-Targets */
    display: flex;
    align-items: center;
  }
}

/* Dashboard-Karten auf kleineren Geräten */
@media (max-width: 767px) {
  .card-body {
    padding: 1rem;
  }
  
  .card-sm .card-body {
    padding: 0.875rem;
  }
  
  .avatar {
    width: 32px;
    height: 32px;
    font-size: 1rem;
  }
  
  .font-weight-medium {
    font-size: 0.9rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 130px;
    display: block;
  }
  
  .text-secondary {
    font-size: 0.85rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 130px;
    display: block;
  }
  
  /* Spezifische Anpassungen für den Versandrechner */
  .page-title {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
  }
  
  /* Verbesserungen für Formular auf mobilen Geräten */
  form .row > div[class^="col-"] {
    margin-bottom: 1rem;
  }
  
  .form-control, .form-select, .btn, .input-icon, .input-icon-addon {
    touch-action: manipulation; /* Verhindert Verzögerungen bei Taps auf iOS */
  }
  
  /* Größere Bedienelemente für Touch-Interaktion */
  .form-check-input, .btn-check + label {
    min-height: 24px;
    min-width: 24px;
  }
  
  .form-switch .form-check-input {
    height: 1.5rem;
    width: 2.75rem;
  }
  
  .form-check-label {
    line-height: 1.5rem;
    padding-top: 2px;
  }
}
  
  .card {
    border-radius: 0.375rem;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
  }
  
  .card:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 10px rgba(0, 0, 0, 0.08);
  }
  
  /* Verbesserte Dashboard-Statistiken */
  .card-sm {
    margin-bottom: 0.75rem;
  }
  
  .card-sm .btn {
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
  }
  
  /* Icons im Card besser positionieren */
  .card .col-auto {
    padding-right: 8px;
  }
}

/* Optimierte mobile Navigation */
@media (max-width: 767px) {
  /* Navbar-Kompakt-Modus beim Scrollen */
  .navbar-compact {
    padding-top: 0.25rem;
    padding-bottom: 0.25rem;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.15);
    background-color: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
  }
  
  .navbar-compact .navbar-brand {
    transform: scale(0.9);
    transform-origin: left center;
  }

  /* Verbesserter aktiver Link */
  .nav-link.active {
    background-color: var(--tblr-primary-lt);
    color: var(--tblr-primary) !important;
    border-radius: 6px;
    font-weight: 500;
  }

  /* Verbesserte Touch-Areas in der Navbar */
  .navbar-nav .nav-item {
    margin: 2px 0;
  }

  .navbar-collapse {
    max-height: 85vh;
    overflow-y: auto;
  }
}

/* Text-Verkürzungen für kleine Bildschirme */
@media (max-width: 767px) {
  .text-truncate-mobile {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 150px;
  }
}

/* Verbesserte Formulare für mobile Geräte */
@media (max-width: 767px) {
  .form-label {
    margin-bottom: 0.25rem;
    font-size: 0.9rem;
    font-weight: 500;
  }
  
  .form-control {
    font-size: 0.95rem;
    height: calc(1.5em + 0.75rem + 2px);
    padding: 0.375rem 0.5rem;
  }
  
  .input-icon-addon {
    padding: 0 0.5rem;
  }
  
  /* Verbesserte Fehleranzeige auf kleinen Bildschirmen */
  .invalid-feedback {
    font-size: 0.75rem;
    margin-top: 0.25rem;
  }
  
  /* Bessere Gruppierung von Formularelementen */
  .form-group, .mb-3 {
    margin-bottom: 0.75rem !important;
  }
  
  /* Optimierte Switches und Checkboxen für Touch */
  .form-check-input {
    width: 1.25rem;
    height: 1.25rem;
    margin-top: 0.125rem;
  }
  
  .form-check-label {
    padding-left: 0.25rem;
    padding-top: 0.125rem;
  }
  
  /* Bessere Abstände für Formular-Abschnitte */
  .form-footer {
    margin-top: 1rem;
    padding-top: 0.75rem;
  }
  
  /* Fixes für Select-Elemente auf mobilen Geräten */
  select.form-select, select.form-control {
    padding-right: 1.75rem;
    background-position: right 0.5rem center;
  }
  
  /* Verbesserte Input-Groups */
  .input-group > .form-control {
    min-height: 38px;
  }
}

/* Bessere Button-Größen für Touch-Geräte */
@media (max-width: 767px) {
  .btn {
    padding: 0.4rem 0.8rem;
    font-size: 0.9rem;
  }
  
  .btn-sm {
    padding: 0.25rem 0.5rem;
    font-size: 0.8rem;
  }
  
  .btn-lg {
    padding: 0.5rem 1rem;
    font-size: 1.1rem;
  }
  
  /* Optimierter Abstand zwischen Buttons */
  .btn + .btn {
    margin-left: 0.5rem;
  }
}

/* Optimierter Footer für Mobile */
@media (max-width: 767px) {
  .footer .container-xl {
    padding: 1.5rem 1rem;
  }
  
  .footer h4 {
    font-size: 1rem;
    margin-bottom: 0.5rem;
  }
  
  .footer .mb-2 {
    margin-bottom: 0.25rem !important;
  }
  
  .footer .py-4 {
    padding-top: 1.5rem !important;
    padding-bottom: 1.5rem !important;
  }
  
  .footer .mt-4 {
    margin-top: 1.5rem !important;
  }
}

/* Spacing utilities für kleine Geräte */
@media (max-width: 767px) {
  .container-xl {
    padding-left: 0.75rem;
    padding-right: 0.75rem;
  }
  
  .row {
    margin-right: -0.375rem;
    margin-left: -0.375rem;
  }
  
  .col, .col-1, .col-2, .col-3, .col-4, .col-5, .col-6, 
  .col-7, .col-8, .col-9, .col-10, .col-11, .col-12, 
  .col-sm, .col-sm-1, .col-sm-2, .col-sm-3, .col-sm-4, 
  .col-sm-5, .col-sm-6, .col-sm-7, .col-sm-8, .col-sm-9, 
  .col-sm-10, .col-sm-11, .col-sm-12 {
    padding-right: 0.375rem;
    padding-left: 0.375rem;
  }
  
  .g-2 {
    --bs-gutter-x: 0.5rem;
    --bs-gutter-y: 0.5rem;
  }
}

/* Verbesserte Darstellung auf mittelgroßen Geräten */
@media (min-width: 768px) and (max-width: 991px) {
  .container-xl {
    max-width: 95%;
  }
  
  .navbar-expand-md .navbar-nav .nav-link {
    padding-left: 0.5rem;
    padding-right: 0.5rem;
  }
  
  .card-deck .card {
    flex: 0 0 calc(50% - 30px);
    margin-bottom: 15px;
  }
}

/* Scrollbare Inhalte im Dashboard für kleine Geräte */
@media (max-width: 767px) {
  .table-responsive {
    max-height: 400px;
    overflow-y: auto;
  }
  
  .table th {
    position: sticky;
    top: 0;
    background-color: #f8f9fa;
    z-index: 1;
  }
}

/* Fokussierter Content auf kleinen Geräten */
@media (max-width: 576px) {
  .d-sm-none-custom {
    display: none !important;
  }
  
  .w-sm-100 {
    width: 100% !important;
  }
  
  .mb-sm-2 {
    margin-bottom: 0.5rem !important;
  }
}

/* Verbesserte Card-Layouts für kleine Geräte */
@media (max-width: 767px) {
  .card {
    margin-bottom: 0.75rem;
  }
  
  .card-header {
    padding: 0.75rem 1rem;
  }
  
  .card-footer {
    padding: 0.75rem 1rem;
  }
}

/* Verbesserte Druck-Stile */
@media print {
  .page {
    padding: 0 !important;
    margin: 0 !important;
  }
  
  .container-xl, .container-fluid {
    padding: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
  }
  
  .card {
    border: none !important;
    box-shadow: none !important;
    margin-bottom: 1rem !important;
    break-inside: avoid !important;
  }
  
  .card-body {
    padding: 0.5rem 0 !important;
  }
  
  .table th {
    color: #000 !important;
    background-color: #fff !important;
    border-bottom: 1px solid #000 !important;
  }
  
  .table td {
    border-color: #ddd !important;
  }
  
  /* Größere Schriftgrößen für bessere Lesbarkeit im Druck */
  body {
    font-size: 12pt !important;
    line-height: 1.4 !important;
  }
  
  h1, h2, h3, h4, h5, h6 {
    page-break-after: avoid !important;
    orphans: 3 !important;
    widows: 3 !important;
  }
}

/* Verbesserte Hover-Effekte für Interaktionselemente */
@media (hover: hover) {
  .btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.12);
    transition: all 0.2s ease;
  }
  
  .card a:hover, .nav-link:hover {
    transition: all 0.2s ease;
  }
  
  .table tr:hover {
    background-color: rgba(0, 0, 0, 0.03);
  }
}

/* Anpassungen für spezifische Templates */
/* Result-Seite */
@media (max-width: 767px) {
  .result-container .pricing-details {
    padding: 0.75rem;
  }
  
  .result-container h3 {
    font-size: 1.2rem;
    margin-bottom: 0.5rem;
  }
  
  .result-container .price {
    font-size: 1.5rem;
  }
  
  .result-container .breakdown-item {
    padding: 0.5rem 0;
  }
}

/* Berechtigungsrollen Interface */
@media (max-width: 767px) {
  .permissions-table td, .roles-table td {
    min-height: 3rem;
  }
  
  .permission-switch {
    transform: scale(0.9);
    margin-left: auto;
  }
}

/* Statusanzeige mit besserer Farbkodierung */
@media (max-width: 767px) {
  .badge {
    font-size: 0.75rem;
    padding: 0.35em 0.65em;
  }
  
  /* Die Badges etwas größer machen für Touch */
  td .badge {
    min-width: 70px;
    text-align: center;
  }
}

/* Verbessern Sie die Performance auf mobilen Geräten */
@media (max-width: 767px) {
  * {
    -webkit-tap-highlight-color: rgba(0, 0, 0, 0);
  }
  
  /* Reduzieren von Animationen/Übergängen auf langsamen Geräten */
  @media (prefers-reduced-motion) {
    * {
      transition-duration: 0.001ms !important;
      animation-duration: 0.001ms !important;
    }
  }
}

/* Weitere verbesserte Tabellendarstellung für alle Bildschirmgrößen */
.table-hover tbody tr:hover {
  background-color: rgba(0, 0, 0, 0.03);
}

.table th {
  white-space: nowrap;
  font-weight: 600;
  border-bottom-width: 2px;
}

/* Farbliche Hervorhebungen für verschiedene Status in Tabellen */
.status-new { color: #3498db; }
.status-processing { color: #f39c12; }
.status-completed { color: #2ecc71; }
.status-cancelled { color: #e74c3c; }

/* Verbesserte Zugänglichkeit für Formulare */
.form-control:focus, .form-select:focus, .form-check-input:focus {
  box-shadow: 0 0 0 0.25rem rgba(66, 153, 225, 0.25);
  border-color: #63b3ed;
}

@media (max-width: 767px) {
  input[type="text"], 
  input[type="email"], 
  input[type="password"], 
  input[type="url"], 
  input[type="number"], 
  textarea {
    font-size: 16px !important; /* Verhindert Zoom auf iOS */
  }
}