/* 首页样式：导航栏、公告条、查询区域、页脚 */

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: 'Segoe UI', 'Microsoft YaHei', sans-serif;
  background: #f5f7fb;
  color: #222;
}

/* 导航栏 */
.navbar {
  background: linear-gradient(90deg, #2a5298, #1e3c72);
  color: #fff;
  padding: 12px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: nowrap;
}
.navbar .brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0; /* 防止过度挤压导致换行 */
}
.navbar .brand img {
  width: 32px;
  height: 32px;
}
.navbar .brand .title {
  font-size: 18px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.navbar .actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}
.navbar a {
  color: #fff;
  text-decoration: none;
  opacity: 0.95;
  white-space: nowrap;
}
.navbar a:hover {
  opacity: 1;
  text-decoration: underline;
}

/* 公告条 */
.announcement-bar {
  background: #fff7e6;
  border-bottom: 1px solid #ffe7ba;
  color: #8c6d1f;
  padding: 8px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.announcement-bar .label {
  font-weight: 600;
}
.announcement-bar .text {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.announcement-bar .controls {
  display: flex;
  gap: 8px;
}
.announcement-bar .btn {
  background: transparent;
  border: 1px solid #d4b106;
  color: #8c6d1f;
  padding: 2px 8px;
  border-radius: 4px;
  cursor: pointer;
}
.announcement-bar .btn:hover {
  background: #fff1b8;
}

/* 主内容区域 */
.container {
  max-width: 1000px;
  margin: 20px auto;
  padding: 0 20px;
}

.search-card {
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 6px 20px rgba(0,0,0,0.08);
  padding: 20px;
}
.search-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.search-title {
  font-size: 18px;
  font-weight: 600;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr auto;
  gap: 12px;
}
.form-row .input {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.form-row label {
  font-size: 12px;
  color: #666;
}
.form-row input, .form-row select {
  height: 36px;
  border: 1px solid #ddd;
  border-radius: 8px;
  padding: 0 10px;
  outline: none;
}
.form-row input:focus, .form-row select:focus {
  border-color: #2a5298;
  box-shadow: 0 0 0 2px rgba(42,82,152,0.1);
}
.search-btn {
  height: 36px;
  padding: 0 16px;
  border: none;
  background: #2a5298;
  color: #fff;
  border-radius: 8px;
  cursor: pointer;
}
.search-btn:hover { background: #1e3c72; }

.results {
  margin-top: 18px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.result-item {
  background: #fafafa;
  border: 1px solid #eee;
  border-radius: 10px;
  padding: 12px;
}
.result-item .name {
  font-weight: 600;
}
.result-item .meta {
  font-size: 12px;
  color: #666;
}

/* 页脚 */
.footer {
  margin-top: 40px;
  padding: 16px 20px;
  text-align: center;
  color: #666;
}
.footer a { color: #2a5298; text-decoration: none; }
.footer a:hover { text-decoration: underline; }

@media (max-width: 768px) {
  .form-row { grid-template-columns: 1fr; }
  .results { grid-template-columns: 1fr; }
  .navbar { padding: 10px 12px; }
  .navbar .actions { gap: 8px; }
  .navbar .brand .title { font-size: 16px; }
  .navbar a { font-size: 13px; }
}

/* 联动查询区域 */
.linkage { display: flex; flex-direction: column; gap: 14px; }

.campus-tabs { display: flex; flex-wrap: wrap; gap: 10px; }
.campus-tabs .tab {
  padding: 8px 16px;
  border: 1px solid #d9d9d9;
  border-radius: 999px;
  background: #fff;
  color: #222;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}
.campus-tabs .tab.active { background: #2a5298; color: #fff; border-color: #2a5298; }

.region-list { display: flex; flex-wrap: wrap; gap: 10px; }
.region-item {
  padding: 8px 14px;
  border: 1px solid #e0e0e0;
  border-radius: 10px;
  background: #fafafa;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
}
.region-item.active { background: #e6f0ff; border-color: #2a5298; color: #2a5298; }

.stations { display: grid; grid-template-columns: 1fr; gap: 12px; }
.station-card { 
  background: #fff; 
  border: 1px solid #eee; 
  border-radius: 10px; 
  padding: 12px; 
  display: flex; 
  align-items: center; 
  justify-content: space-between;
}
.station-card .left { flex: 1; min-width: 0; }
.station-card .name { font-weight: 600; margin-bottom: 4px; }
.station-card .meta { font-size: 12px; color: #666; }
.station-card .right { text-align: right; min-width: 120px; }
.station-card .right .label { font-size: 12px; color: #666; margin-bottom: 4px; }
.station-card .right .avail { 
  display: inline-block; 
  min-width: 48px;
  padding: 6px 10px; 
  border-radius: 999px; 
  font-weight: 700; 
  text-align: center;
}
.station-card .right .avail.avail-ok { background: #e8f7e8; color: #2e7d32; border: 1px solid #b7e1b7; }
.station-card .right .avail.avail-none { background: #f4f4f4; color: #666; border: 1px solid #e0e0e0; }

.hint { color: #888; font-size: 13px; }
.hint.error { color: #c0392b; }

/* 端口号标签 */
.station-card .ports {
  margin-top: 10px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.station-card .port-pill {
  min-width: 30px;
  height: 28px;
  line-height: 28px;
  border-radius: 8px;
  border: 1px solid #e0e0e0;
  padding: 0 8px;
  text-align: center;
  font-size: 12px;
  cursor: pointer;
  user-select: none;
}
.station-card .port-pill:hover { filter: brightness(0.98); }
.station-card .port-offline { background: #f5f5f5; color: #888; }
.station-card .port-idle { background: #e8f7e8; color: #2e7d32; border-color: #b7e1b7; }
.station-card .port-charging { background: #fff3e6; color: #ad4e00; border-color: #ffd8bf; }

/* 模态框 */
.modal { display: none; }
.modal.show { display: block; }
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.35);
}
.modal-dialog {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: #fff;
  border-radius: 12px;
  width: min(520px, 92vw);
  box-shadow: 0 10px 30px rgba(0,0,0,0.15);
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid #eee;
}
.modal-title { font-size: 16px; font-weight: 600; }
.modal-close {
  background: transparent;
  border: none;
  font-size: 20px;
  cursor: pointer;
}
.modal-body { padding: 16px; font-size: 14px; color: #333; }
.modal-body .row { display: flex; justify-content: space-between; margin-bottom: 8px; }
.modal-body .row .label { color: #666; }
.modal-body .row .value { font-weight: 600; }

/* 偏好设置模态专属样式 */
#pref-modal .pref-desc {
  margin-bottom: 12px;
  color: #555;
  font-size: 14px;
}
#pref-modal .modal-body .row {
  display: grid;
  grid-template-columns: 100px 1fr;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}
#pref-modal label {
  color: #333;
  font-weight: 500;
}
#pref-modal select {
  height: 36px;
  border: 1px solid #ddd;
  border-radius: 8px;
  padding: 0 10px;
  outline: none;
  background: #fff;
}
#pref-modal select:focus {
  border-color: #2a5298;
  box-shadow: 0 0 0 2px rgba(42,82,152,0.1);
}
#pref-modal .modal-footer {
  padding: 12px 16px;
  border-top: 1px solid #eee;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}
#pref-modal .modal-footer .btn {
  min-width: 88px;
  height: 36px;
  padding: 0 14px;
  border-radius: 8px;
  border: 1px solid #1e3c72;
  background: linear-gradient(90deg, #2a5298, #1e3c72);
  color: #fff;
  cursor: pointer;
}
#pref-modal .modal-footer .btn:hover { filter: brightness(0.98); }

@media (max-width: 768px) {
  .stations { grid-template-columns: 1fr; }
  .campus-tabs .tab { font-size: 15px; padding: 10px 18px; }
  .region-item { font-size: 15px; padding: 10px 16px; }
  .station-card { padding: 14px; }
  .station-card .right { min-width: 100px; }
  .station-card .ports { gap: 6px; }
  .modal-dialog { width: 94vw; }
}

/* 更小屏幕的移动端优化 */
@media (max-width: 480px) {
  /* 卡片改为上下布局，避免左右挤压 */
  .station-card { flex-direction: column; align-items: flex-start; gap: 8px; }
  .station-card .right { text-align: left; min-width: 0; width: 100%; }
  .station-card .ports { margin-top: 4px; gap: 6px; }
  /* 端口标签增大可点击面积并紧凑排列 */
  .station-card .port-pill { height: 32px; line-height: 32px; border-radius: 999px; font-size: 13px; padding: 0 10px; }
  /* 模态框在手机上靠近顶部并限制高度，支持滚动 */
  .modal-dialog { width: 96vw; top: 8%; left: 50%; transform: translate(-50%, 0); max-height: 84vh; overflow: auto; }
  .modal-body .row { flex-direction: column; align-items: flex-start; gap: 6px; }
}

/* 使用限制弹窗（配额超限） */
.quota-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.35);
  z-index: 998;
}
.quota-backdrop.show { display: block; animation: quota-fade 0.18s ease-out; }

.quota-modal {
  display: none;
  position: fixed;
  left: 50%;
  top: 18%;
  transform: translateX(-50%);
  background: #fff;
  border-radius: 12px;
  border: 1px solid #eee;
  overflow: hidden;
  width: min(520px, 92vw);
  box-shadow: 0 10px 30px rgba(0,0,0,0.15);
  z-index: 999;
}
.quota-modal.show { display: block; animation: quota-appear 0.2s ease-out; }

.quota-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid #eee;
  font-weight: 600;
  font-size: 16px;
  background: linear-gradient(180deg, #fff, #fff 60%, #fafafa);
}
.quota-title {
  color: #d4380d;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.quota-title::before {
  content: '⚠️';
  font-size: 18px;
  line-height: 1;
}
.quota-close {
  border: none;
  background: transparent;
  font-size: 20px;
  cursor: pointer;
  color: #666;
}
.quota-close:hover { color: #000; }

.quota-body { padding: 16px 18px; color: #333; font-size: 14px; line-height: 1.7; }
.quota-message {
  margin-bottom: 14px;
  background: #fff2e8;
  border: 1px solid #ffd8bf;
  color: #ad4e00;
  border-radius: 8px;
  padding: 10px 12px;
}
.quota-contact {
  background: #fafafa;
  border: 1px solid #eee;
  border-radius: 8px;
  padding: 12px;
}
.quota-contact-title { font-weight: 600; margin-bottom: 6px; color: #444; }
.quota-contact-info { white-space: pre-wrap; line-height: 1.6; }

.quota-footer {
  padding: 12px 18px;
  border-top: 1px solid #eee;
  text-align: right;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}
.quota-link {
  color: #2a5298;
  text-decoration: none;
  border: 1px solid #d9d9d9;
  background: #fff;
  border-radius: 6px;
  padding: 6px 12px;
}
.quota-link:hover { background: #f7f7f7; }
.quota-ok {
  border: 1px solid #1e3c72;
  background: linear-gradient(90deg, #2a5298, #1e3c72);
  color: #fff;
  border-radius: 6px;
  padding: 6px 14px;
  cursor: pointer;
}
.quota-ok:hover { filter: brightness(0.98); }

@keyframes quota-appear {
  from { opacity: 0; transform: translateX(-50%) translateY(-4px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}
@keyframes quota-fade {
  from { opacity: 0; }
  to { opacity: 1; }
}

@media (max-width: 480px) {
  .quota-modal { top: 8%; width: 96vw; }
}