/* ===== 9M LLOTA Malaysia - Modern Stylesheet ===== */

:root {
  --brand: #6E3F8D;
  --brand-light: #9D6FC7;
  --brand-dark: #4A2A63;
  --water: #0EA5E9;
  --water-dark: #0284C7;
  --accent: #F59E0B;
  --bg: #F8FAFC;
  --bg-alt: #F1F5F9;
  --card: #FFFFFF;
  --border: #E2E8F0;
  --text: #1E293B;
  --text-muted: #64748B;
  --shadow: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.04);
  --shadow-lg: 0 10px 30px rgba(0,0,0,.08), 0 4px 12px rgba(0,0,0,.04);
  --radius: 16px;
  --radius-sm: 10px;
  --transition: .25s cubic-bezier(.4,0,.2,1);
}

[data-theme="dark"] {
  --brand: #B794E0;
  --brand-light: #D4B8F0;
  --brand-dark: #6E3F8D;
  --water: #38BDF8;
  --water-dark: #0EA5E9;
  --bg: #0F172A;
  --bg-alt: #1E293B;
  --card: #1E293B;
  --border: #334155;
  --text: #E2E8F0;
  --text-muted: #94A3B8;
  --shadow: 0 1px 3px rgba(0,0,0,.3);
  --shadow-lg: 0 10px 30px rgba(0,0,0,.4);
}

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

html { scroll-behavior: smooth; }

body {
  font-family: 'Inter', system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  transition: background var(--transition), color var(--transition);
}

/* ===== Hero ===== */
.hero {
  position: relative;
  background: linear-gradient(135deg, var(--brand-dark) 0%, var(--brand) 40%, var(--water-dark) 100%);
  color: #fff;
  padding: 3rem 1rem 4rem;
  text-align: center;
  overflow: hidden;
}

.hero::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image:
    radial-gradient(circle at 20% 50%, rgba(255,255,255,.08) 0%, transparent 50%),
    radial-gradient(circle at 80% 20%, rgba(255,255,255,.06) 0%, transparent 40%);
  pointer-events: none;
}

.hero::after {
  content: '';
  position: absolute;
  bottom: -1px;
  left: 0;
  right: 0;
  height: 60px;
  background: var(--bg);
  clip-path: polygon(0 100%, 100% 100%, 100% 0, 50% 60%, 0 0);
  transition: background var(--transition);
}

.hero-content {
  position: relative;
  max-width: 900px;
  margin: 0 auto;
}

.hero-logo-wrap {
  display: inline-block;
  background: rgba(255,255,255,.95);
  border-radius: 50%;
  padding: 12px;
  margin-bottom: 1.25rem;
  box-shadow: 0 8px 24px rgba(0,0,0,.25);
  animation: floatIn .6s ease-out;
}

.hero-logo {
  width: 140px;
  height: 140px;
  display: block;
  border-radius: 8px;
}

@keyframes floatIn {
  from { opacity: 0; transform: translateY(-20px) scale(.9); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  background: rgba(255,255,255,.15);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255,255,255,.2);
  padding: .4rem 1rem;
  border-radius: 100px;
  font-size: .85rem;
  font-weight: 500;
  margin-bottom: 1.5rem;
}

.hero h1 {
  font-size: clamp(1.8rem, 5vw, 3rem);
  font-weight: 800;
  letter-spacing: -.02em;
  margin-bottom: .75rem;
  line-height: 1.15;
}

.hero h1 .highlight {
  background: linear-gradient(90deg, #FBBF24, #F59E0B);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.hero p {
  font-size: clamp(.95rem, 2vw, 1.15rem);
  opacity: .92;
  max-width: 680px;
  margin: 0 auto 1.5rem;
}

.hero-callsign {
  display: inline-block;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 1.1rem;
  font-weight: 700;
  background: rgba(255,255,255,.1);
  border: 1px solid rgba(255,255,255,.25);
  padding: .3rem .8rem;
  border-radius: 8px;
  letter-spacing: .05em;
}

/* ===== Theme Toggle ===== */
.theme-toggle {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 1000;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 100px;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 1.2rem;
  box-shadow: var(--shadow);
  transition: all var(--transition);
}

.theme-toggle:hover {
  transform: scale(1.1);
  box-shadow: var(--shadow-lg);
}

/* ===== Layout ===== */
.container {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 1rem;
}

/* ===== Stats Bar ===== */
.stats-bar {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 1rem;
  margin: -2rem auto 2rem;
  position: relative;
  z-index: 10;
}

.stat-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 1.25rem 1rem;
  text-align: center;
  box-shadow: var(--shadow-lg);
  transition: all var(--transition);
}

.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg), 0 0 0 2px var(--brand-light);
}

