/* ── 响应式设计 - 热泵循环仿真器 ───────────────────── */
/* 手机端 < 768px，平板端 768px-1024px */

/* ═════════════════════════════════════════════════════════
   语言选择器样式
   ═════════════════════════════════════════════════════════ */

.lang-selector-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.lang-selector {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg2);
  color: var(--text);
  cursor: pointer;
  font-size: 13px;
  transition: background 0.2s;
}

.lang-selector:hover {
  background: var(--bg3);
}

.lang-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  min-width: 150px;
  background: var(--bg1);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  z-index: 1000;
  display: none;
  flex-direction: column;
  padding: 4px;
}

.lang-dropdown.show {
  display: flex;
}

.lang-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  transition: background 0.15s;
}

.lang-item:hover {
  background: var(--bg2);
}

.lang-item.active {
  background: var(--primary-bg);
  color: var(--primary);
}

/* ═════════════════════════════════════════════════════════
   移动端通用样式
   ═════════════════════════════════════════════════════════ */

/* Header 汉堡菜单按钮 */
.menu-toggle {
  display: none;
  width: 40px;
  height: 40px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg2);
  color: var(--text);
  cursor: pointer;
  font-size: 20px;
  align-items: center;
  justify-content: center;
  padding: 0;
}

/* 移动端导航菜单 */
.mobile-nav {
  display: none;
  position: fixed;
  top: 52px;
  left: 0;
  right: 0;
  background: var(--bg1);
  border-bottom: 1px solid var(--border);
  padding: 8px 16px;
  z-index: 99;
  flex-direction: column;
  gap: 8px;
}

.mobile-nav.show {
  display: flex;
}

.mobile-nav-link {
  display: block;
  padding: 10px 14px;
  border-radius: 8px;
  background: var(--bg2);
  color: var(--text);
  text-decoration: none;
  font-size: 14px;
  border: 1px solid var(--border);
}

.mobile-nav-link.active {
  background: var(--accent3);
  color: #000;
  border-color: var(--accent3);
}

.mobile-nav-divider {
  height: 1px;
  background: var(--border);
  margin: 4px 0;
}

.mobile-nav-link.mobile-nav-accent {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
  font-weight: 600;
}

/* 面板切换标签（用于参数面板和结果面板切换） */
.panel-tabs {
  display: none;
  background: var(--bg1);
  border-bottom: 1px solid var(--border);
  padding: 8px 12px;
  gap: 8px;
  position: sticky;
  top: 52px;
  z-index: 50;
}

.panel-tab {
  flex: 1;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg2);
  color: var(--text-dim);
  font-size: 13px;
  cursor: pointer;
  text-align: center;
}

.panel-tab.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

/* ═════════════════════════════════════════════════════════
   手机端 (< 768px) 响应式样式
   ═════════════════════════════════════════════════════════ */
