/* AKG Unified Platform 6.8.8 responsive consolidation.
   Loaded after module styles so one predictable layer governs shared breakpoints. */

.mobile-nav-toggle {
  display: none;
}

/* Keep page-level actions clear of the persistent notification/language tools. */
@media (min-width: 761px) {
  .production-heading,
  .dashboard-title-row,
  .module-page-heading,
  .page-heading,
  .appscript-page-heading {
    padding-right: 210px !important;
  }
}

/* Tablet and mobile navigation is a compact, accessible drawer. */
@media (max-width: 980px) {
  .app-sidebar {
    position: relative !important;
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    width: 100% !important;
    height: auto !important;
    min-height: 82px !important;
    padding: 9px 14px !important;
  }

  .app-sidebar .sidebar-brand {
    min-width: 0;
    height: 64px !important;
    min-height: 64px !important;
    margin: 0 !important;
  }

  .mobile-nav-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-width: 92px;
    min-height: 44px;
    padding: 0 14px;
    border: 1px solid rgba(255,255,255,.24);
    border-radius: 10px;
    background: rgba(255,255,255,.1);
    color: #fff;
    font: inherit;
    font-weight: 800;
    cursor: pointer;
  }

  .mobile-nav-toggle span:first-child {
    width: 18px;
    font-size: 21px;
    line-height: 1;
  }

  .app-sidebar .sidebar-nav {
    display: none !important;
    grid-column: 1 / -1;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    max-height: min(68vh, 620px);
    margin-top: 8px;
    padding: 10px 0 4px !important;
    overflow-x: hidden !important;
    overflow-y: auto !important;
    border-top: 1px solid rgba(255,255,255,.14);
    overscroll-behavior: contain;
  }

  .app-sidebar .sidebar-nav.mobile-nav-open {
    display: grid !important;
  }

  .app-sidebar .sidebar-link {
    min-height: 48px !important;
    white-space: normal !important;
  }

  .app-sidebar .sidebar-nav-separator {
    display: none !important;
  }

  .app-content.container {
    margin-left: 0 !important;
    width: 100% !important;
  }

  [dir="rtl"] .app-content.container {
    margin-right: 0 !important;
  }

  /* Minimum touch size for operational controls. */
  .btn,
  button:not([type="checkbox"]):not([type="radio"]),
  select,
  input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]),
  textarea,
  .row-action-menu > summary,
  .sidebar-user-menu > summary,
  .notification-menu > summary {
    min-height: 44px;
  }

  .row-action-menu > summary,
  .sidebar-user-menu > summary,
  .notification-menu > summary {
    min-width: 44px;
  }

  .production-action-cell .btn,
  .production-stage-row .btn {
    min-height: 44px;
    padding: 10px 13px;
    font-size: 12px;
  }

  .table-wrap,
  .module-table-wrap,
  .production-table-wrap,
  .controlled-list-table-wrap {
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-inline: contain;
    scrollbar-gutter: stable;
  }
}

@media (max-width: 760px) {
  .app-sidebar {
    min-height: 76px !important;
    padding: 7px 12px !important;
  }

  .app-sidebar .sidebar-brand {
    height: 58px !important;
    min-height: 58px !important;
    grid-template-columns: 50px minmax(0, 1fr) !important;
  }

  .app-sidebar .sidebar-logo {
    width: 48px !important;
    height: 36px !important;
  }

  .mobile-nav-toggle {
    min-width: 48px;
    padding: 0 12px;
  }

  .mobile-nav-toggle span:last-child {
    display: none;
  }

  .app-sidebar .sidebar-nav {
    grid-template-columns: 1fr;
  }

  .workspace-tools {
    position: static !important;
    width: 100%;
    padding: 10px 14px 0 !important;
    justify-content: flex-end !important;
  }

  .production-heading,
  .dashboard-title-row,
  .module-page-heading,
  .page-heading,
  .appscript-page-heading {
    padding-right: 0 !important;
    padding-left: 0 !important;
    min-height: auto !important;
  }

  .production-heading,
  .production-heading-actions,
  .production-panel-head {
    align-items: stretch;
    flex-direction: column;
  }

  .production-heading-actions > .btn,
  .production-panel-head > .btn,
  .production-panel-head > a.btn {
    width: 100%;
  }

  .production-panel {
    padding: 14px;
    border-radius: 13px;
  }

  .production-filter,
  .production-filter.orders,
  .production-filter.quality {
    display: grid !important;
    grid-template-columns: 1fr !important;
  }

  .production-filter > *,
  .module-filter > * {
    width: 100% !important;
    max-width: none !important;
  }

  /* Production orders become labelled cards instead of a 960px-wide table. */
  .production-table-wrap:has(.production-order-table) {
    overflow: visible;
  }

  .production-order-table,
  .production-order-table tbody,
  .production-order-table tr,
  .production-order-table td {
    display: block;
    width: 100%;
    min-width: 0;
  }

  .production-order-table {
    min-width: 0 !important;
    border: 0;
    background: transparent;
  }

  .production-order-table thead {
    display: none;
  }

  .production-order-table tbody {
    display: grid;
    gap: 13px;
  }

  .production-order-table tbody tr {
    overflow: hidden;
    border: 1px solid #dce4ef;
    border-radius: 13px;
    background: #fff;
    box-shadow: 0 5px 16px rgba(15,39,79,.06);
  }

  .production-order-table tbody tr.production-row-overdue {
    border-inline-start: 4px solid #dc2626;
  }

  .production-order-table tbody td[data-label] {
    position: static !important;
    display: grid;
    grid-template-columns: minmax(105px, 36%) minmax(0, 1fr);
    gap: 10px;
    align-items: start;
    padding: 11px 12px;
    border: 0;
    border-bottom: 1px solid #edf1f6;
    box-shadow: none !important;
    text-align: start;
  }

  .production-order-table tbody td[data-label]::before {
    content: attr(data-label);
    color: #64748b;
    font-size: 10px;
    font-weight: 900;
    letter-spacing: .035em;
    text-transform: uppercase;
  }

  .production-order-table tbody td:last-child {
    border-bottom: 0;
  }

  .production-order-table .production-action-cell .btn {
    width: 100%;
  }

  .production-order-table .production-empty {
    display: block;
    padding: 22px 14px;
  }
}