.stat-card .stat-value {
  font-size: 2rem;
  font-weight: 800;
  color: var(--water-dark);
  line-height: 1;
}

.stat-card .stat-label {
  font-size: .8rem;
  color: var(--text-muted);
  margin-top: .35rem;
  text-transform: uppercase;
  letter-spacing: .03em;
}

/* ===== Section ===== */
.section {
  padding: 0 0 2rem;
}

.section-title {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--water-dark);
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  gap: .5rem;
}

.section-title .icon {
  color: var(--water);
}

/* ===== About Section ===== */
.about-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
  gap: 1.25rem;
  margin-bottom: 1.5rem;
}

.about-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow);
  transition: all var(--transition);
}

.about-card:hover {
  box-shadow: var(--shadow-lg);
  border-color: var(--brand-light);
}

.about-card h3 {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--water-dark);
  margin-bottom: .75rem;
  display: flex;
  align-items: center;
  gap: .5rem;
}

.about-card h3::before {
  content: '';
  display: inline-block;
  width: 4px;
  height: 1.1rem;
  background: linear-gradient(180deg, var(--water-dark), var(--water));
  border-radius: 2px;
}

.about-card p {
  font-size: .92rem;
  color: var(--text);
  margin-bottom: .75rem;
}

.about-card p:last-child { margin-bottom: 0; }

.about-card a {
  color: var(--water);
  text-decoration: none;
  font-weight: 600;
}

.about-card a:hover { text-decoration: underline; }

.about-card code {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: .82rem;
  background: var(--bg-alt);
  padding: .15rem .4rem;
  border-radius: 4px;
  color: var(--water-dark);
}

.about-list {
  list-style: none;
  padding: 0;
}

.about-list li {
  font-size: .9rem;
  padding: .4rem 0 .4rem 1.5rem;
  position: relative;
  border-bottom: 1px solid var(--border);
}

.about-list li:last-child { border-bottom: none; }

.about-list li::before {
  content: '\2713';
  position: absolute;
  left: 0;
  top: .4rem;
  color: var(--water);
  font-weight: 700;
}

.about-note {
  background: var(--card);
  border: 1px solid var(--border);
  border-left: 4px solid var(--accent);
  border-radius: var(--radius);
  padding: 1.25rem 1.5rem;
  box-shadow: var(--shadow);
}

.about-note p {
  font-size: .9rem;
  color: var(--text);
  margin: 0 0 1rem;
}

.about-links {
  display: flex;
  flex-wrap: wrap;
  gap: .75rem;
}

@media (max-width: 768px) {
  .about-grid { grid-template-columns: 1fr; }
  .about-links { flex-direction: column; }
  .about-links .btn { text-align: center; }
}

/* ===== Map ===== */
.map-container {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  margin-bottom: 2rem;
}

#map {
  height: 480px;
  width: 100%;
}

.map-legend {
  position: absolute;
  bottom: 1rem;
  left: 1rem;
  z-index: 500;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: .75rem 1rem;
  box-shadow: var(--shadow);
  font-size: .8rem;
}

.map-legend .legend-item {
  display: flex;
  align-items: center;
  gap: .5rem;
  margin: .25rem 0;
}

.map-legend .legend-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 2px solid #fff;
}

/* ===== Toolbar ===== */
.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: .75rem;
  align-items: center;
  margin-bottom: 1.5rem;
}

.search-box {
  flex: 1 1 280px;
  position: relative;
}

.search-box input {
  width: 100%;
  padding: .7rem 1rem .7rem 2.5rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: .95rem;
  background: var(--card);
  color: var(--text);
  transition: all var(--transition);
}

.search-box input:focus {
  outline: none;
  border-color: var(--water-dark);
  box-shadow: 0 0 0 3px rgba(110,63,141,.15);
}

.search-box .search-icon {
  position: absolute;
  left: .85rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 1rem;
}

.toolbar select {
  padding: .7rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: .9rem;
  background: var(--card);
  color: var(--text);
  cursor: pointer;
  transition: all var(--transition);
}

.toolbar select:hover {
  border-color: var(--brand-light);
}

.view-toggle {
  display: flex;
  gap: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.view-toggle button {
  padding: .7rem 1rem;
  border: none;
  background: var(--card);
  color: var(--text-muted);
  cursor: pointer;
  font-size: .85rem;
  font-weight: 600;
  transition: all var(--transition);
}

.view-toggle button.active {
  background: var(--brand);
  color: #fff;
}

.result-count {
  font-size: .85rem;
  color: var(--text-muted);
  margin-left: auto;
}

/* ===== Card Grid ===== */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 1rem;
}

.spot-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: all var(--transition);
  position: relative;
  overflow: hidden;
}

