/* ============================================================
   INPI PDF Downloader — Styles
   Dark mode + Responsive improvements
   ============================================================ */

:root {
  --color-primary: #3b82f6;
  --color-primary-hover: #2563eb;
  --color-primary-light: #dbeafe;
  --color-bg: #f9fafb;
  --color-surface: #ffffff;
  --color-text: #1f2937;
  --color-text-muted: #6b7280;
  --color-border: #e5e7eb;
  --color-error: #dc2626;
  --color-error-bg: #fef2f2;
  --color-success: #16a34a;
  --color-success-bg: #f0fdf4;
  --color-warning-bg: #fffbeb;
  --color-warning-border: #f59e0b;
  --color-tag-bg: #e0e7ff;
  --color-tag-text: #3730a3;
  --color-tag-button: #6366f1;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.1), 0 1px 2px rgba(0, 0, 0, 0.06);
}

html[data-theme="dark"] {
  --color-bg: #111827;
  --color-surface: #1f2937;
  --color-text: #f9fafb;
  --color-text-muted: #9ca3af;
  --color-border: #374151;
  --color-error-bg: #7f1d1d;
  --color-success-bg: #1b4332;
  --color-warning-bg: #78350f;
  --color-tag-bg: #1e3a5f;
  --color-tag-text: #93c5fd;
  --color-tag-button: #60a5fa;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.3), 0 1px 2px rgba(0, 0, 0, 0.2);
}

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

html {
  scroll-behavior: smooth;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--color-bg);
  color: var(--color-text);
  line-height: 1.6;
  min-height: 100vh;
  transition: background-color 0.3s ease, color 0.3s ease;
  animation: fadeIn 0.3s ease-out;
}

@media (prefers-color-scheme: dark) {
  html:not([data-theme="light"]) {
    --color-bg: #111827;
    --color-surface: #1f2937;
    --color-text: #f9fafb;
    --color-text-muted: #9ca3af;
    --color-border: #374151;
    --color-error-bg: #7f1d1d;
    --color-success-bg: #1b4332;
    --color-warning-bg: #78350f;
    --color-tag-bg: #1e3a5f;
    --color-tag-text: #93c5fd;
    --color-tag-button: #60a5fa;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.3), 0 1px 2px rgba(0, 0, 0, 0.2);
  }
}

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

.container {
  max-width: 640px;
  margin: 0 auto;
  padding: 2rem 1rem;
}

/* Header */
header {
  text-align: center;
  margin-bottom: 2rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

header h1 {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--color-primary);
  margin-bottom: 0.25rem;
}

.subtitle {
  color: var(--color-text-muted);
  font-size: 0.95rem;
}

.header-controls {
  display: flex;
  justify-content: center;
  gap: 0.75rem;
  margin-top: 1rem;
  flex-wrap: wrap;
}

.header-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  color: var(--color-text);
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 1.25rem;
  line-height: 1;
}

.header-btn:hover {
  background: var(--color-primary);
  color: white;
  border-color: var(--color-primary);
}

.header-btn.text-btn {
  width: auto;
  padding: 0.4rem 0.8rem;
  font-size: 0.85rem;
  font-weight: 600;
}

