/* Stake Communication Intelligence Dashboard - Shared & Survey */

:root {
  --primary: #004b87;
  --secondary: #2d8cff;
  --background: #f4f6f8;
  --card-bg: #ffffff;
  --card-shadow: 0 2px 12px rgba(0, 75, 135, 0.08);
  --card-shadow-hover: 0 8px 24px rgba(0, 75, 135, 0.12);
  --text: #1a1a2e;
  --text-muted: #5c6b7a;
  --border: #e2e8f0;
  --success: #0d9488;
  --radius: 12px;
  --radius-sm: 8px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: 'Outfit', -apple-system, BlinkMacSystemFont, sans-serif;
  background: linear-gradient(135deg, #f4f6f8 0%, #e8eef4 50%, #f0f4f8 100%);
  background-size: 200% 200%;
  animation: bgShift 15s ease infinite;
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

@keyframes bgShift {
  0%, 100% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
}

/* Page load entrance */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(24px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

h1, h2, h3 {
  font-weight: 600;
  margin: 0 0 0.5em;
}

a {
  color: var(--secondary);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

button {
  font-family: inherit;
  cursor: pointer;
}

input, select, button {
  font-size: 1rem;
}

/* Survey container - full page */
.survey-wrap {
  min-height: 100vh;
  min-height: 100dvh;
  width: 100%;
  padding: 0;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-start;
  animation: fadeIn 0.5s ease;
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
  padding-bottom: env(safe-area-inset-bottom);
}

.survey-card {
  background: var(--card-bg);
  border-radius: 0;
  box-shadow: none;
  width: 100%;
  max-width: 100%;
  min-height: 100vh;
  min-height: 100dvh;
  padding: 1.5rem 1.25rem 2rem;
  transition: box-shadow 0.3s ease, transform 0.3s ease;
  display: flex;
  flex-direction: column;
  flex: 1;
}

@media (min-width: 768px) {
  .survey-wrap {
    padding: 1.5rem;
    align-items: center;
  }

  .survey-card {
    max-width: 640px;
    min-height: auto;
    border-radius: var(--radius);
    box-shadow: var(--card-shadow);
    padding: 2rem;
  }

  .survey-card:hover {
    box-shadow: var(--card-shadow-hover);
  }
}

@keyframes cardFloat {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-4px); }
}

.survey-card {
  animation: fadeInUp 0.6s ease 0.1s both, cardFloat 5s ease-in-out 0.8s infinite;
}

.survey-header {
  text-align: center;
  margin-bottom: 1.5rem;
}

.survey-header h1 {
  color: var(--primary);
  font-size: 1.5rem;
  margin-bottom: 0.25rem;
}

.survey-header > p {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin: 0;
}

@keyframes logoFloat {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-3px); }
}

.survey-logo {
  display: block;
  max-width: 160px;
  height: auto;
  margin: 0 auto 1rem;
  animation: fadeInUp 0.5s ease 0.25s both, logoFloat 4s ease-in-out 1.2s infinite;
}

.survey-header h1 {
  animation: fadeInUp 0.5s ease 0.35s both;
}

.survey-header p {
  animation: fadeInUp 0.5s ease 0.45s both;
}

@keyframes infoGlow {
  0%, 100% { box-shadow: inset 4px 0 0 0 var(--primary); }
  50% { box-shadow: inset 4px 0 0 0 var(--primary), 0 0 20px rgba(0, 75, 135, 0.15); }
}

/* Survey intro / description */
.survey-info {
  background: rgba(0, 75, 135, 0.06);
  border-left: 4px solid var(--primary);
  border-radius: var(--radius-sm);
  padding: 1rem 1.25rem;
  margin-bottom: 1.5rem;
  animation: fadeInUp 0.5s ease 0.55s both, infoGlow 3s ease-in-out 1.5s infinite;
}

.survey-info-img {
  width: 100%;
  max-height: 140px;
  object-fit: cover;
  border-radius: var(--radius-sm);
  margin-bottom: 1rem;
  animation: fadeIn 0.6s ease 0.6s both;
}

.survey-info p {
  margin: 0;
  font-size: 0.9rem;
  color: var(--text);
  line-height: 1.55;
}

.step-desc {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin: -0.35em 0 1rem;
}

.survey-already-done {
  text-align: center;
  padding: 1.5rem 0;
  background: rgba(13, 148, 136, 0.08);
  border-radius: var(--radius-sm);
  border-left: 4px solid var(--success);
}

.survey-already-done-icon {
  font-size: 2rem;
  color: var(--success);
  font-weight: 700;
  margin: 0 0 0.5rem;
}

.survey-already-done h2 {
  font-size: 1.1rem;
  color: var(--text);
  margin: 0 0 0.5rem;
}

.survey-already-done p {
  margin: 0;
  font-size: 0.9rem;
  color: var(--text-muted);
}

/* Progress bar */
.progress-wrap {
  margin-bottom: 1.75rem;
  animation: fadeIn 0.5s ease 0.65s both;
}

