/* SPDX-License-Identifier: MIT */
:root {
  --bg: #f7f7f5;
  --panel: #ffffff;
  --ink: #1c1c1c;
  --muted: #6b6b6b;
  --line: #e2e2dd;
  --accent: #2c7a4b;
  --accent-weak: #cfe6d8;
  --region-fill: #9bb3a4;
  --district-fill: #4f9d6e;
  --district-hi: #e0a82e;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  font-family: system-ui, -apple-system, "Segoe UI", Tahoma, sans-serif;
  color: var(--ink);
  background: var(--bg);
}

#topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 10px 16px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.brand {
  font-weight: 700;
}

#breadcrumb {
  flex: 1;
  font-size: 0.9rem;
  color: var(--muted);
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

#breadcrumb a {
  color: var(--accent);
  cursor: pointer;
  text-decoration: none;
}

#breadcrumb a:hover {
  text-decoration: underline;
}

#breadcrumb .sep {
  color: var(--line);
  margin: 0 6px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

button,
.dropdown-menu a,
#github-link {
  font: inherit;
}

.topbar-actions button,
#github-link {
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  color: var(--ink);
  cursor: pointer;
  text-decoration: none;
}

.topbar-actions button:hover,
#github-link:hover {
  border-color: var(--accent);
}

.dropdown {
  position: relative;
}

.dropdown-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 4px);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 6px;
  box-shadow: var(--shadow);
  min-width: 220px;
  max-height: 60vh;
  overflow: auto;
  z-index: 1000;
  padding: 6px 0;
}

.dropdown-menu a {
  display: block;
  padding: 6px 14px;
  color: var(--ink);
  text-decoration: none;
  font-size: 0.85rem;
}

.dropdown-menu a:hover {
  background: var(--accent-weak);
}

#layout {
  display: flex;
  height: calc(100% - 53px);
}

#sidebar {
  width: 280px;
  flex-shrink: 0;
  background: var(--panel);
  border-right: 1px solid var(--line);
  overflow-y: auto;
  padding: 12px 14px;
}

#sidebar h2 {
  font-size: 1rem;
  margin: 0 0 10px;
}

#list {
  list-style: none;
  margin: 0 0 20px;
  padding: 0;
}

#list li {
  padding: 7px 10px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.9rem;
  display: flex;
  justify-content: space-between;
  gap: 8px;
}

#list li:hover {
  background: var(--accent-weak);
}

#list li.active {
  background: var(--accent);
  color: #fff;
}

#list li .meta {
  color: var(--muted);
  font-size: 0.78rem;
}

#list li.active .meta {
  color: var(--accent-weak);
}

#map {
  flex: 1;
  min-width: 0;
}

#decoder {
  border-top: 1px solid var(--line);
  padding-top: 14px;
}

#decoder h3 {
  font-size: 0.85rem;
  margin: 0 0 8px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}

#decoder-input {
  width: 100%;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-variant-numeric: tabular-nums;
}

#decoder-output {
  margin: 12px 0 0;
}

#decoder-output > div,
#detail dl > div {
  display: flex;
  justify-content: space-between;
  padding: 4px 0;
  border-bottom: 1px dashed var(--line);
}

#decoder-output dt,
#detail dt {
  color: var(--muted);
  font-size: 0.82rem;
}

#decoder-output dd,
#detail dd {
  margin: 0;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

#detail {
  width: 300px;
  flex-shrink: 0;
  background: var(--panel);
  border-left: 1px solid var(--line);
  padding: 16px;
  position: relative;
  overflow-y: auto;
}

#detail-close {
  position: absolute;
  top: 10px;
  right: 12px;
  border: none;
  background: none;
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
  color: var(--muted);
}

#detail h2 {
  margin: 0 30px 14px 0;
  font-size: 1.1rem;
}

#copy-id {
  margin-top: 16px;
  width: 100%;
  padding: 9px;
  border: 1px solid var(--accent);
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
}

#copy-id:hover {
  filter: brightness(1.06);
}

/* Arabic right-to-left mode */
body.rtl {
  direction: rtl;
}

body.rtl #sidebar {
  border-right: none;
  border-left: 1px solid var(--line);
}

body.rtl #detail {
  border-left: none;
  border-right: 1px solid var(--line);
}

body.rtl #detail-close {
  right: auto;
  left: 12px;
}
