/* ═══════════════════════════════════════════════════════
   NigeriaGeo Pro — Stylesheet
   Survey Coordinate Transformation & Validation System
   ═══════════════════════════════════════════════════════ */

/* ═══ CSS CUSTOM PROPERTIES ═══ */
:root {
  --green-dark:   #0a2e1a;
  --green-mid:    #1a5c35;
  --green-bright: #22a855;
  --green-light:  #4dd47a;
  --gold:         #c8922a;
  --gold-light:   #f0b84a;
  --ivory:        #f5f0e8;
  --ivory-dark:   #e8e0d0;
  --white:        #ffffff;
  --text-dark:    #0d1f10;
  --text-mid:     #2d4a35;
  --text-light:   #6b9a78;
  --red-warn:     #c0392b;
  --red-light:    #fdecea;
  --amber-warn:   #d68910;
  --amber-light:  #fef9ec;
  --blue-info:    #1a6fa8;
  --blue-light:   #eaf4fc;
  --panel-bg:     #f9f6f1;
  --border:       #d4cfc4;
  --shadow:       0 4px 24px rgba(10,46,26,0.10);
  --shadow-lg:    0 8px 40px rgba(10,46,26,0.16);
  --radius:       10px;
  --radius-lg:    16px;
  --font-body:    'IBM Plex Sans', sans-serif;
  --font-mono:    'IBM Plex Mono', monospace;
  --font-display: 'Playfair Display', serif;
}

/* ═══ RESET & BASE ═══ */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-body);
  background: var(--green-dark);
  color: var(--text-dark);
  font-size: 16px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ═══ HEADER ═══ */