/* Cards */
.card {
  background: var(--color-surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.5rem;
  margin-bottom: 1.25rem;
  animation: slideUp 0.4s ease-out;
}

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

.card h2 {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 1rem;
}

/* SIREN input */
.siren-input-wrapper {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.siren-input-wrapper input {
  flex: 1;
  min-width: 0;
}

.siren-input-wrapper button {
  flex-shrink: 0;
}

.bulk-paste-link {
  display: inline-block;
  color: var(--color-primary);
  text-decoration: none;
  font-size: 0.85rem;
  margin-top: 0.75rem;
  cursor: pointer;
}

.bulk-paste-link:hover {
  text-decoration: underline;
}

.bulk-paste-textarea {
  width: 100%;
  min-height: 100px;
  padding: 0.75rem;
  margin: 0.75rem 0;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  background: var(--color-bg);
  color: var(--color-text);
  font-family: inherit;
  font-size: 0.95rem;
  resize: vertical;
  transition: border-color 0.15s;
}

.bulk-paste-textarea:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

html[data-theme="dark"] .bulk-paste-textarea:focus {
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.25);
}

/* Tags */
.tags-container {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.75rem;
  min-height: 0;
}

.tag {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  background: var(--color-tag-bg);
  color: var(--color-tag-text);
  padding: 0.4rem 0.75rem;
  border-radius: 999px;
  font-size: 0.875rem;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  animation: tagAppear 0.2s ease-out;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tag .siren-name {
  opacity: 0.75;
  font-weight: 400;
  font-size: 0.8rem;
}

@keyframes tagAppear {
  from {
    opacity: 0;
    transform: scale(0.9);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

.tag button {
  background: none;
  border: none;
  color: var(--color-tag-button);
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  padding: 0;
  margin-left: 0.15rem;
  transition: color 0.2s ease;
  display: inline-flex;
  align-items: center;
}

.tag button:hover {
  color: var(--color-error);
}

/* Form elements */
.form-group {
  margin-bottom: 1rem;
}

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

input[type="text"],
input[type="email"],
input[type="password"] {
  width: 100%;
  padding: 0.65rem 0.75rem;
  font-size: 0.95rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  background: var(--color-surface);
  color: var(--color-text);
  transition: border-color 0.15s, box-shadow 0.15s;
  min-height: 44px;
}

input:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

html[data-theme="dark"] input:focus {
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.25);
}

/* Buttons */
button,
.btn-primary,
.btn-secondary {
  display: inline-block;
  padding: 0.65rem 1.25rem;
  font-size: 0.95rem;
  font-weight: 600;
  border-radius: var(--radius);
  cursor: pointer;
  border: none;
  text-decoration: none;
  text-align: center;
  transition: background 0.2s, color 0.2s, border-color 0.2s, opacity 0.2s;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.btn-primary,
#btn-checkout {
  background: var(--color-primary);
  color: #fff;
  width: 100%;
}

.btn-primary:hover,
#btn-checkout:hover:not(:disabled) {
  background: var(--color-primary-hover);
}

#btn-checkout:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

#btn-add-siren {
  background: var(--color-primary);
  color: #fff;
  white-space: nowrap;
  flex-shrink: 0;
}

#btn-add-siren:hover {
  background: var(--color-primary-hover);
}

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

.btn-secondary:hover {
  background: var(--color-primary-light);
  border-color: var(--color-primary-hover);
}

html[data-theme="dark"] .btn-secondary:hover {
  background: rgba(59, 130, 246, 0.2);
}

/* Tier Selection Cards */
.tier-cards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.tier-card {
  position: relative;
  background: var(--color-surface);
  border: 2px solid var(--color-border);
  border-radius: var(--radius);
  padding: 1.25rem;
  cursor: pointer;
  transition: all 0.25s ease;
  outline: none;
}

.tier-card:hover {
  border-color: var(--color-primary);
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.12);
}

.tier-card.selected {
  border-color: var(--color-primary);
  background: var(--color-primary-light);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

html[data-theme="dark"] .tier-card.selected {
  background: rgba(59, 130, 246, 0.1);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.25);
}

.tier-card:focus-visible {
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.4);
}

.tier-badge {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-primary);
  background: var(--color-primary-light);
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  margin-bottom: 0.75rem;
}

html[data-theme="dark"] .tier-badge {
  background: rgba(59, 130, 246, 0.2);
}

.tier-badge-premium {
  color: #9333ea;
  background: #f3e8ff;
}

html[data-theme="dark"] .tier-badge-premium {
  color: #c084fc;
  background: rgba(147, 51, 234, 0.2);
}

.tier-card h3 {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
  color: var(--color-text);
}

.tier-price {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--color-text);
  margin-bottom: 0.75rem;
}

.tier-price span {
  font-size: 0.8rem;
  font-weight: 400;
  color: var(--color-text-muted);
}

.tier-features {
  list-style: none;
  padding: 0;
  margin: 0;
}

.tier-features li {
  font-size: 0.85rem;
  color: var(--color-text-muted);
  padding: 0.25rem 0;
  padding-left: 1.25rem;
  position: relative;
}

.tier-features li::before {
  content: "✓";
  position: absolute;
  left: 0;
  color: var(--color-success);
  font-weight: 600;
  font-size: 0.8rem;
}

/* Pricing */
.pricing {
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 1rem;
  margin-bottom: 1rem;
}

.pricing-row {
  display: flex;
  justify-content: space-between;
  padding: 0.35rem 0;
  font-size: 0.95rem;
}

