/* Letter Generator Styles */

:root {
  --color-brand: #0A73CC;
  --color-brand-bright: #4FB2FC;
  --color-secondary: #00D2E5;
  --color-text-strong: #3F3F46;
  --color-text-weak: #71717B;
  --color-stroke-strong: #91919A;
  --color-stroke-weak: #D4D4D8;
  --color-fill: #FAFAFA;
  --color-background: #FFFFFF;
  --color-badge-hover-bg: #E8F4FD;
  --color-brand-80: rgba(10, 115, 204, 0.8);
  --color-brand-12: rgba(10, 115, 204, 0.12);
  --font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

.dark-theme {
  --color-brand: #4FB2FC;
  --color-brand-bright: #4FB2FC;
  --color-secondary: #00D2E5;
  --color-text-strong: #FAFAFA;
  --color-text-weak: #D4D4D8;
  --color-stroke-strong: #91919A;
  --color-stroke-weak: #6C6C79;
  --color-fill: #3F3F46;
  --color-background: #27272A;
  --color-badge-hover-bg: rgba(79, 178, 252, 0.15);
  --color-brand-80: rgba(79, 178, 252, 0.8);
  --color-brand-12: rgba(79, 178, 252, 0.12);
}

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

body {
  font-family: var(--font-family);
}

.generator-container {
  font-family: var(--font-family);
  background: var(--color-background);
  min-height: 100vh;
  color: var(--color-text-strong);
}

.grid-container {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 24px;
}

.grid-content {
  grid-column: 3 / 11;
}

/* Preview Hero */
.preview-hero {
  background: var(--color-fill);
  border-bottom: 1px solid var(--color-stroke-weak);
  padding: 40px 24px;
}

.preview-hero-inner {
  max-width: 1200px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 32px;
  align-items: center;
}

.preview-hero-text {
  grid-column: 3 / 7;
}

.preview-hero-image {
  grid-column: 7 / 11;
}

.preview-hero-image img {
  width: 100%;
  height: auto;
  border-radius: 8px;
  border: 1px solid var(--color-stroke-weak);
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
}

.dark-theme .preview-hero-image img {
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.3);
}

.preview-hero-title {
  font-size: 22px;
  font-weight: 600;
  color: var(--color-text-strong);
  margin-bottom: 12px;
  line-height: 130%;
}

.preview-hero-desc {
  font-size: 15px;
  font-weight: 400;
  color: var(--color-text-weak);
  line-height: 160%;
  margin-bottom: 20px;
}

.preview-hero-highlight {
  font-weight: 600;
  color: var(--color-brand);
}

.preview-hero-cta {
  display: inline-block;
  padding: 10px 24px;
  background: var(--color-brand);
  color: #ffffff;
  text-decoration: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  transition: opacity 0.2s;
}

.preview-hero-cta:hover {
  opacity: 0.88;
}

/* Header */
.generator-header {
  background: var(--color-background);
  height: 64px;
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
}

.generator-header::after {
  content: '';
  position: absolute;
  bottom: -24px;
  left: 0;
  right: 0;
  height: 24px;
  background: linear-gradient(to bottom, var(--color-background) 0%, transparent 100%);
  pointer-events: none;
}

.header-wrapper {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 24px;
  display: flex;
  align-items: center;
  position: relative;
}

.header-content {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  width: 100%;
}

.header-inner {
  grid-column: 3 / 11;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: relative;
}

.logo-svg {
  height: 32px;
  width: auto;
  flex-shrink: 0;
}

.header-title {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  font-size: 16px;
  font-weight: 500;
  color: var(--color-text-strong);
  white-space: nowrap;
}

.logo-link {
  display: inline-flex;
  align-items: center;
  text-decoration: none;
  flex-shrink: 0;
  position: relative;
  z-index: 1;
}

.header-toggles {
  position: absolute;
  right: 24px;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  align-items: center;
  gap: 12px;
}

