/* ==========================================================================
   TILE STOCK SYSTEM - CLEAN WHITE THEME & ADAPTIVE DESIGN
   Supports: Auto-detect Mobile (<768px), Tablet/iPad (768-1024px), Desktop (>1024px)
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700;800&family=Prompt:wght@300;400;500;600;700&display=swap');

:root {
  /* Default: Clean White Theme (สว่าง สะอาดตา คมชัดระดับพรีเมียม) */
  --bg-primary: #F8FAFC;
  --bg-secondary: #FFFFFF;
  --bg-card: #FFFFFF;
  --bg-card-hover: #F1F5F9;
  --border-color: #E2E8F0;
  --border-focus: #0D9488;

  --text-main: #0F172A;
  --text-muted: #64748B;
  --text-dim: #94A3B8;

  /* Accent Colors */
  --accent-teal: #0D9488;
  --accent-teal-light: #14B8A6;
  --accent-teal-bg: #F0FDFA;
  --accent-blue: #2563EB;
  --accent-blue-light: #3B82F6;
  --accent-emerald: #059669;
  --accent-amber: #D97706;
  --accent-purple: #7C3AED;
  --accent-rose: #E11D48;

  /* Status Colors */
  --status-new-bg: #EFF6FF;
  --status-new-text: #1D4ED8;
  --status-new-border: #BFDBFE;
  --status-used-bg: #F1F5F9;
  --status-used-text: #475569;
  --status-used-border: #CBD5E1;
  --status-reserved-bg: #FAF5FF;
  --status-reserved-text: #6D28D9;
  --status-reserved-border: #E9D5FF;
  --status-damaged-bg: #FFF1F2;
  --status-damaged-text: #BE123C;
  --status-damaged-border: #FECDD3;

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 16px rgba(15, 23, 42, 0.06);
  --shadow-lg: 0 10px 25px rgba(15, 23, 42, 0.08);
  --font-family: 'Plus Jakarta Sans', 'Prompt', -apple-system, sans-serif;
  --transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Dark Theme (ทางเลือกสำหรับผู้ชอบธีมมืด) */
[data-theme="dark"] {
  --bg-primary: #0F172A;
  --bg-secondary: #1E293B;
  --bg-card: rgba(30, 41, 59, 0.85);
  --bg-card-hover: rgba(51, 65, 85, 0.9);
  --border-color: rgba(255, 255, 255, 0.1);
  --border-focus: #2DD4BF;
  --text-main: #F8FAFC;
  --text-muted: #94A3B8;
  --text-dim: #64748B;
  --accent-teal-bg: rgba(13, 148, 136, 0.15);
  --status-new-bg: rgba(37, 99, 235, 0.2);
  --status-new-text: #93C5FD;
  --status-new-border: transparent;
  --status-used-bg: rgba(100, 116, 139, 0.25);
  --status-used-text: #CBD5E1;
  --status-used-border: transparent;
  --status-reserved-bg: rgba(139, 92, 246, 0.2);
  --status-reserved-text: #C4B5FD;
  --status-reserved-border: transparent;
  --status-damaged-bg: rgba(244, 63, 94, 0.2);
  --status-damaged-text: #FDA4AF;
  --status-damaged-border: transparent;
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.35);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: var(--font-family);
  background-color: var(--bg-primary);
  color: var(--text-main);
  line-height: 1.5;
  min-height: 100vh;
  overflow-x: hidden;
  transition: background-color 0.25s ease, color 0.25s ease;
}

/* Glassmorphism / Clean Card */
.glass {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
}

/* Header */
.app-header {
  position: sticky;
  top: 0;
  z-index: 100;
  padding: 12px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-color);
  background: var(--bg-secondary);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-icon {
  width: 42px;
  height: 42px;
  background: linear-gradient(135deg, var(--accent-teal), #0F766E);
  color: #FFFFFF;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  box-shadow: 0 4px 10px rgba(13, 148, 136, 0.25);
}

.brand-title {
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-main);
}

