/* ==========================================================================
   ธีมและสไตล์หลัก: กองสาธารณสุขและสิ่งแวดล้อม เทศบาลตำบลพันท้ายนรสิงห์
   โหมดการผลิต (Production) สำหรับ Cloudflare Pages
   รองรับ: Web Accessibility (WCAG 2.1), Responsive ทุกอุปกรณ์
   ========================================================================== */

:root {
  --primary: #047857;         /* เขียวเข้มสาธารณสุข */
  --primary-dark: #065f46;
  --primary-light: #10b981;
  --secondary: #0284c7;       /* ฟ้าทะเล/สิ่งแวดล้อมชายฝั่ง */
  --accent: #d97706;          /* ทอง/ส้มเตือนภัย */
  --bg-main: #f8fafc;
  --bg-card: #ffffff;
  --text-main: #1e293b;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --radius: 12px;
  --shadow: 0 4px 6px -1px rgb(0 0 0 / 0.08), 0 2px 4px -2px rgb(0 0 0 / 0.05);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.08);
  --font-base: 'Sarabun', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-size-base: 16px;
}

/* โหมดคอนทราสต์สูงสำหรับผู้สูงอายุ / ผู้มีปัญหาการมองเห็น (High Contrast) */
body.high-contrast {
  --bg-main: #000000 !important;
  --bg-card: #18181b !important;
  --text-main: #ffff00 !important;
  --text-muted: #ffffff !important;
  --border: #ffffff !important;
  --primary: #facc15 !important;
  --primary-dark: #eab308 !important;
  --secondary: #38bdf8 !important;
}

/* ปรับขนาดตัวอักษรทั้งหน้าเว็บ */
body.font-sm { --font-size-base: 14px; }
body.font-md { --font-size-base: 16px; }
body.font-lg { --font-size-base: 19px; }
body.font-xl { --font-size-base: 22px; }

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-base);
  font-size: var(--font-size-base);
  color: var(--text-main);
  background-color: var(--bg-main);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Accessibility Top Bar */
.top-accessibility-bar {
  background: #0f172a;
  color: #f1f5f9;
  font-size: 0.875rem;
  padding: 6px 1rem;
  border-bottom: 1px solid #334155;
}

.top-bar-container {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.accessibility-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.acc-btn {
  background: #1e293b;
  color: #fff;
  border: 1px solid #475569;
  padding: 2px 8px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.8rem;
  transition: all 0.2s;
}

.acc-btn:hover {
  background: var(--primary);
  border-color: var(--primary);
}

/* Header & Navigation */
header.site-header {
  background: #ffffff;
  border-bottom: 2px solid var(--primary);
  position: sticky;
  top: 0;
  z-index: 1000;
  box-shadow: var(--shadow);
}

.header-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0.75rem 1rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.logo-area {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: inherit;
}

.logo-icon {
  width: 48px;
  height: 48px;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  color: #ffffff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  box-shadow: 0 2px 5px rgba(0,0,0,0.15);
}

.logo-text h1 {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--primary-dark);
  line-height: 1.2;
}

.logo-text p {
  font-size: 0.8rem;
  color: var(--text-muted);
}

nav.main-nav {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.nav-links {
  display: flex;
  list-style: none;
  gap: 0.5rem;
}

.nav-links a {
  text-decoration: none;
  color: var(--text-main);
  font-weight: 500;
  padding: 8px 14px;
  border-radius: 8px;
  transition: all 0.2s;
}

.nav-links a:hover,
.nav-links a.active {
  background: #ecfdf5;
  color: var(--primary);
  font-weight: 600;
}

.menu-toggle {
  display: none;
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--primary);
}

/* Alert Banner */
.urgent-alert-bar {
  background: linear-gradient(90deg, #047857, #0284c7);
  color: #ffffff;
  padding: 8px 1rem;
  font-size: 0.9rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-align: center;
}

/* Container */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1.5rem 1rem;
  width: 100%;
}

/* Hero Section */
.hero-section {
  background: linear-gradient(rgba(4, 120, 87, 0.92), rgba(2, 132, 199, 0.9)), url('https://images.unsplash.com/photo-1542601906990-b4d3fb778b09?w=1600') center/cover;
  color: #ffffff;
  border-radius: var(--radius);
  padding: 2.75rem 2rem;
  margin-bottom: 2rem;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.hero-content h2 {
  font-size: 2.2rem;
  font-weight: 700;
  margin-bottom: 0.75rem;
  line-height: 1.25;
}

.hero-content p {
  font-size: 1.1rem;
  margin-bottom: 1.25rem;
  opacity: 0.95;
  max-width: 850px;
}

.hero-cta {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: 8px;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  border: none;
  transition: all 0.2s;
  font-size: 0.95rem;
}

.btn-primary {
  background: #ffffff;
  color: var(--primary-dark);
}
.btn-primary:hover {
  background: #f1f5f9;
  transform: translateY(-2px);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.2);
  color: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.4);
}
.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.3);
}

.btn-success {
  background: var(--primary);
  color: #ffffff;
}
.btn-success:hover {
  background: var(--primary-dark);
}

/* Eco-Dashboard Cards */
.eco-dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 1.5rem;
  margin-bottom: 2.5rem;
}

.eco-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.eco-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 1rem;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.75rem;
}

.eco-card-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--primary-dark);
  display: flex;
  align-items: center;
  gap: 8px;
}

.live-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #fee2e2;
  color: #dc2626;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 20px;
}

.live-dot {
  width: 8px;
  height: 8px;
  background: #ef4444;
  border-radius: 50%;
  animation: pulse-dot 1.5s infinite;
}

@keyframes pulse-dot {
  0% { transform: scale(0.95); opacity: 0.8; }
  50% { transform: scale(1.3); opacity: 1; }
  100% { transform: scale(0.95); opacity: 0.8; }
}

.eco-main-metric {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  margin: 0.75rem 0 1.25rem;
}

.metric-circle {
  width: 75px;
  height: 75px;
  border-radius: 50%;
  background: #10b981;
  color: #ffffff;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  box-shadow: 0 4px 10px rgba(16, 185, 129, 0.3);
}

.metric-circle.moderate {
  background: #f59e0b;
  box-shadow: 0 4px 10px rgba(245, 158, 11, 0.3);
}

.metric-circle.unhealthy-sensitive {
  background: #f97316;
  box-shadow: 0 4px 10px rgba(249, 115, 22, 0.3);
}

.metric-circle.unhealthy {
  background: #ef4444;
  box-shadow: 0 4px 10px rgba(239, 68, 68, 0.3);
}

.metric-circle span { font-size: 1.6rem; line-height: 1; }
.metric-circle small { font-size: 0.65rem; }

.metric-info h4 {
  font-size: 1.15rem;
  margin-bottom: 4px;
}

.metric-info p {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.eco-details-list {
  list-style: none;
  font-size: 0.85rem;
  color: var(--text-muted);
  line-height: 1.7;
  background: #f8fafc;
  padding: 0.75rem 1rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  margin-bottom: 1rem;
}

.eco-card-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* Quick Access Grid */
.section-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--primary-dark);
  margin-bottom: 1.25rem;
  display: flex;
  align-items: center;
  gap: 10px;
}

.quick-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1.25rem;
  margin-bottom: 2.5rem;
}

.quick-card {
  background: var(--bg-card);
  padding: 1.5rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  text-decoration: none;
  color: inherit;
  transition: all 0.25s;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}

.quick-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
  border-color: var(--primary-light);
}

.quick-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  background: #ecfdf5;
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  margin-bottom: 1rem;
}

.quick-card h3 {
  font-size: 1.05rem;
  font-weight: 600;
  margin-bottom: 0.35rem;
  color: var(--text-main);
}

