/* Grundlegende mobile Optimierungen */
body {
  padding-top: 56px; /* Höhe der Navbar berücksichtigen */
  font-size: 16px;
  line-height: 1.5;
  overflow-x: hidden;
  padding-bottom: 40px;
}

/* Responsive Containergröße */
.container {
  max-width: 100%;
  padding: 0 15px;
}

/* Hauptinhalt mit Abstand für fixierte Navbar */
.content-wrapper {
  padding-bottom: 60px; /* Platz für Footer */
  min-height: calc(100vh - 56px);
  display: flex;
  flex-direction: column;
}

/* Cards optimiert für mobile Geräte */
.card {
  margin-bottom: 1.5rem;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
  border-radius: 8px;
  overflow: hidden;
}

.card-header {
  font-weight: 500;
  padding: 12px 16px;
}

.card-body {
  padding: 16px;
}

/* Responsive Tabellen */
.table-container {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch; /* verbessert Scrolling auf iOS */
  margin-bottom: 1rem;
}

.table-responsive {
  min-height: 0.01%;
  overflow-x: auto;
  width: 100%;
  margin-bottom: 1rem;
  -webkit-overflow-scrolling: touch;
}

/* Größere Buttons für Touch-Eingabe */
.btn {
  padding: 0.5rem 1rem;
  font-size: 1rem;
  margin: 0.25rem 0;
  border-radius: 6px;
}

/* Formulare für mobile Geräte */
input,
select,
textarea,
.form-control {
  font-size: 16px !important; /* Verhindert Zoom auf iOS */
  height: auto;
  padding: 12px;
}

.form-label {
  margin-bottom: 0.5rem;
  font-weight: 500;
}

/* Verbesserungen für mobile Navigation */
.navbar-brand {
  font-weight: bold;
  font-size: 1.25rem;
}

.nav-link {
  padding: 0.7rem 1rem;
  font-size: 1rem;
}

.dropdown-menu {
  box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
}

.dropdown-item {
  padding: 0.6rem 1.2rem;
}

/* Verbesserte Dropdown-Menü-Darstellung auf mobilen Geräten */
@media (max-width: 991.98px) {
  .dropdown-menu {
    background-color: rgba(0, 0, 0, 0.05);
    border: none;
    margin-left: 1rem;
    box-shadow: none;
    padding: 0.5rem 0;
  }

  .dropdown-menu .dropdown-item {
    color: rgba(255, 255, 255, 0.85);
    padding: 0.65rem 1.5rem;
    white-space: normal;
  }

  .dropdown-menu .dropdown-item:hover,
  .dropdown-menu .dropdown-item:focus {
    background-color: rgba(0, 0, 0, 0.2);
    color: white;
  }

  .dropdown-menu .dropdown-divider {
    border-top-color: rgba(255, 255, 255, 0.1);
    margin: 0.4rem 0;
  }

  /* Verbesserte Touch-Bereiche für Dropdown-Toggle */
  .nav-item.dropdown .nav-link {
    padding: 0.8rem 1rem;
  }

  /* Dropdown-Menü-Animation */
  .dropdown-menu {
    opacity: 0;
    transform: translateY(-10px);
    transition: opacity 0.3s, transform 0.3s;
    display: block;
    visibility: hidden;
  }

  .dropdown-menu.show {
    opacity: 1;
    transform: translateY(0);
    visibility: visible;
  }
}

/* Fix für Dropdown-Menüs am rechten Bildschirmrand */
.dropdown-menu-end {
  right: 0;
  left: auto;
}

/* Anpassungen für Benachrichtigungen */
.alert {
  padding: 0.8rem 1rem;
  margin: 1rem 0;
  border-radius: 6px;
}

/* Button-Gruppen in Tabellen */
.table .btn {
  padding: 0.375rem 0.75rem;
  margin-bottom: 0.2rem;
}

/* Icon-Anpassungen */
.bi {
  margin-right: 0.25rem;
  vertical-align: text-top;
}

/* Größere Checkboxen und Radio-Buttons */
input[type="checkbox"],
input[type="radio"] {
  width: 20px;
  height: 20px;
  margin-top: 0.2rem;
}