.brand-subtitle {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.device-indicator {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border-radius: 20px;
  font-size: 0.78rem;
  font-weight: 600;
  background: var(--accent-teal-bg);
  color: var(--accent-teal);
  border: 1px solid rgba(13, 148, 136, 0.2);
}

.ws-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--text-muted);
}

.ws-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent-emerald);
  box-shadow: 0 0 6px var(--accent-emerald);
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0% { transform: scale(0.95); opacity: 0.8; }
  50% { transform: scale(1.2); opacity: 1; }
  100% { transform: scale(0.95); opacity: 0.8; }
}

/* KPI Cards */
.kpi-container {
  padding: 20px 24px 8px 24px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 16px;
}

.kpi-card {
  padding: 18px 20px;
  border-radius: var(--radius-lg);
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
  transition: var(--transition);
}

.kpi-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: rgba(13, 148, 136, 0.3);
}

.kpi-label {
  font-size: 0.82rem;
  color: var(--text-muted);
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 8px;
}

.kpi-value {
  font-size: 1.65rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--text-main);
}

.kpi-unit {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-dim);
  margin-left: 4px;
}

/* Control Bar */
.controls-bar {
  padding: 12px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}

.search-box {
  position: relative;
  flex: 1;
  min-width: 280px;
}

.search-box input {
  width: 100%;
  padding: 10px 16px 10px 42px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  background: var(--bg-secondary);
  color: var(--text-main);
  font-family: inherit;
  font-size: 0.9rem;
  outline: none;
  box-shadow: var(--shadow-sm);
  transition: var(--transition);
}

.search-box input:focus {
  border-color: var(--accent-teal);
  box-shadow: 0 0 0 3px rgba(13, 148, 136, 0.15);
}

.search-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-dim);
}

.filters-group {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.filter-select {
  padding: 10px 14px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  background: var(--bg-secondary);
  color: var(--text-main);
  font-family: inherit;
  font-size: 0.88rem;
  outline: none;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: var(--radius-md);
  font-family: inherit;
  font-size: 0.88rem;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent-teal), #0F766E);
  color: #FFFFFF;
  box-shadow: 0 2px 6px rgba(13, 148, 136, 0.25);
}
.btn-primary:hover {
  background: linear-gradient(135deg, var(--accent-teal-light), var(--accent-teal));
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(13, 148, 136, 0.35);
}

.btn-secondary {
  background: var(--bg-secondary);
  color: var(--text-main);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
}
.btn-secondary:hover {
  background: var(--bg-card-hover);
  border-color: #CBD5E1;
}

.btn-sm {
  padding: 6px 12px;
  font-size: 0.82rem;
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 600;
  border: 1px solid transparent;
}
.badge-new { background: var(--status-new-bg); color: var(--status-new-text); border-color: var(--status-new-border); }
.badge-used { background: var(--status-used-bg); color: var(--status-used-text); border-color: var(--status-used-border); }
.badge-reserved { background: var(--status-reserved-bg); color: var(--status-reserved-text); border-color: var(--status-reserved-border); }
.badge-damaged { background: var(--status-damaged-bg); color: var(--status-damaged-text); border-color: var(--status-damaged-border); }

/* ==========================================================================
   VIEW 1: DESKTOP TABLE VIEW (> 1024px)
   ========================================================================== */
.view-desktop {
  padding: 12px 24px 40px 24px;
}

.data-table-container {
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-md);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.88rem;
}

.data-table th {
  background: #F1F5F9;
  padding: 14px 16px;
  font-weight: 700;
  color: #475569;
  border-bottom: 1px solid var(--border-color);
  white-space: nowrap;
}

.data-table th.sortable {
  cursor: pointer;
  user-select: none;
  transition: var(--transition);
}

.data-table th.sortable:hover {
  background: #E2E8F0;
  color: var(--accent-teal);
}

[data-theme="dark"] .data-table th.sortable:hover {
  background: #334155;
  color: var(--accent-teal-light);
}

.sort-icon {
  display: inline-block;
  margin-left: 6px;
  font-size: 0.75rem;
  color: var(--text-dim);
}

.data-table th.sort-active {
  color: var(--accent-teal) !important;
  background: #E6FFFA !important;
}

