/* ========================================
   Multistep Form v2 - Typeform Style
   ======================================== */

/* ========================================
   VARIABLES
   ======================================== */
:root {
  --tf-accent-color: #e88d28;
  --tf-bg: #ffffff;
  --tf-text: #1a1a1a;
  --tf-text-muted: #64748b;
  --tf-border: #e2e8f0;
  --tf-error: #ef4444;
  --tf-success: #10b981;
  --tf-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
  --tf-transition: 320ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* ========================================
   BASE
   ======================================== */
.typeform-page {
  min-height: 100vh;
  background: var(--tf-bg);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  color: var(--tf-text);
  overflow-x: hidden;
}

* {
  box-sizing: border-box;
}

/* ========================================
   LOGO FIXED
   ======================================== */
.tf-logo-fixed {
  position: fixed;
  top: 24px;
  left: 24px;
  z-index: 999;
  padding: 12px 16px;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(10px);
  border-radius: 12px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
  animation: fadeInUp 600ms ease-out;
}

.tf-logo-img {
  height: 36px;
  width: auto;
  display: block;
}

.tf-logo-text {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--tf-text);
  display: block;
}

/* ========================================
   PROGRESS BAR
   ======================================== */
.tf-progress {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: rgba(0, 0, 0, 0.05);
  z-index: 1000;
}

.tf-progress-bar {
  height: 100%;
  width: 0%;
  background: var(--tf-accent-color);
  transition: width var(--tf-transition);
}

/* ========================================
   CONTAINER
   ======================================== */
.tf-container {
  min-height: 100vh;
  position: relative;
}

/* ========================================
   SCREEN (Welcome, Questions, Thank You)
   ======================================== */
.tf-screen {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  visibility: hidden;
  transform: translateY(30px);
  transition: opacity var(--tf-transition), transform var(--tf-transition), visibility 0s var(--tf-transition);
  z-index: 1;
}

.tf-screen.is-active {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
  transition: opacity var(--tf-transition), transform var(--tf-transition), visibility 0s 0s;
  z-index: 2;
}

.tf-screen.is-exiting {
  opacity: 0;
  transform: translateY(-30px);
}

/* ========================================
   SPLIT LAYOUT
   ======================================== */
.tf-split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  height: 100%;
  min-height: 100vh;
}

/* Layout: Full Width (sin imagen) */
.tf-layout-full .tf-split {
  grid-template-columns: 1fr;
}

.tf-layout-full .tf-content {
  max-width: 800px;
  margin: 0 auto;
}

/* Layout: Left (contenido a la izquierda) */
.tf-layout-left .tf-split {
  grid-template-columns: 1fr 1fr;
}

/* Layout: Right (contenido a la derecha) - default */
.tf-layout-right .tf-split {
  grid-template-columns: 1fr 1fr;
}

.tf-layout-right .tf-visual {
  order: 1;
}

.tf-layout-right .tf-content {
  order: 2;
}

/* Left Side: Visual */
.tf-visual {
  position: relative;
  background: linear-gradient(135deg, #fff5e6 0%, #ffe4cc 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.tf-visual-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.tf-visual-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.tf-visual-pattern {
  width: 100%;
  height: 100%;
  background-image: 
    radial-gradient(circle at 25% 25%, rgba(232, 141, 40, 0.08) 0%, transparent 50%),
    radial-gradient(circle at 75% 75%, rgba(232, 141, 40, 0.05) 0%, transparent 50%);
}

.tf-brand-circle {
  width: 160px;
  height: 160px;
  border-radius: 50%;
  background: white;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.1);
}

.tf-brand-circle img {
  max-width: 80%;
  max-height: 80%;
}

.tf-brand-initial {
  font-size: 4rem;
  font-weight: 700;
  color: var(--tf-accent-color);
}

.tf-success-icon {
  width: 160px;
  height: 160px;
  border-radius: 50%;
  background: linear-gradient(135deg, #d1fae5 0%, #a7f3d0 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  animation: successPulse 2s ease infinite;
}

.tf-success-icon svg {
  color: var(--tf-success);
}

@keyframes successPulse {
  0%, 100% {
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.4);
  }
  50% {
    box-shadow: 0 0 0 20px rgba(16, 185, 129, 0);
  }
}