.app-header {
  background: linear-gradient(135deg, #0a2e1a 0%, #0f3d22 60%, #1a5c35 100%);
  border-bottom: 3px solid var(--gold);
  padding: 0 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 80px;
  position: sticky;
  top: 0;
  z-index: 1000;
  box-shadow: 0 2px 20px rgba(0,0,0,0.4);
}

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

.brand-icon {
  width: 52px;
  height: 52px;
  background: var(--gold);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
  font-weight: 800;
  color: var(--green-dark);
  font-family: var(--font-display);
  flex-shrink: 0;
}

.brand-text h1 {
  font-family: var(--font-display);
  color: var(--ivory);
  font-size: 1.55rem;
  letter-spacing: 0.02em;
  line-height: 1.1;
}

.brand-text .subtitle {
  color: var(--gold-light);
  font-size: 0.78rem;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  margin-top: 2px;
}

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

.badge {
  background: rgba(200,146,42,0.18);
  border: 1px solid rgba(200,146,42,0.5);
  color: var(--gold-light);
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 5px 12px;
  border-radius: 20px;
}

/* ═══ MAIN LAYOUT ═══ */
.app-main {
  flex: 1;
  display: grid;
  grid-template-columns: 520px 1fr;
  grid-template-rows: 1fr;
  min-height: calc(100vh - 80px);
  background: var(--ivory);
}

/* ═══ LEFT PANEL ═══ */
.left-panel {
  background: var(--panel-bg);
  border-right: 2px solid var(--border);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.section-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 24px 14px;
  border-bottom: 2px solid var(--border);
  background: white;
  position: sticky;
  top: 0;
  z-index: 10;
}

.section-header .section-icon {
  width: 36px;
  height: 36px;
  background: var(--green-dark);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}

.section-header h2 {
  font-family: var(--font-display);
  font-size: 1.25rem;
  color: var(--green-dark);
}

.panel-body {
  padding: 20px 24px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* ═══ FORM CARDS ═══ */
.form-card {
  background: white;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.form-card-header {
  background: var(--green-dark);
  color: var(--ivory);
  padding: 10px 18px;
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  display: flex;
  align-items: center;
  gap: 8px;
}

.form-card-header.gold {
  background: linear-gradient(90deg, var(--gold) 0%, #a07020 100%);
  color: var(--green-dark);
}

.form-card-header.info {
  background: var(--blue-info);
}

.form-card-body {
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* ═══ FORM CONTROLS ═══ */
.field-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field-label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-mid);
  letter-spacing: 0.04em;
  display: flex;
  align-items: center;
  gap: 6px;
}

.field-label .tooltip-icon {
  width: 18px;
  height: 18px;
  background: var(--green-mid);
  color: white;
  border-radius: 50%;
  font-size: 11px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: help;
  flex-shrink: 0;
  font-style: normal;
  font-weight: 700;
}

.tooltip-icon[data-tip] {
  position: relative;
}

.tooltip-icon[data-tip]:hover::after {
  content: attr(data-tip);
  position: absolute;
  left: 24px;
  top: -4px;
  background: var(--text-dark);
  color: white;
  font-size: 12px;
  font-weight: 400;
  padding: 6px 10px;
  border-radius: 6px;
  white-space: normal;
  z-index: 100;
  max-width: 260px;
  line-height: 1.4;
  min-width: 180px;
  pointer-events: none;
}

select,
input[type="text"],
input[type="number"] {
  width: 100%;
  font-family: var(--font-body);
  font-size: 16px;
  padding: 11px 14px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  background: white;
  color: var(--text-dark);
  transition: border-color 0.18s, box-shadow 0.18s;
  appearance: none;
  -webkit-appearance: none;
}

select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%231a5c35' d='M6 8L0 0h12z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 36px;
}

select:focus,
input:focus {
  outline: none;
  border-color: var(--green-bright);
  box-shadow: 0 0 0 3px rgba(34,168,85,0.15);
}

select:disabled,
input:disabled {
  background: #f0ede8;
  color: #999;
}

input.error {
  border-color: var(--red-warn);
  box-shadow: 0 0 0 3px rgba(192,57,43,0.12);
}

input.ok {
  border-color: var(--green-bright);
}

.coord-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

/* ═══ BUTTONS ═══ */
.btn {
  font-family: var(--font-body);
  font-size: 16px;
  font-weight: 600;
  padding: 13px 22px;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.18s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  letter-spacing: 0.02em;
}

.btn-primary {
  background: var(--green-dark);
  color: white;
}

.btn-primary:hover {
  background: var(--green-mid);
  transform: translateY(-1px);
  box-shadow: var(--shadow);
}

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

.btn-gold {
  background: var(--gold);
  color: var(--green-dark);
}

.btn-gold:hover {
  background: var(--gold-light);
  transform: translateY(-1px);
  box-shadow: var(--shadow);
}

.btn-outline {
  background: white;
  color: var(--green-dark);
  border: 1.5px solid var(--green-mid);
}

.btn-outline:hover {
  background: #f0f8f3;
}

.btn-danger-outline {
  background: white;
  color: var(--red-warn);
  border: 1.5px solid var(--red-warn);
}

.btn-danger-outline:hover {
  background: var(--red-light);
}

.btn-sm {
  font-size: 14px;
  padding: 8px 16px;
}

.btn-block {
  width: 100%;
}

.btn-row {
  display: flex;
  gap: 10px;
}

/* ═══ ALERTS ═══ */
.alert {
  border-radius: 8px;
  padding: 12px 16px;
  font-size: 14px;
  line-height: 1.5;
  display: none;
  gap: 10px;
  align-items: flex-start;
}

.alert.visible {
  display: flex;
}

.alert-icon {
  font-size: 18px;
  flex-shrink: 0;
  margin-top: 1px;
}

.alert-error {
  background: var(--red-light);
  border: 1.5px solid #e74c3c;
  color: #922b21;
}

.alert-warning {
  background: var(--amber-light);
  border: 1.5px solid #e59866;
  color: #784212;
}

.alert-success {
  background: #edfaf3;
  border: 1.5px solid var(--green-bright);
  color: #1a6632;
}

.alert-info {
  background: var(--blue-light);
  border: 1.5px solid #85c1e9;
  color: #1a4f7a;
}

/* ═══ CRS INFO CARD ═══ */
.crs-info-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.crs-info-item {
  background: var(--panel-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
}

.crs-info-item .label {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-light);
  margin-bottom: 4px;
}

.crs-info-item .value {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-dark);
  font-family: var(--font-mono);
}

/* ═══ TRANSFORMATION PIPELINE ═══ */
.pipeline {
  display: flex;
  align-items: center;
  gap: 0;
  flex-wrap: wrap;
  font-size: 0.78rem;
}

.pipeline-step {
  background: var(--green-dark);
  color: var(--ivory);
  padding: 5px 12px;
  border-radius: 4px;
  font-weight: 600;
  font-family: var(--font-mono);
  white-space: nowrap;
}

.pipeline-arrow {
  color: var(--gold);
  font-size: 1.1rem;
  padding: 0 4px;
  font-weight: 700;
}

/* ═══ RESULT DISPLAY ═══ */
.result-coords {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.result-coord-box {
  background: var(--green-dark);
  border-radius: 8px;
  padding: 14px 16px;
}

.result-coord-box .coord-label {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--green-light);
  margin-bottom: 6px;
}

.result-coord-box .coord-value {
  font-family: var(--font-mono);
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--gold-light);
}

