/* =============================================
   정보통신설비 점검시스템 - 모바일 스타일
   대상: 40~60대 비IT 관리사무소 직원
   ============================================= */

:root {
  --primary: #1565C0;
  --primary-light: #1976D2;
  --primary-dark: #0D47A1;
  --success: #2E7D32;
  --danger: #C62828;
  --warning: #E65100;
  --gray: #757575;
  --gray-light: #F5F5F5;
  --gray-border: #E0E0E0;
  --white: #FFFFFF;
  --text: #212121;
  --text-sub: #616161;
  --radius: 10px;
  --shadow: 0 2px 8px rgba(0,0,0,0.12);
}

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

html, body {
  height: 100%;
  font-family: 'Malgun Gothic', '맑은 고딕', 'Apple SD Gothic Neo', sans-serif;
  font-size: 16px;
  color: var(--text);
  background: #EEEEEE;
  overflow-x: hidden;
}

/* ── 앱 컨테이너 ─────────────────── */
#app {
  max-width: 480px;
  margin: 0 auto;
  background: var(--white);
  min-height: 100vh;
  position: relative;
}

/* ── 상단바 ──────────────────────── */
.top-bar {
  background: var(--primary);
  color: var(--white);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 6px rgba(0,0,0,0.2);
}
.top-bar .back-btn {
  background: none;
  border: none;
  color: var(--white);
  font-size: 22px;
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
}
.top-bar h1 {
  font-size: 18px;
  font-weight: bold;
  flex: 1;
}
.top-bar .menu-btn {
  background: none;
  border: none;
  color: var(--white);
  font-size: 22px;
  cursor: pointer;
  padding: 0 4px;
}

/* ── 페이지 컨텐츠 ───────────────── */
.page {
  display: none;
  padding-bottom: 80px;
}
.page.active {
  display: block;
}

/* ── 로그인 화면 ─────────────────── */
#page-login.active {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 100vh;
  padding: 30px 24px;
  background: var(--primary);
}
#page-login .login-logo {
  text-align: center;
  color: var(--white);
  margin-bottom: 40px;
}
#page-login .login-logo .icon {
  font-size: 60px;
  display: block;
  margin-bottom: 12px;
}
#page-login .login-logo h2 {
  font-size: 22px;
  font-weight: bold;
  line-height: 1.4;
}
#page-login .login-logo p {
  font-size: 14px;
  opacity: 0.8;
  margin-top: 6px;
}
.login-form {
  background: var(--white);
  border-radius: 16px;
  padding: 28px 20px;
}
.code-sent-notice {
  text-align: center;
  padding: 16px;
  background: #E3F2FD;
  border-radius: var(--radius);
  margin-bottom: 4px;
}
.code-sent-notice p {
  font-size: 14px;
  color: var(--text-sub);
  line-height: 1.6;
  margin: 8px 0 6px;
}

/* ── 입력 폼 공통 ────────────────── */
.form-group {
  margin-bottom: 16px;
}
.form-group label {
  display: block;
  font-size: 15px;
  font-weight: bold;
  color: var(--text);
  margin-bottom: 6px;
}
.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 13px 14px;
  border: 2px solid var(--gray-border);
  border-radius: var(--radius);
  font-size: 16px;
  color: var(--text);
  background: var(--white);
  outline: none;
  transition: border-color 0.2s;
  appearance: none;
  -webkit-appearance: none;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  border-color: var(--primary);
}
.form-group textarea {
  min-height: 80px;
  resize: vertical;
  line-height: 1.5;
}
.form-group select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24'%3E%3Cpath fill='%23757575' d='M7 10l5 5 5-5z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}

