/* ===== CSS Variables — Light Mode ===== */
:root {
  --bg-base:      #f1f5f9;
  --bg-card:      #ffffff;
  --bg-secondary: #f8fafc;
  --bg-input:     #f1f5f9;
  --border:       #e2e8f0;
  --text-primary:   #0f172a;
  --text-secondary: #64748b;
  --shadow-sm: 0 1px 2px rgba(0,0,0,.05);
  --shadow:    0 1px 3px rgba(0,0,0,.1), 0 1px 2px rgba(0,0,0,.06);
}

/* ===== CSS Variables — Dark Mode ===== */
.dark {
  --bg-base:      #0f172a;
  --bg-card:      #1e293b;
  --bg-secondary: #1e293b;
  --bg-input:     #334155;
  --border:       #334155;
  --text-primary:   #f1f5f9;
  --text-secondary: #94a3b8;
  --shadow-sm: 0 1px 2px rgba(0,0,0,.3);
  --shadow:    0 1px 3px rgba(0,0,0,.4), 0 1px 2px rgba(0,0,0,.2);
}

/* ===== Base ===== */
*, *::before, *::after { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  background-color: var(--bg-base);
  color: var(--text-primary);
  transition: background-color .2s, color .2s;
}

/* ===== Typography ===== */
body, button, input, select, textarea {
  font-family: 'Sarabun', 'Noto Sans Thai', -apple-system, BlinkMacSystemFont, sans-serif;
}

/* ===== Scrollbar ===== */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

.scrollbar-hide::-webkit-scrollbar { display: none; }
.scrollbar-hide { -ms-overflow-style: none; scrollbar-width: none; }

/* ===== Focus Ring ===== */
:focus-visible { outline: 2px solid #6366f1; outline-offset: 2px; }

/* ===== Transitions ===== */
.transition-colors { transition-property: color, background-color, border-color; transition-duration: .15s; }
.transition-all { transition-property: all; transition-duration: .15s; }

/* ===== Active scale ===== */
.active\:scale-98:active { transform: scale(.98); }
.active\:scale-95:active { transform: scale(.95); }

/* ===== Alpine.js cloak ===== */
[x-cloak] { display: none !important; }

/* ===== Step Form Indicator ===== */
.step-indicator {
  display: flex;
  align-items: center;
  gap: 0;
}
.step-dot {
  width: 28px; height: 28px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700;
  flex-shrink: 0;
  transition: all .3s;
}
.step-dot.active   { background: #4f46e5; color: #fff; box-shadow: 0 0 0 3px #c7d2fe; }
.step-dot.done     { background: #10b981; color: #fff; }
.step-dot.inactive { background: var(--bg-input); color: var(--text-secondary); }
.step-line {
  flex: 1; height: 2px; background: var(--border);
  transition: background .3s;
}
.step-line.done { background: #10b981; }

/* ===== Status Badge Sizes ===== */
.status-badge-xs { font-size: 10px; padding: 2px 6px; }
.status-badge-sm { font-size: 11px; padding: 3px 8px; }
.status-badge-md { font-size: 13px; padding: 4px 12px; }

/* ===== Timeline ===== */
.timeline-item { position: relative; padding-left: 36px; }
.timeline-item::before {
  content: '';
  position: absolute;
  left: 14px; top: 24px; bottom: 0;
  width: 2px;
  background: var(--border);
}
.timeline-item:last-child::before { display: none; }
.timeline-dot {
  position: absolute;
  left: 0; top: 4px;
  width: 28px; height: 28px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px;
}

/* ===== Room Cell (Building Monitor) — สีพื้นหลัง/ขอบตั้งจาก JS ตามจำนวนงานค้าง ===== */
.room-cell {
  transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

/* ===== Safe area for bottom nav (mobile) ===== */
.pb-safe { padding-bottom: env(safe-area-inset-bottom, 0); }

/* ===== Card hover ===== */
.card-hover:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0,0,0,.08);
}

/* ===== Image Upload Preview ===== */
.upload-preview-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}
.upload-preview-item {
  position: relative;
  aspect-ratio: 1;
  border-radius: 8px;
  overflow: hidden;
}
.upload-preview-item img { width: 100%; height: 100%; object-fit: cover; }
.upload-preview-remove {
  position: absolute;
  top: 4px; right: 4px;
  width: 20px; height: 20px;
  background: rgba(0,0,0,.6);
  color: #fff;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; font-size: 12px;
}

/* ===== Chart container ===== */
.chart-container { position: relative; }

/* ===== Notification Bell Badge ===== */
@keyframes bell-shake {
  0%, 100% { transform: rotate(0deg); }
  20% { transform: rotate(-15deg); }
  40% { transform: rotate(15deg); }
  60% { transform: rotate(-10deg); }
  80% { transform: rotate(10deg); }
}
.bell-animate { animation: bell-shake .5s ease-in-out; }

/* ===== Pulse dot ===== */
@keyframes pulse-dot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: .5; transform: scale(.8); }
}
.animate-pulse-dot { animation: pulse-dot 2s infinite; }

/* ===== Print styles ===== */
@media print {
  .no-print { display: none !important; }
  body { background: white; }
  .bg-\[var\(--bg-card\)\] { background: white !important; }
  .border { border-color: #e5e7eb !important; }
}

/* ===== Responsive utilities ===== */
@media (max-width: 640px) {
  .hide-mobile { display: none !important; }
}
@media (min-width: 641px) {
  .show-mobile-only { display: none !important; }
}
