/* === UMFRANGREICHE MOBILE OPTIMIERUNG === */
/* Fixt: Horizontaler Überlauf, überlappende Buttons, Onboarding, Chat-Button, Footer */

/* === 1. HORIZONTALER ÜBERLAUF VERHINDERN === */
html, body {
  overflow-x: hidden !important;
  max-width: 100% !important;
}

/* Alle Elemente dürfen nicht über den Viewport hinausragen */
*, *::before, *::after {
  max-width: 100% !important;
  box-sizing: border-box !important;
}

img, video, canvas, svg, iframe {
  max-width: 100% !important;
  height: auto !important;
}

pre, code, kbd, samp {
  white-space: pre-wrap !important;
  word-wrap: break-word !important;
  overflow-wrap: break-word !important;
}

/* === 2. ÖFFENTLICHE STARTSEITE (FRONTEND) === */
@media (max-width: 992px) {
  /* Leistungs-Karten: 4 Spalten → 2 Spalten */
  .row [style*="grid-template-columns:repeat(4,1fr)"] {
    grid-template-columns: repeat(2, 1fr) !important;
  }
}

@media (max-width: 768px) {
  /* Leistungs-Karten: 2 Spalten → 1 Spalte (gestapelt) */
  .row [style*="grid-template-columns:repeat(4,1fr)"],
  .row [style*="grid-template-columns:repeat(2,1fr)"] {
    grid-template-columns: 1fr !important;
  }
  
  /* Hero geringer Höhe auf Mobil */
  .hero-section, .hero-1 { 
    padding: 50px 0 30px !important; 
    margin: 10px !important;
    margin-top: 70px !important;
    border-radius: 14px !important;
  }
  
  /* Header einheitlich — weißer Balken */
  .header-area, .main-header {
    position: relative !important;
    background: #fff !important;
    padding: 12px 0 !important;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05) !important;
  }
  
  /* Header-Logo mobil */
  #headerLogo { max-height:40px; width:auto; max-width:180px !important; }
  
  /* Container padding mobil */
  .container, .container-fluid {
    padding-left: 14px !important;
    padding-right: 14px !important;
  }
  
  /* Titel anpassen */
  .title { font-size: 1.3rem !important; }
  h2.title { font-size: 1.2rem !important; }
  
  /* Buttons mobil — volle Breite wenn möglich */
  .btn-style-one {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    padding: 12px 20px !important;
    font-size: 0.9rem !important;
    min-height: 44px !important;
    width: auto !important;
    max-width: 100% !important;
  }
  
  /* Section padding reduzieren */
  .features-section, .about-section, .services-section, .news-section {
    padding: 40px 0 !important;
  }
  
  /* Footer genug Platz für Chat-Button */
  .footer-section-one, .footer-area-one {
    padding-bottom: 80px !important;
  }
  
  /* Feature Cards padding */
  .row [style*="padding:20px;background:#fff"] {
    padding: 16px !important;
  }
}

@media (max-width: 576px) {
  .hero-section, .hero-1 {
    padding: 30px 0 20px !important;
    margin: 8px !important;
    margin-top: 60px !important;
    border-radius: 10px !important;
    min-height: auto !important;
  }
  
  .title { font-size: 1.1rem !important; }
  h2.title { font-size: 1rem !important; }
  
  #headerLogo { max-height:35px; width:auto; max-width:150px !important; }
  
  .footer-section-one, .footer-area-one {
    padding-bottom: 90px !important;
  }
}

/* === 3. BACKEND (KARRIERE) === */
@media (max-width: 1024px) {
  /* Admin KPI Grid: 4 Spalten → 2 Spalten */
  .admin-kpi-grid-new {
    grid-template-columns: repeat(2, 1fr) !important;
  }
}

