/* ============ AI 塔罗牌 · 主样式表 ============ */

:root {
  --bg-dark: #1a1625;
  --bg-darker: #13101a;
  --bg-card: #2a2438;
  --bg-card-hover: #352e4a;
  --border: #3d3550;
  --border-soft: #2d2740;
  --text-primary: #e8e4f0;
  --text-secondary: #a89ec0;
  --text-muted: #7a7294;
  --accent: #c8a15c;
  --accent-soft: #e8c888;
  --accent-dark: #8b6f3f;
  --purple: #8b7fb8;
  --purple-soft: #a598d4;
  --success: #6bb89f;
  --warning: #d4a55b;
  --danger: #c67b8a;
  --card-face: #f5efdc;
  --card-face-dark: #2a1f3a;
  --card-edge: #8b6f3f;
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 8px 48px rgba(0, 0, 0, 0.5);
  --shadow-gold: 0 4px 24px rgba(200, 161, 92, 0.3);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: -apple-system, "PingFang SC", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  background: linear-gradient(135deg, var(--bg-darker) 0%, var(--bg-dark) 50%, #1d1829 100%);
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.6;
  font-size: 15px;
}

/* ============ 顶部导航 ============ */
.app-header {
  background: linear-gradient(180deg, rgba(30, 25, 45, 0.95) 0%, rgba(26, 22, 37, 0.9) 100%);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(10px);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-content {
  max-width: 1400px;
  margin: 0 auto;
  padding: 1rem 2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 2rem;
  flex-wrap: wrap;
}

.logo {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.logo-symbol {
  font-size: 1.8rem;
  color: var(--accent);
  text-shadow: 0 0 20px rgba(200, 161, 92, 0.5);
}

.logo h1 {
  font-size: 1.4rem;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: 0.05em;
}

.logo .subtitle {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-left: 0.5rem;
}

.nav {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.nav-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-secondary);
  padding: 0.5rem 1rem;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.9rem;
  transition: all 0.2s ease;
}

.nav-btn:hover {
  background: var(--bg-card);
  color: var(--text-primary);
  border-color: var(--accent);
}

.nav-btn.active {
  background: linear-gradient(135deg, var(--accent-dark) 0%, var(--accent) 100%);
  color: var(--bg-darker);
  border-color: var(--accent);
  font-weight: 500;
}

/* ============ 主内容区 ============ */
.app-main {
  max-width: 1400px;
  margin: 0 auto;
  padding: 2rem;
  min-height: calc(100vh - 160px);
}

.view {
  display: none;
  animation: fadeIn 0.3s ease;
}

.view.active {
  display: block;
}

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

/* ============ 通用面板样式 ============ */
.panel {
  background: linear-gradient(180deg, var(--bg-card) 0%, var(--bg-darker) 100%);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 2rem;
  box-shadow: var(--shadow);
}

.panel-title {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border-soft);
}

.title-icon {
  font-size: 1.5rem;
}

.panel-title h2,
.panel-title h3 {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--accent-soft);
}

.hint-text {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-left: auto;
}

/* ============ 解读视图布局 ============ */
.reading-container {
  display: grid;
  grid-template-columns: 380px 1fr;
  gap: 1.5rem;
}

@media (max-width: 1100px) {
  .reading-container {
    grid-template-columns: 1fr;
  }
}

/* ============ 表单组 ============ */
.form-group {
  margin-bottom: 1.5rem;
}

.form-group label {
  display: block;
  font-size: 0.9rem;
  color: var(--text-secondary);
  margin-bottom: 0.5rem;
  font-weight: 500;
}

.form-group input[type="text"],
.form-group input[type="password"],
.form-group input[type="number"],
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 0.75rem 1rem;
  background: var(--bg-darker);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-primary);
  font-size: 0.95rem;
  font-family: inherit;
  transition: all 0.2s ease;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(200, 161, 92, 0.15);
}

.form-group textarea {
  resize: vertical;
  min-height: 60px;
}

.hint {
  font-size: 0.8rem;
  color: var(--warning);
  margin-top: 0.5rem;
  min-height: 1.2em;
}

.hint.success {
  color: var(--success);
}

/* ============ 牌阵选择 ============ */
.spread-options {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.5rem;
}

.spread-option {
  padding: 1rem;
  background: var(--bg-darker);
  border: 1px solid var(--border);
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: left;
}

.spread-option:hover {
  background: var(--bg-card-hover);
  border-color: var(--purple);
}

.spread-option.selected {
  background: linear-gradient(135deg, rgba(200, 161, 92, 0.15) 0%, rgba(139, 111, 63, 0.1) 100%);
  border-color: var(--accent);
  box-shadow: var(--shadow-gold);
}

.spread-option h4 {
  font-size: 1rem;
  color: var(--text-primary);
  margin-bottom: 0.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.spread-option .card-count {
  font-size: 0.8rem;
  color: var(--accent);
  background: rgba(200, 161, 92, 0.15);
  padding: 0.15rem 0.5rem;
  border-radius: 20px;
}

.spread-option p {
  font-size: 0.82rem;
  color: var(--text-muted);
  line-height: 1.5;
}

/* ============ 按钮 ============ */
.primary-btn,
.secondary-btn,
.text-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.85rem 1.5rem;
  border-radius: 10px;
  font-size: 1rem;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.2s ease;
  border: none;
  font-weight: 500;
}

