:root {
  --primary-light: #ECF6F8;
  --primary-color: #8DC7D7;
  --primary-dark: #2ea4c5;
  --primary-hover: #C9E5EC;
  --primary-gray: #ECF6F8;
  --primary-gradient: linear-gradient(135deg, #ECF6F8 0%, #C9E5EC 40%, #7dc3d7 70%, #1582a1 100%);
  --primary-bg-5: rgba(141, 199, 215, 0.05);
  --primary-bg-10: rgba(141, 199, 215, 0.10);
  --primary-bg-15: rgba(141, 199, 215, 0.15);
  --primary-bg-20: rgba(141, 199, 215, 0.20);
  --primary-bg-30: rgba(141, 199, 215, 0.30);
  --aiijiro: #ECF6F8;
  --blizzard-blue: #C9E5EC;
  --morning-glory: #8DC7D7;
  --iceberg-blue: #60B1C7;
  --text-primary: #FFFFFF;
  --text-secondary: #F4FAFB;
  --text-muted: rgba(255, 255, 255, 0.75);
  --text-dark: #032b37;
  --secondary-color: #2c3e50;
  --success-color: #27ae60;
  --danger-color: #e74c3c;
  --border-radius: 12px;
}

body {
  font-family: "Inter", system-ui, -apple-system, sans-serif;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ─── Gradient Card (Room Status) ─────────────────────── */
.gradient-card {
  background: var(--primary-gradient);
}

/* ─── Buttons ──────────────────────────────────────────── */
.btn-primary {
  background: var(--primary-color);
  color: white;
  font-weight: 600;
  transition: background 0.15s ease, transform 0.1s ease;
}

.btn-primary:hover {
  background: var(--primary-dark);
}

.btn-primary:active {
  transform: scale(0.98);
}

.btn-refresh {
  background: linear-gradient(135deg, var(--iceberg-blue), var(--primary-dark));
  transition: opacity 0.15s ease;
}

.btn-refresh:hover {
  opacity: 0.9;
}

/* ─── Form Controls ────────────────────────────────────── */
.form-input {
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
  outline: none;
}

.form-input:focus {
  border-color: var(--primary-color) !important;
  box-shadow: 0 0 0 3px var(--primary-bg-20);
}

.brand-chip {
  background: var(--primary-light);
  color: var(--text-dark);
}

.theme-icon {
  background: var(--primary-dark);
}

.focus-primary:focus {
  border-color: var(--primary-dark) !important;
  box-shadow: 0 0 0 3px var(--primary-bg-20) !important;
}

select.form-input {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
  cursor: pointer;
}

/* ─── Step Items ───────────────────────────────────────── */
.step {
  transition: background-color 0.15s ease;
}

/* ─── Loader ───────────────────────────────────────────── */
.loader {
  border-top-color: var(--primary-color);
  animation: spin 0.8s linear infinite;
}

/* ─── Animations ───────────────────────────────────────── */
@keyframes spin {
  to { transform: rotate(360deg); }
}

@keyframes pulse-light {
  0%, 100% { box-shadow: 0 0 0 0 var(--primary-bg-30); }
  50% { box-shadow: 0 0 0 6px var(--primary-bg-5); }
}

@keyframes fadeOut {
  to { opacity: 0; transform: translateY(-8px); }
}

@keyframes dot-bounce {
  0%, 80%, 100% { transform: scale(0); opacity: 0.4; }
  40% { transform: scale(1); opacity: 1; }
}

.fade-out {
  animation: fadeOut 0.4s ease forwards;
}

.loading-spinner {
  animation: spin 0.8s linear infinite;
}

.loading-dots {
  display: inline-flex;
  align-items: center;
  gap: 3px;
}

.loading-dots div {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: currentColor;
  animation: dot-bounce 1.2s ease-in-out infinite both;
}

.loading-dots div:nth-child(1) { animation-delay: -0.32s; }
.loading-dots div:nth-child(2) { animation-delay: -0.16s; }

/* ─── Screen Reader ────────────────────────────────────── */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}

/* ─── Skeleton ─────────────────────────────────────────── */
.skeleton-loading {
  position: relative;
  overflow: hidden;
  background: #f3f4f6;
  border-radius: var(--border-radius);
}

.skeleton-loading::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent 0%, rgba(255,255,255,0.7) 50%, transparent 100%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite;
}

@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ─── Pulse (Room status icon) ─────────────────────────── */
.pulse-slow {
  animation: pulseSlow 2.5s ease-in-out infinite;
}

@keyframes pulseSlow {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.65; }
}

/* ─── Walking Animation ────────────────────────────────── */
.walk-scene {
  position: relative;
  height: 42px;
  overflow: hidden;
  margin: 8px 0;
  border-radius: 8px;
  background: rgba(255,255,255,0.08);
}