/* Theme Toggle */
.theme-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}

.theme-toggle-track {
  width: 44px;
  height: 24px;
  background: var(--color-stroke-weak);
  border-radius: 12px;
  position: relative;
  transition: background 0.3s ease;
}

.theme-toggle-track.dark {
  background: var(--color-brand);
}

.theme-toggle-thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 20px;
  height: 20px;
  background: var(--color-background);
  border-radius: 50%;
  transition: transform 0.3s ease, background 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.theme-toggle-track.dark .theme-toggle-thumb {
  transform: translateX(20px);
}

.theme-toggle-icon {
  width: 12px;
  height: 12px;
  color: var(--color-text-weak);
}

/* Main Content */
.generator-main {
  padding: 8px 0 0;
  margin-top: -8px;
  padding-bottom: 20vh;
}

/* Chat Messages */
.chat-messages {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 20px;
}

.prompt-message-wrapper {
  display: flex;
  justify-content: flex-end;
  opacity: 0;
  transform: translateY(16px);
}

.prompt-message-wrapper.visible {
  animation: chatSlideIn 0.6s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

.prompt-message {
  background: rgba(10, 115, 204, 0.08);
  border-radius: 12px 12px 0 12px;
  padding: 16px 20px;
  max-width: calc(100% - 8.33%);
}

.dark-theme .prompt-message {
  background: rgba(79, 178, 252, 0.12);
}

.prompt-message .prompt-text {
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 0.8s cubic-bezier(0.4, 0, 0.2, 1), transform 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

.prompt-message .prompt-text.text-visible {
  opacity: 1;
  transform: translateY(0);
}

.response-message-wrapper {
  display: flex;
  justify-content: flex-start;
  opacity: 0;
  transform: translateY(16px);
}

.response-message-wrapper.visible {
  animation: chatSlideIn 0.6s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

.response-message {
  background: var(--color-fill);
  border-radius: 12px 12px 12px 0;
  padding: 16px 20px;
  max-width: calc(100% - 8.33%);
  min-height: 52px;
  position: relative;
}

.response-skeleton {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.skeleton-line {
  height: 16px;
  background: linear-gradient(
    90deg,
    var(--color-stroke-weak) 0%,
    var(--color-background) 50%,
    var(--color-stroke-weak) 100%
  );
  background-size: 200% 100%;
  border-radius: 4px;
  animation: skeletonPulse 1.8s ease-in-out infinite;
}

.skeleton-line:nth-child(1) { width: 100%; }
.skeleton-line:nth-child(2) { width: 90%; }
.skeleton-line:nth-child(3) { width: 65%; }

@keyframes skeletonPulse {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

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

.prompt-text, .response-text {
  font-size: 16px;
  font-weight: 400;
  line-height: 150%;
  letter-spacing: 0.01em;
  color: var(--color-text-strong);
}

.prompt-text strong {
  color: var(--color-text-strong);
  font-weight: 500;
}

/* Nodes */
.prompt-connector-wrapper {
  position: relative;
  height: 12px;
}

.prompt-connector {
  position: absolute;
  left: 16px;
  top: 0;
  width: 1.5px;
  height: 12px;
  background: var(--color-stroke-weak);
}

.prompt-fade {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 10px;
  background: linear-gradient(to bottom, var(--color-background) 0%, transparent 100%);
  z-index: 2;
  pointer-events: none;
}

.nodes-container {
  display: flex;
  flex-direction: column;
  position: relative;
}

.generator-node {
  position: relative;
  min-height: 40px;
}

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

.node-connector-top {
  position: absolute;
  left: 16px;
  top: 0;
  width: 1.5px;
  height: 0;
  background: var(--color-stroke-weak);
  transition: height 0.4s ease-out;
}

.node-connector-top.animating {
  animation: growConnector 0.4s ease-out forwards;
}

.node-connector-top.complete {
  height: 24px;
}

@keyframes growConnector {
  from { height: 0; }
  to { height: 24px; }
}

.node-header-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-top: 32px;
  padding-left: 7px;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.node-header-row.visible {
  opacity: 1;
  transform: translateY(0);
}

.node-indicator {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 1.5px solid var(--color-stroke-weak);
  background: var(--color-background);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
  flex-shrink: 0;
  position: relative;
}

.node-indicator.active {
  border-color: var(--color-brand);
}

.node-indicator.complete {
  border: none;
  background: var(--color-brand-80);
  color: white;
}

.node-indicator svg {
  width: 10px;
  height: 10px;
}

.indicator-pulse {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2.5px solid var(--color-brand);
  animation: pulseRing 1.5s ease-out infinite;
}

@keyframes pulseRing {
  0% { transform: translate(-50%, -50%) scale(1); opacity: 0.32; }
  100% { transform: translate(-50%, -50%) scale(2.5); opacity: 0; }
}

.node-badge {
  display: inline-block;
  padding: 8px;
  background: var(--color-fill);
  border: 1px solid var(--color-stroke-weak);
  border-radius: 4px;
  font-size: 16px;
  font-weight: 400;
  line-height: 115%;
  letter-spacing: -0.01em;
  color: var(--color-text-weak);
}

.node-content-wrapper {
  display: flex;
  gap: 12px;
  margin-left: 16px;
  margin-top: 8px;
  animation: fadeInUp 0.3s ease forwards;
}

.node-line-wrapper {
  display: flex;
  flex-direction: column;
}

.node-line {
  width: 1.5px;
  background: var(--color-stroke-weak);
  flex: 1;
  min-height: 20px;
}

.node-body {
  flex: 1;
  padding-left: 12px;
  padding-bottom: 16px;
  padding-top: 8px;
}

/* Sections */
.content-section {
  margin-top: 20px;
}

.content-section.first {
  margin-top: 0;
}

.section-title {
  font-size: 16px;
  font-weight: 500;
  line-height: 115%;
  letter-spacing: -0.01em;
  color: var(--color-text-strong);
  margin-bottom: 0;
}

.section-title.loading {
  color: var(--color-text-weak);
}

.section-content {
  margin-top: 16px;
}

/* Shimmer Text */
.shimmer-text {
  display: inline-block;
  background: linear-gradient(
    90deg,
    var(--color-text-weak) 0%,
    rgba(255, 255, 255, 0.8) 50%,
    var(--color-text-weak) 100%
  );
  background-size: 200% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  animation: shimmer 1.2s ease-in-out infinite;
  transition: opacity 0.4s ease-in-out;
}

.dark-theme .shimmer-text {
  background: linear-gradient(
    90deg,
    var(--color-text-weak) 0%,
    rgba(39, 39, 42, 0.8) 50%,
    var(--color-text-weak) 100%
  );
  background-size: 200% 100%;
  -webkit-background-clip: text;
  background-clip: text;
}

.shimmer-text.fading {
  opacity: 0;
}

@keyframes shimmer {
  0% { background-position: 100% 0; }
  100% { background-position: -100% 0; }
}

/* Node Text & Bullets */
.node-text {
  font-size: 16px;
  font-weight: 400;
  line-height: 150%;
  letter-spacing: 0.01em;
  color: var(--color-text-weak);
  margin-bottom: 8px;
}

.node-text .text-strong,
.text-strong {
  font-weight: 600;
  color: var(--color-text-strong);
}

.node-bullet {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin-bottom: 4px;
  font-size: 16px;
  font-weight: 500;
  line-height: 150%;
  letter-spacing: 0.01em;
}

.bullet-dot {
  color: var(--color-text-weak);
  flex-shrink: 0;
  line-height: 150%;
}

.bullet-content {
  flex: 1;
}

.bullet-text {
  color: var(--color-text-weak);
}

.bullet-badges {
  display: inline-flex;
  gap: 4px;
  margin-left: 6px;
  vertical-align: middle;
  animation: badgesFadeIn 0.5s ease forwards;
}

@keyframes badgesFadeIn {
  from { opacity: 0; transform: translateX(-8px); }
  to { opacity: 1; transform: translateX(0); }
}

/* Source Badges */
.source-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 16px;
  min-width: 16px;
  padding: 0 5px;
  background: var(--color-fill);
  border: 1px solid var(--color-stroke-weak);
  border-radius: 4px;
  font-size: 11px;
  font-weight: 400;
  line-height: 130%;
  letter-spacing: -0.01em;
  color: var(--color-text-weak);
  cursor: pointer;
  white-space: nowrap;
  vertical-align: middle;
  position: relative;
}

.source-badge.hovered,
.source-badge:hover {
  background: var(--color-badge-hover-bg);
  border-color: transparent;
  color: var(--color-brand);
}

.source-tooltip {
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  margin-bottom: 6px;
  padding: 5px 10px;
  background: var(--color-text-strong);
  color: var(--color-background);
  font-size: 12px;
  font-weight: 400;
  border-radius: 4px;
  white-space: nowrap;
  z-index: 1000;
  animation: tooltipFadeIn 0.2s ease;
}

/* Progress Cards */
.progress-cards-container {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-top: 16px;
}

.progress-card {
  background: var(--color-fill);
  border-radius: 8px;
  padding: 16px;
  opacity: 0;
  transform: translateY(24px);
  transition: opacity 0.5s ease, transform 0.5s ease;
  display: flex;
  flex-direction: column;
  min-height: 110px;
}

.progress-card.visible {
  opacity: 1;
  transform: translateY(0);
}

.progress-card-label {
  font-size: 14px;
  font-weight: 500;
  color: var(--color-text-strong);
  line-height: 1.3;
  flex: 1;
  margin-bottom: 12px;
}

.progress-card-bottom {
  margin-top: auto;
}

.progress-card-track {
  height: 5px;
  background: var(--color-stroke-weak);
  border-radius: 2px;
  overflow: hidden;
}

.progress-card-fill {
  height: 100%;
  background: var(--color-brand);
  border-radius: 2px;
  transition: width 1s ease-out;
}

.progress-card-value {
  font-size: 14px;
  font-weight: 500;
  color: var(--color-text-weak);
  margin-top: 6px;
}

/* Letter */
.letter-container {
  background: var(--color-fill);
  border-radius: 8px;
  overflow: visible;
  position: relative;
}

.letter-content {
  padding: 28px;
  font-size: 15px;
  line-height: 170%;
  min-height: 200px;
  background: var(--color-fill);
  border-radius: 8px 8px 0 0;
}

.letter-sender {
  font-size: 12px;
  color: var(--color-text-weak);
  margin-bottom: 20px;
}

.letter-recipient {
  margin-bottom: 20px;
  color: var(--color-text-strong);
  font-size: 16px;
  line-height: 150%;
  white-space: pre-line;
}

.letter-salutation {
  margin-bottom: 14px;
  color: var(--color-text-strong);
  font-size: 16px;
}

.letter-body p {
  margin-bottom: 14px;
  color: var(--color-text-strong);
  font-size: 16px;
  line-height: 150%;
  letter-spacing: 0.01em;
}

.letter-closing {
  margin-top: 20px;
  margin-bottom: 6px;
  color: var(--color-text-strong);
  font-size: 16px;
}

.letter-signature {
  color: var(--color-text-strong);
  font-size: 16px;
  line-height: 150%;
  white-space: pre-line;
}

.letter-signature div:first-child {
  font-weight: 500;
}

.letter-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  background: var(--color-fill);
  border-top: 1px solid var(--color-stroke-weak);
  border-radius: 0 0 8px 8px;
}

.letter-footer-time {
  font-size: 12px;
  color: var(--color-text-weak);
}

.letter-footer-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

/* Stat Badges */
.stat-badge-wrapper {
  position: relative;
  display: inline-block;
  opacity: 0;
  transform: translateY(12px);
  transition: opacity 0.4s ease, transform 0.4s ease;
}

.stat-badge-wrapper.visible {
  opacity: 1;
  transform: translateY(0);
}

.stat-badge {
  display: inline-block;
  padding: 5px 12px;
  background: var(--color-brand-12);
  color: var(--color-brand);
  border-radius: 9999px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s ease;
}

.stat-badge:hover {
  background: rgba(10, 115, 204, 0.2);
}

.stat-tooltip {
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  margin-bottom: 8px;
  padding: 8px 12px;
  background: var(--color-text-strong);
  color: var(--color-background);
  font-size: 12px;
  font-weight: 400;
  border-radius: 6px;
  white-space: nowrap;
  z-index: 1000;
  animation: tooltipFadeIn 0.2s ease;
}

.stat-tooltip::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 6px solid transparent;
  border-top-color: var(--color-text-strong);
}

@keyframes tooltipFadeIn {
  from { opacity: 0; transform: translateX(-50%) translateY(4px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* Responsive */
@media (max-width: 960px) {
  .grid-content { grid-column: 2 / 12; }
  .header-inner { grid-column: 2 / 12; }
  .prompt-message, .response-message { max-width: 100%; }
  .preview-hero-text { grid-column: 2 / 7; }
  .preview-hero-image { grid-column: 7 / 12; }
}

@media (max-width: 640px) {
  .preview-hero { padding: 20px 16px; }
  .preview-hero-inner { display: flex; flex-direction: column-reverse; gap: 16px; }
  .preview-hero-text { text-align: left; }
  .preview-hero-image { width: 100%; }
  .preview-hero-image img { border-radius: 6px; }
  .preview-hero-title { font-size: 17px; margin-bottom: 8px; }
  .preview-hero-desc { font-size: 13px; margin-bottom: 14px; }
  .preview-hero-cta { font-size: 13px; padding: 9px 20px; }
  .grid-container { padding: 0 16px; }
  .grid-content { grid-column: 1 / 13; }
  .header-inner { grid-column: 1 / 13; }
  .header-wrapper { padding: 0 16px; }
  .header-title { font-size: 14px; }
  .header-toggles { right: 16px; }
  .prompt-text, .response-text, .node-text, .node-bullet, .section-title, .node-badge { font-size: 14px; }
  .letter-recipient, .letter-salutation, .letter-body p, .letter-closing, .letter-signature { font-size: 14px; }
  .letter-sender { font-size: 11px; }
  .letter-content { padding: 20px; }
  .progress-cards-container { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .progress-card { padding: 12px; min-height: 90px; }
  .progress-card-label { font-size: 12px; }
  .progress-card-value { font-size: 12px; }
  .source-badge { height: 14px; min-width: 14px; font-size: 10px; padding: 0 4px; }
  .source-tooltip { font-size: 10px; }
  .stat-badge { font-size: 10px; padding: 4px 10px; }
  .stat-tooltip { font-size: 10px; }
  .letter-footer-time { font-size: 11px; }
  .letter-footer { flex-direction: column; gap: 12px; align-items: flex-start; padding: 12px 16px; }
  .letter-footer-actions { flex-wrap: wrap; }
  .prompt-message, .response-message { padding: 14px 16px; max-width: 100%; }
  .chat-messages { gap: 10px; }
  .node-content-wrapper { margin-left: 12px; }
  .node-body { padding-left: 10px; }
  .node-connector-top { left: 12px; }
  .node-header-row { padding-left: 3px; }
  .prompt-connector { left: 12px; }
}

@media (max-width: 400px) {
  .progress-cards-container { grid-template-columns: 1fr; }
  .header-title { display: none; }
}
