/* === Reset & Base === */
* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: #1a1a2e;
  color: #e0e0e0;
  height: 100vh;
  overflow: hidden;
}

/* === Login Page === */
.login-container {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100vh;
  background: #1a1a2e;
}
.login-box {
  background: #16213e;
  padding: 40px;
  border-radius: 12px;
  border: 1px solid #0f3460;
  width: 380px;
  max-width: 90vw;
}
.login-title {
  font-size: 28px;
  color: #e94560;
  margin-bottom: 4px;
}
.login-subtitle {
  color: #888;
  font-size: 14px;
  margin-bottom: 24px;
}
.login-box input {
  width: 100%;
  padding: 10px 12px;
  background: #1a1a2e;
  color: #e0e0e0;
  border: 1px solid #0f3460;
  border-radius: 6px;
  font-size: 14px;
  margin-bottom: 12px;
}
.login-box input:focus {
  outline: none;
  border-color: #e94560;
}
.login-box button {
  width: 100%;
  padding: 10px;
  background: #e94560;
  color: #fff;
  border: none;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  margin-bottom: 8px;
}
.login-box button:hover { background: #c73650; }
.login-error {
  color: #e94560;
  font-size: 13px;
  min-height: 18px;
}
.login-toggle {
  text-align: center;
  font-size: 13px;
  color: #888;
  margin-top: 8px;
}
.login-toggle a {
  color: #e94560;
  text-decoration: none;
}
.login-toggle a:hover { text-decoration: underline; }

/* === App Layout === */
#app {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* === Sidebar === */
#sidebar {
  width: 400px;
  min-width: 400px;
  background: #16213e;
  display: flex;
  flex-direction: column;
  border-right: 1px solid #0f3460;
  z-index: 10;
}
#sidebar-header {
  padding: 12px 16px;
  border-bottom: 1px solid #0f3460;
}
.brand-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}
.brand-row h1 {
  font-size: 18px;
  color: #e94560;
  font-weight: 700;
}
.brand-row button {
  padding: 4px 10px;
  background: transparent;
  color: #888;
  border: 1px solid #0f3460;
  border-radius: 4px;
  font-size: 12px;
  cursor: pointer;
}
.brand-row button:hover { color: #e94560; border-color: #e94560; }

#search-box {
  display: flex;
  gap: 6px;
}
#search-box input {
  flex: 1;
  padding: 8px 10px;
  background: #1a1a2e;
  color: #e0e0e0;
  border: 1px solid #0f3460;
  border-radius: 4px;
  font-size: 13px;
}
#search-box input:focus { outline: none; border-color: #e94560; }
#search-box button {
  padding: 8px 14px;
  background: #e94560;
  color: #fff;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-weight: 600;
  font-size: 13px;
}
#search-box button:hover { background: #c73650; }

/* === Layer Toggles === */
#layer-toggles {
  padding: 8px 16px;
  border-bottom: 1px solid #0f3460;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.layer-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 0;
  font-size: 13px;
  cursor: pointer;
  color: #ccc;
}
.layer-toggle input { margin: 0; cursor: pointer; }
.layer-swatch {
  width: 12px;
  height: 12px;
  border-radius: 2px;
  display: inline-block;
}
.layer-count {
  margin-left: auto;
  font-size: 11px;
  color: #666;
}

/* === Sidebar Views (stack navigation) === */
.sidebar-view {
  display: none;
  flex-direction: column;
  flex: 1;
  overflow: hidden;
}
.sidebar-view.active {
  display: flex;
}

/* === Back Bar === */
#detail-back-bar {
  padding: 8px 16px;
  border-bottom: 1px solid #0f3460;
}
#detail-back {
  background: none;
  border: none;
  color: #53a8b6;
  font-size: 13px;
  cursor: pointer;
  padding: 0;
}
#detail-back:hover {
  color: #7cc8d4;
  text-decoration: underline;
}

/* === Match Context Badge === */
#detail-match-context {
  padding: 0 16px;
}
#detail-match-context:empty {
  display: none;
}
.match-badge {
  display: inline-block;
  padding: 3px 10px;
  margin: 8px 0 0;
  background: #1a1a2e;
  border: 1px solid #0f3460;
  border-radius: 4px;
  font-size: 11px;
  color: #888;
}

