/* public/assets/core/css/layout.css */
/* ==============================
   NTD LAYOUT 2.0 (ORANGE) - ONE DOM, CSS decides layout
   Breakpoint chốt cứng:
   - Mobile: < 668px
   - Tablet: 668px – 998px
   - Desktop: >= 999px
============================== */

/* SHELL */
.ntd-shell{
  width: calc(100% - 24px);
  height: calc(100vh - 24px);
  margin: 12px auto;
  border-radius: var(--ntd-radius-lg);
  overflow:hidden;
  display:flex;
  box-shadow: var(--ntd-shadow-main);
  background: linear-gradient(
    180deg,
    var(--ntd-orange-2) 0%,
    var(--ntd-orange-1) 55%,
    #ffa55a 100%
  );
}

/* SIDEBAR */
.ntd-sidebar{
  width: 290px;
  min-width: 290px;
  padding: 16px 14px;
  display:flex;
  flex-direction:column;
  background: transparent;
  border-right: 1px solid rgba(255,255,255,.28);
}

/* BRAND */
.ntd-sidebar__brand{
  background: rgba(255,255,255,.20);
  border: 1px solid rgba(255,255,255,.35);
  border-radius: 22px;
  padding: 12px;
  display:flex;
  align-items:center;
  justify-content:space-between;
  box-shadow: var(--ntd-shadow-soft);
}

.ntd-brand{
  display:flex;
  gap:10px;
  align-items:center;
  color:#fff;
}
.ntd-brand__logo{
  width:44px;
  height:44px;
  border-radius:999px;
  background:#fff;
  color:var(--ntd-orange-2);
  display:flex;
  align-items:center;
  justify-content:center;
  font-weight:800;
}
.ntd-brand__text{ display:flex; flex-direction:column; }
.ntd-brand__name{font-weight:800; line-height:1.1;}
.ntd-brand__sub{font-size:12px;opacity:.95; line-height:1.2;}

.ntd-sidebar__toggle{
  width: 34px;
  height: 34px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,.65);
  background: #fff;
  color: var(--ntd-orange-3);
  font-size: 22px;
  line-height: 1;
  display:flex;
  align-items:center;
  justify-content:center;
  cursor:pointer;
  touch-action: manipulation;
}

/* NAV */
.ntd-nav{
  margin-top:14px;
  display:flex;
  flex-direction:column;
  gap:8px;
  padding: 6px;
}

.ntd-nav__link{
  display:flex;
  align-items:center;
  gap:10px;
  padding:10px 14px;
  border-radius:14px;
  color:#fff;
  text-decoration:none;
  background: rgba(255,255,255,.12);
  border: 1px solid rgba(255,255,255,.18);
  transition:.15s;
}
.ntd-nav__link:hover{ background: rgba(255,255,255,.20); }
.ntd-nav__link.active{
  background: rgba(255,255,255,.30);
  border-color: rgba(255,255,255,.35);
  box-shadow:0 10px 22px rgba(0,0,0,.15);
}
.ntd-nav__icon{ width:22px; text-align:center; }
.ntd-nav__text{ font-weight:800; }

/* FOOTER */
.ntd-sidebar__footer{
  margin-top:auto;
  padding: 10px 6px 2px 6px;
}
.ntd-footer-text{
  color:#fff;
  font-size:12px;
  opacity:.95;
}

/* MAIN */
.ntd-main{
  flex:1;
  display:flex;
  flex-direction:column;
  padding:16px;
  background: transparent;
  min-width: 0;
}

/* HEADER */
.ntd-header{
  border-radius: 22px;
  padding:16px 20px;
  color:#fff;
  background: linear-gradient(
    90deg,
    var(--ntd-orange-2) 0%,
    var(--ntd-orange-1) 60%,
    #ffd6b8 100%
  );
  box-shadow: var(--ntd-shadow-soft);
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap: 12px;
}

.ntd-header-logo{ display:flex; align-items:center; gap:10px; }
.ntd-header-logo img{ height:34px; width:auto; display:block; }

