/* =====================================================
   แบบประเมินความพึงพอใจเว็บไซต์โรงเรียนนาแห้ววิทยา
   Premium Survey Styles
   ===================================================== */

/* === Base Variables === */
:root {
  --survey-primary: #5B5BD6;
  --survey-primary-light: #7C7CE8;
  --survey-primary-dark: #4343A8;
  --survey-accent: #E8684A;
  --survey-accent-light: #FF8A6E;
  --survey-success: #30A46C;
  --survey-success-light: #4CC38A;
  --survey-warning: #F5A623;
  --survey-bg: #FAFBFF;
  --survey-card-bg: #FFFFFF;
  --survey-text: #1A1A2E;
  --survey-text-muted: #6B7280;
  --survey-border: #E5E7EB;
  --survey-border-focus: #5B5BD6;
  --survey-shadow: 0 4px 24px rgba(91, 91, 214, 0.08);
  --survey-shadow-hover: 0 8px 32px rgba(91, 91, 214, 0.14);
  --survey-radius: 16px;
  --survey-radius-sm: 10px;
  --survey-transition: all 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

/* === Survey Container === */
.survey-wrapper {
  max-width: 860px;
  margin: 2rem auto 4rem;
  padding: 0 1rem;
}

/* === Survey Hero Banner === */
.survey-hero {
  background: linear-gradient(135deg, #5B5BD6 0%, #7C3AED 50%, #E8684A 100%);
  border-radius: var(--survey-radius);
  padding: 2.5rem 2rem;
  text-align: center;
  color: #fff;
  position: relative;
  overflow: hidden;
  margin-bottom: 2rem;
  box-shadow: 0 12px 40px rgba(91, 91, 214, 0.25);
}

.survey-hero::before {
  content: '';
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: radial-gradient(circle, rgba(255,255,255,0.1) 0%, transparent 70%);
  animation: surveyHeroShimmer 6s ease-in-out infinite;
}

@keyframes surveyHeroShimmer {
  0%, 100% { transform: translate(0, 0); }
  50% { transform: translate(20%, 10%); }
}

.survey-hero-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 72px;
  height: 72px;
  background: rgba(255,255,255,0.2);
  backdrop-filter: blur(10px);
  border-radius: 50%;
  margin-bottom: 1rem;
  font-size: 2rem;
  border: 2px solid rgba(255,255,255,0.3);
  position: relative;
  z-index: 1;
}

.survey-hero h1 {
  font-family: 'Kanit', sans-serif;
  font-size: 1.65rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
  position: relative;
  z-index: 1;
}

.survey-hero p {
  font-size: 0.95rem;
  opacity: 0.9;
  line-height: 1.7;
  position: relative;
  z-index: 1;
}

.survey-hero .survey-badge {
  display: inline-block;
  background: rgba(255,255,255,0.2);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255,255,255,0.3);
  padding: 0.3rem 1rem;
  border-radius: 50px;
  font-size: 0.8rem;
  margin-top: 1rem;
  position: relative;
  z-index: 1;
}

/* === Progress Bar === */
.survey-progress-container {
  background: var(--survey-card-bg);
  border: 1px solid var(--survey-border);
  border-radius: var(--survey-radius);
  padding: 1.25rem 1.5rem;
  margin-bottom: 1.5rem;
  box-shadow: var(--survey-shadow);
  position: sticky;
  top: 80px;
  z-index: 10;
}

.survey-progress-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
}

.survey-progress-label {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--survey-text);
}

.survey-progress-step {
  font-size: 0.8rem;
  color: var(--survey-text-muted);
  font-weight: 500;
}

.survey-progress-bar {
  width: 100%;
  height: 8px;
  background: #EEF0F6;
  border-radius: 10px;
  overflow: hidden;
}

.survey-progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--survey-primary), var(--survey-primary-light));
  border-radius: 10px;
  transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
}

