/* OPS CONNECT — IP LOCATOR
   Law enforcement tactical interface */

:root {
  --bg-deep: #0a0e14;
  --bg-panel: #111820;
  --bg-elevated: #1a2332;
  --border: #2a3a4f;
  --border-bright: #3d5470;
  --text: #c8d4e0;
  --text-dim: #7a8fa3;
  --text-bright: #eef4fa;
  --accent: #c9a227;
  --accent-dim: #8a7020;
  --accent-glow: rgba(201, 162, 39, 0.25);
  --secure: #2d8a5e;
  --secure-bg: rgba(45, 138, 94, 0.12);
  --warn: #c97a27;
  --warn-bg: rgba(201, 122, 39, 0.12);
  --danger: #c93d3d;
  --danger-bg: rgba(201, 61, 61, 0.12);
  --info: #3d8ac9;
  --info-bg: rgba(61, 138, 201, 0.12);
  --mono: "IBM Plex Mono", "Consolas", monospace;
  --sans: "IBM Plex Sans", system-ui, sans-serif;
  --radius: 4px;
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.45);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  font-size: 15px;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--sans);
  background: var(--bg-deep);
  color: var(--text);
  line-height: 1.5;
  position: relative;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse 80% 50% at 50% -20%, rgba(201, 162, 39, 0.06), transparent),
    linear-gradient(180deg, var(--bg-deep) 0%, #0d1219 100%);
  pointer-events: none;
  z-index: 0;
}

.scanline {
  position: fixed;
  inset: 0;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 2px,
    rgba(0, 0, 0, 0.03) 2px,
    rgba(0, 0, 0, 0.03) 4px
  );
  pointer-events: none;
  z-index: 9999;
  opacity: 0.4;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

/* Header */
.top-bar {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.85rem 1.75rem;
  background: #0b1628;
  border-bottom: 1px solid #152238;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.35);
}

.top-bar__brand {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.seal {
  flex-shrink: 0;
  width: 58px;
  height: 58px;
}

.seal__img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
  border-radius: 50%;
}

.top-bar__titles {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 0.1rem;
  line-height: 1.15;
}

.top-bar__agency {
  margin: 0;
  font-family: "Source Sans 3", var(--sans);
  font-size: 1.05rem;
  font-weight: 500;
  letter-spacing: 0.04em;
  color: #5ec8f2;
  text-transform: uppercase;
}

.top-bar__tm {
  font-size: 0.55em;
  font-weight: 400;
  vertical-align: super;
  letter-spacing: 0;
  color: #5ec8f2;
}

.top-bar__title {
  margin: 0;
  font-family: "Source Sans 3", var(--sans);
  font-size: 1.65rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  color: #ffffff;
  text-transform: none;
}

.top-bar__meta {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

@media (max-width: 640px) {
  .top-bar {
    padding: 0.75rem 1rem;
    flex-wrap: wrap;
  }

  .seal {
    width: 48px;
    height: 48px;
  }

  .top-bar__agency {
    font-size: 0.9rem;
  }

  .top-bar__title {
    font-size: 1.35rem;
  }

  .top-bar__meta {
    width: 100%;
    justify-content: flex-end;
  }
}

.status-pill {
  font-family: var(--mono);
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  padding: 0.35rem 0.75rem;
  border-radius: 2px;
  text-transform: uppercase;
}

.status-pill--secure {
  background: var(--secure-bg);
  color: var(--secure);
  border: 1px solid var(--secure);
}

.status-pill--busy {
  background: var(--warn-bg);
  color: var(--warn);
  border: 1px solid var(--warn);
  animation: pulse 1.2s ease-in-out infinite;
}

.status-pill--error {
  background: var(--danger-bg);
  color: var(--danger);
  border: 1px solid var(--danger);
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

.clock {
  font-family: var(--mono);
  font-size: 0.8rem;
  color: var(--text-dim);
  letter-spacing: 0.05em;
}

/* Layout */
.layout {
  position: relative;
  z-index: 1;
  max-width: 1400px;
  margin: 0 auto;
  padding: 1.5rem;
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-areas:
    "search map"
    "results results"
    "history history";
  gap: 1.25rem;
}

.panel--search { grid-area: search; }
.panel--map { grid-area: map; }
.panel--results { grid-area: results; }
.panel--history { grid-area: history; }

@media (max-width: 960px) {
  .layout {
    grid-template-columns: 1fr;
    grid-template-areas:
      "search"
      "map"
      "results"
      "history";
  }
}

/* Panels */
.panel {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.panel__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
  padding: 0.75rem 1rem;
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
}

.panel__header h2 {
  margin: 0;
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-bright);
}

.panel__tag {
  font-family: var(--mono);
  font-size: 0.6rem;
  letter-spacing: 0.1em;
  color: var(--text-dim);
  text-transform: uppercase;
}

.panel__actions {
  display: flex;
  gap: 0.5rem;
}

.panel > :not(.panel__header) {
  padding: 1rem;
}

.panel--map > .map-container,
.panel--map > .map-disclaimer {
  padding-left: 1rem;
  padding-right: 1rem;
}

.panel--map > .map-container {
  padding-top: 0;
}

/* Search form */
.search-form__row {
  display: flex;
  gap: 0.5rem;
}

.search-form input[type="text"] {
  flex: 1;
  min-width: 0;
  padding: 0.65rem 0.85rem;
  font-family: var(--mono);
  font-size: 0.95rem;
  color: var(--text-bright);
  background: var(--bg-deep);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.search-form input[type="text"]:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-glow);
}