/* === Search Results === */
#search-results {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
}
.search-result-header {
  padding: 4px 8px;
  font-size: 12px;
  color: #888;
}
.search-result {
  padding: 8px 10px;
  margin-bottom: 4px;
  background: #1a1a2e;
  border: 1px solid #0f3460;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
}
.search-result:hover { border-color: #e94560; }
.search-result .result-type {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 3px;
  font-size: 10px;
  font-weight: 600;
  margin-right: 6px;
}
.result-type.owner { background: #1b3a2d; color: #6fd08f; }
.result-type.parcel { background: #1b2a4a; color: #60a0e0; }
.result-type.operator { background: #2d1b4e; color: #b68fd0; }
.result-type.docket { background: #4a3a1b; color: #e0c060; }
.search-result .result-name {
  font-weight: 500;
  color: #e0e0e0;
}
.search-result .result-detail {
  font-size: 11px;
  color: #888;
  margin-top: 2px;
}
.search-result .locate-btn {
  float: right;
  padding: 2px 8px;
  background: #0f3460;
  color: #53a8b6;
  border: 1px solid #1a4a7a;
  border-radius: 3px;
  cursor: pointer;
  font-size: 11px;
}
.search-result .locate-btn:hover { background: #1a4a7a; color: #fff; }

/* === Pooling Order Result Links === */
a.doc-result-link {
  display: flex;
  gap: 10px;
  text-decoration: none;
  color: inherit;
}
a.doc-result-link:hover { border-color: #e94560; }
.doc-result-thumb {
  width: 64px;
  height: 80px;
  object-fit: cover;
  border-radius: 4px;
  border: 1px solid #0f3460;
  flex-shrink: 0;
  background: #1a1a2e;
}
.doc-result-body {
  flex: 1;
  min-width: 0;
}

/* === Map === */
#map-container {
  flex: 1;
  position: relative;
}
#map {
  width: 100%;
  height: 100%;
}
.maplibregl-popup-content {
  background: #16213e !important;
  color: #e0e0e0 !important;
  border: 1px solid #0f3460 !important;
  border-radius: 8px !important;
  padding: 10px 14px !important;
  font-size: 13px;
}
.maplibregl-popup-tip {
  border-top-color: #16213e !important;
}
.maplibregl-popup-close-button {
  color: #888 !important;
  font-size: 18px;
}
.maplibregl-popup-close-button:hover { color: #e94560 !important; }

/* === Detail Header === */
#detail-header {
  display: flex;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid #0f3460;
  min-height: 48px;
}
#detail-title {
  font-size: 14px;
  font-weight: 600;
}
#detail-title .tmp-label {
  color: #e94560;
  font-size: 16px;
}
#detail-title .county-label {
  color: #888;
  font-size: 12px;
  margin-left: 8px;
}
/* === Detail Tabs === */
#detail-tabs {
  display: flex;
  border-bottom: 1px solid #0f3460;
  overflow-x: auto;
}
.tab {
  padding: 8px 14px;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: #888;
  font-size: 12px;
  cursor: pointer;
  white-space: nowrap;
}
.tab:hover { color: #e0e0e0; }
.tab.active {
  color: #e94560;
  border-bottom-color: #e94560;
}

/* === Detail Content === */
#detail-content {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
}
.detail-section {
  margin-bottom: 16px;
}
.detail-section h3 {
  font-size: 12px;
  color: #888;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}
.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.detail-field {
  padding: 6px 0;
}
.detail-field .field-label {
  font-size: 11px;
  color: #888;
}
.detail-field .field-value {
  font-size: 14px;
  color: #e0e0e0;
}

/* === Data Tables === */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}
.data-table th {
  background: #0f3460;
  color: #53a8b6;
  padding: 6px 8px;
  text-align: left;
  position: sticky;
  top: 0;
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
.data-table td {
  padding: 5px 8px;
  border-bottom: 1px solid #0f3460;
  color: #ccc;
}
.data-table tr:hover td { background: #1a1a2e; }
.data-table .leased { color: #6fd08f; }
.data-table .unleased { color: #e94560; }
.data-table .acres { text-align: right; }

/* === Badges === */
.badge {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 3px;
  font-size: 11px;
  font-weight: 600;
}
.badge-green { background: #1b3a2d; color: #6fd08f; }
.badge-red { background: #3a1b1b; color: #e06060; }
.badge-blue { background: #1b2a4a; color: #60a0e0; }
.badge-purple { background: #2d1b4e; color: #b68fd0; }
.badge-yellow { background: #4a3a1b; color: #e0c060; }

/* === Loading / Empty States === */
.loading {
  text-align: center;
  padding: 24px;
  color: #666;
  font-size: 13px;
}
.loading::after {
  content: '';
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid #0f3460;
  border-top-color: #e94560;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  margin-left: 8px;
  vertical-align: middle;
}
@keyframes spin { to { transform: rotate(360deg); } }

.empty-state {
  text-align: center;
  padding: 32px 16px;
  color: #666;
  font-size: 13px;
}

/* === CSV Export === */
.export-btn {
  padding: 4px 12px;
  background: #0f3460;
  color: #53a8b6;
  border: 1px solid #1a4a7a;
  border-radius: 4px;
  cursor: pointer;
  font-size: 11px;
  float: right;
  margin-bottom: 8px;
}
.export-btn:hover { background: #1a4a7a; color: #fff; }

/* === Nearby Features === */
.nearby-item {
  padding: 8px 10px;
  margin-bottom: 4px;
  background: #1a1a2e;
  border: 1px solid #0f3460;
  border-radius: 6px;
  font-size: 13px;
}
.nearby-item .nearby-name { font-weight: 500; }
.nearby-item .nearby-detail {
  font-size: 11px;
  color: #888;
  margin-top: 2px;
}
.nearby-item .nearby-distance {
  float: right;
  font-size: 11px;
  color: #53a8b6;
}

/* === Sidebar Toggle (mobile) === */
#sidebar-toggle {
  display: none;
  position: absolute;
  top: 10px;
  left: 10px;
  z-index: 20;
  padding: 6px 10px;
  background: #16213e;
  color: #e0e0e0;
  border: 1px solid #0f3460;
  border-radius: 6px;
  font-size: 18px;
  cursor: pointer;
  line-height: 1;
}
#sidebar-toggle:hover { border-color: #e94560; }

/* === Scrollbar === */
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: #1a1a2e; }
::-webkit-scrollbar-thumb { background: #0f3460; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #1a4a7a; }

/* === Mobile Responsive === */
@media (max-width: 768px) {
  #sidebar {
    position: absolute;
    top: 0;
    left: 0;
    height: 100vh;
    width: 85vw;
    min-width: unset;
    z-index: 30;
    transform: translateX(-100%);
    transition: transform 0.2s ease;
  }
  #sidebar.open {
    transform: translateX(0);
  }
  #sidebar-toggle {
    display: block;
  }
}
