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

:root {
  --ink: #1e293b;
  --ink-soft: #475569;
  --base: #f8fafc;
  --glass-bg: rgba(255, 255, 255, 0.4);
  --glass-border: rgba(255, 255, 255, 0.6);
  --glass-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.07);
  --water: #0ea5e9;
  --water-hover: #0284c7;
  --alert: #f97316;
  --danger: #ef4444;
  --ok: #10b981;
  --radius: 20px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }

body {
  font-family: "Sarabun", system-ui, sans-serif;
  color: var(--ink);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  /* Liquid Background */
  background: 
    radial-gradient(circle at 15% 50%, rgba(14, 165, 233, 0.15), transparent 40%),
    radial-gradient(circle at 85% 30%, rgba(139, 92, 246, 0.15), transparent 40%),
    radial-gradient(circle at 50% 80%, rgba(16, 185, 129, 0.15), transparent 40%);
  background-color: var(--base);
  background-attachment: fixed;
  overflow-x: hidden;
}

/* Liquid Blob Animations */
.blob {
  position: fixed;
  filter: blur(60px);
  z-index: -1;
  opacity: 0.6;
  animation: float 10s infinite ease-in-out alternate;
}
.blob-1 {
  width: 400px; height: 400px;
  background: #bae6fd;
  top: -100px; left: -100px;
  border-radius: 40% 60% 70% 30% / 40% 50% 60% 50%;
}
.blob-2 {
  width: 500px; height: 500px;
  background: #ddd6fe;
  bottom: -150px; right: -100px;
  border-radius: 60% 40% 30% 70% / 60% 30% 70% 40%;
  animation-delay: -5s;
}

@keyframes float {
  0% { transform: translate(0, 0) scale(1); }
  100% { transform: translate(30px, 50px) scale(1.1); }
}

h1, h2, h3, .display, .font-kanit { 
  font-family: "Kanit", "Sarabun", sans-serif; 
  font-weight: 600; 
  letter-spacing: .2px; 
}

/* Glass Navbar */
header {
  background: rgba(255, 255, 255, 0.6);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--glass-border);
  position: sticky;
  top: 0;
  z-index: 100;
  padding: 12px 24px;
  display: flex;
  align-items: center;
  gap: 16px;
  box-shadow: 0 4px 30px rgba(0, 0, 0, 0.05);
}

.logo-container {
  width: 44px; height: 44px;
  border-radius: 12px;
  overflow: hidden;
  flex: none;
  border: 2px solid #fff;
  box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}
.logo-container img {
  width: 100%; height: 100%; object-fit: cover;
}

header .title { font-family: "Kanit", sans-serif; font-size: 1.3rem; font-weight: 600; color: var(--ink); line-height: 1.2; }
header .tag { color: var(--ink-soft); font-size: .85rem; }

/* Navigation Tabs */
.nav-links {
  display: flex;
  gap: 12px;
  margin-left: 24px;
}
.nav-link {
  font-family: "Kanit";
  font-size: 1rem;
  color: var(--ink-soft);
  text-decoration: none;
  padding: 8px 16px;
  border-radius: 12px;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
}
.nav-link:hover {
  background: rgba(255, 255, 255, 0.5);
  color: var(--ink);
}
.nav-link.active {
  background: #fff;
  color: var(--water);
  box-shadow: 0 2px 8px rgba(0,0,0,0.05);
  font-weight: 500;
}

