/* ==========================================================================
   COMPONENTS: Stepper, 3D Flip Card, Forms, Lightbox, Toasts
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. REGISTRATION STEPPER (Cadastro em 6 Etapas)
   -------------------------------------------------------------------------- */
.stepper-container {
  margin-bottom: 2.5rem;
}

.stepper-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: relative;
  max-width: 860px;
  margin: 0 auto;
}

.stepper-progress-bar {
  position: absolute;
  top: 20px;
  left: 0;
  right: 0;
  height: 3px;
  background-color: var(--border-light);
  z-index: 1;
}

.stepper-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--wine-800), var(--gold-500));
  transition: width var(--trans-normal);
  width: 0%;
}

.step-item {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  cursor: pointer;
}

.step-circle {
  width: 42px;
  height: 42px;
  border-radius: var(--radius-full);
  background-color: var(--bg-pure);
  border: 2px solid var(--border-light);
  color: var(--text-muted);
  font-weight: 700;
  font-size: 0.9375rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--trans-fast);
}

.step-item.active .step-circle {
  border-color: var(--wine-800);
  background-color: var(--wine-800);
  color: var(--text-white);
  box-shadow: 0 0 0 4px var(--wine-50);
}

.step-item.completed .step-circle {
  border-color: var(--emerald-600);
  background-color: var(--emerald-600);
  color: var(--text-white);
}

.step-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-top: 0.5rem;
  text-align: center;
  max-width: 80px;
}

.step-item.active .step-label {
  color: var(--wine-900);
  font-weight: 700;
}

/* Step panes */
.step-pane {
  display: none;
  animation: fadeInStep 300ms cubic-bezier(0.16, 1, 0.3, 1);
}

.step-pane.active {
  display: block;
}

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

/* --------------------------------------------------------------------------
   2. FORM CONTROLS & FIELDS
   -------------------------------------------------------------------------- */
.form-box {
  background-color: var(--bg-card);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-light);
  padding: 2.5rem;
  box-shadow: var(--shadow-sm);
  max-width: 840px;
  margin: 0 auto;
}

.form-group {
  margin-bottom: 1.5rem;
}

.form-label {
  display: block;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-main);
  margin-bottom: 0.45rem;
}

.form-label .required {
  color: var(--wine-600);
  margin-left: 2px;
}

.form-control {
  width: 100%;
  font-family: var(--font-sans);
  font-size: 1rem;
  padding: 0.8rem 1rem;
  min-height: 48px;
  border: 1.5px solid var(--border-light);
  border-radius: var(--radius-md);
  background-color: var(--bg-pure);
  color: var(--text-main);
  transition: border-color var(--trans-fast), box-shadow var(--trans-fast);
}

.form-control:focus {
  border-color: var(--wine-800);
  box-shadow: 0 0 0 3px rgba(92, 17, 30, 0.15);
  outline: none;
}

.form-control.error {
  border-color: #ef4444;
  background-color: #fffaf0;
}

.form-hint {
  font-size: 0.8125rem;
  color: var(--text-muted);
  margin-top: 0.35rem;
}

.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1.25rem;
}

/* Photo Uploader Component */
.photo-upload-area {
  border: 2px dashed var(--border-light);
  border-radius: var(--radius-lg);
  padding: 2rem;
  text-align: center;
  background-color: var(--bg-canvas);
  cursor: pointer;
  transition: border-color var(--trans-fast), background-color var(--trans-fast);
}

.photo-upload-area:hover {
  border-color: var(--wine-700);
  background-color: var(--wine-50);
}

.photo-preview-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  margin-top: 1.5rem;
}

.photo-crop-frame {
  width: 180px;
  height: 240px; /* 3x4 document ratio */
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: var(--shadow-md);
  border: 3px solid var(--wine-800);
  position: relative;
  background-color: #000;
}

.photo-crop-frame img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* --------------------------------------------------------------------------
   3. REALISTIC 3D FLIP CARD COMPONENT (Carteirinha de Membro)
   -------------------------------------------------------------------------- */
.card-scene {
  perspective: 1200px;
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
}

.card-flipper {
  position: relative;
  width: 100%;
  aspect-ratio: 85.6 / 53.98; /* Exact CR80 ratio */
  transform-style: preserve-3d;
  transition: transform 650ms cubic-bezier(0.2, 0.85, 0.4, 1.2);
  border-radius: 12px;
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.16);
}

.card-scene.flipped .card-flipper {
  transform: rotateY(180deg);
}

.card-side {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  border-radius: 12px;
  overflow: hidden;
  background-color: #fdfbf9;
  border: 1px solid rgba(0, 0, 0, 0.1);
  display: flex;
  flex-direction: column;
}

.card-front {
  background-image: url('/static/img/card_clean_marble.jpg');
  background-size: cover;
  background-position: center;
}

.card-back {
  transform: rotateY(180deg);
  background-image: url('/static/img/card_back_original_bg.jpg');
  background-size: cover;
  background-position: center;
}

/* Digital Card Header */
.card-header-bar {
  background-color: var(--wine-800);
  color: var(--text-white);
  padding: 4px 8px;
  text-align: center;
}

.card-church-name {
  font-size: clamp(0.55rem, 1.6vw, 0.72rem);
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  line-height: 1.1;
}

.card-ministry-name {
  font-size: clamp(0.48rem, 1.3vw, 0.62rem);
  color: var(--gold-400);
  font-weight: 700;
  text-transform: uppercase;
}

