/* ==========================================
   JeppNTM v9.0 — Orakulum / JeppNAV theme
   ========================================== */

@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Sans:wght@300;400;500;600;700&family=IBM+Plex+Mono:wght@400;500;600&family=Source+Sans+3:wght@300;400;500;600;700&display=swap');

:root {
  /* Orakulum shared dark base */
  --bg-primary: #0D1117;
  --bg-secondary: #161B22;
  --bg-tertiary: #1C2333;
  --bg-panel: #141A24;
  --border-color: #2A3442;
  --text-primary: #E6EDF3;
  --text-secondary: #8B949E;
  --text-muted: #6E7681;

  /* JeppNTM accent — NAV palette (steel gray-blue) */
  --ntm-primary: #7A8FB5;
  --ntm-secondary: #556B8A;
  --ntm-light: #A3B5D4;
  --ntm-gradient: linear-gradient(135deg, #556B8A 0%, #7A8FB5 50%, #A3B5D4 100%);
  --ntm-bg-tint: rgba(122, 143, 181, 0.06);
  --ntm-border-tint: rgba(122, 143, 181, 0.15);

  /* Status colors */
  --green: #3fb950;
  --green-bg: rgba(63, 185, 80, 0.12);
  --green-border: rgba(63, 185, 80, 0.3);
  --yellow: #d29922;
  --yellow-bg: rgba(210, 153, 34, 0.12);
  --yellow-border: rgba(210, 153, 34, 0.3);
  --red: #f85149;
  --red-bg: rgba(248, 81, 73, 0.12);
  --red-border: rgba(248, 81, 73, 0.3);

  --radius: 8px;
  --font-heading: 'IBM Plex Sans', sans-serif;
  --font-body: 'Source Sans 3', sans-serif;
  --font-mono: 'IBM Plex Mono', monospace;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: var(--font-body);
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  overflow: hidden;
}

/* ===== HEADER — gradient bar ===== */
#header {
  height: 44px;
  background: var(--ntm-gradient);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  position: relative;
  z-index: 1000;
  flex-shrink: 0;
}

#header::after {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: linear-gradient(180deg, rgba(0,0,0,0) 0%, rgba(0,0,0,0.15) 100%);
  pointer-events: none;
}

.header-left, .header-right, .header-center {
  display: flex;
  align-items: center;
  gap: 12px;
  z-index: 1;
}

.header-center { flex: 1; justify-content: center; gap: 14px; }

.header-logo {
  width: 24px; height: 24px;
  flex-shrink: 0;
}

.header-logo img {
  width: 100%; height: 100%;
  object-fit: contain;
  filter: brightness(0) invert(1);
}

.header-app-name {
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 18px;
  color: #fff;
  letter-spacing: 0.5px;
  white-space: nowrap;
  cursor: default;
}