@media (max-width: 768px) {
  /* Hauptcontent Bereich */
  .main-content, .app-content {
    margin-left: 0 !important;
    padding: 10px !important;
  }
  
  .main-container, .container-fluid {
    padding: 0 8px !important;
  }
  
  /* Page Header */
  .page-header {
    padding: 10px 0 !important;
    margin-bottom: 12px !important;
    flex-wrap: wrap !important;
  }
  
  .page-title {
    font-size: 1rem !important;
    word-wrap: break-word !important;
  }
  
  .breadcrumb { 
    display: none !important; 
  }
  
  /* Karten */
  .card {
    margin-bottom: 12px !important;
    border-radius: 10px !important;
    overflow: hidden !important;
  }
  
  .card-body { padding: 14px !important; }
  .card-header { padding: 12px 14px !important; flex-wrap: wrap !important; }
  .card-title { 
    font-size: 0.95rem !important; 
    word-wrap: break-word !important;
    margin-right: 8px !important;
  }
  
  /* card-options unter den Titel auf Mobil */
  .card-options {
    width: 100% !important;
    margin-top: 8px !important;
    display: flex !important;
    flex-wrap: wrap !important;
    gap: 6px !important;
  }
  
  .card-options .btn {
    flex: 1 1 auto !important;
    min-width: 0 !important;
    font-size: 0.78rem !important;
    padding: 8px 10px !important;
    white-space: nowrap !important;
    text-overflow: ellipsis !important;
    overflow: hidden !important;
  }
  
  /* Grid-Spalten auf Mobil → 1 Spalte */
  .col-md-6, .col-md-4, .col-md-8, .col-md-3, .col-lg-4, .col-lg-3, .col-lg-6 {
    flex: 0 0 100% !important;
    max-width: 100% !important;
  }
  
  /* Row Spacing */
  .row { 
    margin-left: -6px !important; 
    margin-right: -6px !important;
  }
  .row > [class*="col-"] { 
    padding: 0 6px !important; 
    margin-bottom: 10px !important;
  }
  
  /* === KPI KARTEN (NEU) — applicant-kpi === */
  .applicant-kpi-grid {
    grid-template-columns: 1fr !important;
    gap: 10px !important;
    margin-bottom: 12px !important;
  }
  
  .applicant-kpi-card {
    display: grid !important;
    grid-template-columns: auto 1fr !important;
    grid-template-rows: auto auto !important;
    gap: 4px 12px !important;
    padding: 14px !important;
    align-items: center !important;
  }
  
  .applicant-kpi-icon {
    grid-row: 1 / 3 !important;
    width: 40px !important;
    height: 40px !important;
    font-size: 1rem !important;
  }
  
  .applicant-kpi-body {
    grid-column: 2 !important;
    min-width: 0 !important;
  }
  
  .applicant-kpi-label {
    font-size: 0.72rem !important;
    white-space: normal !important;
    word-wrap: break-word !important;
  }
  
  .applicant-kpi-value {
    font-size: 1.2rem !important;
  }
  
  /* Action Link in eigene Zeile */
  .applicant-kpi-action {
    grid-column: 1 / 3 !important;
    grid-row: 3 !important;
    margin-top: 8px !important;
    padding-top: 8px !important;
    border-top: 1px solid #f1f5f9 !important;
    font-size: 0.82rem !important;
    white-space: normal !important;
    word-wrap: break-word !important;
    text-align: left !important;
  }
  
  /* === KPI KARTEN (ALT) — card-widget === */
  .card-widget h2 {
    font-size: 1.2rem !important;
    word-wrap: break-word !important;
  }
  
  .card-widget .icon-size {
    width: 36px !important;
    height: 36px !important;
    font-size: 1.1rem !important;
    padding: 8px !important;
  }
  
  .card-widget p {
    padding-top: 8px !important;
    display: flex !important;
    flex-direction: column !important;
    gap: 6px !important;
    align-items: flex-start !important;
  }
  
  .card-widget p .float-end {
    float: none !important;
    width: 100% !important;
  }
  
  .card-widget .btn-default, .card-widget .btn-sm {
    width: 100% !important;
    display: block !important;
    text-align: center !important;
    font-size: 0.8rem !important;
    padding: 10px 12px !important;
    min-height: 40px !important;
  }
  
  /* === ONBOARDING WIZARD === */
  .onboarding-grid {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 10px !important;
  }
  
  .onboarding-step-card .card-body { padding: 12px !important; }
  
  .onboarding-icon-circle {
    width: 40px !important;
    height: 40px !important;
    font-size: 1.1rem !important;
    margin-bottom: 8px !important;
  }
  
  .onboarding-step-title { 
    font-size: 0.82rem !important; 
    word-wrap: break-word !important;
  }
  
  .onboarding-step-desc { 
    font-size: 0.72rem !important; 
    min-height: 2em !important;
  }
  
  /* Inaktive Karten weniger transparent — besser lesbar */
  .onboarding-card-pending {
    opacity: 0.92 !important;
  }
  
  /* Onboarding Badges lesbarer */
  .onboarding-step-footer .badge {
    font-size: 0.72rem !important;
    padding: 4px 8px !important;
  }
  
  .onboarding-step-footer .btn {
    font-size: 0.78rem !important;
    padding: 8px 10px !important;
    min-height: 38px !important;
    width: 100% !important;
    display: block !important;
    text-align: center !important;
  }
  
  /* Hauptbutton (wizard-next-action) — volle Breite, Textumbruch */
  #wizard-next-action .btn {
    width: 100% !important;
    max-width: 100% !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    flex-wrap: wrap !important;
    white-space: normal !important;
    word-wrap: break-word !important;
    overflow-wrap: break-word !important;
    text-align: center !important;
    font-size: 0.88rem !important;
    padding: 12px 16px !important;
    min-height: 48px !important;
    line-height: 1.4 !important;
  }
  
  /* === ALLGEMEINE BUTTONS === */
  .btn {
    padding: 10px 14px !important;
    font-size: 0.85rem !important;
    min-height: 42px !important;
    white-space: normal !important;
    word-wrap: break-word !important;
  }
  
  .btn-sm {
    padding: 8px 12px !important;
    font-size: 0.8rem !important;
    min-height: 36px !important;
  }
  
  .btn-lg {
    padding: 12px 20px !important;
    font-size: 0.92rem !important;
    min-height: 48px !important;
  }
  
  /* === FORM ELEMENTE === */
  .form-control, input, select, textarea {
    font-size: 16px !important;
    padding: 10px 12px !important;
  }
  
  .form-label { font-size: 0.82rem !important; }
  
  /* === TABELLEN === */
  .table-responsive { 
    overflow-x: auto !important; 
    -webkit-overflow-scrolling: touch;
  }
  .table { font-size: 0.8rem !important; }
  
  /* === ALERTS === */
  .alert { 
    padding: 12px 14px !important; 
    font-size: 0.85rem !important;
    border-radius: 8px !important;
  }
  
  /* === LIVECHAT FAB === */
  #livechat-fab {
    width: 52px !important;
    height: 52px !important;
    bottom: 20px !important;
    right: 16px !important;
    z-index: 9999 !important;
  }
  
  #livechat-fab .badge {
    font-size: 0.65rem !important;
    min-width: 18px !important;
    height: 18px !important;
    padding: 0 5px !important;
  }
  
  /* === LIVECHAT PANEL === */
  #livechat-panel.livechat-panel-open {
    width: 100% !important;
    height: 100% !important;
    right: 0 !important;
    bottom: 0 !important;
    border-radius: 0 !important;
    max-width: 100% !important;
  }
  
  /* === FLEX CONTAINER === */
  .d-flex {
    flex-wrap: wrap !important;
    gap: 8px !important;
  }
  
  .d-flex[style*="justify-content:center"] {
    flex-direction: column !important;
    align-items: stretch !important;
  }
  
  .d-flex[style*="gap:12px"] {
    flex-direction: column !important;
    gap: 8px !important;
  }
}