.card-address-bar {
  font-size: clamp(0.38rem, 1vw, 0.5rem);
  color: var(--text-muted);
  text-align: center;
  padding: 2px 4px;
}

/* Card Body Layout */
.card-body-front {
  display: grid;
  grid-template-columns: 1.3fr 0.9fr 1.35fr;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  flex-grow: 1;
}

.card-logo-front {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
}

.card-logo-front img {
  width: 100%;
  max-width: 145px;
  max-height: 105px;
  object-fit: contain;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.08));
}

.card-motto {
  font-size: clamp(0.32rem, 0.72vw, 0.42rem);
  font-weight: 800;
  color: var(--wine-800);
  text-align: center;
  letter-spacing: 0.02em;
  white-space: nowrap;
  line-height: 1.1;
  margin-top: 4px;
}

.card-photo-box {
  width: 100%;
  max-width: 86px;
  aspect-ratio: 3 / 4;
  border: 1.5px solid var(--wine-800);
  border-radius: 4px;
  overflow: hidden;
  background-color: #fff;
  box-shadow: var(--shadow-sm);
  margin: 0 auto;
}

.card-photo-box img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.card-info-front {
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.card-role-pill {
  background-color: var(--wine-800);
  color: var(--text-white);
  font-size: clamp(0.48rem, 1.2vw, 0.62rem);
  font-weight: 800;
  padding: 2px 6px;
  border-radius: 4px;
  display: inline-block;
  width: fit-content;
  text-transform: uppercase;
  margin-bottom: 4px;
}

.card-name-front {
  font-size: clamp(0.65rem, 1.6vw, 0.82rem);
  font-weight: 800;
  color: var(--text-main);
  text-transform: uppercase;
  line-height: 1.15;
  margin-bottom: 4px;
}

.card-congregation-front {
  font-size: clamp(0.45rem, 1.1vw, 0.58rem);
  color: var(--text-muted);
  line-height: 1.2;
}

.card-congregation-front strong {
  color: var(--text-main);
  display: block;
}

.card-number-front {
  margin-top: 4px;
  font-size: clamp(0.5rem, 1.3vw, 0.65rem);
  color: var(--wine-800);
  font-weight: 800;
}

/* Card Back Layout */
.card-body-back {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding: 10px 14px;
  flex-grow: 1;
  position: relative;
  z-index: 2;
}

.card-field {
  margin-bottom: 4px;
}

.card-field-label {
  font-size: clamp(0.38rem, 0.9vw, 0.48rem);
  font-weight: 800;
  color: var(--wine-800);
  text-transform: uppercase;
  line-height: 1;
}

.card-field-value {
  font-size: clamp(0.48rem, 1.1vw, 0.6rem);
  font-weight: 600;
  color: var(--text-main);
  text-transform: uppercase;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card-back-footer {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  padding: 4px 14px 8px;
  position: relative;
  z-index: 2;
}

.card-signature-box {
  text-align: center;
  border-top: 1px solid var(--text-main);
  padding-top: 2px;
  width: 140px;
}

.card-signature-name {
  font-size: clamp(0.42rem, 1vw, 0.52rem);
  font-weight: 800;
}

.card-signature-title {
  font-size: clamp(0.36rem, 0.8vw, 0.44rem);
  font-style: italic;
  color: var(--text-muted);
}

.card-qr-box {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.card-qr-box img {
  width: 44px;
  height: 44px;
}

.card-qr-box span {
  font-size: 0.4rem;
  font-weight: 700;
  color: var(--wine-800);
  margin-top: 1px;
}

/* Card Flip Controls */
.card-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  margin-top: 1.5rem;
}

/* --------------------------------------------------------------------------
   4. TOAST NOTIFICATIONS
   -------------------------------------------------------------------------- */
.toast-container {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  background-color: var(--text-main);
  color: var(--text-white);
  padding: 0.85rem 1.4rem;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.9375rem;
  font-weight: 500;
  animation: slideInToast 250ms cubic-bezier(0.16, 1, 0.3, 1);
  max-width: 360px;
}

.toast.toast-success {
  background-color: var(--wine-900);
  border-left: 4px solid #38bdf8;
}

.toast.toast-error {
  background-color: #991b1b;
}

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

/* --------------------------------------------------------------------------
   5. LIGHTBOX COMPONENT
   -------------------------------------------------------------------------- */
.lightbox {
  position: fixed;
  inset: 0;
  background-color: rgba(15, 23, 42, 0.94);
  backdrop-filter: blur(8px);
  z-index: 10000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 2rem;
}

.lightbox.active {
  display: flex;
}

.lightbox-content {
  position: relative;
  max-width: 90vw;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.lightbox-img {
  max-width: 100%;
  max-height: 80vh;
  object-fit: contain;
  border-radius: var(--radius-md);
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.5);
}

.lightbox-caption {
  color: var(--text-white);
  font-size: 1rem;
  margin-top: 1rem;
  text-align: center;
}

.lightbox-close {
  position: absolute;
  top: 1.5rem;
  right: 1.5rem;
  background: transparent;
  border: none;
  color: var(--text-white);
  font-size: 2rem;
  cursor: pointer;
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-full);
  transition: background-color var(--trans-fast);
}

.lightbox-close:hover {
  background-color: rgba(255, 255, 255, 0.15);
}