/* ═══ BATCH / FILE DROP ═══ */
.file-drop {
  border: 2.5px dashed var(--green-mid);
  border-radius: 10px;
  padding: 24px;
  text-align: center;
  background: #f5faf7;
  cursor: pointer;
  transition: all 0.2s;
}

.file-drop:hover,
.file-drop.drag-over {
  background: #e8f5ee;
  border-color: var(--green-bright);
}

.file-drop p {
  font-size: 15px;
  color: var(--text-mid);
  margin-top: 8px;
}

.file-drop .drop-icon {
  font-size: 36px;
}

.batch-table-wrap {
  max-height: 240px;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  font-family: var(--font-mono);
}

th {
  background: var(--green-dark);
  color: var(--ivory);
  padding: 8px 10px;
  text-align: left;
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  position: sticky;
  top: 0;
}

td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  color: var(--text-dark);
}

tr:nth-child(even) td {
  background: #f9f6f1;
}

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

.status-ok  { color: var(--green-mid); font-weight: 600; }
.status-err { color: var(--red-warn);  font-weight: 600; }

/* ═══ RIGHT PANEL ═══ */
.right-panel {
  display: flex;
  flex-direction: column;
  background: var(--ivory);
}

.map-header {
  background: white;
  border-bottom: 2px solid var(--border);
  padding: 16px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.map-header h2 {
  font-family: var(--font-display);
  font-size: 1.2rem;
  color: var(--green-dark);
  display: flex;
  align-items: center;
  gap: 10px;
}

#map {
  flex: 1;
  min-height: 400px;
}

.output-panel {
  background: white;
  border-top: 2px solid var(--border);
  padding: 20px 24px;
  max-height: 280px;
  overflow-y: auto;
}

.output-panel h3 {
  font-family: var(--font-display);
  font-size: 1.05rem;
  color: var(--green-dark);
  margin-bottom: 14px;
  padding-bottom: 10px;
  border-bottom: 1.5px solid var(--border);
}

/* ═══ TRANSFORM RESULT CARD ═══ */
.transform-result-card {
  background: var(--green-dark);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 12px;
}

.transform-result-card .card-head {
  background: var(--gold);
  color: var(--green-dark);
  padding: 10px 18px;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.transform-result-card .card-body {
  padding: 16px 18px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.result-field .lbl {
  font-size: 0.7rem;
  color: var(--green-light);
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin-bottom: 4px;
}

.result-field .val {
  font-family: var(--font-mono);
  font-size: 0.95rem;
  color: white;
  font-weight: 500;
}

.result-field .val.big {
  font-size: 1.1rem;
  color: var(--gold-light);
  font-weight: 600;
}

/* ═══ EMPTY STATE ═══ */
.empty-state {
  text-align: center;
  padding: 30px 20px;
  color: var(--text-light);
  font-size: 15px;
}

.empty-state .empty-icon {
  font-size: 48px;
  margin-bottom: 12px;
}

/* ═══ TABS ═══ */
.tabs {
  display: flex;
  border-bottom: 2px solid var(--border);
  background: white;
  padding: 0 24px;
  gap: 0;
}

.tab {
  padding: 14px 20px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-light);
  cursor: pointer;
  border-bottom: 3px solid transparent;
  margin-bottom: -2px;
  transition: all 0.18s;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 6px;
}

.tab:hover  { color: var(--green-mid); }
.tab.active { color: var(--green-dark); border-bottom-color: var(--gold); }

.tab-panel        { display: none; }
.tab-panel.active { display: flex; flex-direction: column; }

/* ═══ PROGRESS BAR ═══ */
.progress-bar-wrap {
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--green-bright), var(--gold));
  border-radius: 3px;
  transition: width 0.3s;
  width: 0%;
}

/* ═══ DIVIDER ═══ */
.divider {
  border: none;
  border-top: 1.5px solid var(--border);
  margin: 4px 0;
}

/* ═══ FOOTER ═══ */
.app-footer {
  background: var(--green-dark);
  border-top: 2px solid var(--gold);
  color: rgba(245,240,232,0.6);
  font-size: 12px;
  padding: 10px 28px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.app-footer span {
  color: var(--gold-light);
  font-weight: 600;
}

/* ═══ CUSTOM SCROLLBAR ═══ */
::-webkit-scrollbar       { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--panel-bg); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-light); }