header .status {
  margin-left: auto; font-size: .85rem; display: flex; align-items: center; gap: 8px;
  background: rgba(255,255,255,0.8); padding: 8px 14px; border-radius: 999px;
  box-shadow: inset 0 0 0 1px var(--glass-border);
  font-weight: 500;
}
.dot { width: 10px; height: 10px; border-radius: 50%; background: #f1c40f; flex: none; box-shadow: 0 0 8px rgba(241,196,15,0.6); }
.dot.on { background: #10b981; box-shadow: 0 0 8px rgba(16,185,129,0.6); }
.dot.err { background: #ef4444; box-shadow: 0 0 8px rgba(239,68,68,0.6); }

main {
  max-width: 1200px; margin: 30px auto; padding: 0 20px;
  display: grid; grid-template-columns: 400px 1fr; gap: 24px;
}
@media (max-width: 960px) { 
  main { grid-template-columns: 1fr; } 
  .nav-links { display: none; } /* Hide on mobile for simplicity, or we can make a bottom bar */
  .mobile-menu-btn { display: block !important; }
}

/* Glass Card */
.card {
  background: var(--glass-bg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  box-shadow: var(--glass-shadow);
  overflow: hidden;
  transition: transform 0.2s;
}

.card .hd { padding: 18px 20px 0; display: flex; align-items: center; gap: 10px; }
.card .hd i { color: var(--water); }
.card .hd h2 { font-size: 1.1rem; margin: 0; }
.card .hd p { margin: 4px 0 0; color: var(--ink-soft); font-size: .85rem; width: 100%; }
.card .bd { padding: 16px 20px 20px; }

/* Internal Tabs */
.tabs { display: flex; gap: 8px; padding: 16px 20px 0; }
.tab {
  flex: 1; padding: 10px; border: 1px solid transparent; 
  background: rgba(255,255,255,0.4);
  border-radius: 12px; cursor: pointer; font-family: "Sarabun"; font-size: .95rem;
  color: var(--ink-soft); font-weight: 500;
  transition: all 0.2s;
  display: flex; justify-content: center; align-items: center; gap: 6px;
}
.tab:hover { background: rgba(255,255,255,0.7); }
.tab.active { background: #fff; color: var(--water); box-shadow: 0 2px 10px rgba(0,0,0,0.05); }

/* AI Viewer */
.viewer {
  position: relative; width: 100%; aspect-ratio: 4/3; background: #0f172a;
  border-radius: 16px; overflow: hidden; display: grid; place-items: center;
  box-shadow: inset 0 2px 10px rgba(0,0,0,0.2);
}
.viewer canvas, .viewer img, .viewer video { width: 100%; height: 100%; object-fit: cover; display: block; }
.viewer .placeholder { 
  color: #94a3b8; font-size: .9rem; text-align: center; padding: 20px;
  display: flex; flex-direction: column; align-items: center; gap: 10px;
}
.viewer .placeholder i { font-size: 2rem; opacity: 0.7; }

.alert-chip {
  position: absolute; top: 12px; left: 12px; z-index: 3;
  background: rgba(249, 115, 22, 0.9); backdrop-filter: blur(8px);
  color: #fff; font-weight: 600; font-size: .85rem;
  padding: 8px 14px; border-radius: 999px; display: none; align-items: center; gap: 8px;
  box-shadow: 0 4px 15px rgba(249, 115, 22, 0.4);
}
.alert-chip.show { display: inline-flex; animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 0%,100%{ transform: scale(1);} 50%{ transform: scale(1.04);} }

.row { display: flex; gap: 10px; margin-top: 16px; }
button.btn {
  font-family: "Sarabun"; font-weight: 600; font-size: .95rem; cursor: pointer;
  border: none; border-radius: 12px; padding: 12px 16px; flex: 1;
  background: var(--ink); color: #fff;
  display: flex; justify-content: center; align-items: center; gap: 8px;
  transition: all 0.2s;
  box-shadow: 0 4px 12px rgba(30, 41, 59, 0.2);
}
button.btn:hover { transform: translateY(-1px); box-shadow: 0 6px 16px rgba(30, 41, 59, 0.25); }
button.btn:active { transform: translateY(0); }
button.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; box-shadow: none; }
button.btn.ghost { 
  background: rgba(255,255,255,0.8); color: var(--ink); 
  border: 1px solid var(--glass-border); 
  box-shadow: 0 2px 8px rgba(0,0,0,0.05); 
}
button.btn.ghost:hover { background: #fff; }
button.btn.go { background: var(--water); box-shadow: 0 4px 12px rgba(14, 165, 233, 0.3); }
button.btn.go:hover { background: var(--water-hover); }

input[type=file] { display: none; }

/* Progress Bars */
.bars { margin-top: 16px; display: flex; flex-direction: column; gap: 10px; }
.bar-row { font-size: .85rem; }
.bar-row .lab { display: flex; justify-content: space-between; margin-bottom: 4px; }
.bar-row .lab b { font-weight: 600; }
.track { height: 10px; background: rgba(0,0,0,0.05); border-radius: 999px; overflow: hidden; box-shadow: inset 0 1px 3px rgba(0,0,0,0.1); }
.fill { height: 100%; width: 0%; border-radius: 999px; transition: width .3s cubic-bezier(0.4, 0, 0.2, 1); }

/* Inputs */
.field { margin-top: 16px; font-size: .9rem; }
.field label { display: block; color: var(--ink-soft); margin-bottom: 6px; font-weight: 500; }
.field input[type=text], .field select {
  width: 100%; padding: 10px 14px; 
  background: rgba(255,255,255,0.6);
  border: 1px solid var(--glass-border); border-radius: 10px; 
  font-family: "Sarabun"; font-size: .95rem;
  transition: all 0.2s;
  outline: none;
}
.field input[type=text]:focus, .field select:focus {
  background: #fff;
  border-color: var(--water);
  box-shadow: 0 0 0 3px rgba(14, 165, 233, 0.2);
}
.field input[type=range] { width: 100%; accent-color: var(--water); }

.coords { font-size: .85rem; color: var(--ink-soft); margin-top: 8px; }
.coords b { color: var(--ink); font-variant-numeric: tabular-nums; background: rgba(255,255,255,0.5); padding: 2px 6px; border-radius: 6px; }

#map { width: 100%; height: 100%; min-height: 500px; border-radius: 16px; z-index: 1; }
.map-card { display: flex; flex-direction: column; }
.map-card .bd { flex: 1; padding: 10px 20px; }

/* Reports */
.reports { margin-top: 24px; }
.reports .list { display: flex; flex-direction: column; }
.report-item {
  display: flex; align-items: center; gap: 14px; padding: 14px 20px;
  border-top: 1px solid var(--glass-border); cursor: pointer; font-size: .9rem;
  transition: background 0.2s;
}
.report-item:hover { background: rgba(255,255,255,0.4); }
.report-item .pin { width: 14px; height: 14px; border-radius: 50%; flex: none; box-shadow: 0 2px 6px rgba(0,0,0,0.15); }
.report-item .meta { color: var(--ink-soft); font-size: .8rem; }
.report-item .when { margin-left: auto; color: var(--ink-soft); font-size: .8rem; white-space: nowrap; background: rgba(0,0,0,0.04); padding: 4px 8px; border-radius: 6px;}
.empty { padding: 24px 20px; color: var(--ink-soft); font-size: .9rem; text-align: center; }

/* Security Note */
.note { margin: 0 auto 20px; max-width: 1200px; padding: 0 20px; }
.note .inner {
  background: rgba(255, 244, 229, 0.8); backdrop-filter: blur(10px);
  border: 1px solid rgba(251, 146, 60, 0.3); color: #9a3412;
  border-radius: 12px; padding: 12px 16px; font-size: .85rem;
  display: flex; align-items: flex-start; gap: 10px;
}
.note .inner i { font-size: 1.2rem; color: #f97316; flex: none; }

.pin-marker { display: grid; place-items: center; }
.pin-marker .glyph {
  width: 26px; height: 26px; border-radius: 50% 50% 50% 0; transform: rotate(-45deg);
  border: 3px solid #fff; box-shadow: 0 3px 8px rgba(0,0,0,.25);
}

/* Emergency Page */
.page { display: none; }
.page.active { display: grid; animation: fadeIn 0.3s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

.emergency-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
  padding: 20px;
}
.em-card {
  background: rgba(255, 255, 255, 0.7);
  border-radius: 16px;
  padding: 16px;
  display: flex;
  align-items: center;
  gap: 16px;
  border: 1px solid var(--glass-border);
  transition: all 0.2s;
  text-decoration: none;
  color: var(--ink);
}
.em-card:hover {
  background: #fff;
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(0,0,0,0.06);
}
.em-icon {
  width: 48px; height: 48px; border-radius: 12px;
  background: rgba(239, 68, 68, 0.1); color: var(--danger);
  display: grid; place-items: center; font-size: 1.5rem;
  flex: none;
}
.em-info h3 { margin: 0 0 2px 0; font-size: 1.05rem; }
.em-info p { margin: 0; color: var(--ink-soft); font-size: .85rem; }
.em-number { font-size: 1.2rem; font-weight: 600; color: var(--danger); letter-spacing: 1px; }

.mobile-menu-btn {
  display: none; background: none; border: none; font-size: 1.5rem; color: var(--ink); cursor: pointer;
}
.mobile-nav {
  display: none; flex-direction: column; gap: 10px; background: rgba(255,255,255,0.95);
  backdrop-filter: blur(20px); position: absolute; top: 100%; left: 0; right: 0;
  padding: 16px 24px; border-bottom: 1px solid var(--glass-border);
  box-shadow: 0 10px 20px rgba(0,0,0,0.05);
}
.mobile-nav.show { display: flex; }

/* Custom Scrollbar */
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.15); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: rgba(0,0,0,0.25); }