@media (max-width: 576px) {
  .page-title { font-size: 0.9rem !important; }
  .card-title { font-size: 0.88rem !important; }
  .card-body { padding: 12px !important; }
  
  /* Onboarding: 1 Spalte auf sehr kleinen Screens */
  .onboarding-grid {
    grid-template-columns: 1fr !important;
    gap: 8px !important;
  }
  
  .btn {
    padding: 10px 12px !important;
    font-size: 0.82rem !important;
    width: 100% !important;
    display: block !important;
    text-align: center !important;
  }
  
  .btn-sm { width: auto !important; display: inline-block !important; }
  
  /* KPI Werte kleiner */
  .applicant-kpi-value { font-size: 1.05rem !important; }
  .applicant-kpi-label { font-size: 0.68rem !important; }
  
  /* Sidebar Labels */
  .side-menu__label { font-size: 0.78rem !important; }
  span[style*="background:#ef4444"] { 
    font-size: 0.65rem !important; 
    padding: 1px 5px !important; 
  }
  
  /* Footer genug Abstand */
  .footer-section-one, .footer-area-one {
    padding-bottom: 100px !important;
  }
}

/* === 4. AKTIVER AUFTRAG (new_ajob.php) — BUTTON FIXES === */
@media (max-width: 768px) {
  /* float:left/right Buttons → untereinander */
  [style*="float:left"], [style*="float:right"] {
    float: none !important;
    width: 100% !important;
    display: block !important;
    margin-bottom: 8px !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
    clear: both !important;
  }
  
  /* Beide Buttons gleiche Breite */
  .col-md-6 {
    flex: 0 0 100% !important;
    max-width: 100% !important;
    padding: 0 !important;
  }
  
  /* Submit Button volle Breite innerhalb der Karte */
  button[type="submit"] {
    max-width: 100% !important;
    box-sizing: border-box !important;
    width: 100% !important;
  }
  
  /* Fragebogen Textareas */
  .fragebogen-item textarea {
    min-height: 60px !important;
    font-size: 0.85rem !important;
  }
  
  /* Button-Reihen sauber stapeln */
  .row:has([style*="float:left"]) {
    flex-direction: column !important;
  }
}