/* ═══ LEAFLET OVERRIDES ═══ */
.leaflet-popup-content-wrapper {
  border-radius: 10px !important;
  border: 2px solid var(--gold) !important;
  box-shadow: var(--shadow-lg) !important;
  font-family: var(--font-body) !important;
}

.leaflet-popup-tip {
  background: var(--gold) !important;
}

/* ═══ MOBILE TOGGLE BAR ═══ */
.mobile-toggle {
  display: none; /* hidden on desktop; shown via media query */
  background: var(--green-dark);
  border-bottom: 2px solid var(--gold);
  padding: 0;
  position: sticky;
  top: 64px; /* matches mobile header min-height */
  z-index: 999;
}

.mobile-toggle button {
  flex: 1;
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 600;
  padding: 12px 8px;
  border: none;
  background: transparent;
  color: rgba(245,240,232,0.6);
  cursor: pointer;
  transition: all 0.18s;
  border-bottom: 3px solid transparent;
  letter-spacing: 0.04em;
}

.mobile-toggle button.active {
  color: var(--gold-light);
  border-bottom-color: var(--gold);
  background: rgba(200,146,42,0.1);
}

.mobile-toggle button:hover:not(.active) {
  color: var(--ivory);
  background: rgba(255,255,255,0.05);
}



/* ── Tablet (portrait & landscape) ── */
@media (max-width: 1100px) {
  .app-main {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto;
    min-height: auto;
  }

  /* Stack: form first, map second */
  .left-panel  { order: 1; }
  .right-panel { order: 2; min-height: 420px; }

  #map {
    flex: none;
    height: 400px;
    min-height: 0;
  }

  .output-panel { max-height: none; }
}

/* ── Mobile phone ── */
@media (max-width: 768px) {
  /* Header compact */
  .app-header {
    padding: 0 14px;
    min-height: 64px;
    flex-wrap: wrap;
    gap: 6px;
  }

  .brand-text h1   { font-size: 1.15rem; }
  .brand-text .subtitle { display: none; }
  .header-badges   { gap: 6px; }
  .badge           { font-size: 0.62rem; padding: 4px 8px; }

  /* Mobile view-toggle bar */
  .mobile-toggle {
    display: flex;
  }

  /* Main layout */
  .app-main {
    grid-template-columns: 1fr;
    min-height: auto;
  }

  /* Show/hide panels via toggle */
  .left-panel.mobile-hidden,
  .right-panel.mobile-hidden {
    display: none;
  }

  /* Left panel full height on mobile */
  .left-panel {
    min-height: 100svh;
    order: 1;
  }

  /* Right panel: fixed map height so it doesn't swallow screen */
  .right-panel {
    order: 2;
    min-height: auto;
  }

  #map {
    flex: none;
    height: 320px;
    min-height: 0;
  }

  /* Ensure output panel is fully visible, not clipped */
  .output-panel {
    max-height: none;
    padding: 14px 16px;
  }

  /* Panel body padding tighter on phones */
  .panel-body { padding: 14px 14px; gap: 14px; }
  .form-card-body { padding: 14px; gap: 12px; }
  .map-header { padding: 12px 14px; flex-wrap: wrap; gap: 8px; }
  .map-header div { gap: 6px; }

  /* coord-row and crs-info-grid stack to single column on very small screens */
  .coord-row,
  .crs-info-grid { grid-template-columns: 1fr; }

  /* Result card body stack */
  .transform-result-card .card-body { grid-template-columns: 1fr; }
  .result-coords { grid-template-columns: 1fr; }

  /* Tabs scroll horizontally */
  .tabs { padding: 0 10px; overflow-x: auto; }
  .tab  { padding: 12px 14px; font-size: 13px; }

  /* Footer compact */
  .app-footer { flex-direction: column; gap: 4px; text-align: center; padding: 10px 14px; }
}

/* ── Very small phones ── */
@media (max-width: 380px) {
  .brand-icon { width: 38px; height: 38px; font-size: 18px; }
  .brand-text h1 { font-size: 1rem; }
  #map { height: 260px; }
}

/* ═══ ANIMATIONS ═══ */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: none; }
}

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

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.5; }
}

.processing { animation: pulse 1s infinite; }
