/* =========================================================
ระบบบริหารจัดการร้าน อู่ ว.เจริญยนต์ เซอร์วิส
Theme หลัก: ฟ้า #1A5276
========================================================= */
:root {
    --brand: #1A5276;
    --brand-dark: #123c57;
    --brand-light: #2E86C1;
    --brand-bg: #EAF2F8;
    --brand-accent: #F4B400;
    --radius: 14px;
    --shadow-sm: 0 1px 3px rgba(26, 82, 118, 0.08), 0 1px 2px rgba(26, 82, 118, 0.10);
    --shadow-md: 0 4px 14px rgba(26, 82, 118, 0.12);
    --sidebar-w: 268px;
}
* { box-sizing: border-box; }
/* เผื่อพื้นที่ scrollbar แนวตั้งไว้ตลอดเวลา ป้องกันหน้าขยับ/รีโฟลว์ตอนเปิด modal (ดูข้อมูล/แก้ไข)
   ซึ่งเบราว์เซอร์จะซ่อน scrollbar ชั่วคราวจนพื้นที่หน้าจอกว้างขึ้นแล้วแคบกลับ ถ้าหน้านั้นมี scrollbar อยู่ก่อน
   ต้องปิดการเพิ่ม padding-right ที่ Bootstrap ใส่ชดเชยตอนเปิด modal ด้วย ไม่งั้นจะชดเชยซ้ำซ้อนกับข้อนี้
   (Bootstrap เช็คแค่ว่ามี scrollbar อยู่ตอนนั้นไหม ไม่รู้ว่าเราเผื่อพื้นที่ไว้ถาวรแล้ว) */
html { overflow-y: scroll; }
body.modal-open { padding-right: 0 !important; }
body {
    font-family: 'Sarabun', 'Noto Sans Thai', -apple-system, 
    BlinkMacSystemFont, 'Segoe UI', sans-serif; 
    background: #F5F8FA; 
    color: #1f2937; }
a { text-decoration: none; }

/* ---------- Layout shell ---------- */
.app-shell { display: flex; min-height: 100vh; }
.sidebar {
    width: var(--sidebar-w);
    flex-shrink: 0;
    background: linear-gradient(180deg, var(--brand) 0%, var(--brand-dark) 100%);
    color: #fff;
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    overflow-y: auto;
    z-index: 1030;
    transition: transform .25s ease;
}
.sidebar-brand { 
    display: flex; 
    align-items: center; 
    gap: 10px; padding: 22px 20px 16px; 
    border-bottom: 1px solid rgba(255,255,255,.12); }
.sidebar-brand .logo-badge {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    background: rgba(255,255,255,.15);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
}
.sidebar-brand .name { 
    font-weight: 700; 
    font-size: 15px; 
    line-height: 1.25; }
.sidebar-brand .role-tag { 
    font-size: 11.5px; 
    opacity: .75; }
.sidebar-user { 
    padding: 16px 20px; 
    border-bottom: 1px solid rgba(255,255,255,.10); 
    display: flex; 
    align-items: center; 
    gap: 10px; }
.sidebar-user .avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: rgba(255,255,255,.18);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
}
.sidebar-user .u-name { 
    font-size: 13.5px; 
    font-weight: 600; }
.sidebar-user .u-role { 
    font-size: 11.5px; 
    opacity: .7; }
.sidebar-nav { 
    padding: 14px 12px 100px; }
.sidebar-nav .nav-section-title { 
    font-size: 11px; 
    text-transform: uppercase; 
    letter-spacing: .06em; 
    opacity: .55; 
    margin: 16px 10px 6px; }
.sidebar-nav a.nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    color: rgba(255,255,255,.86);
    padding: 10px 14px;
    border-radius: 10px;
    font-size: 14px;
    margin-bottom: 3px;
    transition: background .15s ease, color .15s ease;
}
.sidebar-nav a.nav-link i { 
    width: 18px; 
    text-align: center; 
    font-size: 15px; }