.primary-btn {
  background: linear-gradient(135deg, var(--accent-dark) 0%, var(--accent) 100%);
  color: var(--bg-darker);
  width: 100%;
  margin-top: 1rem;
}

.primary-btn:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-gold);
}

.primary-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

.secondary-btn {
  background: var(--bg-card);
  color: var(--text-primary);
  border: 1px solid var(--border);
}

.secondary-btn:hover {
  background: var(--bg-card-hover);
  border-color: var(--accent);
}

.text-btn {
  background: transparent;
  color: var(--text-muted);
  padding: 0.25rem 0.5rem;
  font-size: 0.85rem;
  margin-top: 0.5rem;
}

.text-btn:hover {
  color: var(--accent);
}

/* ============ 选项行 ============ */
.options-row {
  display: flex;
  gap: 1.5rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}

.toggle-option {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  font-size: 0.9rem;
  color: var(--text-secondary);
}

.toggle-option input[type="checkbox"] {
  width: 18px;
  height: 18px;
  cursor: pointer;
  accent-color: var(--accent);
}

/* ============ 抽牌区域 ============ */
.draw-area {
  min-height: 300px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at center, rgba(139, 127, 184, 0.08) 0%, transparent 70%);
  border-radius: 12px;
  margin: 1rem 0;
}

.deck-placeholder {
  text-align: center;
  padding: 3rem;
}

.deck-illustration {
  font-size: 5rem;
  opacity: 0.4;
  margin-bottom: 1rem;
  animation: float 3s ease-in-out infinite;
}

@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-10px); }
}

.deck-hint {
  color: var(--text-muted);
  font-size: 1rem;
}

/* ============ 抽牌动画 ============ */
.cards-display {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  justify-content: center;
  align-items: flex-start;
  padding: 1.5rem 0;
}

.tarot-card {
  width: 160px;
  height: 280px;
  perspective: 1000px;
  cursor: pointer;
  flex-shrink: 0;
}

.card-inner {
  position: relative;
  width: 100%;
  height: 100%;
  transition: transform 0.8s cubic-bezier(0.4, 0, 0.2, 1);
  transform-style: preserve-3d;
}

.tarot-card.flipped .card-inner {
  transform: rotateY(180deg);
}

.tarot-card.reversed .card-face-front {
  transform: rotateY(180deg) rotate(180deg);
}

.card-face {
  position: absolute;
  width: 100%;
  height: 100%;
  backface-visibility: hidden;
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: var(--shadow-lg);
}

