/* ========== DEVICE CARD ONLY ========== */

.device-grid {
  overflow-y: auto;
  padding: 0 16px 16px 0 !important;
  margin-top: 0 !important;
}

.device-row {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  margin-bottom: 18px;
}

.device-row-label {
  font-size: 15px;
  font-weight: 700;
  color: #374151;
  padding-left: 4px;
}

.device-row-scroll {
  display: flex;
  gap: 16px;
  overflow-x: auto;
  padding-bottom: 10px;
  margin-left: 0 !important;
  padding-left: 0 !important;
}

.device-row-scroll .device-card {
  flex: 0 0 var(--device-card-width, 255px);
  max-width: var(--device-card-width, 255px);
}

.device-row-scroll::-webkit-scrollbar { height: 6px; }
.device-row-scroll::-webkit-scrollbar-track { background: rgba(15, 23, 42, 0.04); }
.device-row-scroll::-webkit-scrollbar-thumb { background: rgba(15, 23, 42, 0.35); border-radius: 3px; }


/* ========================================================= */
/*                      DEVICE CARD UI                       */
/* ========================================================= */

.device-card {
  background: #ffffff;
  border-radius: 14px;
  padding: 16px 16px 21px;
  box-shadow: 0 2px 6px rgba(15, 23, 42, 0.08);
  display: flex;
  flex-direction: column;
  gap: 10px;
  position: relative;
  overflow: hidden;
  flex: 0 0 255px;
}

/* ── 카드 헤더 ── */
.device-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  position: relative;
  z-index: 20;
}

.device-name {
  font-size: 15px;
  font-weight: 600;
  color: #111111;
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.device-header-right {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-shrink: 0;
}

/* 예약 뱃지 (● 개별/그룹 HH:MM) */
.device-reservation-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 13px;
  font-weight: 500;
  color: #1070dd;
  white-space: nowrap;
}

.device-reservation-badge .badge-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #1070dd;
  flex-shrink: 0;
  animation: blink 1.2s infinite alternate;
}

/* 수동예약 뱃지 (주황색) */
.device-reservation-badge.is-manual {
  color: #d97706;
}
.device-reservation-badge.is-manual .badge-dot {
  background: #d97706;
}

/* 기어 설정 버튼 */
.btn-device-reserve {
  width: 24px;
  height: 24px;
  border-radius: 6px;
  border: none;
  background: transparent;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  color: #555555;
  cursor: pointer;
  padding: 0;
  transition: color 0.15s ease, transform 0.15s ease;
  flex-shrink: 0;
}

.btn-device-reserve:hover:not(.is-disabled):not(:disabled) {
  color: #1070dd;
  transform: rotate(20deg) scale(1.1);
}

.btn-device-reserve.is-disabled,
.btn-device-reserve:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}


.btn-device-reserve i {
  pointer-events: none;
}

/* ── O2 수치 행 ── */
.device-o2-row {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 8px;
}

.device-o2-pct {
  font-size: 25px;
  font-weight: 700;
  color: #111111;
  line-height: 1;
}

.device-time-info {
  font-size: 12px;
  font-weight: 500;
  line-height: 1;
  padding-bottom: 3px;
  white-space: nowrap;
}