.spot-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: linear-gradient(90deg, var(--brand), var(--water));
  opacity: 0;
  transition: opacity var(--transition);
}

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

.spot-card:hover::before {
  opacity: 1;
}

.spot-card .card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: .5rem;
  margin-bottom: .5rem;
}

.spot-card .card-code {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: .8rem;
  font-weight: 700;
  color: var(--water-dark);
  background: var(--bg-alt);
  padding: .2rem .5rem;
  border-radius: 6px;
  white-space: nowrap;
}

.spot-card .card-area {
  font-size: .78rem;
  color: var(--text-muted);
  white-space: nowrap;
}

.spot-card .card-name {
  font-size: 1.05rem;
  font-weight: 700;
  margin-bottom: .35rem;
  line-height: 1.3;
}

.spot-card .card-state {
  font-size: .85rem;
  color: var(--text-muted);
  margin-bottom: .75rem;
}

.spot-card .card-type {
  display: inline-block;
  font-size: .75rem;
  padding: .25rem .6rem;
  border-radius: 100px;
  background: var(--bg-alt);
  color: var(--text-muted);
  font-weight: 500;
}

.spot-card .card-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: .75rem;
  padding-top: .75rem;
  border-top: 1px solid var(--border);
}

.spot-card .card-coords {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: .75rem;
  color: var(--text-muted);
}

.spot-card .card-map-link {
  font-size: .8rem;
  color: var(--water);
  text-decoration: none;
  font-weight: 600;
}

.spot-card .card-map-link:hover {
  text-decoration: underline;
}

/* ===== Table View ===== */
.table-wrap {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}

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

thead th {
  background: var(--bg-alt);
  text-align: left;
  padding: .8rem 1rem;
  font-size: .78rem;
  text-transform: uppercase;
  letter-spacing: .03em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
  transition: background var(--transition);
}

thead th:hover { background: var(--border); }

thead th.sort-asc::after { content: " \25B2"; color: var(--water-dark); }
thead th.sort-desc::after { content: " \25BC"; color: var(--water-dark); }

tbody td {
  padding: .7rem 1rem;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

tbody tr:last-child td { border-bottom: none; }
tbody tr { cursor: pointer; transition: background var(--transition); }
tbody tr:hover { background: var(--bg-alt); }

.cell-code {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-weight: 700;
  color: var(--water-dark);
  white-space: nowrap;
}

.cell-name { font-weight: 600; }
.cell-type { font-size: .82rem; color: var(--text-muted); }
.cell-area { font-size: .85rem; color: var(--text-muted); white-space: nowrap; }
.cell-coords {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: .8rem;
  color: var(--text-muted);
  white-space: nowrap;
}

.type-badge {
  display: inline-block;
  font-size: .72rem;
  padding: .2rem .5rem;
  border-radius: 100px;
  background: var(--bg-alt);
  color: var(--text-muted);
  font-weight: 500;
}

/* ===== Modal ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  backdrop-filter: blur(4px);
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition);
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.modal {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  max-width: 560px;
  width: 100%;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  transform: scale(.95);
  transition: transform var(--transition);
}

.modal-overlay.active .modal {
  transform: scale(1);
}

.modal-header {
  background: linear-gradient(135deg, var(--brand) 0%, var(--water-dark) 100%);
  color: #fff;
  padding: 1.5rem;
  position: relative;
}

.modal-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  background: rgba(255,255,255,.2);
  border: none;
  color: #fff;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 1.1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--transition);
}

.modal-close:hover { background: rgba(255,255,255,.35); }

.modal-header .modal-code {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: .85rem;
  opacity: .85;
  margin-bottom: .25rem;
}

.modal-header h2 {
  font-size: 1.4rem;
  font-weight: 700;
  margin-bottom: .35rem;
}

.modal-header .modal-state {
  font-size: .9rem;
  opacity: .85;
}

.modal-body { padding: 1.5rem; }

.modal-row {
  display: flex;
  justify-content: space-between;
  padding: .6rem 0;
  border-bottom: 1px solid var(--border);
}

.modal-row:last-child { border-bottom: none; }

.modal-row .label {
  color: var(--text-muted);
  font-size: .85rem;
}

.modal-row .value {
  font-weight: 600;
  text-align: right;
}

.modal-map {
  margin-top: 1rem;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--border);
}

.modal-map iframe {
  width: 100%;
  height: 240px;
  border: 0;
  display: block;
}

.modal-actions {
  display: flex;
  gap: .75rem;
  margin-top: 1rem;
}

.btn {
  flex: 1;
  padding: .7rem 1rem;
  border: none;
  border-radius: var(--radius-sm);
  font-size: .9rem;
  font-weight: 600;
  cursor: pointer;
  text-align: center;
  text-decoration: none;
  transition: all var(--transition);
}

.btn-primary {
  background: var(--brand);
  color: #fff;
}

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

.btn-secondary {
  background: var(--bg-alt);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-secondary:hover { background: var(--border); }

/* ===== Footer ===== */
footer {
  text-align: center;
  color: var(--text-muted);
  font-size: .85rem;
  padding: 2rem 1rem;
  border-top: 1px solid var(--border);
  margin-top: 2rem;
}

/* ===== About 9M2PJU ===== */
.about-piju {
  padding-bottom: 1rem;
}

.piju-card {
  display: flex;
  gap: 1.5rem;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.75rem;
  box-shadow: var(--shadow);
  align-items: flex-start;
}

.piju-avatar {
  flex-shrink: 0;
}

.piju-avatar img {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  border: 3px solid var(--brand);
  object-fit: cover;
}

.piju-info h3 {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--water-dark);
  margin-bottom: .5rem;
}

