/* =============================================================
   style.css - โรงพยาบาลเชียงกลาง Happinometer Survey
   Theme: Thai Government Official - Soft Green
   ============================================================= */

@import url('https://fonts.googleapis.com/css2?family=Sarabun:ital,wght@0,300;0,400;0,500;0,600;0,700;1,400&display=swap');

/* ---- CSS Variables ---- */
:root {
  --primary:        #1b5e20;
  --primary-mid:    #2e7d32;
  --primary-light:  #43a047;
  --primary-pale:   #e8f5e9;
  --primary-ultra:  #f1f8f1;

  --accent:         #00695c;
  --accent-light:   #e0f2f1;

  --text-dark:      #1a2e1a;
  --text-body:      #2d3a2d;
  --text-muted:     #607060;
  --text-white:     #ffffff;

  --border:         #c8dac8;
  --border-light:   #e2ede2;

  --bg-page:        #f5f7f5;
  --bg-card:        #ffffff;
  --bg-header:      #1b5e20;

  --shadow-sm:      0 1px 3px rgba(0,0,0,.08);
  --shadow-md:      0 4px 12px rgba(0,0,0,.10);
  --shadow-lg:      0 8px 24px rgba(0,0,0,.12);

  --radius-sm:      6px;
  --radius-md:      10px;
  --radius-lg:      16px;

  --font:           'Sarabun', 'TH Sarabun New', sans-serif;
  --transition:     all .2s ease;
}

/* ---- Reset / Base ---- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; font-size: 16px; }

body {
  font-family: var(--font);
  font-size: 1rem;
  line-height: 1.65;
  color: var(--text-body);
  background: var(--bg-page);
  min-height: 100vh;
}

a { color: var(--primary-mid); text-decoration: none; }
a:hover { color: var(--primary); text-decoration: underline; }

img { max-width: 100%; display: block; }

/* ---- Typography ---- */
h1, h2, h3, h4, h5, h6 {
  font-weight: 600;
  line-height: 1.3;
  color: var(--text-dark);
}

/* ---- Layout ---- */
.container {
  width: 100%;
  max-width: 900px;
  margin: 0 auto;
  padding: 0 1.25rem;
}

.container-wide {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1.25rem;
}

/* ---- Site Header ---- */
.site-header {
  background: var(--bg-header);
  color: var(--text-white);
  padding: 0;
  box-shadow: 0 2px 8px rgba(0,0,0,.20);
  position: sticky;
  top: 0;
  z-index: 100;
}

.site-header .header-inner {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: .75rem 1.25rem;
  max-width: 1200px;
  margin: 0 auto;
}

.site-header .logo {
  width: 52px;
  height: 52px;
  object-fit: contain;
  flex-shrink: 0;
  border-radius: 50%;
}

.site-header .header-text h1 {
  font-size: 1.1rem;
  font-weight: 700;
  color: #fff;
  line-height: 1.2;
}

.site-header .header-text p {
  font-size: .82rem;
  color: rgba(255,255,255,.80);
  margin-top: .1rem;
}

.site-header .header-actions {
  margin-left: auto;
  display: flex;
  gap: .5rem;
  align-items: center;
}

/* ---- Hero / Banner ---- */
.survey-hero {
  background: linear-gradient(135deg, #1b5e20 0%, #2e7d32 50%, #388e3c 100%);
  color: #fff;
  padding: 2.5rem 1.25rem;
  text-align: center;
  position: relative;
  overflow: hidden;
}

.survey-hero::before {
  content: '';
  position: absolute;
  inset: 0;
  background: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23ffffff' fill-opacity='0.04'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
  pointer-events: none;
}

.survey-hero .logo-hero {
  width: 88px;
  height: 88px;
  object-fit: contain;
  margin: 0 auto 1rem;
  border-radius: 50%;
  filter: drop-shadow(0 4px 12px rgba(0,0,0,.3));
}

.survey-hero h2 {
  color: #fff;
  font-size: 1.6rem;
  font-weight: 700;
}

.survey-hero p {
  color: rgba(255,255,255,.85);
  font-size: 1rem;
  margin-top: .4rem;
}

.survey-hero .badge-year {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  background: rgba(255,255,255,.15);
  border: 1px solid rgba(255,255,255,.3);
  color: #fff;
  font-size: .85rem;
  padding: .3rem .8rem;
  border-radius: 99px;
  margin-top: .75rem;
  backdrop-filter: blur(4px);
}

/* ---- Cards ---- */
.card {
  background: var(--bg-card);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-light);
  overflow: hidden;
}

