/* AAA HOUSE Material Control v2.6.2
 * Safe Mobile Horizontal Table Navigator
 * Loaded after all legacy styles. Desktop layout is intentionally untouched.
 */

.v262-table-nav,
.v262-topbar-toggle { display: none; }

/* iPhone / phone portrait: keep the full desktop project table and scroll only its frame. */
@media screen and (max-width: 820px) and (orientation: portrait) {
  #page-projects,
  #page-projects .panel,
  #page-projects .table-wrap { min-width: 0 !important; max-width: 100% !important; }

  #page-projects .panel:has(.project-list-table) {
    overflow: hidden !important;
  }

  #page-projects .table-wrap.v262-table-viewport {
    display: block !important;
    width: 100% !important;
    max-width: 100% !important;
    overflow-x: auto !important;
    overflow-y: visible !important;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: contain;
    touch-action: pan-x pan-y;
    scrollbar-width: auto;
    border: 1px solid #dce5df;
    border-radius: 13px;
    background: #fff;
  }

  /* Restore every desktop column hidden by earlier compact-mobile rules. */
  #page-projects .project-list-table.v262-full-mobile-table {
    display: table !important;
    width: 1480px !important;
    min-width: 1480px !important;
    max-width: none !important;
    table-layout: auto !important;
    font-size: 14px !important;
    line-height: 1.35 !important;
    transform: none !important;
    zoom: 1 !important;
  }

  #page-projects .project-list-table.v262-full-mobile-table th,
  #page-projects .project-list-table.v262-full-mobile-table td {
    display: table-cell !important;
    width: auto !important;
    min-width: 0 !important;
    padding: 10px 12px !important;
    font-size: 14px !important;
    line-height: 1.35 !important;
    white-space: normal !important;
    word-break: normal !important;
    overflow-wrap: normal !important;
    line-break: loose !important;
    hyphens: none !important;
    vertical-align: middle !important;
  }

  #page-projects .project-list-table.v262-full-mobile-table th:nth-child(1),
  #page-projects .project-list-table.v262-full-mobile-table td:nth-child(1) { width: 64px !important; min-width: 64px !important; }
  #page-projects .project-list-table.v262-full-mobile-table th:nth-child(2),
  #page-projects .project-list-table.v262-full-mobile-table td:nth-child(2) { width: 112px !important; min-width: 112px !important; }
  #page-projects .project-list-table.v262-full-mobile-table th:nth-child(3),
  #page-projects .project-list-table.v262-full-mobile-table td:nth-child(3) { width: 260px !important; min-width: 260px !important; }
  #page-projects .project-list-table.v262-full-mobile-table th:nth-child(4),
  #page-projects .project-list-table.v262-full-mobile-table td:nth-child(4) { width: 190px !important; min-width: 190px !important; }
  #page-projects .project-list-table.v262-full-mobile-table th:nth-child(5),
  #page-projects .project-list-table.v262-full-mobile-table td:nth-child(5) { width: 124px !important; min-width: 124px !important; }
  #page-projects .project-list-table.v262-full-mobile-table th:nth-child(6),
  #page-projects .project-list-table.v262-full-mobile-table td:nth-child(6) { width: 150px !important; min-width: 150px !important; }
  #page-projects .project-list-table.v262-full-mobile-table th:nth-child(7),
  #page-projects .project-list-table.v262-full-mobile-table td:nth-child(7) { width: 96px !important; min-width: 96px !important; }
  #page-projects .project-list-table.v262-full-mobile-table th:nth-child(8),
  #page-projects .project-list-table.v262-full-mobile-table td:nth-child(8) { width: 172px !important; min-width: 172px !important; }
  #page-projects .project-list-table.v262-full-mobile-table th:nth-child(9),
  #page-projects .project-list-table.v262-full-mobile-table td:nth-child(9) { width: 136px !important; min-width: 136px !important; }
  #page-projects .project-list-table.v262-full-mobile-table th:nth-child(10),
  #page-projects .project-list-table.v262-full-mobile-table td:nth-child(10),
  #page-projects .project-list-table.v262-full-mobile-table th:last-child,
  #page-projects .project-list-table.v262-full-mobile-table td:last-child {
    width: 410px !important;
    min-width: 410px !important;
    position: static !important;
  }

  /* Never replace the real action labels with an unlabeled colour strip. */
  #page-projects .project-list-table .v26-project-actions-trigger {
    display: none !important;
  }
  #page-projects .project-list-table .row-actions,
  #page-projects .project-list-table .row-actions.v26-actions-collapsed,
  #page-projects .project-list-table .row-actions:not(.v26-actions-collapsed) {
    display: flex !important;
    flex-flow: row wrap !important;
    align-items: center !important;
    justify-content: flex-start !important;
    gap: 8px !important;
    width: 390px !important;
    min-width: 390px !important;
    position: static !important;
    padding: 0 !important;
    background: transparent !important;
  }
  #page-projects .project-list-table .row-actions .button {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: auto !important;
    min-width: 82px !important;
    min-height: 42px !important;
    padding: 8px 12px !important;
    font-size: 14px !important;
    line-height: 1.2 !important;
    text-indent: 0 !important;
    white-space: nowrap !important;
    word-break: keep-all !important;
    overflow-wrap: normal !important;
    opacity: 1 !important;
    visibility: visible !important;
  }

  .v262-table-nav {
    display: grid;
    grid-template-columns: 46px minmax(0, 1fr) 46px;
    align-items: center;
    gap: 8px;
    width: 100%;
    margin: 10px 0;
    padding: 8px;
    border: 1px solid #dce5df;
    border-radius: 13px;
    background: #f4f8f5;
  }
  .v262-table-nav button {
    width: 46px;
    min-width: 46px;
    height: 42px;
    border: 1px solid #cbd8d0;
    border-radius: 10px;
    background: #fff;
    color: #172127;
    font-size: 28px;
    font-weight: 900;
    line-height: 1;
  }
  .v262-table-nav button:disabled { opacity: .38; }
  .v262-table-nav-center {
    min-width: 0;
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    align-items: center;
    gap: 8px;
  }
  .v262-table-nav-label {
    color: #24402e;
    font-size: 17px;
    font-weight: 900;
    white-space: nowrap;
  }
  .v262-table-nav input[type="range"] {
    width: 100%;
    min-width: 0;
    height: 36px;
    accent-color: #258a48;
    touch-action: pan-x;
  }

  /* A subtle visual cue that the frame itself can be swiped. */
  #page-projects .table-wrap.v262-table-viewport::after {
    content: "ปัดตารางซ้าย–ขวาเพื่อดูข้อมูลทั้งหมด";
    position: sticky;
    left: 10px;
    display: inline-block;
    margin: 8px 10px 10px;
    padding: 5px 9px;
    border-radius: 999px;
    background: rgba(23,33,39,.88);
    color: #fff;
    font-size: 12px;
    font-weight: 800;
    pointer-events: none;
  }
}