/* Ground line */
.walk-scene::after {
  content: "";
  position: absolute;
  bottom: 5px;
  left: 0;
  right: 0;
  height: 1px;
  background: rgba(255,255,255,0.2);
}

.walk-figure {
  position: absolute;
  bottom: 6px;
  left: 0;
}

.walk-door {
  position: absolute;
  right: 10px;
  bottom: 6px;
  opacity: 0.6;
}

/* Slide across the scene */
.walk-normal {
  animation: walkSlide 2.8s linear infinite;
}

.walk-fast {
  animation: walkSlide 1.6s linear infinite;
}

@keyframes walkSlide {
  0%   { transform: translateX(-30px); }
  100% { transform: translateX(400px); }
}

/* Leg swing (hip origin set inline on <g>) */
.leg-l { animation: legSwing 0.42s ease-in-out infinite; }
.leg-r { animation: legSwingAlt 0.42s ease-in-out infinite; }
.arm-l { animation: legSwingAlt 0.42s ease-in-out infinite; }
.arm-r { animation: legSwing 0.42s ease-in-out infinite; }

/* Fast mode: quicker limb swing */
.walk-fast .leg-l,
.walk-fast .leg-r,
.walk-fast .arm-l,
.walk-fast .arm-r {
  animation-duration: 0.26s;
}

@keyframes legSwing {
  0%, 100% { transform: rotate(22deg); }
  50%       { transform: rotate(-22deg); }
}

@keyframes legSwingAlt {
  0%, 100% { transform: rotate(-22deg); }
  50%       { transform: rotate(22deg); }
}

/* ─── Ping (Used in JS-generated called status) ────────── */
@keyframes ping {
  75%, 100% {
    transform: scale(2);
    opacity: 0;
  }
}

.animate-ping {
  animation: ping 1s cubic-bezier(0, 0, 0.2, 1) infinite;
}

.animate-spin {
  animation: spin 0.7s linear infinite;
}

/* ─── Safe Area (iPhone notch/home bar) ───────────────── */
.safe-area-inset {
  padding-left: max(12px, env(safe-area-inset-left));
  padding-right: max(12px, env(safe-area-inset-right));
  padding-bottom: max(16px, env(safe-area-inset-bottom));
}

/* ─── Touch Target ─────────────────────────────────────── */
.touch-target {
  min-height: 44px;
}

/* ─── SweetAlert2 Mobile Toast ─────────────────────────── */
.swal-mobile-toast {
  font-size: 13px !important;
  padding: 8px 12px !important;
  min-width: 0 !important;
  width: auto !important;
  max-width: calc(100vw - 24px) !important;
  margin: 8px auto 0 !important;
}

.swal-mobile-toast .swal2-title {
  font-size: 13px !important;
  padding: 0 !important;
  margin: 0 !important;
}

.swal-mobile-toast .swal2-icon {
  width: 20px !important;
  height: 20px !important;
  margin: 0 8px 0 0 !important;
  font-size: 10px !important;
  border-width: 2px !important;
}

.swal-mobile-toast .swal2-icon .swal2-icon-content {
  font-size: 12px !important;
}

.swal-mobile-toast .swal2-timer-progress-bar-container {
  height: 2px !important;
}

/* ─── Mobile Input Zoom Prevention ────────────────────── */
@media (max-width: 640px) {
  input, select, textarea {
    font-size: 16px !important; /* prevents iOS auto-zoom */
  }

  input.font-mono {
    font-size: 16px !important;
  }
}

/* ─── Dark Mode ────────────────────────────────────────── */
@media (prefers-color-scheme: dark) {
  body {
    background: #0f172a;
    color: #e2e8f0;
  }

  .bg-white {
    background: #1e293b !important;
  }

  .bg-gray-50 {
    background: #0f172a !important;
  }

  .border-gray-200 {
    border-color: rgba(255, 255, 255, 0.08) !important;
  }

  .form-input {
    background: #1e293b;
    border-color: rgba(255, 255, 255, 0.1);
    color: #e2e8f0;
  }

  select.form-input {
    background-color: #1e293b;
    color: #e2e8f0;
  }

  .text-gray-900 { color: #f1f5f9 !important; }
  .text-gray-700 { color: #cbd5e1 !important; }
  .text-gray-600 { color: #94a3b8 !important; }
  .text-gray-500 { color: #64748b !important; }
  .text-gray-400 { color: #475569 !important; }

  .divide-gray-100 > * + * { border-color: rgba(255,255,255,0.06) !important; }
  .divide-y { border-color: rgba(255,255,255,0.06) !important; }

  .bg-gray-50.rounded-lg { background: #0f172a !important; }
  .bg-green-50 { background: rgba(39,174,96,0.1) !important; }
  .bg-gray-100 { background: rgba(255,255,255,0.06) !important; }
  .text-gray-800 { color: #e2e8f0 !important; }

  .skeleton-loading { background: #1e293b; }
}
