/* ============================================
   时光胶囊 - 主样式表
   温暖优雅的editorial风格
   ============================================ */

@import url('https://fonts.googleapis.com/css2?family=Fraunces:ital,wght@0,400;0,500;1,400;1,500&family=Inter:wght@300;400;500;600&display=swap');

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

:root {
  --bg-warm: #F7F4EF;
  --surface-1: #FBF9F5;
  --surface-2: #FFFFFF;
  --border-warm: #E7E1D7;
  --text-ink: #1F2421;
  --text-muted: #5C635D;
  --accent-terracotta: #C4612F;
  --accent-hover: #A94E22;
  --accent-soft: #F2E3D6;
  --green: #34c759;
  --charcoal: #1F2421;
}

html, body {
  height: 100%;
  overflow: hidden;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "PingFang SC", sans-serif;
  font-weight: 300;
  color: var(--text-ink);
  background: var(--bg-warm);
  position: relative;
}

/* ========== 装饰性背景 ========== */
.orb {
  position: fixed;
  border-radius: 50%;
  opacity: 0.08;
  z-index: 0;
  pointer-events: none;
  background: var(--accent-terracotta);
}

.orb-1 {
  width: 500px;
  height: 500px;
  top: -200px;
  right: -100px;
  filter: blur(100px);
}

.orb-2 {
  width: 400px;
  height: 400px;
  bottom: -150px;
  left: -80px;
  filter: blur(90px);
}

.orb-3 {
  width: 300px;
  height: 300px;
  bottom: 30%;
  right: 20%;
  filter: blur(80px);
}

/* ========== 页面切换 ========== */
.page {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
  align-items: center;
  justify-content: center;
  padding: 20px;
  overflow-y: auto;
}

.page.active {
  display: flex;
  animation: pageIn 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

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

/* ========== 面板容器 ========== */
.glass-panel {
  background: var(--surface-2);
  border: 1px solid var(--border-warm);
  box-shadow: 0 2px 12px rgba(31, 36, 33, 0.06);
  border-radius: 16px;
  padding: clamp(32px, 5vmin, 48px);
  max-width: 480px;
  width: 100%;
  text-align: center;
  position: relative;
}

/* ========== 标题和文本 ========== */
h1 {
  font-family: 'Fraunces', serif;
  font-size: clamp(32px, 6vmin, 44px);
  font-weight: 400;
  letter-spacing: -0.03em;
  line-height: 1.15;
  margin-bottom: 12px;
  color: var(--text-ink);
}

h1 em {
  font-style: italic;
  color: var(--accent-terracotta);
  font-weight: 400;
}

.subtitle {
  color: var(--text-muted);
  font-size: clamp(15px, 2.4vmin, 17px);
  font-weight: 400;
  margin-bottom: 32px;
  line-height: 1.5;
}

.link-text {
  margin-top: 24px;
  font-size: 15px;
  color: var(--text-muted);
  font-weight: 400;
}

.link-text a {
  color: var(--accent-terracotta);
  text-decoration: none;
  font-weight: 500;
  transition: color 0.2s;
  border-bottom: 1px solid transparent;
}

.link-text a:hover {
  color: var(--accent-hover);
  border-bottom-color: var(--accent-hover);
}

/* ========== 表单样式 ========== */
.form {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-bottom: 24px;
  text-align: left;
}

.input-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.input-group label {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-ink);
  padding-left: 4px;
}

.input-group input,
.input-group textarea,
.input-group select {
  font-family: 'Inter', sans-serif;
  font-size: 16px;
  font-weight: 400;
  padding: 14px 16px;
  border: 1px solid var(--border-warm);
  border-radius: 8px;
  background: var(--surface-1);
  color: var(--text-ink);
  transition: all 0.2s ease;
  width: 100%;
}

.input-group input::placeholder,
.input-group textarea::placeholder {
  color: var(--text-muted);
  opacity: 0.7;
}

.input-group input:focus,
.input-group textarea:focus,
.input-group select:focus {
  outline: none;
  border-color: var(--accent-terracotta);
  background: var(--surface-2);
  box-shadow: 0 0 0 3px rgba(196, 97, 47, 0.1);
}

.input-group textarea {
  resize: vertical;
  min-height: 100px;
  line-height: 1.6;
}

/* ========== 按钮样式 ========== */
.btn {
  font-family: 'Inter', sans-serif;
  font-size: 16px;
  font-weight: 500;
  padding: 14px 32px;
  border: none;
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none !important;
}

.btn-primary {
  background: var(--accent-terracotta);
  color: #fff;
  box-shadow: 0 1px 3px rgba(31, 36, 33, 0.12);
}

.btn-primary:hover:not(:disabled) {
  background: var(--accent-hover);
  transform: translateY(-1px);
  box-shadow: 0 3px 8px rgba(31, 36, 33, 0.15);
}

.btn-primary:active:not(:disabled) {
  transform: translateY(0);
  box-shadow: 0 1px 2px rgba(31, 36, 33, 0.1);
}

.btn-secondary {
  background: var(--surface-1);
  color: var(--text-ink);
  border: 1px solid var(--border-warm);
}

.btn-secondary:hover {
  background: var(--surface-2);
  border-color: var(--accent-terracotta);
  color: var(--accent-terracotta);
}

.btn-small {
  font-size: 14px;
  padding: 8px 20px;
  border-radius: 999px;
  background: var(--surface-1);
  color: var(--text-ink);
  border: 1px solid var(--border-warm);
  font-weight: 500;
}

