﻿/* components/modal.css — Recipe View Modal (rvm) and upgrade modal. */

/* ── Upgrade modal ── */

#upgrade-modal.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: none;
  justify-content: center;
  align-items: center;
  z-index: var(--z-max);
}

#upgrade-modal.modal-overlay.show {
  display: flex !important;
}

.upgrade-modal-content {
  background: var(--color-surface);
  padding: var(--space-8);
  border-radius: var(--radius-lg);
  max-width: 400px;
  width: 90%;
  text-align: center;
  box-shadow: var(--shadow-xl);
}

.upgrade-modal-actions {
  margin: var(--space-4) 0;
}

.upgrade-modal-btn-cancel {
  margin-right: var(--space-4);
  padding: var(--space-2) var(--space-4);
  background: var(--color-bg-alt);
  color: var(--text-secondary);
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-family: var(--font-sans);
  transition: background var(--transition-fast);
}

.upgrade-modal-btn-cancel:hover {
  background: var(--color-border);
}

.upgrade-modal-btn-upgrade {
  padding: var(--space-2) var(--space-4);
  background: var(--color-accent);
  color: var(--color-primary);
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-family: var(--font-sans);
  font-weight: var(--weight-semibold);
  transition: background var(--transition-fast);
}

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

/* ── Checkout modal (Stripe Elements) ── */

.checkout-modal-root {
  position: fixed;
  inset: 0;
  z-index: calc(var(--z-max) + 10);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-4);
}

.checkout-overlay {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.65);
  backdrop-filter: blur(4px);
}

.checkout-modal {
  position: relative;
  width: min(480px, 100%);
  background: var(--color-surface);
  border-radius: var(--radius-2xl);
  box-shadow: var(--shadow-xl);
  overflow: hidden;
}

.checkout-close {
  position: absolute;
  top: var(--space-4);
  right: var(--space-4);
  width: 36px;
  height: 36px;
  border: none;
  border-radius: var(--radius-full);
  background: var(--color-primary-10);
  color: var(--color-primary);
  font-size: 1.4rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1;
}

.checkout-header {
  padding: var(--space-6) var(--space-6) var(--space-4);
  border-bottom: 1px solid var(--color-primary-10);
}

.checkout-header h2 {
  margin: 0 0 var(--space-2);
  font-size: 1.4rem;
  color: var(--text-default);
}

.checkout-plan-summary {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.checkout-plan-name {
  font-size: 0.9rem;
  color: var(--text-secondary);
}

.checkout-plan-price {
  font-size: 1rem;
  font-weight: var(--weight-bold);
  color: var(--color-primary);
}

.checkout-body {
  padding: var(--space-6);
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.checkout-stripe-element {
  min-height: 120px;
  border: 1px solid var(--color-primary-10);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
  display: flex;
  align-items: center;
  justify-content: center;
}

.checkout-stripe-loading {
  background: var(--color-bg-alt);
}

.checkout-spinner,
.checkout-btn-spinner {
  width: 28px;
  height: 28px;
  border: 3px solid var(--color-primary-10);
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: checkout-spin 0.7s linear infinite;
  display: inline-block;
}

.checkout-btn-spinner {
  width: 16px;
  height: 16px;
  border-width: 2px;
  vertical-align: middle;
  margin-right: 6px;
}

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

.checkout-error {
  padding: var(--space-3) var(--space-4);
  background: rgba(220, 53, 69, 0.08);
  border: 1px solid rgba(220, 53, 69, 0.3);
  border-radius: var(--radius-md);
  color: #dc3545;
  font-size: 0.88rem;
}

.checkout-submit {
  width: 100%;
  padding: var(--space-4);
  background: var(--gradient-primary);
  color: var(--text-on-dark);
  border: none;
  border-radius: var(--radius-lg);
  font-size: 1rem;
  font-weight: var(--weight-semibold);
  cursor: pointer;
  transition: opacity var(--transition-fast), transform var(--transition-fast);
  display: flex;
  align-items: center;
  justify-content: center;
}

.checkout-submit:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.checkout-submit:not(:disabled):hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 20px rgba(15, 23, 42, 0.2);
}

.checkout-legal {
  margin: 0;
  font-size: 0.78rem;
  color: var(--text-muted);
  text-align: center;
}

.checkout-success {
  padding: var(--space-10) var(--space-6);
  text-align: center;
}

.checkout-success-icon {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: rgba(40, 167, 69, 0.12);
  color: #28a745;
  font-size: 2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto var(--space-4);
}

.checkout-success h3 {
  margin: 0 0 var(--space-2);
  color: var(--text-default);
}

.checkout-success p {
  margin: 0;
  color: var(--text-secondary);
}

/* ── Recipe View Modal (rvm) ── */

.rvm-overlay {
  position: fixed;
  top: var(--lpo-navbar-height, 103px);
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1050;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-6);
  background: rgba(15, 23, 42, 0.62);
  backdrop-filter: blur(6px);
}