.header-app-name .jepp { color: rgba(255,255,255,0.6); font-weight: 500; }
.header-app-name .suffix { color: #fff; }

.header-separator {
  width: 1px; height: 20px;
  background: rgba(255,255,255,0.2);
}

.header-subtitle {
  font-family: var(--font-body);
  font-size: 13px;
  color: rgba(255,255,255,0.7);
  font-weight: 300;
}

.header-api {
  display: flex;
  align-items: center;
}

.header-api input {
  background: rgba(0,0,0,0.25);
  border: 1px solid rgba(255,255,255,0.2);
  color: rgba(255,255,255,0.9);
  padding: 3px 10px;
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 10px;
  width: 170px;
  outline: none;
}

.header-api input:focus { border-color: rgba(255,255,255,0.5); }

.header-version-badge {
  padding: 3px 10px;
  border-radius: 20px;
  font-family: var(--font-mono);
  font-size: 10px;
  background: rgba(0,0,0,0.25);
  border: 1px solid rgba(255,255,255,0.2);
  color: rgba(255,255,255,0.7);
}

.header-version-badge .company {
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 12px;
  letter-spacing: 1.5px;
  color: #fff;
}

.header-version-badge .by {
  color: rgba(255,255,255,0.5);
}

.header-version-badge .version {
  color: rgba(255,255,255,0.7);
}

/* Flags */
.header-flags {
  display: flex;
  gap: 6px;
  align-items: center;
}

.flag-btn {
  width: 28px; height: 20px;
  border-radius: 3px;
  border: 1px solid rgba(255,255,255,0.3);
  cursor: pointer;
  overflow: hidden;
  transition: all 0.2s ease;
  opacity: 0.6;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  background-color: transparent;
}

.flag-btn.active {
  opacity: 1;
  border-color: rgba(255,255,255,0.7);
  box-shadow: 0 0 6px rgba(255,255,255,0.3);
}

.flag-btn:hover { opacity: 1; transform: scale(1.1); }

.flag-en {
  background-image: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 190 100"><rect width="190" height="100" fill="%23bf0a30"/><rect y="7.69" width="190" height="7.69" fill="%23fff"/><rect y="23.08" width="190" height="7.69" fill="%23fff"/><rect y="38.46" width="190" height="7.69" fill="%23fff"/><rect y="53.85" width="190" height="7.69" fill="%23fff"/><rect y="69.23" width="190" height="7.69" fill="%23fff"/><rect y="84.62" width="190" height="7.69" fill="%23fff"/><rect width="76" height="53.85" fill="%23002868"/></svg>');
}

.flag-pl {
  background-image: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 10"><rect width="16" height="5" fill="%23fff"/><rect y="5" width="16" height="5" fill="%23dc143c"/></svg>');
}

/* Stats in header center */
.stat {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 600;
  padding: 2px 10px;
  border-radius: 12px;
  border: 1px solid;
}

.stat.green  { color: #fff; background: rgba(63,185,80,0.3);  border-color: rgba(63,185,80,0.5); }
.stat.yellow { color: #fff; background: rgba(210,153,34,0.3); border-color: rgba(210,153,34,0.5); }
.stat.red    { color: #fff; background: rgba(248,81,73,0.3);  border-color: rgba(248,81,73,0.5); }

/* ===== DROP ZONE ===== */
#dropzone {
  position: absolute;
  top: 44px; left: 0; right: 0; bottom: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.dropzone-inner {
  text-align: center;
  pointer-events: none;
  border: 2px dashed var(--border-color);
  border-radius: 16px;
  padding: 60px 80px;
  background: var(--bg-secondary);
  transition: all 0.25s;
}

#dropzone:hover .dropzone-inner,
#dropzone.dragover .dropzone-inner {
  border-color: var(--ntm-primary);
  background: var(--ntm-bg-tint);
  box-shadow: 0 0 40px rgba(122, 143, 181, 0.15);
}

.dropzone-icon { color: var(--text-muted); margin-bottom: 16px; }
#dropzone:hover .dropzone-icon { color: var(--ntm-primary); }
.dropzone-title { font-family: var(--font-heading); font-size: 18px; font-weight: 600; margin-bottom: 6px; }
.dropzone-sub { font-size: 13px; color: var(--text-muted); }

/* ===== LOADING ===== */
#loading {
  position: fixed; top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  text-align: center; z-index: 9999;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  padding: 40px 50px;
  border-radius: 16px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.6);
}

.spinner {
  border: 3px solid var(--border-color);
  border-top: 3px solid var(--ntm-primary);
  border-radius: 50%;
  width: 40px; height: 40px;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 16px;
}

@keyframes spin { 100% { transform: rotate(360deg); } }
#loading p { color: var(--text-secondary); font-size: 13px; font-family: var(--font-mono); }

/* ===== WORKSPACE — shared scroll ===== */
#workspace {
  position: absolute;
  top: 44px; left: 0; right: 0; bottom: 0;
}

#scrollArea {
  width: 100%;
  height: 100%;
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  align-items: flex-start;
}

/* LEFT: PDF column */
#leftCol {
  flex: 1;
  min-width: 0;
  padding: 12px;
}

/* TOOLBAR bar */
#toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  padding: 6px 14px;
  margin-bottom: 12px;
  border-radius: var(--radius);
  position: sticky;
  top: 0;
  z-index: 100;
}

.legend-items {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}

.legend-item {
  display: flex; align-items: center;
  font-size: 11px; color: var(--text-secondary); gap: 5px;
  font-family: var(--font-mono);
}

.legend-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.legend-dot.green  { background: var(--green); }
.legend-dot.yellow { background: var(--yellow); }
.legend-dot.red    { background: var(--red); }

#btnBack, #btnAI {
  background: rgba(255,255,255,0.06);
  color: var(--text-secondary);
  border: 1px solid var(--border-color);
  padding: 4px 14px;
  border-radius: 5px;
  font-family: var(--font-body);
  font-size: 11px;
  cursor: pointer;
  transition: all 0.15s;
}

#btnBack:hover {
  background: var(--ntm-primary);
  color: #fff;
  border-color: var(--ntm-primary);
}

#btnAI:hover {
  background: var(--ntm-primary);
  color: #fff;
  border-color: var(--ntm-primary);
}

/* PDF PAGES */
.page-wrapper {
  background: white;
  margin-bottom: 12px;
  border-radius: 4px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.4);
  position: relative;
  overflow: hidden;
}

.page-canvas { display: block; }

.text-layer {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  overflow: hidden; line-height: 1;
}

.text-layer span {
  color: transparent; position: absolute; cursor: text;
}

.text-layer span::selection {
  background: rgba(122,143,181,0.35); color: transparent;
}

.marker-layer {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  overflow: hidden; pointer-events: none;
}