.btn-small:hover {
  background: var(--accent-soft);
  border-color: var(--accent-terracotta);
  color: var(--accent-terracotta);
  transform: translateY(-1px);
}

/* ========== 搜索结果和请求列表 ========== */
.search-results {
  text-align: left;
  margin: 16px 0;
  max-height: 300px;
  overflow-y: auto;
}

.search-results:empty {
  display: none;
}

.search-item,
.request-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px;
  background: var(--surface-1);
  border: 1px solid var(--border-warm);
  border-radius: 12px;
  margin-bottom: 12px;
  transition: all 0.2s ease;
}

.search-item:hover,
.request-item:hover {
  background: var(--surface-2);
  border-color: var(--accent-terracotta);
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(31, 36, 33, 0.08);
}

.user-name {
  font-weight: 500;
  font-size: 16px;
  color: var(--text-ink);
  margin-bottom: 4px;
}

.user-username {
  font-size: 14px;
  color: var(--text-muted);
  font-weight: 400;
}

.status-pending {
  font-size: 13px;
  color: var(--accent-terracotta);
  font-weight: 500;
  padding: 6px 14px;
  background: var(--accent-soft);
  border-radius: 999px;
}

.empty {
  text-align: center;
  padding: 32px;
  color: var(--text-muted);
  font-size: 15px;
  font-weight: 400;
}

#pendingRequests,
#sentRequests {
  margin-top: 28px;
}

#pendingRequests h3,
#sentRequests h3 {
  font-family: 'Fraunces', serif;
  font-size: 20px;
  font-weight: 400;
  margin-bottom: 16px;
  color: var(--text-ink);
}

#pendingRequests .request-item .btn {
  margin-left: 8px;
}

/* ========== 主页面样式 ========== */
#mainPage .glass-panel {
  max-width: 800px;
  padding: clamp(28px, 4vmin, 40px);
}

.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 32px;
  flex-wrap: wrap;
  gap: 16px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--border-warm);
}

.header h1 {
  margin: 0;
  font-size: clamp(28px, 5vmin, 36px);
}

.user-info {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.user-info span {
  font-size: 15px;
  font-weight: 500;
  color: var(--accent-terracotta);
  padding: 8px 16px;
  background: var(--accent-soft);
  border-radius: 999px;
}

/* ========== 消息表单 ========== */
.message-form {
  background: var(--surface-1);
  padding: 24px;
  border-radius: 12px;
  margin-bottom: 32px;
  border: 1px solid var(--border-warm);
}

.message-form textarea {
  width: 100%;
  font-family: 'Inter', sans-serif;
  font-size: 16px;
  font-weight: 400;
  padding: 14px 16px;
  border: 1px solid var(--border-warm);
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--text-ink);
  resize: vertical;
  min-height: 100px;
  line-height: 1.6;
  margin-bottom: 16px;
  transition: all 0.2s ease;
}

.message-form textarea:focus {
  outline: none;
  border-color: var(--accent-terracotta);
  box-shadow: 0 0 0 3px rgba(196, 97, 47, 0.1);
}

.form-row {
  display: flex;
  gap: 16px;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
}

.form-row .input-group {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 10px;
}

.form-row .input-group label {
  font-size: 15px;
  font-weight: 500;
  white-space: nowrap;
  color: var(--text-ink);
}

.form-row .input-group input[type="number"] {
  width: 80px;
  padding: 10px 14px;
}

.form-row .input-group span {
  font-size: 15px;
  color: var(--text-muted);
  font-weight: 400;
}

/* ========== 消息列表 ========== */
.message-list {
  max-height: 500px;
  overflow-y: auto;
  padding-right: 8px;
}

.message-item {
  background: var(--surface-1);
  border: 1px solid var(--border-warm);
  padding: 20px;
  border-radius: 12px;
  margin-bottom: 16px;
  transition: all 0.2s ease;
  animation: msgIn 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

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

.message-item:hover {
  background: var(--surface-2);
  border-color: var(--accent-terracotta);
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(31, 36, 33, 0.08);
}

.message-item.own {
  border-left: 3px solid var(--accent-terracotta);
}

.message-item.partner {
  border-left: 3px solid var(--green);
}

.message-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
  gap: 12px;
}

.message-header .sender {
  font-weight: 500;
  font-size: 16px;
  color: var(--text-ink);
}

.message-header .date {
  font-size: 14px;
  color: var(--text-muted);
  font-weight: 400;
}

.message-content {
  font-size: 15px;
  line-height: 1.7;
  color: var(--text-ink);
  margin-bottom: 14px;
  white-space: pre-wrap;
  word-wrap: break-word;
  font-weight: 400;
}

.message-locked {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px;
  background: var(--accent-soft);
  border-radius: 8px;
  margin-bottom: 12px;
}

.lock-icon {
  font-size: 28px;
  flex-shrink: 0;
}

.lock-text {
  font-size: 14px;
  color: var(--text-muted);
  line-height: 1.6;
  font-weight: 400;
}

.message-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.unlock-info {
  font-size: 14px;
  color: var(--green);
  font-weight: 500;
}

/* ========== 空状态 ========== */
.message-list .empty {
  padding: 64px 20px;
  text-align: center;
  color: var(--text-muted);
  font-size: 16px;
  font-weight: 400;
}

/* ========== 滚动条美化 ========== */
::-webkit-scrollbar {
  width: 8px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--border-warm);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}