.sidebar-nav a.nav-link:hover { 
    background: rgba(255,255,255,.10); 
    color: #fff; }
.sidebar-nav a.nav-link.active { 
    background: #fff; 
    color: var(--brand); 
    font-weight: 700; 
    box-shadow: var(--shadow-sm); }
.sidebar-nav a.nav-link .badge-count {
    margin-left: auto;
    background: var(--brand-accent);
    color: #1f2937;
    font-size: 10.5px;
    border-radius: 20px;
    padding: 1px 7px;
    font-weight: 700;
}
.main-area { 
    margin-left: var(--sidebar-w); 
    flex-grow: 1; min-width: 0; 
    width: 100%; }
.topbar {
    background: #fff;
    border-bottom: 1px solid #e5e9ec;
    padding: 14px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 1020;
}
.topbar .page-title { 
    font-size: 19px; 
    font-weight: 700; 
    color: var(--brand-dark); 
    margin: 0; }
.topbar .page-sub { 
    font-size: 12.5px; 
    color: #6b7280; }
.btn-burger { 
    display: none; 
    border: none; 
    background: transparent; 
    font-size: 20px; 
    color: var(--brand); }
.content-wrap { 
    padding: 24px; 
    max-width: 1440px; }

/* ---------- Cards ---------- */
.card { border: none; border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.card-header {
    background: #fff;
    border-bottom: 1px solid #eef1f3;
    border-radius: var(--radius) var(--radius) 0 0 !important;
    font-weight: 700;
    color: var(--brand-dark);
}
.stat-card {
    border-radius: var(--radius);
    background: #fff;
    box-shadow: var(--shadow-sm);
    padding: 18px 20px;
    display: flex;
    align-items: center;
    gap: 14px;
    height: 100%;
}
.stat-card .icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    color: #fff;
    flex-shrink: 0;
}
.stat-card .value { 
  font-size: 24px; 
  font-weight: 800; 
  color: #1f2937; 
  line-height: 1.1; }
.stat-card .label { 
  font-size: 12.5px; 
  color: #6b7280; 
  margin-top: 2px; }

/* ---------- Buttons ---------- */
.btn-brand, .btn-brand:hover, .btn-brand:focus { 
  background: var(--brand); 
  border-color: var(--brand); 
  color: #fff; }

.btn-brand:hover {
  background: var(--brand-dark);
  border-color: var(--brand-dark); }

/* ---------- ภาพรวมคิวการจอง (employee/bookings.php): จุดสีของคำอธิบายสถานะ ---------- */
.legend-dot {
  display: inline-block;
  width: 11px;
  height: 11px;
  border-radius: 3px;
  margin-right: 4px;
  vertical-align: middle;
  border: 1px solid #e5e7eb; }

/* ---------- รูปในหน้าต่าง "ดูข้อมูล" (main.js): รูปเดียวโชว์ใหญ่ หลายรูปจัดเป็นตารางรูปย่อ กดเปิดเต็มได้ ---------- */
.detail-thumb {
  width: 110px;
  height: 110px;
  object-fit: cover;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  cursor: pointer;
  transition: .15s; }
.detail-thumb:hover { opacity: .85; transform: scale(1.03); }
.detail-thumb-single {
  width: auto;
  height: auto;
  max-height: 260px;
  max-width: 100%; }

/* ---------- การ์ดข้อมูลอะไหล่ที่เลือกไว้ในแบบฟอร์มรับซ่อม (เห็นรูป/ยี่ห้อ-รุ่น/สต็อกก่อนกรอกจำนวน) ---------- */
.pp-info {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
  padding: 6px 8px;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  background: #f8fafc; }
.pp-img-link { flex-shrink: 0; display: inline-block; line-height: 0; }
.pp-img {
  width: 40px;
  height: 40px;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid #e5e7eb;
  background: #fff;
  flex-shrink: 0;
  cursor: pointer; }
.pp-text { min-width: 0; flex: 1; }
.pp-name { font-size: 12.5px; font-weight: 600; color: #172033; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pp-meta { font-size: 11.5px; color: #64748b; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pp-stock { flex-shrink: 0; font-size: 11px; }
.pp-stock-good { background: #d1fae5; color: #047857; }
.pp-stock-low { background: #fef3c7; color: #b45309; }
.pp-stock-out { background: #fee2e2; color: #b91c1c; }

/* ---------- กล่องพิมพ์ค้นหาอะไหล่แบบมีรูป (แบบฟอร์มรับซ่อม)
   ใช้กล่องผลค้นหาชุดเดียวร่วมกันทุกแถว ต่อเข้ากับ <body> โดยตรง (ไม่ซ้อนอยู่ใน .table-responsive)
   กันปัญหาโดนตัดขอบ/บังคับให้เกิด scroll เพราะตารางมี overflow-x:auto ของตัวเองอยู่แล้ว ---------- */
.part-search-wrap { position: relative; }
.part-search-results {
  position: fixed;
  z-index: 1090;
  max-height: 320px;
  overflow-y: auto;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  box-shadow: 0 10px 28px rgba(0,0,0,.14); }
.part-search-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  cursor: pointer;
  border-bottom: 1px solid #f1f3f5; }
.part-search-item:last-child { border-bottom: 0; }
.part-search-item:hover { background: #f1f5f9; }
.part-search-item img,
.part-search-item .psi-noimg {
  width: 36px;
  height: 36px;
  border-radius: 6px;
  border: 1px solid #e5e7eb;
  background: #fff;
  object-fit: cover;
  flex-shrink: 0; }
.part-search-item .psi-noimg { display: flex; align-items: center; justify-content: center; color: #999; }
.part-search-item .psi-text { min-width: 0; flex: 1; }
.part-search-item .psi-name { font-size: 13px; font-weight: 600; color: #172033; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.part-search-item .psi-meta { font-size: 11.5px; color: #64748b; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.part-search-empty { padding: 14px; text-align: center; color: #94a3b8; font-size: 13px; }

/* กล่องแก้ไขที่ครอบเนื้อหาด้วย <form>: ให้ส่วนเนื้อหาเลื่อนได้เมื่อยาวเกินหน้าจอ
   (Bootstrap ต้องการให้ .modal-body เป็นลูกตรงของ .modal-content ถ้ามี form คั่นต้องทำให้ form เป็น flex เอง) */
.modal-dialog-scrollable .modal-content > form {
  display: flex;
  flex-direction: column;
  min-height: 0;
  max-height: 100%;
  overflow: hidden; }
.modal-dialog-scrollable .modal-content > form > .modal-body {
  overflow-y: auto; }

/* ปุ่มบันทึกที่ถูกล็อกไว้ (รอให้แก้ข้อมูลก่อน) ต้องยังมองเห็นชัดว่าเป็นปุ่ม ไม่ใช่หายไป */
.btn-brand:disabled, .btn-brand.disabled {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
  opacity: .5;
  cursor: not-allowed; }

.btn-outline-brand { 
  border-color: var(--brand); 
  color: var(--brand); 
  background: #fff; }

.btn-outline-brand:hover { 
  background: var(--brand); 
  color: #fff; }

.text-brand { color: var(--brand) !important; }
.bg-brand { background: var(--brand) !important; }
.bg-brand-soft { background: var(--brand-bg) !important; }
.btn, .form-control, .form-select { border-radius: 10px; }
.btn-sm { border-radius: 8px; }

/* ---------- Tables ---------- */
.table thead th {
    background: var(--brand-bg);
    color: var(--brand-dark);
    font-size: 12.8px;
    text-transform: uppercase;
    letter-spacing: .03em;
    border-bottom: none;
    font-weight: 700;
    white-space: nowrap;
}
.table td { 
  vertical-align: middle; 
  font-size: 14px; }
.table-hover tbody tr:hover { background: #F7FBFD; }
.table-card { 
  border-radius: var(--radius); 
  overflow: hidden; box-shadow: var(--shadow-sm); 
  background:#fff; }

/* ---------- Badges ---------- */
.badge { 
  font-weight: 600; 
  padding: 5px 10px; 
  border-radius: 20px; 
  font-size: 11.5px; }

/* ---------- Login / auth pages ---------- */
.auth-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--brand) 0%, var(--brand-light) 100%);
    padding: 20px;
}
.auth-card {
    background: #fff;
    border-radius: 20px;
    box-shadow: 0 20px 50px rgba(0,0,0,.25);
    overflow: hidden;
    max-width: 960px;
    width: 100%;
    display: flex;
}
.auth-side {
    flex: 1;
    background: linear-gradient(160deg, var(--brand-dark), var(--brand));
    color: #fff;
    padding: 48px 40px;
    display: flex;
    flex-direction: column;
    justify-content: center;
}
.auth-side .badge-role {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: rgba(255,255,255,.12);
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 12.5px;
    margin-bottom: 18px;
    width: fit-content;
}
.auth-form-col { flex: 1; padding: 48px 44px; }
.role-pick { 
  display: grid; 
  grid-template-columns: 1fr 1fr; 
  gap: 10px; 
  margin-bottom: 18px; }
.role-pick label {
    border: 1.5px solid #e5e9ec;
    border-radius: 12px;
    padding: 10px 12px;
    font-size: 13px;
    text-align: center;
    cursor: pointer;
    transition: all .15s;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}
.role-pick input { display: none; }
.role-pick input:checked + label { 
  border-color: var(--brand); 
  background: var(--brand-bg); 
  color: var(--brand-dark); 
  font-weight: 700; }

  /* ---------- Booking calendar slots ---------- */
.slot-grid { 
  display: grid; 
  grid-template-columns: repeat(auto-fill, minmax(92px,1fr)); 
  gap: 8px; }
.slot-btn {
    border: 1.5px solid #dbe3e8;
    background: #fff;
    border-radius: 10px;
    padding: 10px 6px;
    text-align: center;
    font-size: 13px;
    cursor: pointer;
    transition: all .15s;
}
.slot-btn .cap { 
  font-size: 10.5px; 
  color: #6b7280; 
  display:block; 
  margin-top:2px; }

.slot-btn:hover:not(.full) {
  border-color: var(--brand); 
  background: var(--brand-bg); }

.slot-btn.selected,
.slot-btn.selected:hover {
  background: var(--brand);
  border-color: var(--brand); 
  color: #fff; }
  
.slot-btn.selected .cap { color: #dce9f2; }

.slot-btn.full { 
  background: #f3f4f6; 
  color: #b0b6bd; 
  cursor: not-allowed; 
  border-color: #e5e7eb; }

/* ภาพรวมคิวฝั่งพนักงาน: ใช้หน้าตาเดียวกับ slot-btn ของลูกค้า + สถานะ ว่าง/เต็มแล้ว/ยกเลิก */
.queue-overview-slot { cursor: default; }
.queue-overview-slot.has-booking { cursor: pointer; }
.queue-overview-slot:not(.has-booking):hover { border-color: #dbe3e8; background: #fff; }
.slot-btn.slot-taken { background: #fee2e2; color: #b91c1c; border-color: #fca5a5; }
.slot-btn.slot-taken .cap { color: #b91c1c; font-weight: 600; }
.slot-btn.slot-taken.has-booking:hover { background: #fecaca; border-color: #f87171; }
.slot-btn.slot-pending { background: #fef3c7; color: #92400e; border-color: #fcd34d; }
.slot-btn.slot-pending .cap { color: #92400e; font-weight: 600; }
.slot-btn.slot-pending.has-booking:hover { background: #fde68a; border-color: #fbbf24; }
.slot-btn.slot-free .cap { color: #15803d; }
.legend-dot.slot-free { background: #fff; }
.legend-dot.slot-pending { background: #fef3c7; border-color: #fcd34d; }
.legend-dot.slot-taken { background: #fee2e2; border-color: #fca5a5; }

/* หน้าต่างแสดงรายละเอียด/เอกสาร: สถานะเป็นข้อความธรรมดา ไม่มีพื้นสี
   (เฉพาะ badge สถานะ text-bg-*; ป้ายสต็อกในตัวเลือกอะไหล่ยังมีสีตามเดิม) */
.modal-body .badge[class*="text-bg-"],
.order-doc .badge[class*="text-bg-"] {
    background: none !important;
    color: inherit !important;
    padding: 0;
    border-radius: 0;
    font-size: inherit;
    font-weight: 600;
    vertical-align: baseline;
}

/* ---------- Misc ---------- */
.avatar-icon-btn {
    width: 34px;
    height: 34px;
    border-radius: 8px;
    border: 1px solid #e5e9ec;
    display:inline-flex;
    align-items:center;
    justify-content:center;
    color: var(--brand);
    background:#fff;
}
.avatar-icon-btn:hover { background: var(--brand-bg); }
.thumb-photo { 
  width: 40px; 
  height: 40px; 
  border-radius: 8px; 
  object-fit: cover; 
  border:1px solid #e5e9ec; }
.empty-state { 
  text-align: center; 
  padding: 50px 20px; 
  color: #9aa4ad; }
.empty-state i { 
  font-size: 42px; 
  margin-bottom: 10px; 
  display:block; }
.required-star { color: #dc2626; }
.modal-header { background: var(--brand-bg); }
@media print {
    .no-print { display: none !important;
    } .sidebar, .topbar { display: none !important;
    } .main-area { margin-left: 0 !important;
    } body { background: #fff;
    };
}
@media (max-width: 992px) {
    .sidebar { transform: translateX(-100%);
    } .sidebar.open { transform: translateX(0);
    box-shadow: var(--shadow-md);
    } .main-area { margin-left: 0;
    } .btn-burger { display: inline-block;
    };
}
/* ---------- Public landing page ---------- */
.public-page { background: #fff; color: #17202a; }
.public-nav {
    position: sticky;
    top: 0;
    z-index: 1000;
    background: #fff;
    border-bottom: 1px solid #e8edf0;
    padding: 12px 0;
    box-shadow: 0 3px 18px rgba(0, 0, 0, .05);
}
.brand-link { 
  display: flex; 
  align-items: center; 
  gap: 10px; color: var(--brand-dark); 
  font-weight: 800; 
  text-decoration: none; 
  font-size: 18px; }
.brand-icon {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    background: var(--brand);
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.public-hero { 
  background: linear-gradient(135deg, var(--brand-dark), var(--brand));
  color: #fff; 
  padding: 70px 0; }
.public-hero h1 { 
  font-size: clamp(32px, 5vw, 56px); 
  font-weight: 800; 
  margin: 12px 0; }
.public-hero p { 
  font-size: 18px; 
  opacity: .9; 
  max-width: 650px; }
.hero-kicker {
    display: inline-block;
    padding: 7px 13px;
    border: 1px solid rgba(255, 255, 255, .3);
    border-radius: 999px;
    font-size: 13px;
    background: rgba(255, 255, 255, .1);
}
.hero-photo {
    width: 100%;
    height: 500px;
    border-radius: 10px; 
    overflow: hidden;
    background: rgba(255,255,255,.12);
    border: 1px solid rgba(255,255,255,.2);
}

.hero-photo-button {
    display: block;
    width: 100%;
    height: 100%;
    padding: 0;
    margin: 0;
    border: 0;
    background: transparent;
    cursor: pointer;
}

.hero-photo-button img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.hero-placeholder { 
  display: flex; 
  flex-direction: column; 
  align-items: center; 
  justify-content: center; 
  gap: 10px; opacity: .7; 
  font-size: 18px; }
.hero-placeholder i {font-size: 80px;}

.section-pad {padding: 70px 0;}
.section-soft {background: #f7fafc;}
.section-heading { margin-bottom: 28px; }
.section-heading span { 
  color: var(--brand); 
  font-size: 13px; 
  font-weight: 800; 
  text-transform: uppercase; 
  letter-spacing: .08em; }
.section-heading h2 { font-weight: 800; margin: 4px 0 7px; }
.section-heading p { color: #6b7280; margin: 0; }
.info-card,.part-card { 
  position: relative;
  background: #fff; 
  border: 1px solid #e8edf0; 
  border-radius: 18px; 
  padding: 22px;
  height: 100%; 
  box-shadow: 0 5px 18px rgba(17, 24, 39, .04); }
.info-icon {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    background: var(--brand-bg);
    color: var(--brand);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    margin-bottom: 14px;
}
.info-card h5 { font-weight: 800; }
.info-card p { color: #6b7280; min-height: 42px; }
.part-photo {
    height: 125px;
    border-radius: 12px;
    background: linear-gradient(135deg, #eef5f8, #f9fbfc);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 14px;
    color: var(--brand);
    font-size: 45px;
}
.part-card h6 { min-height: 42px;
   line-height: 1.45; 
   font-weight: 700; }
.empty-public { padding: 35px;
   text-align: center; 
   background: #fff; 
   border: 1px dashed #ccd7dd; 
   border-radius: 16px; color: #7b8790; }
.location-card { border: 1px solid #e8edf0; 
  border-radius: 22px; 
  overflow: hidden;
  box-shadow: 0 8px 28px rgba(17, 24, 39, .06); }
.location-pin {
    width: 52px;
    height: 52px;
    border-radius: 15px;
    background: var(--brand-bg);
    color: var(--brand);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 25px;
    margin-bottom: 16px;
}
#garageMap { min-height: 420px; width: 100%; }
.public-footer { 
  background: #13212a; 
  color: #d9e3e8; 
  padding: 22px 0; 
  font-size: 13px; }
.booking-summary {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #fff;
    border: 1px solid #e7edf0;
    border-radius: 16px;
    padding: 16px 18px;
}
.booking-card { 
  background: #fff; 
  border: 1px solid #e4eaee; 
  border-radius: 16px; 
  padding: 18px; 
  box-shadow: 0 4px 16px rgba(17, 24, 39, .04); }
.booking-card-top { 
  display: flex; 
  justify-content: space-between; 
  align-items: center; 
  border-bottom: 1px solid #edf1f3; 
  padding-bottom: 12px; }
@media (max-width: 768px) {
    .public-hero { padding: 45px 0;
    } .section-pad { padding: 50px 0;
    } .booking-summary { gap: 10px;
    } .booking-summary .btn { white-space: nowrap;
    } #garageMap { min-height: 330px;
    };
}

/* ---------- รูปเพิ่มเติม ---------- */
.garage-gallery {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
}

.garage-gallery-item {
    width: 100%;
    height: 150px;
    padding: 0;
    border: 0;
    overflow: hidden;
    border-radius: 12px;
    background: #f3f4f6;
    box-shadow: 0 4px 12px rgba(0,0,0,.08);
    cursor: pointer;
}

.garage-gallery-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.garage-gallery-large {
    max-height: 75vh;
    object-fit: contain;
}

@media (max-width: 768px) {
    .garage-gallery {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }

    .garage-gallery-item {
        height: 130px;
    }
}
.booking-step {
    background: #fff;
    border-radius: 18px;
    padding: 25px 15px;
    height: 100%;
    box-shadow: 0 5px 18px rgba(17,24,39,.05);
}

.booking-step img {
    width: 120px;
    height: 120px;
    object-fit: contain;
    margin-bottom: 15px;
}

.booking-step h5 {
    font-weight: 700;
    margin: 0;
}

/*order employee*/
html,
body {
    overflow-x: hidden;
    max-width: 100%;
}

* {
    box-sizing: border-box;
}

.table-card {
    max-width: 100%;
    width: 100%;
    overflow: hidden;
}

.table-responsive {
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
}

.table-responsive table {
    min-width: 0;
}

.badge {
    display: inline-block !important;
    width: auto !important;
    max-width: 100%;
    white-space: nowrap;
}

.btn {
    max-width: 100%;
}

.modal {
    overflow-x: hidden;
}

.modal-dialog {
    width: auto;
    max-width: min(900px, calc(100vw - 30px));
}

.modal-content {
    max-width: 100%;
    overflow: hidden;
}

.modal-body {
    overflow-x: auto;
}

@media (max-width: 768px) {

    .table-card {
        width: 100%;
        max-width: 100%;
    }

    .table-responsive {
        width: 100%;
    }

    .modal-dialog {
        margin: 10px;
        max-width: calc(100vw - 20px);
    }

    .d-flex {
        max-width: 100%;
    }
    
}

/* =========================================================
   เอกสารใบสั่งซื้อ (.order-doc) ใช้ในหน้าต่างรายละเอียดและตอนพิมพ์
   ไม่มีกรอบ/พื้นสี ให้ดูเป็นเอกสาร
   ========================================================= */
.order-doc {
    color: #212529;
    font-size: 14px;
}

.order-doc-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
    border-bottom: 2px solid var(--brand);
    padding-bottom: 10px;
    margin-bottom: 14px;
}

.order-doc-title {
    font-size: 20px;
    font-weight: 800;
    color: var(--brand);
    margin: 0;
}

.order-doc-no {
    text-align: right;
    font-size: 13px;
}

.order-doc-no strong {
    display: block;
    font-size: 18px;
    color: var(--brand);
}

.order-doc-label {
    font-size: 12px;
    font-weight: 700;
    color: #6c757d;
    text-transform: uppercase;
    letter-spacing: .02em;
    margin-bottom: 2px;
}

.order-doc-info {
    width: 100%;
    margin-bottom: 14px;
}

.order-doc-info th {
    width: 140px;
    font-weight: 600;
    color: #495057;
    padding: 2px 8px 2px 0;
    vertical-align: top;
}

.order-doc-info td {
    padding: 2px 0;
}

.order-doc .table th {
    background: transparent;
    color: #212529;
    border-bottom-width: 2px;
}

/* หน้าต่างพิมพ์ที่เปิดจาก data-print-target */
body.print-doc {
    background: #fff;
    padding: 0;
    margin: 0;
}

@media print {
    @page {
        size: A4;
        margin: 12mm;
    }

    .order-doc .no-print {
        display: none !important;
    }
}

/* =========================================================
   มือถือ (จอแคบ): ย่อระยะขอบ/ตัวอักษร แถบค้นหาขึ้นบรรทัดใหม่ได้
   ตารางรายการเปลี่ยนเป็นการ์ดเรียงลงมาแทนการเลื่อนซ้าย-ขวา
   (main.js ใส่ data-label ให้แต่ละช่องจากหัวตาราง แล้วเติมคลาส .table-stack)
   ========================================================= */
@media (max-width: 576px) {
    .content-wrap { padding: 12px; }
    .topbar { padding: 10px 12px; }
    .topbar .page-title { font-size: 16px; }
    .topbar .page-sub { font-size: 11.5px; }
    .stat-card { padding: 12px 14px; gap: 10px; }
    .stat-card .icon { width: 40px; height: 40px; font-size: 17px; }
    .stat-card .value { font-size: 20px; }

    /* แถบค้นหา/เรียงลำดับเหนือตาราง: ช่องกรอกยืดหดตามจอ ไม่ดันปุ่มตกขอบ */
    .table-card form.d-flex { flex-wrap: wrap; width: 100%; }
    .table-card form.d-flex .form-control,
    .table-card form.d-flex .form-select {
        min-width: 0 !important;
        width: auto !important;
        flex: 1 1 130px;
    }
    /* ช่องวันที่ "จาก/ถึง" ในแถบกรอง วางคู่กันบรรทัดเดียว */
    .table-card form.row > [class*="col-md"]:has(> input[type="date"]) { width: 50%; }

    /* ตารางรายการ -> การ์ด: ชื่อคอลัมน์อยู่ซ้าย ข้อมูลอยู่ขวา */
    table.table-stack,
    table.table-stack > tbody { display: block; width: 100%; }
    table.table-stack > thead { display: none; }
    table.table-stack > tbody > tr {
        display: block;
        padding: 10px 14px;
        border-bottom: 6px solid #f1f4f6;
    }
    table.table-stack > tbody > tr:last-child { border-bottom: 0; }
    table.table-stack > tbody > tr > td {
        display: block;
        position: relative;
        min-height: 28px;
        padding: 4px 0 4px 38%;
        border: 0;
        font-size: 13.5px;
        text-align: left !important;
        overflow-wrap: anywhere;
    }
    table.table-stack > tbody > tr > td::before {
        content: attr(data-label);
        position: absolute;
        left: 0;
        top: 5px;
        width: 35%;
        font-size: 12px;
        font-weight: 700;
        color: #6b7280;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    table.table-stack > tbody > tr > td:not([data-label]),
    table.table-stack > tbody > tr > td[data-label=""] { padding-left: 0; }
    table.table-stack > tbody > tr > td:not([data-label])::before,
    table.table-stack > tbody > tr > td[data-label=""]::before { display: none; }
    table.table-stack > tbody > tr > td .d-flex.justify-content-end { justify-content: flex-start !important; }

    /* หน้าอะไหล่: หมวดหมู่/ยี่ห้อเป็นแถบเลื่อนแนวนอน การ์ดอะไหล่แถวละ 2 ใบ */
    .parts-sidebar .parts-sidebar-title { padding: 10px 14px 6px; font-size: 14px; }
    .parts-sidebar .parts-sidebar-section {
        display: flex;
        flex-wrap: nowrap;
        gap: 6px;
        padding: 0 12px 10px;
        max-height: none;
        overflow-x: auto;
        overflow-y: hidden;
        -webkit-overflow-scrolling: touch;
    }
    .parts-sidebar .parts-filter {
        flex: 0 0 auto;
        width: auto;
        padding: 6px 10px;
        border: 1px solid #e5e7eb;
        white-space: nowrap;
        font-size: 13.5px;
    }
    .parts-page .row > [class*="col-"]:has(> .part-card) { width: 50%; }
    .parts-page .part-card .part-image-wrap { height: 120px; }
    .parts-page .part-card .part-card-body { padding: 10px; }
    .parts-page .part-card .part-name { font-size: 14px; }
    .parts-page .part-card .part-price { font-size: 16px; }
    .parts-page .part-card .part-price-row,
    .parts-page .part-card .part-actions { flex-wrap: wrap; }
}

/* หน้าแรก (มือถือ): ย่อโลโก้/ปุ่มบนแถบบน ให้ปุ่มเข้าสู่ระบบและสมัครสมาชิกอยู่บรรทัดเดียวกันได้ */
@media (max-width: 576px) {
    .public-nav .container { gap: 8px !important; }
    .public-nav .brand-link { font-size: 14px; gap: 6px; min-width: 0; }
    .public-nav .brand-link > span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    .public-nav .brand-icon { width: 32px; height: 32px; border-radius: 9px; font-size: 14px; flex-shrink: 0; }
    .public-nav-actions { gap: 6px !important; flex-shrink: 0; }
    .public-nav-actions .btn { padding: 6px 9px; font-size: 13px; white-space: nowrap; }
}

/* การ์ดสรุปบนแดชบอร์ดที่กดไปหน้ารายการได้ */
.dashboard-clickable {
    position: relative;
    cursor: pointer;
    color: inherit;
    transition: all 0.2s ease;
}
.dashboard-clickable:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 20px rgba(0,0,0,0.10);
}
.dashboard-clickable:active { transform: scale(0.98); }

/* หน้าต่างเปิดงานซ่อมใหม่: ตัวเลือกของแต่ละประเภทการรับซ่อมซ้อนกันในช่องเดียว
   ช่องที่ไม่ได้เลือกยังกินพื้นที่อยู่ (แค่มองไม่เห็น) หน้าต่างจึงสูงเท่ากันทุกประเภท */
.source-stack { display: grid; }
.source-stack > * { grid-area: 1 / 1; min-width: 0; }
.source-stack > .d-none { display: block !important; visibility: hidden; }

/* หน้าแรก (มือถือ): ปุ่มใต้ชื่ออู่ขนาดปกติ กว้างเท่ากัน รูปอู่ไม่สูงเกินจอ */
@media (max-width: 576px) {
    .public-hero { padding: 32px 0; }
    .public-hero p { font-size: 15px; }
    .hero-actions { margin-top: 1rem !important; }
    .hero-actions .btn {
        flex: 1 1 0;
        padding: 9px 10px;
        font-size: 15px;
        border-radius: 10px;
        white-space: nowrap;
    }
    .hero-photo { height: 260px; }
}

/* รายการแนะนำใต้ช่องพิมพ์ค้นหา (main.js สร้างแทน datalist ของเบราว์เซอร์) */
.suggest-box {
    position: absolute;
    z-index: 1080;
    max-height: 240px;
    overflow-y: auto;
    background: #fff;
    border: 1px solid #dbe3e8;
    border-radius: 10px;
    box-shadow: 0 10px 28px rgba(0,0,0,.14);
}
.suggest-item {
    display: block;
    width: 100%;
    padding: 10px 12px;
    border: 0;
    border-bottom: 1px solid #f1f3f5;
    background: #fff;
    color: #172033;
    font-size: 15px;
    text-align: left;
}
.suggest-item:last-child { border-bottom: 0; }
.suggest-item:hover, .suggest-item:active { background: var(--brand-bg); }

/* =========================================================
   มือถือ: ช่องกรอก ปุ่ม และหน้าต่าง modal
   ========================================================= */
@media (max-width: 576px) {
    /* ตัวอักษรในช่องกรอกต้องไม่เล็กกว่า 16px ไม่งั้น iPhone จะซูมหน้าจอเองทุกครั้งที่แตะช่องกรอก */
    input.form-control, textarea.form-control, select.form-select,
    .form-control-sm, .form-select-sm { font-size: 16px; }

    /* ปุ่มเล็ก/ปุ่มไอคอน: ขยายพื้นที่แตะให้กดง่าย */
    .btn-sm { min-height: 36px; padding: 6px 12px; font-size: 14px; }
    .avatar-icon-btn { width: 40px; height: 40px; }

    /* แถบกรองที่มีช่วงวันที่ (input-group) ใช้ความกว้างเต็มบรรทัด */
    .table-card form.d-flex .input-group { width: 100% !important; flex-wrap: nowrap; }
    .table-card form.d-flex .input-group .form-control { flex: 1 1 0; padding-left: 8px; padding-right: 8px; }

    /* modal: ใช้พื้นที่จอให้คุ้ม หัวข้อไม่ใหญ่เกิน ปุ่มด้านล่างกว้างเท่ากันและกดง่าย */
    .modal-header { padding: 12px 14px; }
    .modal-header .modal-title { font-size: 16px; line-height: 1.35; }
    .modal-body { padding: 14px; }
    .modal-footer { padding: 10px 14px; gap: 8px; }
    .modal-footer > * { margin: 0; }
    .modal-footer > .btn { flex: 1 1 auto; white-space: normal; }
    .modal-footer > .me-auto { margin-right: 0 !important; }
    .modal-dialog-scrollable { height: calc(100% - 20px); }
    .modal-body .row > [class*="col-md"] { overflow-wrap: anywhere; }

    /* ตารางย่อยใน modal (รายการอะไหล่ ฯลฯ): ย่อตัวอักษรและช่องไฟให้พอดีจอ */
    .modal-body .table-sm > :not(caption) > * > * { padding: 5px 6px; font-size: 13px; }
    .modal-body .table thead th { white-space: normal; font-size: 12px; }

    /* ช่องเวลา: 3 ช่องต่อแถวเท่ากันทุกหน้า */
    .slot-grid { grid-template-columns: repeat(3, 1fr); }
    .slot-btn { padding: 10px 4px; font-size: 14px; }
}

/* หน้าต่างเปิดงานซ่อมใหม่: รายการรถของลูกค้าหน้าร้าน (เห็นทั้งหมด เลื่อนดู แตะเลือกได้) */
.car-pick-list {
    max-height: 210px;
    overflow-y: auto;
    border: 1px solid #dbe3e8;
    border-radius: 10px;
    background: #fff;
}
.car-pick-item {
    display: block;
    width: 100%;
    padding: 9px 12px;
    border: 0;
    border-bottom: 1px solid #f1f3f5;
    background: #fff;
    color: #172033;
    font-size: 14.5px;
    text-align: left;
}
.car-pick-item:last-child { border-bottom: 0; }
.car-pick-item:hover { background: var(--brand-bg); }
.car-pick-item.active,
.car-pick-item.active:hover { background: var(--brand); color: #fff; }
.car-pick-item.active .text-muted { color: #dce9f2 !important; }

/* ---------- แดชบอร์ด: การ์ดสรุปเรียงเป็นกริดเท่ากันทุกใบ (ทุกบทบาทใช้ชุดเดียวกัน) ---------- */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
    gap: 14px;
}
.stat-grid > .stat-card { height: auto; min-width: 0; }
.stat-grid .stat-card .label { overflow-wrap: anywhere; }
/* รายการในกล่องของแดชบอร์ดที่กดไปหน้ารายการได้ */
.dash-list-link { color: inherit; text-decoration: none; border-radius: 8px; }
.dash-list-link:hover { background: #F7FBFD; color: inherit; }
@media (max-width: 576px) {
    /* มือถือ: 2 ใบต่อแถว ถ้าจำนวนเป็นเลขคี่ ใบสุดท้ายกว้างเต็มแถว ไม่เหลือช่องโหว่ */
    .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
    .stat-grid > :last-child:nth-child(odd) { grid-column: 1 / -1; }
    .stat-grid .stat-card { padding: 12px; gap: 10px; }
    .stat-grid .stat-card .label { font-size: 12px; line-height: 1.3; }
}

/* ช่วงเวลาที่เลือกอยู่: พื้นเข้ม ตัวหนังสือขาว เห็นชัดทั้งตอนแตะค้างและหลังปล่อยนิ้ว */
.slot-grid .slot-btn.selected,
.slot-grid .slot-btn.selected:hover,
.slot-grid .slot-btn.selected:active {
    background: var(--brand) !important;
    border-color: var(--brand-dark) !important;
    color: #fff !important;
    font-weight: 700;
    box-shadow: 0 0 0 3px rgba(31, 78, 121, .22);
}
.slot-grid .slot-btn.selected .cap { color: #fff !important; opacity: .9; }

/* แก้ไขข้อมูลอู่: รูปเพิ่มเติม มีปุ่มกากบาทมุมขวาบนสำหรับลบ */
.gallery-edit-item { position: relative; }
.gallery-remove-btn {
    position: absolute;
    top: -8px;
    right: -8px;
    width: 28px;
    height: 28px;
    padding: 0;
    border: 2px solid #fff;
    border-radius: 50%;
    background: #dc2626;
    color: #fff;
    font-size: 13px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 6px rgba(0,0,0,.25);
}
.gallery-remove-btn:hover { background: #b91c1c; }
.gallery-removed-note {
    display: none;
    position: absolute;
    left: 4px;
    right: 4px;
    bottom: 4px;
    padding: 2px 4px;
    border-radius: 0 0 6px 6px;
    background: rgba(185, 28, 28, .9);
    color: #fff;
    font-size: 11px;
    text-align: center;
}
.gallery-edit-item.is-removed img { opacity: .3; }
.gallery-edit-item.is-removed .gallery-removed-note { display: block; }
.gallery-edit-item.is-removed .gallery-remove-btn { background: #475569; }