/* USER */
.ntd-userbox{
  display:flex;
  align-items:center;
  gap:10px;
  background:rgba(255,255,255,.22);
  border: 1px solid rgba(255,255,255,.28);
  padding:8px 12px;
  border-radius:999px;
}
.ntd-userbox__avatar{
  width:32px;height:32px;
  border-radius:999px;
  background:#fff;
  color:var(--ntd-orange-2);
  font-weight:900;
  display:flex;
  align-items:center;
  justify-content:center;
}
.ntd-userbox__name{
  font-weight:900;
  color:#fff;
  white-space:nowrap;
}

/* CONTENT (scroll dọc; pan-x bảng xử lý ở wrapper) */
.ntd-content{
  margin-top:14px;
  flex:1;
  background: rgba(255,255,255,.92);
  border-radius: var(--ntd-radius-lg);
  box-shadow: var(--ntd-shadow-soft);
  padding:18px;
  border: 1px solid rgba(15,23,42,.06);

  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
}

/* Collapsed (desktop) */
.ntd-shell.ntd-collapsed .ntd-sidebar{
  width:92px;
  min-width:92px;
}
.ntd-shell.ntd-collapsed .ntd-brand__text,
.ntd-shell.ntd-collapsed .ntd-nav__text,
.ntd-shell.ntd-collapsed .ntd-footer-text{
  display:none;
}
.ntd-shell.ntd-collapsed .ntd-sidebar__toggle{
  transform: rotate(180deg);
}

/* =========================================================
   MOBILE/TABLET: < 999px
========================================================= */
@media (max-width: 998px){
  .ntd-shell{
    width:100%;
    height:100vh;
    margin:0;
    border-radius:0;
  }

  .ntd-sidebar{ display:none !important; }
}

/* Mobile: <668 */
@media (max-width: 667px){
  .ntd-header{ padding: 14px 14px; border-radius: 18px; }
  .ntd-header-logo img{ height:30px; }

  .ntd-header .ntd-header__right{ display:none !important; }
}

/* Tablet: 668..998 */
@media (min-width: 668px) and (max-width: 998px){
  .ntd-header .ntd-header__right{ display:block; }
}

/* Desktop: >=999 ẩn UI drawer */
@media (min-width: 999px){
  .ntd-mobile-menu-btn{ display:none !important; }
  .ntd-mobile-overlay{ display:none !important; }
  .ntd-mobile-drawer{ display:none !important; }
}

/* Nút menu (chỉ <999) */
@media (max-width: 998px){
  .ntd-mobile-menu-btn{
    width: 44px;
    height: 44px;
    border-radius: 999px;
    border: 1px solid rgba(255,255,255,.55);
    background: rgba(255,255,255,.18);
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    touch-action: manipulation;
    flex: 0 0 auto;
  }
}

/* OVERLAY + DRAWER */
.ntd-mobile-overlay{
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.40);
  z-index: 1040;
  opacity: 0;
  pointer-events: none;
  transition: opacity .16s ease;
}

/* ✅ FIX SCOPE: Drawer trượt từ BÊN TRÁI cho mobile + tablet */
.ntd-mobile-drawer{
  position: fixed;
  top: 0;
  left: 0;          /* was: right:0 */
  right: auto;      /* was: right:0 */
  height: 100vh;
  width: 420px;
  max-width: 100vw;
  z-index: 1050;

  background: linear-gradient(
    180deg,
    var(--ntd-orange-2) 0%,
    var(--ntd-orange-1) 55%,
    #ffa55a 100%
  );
  box-shadow: var(--ntd-shadow-main);

  transform: translateX(-110%); /* was: translateX(110%) */
  transition: transform .18s ease;
  display:flex;
  flex-direction:column;
  font-size: 15px;
}

@media (max-width: 420px){
  .ntd-mobile-drawer{ width: 100vw; }
}

.ntd-shell.ntd-mobile-open .ntd-mobile-overlay{
  opacity: 1;
  pointer-events: auto;
}
.ntd-shell.ntd-mobile-open .ntd-mobile-drawer{
  transform: translateX(0);
}

/* Drawer top */
.ntd-mobile-drawer__top{
  padding: 14px 14px 10px 14px;
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
}

.ntd-mobile-drawer__brand{
  display:flex;
  align-items:center;
  gap:10px;
  color:#fff;
  background: rgba(255,255,255,.18);
  border: 1px solid rgba(255,255,255,.28);
  border-radius: 20px;
  padding: 10px 12px;
  box-shadow: var(--ntd-shadow-soft);
  flex:1;
  min-width: 0;
}