.rvm-modal {
  width: min(920px, 100%);
  max-height: calc(100vh - var(--lpo-navbar-height, 103px) - 2 * var(--space-6));
  overflow: hidden;
  display: flex;
  flex-direction: column;
  background: linear-gradient(180deg, var(--color-surface) 0%, var(--color-bg) 100%);
  border: 1px solid var(--color-primary-10);
  border-radius: var(--radius-2xl);
  box-shadow: var(--shadow-xl);
}

/* ── Hero ── */

.rvm-hero {
  position: relative;
  min-height: 240px;
  background: linear-gradient(135deg,
    rgba(40, 54, 85, 0.9),
    rgba(15, 23, 42, 0.78));
}

.rvm-hero-svg,
.rvm-hero-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.rvm-hero-svg { object-fit: cover; }

.rvm-hero-img {
  object-fit: cover;
  opacity: 0;
  transition: opacity var(--transition-fast);
}

.rvm-hero-img--visible { opacity: 1; }

/* Status badge */

.rvm-hero-status {
  position: absolute;
  right: var(--space-4);
  bottom: var(--space-4);
  z-index: 2;
  display: inline-flex;
  align-items: center;
  max-width: min(70%, 340px);
  padding: 0.42rem 0.76rem;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: var(--radius-full);
  background: rgba(15, 23, 42, 0.58);
  color: var(--text-on-dark);
  font-size: var(--text-xs);
  font-weight: var(--weight-bold);
  letter-spacing: 0.01em;
  box-shadow: 0 10px 28px rgba(15, 23, 42, 0.22);
  backdrop-filter: blur(10px);
}

.rvm-hero-status::before {
  content: '';
  width: 0.46rem;
  height: 0.46rem;
  margin-right: 0.45rem;
  border-radius: var(--radius-full);
  background: var(--color-accent);
  box-shadow: 0 0 0 0 rgba(15, 23, 42, 0.38);
}

/* While pending or unavailable, SVG placeholder is the right visual — hide the text badge */
.rvm-hero-status--pending,
.rvm-hero-status--unavailable {
  display: none;
}

.rvm-hero-status--ready {
  background: rgba(16, 105, 65, 0.72);
}

.rvm-hero-status--ready::before {
  background: var(--color-success-bg);
}

/* Hero overlay badges */

.rvm-hero-overlay {
  position: absolute;
  inset-inline: 1.25rem;
  bottom: 1.25rem;
  display: flex;
  justify-content: flex-start;
}

.rvm-hero-category,
.rvm-badge,
.rvm-flag {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.42rem 0.82rem;
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
}

.rvm-hero-category {
  color: var(--text-on-dark);
  background: rgba(255, 255, 255, 0.18);
  border: 1px solid rgba(255, 255, 255, 0.24);
}

/* ── Modal sections ── */

.rvm-header,
.rvm-body,
.rvm-footer {
  padding-inline: var(--space-6);
}

.rvm-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-4);
  padding-top: var(--space-5);
  padding-bottom: var(--space-4);
}

.rvm-title {
  margin: 0 0 var(--space-2);
  color: var(--text-default);
  font-size: clamp(1.4rem, 2vw, 2rem);
  line-height: var(--leading-tight);
}

.rvm-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
  color: var(--text-secondary);
}

.rvm-badge {
  color: var(--color-primary);
  background: var(--color-primary-10);
}

.rvm-flag {
  color: var(--palette-teal-700);
  background: rgba(40, 167, 69, 0.14);
}