.survey-progress-fill::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.4), transparent);
  animation: progressShine 2s infinite;
}

@keyframes progressShine {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}

/* === Form Sections === */
.survey-section {
  background: var(--survey-card-bg);
  border: 1px solid var(--survey-border);
  border-radius: var(--survey-radius);
  padding: 2rem;
  margin-bottom: 1.5rem;
  box-shadow: var(--survey-shadow);
  transition: var(--survey-transition);
  animation: sectionFadeIn 0.5s ease-out forwards;
  opacity: 0;
  transform: translateY(16px);
}

.survey-section:hover {
  box-shadow: var(--survey-shadow-hover);
}

@keyframes sectionFadeIn {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.survey-section:nth-child(1) { animation-delay: 0.1s; }
.survey-section:nth-child(2) { animation-delay: 0.15s; }
.survey-section:nth-child(3) { animation-delay: 0.2s; }
.survey-section:nth-child(4) { animation-delay: 0.25s; }
.survey-section:nth-child(5) { animation-delay: 0.3s; }
.survey-section:nth-child(6) { animation-delay: 0.35s; }
.survey-section:nth-child(7) { animation-delay: 0.4s; }

.survey-section-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
  padding-bottom: 1rem;
  border-bottom: 2px solid #F3F4F8;
}

.survey-section-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  font-size: 1.15rem;
  flex-shrink: 0;
}