.ntd-mobile-drawer__brand .logo{
  width: 42px;
  height: 42px;
  border-radius: 999px;
  background: #fff;
  display:flex;
  align-items:center;
  justify-content:center;
  font-weight: 900;
  color: var(--ntd-orange-2);
  flex: 0 0 auto;
}

.ntd-mobile-drawer__brand .text{ min-width: 0; display:flex; flex-direction:column; }

.ntd-mobile-drawer__brand .text .name{
  font-weight: 900;
  line-height: 1.1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ntd-mobile-drawer__brand .text .sub{
  opacity: .95;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ntd-mobile-drawer__close{
  width: 44px;
  height: 44px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,.55);
  background: rgba(255,255,255,.18);
  color:#fff;
  display:flex;
  align-items:center;
  justify-content:center;
  cursor:pointer;
  flex: 0 0 auto;
  touch-action: manipulation;
}

.ntd-mobile-drawer__body{
  padding: 10px 14px 14px 14px;
  overflow:auto;
  flex:1;
  display:flex;
  flex-direction:column;
  gap: 12px;
}

@media (max-width: 576px){
  .ntd-mobile-drawer{ font-size: 14px; }
  .ntd-mobile-drawer__brand .text .name{ font-size: 15px; }
  .ntd-mobile-drawer__brand .text .sub{ font-size: 12px; }
}
@media (max-width: 360px){
  .ntd-mobile-drawer{ font-size: 13.5px; }
}

.ntd-mobile-drawer .ntd-nav{
  margin-top: 0;
  padding: 6px;
  gap: 8px;
}
.ntd-mobile-drawer .ntd-nav__text{
  font-weight: 900;
  font-size: 1em;
}
.ntd-mobile-drawer .ntd-nav__link{
  padding: 12px 14px;
  border-radius: 16px;
}

.ntd-mobile-usercard{
  margin-top: auto;
  background: rgba(255,255,255,.18);
  border: 1px solid rgba(255,255,255,.28);
  border-radius: 20px;
  padding: 12px;
  box-shadow: var(--ntd-shadow-soft);
  color:#fff;
}

.ntd-mobile-usercard .row1{
  display:flex;
  align-items:center;
  gap:10px;
  min-width:0;
}

.ntd-mobile-usercard .avatar{
  width: 42px;
  height: 42px;
  border-radius: 999px;
  background:#fff;
  color: var(--ntd-orange-2);
  font-weight: 900;
  display:flex;
  align-items:center;
  justify-content:center;
  flex: 0 0 auto;
}

.ntd-mobile-usercard .info{
  min-width:0;
  flex:1;
}

.ntd-mobile-usercard .info .fullname{
  font-weight: 900;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 1.05em;
}

.ntd-mobile-usercard .info .username{
  opacity: .95;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: .85em;
}

.ntd-mobile-logout-btn{
  width: 100%;
  margin-top: 10px;
  border-radius: 14px !important;
  border: 1px solid rgba(255,255,255,.55) !important;
  background: rgba(255,255,255,.20) !important;
  color: #fff !important;
  font-weight: 900 !important;
  padding: 11px 12px !important;
  font-size: 1em;
}
.ntd-mobile-logout-btn:active{ transform: translateY(1px); }

/* Drawer/overlay không bị clip */
@media (max-width: 998px){
  .ntd-shell{ overflow: visible; }
}

/* =========================================================
   FIX TABLE PAN-X (wrapper) — BỔ SUNG .ntd-table-scroll-x
========================================================= */
.ntd-content .ntd-table-scroll-x,
.ntd-content .table-responsive,
.ntd-content .dataTables_wrapper,
.ntd-content div.dataTables_scrollBody{
  overflow-x: auto !important;
  overflow-y: hidden !important;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-x !important;
  max-width: 100%;
}

/* Chỉ ép nowrap + min-width ở < 999px để không phá desktop */
@media (max-width: 998px){
  .ntd-content table.dataTable th,
  .ntd-content table.dataTable td{
    white-space: nowrap;
  }
  .ntd-content table.dataTable{
    min-width: 720px;
    width: 100% !important;
  }
} /* ✅ FIX: đóng đúng dấu } cho @media */