.piju-bio {
  font-size: .9rem;
  color: var(--text);
  margin-bottom: .75rem;
  line-height: 1.6;
}

.piju-memberships {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
  margin-bottom: 1rem;
}

.membership-badge {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: .75rem;
  font-weight: 600;
  background: var(--bg-alt);
  color: var(--text-muted);
  padding: .25rem .6rem;
  border-radius: 100px;
  border: 1px solid var(--border);
}

.piju-links {
  display: flex;
  flex-wrap: wrap;
  gap: .75rem;
}

.piju-links .btn {
  flex: 0 0 auto;
}

@media (max-width: 600px) {
  .piju-card { flex-direction: column; align-items: center; text-align: center; }
  .piju-links { justify-content: center; }
  .piju-memberships { justify-content: center; }
}

/* ===== PWA Install Banner ===== */
.pwa-install-banner {
  position: fixed;
  bottom: 1rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1500;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: .75rem 1rem;
  max-width: 420px;
  width: calc(100% - 2rem);
  animation: slideUp .3s ease-out;
}

@keyframes slideUp {
  from { opacity: 0; transform: translateX(-50%) translateY(20px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

.pwa-install-content {
  display: flex;
  align-items: center;
  gap: .75rem;
}

.pwa-install-content img {
  border-radius: 8px;
  flex-shrink: 0;
}

.pwa-install-text {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.pwa-install-text strong {
  font-size: .9rem;
  color: var(--text);
}

.pwa-install-text span {
  font-size: .78rem;
  color: var(--text-muted);
}

.pwa-install-content .btn {
  padding: .5rem 1rem;
  font-size: .85rem;
  flex: 0 0 auto;
}

.pwa-install-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.3rem;
  cursor: pointer;
  padding: 0 .25rem;
  line-height: 1;
}

.pwa-install-close:hover { color: var(--text); }

.footer-logo {
  width: 64px;
  height: 64px;
  margin-bottom: .75rem;
  opacity: .9;
}

footer a {
  color: var(--water);
  text-decoration: none;
}

footer a:hover { text-decoration: underline; }

/* ===== Responsive ===== */
@media (max-width: 768px) {
  .hero { padding: 2rem 1rem 3rem; }
  .stats-bar { grid-template-columns: repeat(2, 1fr); }
  .card-grid { grid-template-columns: 1fr; }
  #map { height: 360px; }
  .cell-coords, thead th:nth-child(6) { display: none; }
  td:nth-child(6) { display: none; }
  .toolbar { gap: .5rem; }
  .search-box { flex: 1 1 100%; }
}

@media (max-width: 480px) {
  .stats-bar { grid-template-columns: repeat(2, 1fr); gap: .5rem; }
  .stat-card { padding: .85rem .5rem; }
  .stat-card .stat-value { font-size: 1.5rem; }
  .view-toggle button { padding: .6rem .7rem; font-size: .8rem; }
}

/* ===== Animations ===== */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.fade-in { animation: fadeIn .4s ease-out; }

/* ===== Leaflet overrides ===== */
.leaflet-popup-content-wrapper {
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
}

.leaflet-popup-content {
  margin: .75rem .85rem;
  font-family: 'Inter', system-ui, sans-serif;
}

.leaflet-popup-content .popup-code {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-weight: 700;
  color: var(--water-dark);
  font-size: .8rem;
}

.leaflet-popup-content .popup-name {
  font-weight: 700;
  font-size: .95rem;
  margin: .15rem 0;
}

.leaflet-popup-content .popup-state {
  color: var(--text-muted);
  font-size: .8rem;
}

/* ===== Scrollbar ===== */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: var(--bg-alt); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }
