/* =========================================================
   ปักษีสยาม (Siam Avian Atlas) — Responsive Modern Stylesheet
   ========================================================= */
:root {
  --emerald-900: #0b2e22;
  --emerald-800: #0f3d2e;
  --emerald-600: #1b6b4f;
  --emerald-100: #e6f4ee;
  --amber-500: #d97706;
  --amber-400: #f59e0b;
  --bg: #f6f8f5;
  --surface: #ffffff;
  --text: #18221e;
  --muted: #5c6f68;
  --border: #dce5e0;
  --danger: #dc2626;
  --radius: 16px;
  --shadow: 0 10px 30px rgba(15, 61, 46, 0.08);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: 'Prompt', sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
}

.container { width: 100%; max-width: 1220px; margin: 0 auto; padding: 0 20px; }
.section { padding: 56px 20px; }
.muted { color: var(--muted); font-size: 0.92rem; }
.mt-1 { margin-top: 12px; display: block; }
.w-100 { width: 100%; }
.flex-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }

/* Navbar */
.navbar {
  position: sticky; top: 0; z-index: 100;
  background: rgba(11, 46, 34, 0.92);
  backdrop-filter: blur(12px);
  color: #fff;
  border-bottom: 1px solid rgba(255,255,255,0.1);
}
.nav-inner { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 68px; flex-wrap: wrap; padding: 8px 20px; }
.brand { display: flex; align-items: center; gap: 10px; color: #fff; text-decoration: none; }
.brand-icon { font-size: 1.9rem; }
.brand-title { font-weight: 700; font-size: 1.15rem; line-height: 1.1; }
.brand-sub { font-size: 0.72rem; opacity: 0.75; }
.nav-links { display: flex; align-items: center; gap: 18px; }
.nav-links a { color: rgba(255,255,255,0.88); text-decoration: none; font-size: 0.92rem; transition: 0.2s; }
.nav-links a:hover { color: var(--amber-400); }
.nav-links a.nav-add-link {
  align-items: center; gap: 4px;
  background: var(--emerald-600); color: #fff;
  padding: 6px 13px; border-radius: 999px; font-weight: 500;
  border: 1px solid rgba(255,255,255,0.2);
}
.nav-links a.nav-add-link:hover { background: var(--amber-500); color: #fff; }
.mobile-only-add { display: none; }
.nav-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* Buttons & Inputs */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 16px; border-radius: 10px; border: none; cursor: pointer;
  font-family: inherit; font-size: 0.9rem; font-weight: 500; transition: 0.2s;
  text-decoration: none;
}
.btn-sm { padding: 5px 10px; font-size: 0.8rem; border-radius: 8px; }
.btn-primary { background: var(--emerald-600); color: #fff; }
.btn-primary:hover { background: var(--emerald-800); transform: translateY(-1px); }
.btn-amber { background: var(--amber-500); color: #fff; }
.btn-amber:hover { background: #b45309; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-outline { background: transparent; border: 1px solid var(--border); color: inherit; }
.btn-outline:hover { background: rgba(255,255,255,0.12); }

.input {
  width: 100%; padding: 10px 12px; border-radius: 10px;
  border: 1px solid var(--border); background: #fff;
  font-family: inherit; font-size: 0.92rem; color: var(--text);
}
.input:focus { outline: 2px solid var(--emerald-600); border-color: transparent; }

/* Hero */
.hero {
  position: relative; overflow: hidden;
  background: radial-gradient(circle at top right, #1b6b4f, #0b2e22 65%);
  color: #fff; padding: 80px 0 64px;
}
#heroParticles { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.hero-content { position: relative; z-index: 2; max-width: 780px; }
.hero-badge {
  display: inline-block; padding: 6px 14px; border-radius: 999px;
  background: rgba(255,255,255,0.12); font-size: 0.84rem; margin-bottom: 16px;
}
.hero h1 { font-size: clamp(2rem, 4.5vw, 3.2rem); line-height: 1.2; margin-bottom: 16px; }
.hero h1 span { color: var(--amber-400); }
.hero p { opacity: 0.9; font-size: 1.02rem; margin-bottom: 24px; }
.hero-cta { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 32px; }
.hero-stats { display: flex; gap: 16px; flex-wrap: wrap; }
.stat-box {
  background: rgba(255,255,255,0.1); backdrop-filter: blur(8px);
  padding: 14px 20px; border-radius: 14px; min-width: 140px;
}
.stat-box strong { display: block; font-size: 1.6rem; color: var(--amber-400); line-height: 1.1; }
.stat-box span { font-size: 0.82rem; opacity: 0.85; }

/* Cards & Filters */
.section-header { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.glass-card {
  background: var(--surface); border-radius: var(--radius);
  border: 1px solid var(--border); box-shadow: var(--shadow); padding: 20px;
}
.filter-row {
  display: grid; grid-template-columns: 2fr repeat(5, 1fr); gap: 10px;
}
.category-pills { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; }
.pill {
  padding: 6px 14px; border-radius: 999px; border: 1px solid var(--border);
  background: #fff; cursor: pointer; font-family: inherit; font-size: 0.85rem; transition: 0.2s;
}
.pill.active, .pill:hover { background: var(--emerald-800); color: #fff; border-color: var(--emerald-800); }

/* Bird Grid */
.bird-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 22px; margin-top: 24px;
}
.bird-card {
  background: var(--surface); border-radius: var(--radius); overflow: hidden;
  border: 1px solid var(--border); box-shadow: var(--shadow);
  cursor: pointer; transition: transform 0.25s, box-shadow 0.25s;
  display: flex; flex-direction: column;
}
.bird-card:hover { transform: translateY(-5px); box-shadow: 0 18px 36px rgba(15,61,46,0.14); }
.bird-thumb { position: relative; height: 210px; background: #dbe5df; overflow: hidden; }
.bird-thumb img { width: 100%; height: 100%; object-fit: cover; transition: transform 0.4s; }
.bird-card:hover .bird-thumb img { transform: scale(1.06); }
.bird-badges { position: absolute; top: 10px; left: 10px; display: flex; gap: 6px; flex-wrap: wrap; }
.img-count {
  position: absolute; bottom: 10px; right: 10px;
  background: rgba(0,0,0,0.65); color: #fff; padding: 3px 9px; border-radius: 999px; font-size: 0.76rem;
}
.bird-body { padding: 16px; flex: 1; display: flex; flex-direction: column; }
.bird-body h3 { font-size: 1.12rem; color: var(--emerald-900); }
.bird-sci { font-style: italic; font-size: 0.82rem; color: var(--muted); margin-bottom: 8px; }
.bird-meta { display: flex; gap: 6px; flex-wrap: wrap; margin-top: auto; padding-top: 10px; }
.tag { background: var(--emerald-100); color: var(--emerald-800); padding: 3px 9px; border-radius: 8px; font-size: 0.76rem; }

/* Badges */
.badge { padding: 3px 9px; border-radius: 999px; font-size: 0.75rem; font-weight: 600; color: #fff; }
.iucn-CR { background: #dc2626; }
.iucn-EN { background: #ea580c; }
.iucn-VU { background: #d97706; }
.iucn-NT { background: #2563eb; }
.iucn-LC { background: #16a34a; }
.role-badge { padding: 4px 10px; border-radius: 999px; font-size: 0.76rem; font-weight: 600; }
.role-admin { background: #dc2626; color: #fff; }
.role-editor { background: #d97706; color: #fff; }
.role-member { background: #16a34a; color: #fff; }

/* Tabs & Knowledge */
.tabs { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.tab-btn {
  padding: 9px 16px; border-radius: 10px; border: 1px solid var(--border);
  background: #fff; cursor: pointer; font-family: inherit; font-weight: 500;
}
.tab-btn.active { background: var(--emerald-800); color: #fff; border-color: var(--emerald-800); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }
.info-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 14px; }
.info-card { background: var(--bg); padding: 14px; border-radius: 12px; border: 1px solid var(--border); }
.guide-list { padding-left: 20px; display: grid; gap: 10px; }
.iucn-legend { display: grid; gap: 10px; }

/* Two-col Community & Logs */
.two-col { display: grid; grid-template-columns: 1.2fr 0.8fr; gap: 22px; }
.comment-form { display: grid; gap: 10px; margin: 14px 0; }
.comments-list, .activity-list { display: grid; gap: 10px; max-height: 440px; overflow-y: auto; }
.comment-item, .activity-item {
  background: var(--bg); padding: 12px; border-radius: 12px; border: 1px solid var(--border);
}
.live-dot {
  background: #fee2e2; color: #dc2626; padding: 3px 10px; border-radius: 999px;
  font-size: 0.74rem; font-weight: 700; animation: pulse 1.6s infinite;
}
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.45; } }

/* Modals */
.modal {
  position: fixed; inset: 0; z-index: 200; background: rgba(0,0,0,0.6);
  display: none; align-items: center; justify-content: center; padding: 16px;
}
.modal.open { display: flex; }
.modal-content {
  background: #fff; border-radius: 18px; width: 100%; max-height: 90vh;
  overflow-y: auto; padding: 24px; position: relative;
}
.modal-sm { max-width: 440px; }
.modal-lg { max-width: 860px; }
.modal-close {
  position: absolute; top: 14px; right: 16px; border: none; background: none;
  font-size: 1.8rem; cursor: pointer; color: var(--muted);
}
.modal-footer { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }
.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.auth-tabs { display: flex; gap: 8px; margin-bottom: 16px; }
.upload-box, .refs-box { background: var(--bg); padding: 14px; border-radius: 12px; border: 1px dashed var(--emerald-600); }
.preview-strip { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.preview-strip img { width: 72px; height: 72px; object-fit: cover; border-radius: 8px; border: 1px solid var(--border); }
.ref-row { display: grid; grid-template-columns: 1fr 1.2fr 1fr auto; gap: 8px; margin-top: 8px; }

/* Gallery in Detail Modal */
.gallery-main { width: 100%; height: 340px; object-fit: cover; border-radius: 14px; cursor: zoom-in; background: #e5ece8; }
.gallery-thumbs { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.gallery-thumb-wrap { position: relative; }
.gallery-thumb-wrap img { width: 76px; height: 58px; object-fit: cover; border-radius: 8px; cursor: pointer; border: 2px solid transparent; }
.gallery-thumb-wrap img.active { border-color: var(--emerald-600); }
.thumb-actions { display: flex; gap: 4px; margin-top: 3px; justify-content: center; }

/* Admin Table */
.admin-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px; margin-top: 12px; }
.admin-stat { background: var(--emerald-100); padding: 12px; border-radius: 12px; text-align: center; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
th, td { padding: 10px; border-bottom: 1px solid var(--border); text-align: left; }
th { background: var(--bg); }

/* Lightbox & Toast */
.lightbox {
  position: fixed; inset: 0; z-index: 300; background: rgba(0,0,0,0.9);
  display: none; align-items: center; justify-content: center; padding: 20px;
}
.lightbox.open { display: flex; }
.lightbox img { max-width: 94vw; max-height: 90vh; border-radius: 10px; }
.lightbox-close { position: absolute; top: 20px; right: 26px; font-size: 2.2rem; color: #fff; background: none; border: none; cursor: pointer; }

.toast-container { position: fixed; bottom: 20px; right: 20px; z-index: 400; display: grid; gap: 8px; }
.toast {
  background: var(--emerald-900); color: #fff; padding: 12px 18px;
  border-radius: 12px; box-shadow: 0 10px 24px rgba(0,0,0,0.2); font-size: 0.9rem;
}
.toast.error { background: var(--danger); }

.footer { background: var(--emerald-900); color: rgba(255,255,255,0.85); text-align: center; padding: 26px 0; margin-top: 40px; }

@media (max-width: 960px) {
  .filter-row { grid-template-columns: repeat(2, 1fr); }
  .two-col { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .nav-links { display: none; }
  .mobile-only-add { display: inline-flex; }
  .filter-row, .form-grid, .ref-row { grid-template-columns: 1fr; }
}

/* Brand Logo Image & Settings Link */
.brand-logo { display: inline-flex; align-items: center; justify-content: center; }
.brand-logo-img { height: 42px; width: auto; max-width: 140px; object-fit: contain; border-radius: 8px; background: rgba(255,255,255,0.92); padding: 3px; }
.nav-links a.nav-settings-link {
  align-items: center; gap: 4px;
  background: rgba(255,255,255,0.14); color: #fff;
  padding: 6px 12px; border-radius: 999px; font-weight: 500;
}
.nav-links a.nav-settings-link:hover { background: var(--amber-500); color: #fff; }

/* Anti-Spam CAPTCHA & Honeypot */
.hp-field { position: absolute !important; left: -9999px !important; opacity: 0 !important; pointer-events: none !important; height: 0 !important; width: 0 !important; }
.captcha-box {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  background: var(--emerald-100); padding: 10px 12px; border-radius: 10px;
  border: 1px solid #b7decb;
}
.captcha-label { font-size: 0.88rem; color: var(--emerald-900); }
.captcha-input { width: 100px !important; text-align: center; font-weight: 600; }
