/* =========================================================
   PRINTNERD BACKEND – MOBILE ERWEITERUNG
   ========================================================= */

/*
|--------------------------------------------------------------------------
| Mobile Navigation – Desktop Grundzustand
|--------------------------------------------------------------------------
*/

.backend-menu-toggle,
.backend-sidebar__mobile-header {
  display: none;
}

.backend-sidebar-overlay {
  display: none;
}


/*
|--------------------------------------------------------------------------
| Tablets / Mobile
|--------------------------------------------------------------------------
*/

@media (max-width: 900px) {

  html {
    -webkit-text-size-adjust: 100%;
  }

  body {
    min-width: 0;
    overflow-x: hidden;
  }

  body.backend-nav-open {
    overflow: hidden;
  }


  /*
  |--------------------------------------------------------------------------
  | Header
  |--------------------------------------------------------------------------
  */

  .backend-header {
    position: sticky;
    top: 0;
    z-index: 900;

    height: 64px;

    padding:
      env(safe-area-inset-top, 0)
      16px
      0;

    gap: 12px;
  }

  .backend-header__brand {
    min-width: 0;
    flex: 1;
  }

  .backend-header__logo {
    height: 34px;
    max-width: 145px;
  }

  .backend-header__user {
    max-width: 110px;

    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;

    font-size: 13px;
  }


  /*
  |--------------------------------------------------------------------------
  | Hamburger
  |--------------------------------------------------------------------------
  */

  .backend-menu-toggle {
    width: 44px;
    height: 44px;
    flex: 0 0 44px;

    display: inline-flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;

    gap: 5px;

    padding: 0;

    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 9px;

    cursor: pointer;
  }

  .backend-menu-toggle span {
    display: block;

    width: 19px;
    height: 2px;

    background: #374151;
    border-radius: 999px;
  }


  /*
  |--------------------------------------------------------------------------
  | Layout
  |--------------------------------------------------------------------------
  */

  .backend-content {
    display: block;
    min-height: calc(100dvh - 64px);
  }

  .backend-main {
    width: 100%;
    min-width: 0;

    padding: 24px 20px 40px;

    overflow: visible;
  }


  /*
  |--------------------------------------------------------------------------
  | Sidebar Drawer
  |--------------------------------------------------------------------------
  */

  .backend-sidebar {
    position: fixed;
    z-index: 1100;

    top: 0;
    bottom: 0;
    left: 0;

    width: min(82vw, 320px);
    height: 100dvh;

    padding:
      calc(18px + env(safe-area-inset-top, 0))
      16px
      calc(18px + env(safe-area-inset-bottom, 0));

    overflow-y: auto;
    overscroll-behavior: contain;

    background: #ffffff;
    border-right: 1px solid #e5e7eb;

    box-shadow: 18px 0 50px rgba(17, 24, 39, 0.16);

    transform: translateX(-105%);
    visibility: hidden;

    transition:
      transform 0.22s ease,
      visibility 0.22s ease;
  }

  body.backend-nav-open .backend-sidebar {
    transform: translateX(0);
    visibility: visible;
  }

  .backend-sidebar__mobile-header {
    display: flex;
    align-items: center;
    justify-content: space-between;

    gap: 16px;

    margin-bottom: 18px;
    padding: 0 4px 14px;

    border-bottom: 1px solid #e5e7eb;
  }

  .backend-sidebar__mobile-header strong {
    color: #111827;
    font-size: 15px;
  }

  .backend-sidebar__close {
    width: 42px;
    height: 42px;

    display: inline-grid;
    place-items: center;

    padding: 0;

    background: #f9fafb;
    color: #374151;

    border: 1px solid #e5e7eb;
    border-radius: 9px;

    font: inherit;
    font-size: 26px;
    line-height: 1;

    cursor: pointer;
  }

  .backend-nav__link {
    min-height: 46px;

    display: flex;
    align-items: center;

    padding: 12px 14px;

    font-size: 15px;
  }


  /*
  |--------------------------------------------------------------------------
  | Overlay
  |--------------------------------------------------------------------------
  */

  .backend-sidebar-overlay {
    position: fixed;
    z-index: 1000;

    inset: 0;

    display: block;

    background: rgba(17, 24, 39, 0.48);

    opacity: 0;
    visibility: hidden;

    transition:
      opacity 0.2s ease,
      visibility 0.2s ease;
  }

  body.backend-nav-open .backend-sidebar-overlay {
    opacity: 1;
    visibility: visible;
  }

  body.backend-nav-open .backend-sidebar-overlay[hidden] {
    display: block;
  }


  /*
  |--------------------------------------------------------------------------
  | Allgemeine Inhalte
  |--------------------------------------------------------------------------
  */

  .page-header,
  .section-header,
  .project-page-header {
    align-items: stretch;
    flex-direction: column;

    gap: 16px;
  }

  .page-header {
    margin-bottom: 22px;
  }

  .backend-main h1 {
    font-size: 25px;
  }

  .card {
    padding: 20px;
  }

  .detail-section {
    margin-top: 20px;
  }

  .filter-card {
    margin-bottom: 22px;
  }

  .filter-card__summary,
  .filter-card__content {
    padding-left: 18px;
    padding-right: 18px;
  }


  /*
  |--------------------------------------------------------------------------
  | Dashboard
  |--------------------------------------------------------------------------
  */

  .dashboard-stats,
  .stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
  }

  .dashboard-stat-card,
  .stat-card {
    padding: 18px;
  }

  .dashboard-stat-card__value,
  .stat-card__value {
    font-size: 29px;
  }


  /*
  |--------------------------------------------------------------------------
  | Formulare / Detail
  |--------------------------------------------------------------------------
  */

  .form-grid,
  .detail-grid,
  .detail-list--grid {
    grid-template-columns: 1fr;
  }

  .status-control {
    width: 100%;
    min-width: 0;
  }

  .status-select {
    width: 100%;
  }

  .project-page-header__actions,
  .table-actions {
    width: 100%;
    flex-wrap: wrap;
    justify-content: flex-start;
  }


  /*
  |--------------------------------------------------------------------------
  | Tabellen
  |--------------------------------------------------------------------------
  */

  .card--table {
    overflow: hidden;
  }

  .table-wrapper {
    width: 100%;
    overflow-x: auto;

    -webkit-overflow-scrolling: touch;
  }

  .backend-table {
    min-width: 720px;
  }
}