/* 시간 숫자는 기본 검정 */
.device-time-info .time-value { color: #111111; }

/* 라벨 색상: 정지=회색, 작동=파랑 */
.device-time-info.is-timer     .time-label { color: #99a1af; }
.device-time-info.is-remaining .time-label { color: #1070dd; }

/* 타이머 설정이 8시간 미만이면 시간 숫자를 빨강으로 경고 */
.device-time-info.is-short .time-value { color: #dc2626; }

/* ── 프로그레스 바 ── */
.progress-bar {
  position: relative;
  width: 100%;
  height: 6px;
  border-radius: 999px;
  background: #e5e7eb;
  overflow: hidden;
}

.progress-fill {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: #d1d5dc;
  transform-origin: left center;
  transform: scaleX(0);
  transition: transform 0.35s ease, background 0.35s ease;
}

.progress-fill.level-low  { background: #ed4545; }
.progress-fill.level-mid  { background: #ffc97b; }
.progress-fill.level-high { background: #1070dd; }
.progress-fill.level-off  { background: #d1d5dc; }

/* ── 제어 행 (산소 모드 / LED 조명) ── */
.device-control-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.device-control-label {
  font-size: 13px;
  font-weight: 500;
  color: #374151;
}

/* 토글 버튼 공통 */
.btn-toggle {
  font-size: 12px;
  font-weight: 700;
  padding: 5px 0;
  border-radius: 6px;
  border: none;
  cursor: pointer;
  width: 52px;
  text-align: center;
  letter-spacing: 0.04em;
  transition: filter 0.15s ease, opacity 0.15s ease;
  flex-shrink: 0;
}

.btn-toggle:hover:not(:disabled) {
  filter: brightness(1.08);
}

.btn-toggle:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

/* 산소 모드 버튼 */
.btn-toggle.is-on-o2  { background: #1070dd; color: #ffffff; }
.btn-toggle.is-off-o2 { background: #99a1af; color: #ffffff; }

/* LED 버튼 */
.btn-toggle.is-on-led  { background: #7bbfff; color: #ffffff; }
.btn-toggle.is-off-led { background: #99a1af; color: #ffffff; }

/* ── 오버레이 (pending / error) ── */
.device-control-overlay {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.52);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(2px);
  color: #ffffff;
  pointer-events: all;
  z-index: 10;
  text-align: center;
  border-radius: 14px;
  gap: 4px;
}

.device-control-overlay.error-overlay {
  background: rgba(80, 80, 80, 0.85);
  backdrop-filter: blur(1px);
}

.overlay-icon {
  font-size: 26px;
  color: #ff9292;
  margin-bottom: 2px;
}

.device-control-spinner {
  width: 26px;
  height: 26px;
  border-radius: 999px;
  border: 3px solid rgba(255, 255, 255, 0.35);
  border-top-color: #ffffff;
  animation: device-spin 0.8s linear infinite;
  margin-bottom: 6px;
}

.device-control-text {
  letter-spacing: 0.06em;
  font-weight: 600;
  font-size: 13px;
}

/* 이상감지(에러) 카드 — 'ERROR NN' 강조 + 모든 제어 차단 */
.device-control-text.device-error-text {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: 0.04em;
}
.device-card.is-error .btn-toggle,
.device-card.is-error .nc-ctrl,
.device-card.is-error .btn-device-led-toggle,
.device-card.is-error .btn-device-reserve {
  pointer-events: none;
}

/* 타이머 '적용 중' — 저장 후 장치 반영 대기 표시 */
.device-time-info.is-applying .time-value { opacity: 0.85; }
.time-applying {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-left: 6px;
  font-size: 11px;
  font-weight: 700;
  color: #2563eb;
}
.time-applying-dot {
  width: 9px;
  height: 9px;
  border-radius: 999px;
  border: 2px solid rgba(37, 99, 235, 0.3);
  border-top-color: #2563eb;
  animation: device-spin 0.7s linear infinite;
}

/* 대시보드 토스트 */
.dash-toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%) translateY(20px);
  background: #1e293b;
  color: #fff;
  padding: 12px 20px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  box-shadow: 0 12px 30px rgba(15, 23, 42, 0.28);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s, transform 0.25s;
  z-index: 4000;
  white-space: nowrap;
  max-width: 90vw;
}
.dash-toast.is-show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
.dash-toast--success { background: #16a34a; }
.dash-toast--info { background: #2563eb; }

@keyframes device-spin {
  to { transform: rotate(360deg); }
}

@keyframes blink {
  0%   { opacity: 0.5; }
  100% { opacity: 1; }
}