.card-header {
  padding: .9rem 1.25rem;
  background: var(--primary-pale);
  border-bottom: 2px solid var(--primary-light);
  display: flex;
  align-items: center;
  gap: .6rem;
}

.card-header .cat-icon {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--primary-mid);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  flex-shrink: 0;
}

.card-header h3 {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--primary);
}

.card-body { padding: 1.25rem; }

/* ---- Form Elements ---- */
.form-section { margin-bottom: 1.5rem; }

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

.form-label {
  display: block;
  font-weight: 600;
  font-size: .92rem;
  color: var(--text-dark);
  margin-bottom: .4rem;
}

.form-label .req { color: #c62828; margin-left: .2rem; }

.form-control {
  width: 100%;
  padding: .6rem .9rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: .95rem;
  color: var(--text-body);
  background: #fff;
  transition: var(--transition);
  outline: none;
}

.form-control:focus {
  border-color: var(--primary-light);
  box-shadow: 0 0 0 3px rgba(67,160,71,.15);
}

select.form-control {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%232e7d32' d='M6 8L0 0h12z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right .9rem center;
  padding-right: 2.2rem;
}

/* ---- Question Cards ---- */
.question-block {
  padding: 1rem 0;
  border-bottom: 1px solid var(--border-light);
}

.question-block:last-child { border-bottom: none; }

.question-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--primary-mid);
  color: #fff;
  font-size: .78rem;
  font-weight: 700;
  flex-shrink: 0;
  margin-right: .5rem;
}

.question-text {
  font-size: .97rem;
  font-weight: 500;
  color: var(--text-dark);
  display: flex;
  align-items: flex-start;
  gap: .2rem;
  margin-bottom: .75rem;
  line-height: 1.55;
}

/* ---- Rating Scale ---- */
.rating-scale {
  display: flex;
  flex-direction: column;
  gap: .4rem;
}

.rating-option {
  display: flex;
  align-items: center;
  gap: .65rem;
  padding: .5rem .75rem;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--border-light);
  cursor: pointer;
  transition: var(--transition);
  user-select: none;
}

.rating-option:hover {
  border-color: var(--primary-light);
  background: var(--primary-ultra);
}

.rating-option input[type="radio"] {
  appearance: none;
  width: 18px;
  height: 18px;
  border: 2px solid var(--border);
  border-radius: 50%;
  flex-shrink: 0;
  transition: var(--transition);
  position: relative;
  cursor: pointer;
}

.rating-option input[type="radio"]::after {
  content: '';
  position: absolute;
  inset: 3px;
  border-radius: 50%;
  background: var(--primary-mid);
  opacity: 0;
  transition: var(--transition);
}

.rating-option input[type="radio"]:checked {
  border-color: var(--primary-mid);
}

.rating-option input[type="radio"]:checked::after {
  opacity: 1;
}

.rating-option.selected {
  border-color: var(--primary-mid);
  background: var(--primary-pale);
}

.rating-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--border-light);
  color: var(--text-muted);
  font-size: .8rem;
  font-weight: 600;
  flex-shrink: 0;
  transition: var(--transition);
}

.rating-option.selected .rating-badge,
.rating-option input[type="radio"]:checked ~ .rating-badge {
  background: var(--primary-mid);
  color: #fff;
}

.rating-option-label {
  font-size: .9rem;
  color: var(--text-body);
  line-height: 1.4;
}

/* ---- Happiness Slider (Q69) ---- */
.happiness-scale {
  padding: 1rem 0;
}

.happiness-track {
  display: flex;
  gap: .4rem;
  margin-bottom: .5rem;
  flex-wrap: wrap;
}

