/* T-Go Hub v1.0 (build 18.1.6) — T-Purchase V2 Layout
   - Tab Navigation แนวนอนด้านบน + Role badge / User name
   - หน้าผู้ขายเชื่อม Master Data + Vendor edit modal
   - หน้าสถานะเอกสาร + ระบบสิทธิ์อนุมัติ
   - Bottom Action Bar / Modal Costsheet
*/

/* ===== Layout: Tab navigation แนวนอนด้านบน ===== */
.tpv2.tpv2-tabs-layout{
  display:flex;
  flex-direction:column;
  min-height:calc(100vh - 64px);
}
.tpv2-tabs-layout .tpv2-shell{display:none}
.tpv2-tabs-layout .tpv2-rail{display:none !important}

.tpv2-tabbar{
  background:#111827;
  color:white;
  position:sticky;
  top:0;
  z-index:50;
  box-shadow:0 2px 8px rgba(15,23,42,0.15);
}
.tpv2-tabbar-inner{
  display:flex;
  align-items:center;
  gap:24px;
  padding:0 22px;
  min-height:64px;
  flex-wrap:wrap;
}

.tpv2-tabbar-brand{
  display:flex;
  align-items:center;
  gap:12px;
  padding:10px 0;
  border-right:1px solid rgba(255,255,255,0.1);
  padding-right:24px;
}
.tpv2-tabbar-brand .tpv2-brand-logo{
  width:36px;
  height:36px;
  border-radius:10px;
  background:#6d5bd0;
  display:grid;
  place-items:center;
  font-weight:800;
  font-size:16px;
  color:white;
}
.tpv2-tabbar-brand-text b{
  display:block;
  font-size:14px;
  line-height:1.2;
}
.tpv2-tabbar-brand-text span{
  display:block;
  font-size:11px;
  color:#cbd5e1;
  margin-top:2px;
}

.tpv2-tabbar-nav{
  display:flex;
  gap:4px;
  flex:1;
  flex-wrap:wrap;
  align-items:center;
  padding:8px 0;
}
.tpv2-tabbar-nav button{
  border:0;
  background:transparent;
  color:#cbd5e1;
  padding:9px 14px;
  border-radius:8px;
  cursor:pointer;
  font-weight:600;
  font-size:13px;
  white-space:nowrap;
  transition:all 0.15s;
}
.tpv2-tabbar-nav button:hover{
  background:rgba(255,255,255,0.08);
  color:white;
}
.tpv2-tabbar-nav button.active{
  background:#6d5bd0;
  color:white;
  box-shadow:0 2px 8px rgba(109,91,208,0.4);
}

