/* ========== 全局样式 ========== */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: #f0f2f5;
  color: #333;
  min-height: 100vh;
}

.app {
  max-width: 480px;
  margin: 0 auto;
  padding: 16px;
}

/* ========== Header ========== */
.header {
  text-align: center;
  padding: 20px 0 12px;
}

.header h1 {
  font-size: 22px;
  color: #1a1a1a;
  font-weight: 600;
}

/* ========== Tabs ========== */
.tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  background: #fff;
  border-radius: 12px;
  padding: 4px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.tab {
  flex: 1;
  padding: 10px 0;
  border: none;
  background: transparent;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 500;
  color: #666;
  cursor: pointer;
  transition: all 0.2s;
}

.tab.active {
  background: #4A90D9;
  color: #fff;
  box-shadow: 0 2px 6px rgba(74, 144, 217, 0.3);
}

.tab:not(.active):hover {
  background: #f0f2f5;
}

/* ========== Pages ========== */
.page {
  display: none;
}

.page.active {
  display: block;
}

/* ========== Card ========== */
.card {
  background: #fff;
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 12px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

/* ========== 生成页面 ========== */
.label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: #666;
  margin-bottom: 8px;
}

#url-input {
  width: 100%;
  padding: 12px 14px;
  border: 1.5px solid #e0e0e0;
  border-radius: 8px;
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s;
  margin-bottom: 12px;
}

#url-input:focus {
  border-color: #4A90D9;
}

#url-input::placeholder {
  color: #bbb;
}

.btn-primary {
  width: 100%;
  padding: 12px;
  background: #4A90D9;
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s;
}

.btn-primary:hover {
  background: #3a7bc8;
}

.btn-primary:active {
  background: #2d6ab5;
}

.btn-primary:disabled {
  background: #a0c4e8;
  cursor: not-allowed;
}

/* ========== 结果区域 ========== */
.result-area {
  animation: fadeIn 0.3s ease;
}

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

.result-row {
  margin-bottom: 16px;
}

.short-url-box {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #f8f9fa;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid #e8e8e8;
}

.short-url-box a {
  flex: 1;
  color: #4A90D9;
  text-decoration: none;
  font-size: 14px;
  word-break: break-all;
}

.short-url-box a:hover {
  text-decoration: underline;
}

.btn-small {
  padding: 6px 10px;
  background: #f0f2f5;
  border: 1px solid #e0e0e0;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  transition: background 0.2s;
  flex-shrink: 0;
}

.btn-small:hover {
  background: #e4e6e9;
}

/* ========== 二维码区域 ========== */
.qr-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

#qrcode {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 12px;
  background: #fff;
  border-radius: 8px;
  border: 1px solid #eee;
}

#qrcode img,
#qrcode canvas {
  border-radius: 4px;
}

#note-input {
  width: 100%;
  padding: 10px 12px;
  border: 1.5px solid #e0e0e0;
  border-radius: 8px;
  font-size: 14px;
  resize: vertical;
  outline: none;
  font-family: inherit;
  transition: border-color 0.2s;
}

#note-input:focus {
  border-color: #4A90D9;
}

.btn-secondary {
  width: 100%;
  padding: 10px;
  background: #f8f9fa;
  color: #333;
  border: 1.5px solid #e0e0e0;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-secondary:hover {
  background: #eef0f2;
  border-color: #ccc;
}

/* ========== 历史管理页面 ========== */
.history-item {
  background: #fff;
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 10px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
  cursor: pointer;
  transition: box-shadow 0.2s;
}

.history-item:hover {
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
}

.history-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

.history-info {
  flex: 1;
  min-width: 0;
}

.history-short {
  font-size: 15px;
  font-weight: 500;
  color: #4A90D9;
  word-break: break-all;
  margin-bottom: 4px;
}

.history-long {
  font-size: 12px;
  color: #999;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin-bottom: 4px;
}

.history-time {
  font-size: 11px;
  color: #bbb;
}

.history-note {
  font-size: 12px;
  color: #666;
  margin-top: 4px;
  font-style: italic;
}

.history-thumb {
  width: 48px;
  height: 48px;
  border-radius: 6px;
  border: 1px solid #eee;
  flex-shrink: 0;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #fafafa;
}

.history-thumb img,
.history-thumb canvas {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

/* 历史详情展开 */
.history-detail {
  display: none;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid #f0f0f0;
  animation: fadeIn 0.2s ease;
}

.history-detail.show {
  display: block;
}

.detail-qr {
  display: flex;
  justify-content: center;
  margin-bottom: 12px;
}

.detail-long-url {
  font-size: 13px;
  color: #555;
  word-break: break-all;
  background: #f8f9fa;
  padding: 8px 10px;
  border-radius: 6px;
  margin-bottom: 8px;
}

.detail-actions {
  display: flex;
  gap: 8px;
}

.detail-actions button {
  flex: 1;
  padding: 8px;
  border-radius: 6px;
  font-size: 13px;
  cursor: pointer;
  border: 1px solid #e0e0e0;
  background: #f8f9fa;
  transition: background 0.2s;
}

.detail-actions button:hover {
  background: #eef0f2;
}

.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: #bbb;
}

.empty-state span {
  font-size: 48px;
  display: block;
  margin-bottom: 12px;
}

.empty-state p {
  font-size: 15px;
}

/* ========== Toast ========== */
.toast {
  position: fixed;
  bottom: 40px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: rgba(0, 0, 0, 0.75);
  color: #fff;
  padding: 10px 20px;
  border-radius: 8px;
  font-size: 14px;
  opacity: 0;
  pointer-events: none;
  transition: all 0.3s;
  z-index: 1000;
  white-space: nowrap;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ========== 响应式 ========== */
@media (max-width: 360px) {
  .app {
    padding: 10px;
  }

  .card {
    padding: 16px;
  }

  .header h1 {
    font-size: 20px;
  }
}