/* Right Side: Content */
.tf-content {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  overflow-y: auto;
}

.tf-content-inner {
  width: 100%;
  max-width: 560px;
  animation: fadeInUp 500ms ease;
}

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

/* ========================================
   BRANDING
   ======================================== */
.tf-brand {
  margin-bottom: 3rem;
}

.tf-brand-logo {
  height: 32px;
  width: auto;
}

.tf-brand-text {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--tf-accent-color);
}

/* ========================================
   TYPOGRAPHY
   ======================================== */
.tf-title {
  font-size: clamp(2rem, 5vw, 3rem);
  font-weight: 700;
  line-height: 1.2;
  margin: 0 0 1rem 0;
  color: var(--tf-text);
}

.tf-description {
  font-size: 1.25rem;
  line-height: 1.6;
  color: var(--tf-text-muted);
  margin: 0 0 2.5rem 0;
}

.tf-welcome-text {
  margin-bottom: 2.5rem;
}

/* ========================================
   QUESTION
   ======================================== */
.tf-question {
  border: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

.tf-question-header {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.tf-question-number {
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--tf-accent-color);
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.tf-question-title {
  font-size: clamp(1.5rem, 4vw, 2rem);
  font-weight: 700;
  line-height: 1.3;
  color: var(--tf-text);
  margin: 0;
}

.tf-required {
  color: var(--tf-error);
  font-size: 1.5rem;
  margin-left: 0.25rem;
}

.tf-question-description {
  font-size: 1.125rem;
  color: var(--tf-text-muted);
  margin: 0;
  line-height: 1.5;
}

.tf-question-answer {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

/* ========================================
   SECTION (Multiple Fields)
   ======================================== */
.tf-section-header {
  margin-bottom: 2rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.tf-section-number {
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--tf-accent-color);
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.tf-section-title {
  font-size: clamp(1.5rem, 4vw, 2rem);
  font-weight: 700;
  line-height: 1.3;
  color: var(--tf-text);
  margin: 0;
}

.tf-section-description {
  font-size: 1.125rem;
  color: var(--tf-text-muted);
  margin: 0;
  line-height: 1.5;
}

.tf-fields {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  margin-bottom: 2rem;
}

.tf-field {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.tf-label {
  font-size: 1rem;
  font-weight: 600;
  color: var(--tf-text);
  display: block;
}

.tf-field-input {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.tf-field-helper {
  font-size: 0.875rem;
  color: var(--tf-text-muted);
  font-style: italic;
}

.tf-section-actions {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin-top: 2rem;
}

/* ========================================
   INPUTS
   ======================================== */
.tf-input,
.tf-textarea,
.tf-select {
  width: 100%;
  font-family: inherit;
  font-size: 1.25rem;
  padding: 1rem 0;
  border: none;
  border-bottom: 2px solid var(--tf-border);
  background: transparent;
  color: var(--tf-text);
  outline: none;
  transition: border-color var(--tf-transition);
}

.tf-input::placeholder,
.tf-textarea::placeholder {
  color: var(--tf-text-muted);
  opacity: 0.6;
}

.tf-input:focus {
  outline: none;
  border-bottom-color: var(--tf-accent-color);
}

.tf-select:focus {
  outline: none;
  border-bottom-color: var(--tf-accent-color);
  border-left-color: transparent;
  border-right-color: transparent;
  border-top-color: transparent;
}

.tf-textarea {
  resize: vertical;
  min-height: 120px;
  line-height: 1.6;
  border: 1px solid var(--tf-border);
  border-radius: 8px;
  padding: 12px 16px;
  transition: border-color var(--tf-transition);
}

.tf-textarea:focus {
  outline: none;
  border-color: var(--tf-accent-color);
}

.tf-textarea-hint {
  font-size: 0.875rem;
  color: var(--tf-text-muted);
  font-weight: 500;
}

.tf-select {
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.5rem center;
  padding-right: 2.5rem;
}

.tf-select option {
  padding: 12px 16px;
  background: white;
  color: var(--tf-text);
}

/* ========================================
   OPTIONS (Radio & Checkbox)
   ======================================== */
.tf-options {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.tf-option {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem 1.25rem;
  border: 2px solid var(--tf-border);
  border-radius: 8px;
  background: var(--tf-bg);
  cursor: pointer;
  transition: all var(--tf-transition);
  user-select: none;
}

.tf-option:hover {
  border-color: var(--tf-accent-color);
  background: rgba(232, 141, 40, 0.02);
  transform: translateX(4px);
}

.tf-option-input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.tf-option-button {
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  border: 2px solid var(--tf-border);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #f8fafc;
  transition: all var(--tf-transition);
  font-weight: 600;
  color: var(--tf-text-muted);
}

.tf-option-letter {
  font-size: 1.125rem;
}

.tf-option:has(.tf-option-input:checked) .tf-option-button,
.tf-option-input:checked + .tf-option-button {
  background: var(--tf-accent-color);
  border-color: var(--tf-accent-color);
  color: white;
}

.tf-option:has(.tf-option-input:checked) {
  background: rgba(232, 141, 40, 0.05);
}

.tf-option-button svg {
  opacity: 0;
  transform: scale(0.5);
  transition: all var(--tf-transition);
  stroke: white;
}

.tf-option:has(.tf-option-input:checked) .tf-option-button svg {
  opacity: 1;
  transform: scale(1);
}

.tf-option-content {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  flex: 1;
}

.tf-option-label {
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--tf-text);
  line-height: 1.4;
}

.tf-option-desc {
  font-size: 0.9375rem;
  color: var(--tf-text-muted);
  line-height: 1.5;
}

/* ========================================
   BUTTONS
   ======================================== */
.tf-button {
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  font-family: inherit;
  font-size: 1.125rem;
  font-weight: 600;
  padding: 1rem 2rem;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: all var(--tf-transition);
  outline: none;
}

.tf-button-primary {
  background: var(--tf-accent-color);
  color: white;
  box-shadow: 0 4px 12px rgba(232, 141, 40, 0.3);
}

.tf-button-primary:hover:not(:disabled) {
  background: #d47a1a;
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(232, 141, 40, 0.4);
}

.tf-button-primary:active:not(:disabled) {
  transform: translateY(0);
}

.tf-button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none !important;
}

.tf-button svg {
  flex-shrink: 0;
}

/* ========================================
   ACTIONS
   ======================================== */
.tf-question-actions {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin-top: 1rem;
}

.tf-footer-note {
  font-size: 0.9375rem;
  color: var(--tf-text-muted);
  margin: 0;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.tf-footer-note kbd {
  display: inline-block;
  padding: 0.25rem 0.625rem;
  font-size: 0.875rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-weight: 600;
  color: var(--tf-text);
  background: #f1f5f9;
  border: 1px solid var(--tf-border);
  border-radius: 4px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

/* ========================================
   ERROR STATE
   ======================================== */
.tf-error {
  font-size: 0.9rem;
  color: var(--tf-error);
  font-weight: 600;
  min-height: 0;
  display: none;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.tf-error:not(:empty) {
  display: flex;
  animation: shake 0.4s ease;
}

.tf-error:not(:empty)::before {
  content: '⚠';
  font-size: 1.25rem;
}

.tf-field.has-error .tf-error {
  display: flex;
}

.tf-question.has-error .tf-input,
.tf-question.has-error .tf-textarea,
.tf-question.has-error .tf-select,
.tf-field.has-error .tf-input,
.tf-field.has-error .tf-textarea,
.tf-field.has-error .tf-select {
  border-bottom-color: var(--tf-error);
}

.tf-field.has-error .tf-textarea {
  border-color: var(--tf-error);
}

.tf-field.has-error .tf-input,
.tf-field.has-error .tf-textarea,
.tf-field.has-error .tf-select {
  animation: shake 400ms ease;
}

.tf-question.has-error {
  animation: shake 400ms ease;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  10%, 30%, 50%, 70%, 90% { transform: translateX(-8px); }
  20%, 40%, 60%, 80% { transform: translateX(8px); }
}

/* ========================================
   NAVIGATION
   ======================================== */
.tf-navigation {
  position: fixed;
  top: 50%;
  left: 1.5rem;
  transform: translateY(-50%);
  z-index: 100;
}

.tf-nav-button {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 2px solid var(--tf-border);
  background: white;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--tf-transition);
  box-shadow: var(--tf-shadow);
}

.tf-nav-button:hover {
  border-color: var(--tf-accent-color);
  color: var(--tf-accent-color);
  transform: translateX(-4px);
}

.tf-nav-button:disabled {
  opacity: 0.3;
  cursor: not-allowed;
  transform: none !important;
}

/* ========================================
   THANK YOU SCREEN
   ======================================== */
.tf-redirect-note {
  font-size: 1rem;
  color: var(--tf-accent-color);
  font-weight: 600;
  margin-top: 1.5rem;
  animation: pulse 1.5s ease infinite;
}

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

/* ========================================
   LOADING STATE
   ======================================== */
.tf-form.is-loading {
  pointer-events: none;
  opacity: 0.6;
}

/* ========================================
   RESPONSIVE
   ======================================== */
@media (max-width: 1024px) {
  .tf-footer-note {
    display: none;
  }
  
  .tf-split {
    grid-template-columns: 1fr;
    grid-template-rows: 40vh 1fr;
  }

  /* En tablets, todos los layouts se vuelven verticales */
  .tf-layout-full .tf-split,
  .tf-layout-left .tf-split,
  .tf-layout-right .tf-split {
    grid-template-columns: 1fr;
    grid-template-rows: 40vh 1fr;
  }

  /* Exception for full layout: single column, single row */
  .tf-layout-full .tf-split {
    grid-template-rows: 1fr;
  }

  .tf-layout-left .tf-visual {
    order: 1;
  }

  .tf-layout-left .tf-content {
    order: 2;
  }

  .tf-visual {
    padding: 0;
    border-bottom: 1px solid var(--tf-border);
  }

  .tf-navigation {
    top: auto;
    bottom: 1.5rem;
    left: 1.5rem;
    transform: none;
  }
}

@media (max-width: 640px) {
  .tf-logo-fixed {
    top: 16px;
    left: 16px;
    padding: 8px 12px;
  }

  .tf-logo-img {
    height: 28px;
  }

  .tf-layout-full .tf-split {
    /* Create a header row to avoid logo overlap */
    grid-template-rows: 80px 1fr;
  }
  
  .tf-layout-full .tf-content {
    grid-row: 2;
    padding-top: 2rem; /* Normal padding */
  }

  .tf-split {
    grid-template-rows: 25vh 1fr;
  }

  .tf-content {
    /* Standard padding */
    padding: 2rem 1rem 1.5rem 1rem;
  }
  
  .tf-navigation {
    top: 16px;
    right: 16px;
    bottom: auto;
    left: auto;
    transform: none;
  }
  
  .tf-nav-button {
    width: 40px;
    height: 40px;
  }

  .tf-title {
    font-size: 1.75rem;
  }

  .tf-description {
    font-size: 1.125rem;
  }

  .tf-question-title {
    font-size: 1.5rem;
  }

  .tf-input,
  .tf-textarea,
  .tf-select {
    font-size: 1.125rem;
  }

  .tf-option {
    padding: 0.875rem 1rem;
  }

  .tf-option-button {
    width: 36px;
    height: 36px;
  }

  .tf-option-label {
    font-size: 1rem;
  }

  .tf-brand-circle,
  .tf-success-icon {
    width: 120px;
    height: 120px;
  }

  .tf-brand-initial {
    font-size: 3rem;
  }
}

/* ========================================
   ACCESSIBILITY
   ======================================== */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}

.tf-button:focus-visible,
.tf-nav-button:focus-visible {
  outline: 2px solid var(--tf-accent-color);
  outline-offset: 2px;
}

.tf-option:focus-within {
  outline: none;
  border-color: var(--tf-accent-color);
  background: rgba(232, 141, 40, 0.05);
}

.tf-input:focus-visible,
.tf-textarea:focus-visible,
.tf-select:focus-visible {
  outline: none;
}

/* ========================================
   PRINT
   ======================================== */
@media print {
  .tf-progress,
  .tf-navigation,
  .tf-question-actions,
  .tf-whatsapp-button {
    display: none;
  }

  .tf-split {
    grid-template-columns: 1fr;
  }

  .tf-visual {
    display: none;
  }
}
