/* ============================================
   PromptPacks PWA — Premium Minimal Design
   ============================================ */

:root {
  --bg: #FAFAFA;
  --surface: #FFFFFF;
  --surface-hover: #F5F5F7;
  --border: #E8E8ED;
  --border-focus: #6C63FF;
  --text-primary: #1A1A2E;
  --text-secondary: #6B7280;
  --text-tertiary: #9CA3AF;
  --accent: #6C63FF;
  --accent-light: #EEF0FF;
  --accent-dark: #5A52D5;
  --success: #10B981;
  --success-light: #ECFDF5;
  --error: #EF4444;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.06);
  --shadow-lg: 0 8px 30px rgba(0,0,0,0.08);
  --shadow-xl: 0 20px 60px rgba(0,0,0,0.1);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --font-serif: 'DM Serif Display', Georgia, serif;
  --font-sans: 'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

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

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Header */
.header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(250, 250, 250, 0.85);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
}

.header-inner {
  max-width: 680px;
  margin: 0 auto;
  padding: 12px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
}

.logo-text {
  font-family: var(--font-serif);
  font-size: 1.2rem;
  color: var(--text-primary);
  letter-spacing: -0.02em;
}

.usage-badge {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px 14px;
  border-radius: 100px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-secondary);
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  font-family: var(--font-sans);
}

.usage-badge:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.usage-badge.depleted {
  background: #FFF7ED;
  border-color: #FB923C;
  color: #EA580C;
}

/* Main */
.main {
  max-width: 680px;
  margin: 0 auto;
  padding: 0 20px;
  padding-bottom: calc(40px + var(--safe-bottom));
}

/* Hero */
.hero {
  padding: 48px 0 12px;
  text-align: center;
  transition: all 0.4s ease;
}

.hero.compact {
  padding: 20px 0 8px;
}

.hero-title {
  font-family: var(--font-serif);
  font-size: 2.4rem;
  font-weight: 400;
  line-height: 1.15;
  letter-spacing: -0.03em;
  color: var(--text-primary);
  margin-bottom: 12px;
}

.hero.compact .hero-title {
  font-size: 1.6rem;
}

.hero-subtitle {
  font-size: 1.05rem;
  color: var(--text-secondary);
  line-height: 1.6;
  max-width: 520px;
  margin: 0 auto;
}

.hero.compact .hero-subtitle {
  display: none;
}

/* Input Area */
.input-area {
  padding: 8px 0 24px;
}

.input-container {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 12px 14px;
  transition: all 0.25s ease;
  box-shadow: var(--shadow-sm);
}

.input-container:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-light), var(--shadow-md);
}

.input-container textarea {
  flex: 1;
  border: none;
  outline: none;
  background: none;
  font-family: var(--font-sans);
  font-size: 1rem;
  line-height: 1.5;
  color: var(--text-primary);
  resize: none;
  min-height: 24px;
  max-height: 120px;
}

.input-container textarea::placeholder {
  color: var(--text-tertiary);
}

.send-btn {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  border: none;
  background: var(--accent);
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.send-btn:hover:not(:disabled) {
  background: var(--accent-dark);
  transform: scale(1.05);
}

.send-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* Hint Chips */
.input-hints {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
  justify-content: center;
}

.hint-chip {
  padding: 8px 16px;
  border-radius: 100px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-secondary);
  font-size: 0.85rem;
  font-family: var(--font-sans);
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

.hint-chip:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-light);
}

/* Follow-up Section */
.followup-section {
  padding: 8px 0 24px;
  animation: slideUp 0.4s ease;
}

.section-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 16px;
}

.label-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  animation: pulse 2s infinite;
}

.label-dot.success {
  background: var(--success);
  animation: none;
}

.followup-cards {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 20px;
}

.followup-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px;
  transition: all 0.2s;
}

.followup-card:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-light);
}

.followup-label {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.followup-input {
  width: 100%;
  border: none;
  outline: none;
  background: none;
  font-family: var(--font-sans);
  font-size: 0.95rem;
  color: var(--text-primary);
  line-height: 1.5;
}

.followup-input::placeholder {
  color: var(--text-tertiary);
}

.generate-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  padding: 16px;
  border-radius: var(--radius-md);
  border: none;
  background: var(--accent);
  color: white;
  font-family: var(--font-sans);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.25s;
  box-shadow: 0 4px 14px rgba(108, 99, 255, 0.3);
}

.generate-btn:hover {
  background: var(--accent-dark);
  box-shadow: 0 6px 20px rgba(108, 99, 255, 0.4);
  transform: translateY(-1px);
}

.generate-btn:active {
  transform: translateY(0);
}

/* Loading */
.loading-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 60px 0;
  animation: fadeIn 0.3s ease;
}

.loading-animation {
  position: relative;
  width: 80px;
  height: 80px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 24px;
}

.pulse-ring {
  position: absolute;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  border: 2px solid var(--accent);
  opacity: 0;
  animation: pulseRing 2s ease-out infinite;
}

.pulse-ring.delay-1 { animation-delay: 0.6s; }
.pulse-ring.delay-2 { animation-delay: 1.2s; }

.loading-icon {
  position: relative;
  z-index: 1;
}

.loading-text {
  color: var(--text-secondary);
  font-size: 1rem;
}

.loading-dots::after {
  content: '';
  animation: dots 1.5s steps(4, end) infinite;
}

/* Result */
.result-section {
  padding: 8px 0;
  animation: slideUp 0.5s ease;
}

.result-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.result-actions {
  display: flex;
  gap: 4px;
}

.action-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-secondary);
  font-size: 0.8rem;
  font-family: var(--font-sans);
  cursor: pointer;
  transition: all 0.2s;
}

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

