/* ============================================
   SUBWAY SMART GUIDE SYSTEM - MAIN STYLES
   ============================================ */

:root {
  --primary: #1a56db;
  --primary-dark: #1341a8;
  --primary-light: #e8f0fe;
  --secondary: #0ea5e9;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --danger-dark: #b91c1c;
  --orange: #f97316;
  --purple: #8b5cf6;
  --dark: #1e293b;
  --dark-2: #334155;
  --gray: #64748b;
  --gray-light: #94a3b8;
  --gray-lighter: #cbd5e1;
  --bg: #f1f5f9;
  --bg-2: #f8fafc;
  --white: #ffffff;
  --border: #e2e8f0;
  --shadow: 0 2px 8px rgba(0,0,0,0.08);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.12);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.16);
  --radius: 12px;
  --radius-sm: 8px;
  --font: 'Noto Sans KR', sans-serif;
  --transition: all 0.2s ease;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; }
body { font-family: var(--font); background: var(--bg); color: var(--dark); }
a { text-decoration: none; color: inherit; }
button { cursor: pointer; border: none; font-family: var(--font); }
input, select, textarea { font-family: var(--font); }
img { max-width: 100%; }
.hidden { display: none !important; }

/* ========== 공통 버튼 ========== */
.btn-primary {
  background: var(--primary);
  color: var(--white);
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  transition: var(--transition);
}
.btn-primary:hover { background: var(--primary-dark); }
.btn-save {
  background: var(--success);
  color: var(--white);
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  transition: var(--transition);
}
.btn-save:hover { opacity: 0.9; }
.btn-danger {
  background: var(--danger);
  color: var(--white);
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  transition: var(--transition);
}
.btn-danger:hover { background: var(--danger-dark); }
.btn-cancel {
  background: var(--gray-lighter);
  color: var(--dark-2);
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  transition: var(--transition);
}
.btn-add {
  background: var(--primary);
  color: white;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  transition: var(--transition);
}
.btn-add:hover { background: var(--primary-dark); }
.btn-sm {
  background: var(--primary);
  color: white;
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
}
.btn-sm:hover { opacity: 0.9; }
.btn-test {
  background: var(--secondary);
  color: white;
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
}

/* ========== 공통 폼 ========== */
.form-group {
  margin-bottom: 16px;
}
.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--dark-2);
  margin-bottom: 6px;
}
.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  color: var(--dark);
  background: var(--white);
  transition: var(--transition);
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(26,86,219,0.1);
}
.form-row {
  display: flex;
  gap: 10px;
  align-items: flex-end;
}
.form-row select { flex: 1; }
.hint { font-size: 12px; color: var(--gray); margin-top: 4px; }

/* ========== 공통 모달 ========== */
.modal {
  position: fixed; inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
}
.modal-overlay {
  position: absolute; inset: 0;
  background: rgba(0,0,0,0.5);
}
.modal-content {
  position: relative;
  background: var(--white);
  border-radius: var(--radius);
  width: 90%;
  max-width: 500px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  animation: modalIn 0.2s ease;
}
@keyframes modalIn {
  from { opacity: 0; transform: scale(0.95); }
  to { opacity: 1; transform: scale(1); }
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--border);
}
.modal-header h2, .modal-header h3 {
  font-size: 18px;
  font-weight: 700;
  color: var(--dark);
}
.modal-close {
  background: none;
  font-size: 22px;
  color: var(--gray);
  line-height: 1;
  padding: 4px;
}
.modal-close:hover { color: var(--danger); }
.modal-body {
  padding: 20px 24px;
}
.modal-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

/* ========== 토글 스위치 ========== */
.toggle-switch {
  position: relative;
  display: inline-block;
  width: 48px;
  height: 26px;
  flex-shrink: 0;
}
.toggle-switch input { display: none; }
.toggle-slider {
  position: absolute;
  inset: 0;
  background: var(--gray-lighter);
  border-radius: 26px;
  cursor: pointer;
  transition: var(--transition);
}
.toggle-slider:before {
  content: '';
  position: absolute;
  width: 20px; height: 20px;
  left: 3px; bottom: 3px;
  background: white;
  border-radius: 50%;
  transition: var(--transition);
  box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}