.quick-card p {
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* Emergency Banner */
.emergency-banner {
  background: #fff1f2;
  border: 2px solid #f43f5e;
  border-radius: var(--radius);
  padding: 1.5rem;
  margin-bottom: 2.5rem;
  box-shadow: var(--shadow);
}

.emergency-title {
  color: #be123c;
  font-size: 1.2rem;
  font-weight: 700;
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  gap: 8px;
}

.emergency-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1rem;
}

.emergency-item {
  background: #ffffff;
  padding: 1rem;
  border-radius: 8px;
  border: 1px solid #fecdd3;
  display: flex;
  align-items: center;
  gap: 1rem;
}

.emergency-item-icon {
  font-size: 2rem;
}

.emergency-item strong {
  display: block;
  font-size: 0.9rem;
  color: #475569;
}

.emergency-item a {
  font-size: 1.25rem;
  font-weight: 700;
  color: #e11d48;
  text-decoration: none;
}

/* News Cards */
.news-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 1.5rem;
  margin-bottom: 2.5rem;
}

.news-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  transition: transform 0.2s;
  display: flex;
  flex-direction: column;
}

.news-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-lg);
}

.news-thumb {
  height: 180px;
  background-color: #cbd5e1;
  background-size: cover;
  background-position: center;
  position: relative;
}

.news-badge {
  position: absolute;
  top: 10px;
  left: 10px;
  background: var(--primary);
  color: #fff;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
}

.news-body {
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  flex-grow: 1;
}

.news-date {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}

.news-title {
  font-size: 1.05rem;
  font-weight: 700;
  margin-bottom: 0.75rem;
  color: var(--text-main);
  line-height: 1.4;
}

.news-desc {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-bottom: 1rem;
  flex-grow: 1;
}

/* Empty State Box */
.empty-state {
  text-align: center;
  padding: 2.5rem 1rem;
  background: #ffffff;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  color: var(--text-muted);
  font-size: 0.95rem;
}

/* ทำเนียบบุคลากร (Staff Directory Styles) */
.division-section {
  margin-bottom: 2.5rem;
}

.division-header {
  background: #f1f5f9;
  border-left: 4px solid var(--primary);
  padding: 10px 16px;
  border-radius: 0 8px 8px 0;
  margin-bottom: 1.25rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.division-header h4 {
  font-size: 1.15rem;
  color: var(--primary-dark);
}

.staff-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1.25rem;
}

.staff-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  text-align: center;
  box-shadow: var(--shadow);
  transition: transform 0.2s, box-shadow 0.2s;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.staff-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-lg);
  border-color: var(--primary-light);
}

.staff-avatar {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: #e2e8f0;
  color: #475569;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.2rem;
  margin-bottom: 0.75rem;
  border: 3px solid #ecfdf5;
}

.staff-avatar.leader {
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  color: #ffffff;
  border-color: #d1fae5;
}

.staff-name {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 4px;
}

.staff-position {
  font-size: 0.85rem;
  color: var(--primary-dark);
  font-weight: 600;
  margin-bottom: 6px;
}

.staff-department {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.staff-contact {
  font-size: 0.8rem;
  color: var(--secondary);
  background: #f0f9ff;
  padding: 4px 10px;
  border-radius: 12px;
  display: inline-block;
  margin-top: auto;
}

/* Form Styles */
.form-card {
  background: var(--bg-card);
  padding: 2rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  margin-bottom: 2rem;
}

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

.form-label {
  display: block;
  font-weight: 600;
  margin-bottom: 0.5rem;
  font-size: 0.95rem;
}

.form-control {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.95rem;
  font-family: inherit;
  transition: border-color 0.2s;
}

.form-control:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(4, 120, 87, 0.15);
}

/* Tabs */
.tabs-nav {
  display: flex;
  gap: 0.5rem;
  border-bottom: 2px solid var(--border);
  margin-bottom: 1.5rem;
  overflow-x: auto;
}

.tab-btn {
  padding: 10px 18px;
  border: none;
  background: none;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 3px solid transparent;
  transition: all 0.2s;
  white-space: nowrap;
}