.search-form input[type="text"]::placeholder {
  color: var(--text-dim);
  font-family: var(--sans);
  font-size: 0.85rem;
}

.search-form__actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

.case-ref {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px dashed var(--border);
}

.case-ref label {
  display: block;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-dim);
  margin-bottom: 0.4rem;
}

.case-ref input {
  width: 100%;
  padding: 0.5rem 0.75rem;
  font-family: var(--mono);
  font-size: 0.85rem;
  color: var(--text);
  background: var(--bg-deep);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  outline: none;
}

.case-ref input:focus {
  border-color: var(--accent-dim);
}

/* Buttons */
.btn {
  font-family: var(--mono);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 0.65rem 1.1rem;
  border-radius: var(--radius);
  border: 1px solid transparent;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
  white-space: nowrap;
}

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.btn--primary {
  background: var(--accent);
  color: #0a0e14;
  border-color: var(--accent);
}

.btn--primary:hover:not(:disabled) {
  background: #dbb42e;
}

.btn--ghost {
  background: transparent;
  color: var(--text-dim);
  border-color: var(--border);
}

.btn--ghost:hover:not(:disabled) {
  color: var(--accent);
  border-color: var(--accent-dim);
  background: var(--accent-glow);
}

.btn--sm {
  padding: 0.4rem 0.7rem;
  font-size: 0.65rem;
}

/* Map */
.map-container {
  height: 320px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #e8eef4;
  margin-bottom: 0.5rem;
}

.map-disclaimer {
  margin: 0 0 1rem;
  font-size: 0.7rem;
  color: var(--text-dim);
  font-style: italic;
  line-height: 1.4;
}

.leaflet-container {
  background: #e8eef4;
  font-family: var(--sans);
}

/* Alert */
.alert {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  padding: 0.75rem 1rem;
  margin-bottom: 1rem;
  border-radius: var(--radius);
  font-size: 0.85rem;
  border: 1px solid var(--border);
}

.alert__icon {
  font-size: 0.6rem;
  line-height: 1.6;
}

.alert--idle {
  background: var(--bg-elevated);
  color: var(--text-dim);
}

.alert--loading {
  background: var(--info-bg);
  border-color: var(--info);
  color: var(--info);
}

.alert--success {
  background: var(--secure-bg);
  border-color: var(--secure);
  color: var(--secure);
}

.alert--warn {
  background: var(--warn-bg);
  border-color: var(--warn);
  color: var(--warn);
}

.alert--error {
  background: var(--danger-bg);
  border-color: var(--danger);
  color: var(--danger);
}

/* Results grid */
.results-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 0.75rem;
}

.result-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.65rem 0.85rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.result-card--wide {
  grid-column: 1 / -1;
}

.result-card--highlight {
  border-color: var(--accent-dim);
  background: linear-gradient(135deg, var(--bg-elevated) 0%, rgba(201, 162, 39, 0.06) 100%);
}

.result-card--flag {
  border-color: var(--warn);
  background: var(--warn-bg);
}

.result-card__label {
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-dim);
}

.result-card__value {
  font-size: 0.9rem;
  color: var(--text-bright);
  word-break: break-word;
}

