/* ============================================================
   CSS Custom Properties — light (default) & dark themes
   ============================================================ */
:root {
  --bg:           #f0f4f8;
  --surface:      #ffffff;
  --surface-2:    #f8fafc;
  --border:       #e2e8f0;
  --border-focus: #3b82f6;
  --text:         #0f172a;
  --text-muted:   #64748b;
  --accent:       #1d4ed8;
  --accent-hover: #1e40af;
  --accent-light: #dbeafe;
  --btn-text:     #ffffff;
  --shadow-sm:    0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
  --shadow-md:    0 4px 12px rgba(0,0,0,.10), 0 2px 4px rgba(0,0,0,.06);
  --shadow-lg:    0 10px 30px rgba(0,0,0,.12);
  --radius:       12px;
  --radius-sm:    8px;
  --radius-xs:    6px;
  --header-h:     60px;
  --transition:   0.2s ease;
}

body.dark-theme {
  --bg:           #0b1120;
  --surface:      #1e293b;
  --surface-2:    #162032;
  --border:       #334155;
  --border-focus: #60a5fa;
  --text:         #f1f5f9;
  --text-muted:   #94a3b8;
  --accent:       #3b82f6;
  --accent-hover: #2563eb;
  --accent-light: #1e3a5f;
  --btn-text:     #ffffff;
  --shadow-sm:    0 1px 3px rgba(0,0,0,.30);
  --shadow-md:    0 4px 12px rgba(0,0,0,.40);
  --shadow-lg:    0 10px 30px rgba(0,0,0,.50);
}

/* ============================================================
   Reset & Base
   ============================================================ */
*, *::before, *::after { box-sizing: border-box; }

body {
  font-family: 'Open Sans', system-ui, -apple-system, sans-serif;
  margin: 0;
  padding: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background-color: var(--bg);
  color: var(--text);
  transition: background-color var(--transition), color var(--transition);
}

/* ============================================================
   Header / Navbar
   ============================================================ */
header {
  height: var(--header-h);
  background-color: var(--surface);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 100;
  transition: background-color var(--transition), border-color var(--transition);
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.header-brand img {
  width: 28px;
  height: 28px;
}

.header-brand h1 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.01em;
}

.header-brand span {
  font-size: 0.7rem;
  font-weight: 400;
  color: var(--text-muted);
  display: block;
  line-height: 1;
}

/* ============================================================
   Theme Toggle Button
   ============================================================ */
#darkModeBtn {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 6px 14px;
  font-size: 0.8rem;
  font-family: inherit;
  cursor: pointer;
  transition: background-color var(--transition), color var(--transition),
              border-color var(--transition), transform 0.15s ease, box-shadow 0.15s ease;
}

#darkModeBtn:hover {
  background-color: var(--accent-light);
  border-color: var(--accent);
  color: var(--accent);
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

/* ============================================================
   Main Layout
   ============================================================ */
main {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 20px 24px 0;
  gap: 20px;
  max-width: 1400px;
  width: 100%;
  margin: 0 auto;
}

.top-row {
  display: grid;
  grid-template-columns: 380px 1fr;
  gap: 20px;
  align-items: stretch;
  min-height: 520px;
}

/* ============================================================
   Cards
   ============================================================ */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  transition: background-color var(--transition), border-color var(--transition),
              box-shadow var(--transition);
  overflow: hidden;
}

.card:hover {
  box-shadow: var(--shadow-md);
}

/* ============================================================
   Panels (left controls)
   ============================================================ */
.panels {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 16px 18px;
  transition: background-color var(--transition), border-color var(--transition);
}

.panel-title {
  margin: 0 0 12px;
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--accent);
  display: flex;
  align-items: center;
  gap: 7px;
}

.panel-title::before {
  content: '';
  display: inline-block;
  width: 3px;
  height: 14px;
  background: var(--accent);
  border-radius: 2px;
}

/* ============================================================
   Inputs
   ============================================================ */
.input-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 10px;
}

.input-group:last-of-type {
  margin-bottom: 0;
}

label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 0.03em;
}

input[type="text"] {
  width: 100%;
  padding: 9px 12px;
  font-size: 0.875rem;
  font-family: inherit;
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition),
              background-color var(--transition);
}

input[type="text"]:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--border-focus) 20%, transparent);
  background: var(--surface);
}

input[type="text"]::placeholder {
  color: var(--text-muted);
  opacity: 0.7;
}

.field-hint {
  font-size: 0.7rem;
  color: var(--text-muted);
  margin: 0;
  min-height: 1em;
  transition: color var(--transition);
}

.field-hint.error {
  color: #ef4444;
}

.format-hint {
  font-size: 0.68rem;
  color: var(--text-muted);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  padding: 6px 10px;
  margin-top: 6px;
  line-height: 1.6;
  font-family: 'Courier New', monospace;
}

.format-hint strong {
  font-family: 'Open Sans', sans-serif;
  font-size: 0.7rem;
  color: var(--text-muted);
  display: block;
  margin-bottom: 2px;
  letter-spacing: 0.03em;
}

/* ============================================================
   Buttons
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 18px;
  font-size: 0.825rem;
  font-weight: 600;
  font-family: inherit;
  border: none;
  border-radius: var(--radius-xs);
  cursor: pointer;
  transition: background-color var(--transition), transform 0.15s ease,
              box-shadow 0.15s ease;
  margin-top: 10px;
  width: 100%;
}

.btn-primary {
  background-color: var(--accent);
  color: var(--btn-text);
}

.btn-primary:hover {
  background-color: var(--accent-hover);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px color-mix(in srgb, var(--accent) 35%, transparent);
}

.btn-primary:active {
  transform: translateY(0);
}

/* ============================================================
   Map
   ============================================================ */
.map-card {
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  min-height: 400px;
  transition: border-color var(--transition);
}

#map {
  width: 100%;
  height: 100%;
  min-height: 400px;
  display: block;
}

/* ============================================================
   Results Table
   ============================================================ */
.results-section {
  padding: 0 0 20px;
}

.results-label {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 10px;
}

.result-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.result-table th {
  background: var(--surface-2);
  color: var(--text-muted);
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 10px 16px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.result-table td {
  padding: 11px 16px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  font-family: 'Courier New', monospace;
  font-size: 0.875rem;
}

.result-table tr:last-child td {
  border-bottom: none;
}

.result-table td:first-child {
  font-family: 'Open Sans', sans-serif;
  font-weight: 600;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  width: 120px;
}

.result-table tr:hover td {
  background: var(--surface-2);
}

/* MGRS row — highlight it */
.result-table tr.row-mgrs td {
  color: var(--accent);
  font-weight: 700;
  font-size: 0.95rem;
}

/* ============================================================
   Footer
   ============================================================ */
footer {
  text-align: center;
  font-size: 0.7rem;
  color: var(--text-muted);
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 10px 0;
  transition: background-color var(--transition), border-color var(--transition);
}

/* ============================================================
   Responsive
   ============================================================ */
@media screen and (max-width: 900px) {
  main {
    padding: 16px 16px 0;
  }

  .top-row {
    grid-template-columns: 1fr;
    min-height: unset;
  }

  .map-card {
    min-height: 320px;
  }

  #map {
    min-height: 320px;
  }
}

@media screen and (max-width: 480px) {
  header {
    padding: 0 16px;
  }

  .header-brand h1 {
    font-size: 0.9rem;
  }

  main {
    padding: 12px 12px 0;
    gap: 12px;
  }

  .result-table td:first-child {
    width: 90px;
  }
}
