/**
 * Portal – Mobile-Optimierung (nur Smartphones)
 * Gilt ausschließlich innerhalb von @media (max-width: 767.98px).
 * Desktop-Darstellung bleibt unverändert.
 * Einbindung: nach portal-style.css in templates/header.php.
 */

@media (max-width: 767.98px) {

  /* ==========================================================================
     ALLIANCE-LOGO IM FOOTER – neue Zeile, mittig auf Mobile
     ========================================================================== */
  .footer-alliance-row {
    justify-content: center !important;
    text-align: center;
  }
  /* Logo (und ggf. umschließender Link) in eigene Zeile zwingen */
  .footer-alliance-row a:has(img[alt="Alliance"]) {
    flex-basis: 100%;
    width: 100%;
    margin-top: 0.5rem;
    text-align: center;
  }
  .footer-alliance-row img[alt="Alliance"] {
    display: block;
    margin-left: auto;
    margin-right: auto;
    margin-top: 0.5rem;
  }
  .footer-alliance-row > a:has(img[alt="Alliance"]) img[alt="Alliance"] {
    margin-top: 0;
  }
  /* Logo ohne Link: ebenfalls neue Zeile, mittig */
  .footer-alliance-row > img[alt="Alliance"] {
    flex-basis: 100%;
    width: 100%;
    margin-top: 0.5rem;
  }

  /* ==========================================================================
     BUTTONS – volle Breite für bessere Bedienbarkeit (Touch)
     ========================================================================== */
  .portal .btn,
  .portal .card-body .btn,
  .portal .border.rounded .btn,
  .portal .alert .btn {
    display: block;
    width: 100%;
    box-sizing: border-box;
    text-align: center;
  }
  .portal .btn + .btn,
  .portal .card-body .btn + .btn {
    margin-top: 0.5rem;
  }
  /* Button-Gruppen (z. B. "Abbrechen" neben "Speichern") als Stack */
  .portal .d-flex.gap-2 .btn,
  .portal .btn-group .btn {
    width: 100%;
  }

  /* ==========================================================================
     LESBARKEIT – Schrift und Abstände
     ========================================================================== */
  .portal .col-lg-8,
  .main-content-card:has(.portal) .card-body {
    font-size: 1rem;
    line-height: 1.5;
  }
  .portal .col-lg-8 h1,
  .portal .col-lg-8 .h1,
  .portal .col-lg-8 h2,
  .portal .col-lg-8 .h2 {
    font-size: 1.35rem;
    margin-bottom: 0.75rem;
    line-height: 1.3;
  }
  .portal .col-lg-8 h5,
  .portal .col-lg-8 .h5 {
    font-size: 1.1rem;
    margin-bottom: 0.5rem;
  }
  .portal .col-lg-8 .card-body p,
  .portal .col-lg-8 .card-body small {
    margin-bottom: 0.5rem;
  }
  .portal .col-lg-8 .table,
  .portal .col-lg-8 .table-responsive .table {
    font-size: 0.95rem;
  }
  .portal .col-lg-8 .table-responsive tbody tr td[data-label]::before {
    font-size: 0.9rem;
    font-weight: 600;
  }

  /* ==========================================================================
     BEZEICHNER ÜBER DEM WERT (Name:, E-Mail: etc.)
     ========================================================================== */
  .portal .card-body p.mb-1 strong,
  .portal .card-body p strong {
    display: block;
    margin-bottom: 0.25rem;
  }
  .portal .card-body dl.row dt,
  .portal .card-body dl.row dd {
    width: 100%;
    margin-bottom: 0.25rem;
  }
  .portal .card-body dl.row dt {
    margin-top: 0.5rem;
  }
  .portal .card-body dl.row dt:first-child {
    margin-top: 0;
  }

  /* ==========================================================================
     SIDEBAR ALS HAMBURGER-OFFCANVAS (Vorbereitung)
     Aktivierung: Button + Offcanvas-HTML + portal-mobile.js einbinden.
     Die Sidebar-Spalte wird per JS in den Offcanvas geklont und hier ausgeblendet.
     ========================================================================== */
  /* Hamburger-Button – sichtbar nur auf Mobile, feste Position */
  .portal-mobile-menu-btn {
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 1040;
    width: 44px;
    height: 44px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    border: 1px solid rgba(0, 0, 0, 0.15);
    background: var(--navbar_bg_color, #212529);
    color: #fff;
    font-size: 1.5rem;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    transition: background 0.2s, transform 0.2s;
  }
  .portal-mobile-menu-btn:hover {
    background: #343a40;
    color: #fff;
  }
  .portal-mobile-menu-btn:focus {
    outline: 2px solid rgba(255, 255, 255, 0.5);
    outline-offset: 2px;
  }

  /* Offcanvas-Container (wird per JS mit Sidebar-Inhalt gefüllt) */
  .portal-sidebar-offcanvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 280px;
    max-width: 85vw;
    height: 100%;
    z-index: 1050;
    background: #1a1a1a;
    color: #fff;
    box-shadow: 4px 0 20px rgba(0, 0, 0, 0.3);
    transform: translateX(-100%);
    transition: transform 0.3s ease;
    overflow-y: auto;
    overflow-x: hidden;
  }
  body.portal-sidebar-open .portal-sidebar-offcanvas {
    transform: translateX(0);
  }
  .portal-sidebar-offcanvas .card,
  .portal-sidebar-offcanvas .portal-sidebar-card {
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
  }
  .portal-sidebar-offcanvas .card-body {
    padding: 1rem;
    background: transparent !important;
  }
  .portal-sidebar-offcanvas .nav-link,
  .portal-sidebar-offcanvas .portal-sidebar-link {
    color: #fff !important;
    padding: 0.75rem;
    border-radius: 6px;
  }
  .portal-sidebar-offcanvas .nav-link:hover,
  .portal-sidebar-offcanvas .portal-sidebar-link:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #fff !important;
  }
  .portal-sidebar-offcanvas .btn-danger {
    margin-top: 0.5rem;
    width: 100%;
  }
  /* Schließen-Button im Offcanvas (optional, kann per JS eingefügt werden) */
  .portal-sidebar-offcanvas-close {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    width: 40px;
    height: 40px;
    padding: 0;
    border: none;
    background: transparent;
    color: #fff;
    font-size: 1.5rem;
    cursor: pointer;
    opacity: 0.9;
  }
  .portal-sidebar-offcanvas-close:hover {
    opacity: 1;
  }

  /* Overlay hinter dem Offcanvas */
  .portal-sidebar-overlay {
    position: fixed;
    inset: 0;
    z-index: 1045;
    background: rgba(0, 0, 0, 0.5);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s, visibility 0.3s;
  }
  body.portal-sidebar-open .portal-sidebar-overlay {
    opacity: 1;
    visibility: visible;
  }

  /* Sidebar-Spalte auf Mobile ausblenden, sobald JS sie in den Offcanvas geklont hat */
  body.portal-sidebar-js-ready .portal .col-lg-4.portal-sidebar-col {
    display: none !important;
  }
}
