/* ═══════════════════════════════════════════════
   台股投資分析報告 — 網頁樣式
   ═══════════════════════════════════════════════ */

/* ── Reset & Base ─────────────────────────── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --c-primary:    #1a5276;
  --c-secondary:  #2e86c1;
  --c-accent:     #e74c3c;
  --c-green:      #27ae60;
  --c-bg:         #f0f3f8;
  --c-surface:    #ffffff;
  --c-text:       #2c3e50;
  --c-text-light: #7f8c8d;
  --c-border:     #dce1e8;
  --radius:       12px;
  --radius-sm:    8px;
  --shadow:       0 2px 12px rgba(0,0,0,0.08);
  --shadow-lg:    0 8px 30px rgba(0,0,0,0.12);
  --font: "Microsoft JhengHei", "PingFang TC", "Heiti TC",
          -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body {
  font-family: var(--font);
  background: var(--c-bg);
  color: var(--c-text);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ── Header ───────────────────────────────── */
.header {
  background: linear-gradient(135deg, var(--c-primary) 0%, var(--c-secondary) 100%);
  color: #fff;
  padding: 18px 0;
  box-shadow: 0 2px 20px rgba(26,82,118,0.3);
}
.header-inner {
  max-width: 960px;
  margin: 0 auto;
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.logo {
  display: flex;
  align-items: center;
  gap: 14px;
}
.logo-icon {
  font-size: 2rem;
}
.logo h1 {
  font-size: 1.4rem;
  font-weight: 700;
  letter-spacing: 0.5px;
}
.subtitle {
  font-size: 0.8rem;
  opacity: 0.85;
  margin-top: 2px;
}
.badge {
  background: rgba(255,255,255,0.2);
  border: 1px solid rgba(255,255,255,0.3);
  border-radius: 20px;
  padding: 4px 14px;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.5px;
}

/* ── Container ────────────────────────────── */
.container {
  max-width: 960px;
  margin: 0 auto;
  padding: 30px 24px;
  flex: 1;
}

/* ── Search Section ───────────────────────── */
.search-section {
  margin-bottom: 40px;
}
.search-card {
  background: var(--c-surface);
  border-radius: var(--radius);
  padding: 36px;
  box-shadow: var(--shadow);
  border: 1px solid var(--c-border);
}
.search-card h2 {
  font-size: 1.3rem;
  color: var(--c-primary);
  margin-bottom: 8px;
}
.search-hint {
  color: var(--c-text-light);
  font-size: 0.85rem;
  margin-bottom: 24px;
}
.search-hint code {
  background: #eef2f7;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 0.85rem;
  color: var(--c-secondary);
  font-weight: 600;
}

.search-form {
  margin-bottom: 20px;
}
.input-group {
  display: flex;
  gap: 12px;
}
.input-group input {
  flex: 1;
  padding: 14px 18px;
  border: 2px solid var(--c-border);
  border-radius: var(--radius-sm);
  font-size: 1.05rem;
  font-family: var(--font);
  transition: border-color 0.2s, box-shadow 0.2s;
  outline: none;
}
.input-group input:focus {
  border-color: var(--c-secondary);
  box-shadow: 0 0 0 3px rgba(46,134,193,0.15);
}
.input-group input::placeholder {
  color: #b0bec5;
}

/* ── Quick Pick ───────────────────────────── */
.quick-pick {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}
.quick-label {
  font-size: 0.8rem;
  color: var(--c-text-light);
  margin-right: 4px;
}
.chip {
  background: #eef2f7;
  border: 1px solid transparent;
  border-radius: 20px;
  padding: 5px 14px;
  font-size: 0.82rem;
  font-family: var(--font);
  color: var(--c-primary);
  cursor: pointer;
  transition: all 0.15s;
}
.chip:hover {
  background: var(--c-secondary);
  color: #fff;
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(46,134,193,0.3);
}

/* ── Buttons ──────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 14px 28px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  font-weight: 600;
  font-family: var(--font);
  cursor: pointer;
  transition: all 0.2s;
  text-decoration: none;
  white-space: nowrap;
}
.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}
.btn-primary {
  background: linear-gradient(135deg, var(--c-secondary), var(--c-primary));
  color: #fff;
}
.btn-primary:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(26,82,118,0.35);
}
.btn-pdf {
  background: linear-gradient(135deg, var(--c-accent), #c0392b);
  color: #fff;
}
.btn-pdf:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(231,76,60,0.35);
}
.btn-html {
  background: linear-gradient(135deg, var(--c-green), #1e8449);
  color: #fff;
}
.btn-html:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(39,174,96,0.35);
}
.btn-html-outline {
  background: transparent;
  color: var(--c-green);
  border: 2px solid var(--c-green);
}
.btn-html-outline:hover {
  background: var(--c-green);
  color: #fff;
}
.btn-ghost {
  background: transparent;
  color: var(--c-text-light);
  border: 1px solid var(--c-border);
  padding: 10px 20px;
  font-size: 0.85rem;
}
.btn-ghost:hover {
  background: #eef2f7;
  color: var(--c-text);
}
.btn-icon {
  font-size: 1.1rem;
}

/* ── Spinner ──────────────────────────────── */
.spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ── Progress Section ─────────────────────── */
.progress-section {
  margin-bottom: 40px;
}
.progress-card {
  background: var(--c-surface);
  border-radius: var(--radius);
  padding: 36px;
  box-shadow: var(--shadow);
  border: 1px solid var(--c-border);
}
.progress-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}
.progress-header h3 {
  font-size: 1.1rem;
  color: var(--c-primary);
}
.progress-pct {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--c-secondary);
  font-variant-numeric: tabular-nums;
}
.progress-bar-bg {
  width: 100%;
  height: 12px;
  background: #eef2f7;
  border-radius: 6px;
  overflow: hidden;
  margin-bottom: 12px;
}
.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--c-secondary), var(--c-primary));
  border-radius: 6px;
  transition: width 0.4s ease;
}
.progress-step {
  font-size: 0.9rem;
  color: var(--c-text-light);
  min-height: 1.4em;
}