@media screen and (max-width: 767px) {
  /* ── Header 调整 ─────────────────── */
  header {
    height: 52px;
    padding: 0 10px;
    gap: 6px;
    display: flex;
    align-items: center;
  }

  /* Logo: 只显示图标+短文字，隐藏副标题 */
  .logo {
    font-size: 13px;
    gap: 4px;
    flex-shrink: 1;
    min-width: 0;
    overflow: hidden;
    white-space: nowrap;
  }

  .logo svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
  }

  .logo-sub {
    display: none;
  }

  /* 显示汉堡菜单，隐藏顶部导航标签 */
  .menu-toggle {
    display: flex;
    flex-shrink: 0;
    width: 36px;
    height: 36px;
    font-size: 18px;
  }

  .mode-tabs {
    display: none;
  }

  /* 隐藏管理后台链接（移入汉堡菜单） */
  .lang-selector-wrap .admin-link {
    display: none;
  }

  /* 隐藏注册按钮（移入汉堡菜单） */
  .register-btn-header {
    display: none;
  }

  /* 用户状态区域：只保留登录按钮 */
  .user-status {
    gap: 4px;
    margin-right: 0;
    margin-left: auto;
    flex-shrink: 0;
    display: flex;
    align-items: center;
  }

  /* 隐藏剩余次数文字（移入汉堡菜单或登录后显示） */
  .remaining-count {
    display: none;
  }

  .login-btn {
    padding: 6px 12px;
    font-size: 12px;
    white-space: nowrap;
  }

  /* 已登录用户信息紧凑显示 */
  .user-info-wrap {
    gap: 4px;
  }

  .user-info-wrap .username {
    max-width: 80px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 12px;
  }

  /* 语言选择器：紧凑化 */
  .lang-selector-wrap {
    order: 0;
    flex-shrink: 0;
  }

  .lang-selector {
    padding: 6px 8px;
    font-size: 12px;
    gap: 2px;
  }

  .lang-selector .lang-text {
    display: none;
  }

  .lang-dropdown {
    right: 0;
    left: auto;
  }

  /* ── 面板切换标签 ─────────────────── */
  .panel-tabs {
    display: flex;
  }
  
  /* ── 左右分栏改为单栏 ─────────────────── */
  .app-body {
    display: block;
    height: auto;
    overflow-y: auto;
  }
  
  .panel-left {
    display: none;
    width: 100%;
    border-right: none;
    border-bottom: 1px solid var(--border);
    max-height: none;
    overflow-y: visible;
  }
  
  .panel-left.active {
    display: flex;
  }
  
  .panel-right {
    display: none;
    width: 100%;
    padding: 12px;
    overflow-y: visible;
  }
  
  .panel-right.active {
    display: flex;
  }
  
  /* ── Section 样式调整 ─────────────────── */
  .section {
    padding: 12px 14px;
  }
  
  .section-title {
    font-size: 11px;
    margin-bottom: 10px;
  }
  
  /* ── 输入框样式调整 ─────────────────── */
  input[type="number"], input[type="text"], select {
    padding: 8px 10px;
    font-size: 14px;
  }
  
  label {
    font-size: 13px;
    margin-bottom: 6px;
  }
  
  label span.unit {
    font-size: 12px;
    padding: 2px 8px;
  }
  
  .row2 {
    grid-template-columns: 1fr 1fr;
    gap: 10px;
  }
  
  .row3 {
    grid-template-columns: 1fr 1fr;
    gap: 10px;
  }
  
  /* ── 按钮样式调整 ─────────────────── */
  .calc-btn {
    padding: 14px;
    font-size: 15px;
  }
  
  .toggle-btn {
    padding: 8px;
    font-size: 13px;
  }
  
  /* ── KPI卡片调整 ─────────────────── */
  .kpi-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
  }
  
  .kpi-card {
    padding: 10px 12px;
  }
  
  .kpi-value {
    font-size: 16px;
  }
  
  /* ── 登录模态框调整 ─────────────────── */
  .login-modal-content {
    width: calc(100vw - 32px);
    padding: 20px 16px;
    margin: 16px;
  }
  
  .login-modal-title {
    font-size: 16px;
    margin-bottom: 16px;
  }
  
  .login-field input {
    padding: 12px;
    font-size: 16px;
  }
  
  .login-field-row button {
    padding: 12px 14px;
    font-size: 14px;
  }
  
  .login-submit {
    padding: 14px;
    font-size: 15px;
  }
  
  /* ── 语言选择器调整 ─────────────────── */
  .lang-dropdown {
    right: 0;
    left: auto;
  }
  .charts-row {
    grid-template-columns: 1fr;
    gap: 16px;
  }
  
  .chart-card {
    width: 100%;
  }
  
  .chart-card > div {
    height: 350px;
    overflow: auto;
  }
  
  .chart-canvas-wrap {
    height: 350px;
  }
  
  /* 系统流程图SVG在手机端自适应 */
  #systemDiagram,
  .chart-card svg {
    min-height: 300px;
  }
  
  /* ── 结果表格调整 ─────────────────── */
  .result-table-wrap {
    overflow-x: auto;
  }
  
  .result-table {
    min-width: 600px;
  }
}

/* ═════════════════════════════════════════════════════════
   平板端 (768px - 1024px) 响应式样式
   ═════════════════════════════════════════════════════════ */
