/**
 * Cold Chain System — Unified Native & PWA Stylesheet
 * File: assets/css/app.css
 * 
 * รวมสไตล์ระบบทั้งหมดสำหรับประสบการณ์ใช้งานดุจ Native App:
 * - Safe-Area Insets (รองรับติ่งจอและขอบล่าง iPhone)
 * - Native Touch & Active Interactions
 * - Table-Card Layout สำหรับการแสดงผลตู้แช่บนมือถือ
 * - Bottom Sheet Modals & Drag Handle
 */

/* ==========================================================================
   1. Base & Native Interaction Polish
   ========================================================================== */

/* ปิดกล่องสี่เหลี่ยมสีเทาเวลาแตะบน Mobile Safari / Chrome */
* {
  -webkit-tap-highlight-color: transparent;
}

/* Scrollbar สไตล์ shadcn/ui */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: #d4d4d8;
  border-radius: 9999px;
}
::-webkit-scrollbar-thumb:hover {
  background: #a1a1aa;
}

/* ป้องกันการเด้ง Scroll เกินขอบเขต และปิด Native Pull-to-Refresh ของ Browser โดยเด็ดขาด 100% */
html, body {
  overscroll-behavior-y: none !important;
  overscroll-behavior: none !important;
}

.overscroll-contain {
  overscroll-behavior: contain;
}

/* ป้องกันการเลือกข้อความบนปุ่มหรือ Navigation Bar */
.no-select {
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}

/* เอฟเฟกต์การแตะปุ่มดุจ Native App (Haptic Touch Press) */
.touch-press:active {
  transform: scale(0.97);
  transition: transform 0.12s cubic-bezier(0.4, 0, 0.2, 1);
}

.touch-press-subtle:active {
  transform: scale(0.985);
  transition: transform 0.1s ease;
}

/* ==========================================================================
   2. Safe Area Insets (รองรับ Dynamic Island, Notch, และ Home Indicator Bar)
   ========================================================================== */

.pt-safe {
  padding-top: env(safe-area-inset-top, 0px);
}

.pb-safe {
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

.mb-safe {
  margin-bottom: env(safe-area-inset-bottom, 0px);
}

.bottom-safe {
  bottom: env(safe-area-inset-bottom, 0px);
}

/* ==========================================================================
   3. Table-Card Architecture (มุมมองตารางการ์ดสำหรับหน้าจอมือถือ)
   ========================================================================== */

/* เมื่อเปิดโหมด Table-Card (โหมดเริ่มต้นบนมือถือ) */
#stationGrid.mode-table-card {
  grid-template-columns: repeat(1, minmax(0, 1fr)) !important;
  gap: 0.75rem !important;
}

@media (min-width: 768px) {
  #stationGrid.mode-table-card {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 1rem !important;
  }
}

@media (min-width: 1280px) {
  #stationGrid.mode-table-card {
    grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
    gap: 1.25rem !important;
  }
}

/* ความกะทัดรัดของการ์ดในโหมด Table-Card (ความสูงเหลือเพียง ~115px) */
#stationGrid.mode-table-card .station-card {
  padding: 0.75rem 0.875rem !important;
  min-height: auto !important;
}

#stationGrid.mode-table-card .station-card-header {
  margin-bottom: 0.35rem !important;
}

#stationGrid.mode-table-card .station-avatar {
  height: 1.75rem !important;
  width: 1.75rem !important;
}

#stationGrid.mode-table-card .station-card-title {
  font-size: 0.8125rem !important;
  min-height: auto !important;
  line-height: 1.25 !important;
  white-space: nowrap !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
  display: block !important;
}

#stationGrid.mode-table-card .station-badge-row {
  margin-top: 0.125rem !important;
  margin-bottom: 0.25rem !important;
  font-size: 0.6875rem !important;
}

#stationGrid.mode-table-card .station-badge-row span {
  padding: 0.0625rem 0.25rem !important;
  font-size: 0.65rem !important;
}

#stationGrid.mode-table-card .station-temp-grid {
  margin-top: 0.25rem !important;
  margin-bottom: 0.25rem !important;
  gap: 0.5rem !important;
}

#stationGrid.mode-table-card .station-chiller-box,
#stationGrid.mode-table-card .station-freezer-box {
  padding: 0.35rem 0.5rem !important;
}

#stationGrid.mode-table-card .station-chiller-box > div:first-child,
#stationGrid.mode-table-card .station-freezer-box > div:first-child {
  font-size: 0.65rem !important;
  margin-bottom: 0.125rem !important;
}

#stationGrid.mode-table-card .station-chiller-val,
#stationGrid.mode-table-card .station-freezer-val {
  font-size: 1.25rem !important;
  margin-top: 0 !important;
  margin-bottom: 0 !important;
  line-height: 1.2 !important;
}

#stationGrid.mode-table-card .station-chiller-status,
#stationGrid.mode-table-card .station-freezer-status {
  height: 1.125rem !important;
  margin-top: 0.125rem !important;
}

#stationGrid.mode-table-card .station-chiller-status span,
#stationGrid.mode-table-card .station-freezer-status span {
  font-size: 0.625rem !important;
  padding: 0.05rem 0.35rem !important;
}

#stationGrid.mode-table-card .station-card-footer {
  padding-top: 0.35rem !important;
  margin-top: 0.25rem !important;
}

/* ==========================================================================
   4. Native Bottom Sheet Components
   ========================================================================== */

.bottom-sheet-handle {
  width: 3rem;
  height: 0.375rem;
  background-color: #e4e4e7;
  border-radius: 9999px;
  margin-left: auto;
  margin-right: auto;
  margin-bottom: 1rem;
}

/* ==========================================================================
   5. Print Styles
   ========================================================================== */

@media print {
  .no-print {
    display: none !important;
  }
  body {
    print-color-adjust: exact;
    -webkit-print-color-adjust: exact;
  }
}

