/* 医院医疗设备扫码APP - 样式表 (Mobile Native App Style) */
:root {
  --primary-color: #1a66ff;
  --primary-dark: #004bd6;
  --primary-light: #e8f0ff;
  --success-color: #00b887;
  --success-light: #e6f8f3;
  --warning-color: #ff9900;
  --warning-light: #fff5e6;
  --danger-color: #ff4d4f;
  --danger-light: #ffeef0;
  --purple-color: #722ed1;
  --purple-light: #f9f0ff;
  --bg-color: #f5f7fa;
  --card-bg: #ffffff;
  --text-main: #1f2937;
  --text-sub: #6b7280;
  --border-color: #e5e7eb;
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --shadow-sm: 0 2px 8px rgba(0,0,0,0.04);
  --shadow-md: 0 6px 16px rgba(0,0,0,0.08);
  --shadow-lg: 0 12px 32px rgba(0,0,0,0.12);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  -webkit-tap-highlight-color: transparent;
}

body {
  background-color: #111827;
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  padding: 10px;
}

/* 模拟手机容器 */
.phone-container {
  width: 100%;
  max-width: 420px;
  height: 860px;
  max-height: 92vh;
  background-color: var(--bg-color);
  border-radius: 36px;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5), 0 0 0 10px #1f2937;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
}

/* 手机顶部状态栏/刘海 */
.phone-notch {
  height: 30px;
  background: #ffffff;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 24px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-main);
  z-index: 100;
  border-bottom: 1px solid rgba(0,0,0,0.03);
}

/* 顶部导航标题栏 */
.app-header {
  background: #ffffff;
  padding: 14px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
  z-index: 90;
}

.app-title {
  display: flex;
  align-items: center;
  gap: 10px;
}

.app-title .logo-icon {
  width: 32px;
  height: 32px;
  background: linear-gradient(135deg, #1a66ff, #00b887);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 18px;
  font-weight: bold;
}

.app-title h1 {
  font-size: 17px;
  font-weight: 700;
  color: var(--text-main);
}

.app-title p {
  font-size: 11px;
  color: var(--text-sub);
}

.header-badge {
  background: var(--primary-light);
  color: var(--primary-color);
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
}

/* 主内容区域 (支持滚动) */
.app-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  position: relative;
}

/* 底部 TabBar */
.app-tabbar {
  height: 65px;
  background: #ffffff;
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: space-around;
  align-items: center;
  z-index: 90;
  padding-bottom: 8px;
}

.tab-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  color: var(--text-sub);
  font-size: 11px;
  cursor: pointer;
  transition: all 0.2s;
  background: none;
  border: none;
  width: 25%;
}

.tab-item i {
  font-size: 20px;
}

.tab-item.active {
  color: var(--primary-color);
  font-weight: 700;
}

.tab-item.scan-tab {
  position: relative;
  top: -14px;
}

.tab-item.scan-tab .scan-btn-circle {
  width: 52px;
  height: 52px;
  background: linear-gradient(135deg, #1a66ff, #0052cc);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 24px;
  box-shadow: 0 8px 18px rgba(26, 102, 255, 0.4);
  border: 4px solid #ffffff;
  transition: transform 0.2s;
}

.tab-item.scan-tab:active .scan-btn-circle {
  transform: scale(0.92);
}

/* ---------------- 页面视图组件 ---------------- */
.view-section {
  display: none;
  animation: fadeIn 0.25s ease-in-out forwards;
}

.view-section.active {
  display: block;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* --- 1. 扫码界面 --- */
.scanner-card {
  background: #ffffff;
  border-radius: var(--radius-md);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  text-align: center;
  margin-bottom: 16px;
}

.camera-viewport {
  width: 100%;
  height: 240px;
  background: #0f172a;
  border-radius: var(--radius-md);
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  margin: 14px 0;
  border: 2px dashed rgba(255,255,255,0.2);
}

#video-element {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.scan-frame {
  position: absolute;
  width: 180px;
  height: 180px;
  border: 2px solid rgba(255,255,255,0.4);
  border-radius: 16px;
  box-shadow: 0 0 0 4000px rgba(0, 0, 0, 0.45);
  pointer-events: none;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 8px;
}

/* 扫描框架四角 */
.scan-corner {
  position: absolute;
  width: 20px;
  height: 20px;
  border-color: #00b887;
  border-style: solid;
}

.corner-tl { top: -2px; left: -2px; border-width: 4px 0 0 4px; border-top-left-radius: 12px; }
.corner-tr { top: -2px; right: -2px; border-width: 4px 4px 0 0; border-top-right-radius: 12px; }
.corner-bl { bottom: -2px; left: -2px; border-width: 0 0 4px 4px; border-bottom-left-radius: 12px; }
.corner-br { bottom: -2px; right: -2px; border-width: 0 4px 4px 0; border-bottom-right-radius: 12px; }

/* 扫描激光线条动画 */
.scan-laser {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 3px;
  background: linear-gradient(90deg, transparent, #00b887, transparent);
  box-shadow: 0 0 12px #00b887;
  animation: laserScan 2.2s infinite ease-in-out;
}

@keyframes laserScan {
  0% { top: 10%; opacity: 0.2; }
  50% { top: 85%; opacity: 1; }
  100% { top: 10%; opacity: 0.2; }
}

.camera-tip {
  color: rgba(255,255,255,0.85);
  font-size: 12px;
  z-index: 10;
  margin-top: 130px;
  background: rgba(0,0,0,0.6);
  padding: 4px 12px;
  border-radius: 12px;
}

/* 模拟测试扫码控制区 */
.quick-test-section {
  background: var(--primary-light);
  border-radius: var(--radius-md);
  padding: 14px;
  margin-top: 14px;
  text-align: left;
}

.quick-test-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--primary-color);
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.quick-device-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.chip-btn {
  background: #ffffff;
  border: 1px solid #bfdbfe;
  color: var(--primary-dark);
  padding: 6px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.chip-btn:active {
  background: var(--primary-color);
  color: white;
}

/* --- 2. 设备详情卡片 --- */
.device-detail-card {
  background: #ffffff;
  border-radius: var(--radius-md);
  padding: 18px;
  box-shadow: var(--shadow-sm);
  margin-bottom: 14px;
  position: relative;
}

.device-header-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 12px;
}

.device-name {
  font-size: 18px;
  font-weight: 800;
  color: var(--text-main);
  line-height: 1.3;
}

.device-id-code {
  font-size: 12px;
  color: var(--text-sub);
  margin-top: 2px;
  font-family: monospace;
}

.status-badge {
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
}

.status-badge.in_use { background: var(--success-light); color: var(--success-color); }
.status-badge.idle { background: var(--primary-light); color: var(--primary-color); }
.status-badge.borrowed { background: var(--purple-light); color: var(--purple-color); }
.status-badge.fault { background: var(--danger-light); color: var(--danger-color); }
.status-badge.maintenance { background: var(--warning-light); color: var(--warning-color); }

/* 基本信息网格 */
.info-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  background: #f9fafb;
  padding: 12px;
  border-radius: var(--radius-sm);
  margin: 12px 0;
}