[data-theme="dark"] .data-table th.sort-active {
  color: var(--accent-teal-light) !important;
  background: rgba(13, 148, 136, 0.2) !important;
}

.data-table th.sort-active .sort-icon {
  color: var(--accent-teal) !important;
  font-weight: 800;
}

[data-theme="dark"] .data-table th {
  background: #1E293B;
  color: #94A3B8;
}

.data-table td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-color);
  color: var(--text-main);
  vertical-align: middle;
}

.data-table tr:hover td {
  background: var(--bg-card-hover);
}

.table-photo {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-sm);
  object-fit: cover;
  background: #E2E8F0;
  border: 1px solid var(--border-color);
}

/* ==========================================================================
   ROW COLOR CODING ตามสถานะการตรวจรับสินค้า
   - รับแล้วเป็น 0: สีเทา (Pending)
   - รับบางส่วน: สีเหลืองอ่อน (Partial)
   - รับครบแล้ว: สีเขียวอ่อน (Completed)
   ========================================================================== */
.data-table tr.row-status-pending td {
  background: #F8FAFC;
  color: var(--text-main);
}
.data-table tr.row-status-pending:hover td {
  background: #F1F5F9;
}

.data-table tr.row-status-partial td {
  background: #FEFCE8;
  color: #713F12;
}
.data-table tr.row-status-partial:hover td {
  background: #FEF9C3;
}
.data-table tr.row-status-partial td:first-child {
  border-left: 4px solid #EAB308;
}

.data-table tr.row-status-completed td {
  background: #F0FDF4;
  color: #14532D;
}
.data-table tr.row-status-completed:hover td {
  background: #DCFCE7;
}
.data-table tr.row-status-completed td:first-child {
  border-left: 4px solid #10B981;
}

/* Dark Mode Overrides for Status Rows */
[data-theme="dark"] .data-table tr.row-status-pending td {
  background: rgba(30, 41, 59, 0.7);
  color: var(--text-main);
}
[data-theme="dark"] .data-table tr.row-status-partial td {
  background: rgba(234, 179, 8, 0.12);
  color: #FEF08A;
}
[data-theme="dark"] .data-table tr.row-status-completed td {
  background: rgba(16, 185, 129, 0.12);
  color: #A7F3D0;
}

/* Progress Bar */
.progress-box {
  width: 100%;
  height: 7px;
  background: rgba(0, 0, 0, 0.08);
  border-radius: 4px;
  overflow: hidden;
  margin-top: 5px;
}
.progress-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.4s ease;
}
.progress-fill.partial {
  background: linear-gradient(90deg, #F59E0B, #EAB308);
}
.progress-fill.completed {
  background: linear-gradient(90deg, #10B981, #059669);
}

/* AI OCR Match Banner */
.ocr-banner {
  padding: 14px 18px;
  border-radius: var(--radius-md);
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 14px;
}
.ocr-banner.matched {
  background: #F0FDF4;
  border: 1px solid #86EFAC;
  color: #15803D;
}
.ocr-banner.mismatched {
  background: #FFF1F2;
  border: 1px solid #FECDD3;
  color: #BE123C;
}

/* ==========================================================================
   VIEW 2: IPAD / TABLET SPLIT VIEW (768px - 1024px)
   ========================================================================== */
.view-tablet {
  display: grid;
  grid-template-columns: 400px 1fr;
  gap: 18px;
  padding: 12px 20px;
  height: calc(100vh - 180px);
}

.tablet-list-pane {
  overflow-y: auto;
  padding-right: 8px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.tablet-detail-pane {
  border-radius: var(--radius-lg);
  padding: 24px;
  overflow-y: auto;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
}

.list-item-tile {
  padding: 14px;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  gap: 12px;
  align-items: center;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
}

.list-item-tile.active {
  border-color: var(--accent-teal);
  background: var(--accent-teal-bg);
}

/* ==========================================================================
   VIEW 3: MOBILE VIEW (< 768px)
   ========================================================================== */
.view-mobile {
  padding: 12px 16px 80px 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.mobile-tile-card {
  padding: 16px;
  border-radius: var(--radius-lg);
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
}

.card-top {
  display: flex;
  gap: 12px;
}

.card-thumb {
  width: 72px;
  height: 72px;
  border-radius: var(--radius-md);
  object-fit: cover;
  flex-shrink: 0;
  border: 1px solid var(--border-color);
  background: #E2E8F0;
}

.card-info {
  flex: 1;
}

.card-item-no {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-main);
}

.card-meta {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.card-stock-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-radius: var(--radius-md);
  background: #F1F5F9;
}

[data-theme="dark"] .card-stock-row {
  background: rgba(0, 0, 0, 0.25);
}

.stock-stepper {
  display: flex;
  align-items: center;
  gap: 8px;
}

.stepper-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid var(--border-color);
  background: var(--bg-secondary);
  color: var(--text-main);
  font-size: 1.15rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
}

.stepper-btn:active {
  transform: scale(0.92);
}

/* Mobile Bottom Navigation */
.mobile-bottom-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 10px 20px;
  border-top: 1px solid var(--border-color);
  background: var(--bg-secondary);
  justify-content: space-around;
  z-index: 1000;
  box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.05);
}