/* Tabellen-Anpassungen für kleine Bildschirme */
@media (max-width: 767.98px) {
  .table-mobile-friendly {
    display: block;
    width: 100%;
  }

  .table-mobile-friendly thead {
    display: none;
  }

  .table-mobile-friendly tbody,
  .table-mobile-friendly th,
  .table-mobile-friendly td,
  .table-mobile-friendly tr {
    display: block;
  }

  .table-mobile-friendly tr {
    margin-bottom: 1rem;
    border: 1px solid #dee2e6;
    border-radius: 5px;
  }

  .table-mobile-friendly td {
    border: none;
    position: relative;
    padding-left: 50%;
    padding: 8px 8px 8px 50%;
    min-height: 38px;
    border-bottom: 1px solid #f0f0f0;
  }

  .table-mobile-friendly td::before {
    content: attr(data-title);
    position: absolute;
    left: 12px;
    width: 45%;
    font-weight: bold;
    padding-right: 10px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
}

/* Karten-Layout für Listen auf kleinen Geräten */
@media (max-width: 767.98px) {
  .card-list-item {
    margin-bottom: 1rem;
    border: 1px solid #dee2e6;
    border-radius: 5px;
    padding: 1rem;
  }

  .card-list-title {
    font-weight: bold;
    font-size: 1.1rem;
    margin-bottom: 0.5rem;
  }

  .card-list-actions {
    margin-top: 0.75rem;
    display: flex;
    gap: 0.5rem;
  }
}

/* Verbesserungen für Admin-Listen auf Mobilgeräten */
@media (max-width: 767.98px) {
  /* Tabellenüberschriften immer sichtbar halten */
  .admin-table thead {
    display: block;
  }

  /* Tabellenzellen für bessere Lesbarkeit anpassen */
  .admin-table td,
  .admin-table th {
    word-break: break-word;
    max-width: 150px;
    min-width: 65px;
  }

  /* Kleinere Schrift für Tabellen */
  .admin-table {
    font-size: 0.85rem;
  }

  /* Text abschneiden mit Ellipsis */
  .text-truncate-sm {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 120px;
    display: inline-block;
  }

  /* Spaltengröße für Benutzernamen/E-Mails */
  .admin-table .col-user {
    width: 25%;
  }

  /* Spaltengröße für Aktionen */
  .admin-table .col-actions {
    width: 30%;
  }

  /* Kompaktere Buttons in den Aktionen */
  .admin-table .btn-sm {
    padding: 0.25rem 0.4rem;
    font-size: 0.75rem;
  }

  /* Listenelemente in Cards für mobile Ansicht */
  .mobile-card-list {
    margin-bottom: 1rem;
  }

  .mobile-card-list .card {
    margin-bottom: 0.75rem;
  }

  .mobile-card-list .card-body {
    padding: 0.75rem;
  }

  .mobile-card-list .card-title {
    margin-bottom: 0.5rem;
    font-size: 1rem;
  }

  .mobile-card-list .card-text {
    font-size: 0.85rem;
    margin-bottom: 0.5rem;
  }

  .mobile-card-list .card-footer {
    padding: 0.5rem 0.75rem;
    background-color: transparent;
    border-top: 1px solid rgba(0, 0, 0, 0.125);
  }

  /* Buttons in Karten-Ansicht */
  .mobile-card-list .btn-group .btn {
    padding: 0.25rem 0.4rem;
    font-size: 0.8rem;
  }
}

/* Keine Mindesbreite für Tabellen auf Smartphones */
@media (max-width: 576px) {
  .table-sm-responsive {
    table-layout: auto;
    width: auto;
  }
}

/* Verbesserungen für Modals auf kleinen Bildschirmen */
@media (max-width: 576px) {
  .modal-dialog {
    margin: 0.5rem;
  }

  .modal-header {
    padding: 0.75rem 1rem;
  }

  .modal-body {
    padding: 1rem;
  }

  .modal-footer {
    padding: 0.75rem 1rem;
  }

  .modal-title {
    font-size: 1.1rem;
  }
}

/* Verbesserte lesbarkeit auf größeren Bildschirmen */
@media (min-width: 992px) {
  .container {
    max-width: 1140px;
    margin: 0 auto;
  }

  body {
    font-size: 1rem;
  }
}

.btn-close {
  padding: 0.8rem;
}

footer {
  background-color: #f8f9fa;
  padding: 1rem 0;
  margin-top: auto;
  font-size: 0.9rem;
  margin-top: 3rem;
  padding-top: 1rem;
  border-top: 1px solid #e9ecef;
  text-align: center;
  color: #6c757d;
}

.btn-group {
  white-space: nowrap;
}

.form-error {
  color: #dc3545;
  font-size: 0.875rem;
  margin-top: 0.25rem;
}

/* Anpassungen für die Tabellenfilterung */
.table-section {
  display: none; /* Standardmäßig versteckt */
  margin-bottom: 2rem;
}

/* Aktive Buttons in der Filterleiste hervorheben */
.btn-outline-primary.active {
  background-color: #0d6efd;
  color: white;
  font-weight: bold;
}

/* Filtergruppe für Tabellen */
.btn-group[role="group"] .btn {
  flex: 1;
  padding: 10px 5px;
  font-size: 0.85rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

@media (max-width: 380px) {
  .btn-group[role="group"] .btn {
    padding: 8px 2px;
    font-size: 0.7rem;
    letter-spacing: -0.5px;
  }
}

/* Favoriten-Stern Stile */
.favorite-toggle {
  background: none;
  border: none;
  cursor: pointer;
  transition: transform 0.2s ease;
  position: relative;
}

.favorite-toggle:hover {
  transform: scale(1.2);
}

.favorite-toggle .bi-star,
.favorite-toggle .bi-star-fill {
  font-size: 1.2rem;
}

/* Verarbeitungsanzeige für Favoriten-Toggle */
.favorite-processing {
  opacity: 0.6;
  pointer-events: none;
}

.favorite-processing::after {
  content: "";
  position: absolute;
  width: 10px;
  height: 10px;
  top: 50%;
  left: 50%;
  margin-top: -5px;
  margin-left: -5px;
  border-radius: 50%;
  border: 2px solid #ccc;
  border-top-color: #0d6efd;
  animation: spin 0.6s linear infinite;
}

@keyframes spin {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}

/* Animations-Klassen für Feedback */
@keyframes pulse {
  0% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.3);
  }
  100% {
    transform: scale(1);
  }
}