.notam-marker {
  position: absolute;
  font-size: 14px; cursor: pointer;
  z-index: 100; pointer-events: auto;
  filter: drop-shadow(0 1px 3px rgba(0,0,0,0.4));
  transition: transform 0.15s;
}

.notam-marker:hover { transform: scale(1.5); }

/* ===== RIGHT PANEL ===== */
#rightCol {
  width: 320px;
  min-width: 320px;
  flex-shrink: 0;
  position: relative;
  padding: 12px 12px 12px 0;
}

#panel {
  position: relative;
  /* height set dynamically by JS to match left content */
}

/* Panel card */
.panel-card {
  position: absolute;
  left: 0; right: 0;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  overflow: hidden;
  transition: border-color 0.2s;
}

.panel-card:hover {
  border-color: var(--ntm-border-tint);
}

.panel-card-header {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 10px;
  background: var(--bg-tertiary);
  border-bottom: 1px solid var(--border-color);
  font-family: var(--font-heading);
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
}

.panel-card-header .page-num {
  font-family: var(--font-mono);
  font-size: 10px;
  background: var(--bg-primary);
  padding: 1px 6px;
  border-radius: 3px;
  color: var(--text-muted);
}

.panel-card-body {
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

/* Copyable fields */
.copy-field {
  display: flex;
  align-items: center;
  gap: 5px;
}

.copy-field-text {
  flex: 1;
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-primary);
  background: var(--bg-primary);
  padding: 4px 8px;
  border-radius: 4px;
  border: 1px solid var(--border-color);
  cursor: grab;
  user-select: all;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: border-color 0.15s;
}

.copy-field-text:hover { border-color: var(--ntm-primary); }
.copy-field-text:active { cursor: grabbing; }

.copy-btn {
  background: var(--bg-primary);
  color: var(--text-muted);
  border: 1px solid var(--border-color);
  padding: 3px 7px;
  border-radius: 4px;
  font-size: 11px;
  cursor: pointer;
  flex-shrink: 0;
  transition: all 0.15s;
}

.copy-btn:hover {
  background: var(--ntm-primary);
  color: #fff;
  border-color: var(--ntm-primary);
}

/* Translate */
.translate-btn {
  width: 100%;
  background: rgba(122, 143, 181, 0.1);
  color: var(--ntm-light);
  border: 1px solid var(--ntm-border-tint);
  padding: 5px 10px;
  border-radius: 5px;
  font-family: var(--font-body);
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  margin-top: 2px;
}

.translate-btn:hover {
  background: rgba(122, 143, 181, 0.2);
  color: #fff;
}

.translate-btn:disabled { opacity: 0.4; cursor: wait; }

.translation-box {
  font-family: var(--font-body);
  font-size: 11px;
  color: var(--text-primary);
  background: rgba(122, 143, 181, 0.06);
  border: 1px solid var(--ntm-border-tint);
  border-radius: 5px;
  padding: 8px 10px;
  margin-top: 4px;
  line-height: 1.5;
  white-space: pre-wrap;
  user-select: all;
  cursor: text;
}

/* ===== UTILITY ===== */
.hidden { display: none !important; }

/* Lucide icon alignment */
.copy-btn svg, .translate-btn svg, #btnBack svg, #btnAI svg {
  vertical-align: middle;
  display: inline-block;
}

.translate-btn { display: inline-flex; align-items: center; gap: 5px; }
.copy-btn { display: inline-flex; align-items: center; justify-content: center; }
#btnBack, #btnAI { display: inline-flex; align-items: center; gap: 4px; }

.spin { animation: spin 1s linear infinite; }


/* ===== AI ANALYSIS RESULTS ===== */
.ai-result-placeholder {
  margin-top: 4px;
}

.ai-result-box {
  border-radius: 5px;
  overflow: hidden;
  border: 1px solid var(--border-color);
  margin-top: 2px;
}

.ai-result-header {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  font-family: var(--font-heading);
  font-size: 11px;
  font-weight: 600;
}

.ai-result-header.ai-found {
  background: var(--yellow-bg);
  border-bottom: 1px solid var(--yellow-border);
  color: var(--yellow);
}

.ai-result-header.ai-none {
  background: rgba(248, 81, 73, 0.08);
  color: var(--text-muted);
}

.ai-result-header.ai-error {
  background: var(--red-bg);
  border-bottom: 1px solid var(--red-border);
  color: var(--red);
}

.ai-icon {
  font-size: 14px;
  line-height: 1;
}

.ai-x {
  font-size: 14px;
  line-height: 1;
}

.ai-result-body {
  padding: 8px 10px;
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-primary);
  background: var(--bg-primary);
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
}

.ai-marker {
  transition: transform 0.15s;
  user-select: none;
}
.ai-marker:hover {
  transform: scale(1.4);
}

#btnAI:disabled {
  opacity: 0.7;
  cursor: wait;
}