/* Flash Animation */
@keyframes flash-update {
  0% { background-color: rgba(13, 148, 136, 0.35); }
  100% { background-color: transparent; }
}

.item-flash {
  animation: flash-update 1.5s ease-out;
}

/* Modal */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(15, 23, 42, 0.5);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 2000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.modal-content {
  width: 100%;
  max-width: 650px;
  max-height: 90vh;
  border-radius: var(--radius-xl);
  overflow-y: auto;
  padding: 28px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-lg);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.modal-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-main);
}

.btn-close {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 1.6rem;
  cursor: pointer;
  line-height: 1;
}

/* Toast */
.toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 3000;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.toast {
  padding: 12px 18px;
  border-radius: var(--radius-md);
  background: var(--bg-secondary);
  border: 1px solid var(--accent-teal);
  color: var(--text-main);
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.88rem;
  font-weight: 500;
  animation: slideIn 0.3s ease;
}

@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* Explicit CSS Breakpoints for View Display */
body.mode-mobile .view-desktop,
body.mode-mobile .view-tablet {
  display: none !important;
}
body.mode-mobile .view-mobile {
  display: flex !important;
}
body.mode-mobile .mobile-bottom-nav {
  display: flex !important;
}

body.mode-tablet .view-desktop,
body.mode-tablet .view-mobile,
body.mode-tablet .mobile-bottom-nav {
  display: none !important;
}
body.mode-tablet .view-tablet {
  display: grid !important;
}

body.mode-desktop .view-mobile,
body.mode-desktop .view-tablet,
body.mode-desktop .mobile-bottom-nav {
  display: none !important;
}
body.mode-desktop .view-desktop {
  display: block !important;
}

/* User Auth & Management Styles */
.user-badge-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--accent-teal-bg);
  color: var(--accent-teal);
  padding: 5px 12px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--accent-teal);
  font-size: 0.82rem;
  font-weight: 600;
}

.copy-credential-banner {
  background: #ECFDF5;
  border: 1px solid #6EE7B7;
  border-radius: var(--radius-md);
  padding: 14px;
  margin-bottom: 16px;
  color: #065F46;
}

.role-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  font-size: 0.75rem;
  font-weight: 700;
}
.role-badge.admin {
  background: #FEE2E2;
  color: #991B1B;
}
.role-badge.staff {
  background: #E0E7FF;
  color: #3730A3;
}

/* Login Gatekeeper Screen */
.login-gate-screen {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: var(--bg-main);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 99999;
}

.login-card-box {
  width: 100%;
  max-width: 440px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 36px 30px;
  box-shadow: 0 20px 40px -15px rgba(0, 0, 0, 0.08);
  animation: fadeIn 0.3s ease;
}

/* ==========================================================================
   IMAGE LIGHTBOX / FULL-SIZE VIEWER MODAL
   ========================================================================== */
.image-lightbox-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(15, 23, 42, 0.92);
  backdrop-filter: blur(8px);
  z-index: 100000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.image-lightbox-overlay.active {
  display: flex !important;
  animation: fadeIn 0.2s ease;
}