.result-content {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px 24px;
  font-size: 0.95rem;
  line-height: 1.75;
  color: var(--text-primary);
  box-shadow: var(--shadow-sm);
  white-space: pre-wrap;
  overflow-wrap: break-word;
}

.result-content h1,
.result-content h2,
.result-content h3 {
  font-family: var(--font-serif);
  margin: 20px 0 8px;
  line-height: 1.3;
}

.result-content h1 { font-size: 1.4rem; }
.result-content h2 { font-size: 1.2rem; }
.result-content h3 { font-size: 1.05rem; }

.result-content h1:first-child,
.result-content h2:first-child,
.result-content h3:first-child {
  margin-top: 0;
}

.result-content p { margin-bottom: 12px; }

.result-content ul, .result-content ol {
  margin: 8px 0 16px 20px;
}

.result-content li { margin-bottom: 6px; }

.result-content strong {
  font-weight: 600;
  color: var(--text-primary);
}

.result-content em {
  color: var(--text-secondary);
}

.result-content blockquote {
  border-left: 3px solid var(--accent);
  padding-left: 16px;
  margin: 12px 0;
  color: var(--text-secondary);
}

.new-request-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 14px;
  margin-top: 20px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-secondary);
  font-family: var(--font-sans);
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

.new-request-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(0,0,0,0.4);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  animation: fadeIn 0.2s ease;
}

.modal {
  background: var(--surface);
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  padding: 32px 24px calc(32px + var(--safe-bottom));
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  overflow-y: auto;
  position: relative;
  animation: slideUpModal 0.35s ease;
}

@media (min-width: 640px) {
  .modal-overlay {
    align-items: center;
  }
  .modal {
    border-radius: var(--radius-xl);
    padding: 40px 32px;
    max-height: 80vh;
  }
}

.modal-close {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: none;
  background: var(--surface-hover);
  color: var(--text-secondary);
  font-size: 1.2rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-badge {
  display: inline-block;
  padding: 4px 14px;
  border-radius: 100px;
  background: linear-gradient(135deg, #6C63FF, #8B5CF6);
  color: white;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  margin-bottom: 16px;
}

.modal-title {
  font-family: var(--font-serif);
  font-size: 1.8rem;
  margin-bottom: 8px;
}

.modal-desc {
  color: var(--text-secondary);
  margin-bottom: 24px;
  line-height: 1.6;
}

.modal-features {
  list-style: none;
  margin-bottom: 24px;
}

.modal-features li {
  padding: 8px 0;
  color: var(--text-primary);
  font-size: 0.95rem;
  display: flex;
  align-items: center;
  gap: 10px;
}

.modal-features li::before {
  content: '✓';
  display: flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--success-light);
  color: var(--success);
  font-size: 0.75rem;
  font-weight: 700;
  flex-shrink: 0;
}

.modal-price {
  text-align: center;
  margin-bottom: 20px;
}

.price-amount {
  font-family: var(--font-serif);
  font-size: 2.8rem;
  color: var(--text-primary);
}

.price-period {
  font-size: 1rem;
  color: var(--text-secondary);
}

.upgrade-btn {
  display: block;
  width: 100%;
  padding: 16px;
  border-radius: var(--radius-md);
  border: none;
  background: var(--accent);
  color: white;
  font-family: var(--font-sans);
  font-size: 1rem;
  font-weight: 600;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: 0 4px 14px rgba(108, 99, 255, 0.3);
}

.upgrade-btn:hover {
  background: var(--accent-dark);
}

.modal-login {
  text-align: center;
  margin-top: 16px;
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.link-btn {
  background: none;
  border: none;
  color: var(--accent);
  font-family: var(--font-sans);
  font-size: 0.85rem;
  cursor: pointer;
  text-decoration: underline;
}

.pro-login-form {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

.pro-email-input {
  flex: 1;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  font-family: var(--font-sans);
  font-size: 0.9rem;
  outline: none;
}

.pro-email-input:focus {
  border-color: var(--accent);
}

.verify-btn {
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  border: none;
  background: var(--accent);
  color: white;
  font-family: var(--font-sans);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
}

/* Toast */
.toast {
  position: fixed;
  bottom: calc(24px + var(--safe-bottom));
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  padding: 12px 24px;
  border-radius: 100px;
  background: var(--text-primary);
  color: white;
  font-size: 0.85rem;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  z-index: 2000;
  opacity: 0;
  transition: all 0.3s ease;
}

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

/* Utilities */
.hidden {
  display: none !important;
}

/* Animations */
@keyframes slideUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes slideUpModal {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

@keyframes pulseRing {
  0% { transform: scale(0.5); opacity: 0.8; }
  100% { transform: scale(1.5); opacity: 0; }
}

@keyframes dots {
  0% { content: ''; }
  25% { content: '.'; }
  50% { content: '..'; }
  75% { content: '...'; }
}

/* Responsive */
@media (max-width: 480px) {
  .hero-title {
    font-size: 1.8rem;
  }
  .hero-subtitle {
    font-size: 0.95rem;
  }
  .input-hints {
    justify-content: flex-start;
    overflow-x: auto;
    flex-wrap: nowrap;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding-bottom: 4px;
  }
  .input-hints::-webkit-scrollbar { display: none; }
  .result-content {
    padding: 20px 16px;
  }
  .action-btn span {
    display: none;
  }
}

/* Print styles for download */
@media print {
  .header, .input-area, .result-header, .new-request-btn,
  .followup-section, .loading-section, .hero {
    display: none !important;
  }
  .result-content {
    border: none;
    box-shadow: none;
    padding: 0;
  }
}
