/* CSS Variables pour les couleurs (configurables via UI params) */
:root {
  --primary-blue: #1e55c4;
  --dark-navy: #0d2e6d;
  --body-text: #374a74;
  --bg-light: #f4f7ff;
  --header-tint: #e9f1ff;
  --border-color: #e0e6f4;
}

/* Layout global */
body {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg-light);
  margin: 0;
  padding: 1.5rem;
  display: flex;
  justify-content: center;
  color: var(--body-text);
}

#app-root {
  width: 100%;
  max-width: 800px;
}

/* App Header avec logo */
.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 0;
  margin-bottom: 1rem;
}

.header-logo {
  display: flex;
  align-items: center;
}

.header-logo-img {
  max-height: 48px;
  max-width: 200px;
  width: auto;
  height: auto;
  object-fit: contain;
}

.header-right {
  display: flex;
  align-items: center;
}

/* Page & headers */
.page {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.page-header {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.page-header h1 {
  margin: 0;
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--dark-navy);
}

.subtitle {
  margin: 0;
  color: var(--body-text);
  font-size: 0.95rem;
  line-height: 1.6;
}

/* Sections */
.section {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.section-title {
  margin: 0 0 0.5rem 0;
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--dark-navy);
}

/* Cards */
.card {
  background: #ffffff;
  border-radius: 12px;
  padding: 1.25rem 1.5rem;
  box-shadow: 0 2px 6px rgba(15, 23, 42, 0.08);
}

.card-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

/* Upsell card (disponibles) - layout horizontal */
.upsell-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.upsell-card-content {
  flex: 1;
  min-width: 0;
}

.card-meta-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-top: 0.5rem;
}

.card-title {
  margin: 0 0 0.25rem 0;
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--dark-navy);
}

.card-text {
  margin: 0;
  font-size: 0.9rem;
  color: var(--body-text);
  line-height: 1.5;
}

.card-meta {
  margin-top: 0.5rem;
  font-size: 0.8rem;
  color: var(--body-text);
}

/* Card footer pour prix et statut */
.card-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border-color);
}

.card-price {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--dark-navy);
}

/* Items summary (pour upsells en cours) */
.items-summary {
  margin: 0.75rem 0;
}

.item-summary-row {
  font-size: 0.9rem;
  color: var(--body-text);
  padding: 0.25rem 0;
}

/* Options / Checkout */
.options {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.option-row {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  background: #f9fafb;
  border-radius: 10px;
  padding: 0.75rem 0.9rem;
}

.option-row-clickable {
  cursor: pointer;
  transition: background-color 0.2s, box-shadow 0.2s;
}

.option-row-clickable:hover {
  background: #f3f4f6;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.option-left {
  flex: 1;
  min-width: 0;
}

.option-title {
  font-weight: 600;
  line-height: 1.2;
  color: var(--dark-navy);
}

.option-meta {
  margin-top: 0.25rem;
  font-size: 0.8rem;
  color: var(--body-text);
}

.option-right {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  min-width: 80px;
}

.qty-select {
  padding: 0.3rem 0.5rem;
  border-radius: 6px;
  border: 1px solid var(--border-color);
  font-size: 0.85rem;
  background: #ffffff;
}

/* Total & paiement */
#total {
  text-align: right;
  font-weight: 600;
  margin-top: 0.5rem;
  font-size: 1.1rem;
  color: var(--dark-navy);
}

.payment-wrapper {
  margin-top: 1rem;
}

.payment-wrapper.hidden {
  display: none;
}

#payment-element {
  margin-top: 0.75rem;
}

/* Boutons */
.btn {
  border: none;
  border-radius: 8px;
  padding: 0.75rem 1.5rem;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  transition: background-color 0.2s;
}

.btn.primary {
  background: var(--primary-blue);
  color: #ffffff;
}

.btn.primary:hover:not(:disabled) {
  background: #1a4db0;
}

.btn.secondary {
  background: #e5e7eb;
  color: var(--dark-navy);
}

.btn.secondary:hover:not(:disabled) {
  background: #d1d5db;
}

.btn.link {
  background: transparent;
  color: var(--primary-blue);
  padding-left: 0;
  padding-right: 0;
  font-weight: 500;
}

.btn.link:hover {
  text-decoration: underline;
}

.btn.hidden {
  display: none;
}

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

.btn:disabled:hover {
  background: var(--primary-blue);
}

.btn.secondary:disabled:hover {
  background: #e5e7eb;
}

/* Spinner */
.spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-radius: 50%;
  border-top-color: #ffffff;
  animation: spin 0.6s linear infinite;
}

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

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.25rem 0.75rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 500;
  background: #e5e7eb;
  color: var(--dark-navy);
}

.badge.required {
  background: #fee2e2;
  color: #b91c1c;
}

/* Statut / items */
.status-row,
.triggers-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  margin: 0.75rem 0;
}

.label {
  font-size: 0.85rem;
  color: var(--body-text);
}

.value {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--dark-navy);
}

.items-list {
  list-style: none;
  padding-left: 0;
  margin: 0.25rem 0 0 0;
}

.item-row {
  font-size: 0.9rem;
  padding: 0.1rem 0;
  color: var(--body-text);
}

/* Items table (style mail) */
.items-table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.5rem 0;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  overflow: hidden;
}

.items-table thead {
  background: var(--bg-light);
}

.items-table th {
  padding: 12px 16px;
  text-align: left;
  font-size: 14px;
  font-weight: 600;
  color: var(--dark-navy);
  border-bottom: 1px solid var(--border-color);
}

.items-table th:nth-child(2) {
  text-align: center;
}

.items-table th:nth-child(3) {
  text-align: right;
}

.items-table tbody tr {
  border-bottom: 1px solid var(--border-color);
}

.items-table tbody tr:last-child {
  border-bottom: none;
}

.items-table td {
  padding: 12px 16px;
  font-size: 14px;
  color: var(--body-text);
}

.items-table tbody td:nth-child(2) {
  text-align: center;
}

.items-table tbody td:nth-child(3) {
  text-align: right;
}

.items-table tfoot {
  background: var(--bg-light);
}

.items-table tfoot td {
  padding: 16px;
  font-size: 16px;
  font-weight: 700;
  color: var(--dark-navy);
}

.items-table tfoot td:last-child {
  text-align: right;
}

.total-row {
  font-weight: 700;
}

/* Receipt link */
.receipt-link {
  display: inline-block;
  margin-top: 1rem;
  color: var(--primary-blue);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
}

.receipt-link:hover {
  text-decoration: underline;
}

/* Divers */
.actions-row {
  display: flex;
  gap: 0.5rem;
  margin-top: 1rem;
}

.error {
  margin-top: 0.5rem;
  font-size: 0.8rem;
  color: #b91c1c;
}

.muted {
  color: #9ca3af;
  font-size: 0.85rem;
}

/* Language selector */
.lang-selector {
  display: flex;
  align-items: center;
}

.lang-select {
  padding: 0.4rem 0.6rem;
  border-radius: 6px;
  border: 1px solid var(--border-color);
  font-size: 0.85rem;
  background: #ffffff;
  color: var(--dark-navy);
  cursor: pointer;
}

.lang-select:hover {
  border-color: #9ca3af;
}

.lang-select:focus {
  outline: none;
  border-color: var(--primary-blue);
  box-shadow: 0 0 0 3px rgba(30, 85, 196, 0.1);
}