.lightbox-container {
  max-width: 95vw;
  max-height: 95vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
}

.lightbox-header {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: #fff;
  padding-bottom: 12px;
}
.lightbox-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: #F8FAFC;
}

.lightbox-body {
  max-width: 100%;
  max-height: 80vh;
  display: flex;
  justify-content: center;
  align-items: center;
}
.lightbox-body img {
  max-width: 90vw;
  max-height: 78vh;
  border-radius: var(--radius-md);
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.7);
  object-fit: contain;
  background: #000;
  border: 1px solid rgba(255, 255, 255, 0.15);
}

/* Image Card in Receiving Modal (Carton Label) */
.rec-image-card {
  display: flex;
  gap: 16px;
  background: var(--bg-main);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 12px;
  align-items: center;
  margin-top: 10px;
}
.rec-preview-thumb {
  width: 90px;
  height: 90px;
  border-radius: var(--radius-sm);
  object-fit: cover;
  cursor: pointer;
  border: 2px solid var(--border-color);
  transition: transform 0.2s ease, border-color 0.2s ease;
}
.rec-preview-thumb:hover {
  transform: scale(1.05);
  border-color: var(--accent-teal);
}

/* Product Reference Card in Receiving Modal (รูปตัวอย่างสินค้าจริงเพื่อเทียบหน้างาน) */
.rec-product-reference-card {
  display: flex;
  gap: 16px;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 14px 16px;
  margin-bottom: 18px;
  align-items: center;
  box-shadow: var(--shadow-sm);
}
.rec-product-img-box {
  position: relative;
  width: 100px;
  height: 100px;
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 2px solid var(--border-color);
  background: var(--bg-secondary);
  flex-shrink: 0;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(0,0,0,0.06);
  transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}
.rec-product-img-box:hover {
  transform: scale(1.04);
  border-color: var(--accent-teal);
  box-shadow: 0 4px 12px rgba(13, 148, 136, 0.2);
}
.rec-product-img-box img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.rec-product-zoom-hint {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(15, 23, 42, 0.78);
  backdrop-filter: blur(4px);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 600;
  text-align: center;
  padding: 3px 0;
  transition: background 0.2s ease;
}
.rec-product-img-box:hover .rec-product-zoom-hint {
  background: rgba(13, 148, 136, 0.95);
}
.rec-product-meta {
  flex: 1;
  min-width: 0;
}
.rec-product-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--accent-teal);
  background: var(--accent-teal-bg);
  border: 1px solid rgba(13, 148, 136, 0.25);
  padding: 3px 9px;
  border-radius: 9999px;
  margin-bottom: 4px;
}

/* Photo Gallery Grid & Cards (คลังรูปภาพและการจัดการรูปหน้าปก) */
.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(175px, 1fr));
  gap: 14px;
  max-height: 460px;
  overflow-y: auto;
  padding: 4px;
}
.gallery-card {
  position: relative;
  background: var(--bg-main);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-sm);
  transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}
.gallery-card:hover {
  transform: translateY(-2px);
  border-color: var(--accent-teal);
  box-shadow: var(--shadow-md);
}
.gallery-card.is-cover {
  border: 2px solid var(--accent-teal);
  box-shadow: 0 0 0 1px var(--accent-teal);
}
.gallery-thumb-wrap {
  position: relative;
  width: 100%;
  height: 135px;
  background: var(--bg-secondary);
  cursor: pointer;
  overflow: hidden;
}
.gallery-thumb-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.2s ease;
}
.gallery-thumb-wrap:hover img {
  transform: scale(1.05);
}
.gallery-cover-badge {
  position: absolute;
  top: 6px;
  left: 6px;
  background: #0D9488;
  color: #fff;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 9999px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.3);
  display: flex;
  align-items: center;
  gap: 4px;
}
.gallery-actions {
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: var(--bg-primary);
  border-top: 1px solid var(--border-color);
}
.gallery-actions .btn {
  width: 100%;
  justify-content: center;
  padding: 5px 8px;
  font-size: 0.78rem;
}