/* Phone landscape: an explicit, always-visible control to collapse/expand the top bar. */
@media screen and (orientation: landscape) and (max-height: 560px) and (max-width: 1000px) {
  .v262-topbar-toggle {
    position: fixed;
    z-index: 100050;
    top: calc(8px + env(safe-area-inset-top));
    right: calc(8px + env(safe-area-inset-right));
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    min-width: 126px;
    min-height: 42px;
    padding: 7px 12px;
    border: 1px solid #afc0b5;
    border-radius: 12px;
    background: rgba(255,255,255,.97);
    color: #173222;
    box-shadow: 0 7px 22px rgba(0,0,0,.2);
    font-size: 14px;
    font-weight: 900;
    white-space: nowrap;
  }

  body.v262-topbar-collapsed { --topbar-height: calc(50px + env(safe-area-inset-top)) !important; }
  body.v262-topbar-collapsed .topbar {
    min-height: var(--topbar-height) !important;
    height: var(--topbar-height) !important;
    max-height: var(--topbar-height) !important;
    display: flex !important;
    align-items: center !important;
    justify-content: flex-start !important;
    flex-wrap: nowrap !important;
    overflow: hidden !important;
    padding: calc(6px + env(safe-area-inset-top)) 150px 6px max(12px, env(safe-area-inset-left)) !important;
  }
  body.v262-topbar-collapsed .topbar .top-actions,
  body.v262-topbar-collapsed .topbar .menu-button,
  body.v262-topbar-collapsed .topbar .top-brand img,
  body.v262-topbar-collapsed .topbar .top-brand small { display: none !important; }
  body.v262-topbar-collapsed .topbar .top-brand {
    display: flex !important;
    grid-column: auto !important;
    grid-row: auto !important;
    min-width: 0 !important;
  }
  body.v262-topbar-collapsed .topbar .top-brand strong {
    display: block !important;
    max-width: calc(100vw - 175px);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 15px !important;
  }
  body.v262-topbar-collapsed .sidebar {
    top: var(--topbar-height) !important;
    height: calc(100dvh - var(--topbar-height)) !important;
  }
}

@media print {
  .v262-table-nav,
  .v262-topbar-toggle { display: none !important; }
}