.tab-btn.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

.tab-content {
  display: none;
}
.tab-content.active {
  display: block;
}

/* Tracking Timeline */
.timeline {
  position: relative;
  margin: 1.5rem 0;
  padding-left: 2rem;
  border-left: 3px solid #cbd5e1;
}

.timeline-step {
  position: relative;
  margin-bottom: 1.5rem;
}

.timeline-dot {
  position: absolute;
  left: -2.7rem;
  top: 0;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #cbd5e1;
  border: 3px solid #fff;
}

.timeline-step.completed .timeline-dot {
  background: var(--primary);
}

.timeline-step.active .timeline-dot {
  background: var(--accent);
  box-shadow: 0 0 0 4px rgba(217, 119, 6, 0.2);
}

/* Footer */
footer.site-footer {
  background: #0f172a;
  color: #cbd5e1;
  margin-top: auto;
  padding: 3rem 1rem 1.5rem;
  border-top: 4px solid var(--primary);
}

.footer-grid {
  max-width: 1200px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 2rem;
  margin-bottom: 2.5rem;
}

.footer-col h4 {
  color: #f8fafc;
  font-size: 1.1rem;
  margin-bottom: 1.25rem;
  border-left: 3px solid var(--primary);
  padding-left: 8px;
}

.footer-col p, .footer-col li {
  font-size: 0.9rem;
  line-height: 1.7;
  color: #94a3b8;
}

.footer-col ul {
  list-style: none;
}

.footer-col a {
  color: #cbd5e1;
  text-decoration: none;
  transition: color 0.2s;
}

.footer-col a:hover {
  color: var(--primary-light);
}

.social-links {
  display: flex;
  gap: 12px;
  margin-top: 1rem;
}

.social-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: #1e293b;
  color: #fff;
  text-decoration: none;
  font-size: 1.1rem;
  transition: background 0.2s;
}

.social-btn:hover {
  background: var(--primary);
}

.footer-bottom {
  max-width: 1200px;
  margin: 0 auto;
  padding-top: 1.5rem;
  border-top: 1px solid #1e293b;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
  font-size: 0.85rem;
}

/* Responsive */
@media (max-width: 768px) {
  .hero-section {
    padding: 2rem 1.25rem;
  }
  .hero-content h2 {
    font-size: 1.6rem;
  }
  .menu-toggle {
    display: block;
  }
  .nav-links {
    display: none;
    flex-direction: column;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: #ffffff;
    padding: 1rem;
    box-shadow: var(--shadow-lg);
    border-top: 1px solid var(--border);
  }
  .nav-links.show {
    display: flex;
  }
}

/* Official Logo Styling */
.site-logo-img {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid #047857;
  background: #ffffff;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.12);
  flex-shrink: 0;
  transition: transform 0.2s ease;
}

.site-logo-img:hover {
  transform: scale(1.05);
}

/* Facebook Embed & Conversion Box */
.fb-preview-box {
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  margin-top: 10px;
  display: flex;
  gap: 12px;
  align-items: center;
}

.fb-preview-img {
  width: 90px;
  height: 90px;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid #cbd5e1;
  background: #e2e8f0;
}

/* RBAC Role Badges */
.role-badge-super {
  background: #fef2f2;
  color: #b91c1c;
  border: 1px solid #fecaca;
  padding: 3px 8px;
  border-radius: 12px;
  font-size: 0.8rem;
  font-weight: 600;
}

.role-badge-officer {
  background: #eff6ff;
  color: #1d4ed8;
  border: 1px solid #bfdbfe;
  padding: 3px 8px;
  border-radius: 12px;
  font-size: 0.8rem;
  font-weight: 600;
}

.role-badge-pr {
  background: #f0fdf4;
  color: #15803d;
  border: 1px solid #bbf7d0;
  padding: 3px 8px;
  border-radius: 12px;
  font-size: 0.8rem;
  font-weight: 600;
}