@media screen and (min-width: 768px) and (max-width: 1024px) {
  /* ── Header 调整 ─────────────────── */
  header {
    padding: 0 16px;
    gap: 12px;
  }
  
  .logo {
    font-size: 14px;
  }
  
  .logo-sub {
    font-size: 11px;
  }
  
  .mode-tab {
    padding: 4px 10px;
    font-size: 12px;
  }
  
  /* ── 左右分栏调整比例 ─────────────────── */
  .app-body {
    grid-template-columns: 280px 1fr;
  }
  
  .panel-left {
    width: 280px;
  }
  
  /* ── Section 样式调整 ─────────────────── */
  .section {
    padding: 12px 14px;
  }
  
  /* ── KPI卡片调整 ─────────────────── */
  .kpi-grid {
    grid-template-columns: repeat(3, 1fr);
  }
  
  /* ── 图表区域调整 ─────────────────── */
  .chart-wrap {
    height: 300px;
  }
}

/* ═════════════════════════════════════════════════════════
   自定义循环页面 (custom.html) 特殊响应式
   ═════════════════════════════════════════════════════════ */
@media screen and (max-width: 767px) {
  /* ── 自定义循环三栏布局改为标签切换 ─────────────────── */
  .main {
    flex-direction: column;
    overflow-y: auto;
  }
  
  /* 器件库面板 */
  .lib-panel {
    display: none;
    width: 100%;
    min-width: 100%;
    max-height: 200px;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }
  
  .lib-panel.active {
    display: flex;
  }
  
  /* 画布区域 */
  .canvas-area {
    display: none;
    height: 400px;
    min-height: 400px;
  }
  
  .canvas-area.active {
    display: flex;
  }
  
  /* 属性面板 */
  .props-panel {
    display: none;
    width: 100%;
    min-width: 100%;
    border-left: none;
    border-top: 1px solid var(--border);
  }
  
  .props-panel.active {
    display: flex;
  }
  
  /* 工具栏调整 */
  .toolbar {
    flex-wrap: wrap;
    gap: 4px;
    margin-left: 8px;
  }
  
  .tb-btn {
    padding: 4px 8px;
    font-size: 11px;
  }
  
  /* 流体选择区域 */
  .fluid-select-wrap {
    margin-left: 4px;
    padding-left: 4px;
    border-left: none;
  }
  
  .fluid-select-wrap label {
    display: none;
  }
  
  .fluid-select-wrap select {
    min-width: 70px;
    font-size: 12px;
  }
  
  /* 缩放控件调整 */
  .zoom-controls {
    bottom: 8px;
    right: 8px;
  }
  
  .zoom-btn {
    width: 28px;
    height: 28px;
    font-size: 14px;
  }
  
  .zoom-label {
    font-size: 10px;
    padding: 0 4px;
  }
  
  /* 自定义循环的模态框 */
  .modal {
    min-width: calc(100vw - 32px);
    max-width: calc(100vw - 32px);
    padding: 16px;
    margin: 16px;
  }
  
  .modal h3 {
    font-size: 14px;
  }
  
  /* 自定义循环的登录模态框 */
  .login-box {
    min-width: calc(100vw - 32px);
    max-width: calc(100vw - 32px);
    padding: 20px 16px;
  }
  
  .login-title {
    font-size: 16px;
  }
  
  .login-field input {
    padding: 10px;
    font-size: 16px;
  }
  
  .login-actions button {
    padding: 12px;
    font-size: 14px;
  }
}

/* ═════════════════════════════════════════════════════════
   触摸设备优化
   ═════════════════════════════════════════════════════════ */
@media (hover: none) and (pointer: coarse) {
  /* 增大可点击区域 */
  input[type="number"], input[type="text"], select {
    min-height: 44px;
  }
  
  button, .tb-btn, .toggle-btn, .mode-tab, .panel-tab {
    min-height: 44px;
    min-width: 44px;
  }
  
  /* 禁用hover效果 */
  .kpi-card:hover,
  .lib-item:hover,
  .tb-btn:hover,
  .mode-tab:hover {
    transform: none;
    box-shadow: none;
  }
  
  /* 激活状态代替hover */
  .lib-item:active,
  .tb-btn:active,
  .mode-tab:active {
    background: var(--bg3);
  }
}