.rvm-meta-separator,
.rvm-meta-text {
  font-size: 0.88rem;
  color: var(--text-muted);
}

/* ── Header actions ── */

.rvm-header-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.rvm-edit-btn,
.rvm-close-btn,
.rvm-action-btn {
  border: none;
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: transform var(--transition-fast),
              box-shadow var(--transition-fast),
              background var(--transition-fast);
}

.rvm-edit-btn,
.rvm-action-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-height: 44px;
  padding: 0.78rem 1.1rem;
  font-weight: var(--weight-semibold);
}

.rvm-edit-btn {
  background: var(--color-primary-10);
  color: var(--color-primary);
}

.rvm-close-btn {
  width: 44px;
  height: 44px;
  font-size: 1.4rem;
  color: var(--color-primary);
  background: var(--color-primary-10);
}

.rvm-edit-btn:hover,
.rvm-close-btn:hover,
.rvm-action-btn:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 10px 20px rgba(15, 23, 42, 0.12);
}

/* ── Body ── */

.rvm-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding-bottom: var(--space-4);
  scroll-behavior: smooth;
}

.rvm-body::-webkit-scrollbar { width: 5px; }
.rvm-body::-webkit-scrollbar-track { background: transparent; }
.rvm-body::-webkit-scrollbar-thumb { background: var(--color-border); border-radius: 3px; }

.rvm-section + .rvm-section {
  margin-top: var(--space-6);
}

.rvm-section-title {
  margin: 0 0 0.85rem;
  font-size: var(--text-base);
  color: var(--color-primary);
}

/* ── Ingredient & step rows ── */

.rvm-ingredients,
.rvm-instructions {
  display: grid;
  gap: 0.8rem;
}

.rvm-ingredient,
.rvm-step {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 0.75rem;
  align-items: start;
  padding: 0.9rem var(--space-4);
  background: var(--color-surface);
  border: 1px solid var(--color-primary-10);
  border-radius: var(--radius-xl);
}

.rvm-step {
  grid-template-columns: auto 1fr;
}

.rvm-ingredient-bullet,
.rvm-step-number {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.8rem;
  height: 1.8rem;
  border-radius: var(--radius-full);
  font-weight: var(--weight-bold);
  color: var(--color-primary);
  background: rgba(15, 23, 42, 0.22);
}

.rvm-ingredient-text,
.rvm-step-text {
  margin: 0;
  color: var(--text-default);
}

.rvm-ingredient-qty {
  color: var(--text-muted);
  font-size: 0.88rem;
  white-space: nowrap;
}

.rvm-empty {
  margin: 0;
  color: var(--text-muted);
}

/* ── Footer ── */

.rvm-footer {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  padding-top: var(--space-4);
  padding-bottom: var(--space-6);
  border-top: 1px solid var(--color-primary-10);
  background: rgba(255, 255, 255, 0.92);
}

.rvm-action-btn--primary {
  color: var(--text-on-dark);
  background: var(--gradient-primary);
}

.rvm-action-btn--secondary {
  color: var(--color-primary);
  background: var(--color-primary-10);
}

.rvm-action-btn--ghost {
  color: var(--color-primary);
  background: transparent;
  border: 1px solid var(--color-primary-20);
}

.rvm-action-btn:disabled {
  opacity: 0.65;
  cursor: not-allowed;
}

/* ── Animation ── */

@keyframes rvm-status-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(15, 23, 42, 0.38); }
  50%       { box-shadow: 0 0 0 7px rgba(15, 23, 42, 0); }
}

/* ── Mobile ── */

@media (max-width: 768px) {
  .rvm-overlay {
    padding: 0.75rem;
  }

  .rvm-modal {
    max-height: calc(100vh - var(--lpo-navbar-height, 103px) - 1.5rem);
    border-radius: 18px;
  }

  .rvm-hero {
    min-height: 190px;
  }

  .rvm-hero-status {
    right: 0.75rem;
    bottom: 0.75rem;
    max-width: calc(100% - 1.5rem);
    font-size: 0.72rem;
  }

  .rvm-header {
    flex-direction: column;
  }

  .rvm-header-actions,
  .rvm-footer {
    width: 100%;
  }

  .rvm-action-btn {
    flex: 1 1 100%;
  }
}