/* ── Result Section ───────────────────────── */
.result-section {
  margin-bottom: 40px;
}
.result-card {
  background: var(--c-surface);
  border-radius: var(--radius);
  padding: 36px;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--c-border);
}
.result-header {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 28px;
}
.result-icon {
  font-size: 2.5rem;
}
.result-header h3 {
  font-size: 1.3rem;
  color: var(--c-primary);
}
.result-header p {
  color: var(--c-text-light);
  font-size: 0.85rem;
  margin-top: 4px;
}
.result-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 24px;
}
.result-warnings {
  background: #fff8e1;
  border: 1px solid #ffcc02;
  border-radius: var(--radius-sm);
  padding: 16px 20px;
  margin-bottom: 20px;
}
.result-warnings h4 {
  font-size: 0.85rem;
  color: #f57f17;
  margin-bottom: 8px;
}
.result-warnings ul {
  padding-left: 20px;
}
.result-warnings li {
  font-size: 0.8rem;
  color: #795548;
  margin-bottom: 4px;
}
.result-footer {
  border-top: 1px solid var(--c-border);
  padding-top: 20px;
  display: flex;
  justify-content: center;
}

/* ── Error Section ────────────────────────── */
.error-section {
  margin-bottom: 40px;
}
.error-card {
  background: #fef2f2;
  border: 1px solid #fcc;
  border-radius: var(--radius);
  padding: 36px;
  text-align: center;
}
.error-icon {
  font-size: 2.5rem;
  margin-bottom: 12px;
}
.error-card h3 {
  color: var(--c-accent);
  margin-bottom: 8px;
}
.error-card p {
  color: #c0392b;
  font-size: 0.9rem;
  margin-bottom: 20px;
}

/* ── Features Section ─────────────────────── */
.features-section {
  margin-top: 20px;
}
.features-section h2 {
  font-size: 1.2rem;
  color: var(--c-primary);
  margin-bottom: 20px;
  text-align: center;
}
.features-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
}
.feature-card {
  background: var(--c-surface);
  border-radius: var(--radius-sm);
  padding: 20px;
  box-shadow: var(--shadow);
  border: 1px solid var(--c-border);
  text-align: center;
  transition: transform 0.15s;
}
.feature-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}
.feature-icon {
  font-size: 1.8rem;
  margin-bottom: 10px;
}
.feature-card h4 {
  font-size: 0.9rem;
  color: var(--c-primary);
  margin-bottom: 6px;
}
.feature-card p {
  font-size: 0.78rem;
  color: var(--c-text-light);
  line-height: 1.5;
}

/* ── Footer ───────────────────────────────── */
.footer {
  background: var(--c-surface);
  border-top: 1px solid var(--c-border);
  padding: 24px;
  text-align: center;
  margin-top: auto;
}
.footer p {
  font-size: 0.78rem;
  color: var(--c-text-light);
  margin-bottom: 4px;
}
.footer-meta {
  font-size: 0.7rem !important;
  opacity: 0.7;
}

/* ── Responsive ───────────────────────────── */
@media (max-width: 640px) {
  .header-inner {
    flex-direction: column;
    gap: 10px;
    text-align: center;
  }
  .logo {
    flex-direction: column;
  }
  .input-group {
    flex-direction: column;
  }
  .search-card, .progress-card, .result-card {
    padding: 24px 18px;
  }
  .result-actions {
    flex-direction: column;
  }
  .result-actions .btn {
    justify-content: center;
  }
  .features-grid {
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  }
  .quick-pick {
    justify-content: center;
  }
}