.toggle-switch input:checked + .toggle-slider { background: var(--primary); }
.toggle-switch input:checked + .toggle-slider:before { transform: translateX(22px); }
.toggle-switch.large { width: 58px; height: 32px; }
.toggle-switch.large .toggle-slider:before { width: 26px; height: 26px; }
.toggle-switch.large input:checked + .toggle-slider:before { transform: translateX(26px); }

/* ========== 입력창+버튼 그룹 ========== */
.input-with-btn {
  display: flex;
  gap: 8px;
}
.input-with-btn input { flex: 1; }

/* ========== 상태 배너 ========== */
.status-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 20px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 14px;
  margin-bottom: 20px;
}
.status-normal { background: #d1fae5; color: #065f46; }
.status-warning { background: #fef3c7; color: #92400e; }
.status-danger { background: #fee2e2; color: #991b1b; animation: pulse 1s infinite; }
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:0.7} }
.fire-badge {
  background: var(--danger);
  color: white;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 12px;
  animation: pulse 1s infinite;
}

/* ========== 메인 페이지 ========== */
.main-body { background: var(--bg); }
.main-header {
  background: var(--primary);
  color: white;
  padding: 16px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: var(--shadow-md);
}
.header-left { display: flex; align-items: center; gap: 12px; }
.logo-icon {
  width: 44px; height: 44px;
  background: rgba(255,255,255,0.2);
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px;
}
.header-title h1 { font-size: 20px; font-weight: 700; }
.header-title span { font-size: 12px; opacity: 0.8; }
.btn-admin {
  background: rgba(255,255,255,0.2);
  color: white;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  border: 1px solid rgba(255,255,255,0.3);
  transition: var(--transition);
}
.btn-admin:hover { background: rgba(255,255,255,0.3); }
.main-content { max-width: 1100px; margin: 0 auto; padding: 24px 20px; }

/* 카드 그리드 */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 20px;
  margin-bottom: 28px;
}
.main-card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 28px 24px;
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: var(--transition);
  position: relative;
  border: 2px solid transparent;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
}
.main-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-md);
}
.main-card .card-icon {
  width: 52px; height: 52px;
  border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  font-size: 24px;
  margin-bottom: 4px;
}
.main-card h2 { font-size: 18px; font-weight: 700; }
.main-card p { font-size: 13px; color: var(--gray); line-height: 1.6; }
.main-card .card-arrow {
  position: absolute; right: 20px; top: 50%;
  transform: translateY(-50%);
  color: var(--gray-lighter);
  font-size: 18px;
}
.qr-card { border-color: var(--primary); }
.qr-card .card-icon { background: var(--primary-light); color: var(--primary); }
.transfer-card .card-icon { background: #e0f2fe; color: #0284c7; }
.exit-card .card-icon { background: #d1fae5; color: var(--success); }
.evacuation-card .card-icon { background: #fef3c7; color: var(--warning); }
.accessible-card .card-icon { background: #ede9fe; color: var(--purple); }
.fire-card .card-icon { background: #fee2e2; color: var(--danger); }

/* 역 정보 섹션 */
.station-info-section, .realtime-section {
  background: var(--white);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
  margin-bottom: 20px;
}
.station-info-section h3, .realtime-section h3 {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 16px;
  color: var(--dark);
}
.station-info-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
}
.loading-spinner { color: var(--gray); padding: 20px; text-align: center; }

.realtime-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 12px;
}
.realtime-item {
  background: var(--bg);
  border-radius: var(--radius-sm);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.realtime-label { font-size: 12px; color: var(--gray); }
.realtime-value { font-size: 22px; font-weight: 700; color: var(--dark); }
.status-ok { color: var(--success) !important; font-size: 16px !important; }

/* 메인 Footer */
.main-footer {
  text-align: center;
  padding: 24px;
  font-size: 12px;
  color: var(--gray);
}

/* ========== 팝업 오버레이 ========== */
.popup-overlay {
  position: fixed; inset: 0; z-index: 9000;
  display: flex; align-items: center; justify-content: center;
  background: rgba(0,0,0,0.6);
}
.popup-card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 32px 28px;
  text-align: center;
  max-width: 340px;
  width: 90%;
  box-shadow: var(--shadow-lg);
  animation: modalIn 0.25s ease;
}
.popup-card .popup-icon {
  font-size: 48px;
  color: var(--primary);
  margin-bottom: 12px;
}
.popup-card h3 {
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 10px;
}
.popup-card p { font-size: 14px; color: var(--gray); line-height: 1.6; }
.popup-actions {
  display: flex;
  gap: 10px;
  margin-top: 20px;
  justify-content: center;
}
.btn-update-route {
  background: var(--primary);
  color: white;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  font-weight: 600;
}
.btn-close-popup {
  background: var(--bg);
  color: var(--dark-2);
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  font-weight: 600;
}

/* 화재 팝업 */
.fire-popup {
  border: 3px solid var(--danger);
}
.fire-popup-anim {
  font-size: 56px;
  animation: fireAnim 0.5s infinite alternate;
}
@keyframes fireAnim { from{transform:scale(1)} to{transform:scale(1.15)} }
.fire-instruction {
  color: var(--danger) !important;
  font-weight: 700 !important;
  font-size: 16px !important;
}
.btn-evacuate-emergency {
  background: var(--danger);
  color: white;
  padding: 14px 24px;
  border-radius: var(--radius-sm);
  font-size: 16px;
  font-weight: 700;
  width: 100%;
  margin-top: 16px;
  animation: pulse 1s infinite;
}

/* ========== QR 테스트 패널 ========== */
.test-panel-section {
  background: var(--white);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
  margin-bottom: 20px;
  border: 2px solid #e0f2fe;
}
.test-panel-section h3 {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 8px;
  color: var(--dark);
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.test-panel-section h3 i { color: #0284c7; }
.test-badge {
  background: #0284c7;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 10px;
  border-radius: 99px;
  letter-spacing: 0.3px;
}
.test-desc {
  font-size: 13px;
  color: var(--gray);
  margin-bottom: 16px;
  line-height: 1.5;
}
.test-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}
.test-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 14px 10px;
  border-radius: 12px;
  text-decoration: none;
  transition: transform 0.15s, box-shadow 0.15s;
  border: 2px solid transparent;
  text-align: center;
  cursor: pointer;
}
.test-btn:hover {
  transform: translateY(-3px);
  box-shadow: 0 6px 18px rgba(0,0,0,0.13);
  border-color: currentColor;
}
.test-btn-floor {
  font-size: 11px;
  font-weight: 800;
  padding: 2px 8px;
  border-radius: 6px;
  background: rgba(0,0,0,0.12);
  color: inherit;
}
.test-btn-name {
  font-size: 13px;
  font-weight: 700;
  color: inherit;
  line-height: 1.3;
}
.test-btn-id {
  font-size: 10px;
  opacity: 0.65;
  font-family: 'Courier New', monospace;
  color: inherit;
}
/* 타입별 색상 */
.test-platform  { background: #e0f2fe; color: #0284c7; }
.test-elevator  { background: #ede9fe; color: #7c3aed; }
.test-escalator { background: #dbeafe; color: #1d4ed8; }
.test-gate      { background: #d1fae5; color: #059669; }
.test-emergency { background: #fee2e2; color: #dc2626; }
.test-exit      { background: #d1fae5; color: #047857; }

/* URL 직접 입력 */
.test-url-section {
  border-top: 1px solid var(--border);
  padding-top: 14px;
  margin-top: 4px;
}
.test-url-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--gray);
  margin-bottom: 8px;
}
.test-url-row {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg);
  border: 1.5px solid var(--border);
  border-radius: 10px;
  padding: 4px 4px 4px 12px;
}
.test-url-prefix {
  font-size: 13px;
  color: var(--gray);
  white-space: nowrap;
  font-family: 'Courier New', monospace;
}
.test-url-row input {
  flex: 1;
  border: none;
  background: transparent;
  font-size: 14px;
  color: var(--dark);
  padding: 8px 0;
  outline: none;
  font-family: 'Courier New', monospace;
  min-width: 0;
}
.test-url-btn {
  background: var(--primary);
  color: #fff;
  border: none;
  padding: 9px 18px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.2s;
}
.test-url-btn:hover { background: var(--primary-dark); }

/* ========== 반응형 ========== */
@media (max-width: 600px) {
  .main-header { padding: 12px 16px; }
  .header-title h1 { font-size: 16px; }
  .main-content { padding: 16px 12px; }
  .card-grid { grid-template-columns: 1fr 1fr; gap: 12px; }
  .main-card { padding: 18px 14px; }
  .main-card h2 { font-size: 15px; }
  .main-card .card-icon { width: 40px; height: 40px; font-size: 18px; }
  .main-card .card-arrow { display: none; }
}
@media (max-width: 380px) {
  .card-grid { grid-template-columns: 1fr; }
}