.info-item {
  display: flex;
  flex-direction: column;
}

.info-label {
  font-size: 11px;
  color: var(--text-sub);
  margin-bottom: 2px;
}

.info-val {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-main);
}

/* 按钮操作组 */
.action-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 14px;
}

.btn {
  border: none;
  padding: 12px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: all 0.2s;
}

.btn-primary { background: var(--primary-color); color: white; }
.btn-primary:active { background: var(--primary-dark); }

.btn-purple { background: var(--purple-color); color: white; }
.btn-purple:active { opacity: 0.9; }

.btn-success { background: var(--success-color); color: white; }

.btn-danger { background: var(--danger-light); color: var(--danger-color); border: 1px solid #fca5a5; }

.btn-outline { background: white; border: 1px solid var(--border-color); color: var(--text-main); }

.btn-full { grid-column: span 2; }

/* 动态列表卡片 */
.history-section {
  background: #ffffff;
  border-radius: var(--radius-md);
  padding: 16px;
  margin-bottom: 14px;
  box-shadow: var(--shadow-sm);
}

.section-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.timeline {
  position: relative;
  padding-left: 18px;
}

.timeline::before {
  content: '';
  position: absolute;
  left: 6px;
  top: 4px;
  bottom: 4px;
  width: 2px;
  background: var(--border-color);
}

.timeline-item {
  position: relative;
  margin-bottom: 14px;
}

.timeline-item:last-child {
  margin-bottom: 0;
}

.timeline-dot {
  position: absolute;
  left: -18px;
  top: 4px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--primary-color);
  border: 2px solid white;
  box-shadow: 0 0 0 2px var(--primary-light);
}

.timeline-time {
  font-size: 10px;
  color: var(--text-sub);
}

.timeline-content {
  font-size: 12px;
  color: var(--text-main);
  font-weight: 600;
  margin-top: 2px;
}

.timeline-remark {
  font-size: 11px;
  color: var(--text-sub);
  margin-top: 1px;
}

/* 弹窗/模态框 */
.modal-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(3px);
  z-index: 200;
  display: none;
  align-items: flex-end;
  justify-content: center;
}

.modal-overlay.active {
  display: flex;
  animation: slideUp 0.25s ease-out forwards;
}

@keyframes slideUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

.modal-sheet {
  background: #ffffff;
  width: 100%;
  border-top-left-radius: 24px;
  border-top-right-radius: 24px;
  padding: 20px;
  max-height: 85%;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border-color);
}

.modal-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-main);
}

.close-btn {
  background: none;
  border: none;
  font-size: 20px;
  color: var(--text-sub);
  cursor: pointer;
}

.form-group {
  margin-bottom: 14px;
}

.form-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-main);
  margin-bottom: 6px;
}

.form-input, .form-select, .form-textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: var(--text-main);
  background: #fff;
  outline: none;
}

.form-input:focus, .form-select:focus, .form-textarea:focus {
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px var(--primary-light);
}

/* Toast 消息提示 */
.toast-msg {
  position: absolute;
  top: 50px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(31, 41, 55, 0.92);
  color: white;
  padding: 10px 20px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  z-index: 300;
  display: none;
  animation: fadeIn 0.2s ease-out;
}
