/* Smart Fix — Responsive layout (mobile & tablet) */

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(13, 58, 110, 0.45);
  z-index: 199;
  opacity: 0;
  transition: opacity 0.25s ease;
}

body.sidebar-open {
  overflow: hidden;
}

body.sidebar-open .sidebar-overlay,
.sidebar-overlay.active {
  display: block;
  opacity: 1;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  flex: 1;
}

.sidebar-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 1.5px solid var(--border, #c8e2f8);
  border-radius: 10px;
  background: #fff;
  color: var(--text-main, #0d3a6e);
  font-size: 22px;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.15s;
}

.sidebar-toggle:hover {
  background: var(--blue-50, #f0f7ff);
}

.table-responsive {
  -webkit-overflow-scrolling: touch;
}

@media (max-width: 991.98px) {
  .sidebar-toggle {
    display: inline-flex;
  }

  .sidebar {
    transform: translateX(-100%);
    transition: transform 0.28s ease;
    z-index: 200;
    width: min(280px, 88vw);
    max-width: 280px;
  }

  body.sidebar-open .sidebar,
  .sidebar.open {
    transform: translateX(0);
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.18);
  }

  .main-wrap {
    margin-left: 0 !important;
    width: 100%;
    max-width: 100vw;
    overflow-x: hidden;
  }

  .topbar {
    padding: 0 14px;
    height: auto;
    min-height: 54px;
    flex-wrap: wrap;
    gap: 8px;
    padding-top: 8px;
    padding-bottom: 8px;
  }

  .topbar-title {
    font-size: 15px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .topbar-right {
    flex-wrap: wrap;
    gap: 8px;
    justify-content: flex-end;
  }

  .topbar-right > span:not(:last-child) {
    display: none;
  }

  .page {
    padding: 14px !important;
  }

  .section-head {
    flex-wrap: wrap;
    gap: 8px;
    font-size: 14px;
    padding: 12px 14px;
  }

  .stat-card {
    padding: 16px;
  }

  .stat-num {
    font-size: 22px;
  }

  .btn-primary-sf,
  .btn-outline-sf {
    min-height: 42px;
  }

  .d-flex.gap-1,
  .d-flex.gap-2 {
    flex-wrap: wrap;
  }

  .table-sf {
    min-width: 100%;
  }

  .table-sf th,
  .table-sf td {
    font-size: 12px;
  }

  .modal-dialog {
    margin: 10px;
    max-width: calc(100% - 20px);
  }

  .modal-body .row.g-3 > [class*="col-md-"] {
    flex: 0 0 100%;
    max-width: 100%;
  }

  /* Progress stepper — เลื่อนแนวนอนได้ */
  .d-flex.align-items-start.gap-0.mb-4,
  .ticket-steps {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 6px;
    flex-wrap: nowrap !important;
  }

  .ticket-step {
    min-width: 64px;
  }

  .step-label,
  .ticket-step-label {
    font-size: 9px;
  }

  .step-dot,
  .ticket-step-dot {
    width: 30px;
    height: 30px;
    font-size: 12px;
  }

  .ticket-hero {
    padding: 16px !important;
  }

  .ticket-hero-title {
    font-size: 20px !important;
  }

  .ticket-hero-sub {
    font-size: 12px;
  }

  .info-grid,
  .repair-meta-grid {
    grid-template-columns: 1fr !important;
  }

  .bar-label {
    width: 72px;
    font-size: 11px;
  }

  .img-compare-photo,
  .img-compare-empty {
    height: 140px;
  }

  .job-card {
    padding: 14px;
  }
}

@media (max-width: 575.98px) {
  .sidebar-user .user-name {
    font-size: 13px;
  }

  .topbar-title {
    font-size: 14px;
    max-width: 160px;
  }

  .page {
    padding: 10px !important;
  }

  .section-card .p-4,
  .section-card .p-3 {
    padding: 14px !important;
  }

  .col-lg-4 .section-card.text-center .row .col-4 {
    padding: 4px;
  }

  .col-lg-4 .section-card.text-center .row .col-4 div:first-child {
    font-size: 17px !important;
  }

  .form .col-12.d-flex.gap-2 {
    flex-direction: column;
  }

  .form .col-12.d-flex.gap-2 .btn-primary-sf,
  .form .col-12.d-flex.gap-2 .btn-outline-sf,
  .form .col-12.d-flex.gap-2 a.btn-outline-sf {
    width: 100%;
    text-align: center;
    justify-content: center;
  }

  .table-sf {
    min-width: 520px;
  }

  .ticket-hero .d-flex.flex-wrap {
    flex-direction: column;
    align-items: flex-start !important;
  }

  .modal.show {
    padding-left: 0 !important;
  }

  .modal.fade.show .modal-dialog {
    margin: 0;
    max-width: 100%;
    min-height: 100%;
  }

  .modal.fade.show .modal-content {
    min-height: 100vh;
    border-radius: 0;
  }
}

/* รูปก่อน/หลังซ่อม — เรียงแนวตั้งบนมือถือ */
@media (max-width: 767.98px) {
  .img-compare-wrap .col-6 {
    flex: 0 0 100%;
    max-width: 100%;
  }
}

/* หน้า Login */
.login-wrap {
  max-width: 400px;
  margin: 60px auto;
  padding: 0 16px;
  text-align: center;
}

@media (max-width: 575.98px) {
  .login-wrap {
    margin: 24px auto;
    padding: 0 12px;
  }

  body.login-page .login-card {
    padding: 24px 18px !important;
  }
}

@media (max-width: 991.98px) {
  html {
    overflow-x: hidden;
  }
}