.happiness-btn {
  flex: 1;
  min-width: 42px;
  padding: .5rem .25rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: #fff;
  text-align: center;
  cursor: pointer;
  font-family: var(--font);
  font-size: .9rem;
  font-weight: 600;
  color: var(--text-muted);
  transition: var(--transition);
}

.happiness-btn:hover { border-color: var(--primary-light); background: var(--primary-ultra); }
.happiness-btn.active {
  background: var(--primary-mid);
  border-color: var(--primary-mid);
  color: #fff;
  box-shadow: var(--shadow-sm);
}

.happiness-labels {
  display: flex;
  justify-content: space-between;
  font-size: .78rem;
  color: var(--text-muted);
  padding: 0 .1rem;
}

.happiness-value-display {
  text-align: center;
  margin-top: .75rem;
  font-size: 1rem;
  font-weight: 600;
  color: var(--primary);
}

/* ---- Progress Bar ---- */
.survey-progress {
  background: var(--bg-card);
  border-bottom: 1px solid var(--border-light);
  padding: .75rem 1.25rem;
  position: sticky;
  top: 64px;
  z-index: 90;
  box-shadow: 0 2px 6px rgba(0,0,0,.05);
}

.progress-bar-wrap {
  width: 100%;
  height: 6px;
  background: var(--border-light);
  border-radius: 99px;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary-light), var(--accent));
  border-radius: 99px;
  transition: width .5s ease;
}

.progress-text {
  font-size: .82rem;
  color: var(--text-muted);
  margin-top: .3rem;
}

/* ---- Buttons ---- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  padding: .6rem 1.4rem;
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: .95rem;
  font-weight: 600;
  cursor: pointer;
  border: 1.5px solid transparent;
  transition: var(--transition);
  text-decoration: none;
  line-height: 1.4;
  white-space: nowrap;
}

.btn-primary {
  background: var(--primary-mid);
  color: #fff;
  border-color: var(--primary-mid);
}
.btn-primary:hover {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
  text-decoration: none;
}

.btn-outline {
  background: transparent;
  color: var(--primary-mid);
  border-color: var(--primary-mid);
}
.btn-outline:hover {
  background: var(--primary-pale);
  text-decoration: none;
}

.btn-ghost {
  background: rgba(255,255,255,.12);
  color: #fff;
  border-color: rgba(255,255,255,.3);
}
.btn-ghost:hover {
  background: rgba(255,255,255,.22);
  color: #fff;
  text-decoration: none;
}

.btn-danger { background: #c62828; color: #fff; border-color: #c62828; }
.btn-danger:hover { background: #b71c1c; color: #fff; text-decoration: none; }

.btn-sm { padding: .35rem .9rem; font-size: .85rem; }
.btn-lg { padding: .85rem 2rem; font-size: 1.05rem; }
.btn-block { width: 100%; justify-content: center; }

/* ---- Alerts ---- */
.alert {
  padding: .85rem 1rem;
  border-radius: var(--radius-sm);
  border-left: 4px solid;
  font-size: .92rem;
  margin-bottom: 1rem;
}