.survey-section-icon.purple {
  background: linear-gradient(135deg, #EEE5FF, #DDD0FF);
  color: #7C3AED;
}

.survey-section-icon.blue {
  background: linear-gradient(135deg, #E0E7FF, #C7D2FE);
  color: #4F46E5;
}

.survey-section-icon.green {
  background: linear-gradient(135deg, #D1FAE5, #A7F3D0);
  color: #059669;
}

.survey-section-icon.orange {
  background: linear-gradient(135deg, #FFEDD5, #FED7AA);
  color: #EA580C;
}

.survey-section-icon.pink {
  background: linear-gradient(135deg, #FCE7F3, #FBCFE8);
  color: #DB2777;
}

.survey-section-icon.teal {
  background: linear-gradient(135deg, #CCFBF1, #99F6E4);
  color: #0D9488;
}

.survey-section-icon.red {
  background: linear-gradient(135deg, #FEE2E2, #FECACA);
  color: #DC2626;
}

.survey-section-title {
  font-family: 'Kanit', sans-serif;
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--survey-text);
}

.survey-section-subtitle {
  font-size: 0.82rem;
  color: var(--survey-text-muted);
  margin-top: 0.15rem;
}

/* === Form Groups === */
.survey-form-group {
  margin-bottom: 1.25rem;
}

.survey-form-group label {
  display: block;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--survey-text);
  margin-bottom: 0.5rem;
}

.survey-form-group label .required {
  color: var(--survey-accent);
  margin-left: 0.2rem;
}

/* === Radio Card Options (Demographics) === */
.survey-radio-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 0.75rem;
}

.survey-radio-card {
  position: relative;
}

.survey-radio-card input[type="radio"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.survey-radio-card label {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 1rem 0.75rem;
  border: 2px solid var(--survey-border);
  border-radius: var(--survey-radius-sm);
  cursor: pointer;
  text-align: center;
  transition: var(--survey-transition);
  min-height: 70px;
  font-size: 0.85rem !important;
  font-weight: 500 !important;
  color: var(--survey-text) !important;
  background: #FAFBFF;
}

.survey-radio-card label i {
  font-size: 1.3rem;
  margin-bottom: 0.4rem;
  color: var(--survey-text-muted);
  transition: var(--survey-transition);
}

.survey-radio-card input[type="radio"]:checked + label {
  border-color: var(--survey-primary);
  background: linear-gradient(135deg, #EEE5FF 0%, #E0E7FF 100%);
  box-shadow: 0 4px 12px rgba(91, 91, 214, 0.15);
}

.survey-radio-card input[type="radio"]:checked + label i {
  color: var(--survey-primary);
}

.survey-radio-card label:hover {
  border-color: var(--survey-primary-light);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(91, 91, 214, 0.1);
}

/* === Star / Likert Scale Rating === */
.survey-rating-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  overflow: hidden;
  border-radius: var(--survey-radius-sm);
  border: 1px solid var(--survey-border);
}

.survey-rating-table thead th {
  background: linear-gradient(135deg, #F5F3FF, #EEF2FF);
  padding: 0.85rem 0.5rem;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--survey-text);
  text-align: center;
  border-bottom: 2px solid var(--survey-border);
  white-space: nowrap;
}

.survey-rating-table thead th:first-child {
  text-align: left;
  padding-left: 1rem;
  min-width: 220px;
}

.survey-rating-table tbody tr {
  transition: background 0.2s ease;
}

.survey-rating-table tbody tr:nth-child(even) {
  background: #FAFBFF;
}

.survey-rating-table tbody tr:hover {
  background: #F0EDFF;
}

.survey-rating-table tbody td {
  padding: 0.85rem 0.5rem;
  text-align: center;
  border-bottom: 1px solid #F3F4F6;
  vertical-align: middle;
}

.survey-rating-table tbody td:first-child {
  text-align: left;
  padding-left: 1rem;
  font-size: 0.88rem;
  color: var(--survey-text);
  font-weight: 400;
  line-height: 1.5;
}

/* Custom Radio Circle for Ratings */
.survey-rating-radio {
  position: relative;
  display: inline-block;
}

.survey-rating-radio input[type="radio"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.survey-rating-radio .radio-circle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 2px solid #D1D5DB;
  cursor: pointer;
  transition: var(--survey-transition);
  margin: 0 auto;
  font-size: 0.75rem;
  font-weight: 600;
  color: transparent;
}

.survey-rating-radio input[type="radio"]:checked + .radio-circle {
  border-color: var(--survey-primary);
  background: var(--survey-primary);
  color: #fff;
  box-shadow: 0 3px 10px rgba(91, 91, 214, 0.3);
  transform: scale(1.1);
}

.survey-rating-radio .radio-circle:hover {
  border-color: var(--survey-primary-light);
  background: #F0EDFF;
  color: var(--survey-primary);
  transform: scale(1.05);
}

/* === Emoji Rating (Overall) === */
.survey-emoji-rating {
  display: flex;
  justify-content: center;
  gap: 1rem;
  padding: 1rem 0;
}

.survey-emoji-item {
  position: relative;
  cursor: pointer;
}

.survey-emoji-item input[type="radio"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.survey-emoji-item label {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
  cursor: pointer;
  transition: var(--survey-transition);
  padding: 0.75rem;
  border-radius: 16px;
  border: 2px solid transparent;
}

.survey-emoji-item label .emoji {
  font-size: 2.5rem;
  transition: var(--survey-transition);
  filter: grayscale(0.4);
}

.survey-emoji-item label .emoji-label {
  font-size: 0.72rem;
  color: var(--survey-text-muted);
  font-weight: 500;
  text-align: center;
}

.survey-emoji-item input[type="radio"]:checked + label {
  border-color: var(--survey-primary);
  background: #F5F3FF;
  transform: scale(1.08);
}

.survey-emoji-item input[type="radio"]:checked + label .emoji {
  filter: grayscale(0);
  transform: scale(1.15);
}

.survey-emoji-item label:hover {
  transform: scale(1.05);
}

.survey-emoji-item label:hover .emoji {
  filter: grayscale(0);
}

/* === Toggle Switch (Recommend) === */
.survey-toggle-group {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem 1.5rem;
  background: #FAFBFF;
  border-radius: var(--survey-radius-sm);
  border: 1px solid var(--survey-border);
}

.survey-toggle {
  position: relative;
  width: 56px;
  height: 30px;
  flex-shrink: 0;
}

.survey-toggle input {
  opacity: 0;
  width: 0;
  height: 0;
}

.survey-toggle-slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #D1D5DB;
  transition: var(--survey-transition);
  border-radius: 30px;
}

.survey-toggle-slider:before {
  position: absolute;
  content: "";
  height: 24px;
  width: 24px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: var(--survey-transition);
  border-radius: 50%;
  box-shadow: 0 2px 6px rgba(0,0,0,0.15);
}

.survey-toggle input:checked + .survey-toggle-slider {
  background: linear-gradient(135deg, var(--survey-success), var(--survey-success-light));
}

.survey-toggle input:checked + .survey-toggle-slider:before {
  transform: translateX(26px);
}

.survey-toggle-label {
  font-size: 0.9rem;
  color: var(--survey-text);
  font-weight: 500;
}

/* === Textarea === */
.survey-textarea {
  width: 100%;
  min-height: 100px;
  padding: 1rem;
  border: 2px solid var(--survey-border);
  border-radius: var(--survey-radius-sm);
  font-family: 'Kanit', sans-serif;
  font-size: 0.9rem;
  color: var(--survey-text);
  resize: vertical;
  transition: var(--survey-transition);
  background: #FAFBFF;
}

.survey-textarea:focus {
  outline: none;
  border-color: var(--survey-primary);
  box-shadow: 0 0 0 4px rgba(91, 91, 214, 0.1);
  background: #fff;
}

.survey-textarea::placeholder {
  color: #B0B8C8;
}

/* === Text Input for "Other" === */
.survey-text-input {
  width: 100%;
  padding: 0.75rem 1rem;
  border: 2px solid var(--survey-border);
  border-radius: var(--survey-radius-sm);
  font-family: 'Kanit', sans-serif;
  font-size: 0.88rem;
  color: var(--survey-text);
  transition: var(--survey-transition);
  background: #FAFBFF;
  margin-top: 0.5rem;
}

.survey-text-input:focus {
  outline: none;
  border-color: var(--survey-primary);
  box-shadow: 0 0 0 4px rgba(91, 91, 214, 0.1);
  background: #fff;
}

/* === Submit Button === */
.survey-submit-section {
  text-align: center;
  padding: 2rem;
}

.survey-submit-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1rem 3rem;
  background: linear-gradient(135deg, var(--survey-primary), #7C3AED);
  color: #fff;
  border: none;
  border-radius: 50px;
  font-family: 'Kanit', sans-serif;
  font-size: 1.05rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--survey-transition);
  box-shadow: 0 8px 24px rgba(91, 91, 214, 0.3);
  position: relative;
  overflow: hidden;
}

.survey-submit-btn::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 200%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
  transition: left 0.5s;
}

.survey-submit-btn:hover {
  transform: translateY(-3px);
  box-shadow: 0 12px 32px rgba(91, 91, 214, 0.4);
}

.survey-submit-btn:hover::before {
  left: 100%;
}

.survey-submit-btn:active {
  transform: translateY(-1px);
}

.survey-submit-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

.survey-submit-btn .spinner {
  display: none;
  width: 20px;
  height: 20px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

.survey-submit-btn.loading .spinner {
  display: inline-block;
}

.survey-submit-btn.loading .btn-text {
  display: none;
}

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

/* === Success Modal === */
.survey-success-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(8px);
  z-index: 9999;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.3s ease;
}

.survey-success-overlay.active {
  display: flex;
}

.survey-success-modal {
  background: #fff;
  border-radius: 24px;
  padding: 3rem 2.5rem;
  text-align: center;
  max-width: 420px;
  width: 90%;
  position: relative;
  animation: modalSlideUp 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
  box-shadow: 0 24px 64px rgba(0,0,0,0.15);
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes modalSlideUp {
  from {
    opacity: 0;
    transform: translateY(40px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.survey-success-icon {
  width: 80px;
  height: 80px;
  background: linear-gradient(135deg, #D1FAE5, #A7F3D0);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 1.5rem;
  font-size: 2.5rem;
}

.survey-success-modal h2 {
  font-family: 'Kanit', sans-serif;
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--survey-text);
  margin-bottom: 0.75rem;
}

.survey-success-modal p {
  font-size: 0.92rem;
  color: var(--survey-text-muted);
  line-height: 1.7;
  margin-bottom: 1.5rem;
}

.survey-success-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 2rem;
  background: linear-gradient(135deg, var(--survey-success), var(--survey-success-light));
  color: #fff;
  border: none;
  border-radius: 50px;
  font-family: 'Kanit', sans-serif;
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
  transition: var(--survey-transition);
  box-shadow: 0 4px 16px rgba(48, 164, 108, 0.3);
}

.survey-success-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(48, 164, 108, 0.4);
}

/* === Confetti Animation === */
.confetti-piece {
  position: fixed;
  width: 10px;
  height: 10px;
  top: -10px;
  z-index: 10000;
  border-radius: 2px;
  animation: confettiFall 3s ease-out forwards;
  pointer-events: none;
}

@keyframes confettiFall {
  0% {
    transform: translateY(0) rotate(0deg) scale(1);
    opacity: 1;
  }
  100% {
    transform: translateY(100vh) rotate(720deg) scale(0);
    opacity: 0;
  }
}

/* === Responsive Design === */
@media (max-width: 768px) {
  .survey-wrapper {
    padding: 0 0.5rem;
    margin: 1rem auto 3rem;
  }

  .survey-hero {
    padding: 2rem 1.25rem;
    border-radius: 12px;
  }

  .survey-hero h1 {
    font-size: 1.35rem;
  }

  .survey-section {
    padding: 1.25rem;
    border-radius: 12px;
  }

  .survey-radio-cards {
    grid-template-columns: repeat(2, 1fr);
  }

  .survey-rating-table {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .survey-rating-table thead th {
    font-size: 0.7rem;
    padding: 0.6rem 0.3rem;
  }

  .survey-rating-table tbody td {
    padding: 0.6rem 0.3rem;
  }

  .survey-rating-table tbody td:first-child {
    font-size: 0.8rem;
    min-width: 160px;
    padding-left: 0.6rem;
  }

  .survey-rating-radio .radio-circle {
    width: 30px;
    height: 30px;
    font-size: 0.65rem;
  }

  .survey-emoji-rating {
    gap: 0.5rem;
  }

  .survey-emoji-item label {
    padding: 0.5rem;
  }

  .survey-emoji-item label .emoji {
    font-size: 1.8rem;
  }

  .survey-emoji-item label .emoji-label {
    font-size: 0.65rem;
  }

  .survey-submit-btn {
    padding: 0.85rem 2rem;
    font-size: 0.95rem;
    width: 100%;
    justify-content: center;
  }

  .survey-progress-container {
    position: relative;
    top: 0;
  }
}

@media (max-width: 480px) {
  .survey-radio-cards {
    grid-template-columns: 1fr;
  }
}

/* === Error State === */
.survey-error {
  border-color: var(--survey-accent) !important;
  animation: shake 0.5s ease;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-5px); }
  40%, 80% { transform: translateX(5px); }
}

.survey-error-msg {
  color: var(--survey-accent);
  font-size: 0.8rem;
  margin-top: 0.3rem;
  display: none;
}

.survey-error-msg.show {
  display: block;
}

/* === Privacy Note === */
.survey-privacy {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 1rem 1.25rem;
  background: #F0FDF4;
  border: 1px solid #BBF7D0;
  border-radius: var(--survey-radius-sm);
  margin-top: 1rem;
}

.survey-privacy i {
  color: var(--survey-success);
  font-size: 1.1rem;
  margin-top: 0.15rem;
}

.survey-privacy span {
  font-size: 0.82rem;
  color: #166534;
  line-height: 1.6;
}