.card-face-back {
  background: linear-gradient(135deg, #2a1f3a 0%, #1a1625 50%, #2a1f3a 100%);
  border: 2px solid var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
}

.card-back-pattern {
  width: 80%;
  height: 80%;
  border: 1px solid var(--accent);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 3rem;
  color: var(--accent);
  opacity: 0.7;
  background: repeating-linear-gradient(
    45deg,
    transparent,
    transparent 10px,
    rgba(200, 161, 92, 0.05) 10px,
    rgba(200, 161, 92, 0.05) 20px
  );
}

.card-face-front {
  background: linear-gradient(180deg, var(--card-face) 0%, #ebe2c8 100%);
  border: 2px solid var(--card-edge);
  transform: rotateY(180deg);
  color: #2a1f3a;
  padding: 0.75rem;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.card-position-label {
  font-size: 0.7rem;
  color: var(--accent-dark);
  text-align: center;
  margin-bottom: 0.5rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid rgba(139, 111, 63, 0.3);
  width: 100%;
  font-weight: 600;
  letter-spacing: 0.05em;
}

.card-symbol {
  font-size: 2.5rem;
  margin: 0.5rem 0;
  text-align: center;
}

.card-name {
  font-size: 0.95rem;
  font-weight: 600;
  text-align: center;
  color: #2a1f3a;
  margin-bottom: 0.25rem;
}

.card-name-en {
  font-size: 0.7rem;
  color: #6b5a38;
  text-align: center;
  margin-bottom: 0.5rem;
  font-style: italic;
}

.card-keywords {
  font-size: 0.72rem;
  text-align: center;
  color: #8b6f3f;
  padding: 0.5rem;
  background: rgba(139, 111, 63, 0.08);
  border-radius: 6px;
  margin-top: auto;
  line-height: 1.4;
}

.card-orientation {
  font-size: 0.65rem;
  text-align: center;
  color: #a08040;
  margin-top: 0.25rem;
  font-weight: 600;
  letter-spacing: 0.1em;
}

.tarot-card:hover:not(.flipped) .card-inner {
  transform: translateY(-5px) scale(1.02);
}

.tarot-card.flipped:hover .card-inner {
  transform: rotateY(180deg) translateY(-3px);
}

/* ============ AI 解读输出 ============ */
.reading-area {
  margin-top: 2rem;
}

.reading-output {
  background: var(--bg-darker);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.5rem;
  line-height: 1.8;
  font-size: 0.95rem;
  white-space: pre-wrap;
  min-height: 200px;
}

.reading-output h1,
.reading-output h2,
.reading-output h3,
.reading-output h4 {
  color: var(--accent-soft);
  margin: 1.5rem 0 0.75rem;
}

.reading-output h1 { font-size: 1.4rem; }
.reading-output h2 { font-size: 1.2rem; }
.reading-output h3 { font-size: 1.1rem; }
.reading-output h4 { font-size: 1rem; }

.reading-output p {
  margin-bottom: 1rem;
  color: var(--text-primary);
}

.reading-output strong {
  color: var(--accent);
}

.reading-output ul,
.reading-output ol {
  margin: 0.75rem 0 1rem;
  padding-left: 1.5rem;
}

.reading-output li {
  margin-bottom: 0.5rem;
  color: var(--text-primary);
}

.reading-output em {
  color: var(--text-secondary);
  font-style: italic;
}

.reading-actions {
  display: flex;
  gap: 1rem;
  margin-top: 1.5rem;
  flex-wrap: wrap;
}

/* ============ 历史记录 ============ */
.history-panel {
  max-width: 1000px;
  margin: 0 auto;
}

.history-list {
  display: grid;
  gap: 1rem;
}

.history-item {
  background: var(--bg-darker);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.5rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

.history-item:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
}

.history-question {
  font-size: 1.05rem;
  color: var(--text-primary);
  margin-bottom: 0.5rem;
  font-weight: 500;
}

.history-meta {
  display: flex;
  gap: 1rem;
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
}

.history-cards {
  font-size: 0.85rem;
  color: var(--text-secondary);
  padding: 0.5rem 0.75rem;
  background: rgba(139, 127, 184, 0.1);
  border-radius: 6px;
  margin-top: 0.5rem;
}

.history-delete {
  float: right;
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1.2rem;
  padding: 0 0.5rem;
  transition: color 0.2s;
}

.history-delete:hover {
  color: var(--danger);
}

.empty-state {
  text-align: center;
  padding: 3rem;
  color: var(--text-muted);
  font-size: 1rem;
}

/* ============ AI 配置面板 ============ */
.settings-container {
  max-width: 800px;
  margin: 0 auto;
}

.settings-actions {
  display: flex;
  gap: 1rem;
  align-items: center;
  margin-top: 1rem;
  flex-wrap: wrap;
}

.status-text {
  font-size: 0.9rem;
  color: var(--text-muted);
}

.status-text.success {
  color: var(--success);
}

.status-text.error {
  color: var(--danger);
}

.privacy-note {
  background: rgba(107, 184, 159, 0.1);
  border: 1px solid rgba(107, 184, 159, 0.3);
  border-radius: 10px;
  padding: 1rem;
  margin-top: 2rem;
  font-size: 0.9rem;
  color: var(--text-secondary);
  line-height: 1.6;
}

/* ============ 使用指南 ============ */
.guide-panel {
  max-width: 900px;
  margin: 0 auto;
}

.guide-content {
  line-height: 1.8;
  font-size: 0.95rem;
}

.guide-content h3 {
  color: var(--accent-soft);
  font-size: 1.15rem;
  margin: 2rem 0 0.75rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border-soft);
}

.guide-content h3:first-child {
  margin-top: 0;
}

.guide-content p {
  color: var(--text-primary);
  margin-bottom: 1rem;
}

.guide-content ul,
.guide-content ol {
  padding-left: 1.5rem;
  margin-bottom: 1rem;
  color: var(--text-secondary);
}

.guide-content li {
  margin-bottom: 0.5rem;
}

.guide-content strong {
  color: var(--accent);
}

/* ============ 加载遮罩 ============ */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(15, 12, 25, 0.85);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  animation: fadeIn 0.2s ease;
}

.loading-modal {
  text-align: center;
  padding: 3rem;
}

.loading-spinner {
  width: 60px;
  height: 60px;
  border: 4px solid rgba(200, 161, 92, 0.2);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin: 0 auto 1.5rem;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.loading-text {
  font-size: 1.1rem;
  color: var(--accent-soft);
}

/* ============ 页脚 ============ */
.app-footer {
  text-align: center;
  padding: 2rem;
  color: var(--text-muted);
  font-size: 0.85rem;
  border-top: 1px solid var(--border-soft);
  margin-top: 2rem;
}

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

::-webkit-scrollbar-track {
  background: var(--bg-darker);
}

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

::-webkit-scrollbar-thumb:hover {
  background: var(--accent-dark);
}

/* ============ 响应式调整 ============ */
@media (max-width: 768px) {
  .app-main {
    padding: 1rem;
  }

  .panel {
    padding: 1.25rem;
  }

  .header-content {
    padding: 1rem;
    flex-direction: column;
    gap: 1rem;
  }

  .logo .subtitle {
    display: none;
  }

  .tarot-card {
    width: 130px;
    height: 230px;
  }

  .card-symbol {
    font-size: 2rem;
  }

  .card-name {
    font-size: 0.85rem;
  }

  .reading-container {
    grid-template-columns: 1fr;
  }
}