.favorite-added {
  animation: pulse 0.3s ease-in-out;
}

.favorite-removed {
  animation: pulse 0.3s ease-in-out;
}

/* Favoriten-Abschnitt im Dashboard */
.card-header.bg-warning {
  color: #212529;
  background-color: #ffc107 !important;
}

.card-header.bg-warning h3 {
  display: flex;
  align-items: center;
}

.card-header.bg-warning h3 .bi-star-fill {
  margin-right: 0.5rem;
}

/* Dashboard-Karten gleichmäßige Höhe */
.dashboard-cards .card {
  height: 100%;
}

/* Desktop-Ansicht: Alle Tabellen anzeigen */
@media (min-width: 992px) {
  .table-section {
    display: block !important;
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid #eee;
  }

  .table-section:last-child {
    border-bottom: none;
  }

  /* Separator zwischen den Tabellen für bessere Lesbarkeit */
  .table-section + .table-section {
    margin-top: 1.5rem;
  }

  /* Tabellen-Überschriften hervorheben */
  .table-section h3 {
    background-color: #f8f9fa;
    padding: 0.5rem 0.75rem;
    border-radius: 4px;
  }
}

/* Desktop-Ansicht: Alle Tabellen anzeigen */
@media (min-width: 992px) {
  .table-section {
    display: block !important;
  }
}

/* Mobile Navigation Gruppenformatierung */
.mobile-nav-heading {
  display: block;
  color: #ffffff;
  font-weight: 600;
  padding: 0.75rem 1rem;
  margin-top: 0.5rem;
  font-size: 1.1rem;
  border-top: 1px solid rgba(255, 255, 255, 0.15);
  background-color: rgba(0, 0, 0, 0.1);
  letter-spacing: 0.5px;
  pointer-events: none; /* Verhindert Klicks auf die Überschrift */
}

.mobile-nav-subitem {
  padding-left: 2rem !important;
  color: rgba(255, 255, 255, 0.8) !important;
}

.mobile-nav-subitem:hover,
.mobile-nav-subitem:focus {
  color: #ffffff !important;
  background-color: rgba(255, 255, 255, 0.1);
}

/* Mobile Navigation Spacing */
.mobile-nav-group + .nav-item .mobile-nav-subitem {
  padding-top: 0.4rem;
}

@media (max-width: 991.98px) {
  .navbar-collapse {
    max-height: 80vh;
    overflow-y: auto;
  }

  /* Verbesserte visuelle Trennung in mobilem Menü */
  .navbar-nav + .navbar-nav {
    margin-top: 1rem;
    padding-top: 0.5rem;
    border-top: 1px solid rgba(255, 255, 255, 0.15);
  }
}

/* Verstecken der nicht aktiven Tabelle in der mobilen Ansicht */
@media (max-width: 991.98px) {
  .table-section.mobile-hidden {
    display: none;
  }
}

/* Responsive Tables für Listen */
.table-responsive-custom {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* Verbesserte Lesbarkeit in Tabellen */
.admin-table td,
.admin-table th {
  padding: 0.5rem;
  vertical-align: middle;
}

/* Hervorhebung der aktiven Seite in der Navigation */
.navbar-nav .nav-link.active {
  font-weight: 600;
  position: relative;
}

.navbar-nav .nav-link.active::after {
  content: "";
  position: absolute;
  bottom: 0;
  left: 1rem;
  right: 1rem;
  height: 3px;
  background-color: #fff;
  border-radius: 3px;
}

/* Verbesserte Lesbarkeit in Listen auf kleinen Geräten */
@media (max-width: 767.98px) {
  .list-group-item {
    padding: 0.75rem 0.5rem;
  }

  .mobile-card-list .btn {
    padding: 0.4rem 0.6rem;
    font-size: 0.875rem;
  }

  /* Verbesserter Platz für Favoritenknöpfe */
  .favorite-toggle {
    padding: 0.5rem;
  }
}

/* Rollenwechsler-Styling */
.role-switcher .dropdown-toggle {
  border-radius: 20px;
  padding: 0.25rem 0.75rem;
  display: flex;
  align-items: center;
}

.role-switcher .dropdown-item {
  display: flex;
  align-items: center;
}

.role-switcher .dropdown-item i {
  margin-right: 0.5rem;
}

.role-switcher .dropdown-item.active {
  background-color: #0d6efd;
  color: white;
}