.alert-error { background: #ffebee; border-color: #c62828; color: #b71c1c; }
.alert-success { background: #e8f5e9; border-color: #2e7d32; color: #1b5e20; }
.alert-info { background: #e3f2fd; border-color: #1565c0; color: #0d47a1; }
.alert-warning { background: #fff8e1; border-color: #f57f17; color: #e65100; }

/* ---- Thank You Page ---- */
.thankyou-wrap {
  min-height: calc(100vh - 80px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem 1.25rem;
}

.thankyou-card {
  background: #fff;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 3rem 2rem;
  text-align: center;
  max-width: 520px;
  width: 100%;
  border-top: 5px solid var(--primary-mid);
}

.thankyou-icon {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: var(--primary-pale);
  border: 3px solid var(--primary-light);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.2rem;
  margin: 0 auto 1.5rem;
  animation: pop .5s ease;
}

@keyframes pop {
  0% { transform: scale(0); opacity: 0; }
  70% { transform: scale(1.1); }
  100% { transform: scale(1); opacity: 1; }
}

/* ---- Survey Layout ---- */
.survey-layout {
  display: flex;
  gap: 1.5rem;
  padding: 1.5rem 0;
  align-items: flex-start;
}

.survey-main { flex: 1; min-width: 0; }

.survey-sidebar {
  width: 220px;
  flex-shrink: 0;
  position: sticky;
  top: 120px;
}

.nav-pills {
  background: #fff;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-light);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.nav-pill-item {
  display: flex;
  align-items: center;
  gap: .5rem;
  padding: .65rem .9rem;
  font-size: .85rem;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border-light);
  cursor: pointer;
  transition: var(--transition);
  text-decoration: none;
}

.nav-pill-item:last-child { border-bottom: none; }
.nav-pill-item:hover { background: var(--primary-ultra); color: var(--primary); text-decoration: none; }
.nav-pill-item.active { background: var(--primary-pale); color: var(--primary); font-weight: 600; }

.nav-pill-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--border);
  flex-shrink: 0;
}

.nav-pill-item.active .nav-pill-dot { background: var(--primary-mid); }

/* ---- Section Anchor ---- */
.section-anchor { 
  scroll-margin-top: 130px; 
}

/* ---- Info Box ---- */
.info-box {
  background: var(--accent-light);
  border: 1px solid #80cbc4;
  border-radius: var(--radius-sm);
  padding: .85rem 1rem;
  font-size: .88rem;
  color: #004d40;
  margin-bottom: 1.25rem;
  display: flex;
  gap: .5rem;
  align-items: flex-start;
}

/* ---- Footer ---- */
.site-footer {
  background: var(--primary);
  color: rgba(255,255,255,.7);
  text-align: center;
  padding: 1.5rem 1.25rem;
  font-size: .82rem;
  margin-top: 3rem;
}

.site-footer a { color: rgba(255,255,255,.9); }

/* ---- Table ---- */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .9rem;
}

.data-table th {
  background: var(--primary-pale);
  color: var(--primary);
  font-weight: 700;
  padding: .6rem .85rem;
  text-align: left;
  border-bottom: 2px solid var(--primary-light);
}

.data-table td {
  padding: .6rem .85rem;
  border-bottom: 1px solid var(--border-light);
  vertical-align: middle;
}

.data-table tr:hover td { background: var(--primary-ultra); }

/* ---- Badge ---- */
.badge {
  display: inline-flex;
  align-items: center;
  padding: .2rem .6rem;
  border-radius: 99px;
  font-size: .75rem;
  font-weight: 600;
}

.badge-green { background: #e8f5e9; color: #1b5e20; }
.badge-gray  { background: #f5f5f5; color: #616161; }
.badge-red   { background: #ffebee; color: #b71c1c; }
.badge-blue  { background: #e3f2fd; color: #0d47a1; }

/* ---- Error Highlight ---- */
.question-block.has-error .rating-scale {
  border: 1.5px solid #e53935;
  border-radius: var(--radius-sm);
  padding: .5rem;
}

.error-msg {
  color: #c62828;
  font-size: .82rem;
  margin-top: .3rem;
  display: flex;
  align-items: center;
  gap: .3rem;
}

/* ---- Responsive ---- */
@media (max-width: 768px) {
  .survey-layout { flex-direction: column; }
  .survey-sidebar { width: 100%; position: static; }
  .nav-pills { display: flex; overflow-x: auto; }
  .nav-pill-item { flex-shrink: 0; border-bottom: none; border-right: 1px solid var(--border-light); }
  .happiness-btn { min-width: 34px; font-size: .8rem; }
  .survey-hero h2 { font-size: 1.3rem; }
  .rating-scale { gap: .35rem; }
}

@media (max-width: 480px) {
  .btn-lg { padding: .7rem 1.4rem; font-size: .95rem; }
  .card-body { padding: 1rem; }
  .container { padding: 0 1rem; }
}

/* ---- Print ---- */
@media print {
  .site-header, .survey-sidebar, .survey-progress, .site-footer { display: none; }
  body { background: #fff; }
  .card { box-shadow: none; border: 1px solid #ddd; }
}