.pricing-row.total {
  border-top: 1px solid var(--color-border);
  margin-top: 0.35rem;
  padding-top: 0.6rem;
  font-weight: 700;
  font-size: 1.05rem;
}

/* Info & error */
.info {
  font-size: 0.85rem;
  color: var(--color-text-muted);
  margin-top: 0.5rem;
}

.error {
  color: var(--color-error);
  background: var(--color-error-bg);
  padding: 0.75rem;
  border-radius: var(--radius);
  font-size: 0.875rem;
  margin-top: 0.5rem;
}

/* Banner */
.banner {
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  font-size: 0.9rem;
  margin-bottom: 1.25rem;
}

.banner-warning {
  background: var(--color-warning-bg);
  border: 1px solid var(--color-warning-border);
  color: var(--color-text);
}

/* Toast */
.toast-container {
  position: fixed;
  bottom: 1rem;
  right: 1rem;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  max-width: 90vw;
  pointer-events: none;
}

.toast {
  background: var(--color-surface);
  color: var(--color-text);
  padding: 1rem;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border-left: 4px solid var(--color-primary);
  animation: slideInRight 0.3s ease-out;
  pointer-events: auto;
  max-width: 320px;
  font-size: 0.9rem;
}

.toast.success {
  border-left-color: var(--color-success);
}

.toast.error {
  border-left-color: var(--color-error);
}

@keyframes slideInRight {
  from {
    opacity: 0;
    transform: translateX(100%);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

/* Phase Indicator (analysis tier progress) */
.phase-indicator {
  margin: 1.25rem 0;
}

.phase-steps {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0;
}

.phase-step {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  border-radius: var(--radius);
  transition: all 0.3s ease;
}

.phase-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--color-border);
  transition: all 0.3s ease;
  flex-shrink: 0;
}

.phase-step.active .phase-dot {
  background: var(--color-primary);
  box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.2);
  animation: pulse 1.5s infinite;
}

.phase-step.completed .phase-dot {
  background: var(--color-success);
}

@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.2); }
  50% { box-shadow: 0 0 0 8px rgba(59, 130, 246, 0.1); }
}

.phase-label {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--color-text-muted);
  transition: color 0.3s;
}

.phase-step.active .phase-label {
  color: var(--color-primary);
  font-weight: 600;
}

.phase-step.completed .phase-label {
  color: var(--color-success);
}

.phase-connector {
  width: 40px;
  height: 2px;
  background: var(--color-border);
  transition: background 0.3s;
}

.phase-connector.completed {
  background: var(--color-success);
}

/* Success page */
.success-card {
  text-align: center;
}

.status-icon {
  font-size: 3rem;
  margin-bottom: 0.75rem;
  animation: bounce 0.6s ease-out;
}

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

.progress-bar-wrapper {
  width: 100%;
  height: 8px;
  background: var(--color-border);
  border-radius: 4px;
  margin: 1.25rem 0;
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--color-primary), var(--color-primary-hover));
  border-radius: 4px;
  width: 10%;
  transition: width 0.5s ease;
}

.siren-progress-list {
  text-align: left;
  margin: 1.5rem 0;
  padding: 1rem;
  background: var(--color-bg);
  border-radius: var(--radius);
  border: 1px solid var(--color-border);
}

.siren-progress-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 0;
  font-size: 0.9rem;
  animation: slideUp 0.3s ease-out;
}

.siren-progress-item.completed .status-check {
  color: var(--color-success);
}

.siren-progress-item.pending .status-check {
  color: var(--color-text-muted);
}

.status-check {
  font-size: 1.2rem;
  flex-shrink: 0;
}

#download-section {
  margin-top: 1.5rem;
}

#download-section .btn-primary {
  display: inline-block;
  width: auto;
  padding: 0.75rem 2rem;
}

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

/* Footer */
footer {
  text-align: center;
  margin-top: 2rem;
  font-size: 0.8rem;
  color: var(--color-text-muted);
}

footer a {
  color: var(--color-primary);
  text-decoration: none;
}

footer a:hover {
  text-decoration: underline;
}

/* Loading spinner on button */
.btn-loading {
  position: relative;
  color: transparent !important;
}

.btn-loading::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 1.2rem;
  height: 1.2rem;
  margin: -0.6rem 0 0 -0.6rem;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

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