.result-card__value.mono {
  font-family: var(--mono);
  font-size: 0.85rem;
}

.result-card--placeholder .result-card__value {
  color: var(--text-dim);
}

/* History table */
.history-table-wrap {
  overflow-x: auto;
}

.history-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8rem;
}

.history-table th {
  text-align: left;
  font-family: var(--mono);
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-dim);
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--border-bright);
  white-space: nowrap;
}

.history-table td {
  padding: 0.55rem 0.75rem;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  vertical-align: middle;
}

.history-table td.mono {
  font-family: var(--mono);
  font-size: 0.75rem;
}

.history-table tbody tr:hover {
  background: rgba(255, 255, 255, 0.02);
}

.history-empty td {
  text-align: center;
  color: var(--text-dim);
  font-style: italic;
  padding: 1.5rem;
}

.history-reload {
  font-family: var(--mono);
  font-size: 0.65rem;
  color: var(--accent);
  background: none;
  border: none;
  cursor: pointer;
  text-decoration: underline;
  padding: 0;
}

.history-reload:hover {
  color: var(--text-bright);
}

/* Footer */
.footer {
  position: relative;
  z-index: 1;
  padding: 1.25rem 1.5rem 2rem;
  text-align: center;
  font-size: 0.75rem;
  color: var(--text-dim);
  border-top: 1px solid var(--border);
  margin-top: 1rem;
}

.footer p {
  margin: 0.25rem 0;
}

.footer__fine {
  font-size: 0.65rem;
  opacity: 0.7;
}

.footer strong {
  color: var(--accent);
  letter-spacing: 0.05em;
}

/* Leaflet dark tweaks */
.leaflet-control-zoom a {
  background: var(--bg-elevated) !important;
  color: var(--text) !important;
  border-color: var(--border) !important;
}

.leaflet-control-zoom a:hover {
  background: var(--bg-panel) !important;
  color: var(--accent) !important;
}

.leaflet-popup-content-wrapper {
  background: var(--bg-panel);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.leaflet-popup-tip {
  background: var(--bg-panel);
}

.leaflet-popup-content {
  font-family: var(--mono);
  font-size: 0.75rem;
  margin: 0.6rem 0.8rem;
}

/* Search overlay */
.search-overlay {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(5, 8, 12, 0.88);
  backdrop-filter: blur(4px);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.25s ease, visibility 0.25s ease;
}

.search-overlay.is-active {
  opacity: 1;
  visibility: visible;
}

.search-overlay__panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  padding: 2rem 2.5rem;
  background: var(--bg-panel);
  border: 1px solid var(--accent-dim);
  border-radius: var(--radius);
  box-shadow: 0 0 60px rgba(201, 162, 39, 0.15), var(--shadow);
  min-width: 280px;
}

.radar {
  position: relative;
  width: 140px;
  height: 140px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(201, 162, 39, 0.08) 0%, transparent 70%);
  border: 1px solid var(--border-bright);
  overflow: hidden;
}

.radar__ring {
  position: absolute;
  top: 50%;
  left: 50%;
  border: 1px solid rgba(201, 162, 39, 0.25);
  border-radius: 50%;
  transform: translate(-50%, -50%);
}

.radar__ring--1 { width: 40%; height: 40%; }
.radar__ring--2 { width: 70%; height: 70%; }
.radar__ring--3 { width: 100%; height: 100%; border-color: rgba(201, 162, 39, 0.4); }

.radar__sweep {
  position: absolute;
  inset: 0;
  background: conic-gradient(
    from 0deg,
    transparent 0deg,
    transparent 270deg,
    rgba(201, 162, 39, 0.45) 360deg
  );
  animation: radar-sweep 2s linear infinite;
  border-radius: 50%;
}

.radar__center {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 8px;
  height: 8px;
  margin: -4px 0 0 -4px;
  background: var(--accent);
  border-radius: 50%;
  box-shadow: 0 0 12px var(--accent);
}

.radar__blip {
  position: absolute;
  width: 6px;
  height: 6px;
  background: var(--secure);
  border-radius: 50%;
  box-shadow: 0 0 8px var(--secure);
  opacity: 0;
  animation: radar-blip 2s ease-in-out infinite;
}