/* === 5. AUSZAHLUNGEN — BANNER ICON FIX === */
@media (max-width: 768px) {
  .card.bg-success .d-flex {
    flex-direction: column !important;
    gap: 8px !important;
  }
  
  .card.bg-success .ms-auto {
    margin-left: 0 !important;
    margin-top: 8px !important;
  }
  
  .card.bg-success .fs-30 {
    font-size: 1.5rem !important;
  }
  
  .card.bg-success h2 {
    font-size: 1.1rem !important;
  }
  
  .card.bg-success p {
    font-size: 0.82rem !important;
  }
}

/* === 6. FOOTER PADDING FÜR CHAT BUTTON === */
.footer-section-one {
  padding-bottom: 80px !important;
}

@media (max-width: 768px) {
  .footer-section-one {
    padding-bottom: 100px !important;
  }
}

/* === 7. SCROLL-TO-TOP BUTTON === */
@media (max-width: 768px) {
  .scroll-to-top, .back-to-top, [class*="scroll-top"] {
    bottom: 80px !important;
    right: 16px !important;
    z-index: 9998 !important;
  }
}

/* === HERO MOBILE OPTIMIERUNG === */
@media (max-width: 768px) {
    /* Hero-Content linksbündig statt zentriert */
    .hero-content { text-align: left !important; padding: 32px 0 32px !important; }
    .hero-content .text { line-height: 1.7 !important; font-size: 0.9rem !important; }
    
    /* Hero-Buttons: volle Breite, gleich groß */
    .hero-button { flex-direction: column !important; gap: 10px !important; }
    .hero-button .btn-style-one {
        width: 100% !important;
        max-width: 100% !important;
        display: flex !important;
        justify-content: center !important;
        align-items: center !important;
        min-height: 48px !important;
        padding: 14px 20px !important;
        font-size: 0.92rem !important;
    }
    .hero-button .btn-style-one:last-child {
        border: 2px solid rgba(255,255,255,0.7) !important;
    }
    
    /* Kennzahlen: gestapelt mit Trennlinie horizontal */
    .hero-content > div[style*="display:flex; gap:32px"] {
        flex-direction: column !important;
        gap: 12px !important;
        margin-top: 24px !important;
    }
    .hero-content > div[style*="display:flex; gap:32px"] > div[style*="width:1px"] {
        width: 100% !important;
        height: 1px !important;
        background: rgba(255,255,255,0.15) !important;
    }
    .hero-content > div[style*="display:flex; gap:32px"] > div:not([style*="width:1px"]) {
        display: flex !important;
        align-items: baseline !important;
        gap: 12px !important;
    }
    .hero-content > div[style*="display:flex; gap:32px"] > div:not([style*="width:1px"]) > div:first-child {
        font-size: 1.3rem !important;
    }
    .hero-content > div[style*="display:flex; gap:32px"] > div:not([style*="width:1px"]) > div:last-child {
        font-size: 0.78rem !important;
    }
    
    /* Hero-Titel: "Vertrauen schafft." zusammenhalten */
    .hero-title { font-size: 1.6rem !important; line-height: 1.25 !important; }
    .hero-title span { display: inline-block !important; }
    
    /* Abstand nach dem Hero */
    .hero-section, .hero-1 { margin-bottom: 24px !important; }
}

@media (max-width: 576px) {
    .hero-title { font-size: 1.4rem !important; }
    .hero-content .text { font-size: 0.85rem !important; }
    .hero-content > div[style*="display:flex; gap:32px"] > div:not([style*="width:1px"]) {
        flex-direction: column !important;
        gap: 2px !important;
    }
    .hero-content > div[style*="display:flex; gap:32px"] > div:not([style*="width:1px"]) > div:first-child {
        font-size: 1.2rem !important;
    }
    .hero-content > div[style*="display:flex; gap:32px"] > div:not([style*="width:1px"]) > div:last-child {
        font-size: 0.75rem !important;
    }
}

/* === NAV SUPPORT-BOX === */
.header-style-one .right-box { gap: 16px !important; }
.header-style-one .header-phone_box { margin-left: 16px !important; }