/*
|--------------------------------------------------------------------------
| Kleine Smartphones
|--------------------------------------------------------------------------
*/

@media (max-width: 600px) {

  .backend-header {
    padding-left: 12px;
    padding-right: 12px;
  }

  .backend-header__user {
    max-width: 88px;
    font-size: 12px;
  }

  .backend-main {
    padding:
      18px
      14px
      calc(32px + env(safe-area-inset-bottom, 0));
  }

  .backend-main h1 {
    font-size: 23px;
  }

  .card {
    padding: 17px;
    border-radius: 10px;
  }

  .dashboard-stats,
  .stats-grid {
    grid-template-columns: 1fr;
  }

  .dashboard-card-header {
    align-items: flex-start;
    flex-direction: column;

    padding: 17px;
  }

  .form-actions {
    flex-direction: column-reverse;
    align-items: stretch;

    padding-bottom: 20px;
  }

  .form-actions .button,
  .project-page-header__actions .button,
  .table-actions .button {
    width: 100%;
  }

  .detail-row {
    grid-template-columns: 1fr;
    gap: 5px;
  }

  .file-upload,
  .file-item {
    align-items: stretch;
    flex-direction: column;
  }

  .file-upload .button,
  .file-item__action .button {
    width: 100%;
  }

  .pagination {
    align-items: stretch;
  }

  .pagination__buttons {
    width: 100%;
  }


  /*
  |--------------------------------------------------------------------------
  | Login
  |--------------------------------------------------------------------------
  */

  .login-page {
    min-height: 100dvh;
  }

  .login-wrapper {
    min-height: 100dvh;

    display: flex;
    align-items: center;
    justify-content: center;

    padding:
      calc(20px + env(safe-area-inset-top, 0))
      16px
      calc(20px + env(safe-area-inset-bottom, 0));
  }

  .login-card {
    width: 100%;
    max-width: 440px;

    padding: 28px 20px;
  }

  .login-logo img {
    max-width: 180px;
    height: auto;
  }

  .login-header h1 {
    font-size: 24px;
  }

  .login-header p {
    font-size: 14px;
    line-height: 1.55;
  }

  .login-field input {
    min-height: 48px;
    font-size: 16px;
  }

  .login-button {
    min-height: 48px;
    width: 100%;
  }
}


/*
|--------------------------------------------------------------------------
| Sehr schmale Geräte
|--------------------------------------------------------------------------
*/

@media (max-width: 390px) {

  .backend-header__logo {
    height: 30px;
    max-width: 125px;
  }

  .backend-header__user {
    max-width: 68px;
  }

  .backend-sidebar {
    width: 88vw;
  }
}


/*
|--------------------------------------------------------------------------
| Reduzierte Bewegung
|--------------------------------------------------------------------------
*/

@media (prefers-reduced-motion: reduce) {

  .backend-sidebar,
  .backend-sidebar-overlay {
    transition: none;
  }
}