/* Responsive */
@media (max-width: 768px) {
  .container {
    padding: 1.5rem 1rem;
  }

  .card {
    padding: 1.25rem;
  }

  header {
    margin-bottom: 1.5rem;
  }

  header h1 {
    font-size: 1.5rem;
  }

  .header-controls {
    gap: 0.5rem;
  }

  .header-btn {
    width: 36px;
    height: 36px;
    font-size: 1.1rem;
  }

  .siren-input-wrapper {
    flex-direction: column;
    gap: 0.5rem;
  }

  .siren-input-wrapper button {
    width: 100%;
  }

  .tier-cards {
    grid-template-columns: 1fr;
  }

  .toast-container {
    bottom: 0.75rem;
    right: 0.75rem;
  }

  .toast {
    max-width: 85vw;
  }
}

@media (max-width: 480px) {
  .container {
    padding: 1rem 0.75rem;
  }

  .card {
    padding: 1rem;
    margin-bottom: 1rem;
  }

  header h1 {
    font-size: 1.25rem;
  }

  .subtitle {
    font-size: 0.85rem;
  }

  .header-controls {
    gap: 0.4rem;
  }

  .header-btn {
    width: 32px;
    height: 32px;
    font-size: 1rem;
  }

  .header-btn.text-btn {
    padding: 0.3rem 0.6rem;
    font-size: 0.75rem;
  }

  .card h2 {
    font-size: 1rem;
  }

  .status-icon {
    font-size: 2.5rem;
  }

  .toast {
    max-width: 80vw;
    padding: 0.75rem;
    font-size: 0.85rem;
  }

  input[type="text"],
  input[type="email"],
  input[type="password"] {
    min-height: 44px;
  }

  button,
  .btn-primary,
  .btn-secondary {
    min-height: 44px;
    padding: 0.6rem 1rem;
    font-size: 0.9rem;
  }
}

/* Hero Section */
.hero {
  background: linear-gradient(135deg, #1e3a5f 0%, #3b82f6 100%);
  color: white;
  padding: 4rem 1rem 3rem;
  text-align: center;
}

.hero-content {
  max-width: 700px;
  margin: 0 auto;
}

.hero h1 {
  font-size: 2rem;
  font-weight: 800;
  line-height: 1.2;
  margin-bottom: 1rem;
  color: white;
}

.hero-subtitle {
  font-size: 1.1rem;
  opacity: 0.9;
  margin-bottom: 2rem;
  line-height: 1.5;
  color: rgba(255,255,255,0.9);
}

.hero-stats {
  display: flex;
  justify-content: center;
  gap: 2rem;
  margin-bottom: 2rem;
  flex-wrap: wrap;
}

.stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
}

.stat-value {
  font-size: 1.5rem;
  font-weight: 700;
}

.stat-label {
  font-size: 0.85rem;
  opacity: 0.85;
}

.hero-cta {
  display: inline-block;
  background: white;
  color: #1e3a5f;
  padding: 0.75rem 2rem;
  border-radius: 8px;
  font-weight: 700;
  font-size: 1rem;
  text-decoration: none;
  transition: transform 0.2s, box-shadow 0.2s;
}

.hero-cta:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}

/* FAQ Section */
.faq-section {
  background: var(--color-surface);
  padding: 3rem 1rem;
  margin-top: 2rem;
  border-top: 1px solid var(--color-border);
}

.faq-section h2 {
  text-align: center;
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--color-text);
  margin-bottom: 1.5rem;
}

.faq-list {
  max-width: 640px;
  margin: 0 auto;
}

.faq-item {
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  margin-bottom: 0.75rem;
  overflow: hidden;
}

.faq-item summary {
  padding: 1rem 1.25rem;
  font-weight: 600;
  cursor: pointer;
  list-style: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: background 0.2s;
}

.faq-item summary:hover {
  background: var(--color-bg);
}

.faq-item summary::after {
  content: "+";
  font-size: 1.25rem;
  font-weight: 300;
  color: var(--color-text-muted);
  transition: transform 0.2s;
}

.faq-item[open] summary::after {
  content: "−";
}

.faq-item p {
  padding: 0 1.25rem 1rem;
  color: var(--color-text-muted);
  line-height: 1.6;
  font-size: 0.95rem;
}

@media (max-width: 480px) {
  .hero h1 { font-size: 1.5rem; }
  .hero-stats { gap: 1rem; }
  .stat-value { font-size: 1.2rem; }
}