.radar__blip--1 { top: 28%; left: 62%; animation-delay: 0.4s; }
.radar__blip--2 { top: 58%; left: 32%; animation-delay: 1.1s; }

@keyframes radar-sweep {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

@keyframes radar-blip {
  0%, 100% { opacity: 0; transform: scale(0.5); }
  50% { opacity: 1; transform: scale(1); }
}

.search-overlay__title {
  margin: 0;
  font-family: var(--mono);
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: 0.35em;
  color: var(--accent);
  text-indent: 0.35em;
}

.search-overlay__status {
  margin: 0;
  font-family: var(--mono);
  font-size: 0.8rem;
  color: var(--text);
  text-align: center;
  min-height: 1.2em;
}

.search-overlay__bar {
  width: 100%;
  height: 3px;
  background: var(--bg-deep);
  border-radius: 2px;
  overflow: hidden;
  border: 1px solid var(--border);
}

.search-overlay__bar-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent-dim), var(--accent));
  animation: search-progress 2s ease-in-out forwards;
}

.search-overlay.is-active .search-overlay__bar-fill {
  animation: search-progress 2s ease-in-out forwards;
}

@keyframes search-progress {
  0% { width: 0%; }
  40% { width: 55%; }
  75% { width: 82%; }
  100% { width: 100%; }
}

.search-overlay__hint {
  margin: 0;
  font-size: 0.6rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-dim);
}

/* PDF export modal */
.modal {
  position: fixed;
  inset: 0;
  z-index: 10001;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background: rgba(5, 8, 12, 0.88);
  backdrop-filter: blur(4px);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.25s ease, visibility 0.25s ease;
}

.modal.is-active {
  opacity: 1;
  visibility: visible;
}

.modal__panel {
  width: 100%;
  max-width: 560px;
  max-height: 92vh;
  overflow-y: auto;
  background: var(--bg-panel);
  border: 1px solid var(--border-bright);
  border-radius: var(--radius);
  box-shadow: 0 8px 48px rgba(0, 0, 0, 0.55);
}

.modal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.25rem;
  background: #0b1628;
  border-bottom: 1px solid var(--accent-dim);
}

.modal__header h2 {
  margin: 0;
  font-family: "Source Sans 3", var(--sans);
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-bright);
  letter-spacing: 0.02em;
}

.modal__close {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  padding: 0.25rem 0.5rem;
}

.modal__close:hover {
  color: var(--text-bright);
}

.modal__disclaimer {
  margin: 1rem 1.25rem 0;
  padding: 0.85rem 1rem;
  background: var(--danger-bg);
  border: 1px solid var(--danger);
  border-radius: var(--radius);
}

.modal__disclaimer-title {
  margin: 0 0 0.4rem;
  font-family: var(--mono);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--danger);
}

.modal__disclaimer p:last-child {
  margin: 0;
  font-size: 0.82rem;
  color: var(--text);
  line-height: 1.5;
}

.modal__form {
  padding: 1rem 1.25rem 1.25rem;
}

.modal__fieldset {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  margin: 0 0 1rem;
}

.modal__fieldset legend {
  font-family: var(--mono);
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent);
  padding: 0 0.4rem;
}

.modal__grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.85rem;
}

.modal__field--wide {
  grid-column: 1 / -1;
}

.modal__field label {
  display: block;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-dim);
  margin-bottom: 0.35rem;
}

.modal__field .req {
  color: var(--danger);
}

.modal__field input,
.modal__field select {
  width: 100%;
  padding: 0.55rem 0.7rem;
  font-family: var(--sans);
  font-size: 0.9rem;
  color: var(--text-bright);
  background: var(--bg-deep);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  outline: none;
}

.modal__field input:focus,
.modal__field select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-glow);
}

.modal__ack {
  margin-bottom: 1rem;
  padding: 0.85rem 1rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.modal__ack-label {
  display: flex;
  gap: 0.65rem;
  align-items: flex-start;
  cursor: pointer;
  font-size: 0.82rem;
  color: var(--text);
  line-height: 1.5;
}

.modal__ack-label input {
  flex-shrink: 0;
  margin-top: 0.2rem;
  width: 1rem;
  height: 1rem;
  accent-color: var(--accent);
}

.modal__actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.65rem;
  flex-wrap: wrap;
}

@media (max-width: 520px) {
  .modal__grid {
    grid-template-columns: 1fr;
  }
}
