/* smarthome.css — 스마트홈 다크테마 PWA */

/* ── 리셋 & 기본 ── */
* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; overflow: hidden; }
body {
  font-family: 'Malgun Gothic', -apple-system, 'Segoe UI', sans-serif;
  font-size: 15px; line-height: 1.5;
  color: #e0e0e0; background: #1a1a2e;
  padding-top: env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
}
#app {
  display: flex; flex-direction: column;
  height: 100vh; overflow: hidden;
}

/* ── 스크린리더 전용 ── */
.sr-only {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}

/* ── 헤더 바 ── */
.header-bar {
  display: flex; align-items: center;
  padding: 10px 14px; gap: 10px;
  background: #0f3460;
  border-bottom: 2px solid #16213e;
  flex-shrink: 0;
}
.header-bar .title {
  flex: 1; font-size: 17px; font-weight: 700; color: #fff;
}
.header-bar button {
  min-width: 44px; min-height: 44px;
  background: transparent; border: none;
  color: #ccc; font-size: 20px;
  cursor: pointer; border-radius: 8px;
}
.header-bar button:hover { background: rgba(255,255,255,.1); }

/* ── 영역 탭 ── */
.area-tabs {
  display: flex; gap: 0;
  overflow-x: auto; flex-shrink: 0;
  background: #0f3460;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.area-tabs::-webkit-scrollbar { display: none; }
.area-tab {
  flex-shrink: 0; padding: 10px 16px;
  font-size: 14px; font-weight: 600;
  color: #8899aa; border: none; background: transparent;
  white-space: nowrap; cursor: pointer;
  min-height: 44px;
}
.area-tab:hover { color: #ccc; }
.area-tab.active {
  color: #fff; background: #16213e;
  border-bottom: 2px solid #5dade2;
}

/* ── 요약바 ── */
.summary-bar {
  display: flex; align-items: center;
  padding: 8px 16px; gap: 8px;
  font-size: 13px; color: #999;
  background: #1a1a2e; flex-shrink: 0;
}
.summary-bar .count { font-weight: 600; color: #ccc; }

/* ── 콘텐츠 영역 ── */
.content-area {
  flex: 1; overflow-y: auto;
  padding: 8px 14px 60px;
  -webkit-overflow-scrolling: touch;
}

/* ── 영역 헤더 ── */
.area-header {
  font-size: 14px; font-weight: 700;
  color: #c4b8f0;
  padding: 10px 14px 6px;
  margin-top: 6px;
  background: linear-gradient(135deg, rgba(15,52,96,.7), rgba(83,52,131,.35));
  border-left: 3px solid #7b68ee;
  border-radius: 6px 6px 0 0;
  position: sticky; top: 0; z-index: 2;
}

/* ── 엔티티 카드 ── */
.entity-card-wrap {
  margin-bottom: 8px;
  background: #16213e;
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(0,0,0,.3);
  overflow: hidden;
}
.entity-card {
  padding: 14px 16px;
  display: flex; flex-direction: column; gap: 8px;
}
.entity-main {
  display: flex; align-items: center; gap: 12px;
}
.entity-icon {
  font-size: 22px; width: 36px; text-align: center; flex-shrink: 0;
}
.entity-info { flex: 1; min-width: 0; }
.entity-name {
  font-size: 15px; font-weight: 600; color: #e8e8e8;
  word-break: break-word;
}
.entity-state { font-size: 13px; color: #999; margin-top: 2px; }
.entity-state.on { color: #5dade2; }

/* ── 카드 버튼 (토글 가능 엔티티) ── */
.entity-card-btn {
  width: 100%; text-align: left;
  cursor: pointer; border: none;
  color: inherit; font: inherit;
}
.entity-card-btn:active { background: #1e2a4e; }

/* ── 토글 배지 ── */
.toggle-badge {
  font-size: 12px; font-weight: 600;
  padding: 4px 12px; border-radius: 16px;
  flex-shrink: 0;
}
.toggle-badge.on { background: #5dade2; color: #fff; }
.toggle-badge.off { background: #2a2a4e; color: #999; }

/* ── 슬라이더 ── */
.slider-row {
  display: flex; align-items: center; gap: 10px; padding: 4px 16px 8px;
}
.slider-row .label {
  font-size: 12px; color: #999; width: 40px; flex-shrink: 0;
}
.slider-row .value {
  font-size: 13px; font-weight: 600; color: #ccc;
  width: 44px; text-align: right; flex-shrink: 0;
}
input[type="range"] {
  flex: 1; -webkit-appearance: none; appearance: none;
  height: 6px; background: #2a2a4e; border-radius: 3px;
  outline: none; min-height: 44px;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 28px; height: 28px;
  background: #5dade2; border-radius: 50%; cursor: pointer;
}
input[type="range"]::-moz-range-thumb {
  width: 28px; height: 28px;
  background: #5dade2; border-radius: 50%;
  cursor: pointer; border: none;
}

/* ── 온도 조절 ── */
.temp-control {
  display: flex; align-items: center; gap: 8px; padding: 4px 16px 8px;
}
.temp-btn {
  min-width: 44px; min-height: 44px;
  border-radius: 50%; border: none;
  background: #2a2a4e; color: #ccc;
  font-size: 20px; font-weight: 700; cursor: pointer;
}
.temp-btn:hover { background: #3a3a5e; }
.temp-display {
  font-size: 18px; font-weight: 700;
  color: #e8e8e8; min-width: 60px; text-align: center;
}

/* ── 셀렉트 ── */
.entity-select {
  width: calc(100% - 32px); margin: 0 16px 8px; padding: 8px 12px;
  background: #1a1a3e; border: 1px solid #2a2a4e;
  border-radius: 8px; color: #e0e0e0;
  font-size: 14px; min-height: 44px;
}

/* ── 숫자 조절 ── */
.num-control { display: flex; align-items: center; gap: 8px; padding: 4px 16px 8px; }
.num-btn {
  min-width: 44px; min-height: 44px;
  border-radius: 8px; border: none;
  background: #2a2a4e; color: #ccc;
  font-size: 18px; font-weight: 700; cursor: pointer;
}
.num-btn:hover { background: #3a3a5e; }
.num-display {
  font-size: 16px; font-weight: 600;
  color: #e8e8e8; min-width: 60px; text-align: center;
}

/* ── 상태바 ── */
.status-bar {
  padding: 6px 14px; font-size: 11px;
  color: #667; background: #0f3460;
  border-top: 1px solid #16213e;
  flex-shrink: 0;
}

/* ── 설정 오버레이 ── */
.settings-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.85);
  display: flex; align-items: center; justify-content: center;
  z-index: 100; padding: 20px;
}
.settings-form {
  background: #16213e;
  border-radius: 16px;
  padding: 28px 24px;
  width: 100%; max-width: 420px;
}
.settings-form h2 {
  font-size: 20px; font-weight: 700;
  color: #fff; margin-bottom: 20px;
}
.settings-form label {
  display: block; margin-top: 16px;
  color: #ccc; font-size: 14px; font-weight: 600;
}
.settings-form input[type="text"],
.settings-form input[type="password"] {
  width: 100%; padding: 12px 14px; margin-top: 6px;
  background: #1a1a3e; border: 1px solid #2a2a4e;
  border-radius: 10px; color: #e0e0e0; font-size: 15px;
}
.settings-form input:focus { border-color: #5dade2; outline: none; }
.settings-form .hint {
  font-size: 12px; color: #888; margin-top: 4px; line-height: 1.4;
}
.settings-form .btn-row {
  display: flex; gap: 10px; margin-top: 24px;
}
.settings-form .btn-primary {
  flex: 1; padding: 12px;
  background: #5dade2; color: #fff;
  border: none; border-radius: 10px;
  font-size: 15px; font-weight: 600;
  cursor: pointer; min-height: 48px;
}
.settings-form .btn-primary:hover { background: #4a9cd4; }
.settings-form .btn-secondary {
  padding: 12px 20px;
  background: #2a2a4e; color: #ccc;
  border: none; border-radius: 10px;
  font-size: 15px; cursor: pointer; min-height: 48px;
}

/* ── 로딩 ── */
.loading {
  text-align: center; padding: 60px 20px;
  color: #999; font-size: 16px;
}
.loading .spinner {
  display: inline-block; width: 36px; height: 36px;
  border: 3px solid #2a2a4e; border-top-color: #5dade2;
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin-bottom: 12px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── 에러/빈상태 ── */
.error-msg {
  padding: 20px; text-align: center;
  color: #e74c3c; font-size: 15px;
}
.empty-msg {
  padding: 40px 20px; text-align: center;
  color: #888; font-size: 15px;
}

/* ── 포커스 ── */
:focus-visible {
  outline: 2px solid #5dade2;
  outline-offset: 2px;
}

.hidden { display: none !important; }