.progress-bar {
  height: 6px;
  background: var(--border);
  border-radius: 999px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--secondary), var(--primary));
  background-size: 200% 100%;
  border-radius: 999px;
  transition: width 0.5s cubic-bezier(0.4, 0, 0.2, 1);
  animation: progressShine 2s ease-in-out infinite, progressGradient 4s linear infinite;
}

@keyframes progressShine {
  0% { opacity: 1; }
  50% { opacity: 0.85; }
  100% { opacity: 1; }
}

@keyframes progressGradient {
  0% { background-position: 0% 50%; }
  100% { background-position: 200% 50%; }
}

@keyframes progressTextPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}

.progress-text {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 0.5rem;
  animation: progressTextPulse 2.5s ease-in-out infinite;
}

/* Steps */
.survey-step {
  display: none;
}

.survey-step.active {
  display: block;
  animation: stepIn 0.4s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

@keyframes stepIn {
  from {
    opacity: 0;
    transform: translateY(16px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.survey-step.active .option-card {
  animation: optionIn 0.4s ease backwards;
}

.survey-step.active .option-card:nth-child(1) { animation-delay: 0.05s; }
.survey-step.active .option-card:nth-child(2) { animation-delay: 0.1s; }
.survey-step.active .option-card:nth-child(3) { animation-delay: 0.15s; }
.survey-step.active .option-card:nth-child(4) { animation-delay: 0.2s; }
.survey-step.active .option-card:nth-child(5) { animation-delay: 0.25s; }
.survey-step.active .option-card:nth-child(6) { animation-delay: 0.3s; }

@keyframes optionIn {
  from {
    opacity: 0;
    transform: translateX(-12px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes stepTitleIn {
  from {
    opacity: 0;
    transform: translateX(-20px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

.survey-step.active h2 {
  animation: stepTitleIn 0.45s cubic-bezier(0.4, 0, 0.2, 1) 0.05s backwards;
}

.survey-step.active .step-desc {
  animation: stepTitleIn 0.45s cubic-bezier(0.4, 0, 0.2, 1) 0.12s backwards;
}

.survey-step h2 {
  font-size: 1.1rem;
  color: var(--text);
  margin-bottom: 1rem;
}

/* Options - card style */
.options-grid {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.option-card {
  display: flex;
  align-items: center;
  padding: 1rem 1.25rem;
  background: var(--background);
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: border-color 0.25s ease, background 0.25s ease, transform 0.25s ease, box-shadow 0.25s ease;
}

.option-card:hover {
  border-color: var(--secondary);
  background: rgba(45, 140, 255, 0.06);
  transform: translateX(4px);
  box-shadow: 0 4px 12px rgba(0, 75, 135, 0.08);
}

@keyframes selectPulse {
  0% { transform: scale(1); }
  50% { transform: scale(1.02); }
  100% { transform: scale(1); }
}

.option-card.selected {
  border-color: var(--primary);
  background: rgba(0, 75, 135, 0.08);
  box-shadow: 0 2px 8px rgba(0, 75, 135, 0.12);
}

.survey-step.active .option-card.selected {
  animation: selectPulse 0.5s ease backwards;
}

.option-card input {
  margin-right: 0.75rem;
  accent-color: var(--primary);
  width: 1.1rem;
  height: 1.1rem;
}

.option-card label {
  flex: 1;
  cursor: pointer;
  margin: 0;
  font-weight: 500;
}

/* Buttons */
.btn-wrap {
  display: flex;
  gap: 0.75rem;
  margin-top: 1.5rem;
  flex-wrap: wrap;
}

.survey-step.active .btn-wrap {
  animation: fadeInUp 0.4s ease 0.35s backwards;
}

.btn {
  padding: 0.75rem 1.5rem;
  border-radius: var(--radius-sm);
  font-weight: 600;
  border: none;
  transition: background 0.25s ease, transform 0.2s ease, box-shadow 0.2s ease;
}

.btn:hover {
  transform: translateY(-1px);
}

.btn:active {
  transform: scale(0.98) translateY(0);
}

.btn-primary {
  background: var(--primary);
  color: white;
}

.btn-primary:hover {
  background: #003a6a;
  box-shadow: 0 4px 14px rgba(0, 75, 135, 0.35);
}

.btn-secondary {
  background: var(--background);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  background: var(--border);
}

.btn-success {
  background: var(--success);
  color: white;
}

.btn-success:hover {
  background: #0f766e;
}

/* Success screen */
@keyframes successPop {
  0% { opacity: 0; transform: scale(0.5); }
  60% { transform: scale(1.08); }
  100% { opacity: 1; transform: scale(1); }
}

@keyframes successFadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.success-screen {
  text-align: center;
  padding: 1rem 0;
}

.success-images {
  display: flex;
  gap: 0.75rem;
  justify-content: center;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}

.success-images img {
  max-width: 140px;
  max-height: 100px;
  width: auto;
  height: auto;
  object-fit: cover;
  border-radius: var(--radius-sm);
  animation: successFadeIn 0.5s ease backwards, successImgPulse 3s ease-in-out 1.2s infinite;
}

@keyframes successImgPulse {
  0%, 100% { transform: scale(1); box-shadow: 0 2px 8px rgba(0,0,0,0.06); }
  50% { transform: scale(1.03); box-shadow: 0 6px 16px rgba(0, 75, 135, 0.12); }
}

.success-images img:nth-child(1) {
  animation: successFadeIn 0.5s ease 0.1s backwards, successImgPulse 3s ease-in-out 1.2s infinite;
}

.success-images img:nth-child(2) {
  animation: successFadeIn 0.5s ease 0.2s backwards, successImgPulse 3s ease-in-out 1.4s infinite;
}

.success-screen .icon {
  font-size: 3rem;
  margin-bottom: 0.5rem;
  color: var(--success);
  font-weight: 700;
  animation: successPop 0.5s ease 0.25s backwards;
}

.success-screen h2 {
  animation: successFadeIn 0.5s ease 0.35s backwards;
}

.success-screen > p {
  animation: successFadeIn 0.5s ease 0.45s backwards;
}

.success-screen h2 {
  color: var(--success);
  margin-bottom: 0.5rem;
}

.success-screen > p {
  color: var(--text-muted);
  margin-bottom: 1.5rem;
}

.share-actions {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  animation: successFadeIn 0.5s ease 0.55s backwards;
}

.qr-section {
  animation: successFadeIn 0.5s ease 0.65s backwards;
}

.btn-whatsapp {
  background: #25d366;
  color: white;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.btn-whatsapp {
  transition: background 0.25s ease, transform 0.2s ease, box-shadow 0.2s ease;
}

.btn-whatsapp:hover {
  background: #20bd5a;
  transform: translateY(-2px);
  box-shadow: 0 4px 14px rgba(37, 211, 102, 0.4);
}

.qr-section {
  margin-top: 1.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
}

.qr-section p {
  font-size: 0.9rem;
  margin-bottom: 0.75rem;
}

#qr-canvas {
  display: block;
  margin: 0 auto;
  border-radius: var(--radius-sm);
}

/* Form validation */
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  15% { transform: translateX(-6px); }
  30% { transform: translateX(6px); }
  45% { transform: translateX(-4px); }
  60% { transform: translateX(4px); }
  75% { transform: translateX(-2px); }
}

.error-msg {
  color: #dc2626;
  font-size: 0.85rem;
  margin-top: 0.5rem;
}

.option-card.error {
  border-color: #dc2626;
  animation: shake 0.5s ease;
}

/* Mobile & touch friendly */
html {
  -webkit-text-size-adjust: 100%;
  touch-action: manipulation;
}

.survey-card {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.option-card {
  min-height: 48px;
}

.btn {
  min-height: 48px;
  min-width: 44px;
  padding: 0.875rem 1.5rem;
}

@media (max-width: 767px) {
  .survey-wrap {
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
  }

  .survey-card {
    padding: 1rem 1rem 1.5rem;
    padding-left: max(1rem, env(safe-area-inset-left));
    padding-right: max(1rem, env(safe-area-inset-right));
    padding-bottom: max(1.5rem, env(safe-area-inset-bottom));
  }

  .survey-header {
    margin-bottom: 1.25rem;
  }

  .survey-header h1 {
    font-size: 1.35rem;
    line-height: 1.3;
  }

  .survey-header > p {
    font-size: 0.9rem;
  }

  .survey-logo {
    max-width: 140px;
  }

  .survey-info {
    padding: 1rem;
    margin-bottom: 1.25rem;
  }

  .survey-info-img {
    max-height: 120px;
  }

  .progress-wrap {
    margin-bottom: 1.5rem;
  }

  .survey-step h2 {
    font-size: 1.15rem;
    margin-bottom: 0.75rem;
  }

  .step-desc {
    font-size: 0.9rem;
    margin-bottom: 0.75rem;
  }

  .option-card {
    padding: 1rem 1.25rem;
    min-height: 52px;
  }

  .option-card input {
    width: 1.25rem;
    height: 1.25rem;
    min-width: 1.25rem;
    min-height: 1.25rem;
  }

  .btn-wrap {
    margin-top: 1.25rem;
    gap: 0.75rem;
  }

  .btn {
    flex: 1;
    min-width: 0;
    justify-content: center;
  }

  .btn-wrap .btn-primary {
    order: 1;
  }

  .btn-wrap .btn-secondary {
    order: 0;
  }

  .success-screen {
    padding: 0.5rem 0 1rem;
  }

  .success-images img {
    max-width: 120px;
    max-height: 90px;
  }

  .qr-section {
    margin-top: 1.25rem;
    padding-top: 1.25rem;
  }

  #qr-canvas {
    max-width: 100%;
    height: auto;
  }
}

@media (max-width: 480px) {
  .survey-card {
    padding: 0.875rem 0.875rem 1.25rem;
  }

  .survey-header h1 {
    font-size: 1.25rem;
  }

  .option-card {
    padding: 0.875rem 1rem;
    min-height: 48px;
  }
}