/* ── 버튼 ────────────────────────── */
.btn {
  display: block;
  width: 100%;
  padding: 15px;
  border: none;
  border-radius: var(--radius);
  font-size: 17px;
  font-weight: bold;
  cursor: pointer;
  text-align: center;
  transition: opacity 0.15s, transform 0.1s;
  text-decoration: none;
  line-height: 1;
}
.btn:active { transform: scale(0.97); }
.btn-primary { background: var(--primary); color: var(--white); }
.btn-success { background: var(--success); color: var(--white); }
.btn-danger  { background: var(--danger);  color: var(--white); }
.btn-outline {
  background: var(--white);
  color: var(--primary);
  border: 2px solid var(--primary);
}
.btn-gray {
  background: var(--gray-light);
  color: var(--text);
  border: 1px solid var(--gray-border);
}
.btn-sm {
  padding: 9px 14px;
  font-size: 14px;
  width: auto;
  display: inline-block;
}
.btn-icon {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

/* ── 홈 화면 ─────────────────────── */
.home-header {
  background: var(--primary);
  color: var(--white);
  padding: 20px 16px 24px;
}
.home-header .greeting { font-size: 14px; opacity: 0.85; }
.home-header h2 { font-size: 22px; font-weight: bold; margin-top: 4px; }
.home-header .date-info { font-size: 13px; opacity: 0.75; margin-top: 8px; }

.home-stats {
  display: flex;
  gap: 12px;
  padding: 16px;
  margin-top: -10px;
}
.stat-card {
  flex: 1;
  background: var(--white);
  border-radius: var(--radius);
  padding: 14px 10px;
  text-align: center;
  box-shadow: var(--shadow);
}
.stat-card .num {
  font-size: 28px;
  font-weight: bold;
  color: var(--primary);
}
.stat-card .label {
  font-size: 12px;
  color: var(--text-sub);
  margin-top: 4px;
}

.home-actions {
  padding: 0 16px 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.action-card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 18px 16px;
  display: flex;
  align-items: center;
  gap: 16px;
  box-shadow: var(--shadow);
  cursor: pointer;
  border: 2px solid transparent;
  transition: border-color 0.2s;
  text-decoration: none;
  color: var(--text);
}
.action-card:active { border-color: var(--primary); }
.action-card .icon {
  font-size: 36px;
  width: 52px;
  text-align: center;
}
.action-card .info h3 { font-size: 17px; font-weight: bold; }
.action-card .info p  { font-size: 13px; color: var(--text-sub); margin-top: 3px; }
.action-card .arrow   { margin-left: auto; font-size: 20px; color: var(--gray); }

/* ── 목록 화면 ───────────────────── */
.list-header {
  padding: 14px 16px 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.list-header h2 { font-size: 17px; font-weight: bold; }

.insp-card {
  margin: 0 16px 12px;
  background: var(--white);
  border-radius: var(--radius);
  border: 1px solid var(--gray-border);
  padding: 14px 16px;
  cursor: pointer;
  transition: box-shadow 0.2s;
}
.insp-card:active { box-shadow: 0 0 0 2px var(--primary); }
.insp-card .card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}
.insp-card .site-name {
  font-size: 17px;
  font-weight: bold;
  flex: 1;
}
.badge {
  padding: 3px 9px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: bold;
  white-space: nowrap;
}
.badge-진행중 { background: #FFF3E0; color: var(--warning); }
.badge-완료   { background: #E8F5E9; color: var(--success); }
.insp-card .card-info {
  margin-top: 8px;
  font-size: 14px;
  color: var(--text-sub);
  line-height: 1.7;
}

/* ── 점검 시작 화면 ──────────────── */
.section-title {
  font-size: 15px;
  font-weight: bold;
  color: var(--primary);
  padding: 14px 16px 6px;
  border-bottom: 2px solid var(--primary-light);
  margin-bottom: 8px;
}
.facility-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  padding: 8px 16px;
}
.facility-check {
  background: var(--gray-light);
  border: 2px solid var(--gray-border);
  border-radius: var(--radius);
  padding: 12px 10px;
  cursor: pointer;
  transition: all 0.15s;
  text-align: center;
  font-size: 13px;
  line-height: 1.4;
  min-height: 60px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.facility-check.selected {
  background: #E3F2FD;
  border-color: var(--primary);
  color: var(--primary);
  font-weight: bold;
}
.facility-check:active { opacity: 0.7; }

/* ── 점검 진행 화면 ──────────────── */
.facility-progress {
  padding: 12px 16px;
  background: var(--gray-light);
  border-bottom: 1px solid var(--gray-border);
}
.progress-info {
  display: flex;
  justify-content: space-between;
  font-size: 14px;
  margin-bottom: 6px;
}
.progress-bar {
  height: 6px;
  background: var(--gray-border);
  border-radius: 3px;
  overflow: hidden;
}
.progress-bar-fill {
  height: 100%;
  background: var(--primary);
  border-radius: 3px;
  transition: width 0.3s;
}

.facility-tab-bar {
  display: flex;
  overflow-x: auto;
  padding: 0 16px;
  gap: 8px;
  border-bottom: 1px solid var(--gray-border);
  scrollbar-width: none;
}
.facility-tab-bar::-webkit-scrollbar { display: none; }
.facility-tab {
  padding: 10px 14px;
  border: none;
  background: none;
  font-size: 14px;
  color: var(--text-sub);
  cursor: pointer;
  white-space: nowrap;
  border-bottom: 3px solid transparent;
  transition: all 0.15s;
}
.facility-tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
  font-weight: bold;
}
.facility-tab.has-issue { color: var(--danger); }

.inspect-facility-block { padding: 12px 16px; }
.facility-meta { background: var(--gray-light); border-radius: var(--radius); padding: 12px; margin-bottom: 14px; }
.facility-meta .form-group { margin-bottom: 10px; }
.facility-meta .form-group:last-child { margin-bottom: 0; }

.category-section { margin-bottom: 16px; }
.category-label {
  font-size: 14px;
  font-weight: bold;
  color: var(--white);
  background: var(--primary-light);
  padding: 6px 12px;
  border-radius: 6px;
  margin-bottom: 8px;
  display: inline-block;
}

.check-item {
  border: 1px solid var(--gray-border);
  border-radius: var(--radius);
  margin-bottom: 8px;
  overflow: hidden;
  background: var(--white);
}
.check-item-header {
  padding: 12px 14px;
  font-size: 15px;
  line-height: 1.5;
  background: var(--white);
}
.result-buttons {
  display: flex;
  gap: 0;
  border-top: 1px solid var(--gray-border);
}
.result-btn {
  flex: 1;
  padding: 11px 6px;
  border: none;
  background: var(--gray-light);
  font-size: 15px;
  font-weight: bold;
  cursor: pointer;
  transition: background 0.15s;
  border-right: 1px solid var(--gray-border);
}
.result-btn:last-child { border-right: none; }
.result-btn.selected-O { background: #E3F2FD; color: var(--primary); }
.result-btn.selected-X { background: #FFEBEE; color: var(--danger); }
.result-btn.selected-- { background: #F5F5F5; color: var(--gray); }
.result-btn:active { opacity: 0.7; }

.remark-area {
  padding: 8px 14px;
  border-top: 1px solid var(--gray-border);
  background: #FFFDE7;
}
.remark-area textarea {
  width: 100%;
  border: 1px solid #FFE082;
  border-radius: 6px;
  padding: 8px;
  font-size: 14px;
  background: #FFFDE7;
  resize: none;
  min-height: 60px;
}

/* ── 사진 촬영 ───────────────────── */
.photo-section {
  border: 2px dashed var(--gray-border);
  border-radius: var(--radius);
  padding: 14px;
  margin: 12px 0;
  text-align: center;
}
.photo-section .photo-label {
  font-size: 14px;
  color: var(--text-sub);
  margin-bottom: 10px;
}
.photo-preview {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-start;
  margin-top: 10px;
}
.photo-thumb {
  position: relative;
  width: 80px;
  height: 80px;
}
.photo-thumb img {
  width: 80px;
  height: 80px;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid var(--gray-border);
}
.photo-thumb .del-btn {
  position: absolute;
  top: -6px;
  right: -6px;
  width: 22px;
  height: 22px;
  background: var(--danger);
  color: var(--white);
  border: none;
  border-radius: 50%;
  font-size: 13px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ── 하단 고정 버튼 ──────────────── */
.bottom-actions {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 480px;
  background: var(--white);
  border-top: 1px solid var(--gray-border);
  padding: 12px 16px;
  display: flex;
  gap: 8px;
  z-index: 50;
}
.bottom-actions .btn { flex: 1; padding: 13px 6px; font-size: 15px; }

/* ── 모달 ────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 200;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
.modal-overlay.hidden { display: none; }
.modal-sheet {
  background: var(--white);
  border-radius: 20px 20px 0 0;
  padding: 20px 20px 36px;
  width: 100%;
  max-width: 480px;
  max-height: 80vh;
  overflow-y: auto;
}
.modal-sheet h3 { font-size: 18px; font-weight: bold; margin-bottom: 16px; }
.modal-close { float: right; background: none; border: none; font-size: 22px; cursor: pointer; }

/* ── 알림/토스트 ─────────────────── */
.toast {
  position: fixed;
  top: 70px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0,0,0,0.8);
  color: var(--white);
  padding: 10px 20px;
  border-radius: 20px;
  font-size: 15px;
  z-index: 999;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.3s;
}
.toast.show { opacity: 1; }

/* ── 빈 상태 ─────────────────────── */
.empty-state {
  text-align: center;
  padding: 50px 20px;
  color: var(--text-sub);
}
.empty-state .icon { font-size: 60px; display: block; margin-bottom: 16px; }
.empty-state p { font-size: 16px; }

/* ── 로딩 스피너 ─────────────────── */
.spinner {
  width: 40px;
  height: 40px;
  border: 4px solid var(--gray-border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 40px auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(255,255,255,0.8);
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 12px;
}
.loading-overlay.hidden { display: none; }
.loading-overlay p { font-size: 15px; color: var(--text-sub); }

/* ── 점검 완료 화면 ──────────────── */
.complete-screen {
  text-align: center;
  padding: 40px 20px;
}
.complete-screen .big-icon { font-size: 80px; display: block; margin-bottom: 20px; }
.complete-screen h2 { font-size: 22px; font-weight: bold; margin-bottom: 10px; }
.complete-screen p  { font-size: 15px; color: var(--text-sub); margin-bottom: 24px; }

/* ── 배지 ────────────────────────── */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: bold;
}
.badge-primary { background: #BBDEFB; color: #0D47A1; }
.badge-warning { background: #FFE0B2; color: #E65100; }
.badge-gray    { background: #EEEEEE; color: #616161; }

/* ── 업체 카드 (슈퍼어드민) ─────── */
.company-card {
  background: var(--white);
  border: 1px solid var(--gray-border);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 10px;
  box-shadow: var(--shadow);
}
.company-card-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}
.company-name {
  font-size: 16px;
  font-weight: bold;
  color: var(--text);
}
.company-card-actions {
  display: flex;
  gap: 6px;
  margin-top: 10px;
  flex-wrap: wrap;
}

/* ── 사용자 목록 아이템 ──────────── */
.user-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid var(--gray-border);
}
.user-item:last-child { border-bottom: none; }

/* ── 반응형 ──────────────────────── */
@media (min-width: 480px) {
  body { background: #BDBDBD; }
  #app { box-shadow: 0 0 20px rgba(0,0,0,0.2); }
}