@media (max-width: 420px) {
  .workspace-tools .language-switch {
    padding-inline: 12px;
  }

  .production-order-table tbody td[data-label] {
    grid-template-columns: 1fr;
    gap: 5px;
  }
}

@media print {
  .mobile-nav-toggle {
    display: none !important;
  }
}

/* 6.9.2: every Production table becomes a labelled, touch-friendly list on phones. */
@media (max-width: 760px) {
  .production-module .production-table-wrap:has(.production-mobile-cards) {
    overflow: visible;
    border: 0;
    background: transparent;
  }

  .production-module .production-mobile-cards,
  .production-module .production-mobile-cards tbody,
  .production-module .production-mobile-cards tr,
  .production-module .production-mobile-cards td {
    display: block;
    width: 100%;
    min-width: 0 !important;
  }

  .production-module .production-mobile-cards {
    border: 0;
    background: transparent;
  }

  .production-module .production-mobile-cards thead { display: none; }
  .production-module .production-mobile-cards tbody { display: grid; gap: 13px; }

  .production-module .production-mobile-cards tbody tr {
    overflow: hidden;
    border: 1px solid #dce4ef;
    border-radius: 13px;
    background: #fff;
    box-shadow: 0 5px 16px rgba(15,39,79,.06);
  }

  .production-module .production-mobile-cards tbody tr.production-row-overdue {
    border-inline-start: 4px solid #dc2626;
  }

  .production-module .production-mobile-cards tbody td:not([colspan]) {
    position: static !important;
    display: grid;
    grid-template-columns: minmax(105px,36%) minmax(0,1fr);
    gap: 10px;
    align-items: start;
    padding: 12px;
    border: 0;
    border-bottom: 1px solid #edf1f6;
    box-shadow: none !important;
    text-align: start !important;
  }

  .production-module .production-mobile-cards tbody td:not([colspan])::before {
    content: attr(data-label);
    color: #64748b;
    font-size: 10.5px;
    font-weight: 900;
    letter-spacing: .025em;
    text-transform: uppercase;
  }

  .production-module .production-mobile-cards tbody td[data-label=""] {
    grid-template-columns: 1fr;
  }
  .production-module .production-mobile-cards tbody td[data-label=""]::before { display:none; }
  .production-module .production-mobile-cards tbody td:last-child { border-bottom:0; }
  .production-module .production-mobile-cards .production-action-cell .btn,
  .production-module .production-mobile-cards tbody td:last-child .btn { width:100%; }

  .production-module .production-mobile-cards .production-empty {
    display:block;
    padding:22px 14px;
    text-align:center!important;
  }

  .production-module .production-pagination {
    align-items:flex-start;
    flex-direction:column;
  }

  .production-module .production-pagination>div {
    width:100%;
    flex-wrap:wrap;
  }
}

@media (max-width: 420px) {
  .production-module .production-mobile-cards tbody td:not([colspan]) {
    grid-template-columns:1fr;
    gap:5px;
  }
}
