/* ============================================
   Background
   ============================================ */
body {
  background: linear-gradient(135deg, #eef2ff 0%, #f0f9ff 30%, #faf5ff 60%, #fefce8 100%);
  min-height: 100dvh;
}

/* ============================================
   Card
   ============================================ */
.main-card {
  background: #fff;
  border-radius: 1.5rem;
  box-shadow:
    0 4px 6px -1px rgba(0,0,0,.04),
    0 12px 36px -6px rgba(0,0,0,.07),
    0 0 0 1px rgba(0,0,0,.03);
  padding: 1.5rem;
  opacity: 0;
  transform: translateY(32px) scale(0.96);
}
@media (min-width: 640px) {
  .main-card { padding: 2.25rem; border-radius: 1.75rem; }
}
.main-card.card-entered {
  animation: card-in 0.55s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}
@keyframes card-in {
  from { opacity: 0; transform: translateY(32px) scale(0.96); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* ============================================
   Agent Name
   ============================================ */
.agent-name {
  display: inline-block;
  padding: 0.25rem 0.875rem;
  border-radius: 9999px;
  font-size: 0.8125rem;
  font-weight: 600;
  color: #4f46e5;
  background: #eef2ff;
  animation: fade-in .35s ease both;
}

/* ============================================
   Language Switcher
   ============================================ */
.lang-btn {
  position: absolute;
  top: -0.25rem;
  right: 0;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 0.375rem 0.625rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 600;
  color: #6b7280;
  background: rgba(0,0,0,.03);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.2s;
  z-index: 10;
}
.lang-btn:hover {
  background: rgba(0,0,0,.06);
  color: #374151;
  border-color: #e5e7eb;
}
.lang-globe {
  opacity: 0.6;
  flex-shrink: 0;
}

.lang-dropdown {
  position: absolute;
  top: 2rem;
  right: 0;
  min-width: 160px;
  max-width: 220px;
  max-height: 260px;
  overflow-y: auto;
  background: #fff;
  border-radius: 0.75rem;
  box-shadow: 0 12px 40px rgba(0,0,0,.12), 0 0 0 1px rgba(0,0,0,.05);
  z-index: 20;
  padding: 0.375rem;
}
.lang-list {
  display: flex;
  flex-direction: column;
}
.lang-option {
  width: 100%;
  padding: 0.5rem 0.75rem;
  border-radius: 0.5rem;
  font-size: 0.8125rem;
  text-align: left;
  border: none;
  background: transparent;
  color: #374151;
  cursor: pointer;
  transition: background 0.15s;
}
.lang-option:hover {
  background: #f3f4f6;
}
.lang-option.active {
  background: #eef2ff;
  color: #4f46e5;
  font-weight: 600;
}

/* ============================================
   Star Rating
   ============================================ */
.star-btn {
  width: 52px; height: 52px;
  padding: 0;
  border: none;
  background: transparent;
  cursor: pointer;
  outline: none;
  -webkit-tap-highlight-color: transparent;
}
@media (min-width: 640px) {
  .star-btn { width: 48px; height: 48px; }
}
.star-btn:focus-visible span {
  transform: scale(1.15);
}

.star-btn span {
  position: relative;
  display: block;
  font-size: 44px;
  line-height: 1;
  color: #e5e7eb;
  transition: color 0.15s ease, transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}
@media (min-width: 640px) {
  .star-btn span { font-size: 40px; }
}

/* committed: filled */
.star-btn.full span {
  color: #fbbf24;
}

/* committed: half */
.star-btn.half span {
  color: transparent;
}
.star-btn.half span::before {
  content: '★';
  position: absolute;
  left: 0;
  width: 50%;
  overflow: hidden;
  color: #fbbf24;
}

/* preview: filled (same visual, different class) */
.star-btn.pre-full span {
  color: #fbbf24;
}

/* preview: half */
.star-btn.pre-half span {
  color: transparent;
}
.star-btn.pre-half span::before {
  content: '★';
  position: absolute;
  left: 0;
  width: 50%;
  overflow: hidden;
  color: #fbbf24;
}

/* pop animation */
.star-btn.pop span {
  animation: star-pop 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes star-pop {
  0%   { transform: scale(1); }
  40%  { transform: scale(1.22); }
  100% { transform: scale(1); }
}

/* Rating text */
#rating-text {
  transition: opacity 0.2s ease, transform 0.2s ease, color 0.3s ease;
}

/* ============================================
   Feedback Tags
   ============================================ */
.feedback-tag {
  padding: 0.5rem 1rem;
  border-radius: 9999px;
  font-size: 0.8125rem;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid #e5e7eb;
  background: #fff;
  color: #4b5563;
  transition: all 0.2s ease-out;
  outline: none;
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  max-width: 100%;
  word-break: break-word;
}
@media (min-width: 640px) {
  .feedback-tag {
    padding: 0.375rem 0.875rem;
    min-height: auto;
  }
}
.feedback-tag:hover {
  border-color: #a5b4fc;
  background: #f5f3ff;
}
.feedback-tag:focus-visible {
  box-shadow: 0 0 0 3px rgba(99,102,241,.3);
}
/* colored selected states — index-based via JS */
.feedback-tag.tag-selected {
  color: #fff;
  border-color: transparent;
}
.feedback-tag.tag-selected:hover {
  opacity: 0.9;
}
/* color palette for selected tags */
.feedback-tag.tag-c0 { background: #6366f1; border-color: #6366f1; }
.feedback-tag.tag-c1 { background: #10b981; border-color: #10b981; }
.feedback-tag.tag-c2 { background: #f59e0b; border-color: #f59e0b; }
.feedback-tag.tag-c3 { background: #8b5cf6; border-color: #8b5cf6; }
.feedback-tag.tag-c4 { background: #ec4899; border-color: #ec4899; }
.feedback-tag.tag-c5 { background: #06b6d4; border-color: #06b6d4; }
.feedback-tag.tag-c6 { background: #f97316; border-color: #f97316; }
.feedback-tag.tag-c7 { background: #3b82f6; border-color: #3b82f6; }

/* tag pop animation */
@keyframes tag-pop {
  0%   { transform: scale(1); }
  40%  { transform: scale(1.08); }
  100% { transform: scale(1); }
}
.tag-pop {
  animation: tag-pop 0.28s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* ============================================
   Textarea
   ============================================ */
.feedback-textarea {
  width: 100%;
  min-height: 80px;
  padding: 0.75rem 0.875rem;
  border-radius: 0.75rem;
  border: 1.5px solid #e5e7eb;
  background: #f9fafb;
  font-size: 1rem;
  line-height: 1.6;
  color: #1f2937;
  resize: vertical;
  transition: all 0.2s ease-out;
  outline: none;
  font-family: inherit;
}
@media (min-width: 640px) {
  .feedback-textarea { font-size: 0.875rem; }
}
.feedback-textarea:focus {
  border-color: #a5b4fc;
  background: #fff;
  box-shadow: 0 0 0 4px rgba(79, 70, 229, 0.06);
}
.feedback-textarea::placeholder {
  color: #9ca3af;
}

.email-input {
  width: 100%;
  padding: 0.625rem 0.875rem;
  border-radius: 0.75rem;
  border: 1.5px solid #e5e7eb;
  background: #f9fafb;
  font-size: 0.875rem;
  color: #1f2937;
  outline: none;
  transition: border-color .2s, box-shadow .2s, background .2s;
}
.email-input:focus {
  border-color: #a5b4fc;
  background: #fff;
  box-shadow: 0 0 0 4px rgba(79, 70, 229, 0.06);
}
.email-input::placeholder {
  color: #9ca3af;
}

/* ============================================
   Tip Buttons
   ============================================ */
.tip-btn {
  padding: 0.75rem 0.5rem;
  border-radius: 0.75rem;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  border: 1.5px solid #e5e7eb;
  background: #fffbeb;
  color: #92400e;
  transition: all 0.2s ease-out;
  outline: none;
  min-height: 48px;
  opacity: 0;
  animation: tip-stagger-in 0.35s cubic-bezier(0.16, 1, 0.3, 1) forwards;
  word-break: break-word;
  overflow-wrap: break-word;
}
@media (min-width: 640px) {
  .tip-btn {
    padding: 0.625rem 1rem;
    font-size: 0.875rem;
    min-height: auto;
  }
}
.tip-btn:hover {
  border-color: #fcd34d;
  background: #fef3c7;
}
.tip-btn:focus-visible {
  box-shadow: 0 0 0 3px rgba(245,158,11,.3);
}
.tip-btn.tip-selected {
  background: linear-gradient(135deg, #f59e0b, #d97706);
  color: #fff;
  border-color: transparent;
  box-shadow: 0 4px 14px rgba(245,158,11,.35);
}
.tip-btn.tip-selected:hover {
  background: linear-gradient(135deg, #d97706, #b45309);
  box-shadow: 0 6px 18px rgba(245,158,11,.4);
}

@keyframes tip-stagger-in {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Custom tip */
.tip-custom-input {
  flex: 1;
  padding: 0.5rem 0.75rem;
  border-radius: 0.625rem;
  border: 1.5px solid #e5e7eb;
  background: #f9fafb;
  font-size: 1rem;
  font-weight: 600;
  color: #b45309;
  transition: all 0.2s ease-out;
  outline: none;
  min-width: 0;
}
.tip-custom-input:focus {
  border-color: #fcd34d;
  background: #fff;
  box-shadow: 0 0 0 3px rgba(245,158,11,.12);
}
.tip-custom-input::placeholder {
  color: #9ca3af;
  font-weight: 400;
  font-size: 0.875rem;
}

/* ============================================
   Slider (custom tip — scoped to #tip-custom-wrap)
   ============================================ */
#tip-custom-wrap .slider-track {
  position: relative;
  height: 12px;
  background: #fef3c7;
  border-radius: 6px;
  cursor: pointer;
  touch-action: none;
  user-select: none;
  margin: 0 2px;
  outline: none;
}
@media (min-width: 640px) {
  #tip-custom-wrap .slider-track { height: 8px; border-radius: 4px; }
}
#tip-custom-wrap .slider-track:focus-visible {
  box-shadow: 0 0 0 3px rgba(245,158,11,.25);
}
#tip-custom-wrap .slider-track.slider-active .slider-thumb {
  box-shadow: 0 4px 18px rgba(245,158,11,.45);
  transform: translate(-50%, -50%) scale(1.15);
}

#tip-custom-wrap .slider-fill {
  position: absolute;
  top: 0; left: 0;
  height: 100%;
  background: linear-gradient(90deg, #fbbf24, #f59e0b);
  border-radius: 6px;
  transition: width 0.08s ease-out;
  pointer-events: none;
}
@media (min-width: 640px) {
  #tip-custom-wrap .slider-fill { border-radius: 4px; }
}

#tip-custom-wrap .slider-thumb {
  position: absolute;
  top: 50%;
  width: 28px; height: 28px;
  background: #fff;
  border: 3px solid #f59e0b;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  box-shadow: 0 2px 8px rgba(245,158,11,.25);
  transition: left 0.08s ease-out, box-shadow 0.2s, transform 0.2s;
  cursor: grab;
  pointer-events: none;
}
@media (min-width: 640px) {
  #tip-custom-wrap .slider-thumb { width: 24px; height: 24px; }
}

/* ============================================
   Submit Button
   ============================================ */
.submit-btn {
  width: 100%;
  padding: 0.875rem;
  border-radius: 0.875rem;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  background: linear-gradient(135deg, #6366f1, #4f46e5);
  color: #fff;
  transition: all 0.25s ease-out;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  outline: none;
  min-height: 52px;
  word-break: break-word;
  text-align: center;
  white-space: normal;
}
@media (min-width: 640px) {
  .submit-btn { min-height: auto; }
}
.submit-btn:hover:not(:disabled) {
  background: linear-gradient(135deg, #4f46e5, #4338ca);
  box-shadow: 0 8px 25px rgba(79,70,229,.3);
  transform: translateY(-1px);
}
.submit-btn:active:not(:disabled) {
  transform: translateY(0);
}
.submit-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}
.submit-btn:focus-visible {
  box-shadow: 0 0 0 3px rgba(79,70,229,.5);
}
.submit-btn.submit-ready {
  animation: submit-glow 0.7s ease-out;
}
@keyframes submit-glow {
  0%,100% { box-shadow: 0 0 0 0 rgba(99,102,241,.4); }
  50%     { box-shadow: 0 0 0 10px rgba(99,102,241,0); }
}

/* Spinner */
.spinner {
  display: inline-block;
  width: 1.125rem;
  height: 1.125rem;
  border: 2px solid rgba(255,255,255,.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
.spinner.hidden { display: none; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ============================================
   Section Divider
   ============================================ */
.section-divider {
  height: 1px;
  background: linear-gradient(to right, transparent, #f3f4f6, transparent);
  margin: 1rem 0;
}
@media (min-width: 640px) {
  .section-divider { margin: 1.5rem 0; }
}

/* ============================================
   Section Title
   ============================================ */
.section-title {
  font-size: 0.9375rem;
  font-weight: 600;
  color: #374151;
  margin-bottom: 0.75rem;
  display: flex;
  align-items: center;
  gap: 0.375rem;
}

/* ============================================
   Success Card
   ============================================ */
.success-icon-wrap {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: linear-gradient(135deg, #10b981, #34d399);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 1rem;
  box-shadow: 0 8px 30px rgba(16,185,129,.3);
}
@keyframes check-draw {
  from { stroke-dashoffset: 60; }
  to   { stroke-dashoffset: 0; }
}
.success-check {
  stroke-dasharray: 60;
  animation: check-draw 0.5s 0.2s cubic-bezier(0.16, 1, 0.3, 1) both;
}
@keyframes fade-in-up {
  from { opacity: 0; transform: translateY(24px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
.success-show {
  animation: fade-in-up 0.5s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

/* ============================================
   Shake
   ============================================ */
@keyframes shake {
  0%,100% { transform: translateX(0); }
  20%     { transform: translateX(-6px); }
  40%     { transform: translateX(6px); }
  60%     { transform: translateX(-4px); }
  80%     { transform: translateX(4px); }
}
.animate-shake {
  animation: shake 0.5s ease-in-out;
}

/* ============================================
   Overflow protection — all languages
   ============================================ */
h1, h2, p, span, button, a {
  overflow-wrap: break-word;
}
#rating-text, #success-tip, #submit-text {
  max-width: 100%;
}

/* ============================================
   Utilities
   ============================================ */
.animate-fade-in {
  animation: fade-in 0.3s ease-out;
}
@keyframes fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* Toast */
.toast {
  position: fixed;
  top: 1rem;
  left: 50%;
  transform: translateX(-50%);
  padding: 0.5rem 1.25rem;
  border-radius: 0.5rem;
  font-size: 0.8125rem;
  font-weight: 500;
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: opacity .25s ease, transform .25s ease;
}
.toast-show {
  opacity: 1;
  transform: translateX(-50%) translateY(4px);
}
.toast-error { background: #fee2e2; color: #991b1b; }

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