/* ===== User & Role Badge ===== */
.tpv2-tabbar-user{
  display:flex;
  align-items:center;
  gap:10px;
  padding-left:16px;
  border-left:1px solid rgba(255,255,255,0.1);
}
.tpv2-user-name{
  color:#e2e8f0;
  font-size:13px;
  font-weight:500;
}
.tpv2-role-badge{
  display:inline-flex;
  align-items:center;
  padding:4px 10px;
  border-radius:8px;
  font-size:11px;
  font-weight:800;
  letter-spacing:0.5px;
}
.tpv2-role-badge.tpv2-role-ceo{background:#8b5cf6;color:white;box-shadow:0 0 0 2px rgba(139,92,246,0.3)}
.tpv2-role-badge.tpv2-role-bo{background:#06b6d4;color:white;box-shadow:0 0 0 2px rgba(6,182,212,0.3)}
.tpv2-role-badge.tpv2-role-user{background:#64748b;color:white}

/* ===== Main content เต็มความกว้าง ===== */
.tpv2-main.tpv2-main-full{
  flex:1;
  padding:22px;
  min-width:0;
  width:100%;
  max-width:none;
}

/* ===== Topbar with Back button (บนซ้าย) ===== */
.tpv2-top.tpv2-top-with-back{
  align-items:flex-start;
}
.tpv2-top-left{
  display:flex;
  align-items:center;
  gap:14px;
}
.tpv2-top-left .tpv2-title{
  font-size:22px;
}
.tpv2-btn.ghost{
  background:#f1f5f9;
  border-color:#e2e8f0;
  color:#334155;
  font-weight:700;
}
.tpv2-btn.ghost:hover{
  background:#e2e8f0;
}
.tpv2-btn.danger{
  background:#fef2f2;
  border-color:#fecaca;
  color:#b91c1c;
}
.tpv2-btn.danger:hover{
  background:#fee2e2;
}
.tpv2-btn.is-disabled,
.tpv2-btn[disabled]{
  opacity:0.45;
  cursor:not-allowed;
  filter:grayscale(0.5);
}

/* ===== Bottom Action Bar (sticky ขวาล่าง) ===== */
.tpv2-with-bottom-bar{
  padding-bottom:88px;
}
.tpv2-bottom-bar{
  position:sticky;
  bottom:0;
  left:0;
  right:0;
  margin:0 -22px -22px;
  background:linear-gradient(180deg, rgba(255,255,255,0.7) 0%, #ffffff 30%);
  border-top:1px solid #e5e7eb;
  padding:14px 22px;
  z-index:10;
  backdrop-filter:blur(8px);
  -webkit-backdrop-filter:blur(8px);
  box-shadow:0 -4px 16px rgba(15,23,42,0.06);
}
.tpv2-bottom-bar-inner{
  display:flex;
  gap:10px;
  justify-content:flex-end;
  align-items:center;
  flex-wrap:wrap;
}
.tpv2-bottom-bar .tpv2-btn{
  min-width:110px;
  padding:11px 18px;
  font-size:14px;
}

/* ===== Modal (Costsheet picker / Vendor edit) ===== */
.tpv2-modal-backdrop{
  position:fixed;
  inset:0;
  background:rgba(15,23,42,0.55);
  display:flex;
  align-items:center;
  justify-content:center;
  padding:24px;
  z-index:1000;
  animation:tpv2-fade-in 0.15s ease-out;
}
@keyframes tpv2-fade-in{from{opacity:0}to{opacity:1}}
.tpv2-modal{
  background:white;
  border-radius:16px;
  width:100%;
  max-width:920px;
  max-height:85vh;
  display:flex;
  flex-direction:column;
  box-shadow:0 24px 64px rgba(15,23,42,0.30);
  animation:tpv2-slide-up 0.2s ease-out;
  overflow:hidden;
}
@keyframes tpv2-slide-up{from{transform:translateY(20px);opacity:0}to{transform:translateY(0);opacity:1}}
.tpv2-modal-head{
  display:flex;
  justify-content:space-between;
  align-items:flex-start;
  padding:20px 24px;
  border-bottom:1px solid #e5e7eb;
  background:#fafbff;
}
.tpv2-modal-head h2{margin:0;font-size:20px;color:#172033}
.tpv2-modal-head .tpv2-muted{margin:4px 0 0;font-size:13px}
.tpv2-modal-close{
  border:0;background:transparent;cursor:pointer;font-size:28px;line-height:1;color:#64748b;
  width:36px;height:36px;border-radius:8px;display:grid;place-items:center;transition:all 0.15s;
}
.tpv2-modal-close:hover{background:#e2e8f0;color:#172033}
.tpv2-modal-body{flex:1;overflow:auto;padding:8px 24px 16px}
.tpv2-modal-foot{
  padding:14px 24px;border-top:1px solid #e5e7eb;background:#fafbff;
  display:flex;justify-content:flex-end;gap:10px;
}

/* ===== Vendor Edit Form ===== */
.tpv2-vendor-form{
  display:grid;
  gap:14px;
  padding:8px 0;
}
.tpv2-field-v{
  display:grid;
  gap:6px;
}
.tpv2-field-v label{
  font-size:13px;
  font-weight:600;
  color:#475569;
}
.tpv2-field-v input{
  width:100%;
  padding:10px 12px;
  border:1px solid #dbe2ef;
  border-radius:10px;
  font-size:14px;
}
.tpv2-field-v input:focus{
  outline:none;
  border-color:#6d5bd0;
  box-shadow:0 0 0 3px rgba(109,91,208,0.15);
}

/* ===== Bridge Info (ผู้ขาย / สิทธิ์) ===== */
.tpv2-bridge-info,
.tpv2-perm-info{
  margin:0 0 16px;
  padding:12px 16px;
  border-radius:12px;
  font-size:13px;
  background:#eef2ff;
  border:1px solid #c7d2fe;
  color:#3730a3;
  display:flex;
  align-items:center;
  gap:8px;
  flex-wrap:wrap;
}
.tpv2-bridge-info.tpv2-bridge-warn{
  background:#fef3c7;
  border-color:#fde68a;
  color:#92400e;
}
.tpv2-perm-info{
  background:#f0fdf4;
  border-color:#bbf7d0;
  color:#166534;
}

/* ===== Doc type badge (PR/PO) ===== */
.tpv2-doctype-badge{
  display:inline-block;
  padding:3px 10px;
  border-radius:6px;
  font-size:11px;
  font-weight:800;
  letter-spacing:0.5px;
}
.tpv2-doctype-badge.pr{background:#dbeafe;color:#1e40af}
.tpv2-doctype-badge.po{background:#fce7f3;color:#9f1239}

/* ===== Report items ในหน้าหลัก ===== */
.tpv2-report-item{
  background:#f8fafc;
  border:1px solid #e2e8f0;
  border-radius:12px;
  padding:16px;
}
.tpv2-report-num{
  font-size:24px;
  font-weight:800;
  color:#172033;
  margin-top:6px;
}

/* ===== Badge เพิ่มเติม ===== */
.tpv2-badge.draft{background:#f3f4f6;color:#374151;border-color:#d1d5db}

/* ===== รองรับมือถือ / จอแคบ ===== */
@media(max-width:1100px){
  .tpv2-tabbar-inner{padding:0 16px;gap:12px}
  .tpv2-tabbar-brand{border-right:0;padding-right:0;width:auto}
  .tpv2-tabbar-nav{overflow-x:auto;flex-wrap:nowrap;padding-bottom:6px}
  .tpv2-tabbar-user{padding-left:0;border-left:0}
  .tpv2-bottom-bar{margin:0 -16px -16px;padding:12px 16px}
  .tpv2-modal{max-height:92vh}
  .tpv2-top-left{flex-wrap:wrap}
  .tpv2-main.tpv2-main-full{padding:16px}
}

@media print{
  .tpv2-bottom-bar,
  .tpv2-modal-backdrop,
  .tpv2-tabbar,
  .tpv2-top-left .tpv2-btn{display:none!important}
}

/* ===== v18.2.1: Editable cells in PR table ===== */
.tpv2-cell{
  width:100%;
  border:1px solid #e5e7eb;
  border-radius:6px;
  padding:6px 8px;
  font:inherit;
  background:#fff;
  box-sizing:border-box;
  outline:none;
  transition:border-color .15s, box-shadow .15s;
}
.tpv2-cell:hover{border-color:#cbd5e1}
.tpv2-cell:focus{
  border-color:#3b82f6;
  box-shadow:0 0 0 3px rgba(59,130,246,.15);
}
.tpv2-cell-sub{
  color:#475569;
  background:#f9fafb;
}
.tpv2-cell-sub:focus{background:#fff}
.tpv2-cell.right{text-align:right}
/* select dropdown ใน table */
select.tpv2-cell{
  cursor:pointer;
  background-image:url("data:image/svg+xml;charset=US-ASCII,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2364748b' d='M2 4l4 4 4-4'/%3E%3C/svg%3E");
  background-repeat:no-repeat;
  background-position:right 8px center;
  padding-right:24px;
  appearance:none;
  -webkit-appearance:none;
  -moz-appearance:none;
}

/* v18.2.2 PR bottom action layout */
.tpv2-bottom-bar-inner.tpv2-bottom-bar-split{
  justify-content:space-between;
  align-items:center;
  gap:16px;
}
.tpv2-bottom-left,
.tpv2-bottom-right{
  display:flex;
  gap:10px;
  align-items:center;
  flex-wrap:wrap;
}
.tpv2-bottom-left{justify-content:flex-start;}
.tpv2-bottom-right{justify-content:flex-end;margin-left:auto;}
@media(max-width:760px){
  .tpv2-bottom-bar-inner.tpv2-bottom-bar-split{align-items:stretch;}
  .tpv2-bottom-left,.tpv2-bottom-right{width:100%;}
  .tpv2-bottom-right{margin-left:0;}
  .tpv2-bottom-bar .tpv2-btn{flex:1;}
}
