/* ═══════════════════════════════════════════════════════
   Diagnomap — Premium Light Theme
   ═══════════════════════════════════════════════════════ */

/* ── Reset & Base ──────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg-primary:    #f8f9fb;
  --bg-secondary:  #ffffff;
  --bg-card:       #ffffff;
  --bg-elevated:   #f0f1f5;
  --bg-hover:      #ecedf2;
  --border:        rgba(0,0,0,0.06);
  --border-strong: rgba(0,0,0,0.12);
  --text-primary:  #1a1a2e;
  --text-secondary:#5a5a72;
  --text-muted:    #8e8ea0;
  --accent:        #6366f1;
  --accent-light:  #818cf8;
  --accent-glow:   rgba(99,102,241,0.12);
  --accent-solid:  rgba(99,102,241,0.08);
  --success:       #16a34a;
  --warning:       #d97706;
  --error:         #dc2626;
  --hotspot:       rgba(99,102,241,0.18);
  --hotspot-hover: rgba(99,102,241,0.35);
  --hotspot-active:rgba(99,102,241,0.5);
  --radius-sm:     6px;
  --radius-md:     10px;
  --radius-lg:     16px;
  --radius-xl:     24px;
  --shadow-sm:     0 1px 3px rgba(0,0,0,0.06);
  --shadow-md:     0 4px 12px rgba(0,0,0,0.08);
  --shadow-lg:     0 8px 30px rgba(0,0,0,0.1);
  --shadow-card:   0 1px 3px rgba(0,0,0,0.04), 0 6px 16px rgba(0,0,0,0.06);
  --transition:    200ms cubic-bezier(0.4, 0, 0.2, 1);
  --font:          'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

html { font-size: 15px; }
body {
  font-family: var(--font);
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

/* ── Scrollbar ─────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.12); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(0,0,0,0.2); }

/* ── Utilities ─────────────────────────────────────── */
.screen-hidden { display: none !important; }

/* ── Header ────────────────────────────────────────── */
#app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  height: 56px;
  background: rgba(255,255,255,0.88);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}

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

.logo-icon {
  width: 36px; height: 36px;
  display: grid; place-items: center;
  background: linear-gradient(135deg, var(--accent), #a78bfa);
  border-radius: var(--radius-sm);
  color: white;
}

.header-brand h1 {
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-primary);
}

.header-tag {
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--accent);
  background: var(--accent-glow);
  padding: 2px 8px;
  border-radius: 99px;
}

.header-actions { display: flex; gap: 8px; }

/* ── Buttons ───────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border: none;
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border-strong);
}
.btn-ghost:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
  border-color: rgba(0,0,0,0.2);
}

.btn-accent {
  background: linear-gradient(135deg, var(--accent), #7c3aed);
  color: white;
  box-shadow: 0 2px 8px var(--accent-glow);
}
.btn-accent:hover {
  box-shadow: 0 4px 16px rgba(99,102,241,0.25);
  transform: translateY(-1px);
}

.btn-tool {
  width: 32px; height: 32px;
  display: grid; place-items: center;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition);
}
.btn-tool:hover { background: var(--bg-hover); color: var(--text-primary); }
.btn-tool.active { background: var(--accent-glow); color: var(--accent); border-color: var(--accent); }

.tool-divider { width: 1px; height: 20px; background: var(--border-strong); margin: 0 4px; }

/* ── Upload / Landing Screen ───────────────────────── */
#upload-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0 24px 60px;
}

/* Hero */
.hero {
  text-align: center;
  max-width: 680px;
  padding: 64px 0 40px;
  animation: fadeInUp 0.6s ease-out;
}
.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--accent);
  background: var(--accent-glow);
  border: 1px solid rgba(99,102,241,0.15);
  border-radius: 99px;
  margin-bottom: 24px;
}
.hero h2 {
  font-size: 2.6rem;
  font-weight: 900;
  letter-spacing: -0.035em;
  line-height: 1.15;
  margin-bottom: 20px;
  color: var(--text-primary);
}
.hero-highlight {
  background: linear-gradient(135deg, var(--accent), #a855f7, #ec4899);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.hero-sub {
  color: var(--text-secondary);
  font-size: 1.1rem;
  line-height: 1.75;
  max-width: 540px;
  margin: 0 auto;
}

/* Drop Zone */
.drop-zone {
  width: 100%;
  max-width: 600px;
  border: 2px dashed rgba(0,0,0,0.15);
  border-radius: var(--radius-xl);
  padding: 56px 40px;
  text-align: center;
  cursor: pointer;
  transition: all 0.3s ease;
  background: var(--bg-card);
  box-shadow: var(--shadow-card);
  position: relative;
  overflow: hidden;
  animation: fadeInUp 0.6s ease-out 0.1s both;
  margin-bottom: 72px;
}
.drop-zone::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: radial-gradient(600px circle at var(--mouse-x, 50%) var(--mouse-y, 50%), var(--accent-glow), transparent 50%);
  opacity: 0;
  transition: opacity 0.4s ease;
  pointer-events: none;
}
.drop-zone:hover::before, .drop-zone.drag-over::before { opacity: 1; }
.drop-zone:hover, .drop-zone:focus-visible {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-glow), var(--shadow-card);
}
.drop-zone.drag-over {
  border-color: var(--accent-light);
  background: rgba(99,102,241,0.04);
  transform: scale(1.02);
}

.drop-zone-inner { position: relative; z-index: 1; }
.drop-icon {
  margin-bottom: 16px;
  color: var(--accent);
  animation: floatUp 3s ease-in-out infinite;
}
.drop-label { font-size: 1.1rem; font-weight: 600; color: var(--text-primary); margin-bottom: 4px; }
.drop-sub { color: var(--text-secondary); font-size: 0.9rem; margin-bottom: 16px; }
.drop-browse { color: var(--accent); text-decoration: underline; cursor: pointer; font-weight: 500; }
.drop-browse:hover { color: var(--accent-light); }
.drop-hint { color: var(--text-muted); font-size: 0.75rem; }

/* How It Works */
.how-it-works {
  width: 100%;
  max-width: 900px;
  text-align: center;
  margin-bottom: 64px;
  animation: fadeInUp 0.6s ease-out 0.2s both;
}
.how-it-works h3 {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  margin-bottom: 28px;
}
.steps-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 20px;
}
.step-card {
  position: relative;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 32px 20px 28px;
  text-align: center;
  transition: all 0.25s ease;
  box-shadow: var(--shadow-sm);
}
.step-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-3px);
  border-color: var(--border-strong);
}
.step-number {
  position: absolute;
  top: -12px;
  left: 50%;
  transform: translateX(-50%);
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, var(--accent), #7c3aed);
  color: white;
  font-size: 0.7rem;
  font-weight: 800;
  border-radius: 50%;
  box-shadow: 0 2px 8px var(--accent-glow);
}
.step-icon {
  color: var(--accent);
  margin-bottom: 14px;
}
.step-card h4 {
  font-size: 0.95rem;
  font-weight: 700;
  margin-bottom: 8px;
  color: var(--text-primary);
}
.step-card p {
  font-size: 0.82rem;
  color: var(--text-secondary);
  line-height: 1.6;
}

/* Use Cases */
.use-cases {
  width: 100%;
  max-width: 900px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-bottom: 48px;
  animation: fadeInUp 0.6s ease-out 0.3s both;
}
.use-case-card {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 20px;
  transition: all 0.25s ease;
  box-shadow: var(--shadow-sm);
}
.use-case-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}
.use-case-card svg {
  color: var(--accent);
  flex-shrink: 0;
  margin-top: 2px;
}
.use-case-card strong {
  font-size: 0.9rem;
  font-weight: 700;
  display: block;
  margin-bottom: 4px;
  color: var(--text-primary);
}
.use-case-card p {
  font-size: 0.8rem;
  color: var(--text-secondary);
  line-height: 1.55;
}

/* Footer */
.landing-footer {
  text-align: center;
  padding: 24px 0;
  border-top: 1px solid var(--border);
  width: 100%;
  max-width: 900px;
}
.landing-footer p {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* ── Processing Screen ─────────────────────────────── */
#processing-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: calc(100vh - 56px);
  padding: 40px 24px;
}

.processing-card {
  text-align: center;
  max-width: 400px;
  animation: fadeInUp 0.5s ease-out;
}
.processing-card h3 { font-size: 1.3rem; font-weight: 700; margin: 24px 0 8px; color: var(--text-primary); }
.processing-card p { color: var(--text-secondary); margin-bottom: 28px; }

.spinner {
  width: 48px; height: 48px;
  margin: 0 auto;
  border: 3px solid var(--bg-elevated);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.progress-bar {
  width: 100%;
  height: 4px;
  background: var(--bg-elevated);
  border-radius: 2px;
  overflow: hidden;
}
.progress-bar-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent), var(--accent-light));
  border-radius: 2px;
  transition: width 0.4s ease;
}

/* ── Results Screen ────────────────────────────────── */
#results-screen {
  height: calc(100vh - 56px);
  overflow: hidden;
}

.results-layout {
  display: flex;
  height: 100%;
}

/* ── Viewer Panel ──────────────────────────────────── */
.viewer-panel {
  flex: 3;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border);
  min-width: 0;
}

.viewer-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-secondary);
}
.viewer-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-secondary);
}
.viewer-tools { display: flex; align-items: center; gap: 4px; }

.viewer-container {
  flex: 1;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: #e8e9ed;
  position: relative;
}

.diagram-title {
  width: 100%;
  padding: 12px 20px;
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
  color: #1a1a2e;
  background: rgba(255,255,255,0.9);
  border-bottom: 1px solid rgba(0,0,0,0.08);
  border-left: 3px solid #6366f1;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  flex-shrink: 0;
  z-index: 2;
}

.viewer-canvas {
  position: relative;
  display: inline-block;
  transform-origin: center center;
  transition: transform 0.2s ease;
}

#diagram-image {
  display: block;
  max-width: 100%;
  max-height: calc(100vh - 104px);
  object-fit: contain;
  user-select: none;
  -webkit-user-drag: none;
  box-shadow: var(--shadow-lg);
}

/* ── Hotspot Layer ─────────────────────────────────── */
.hotspot-layer {
  position: absolute;
  top: 0; left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.hotspot {
  position: absolute;
  border: 2px solid var(--accent);
  background: var(--hotspot);
  border-radius: 3px;
  cursor: pointer;
  pointer-events: all;
  transition: all 0.2s ease;
  z-index: 1;
}
.hotspot:hover {
  background: var(--hotspot-hover);
  border-color: var(--accent);
  box-shadow: 0 0 12px var(--accent-glow);
  z-index: 10;
}
.hotspot.hotspot-active {
  background: var(--hotspot-active);
  border-color: var(--accent);
  box-shadow: 0 0 20px rgba(99,102,241,0.25), 0 0 40px rgba(99,102,241,0.1);
  z-index: 10;
  animation: hotspotPulse 1.5s ease-in-out infinite;
}

.hotspot-tooltip {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%) scale(0.9);
  background: var(--text-primary);
  color: #fff;
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  font-weight: 600;
  white-space: nowrap;
  box-shadow: var(--shadow-md);
  opacity: 0;
  pointer-events: none;
  transition: all 0.15s ease;
}
.hotspot:hover .hotspot-tooltip,
.hotspot.hotspot-active .hotspot-tooltip {
  opacity: 1;
  transform: translateX(-50%) scale(1);
}

.hotspot-label {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 0.6rem;
  font-weight: 700;
  color: var(--accent);
  pointer-events: none;
}

/* ── Table Panel ───────────────────────────────────── */
.table-panel {
  flex: 2;
  display: flex;
  flex-direction: column;
  min-width: 300px;
  background: var(--bg-secondary);
}

.table-header {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}
.table-header h3 {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.95rem;
  font-weight: 600;
  margin-bottom: 10px;
  color: var(--text-primary);
}
.part-count {
  font-size: 0.7rem;
  font-weight: 600;
  background: var(--accent-glow);
  color: var(--accent);
  padding: 1px 8px;
  border-radius: 99px;
}

.search-input {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--bg-primary);
  color: var(--text-primary);
  font-family: var(--font);
  font-size: 0.85rem;
  outline: none;
  transition: all var(--transition);
}
.search-input::placeholder { color: var(--text-muted); }
.search-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-glow); }

.table-scroll {
  flex: 1;
  overflow-y: auto;
}

#parts-table {
  width: 100%;
  border-collapse: collapse;
}
#parts-table thead { position: sticky; top: 0; z-index: 5; }
#parts-table th {
  padding: 10px 12px;
  text-align: left;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border-strong);
  white-space: nowrap;
}
.th-sortable { cursor: pointer; user-select: none; }
.th-sortable:hover { color: var(--text-primary); }
.th-sortable.active { color: var(--accent); }

#parts-table td {
  padding: 10px 12px;
  font-size: 0.85rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
#parts-table tbody tr {
  cursor: pointer;
  transition: all var(--transition);
}
#parts-table tbody tr:hover { background: var(--bg-hover); }
#parts-table tbody tr.row-active {
  background: rgba(99,102,241,0.08);
  border-left: 3px solid var(--accent);
}

.label-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 28px;
  padding: 2px 8px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--text-primary);
}

.pos-text { color: var(--text-muted); font-size: 0.75rem; font-variant-numeric: tabular-nums; }

.btn-delete {
  width: 28px; height: 28px;
  display: grid; place-items: center;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--transition);
}
.btn-delete:hover {
  background: rgba(220,38,38,0.06);
  color: var(--error);
  border-color: rgba(220,38,38,0.2);
}

/* ── Toast ─────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(0);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 20px;
  background: var(--bg-card);
  border: 1px solid rgba(220,38,38,0.2);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  z-index: 200;
  animation: slideUp 0.3s ease-out;
}
.toast-hidden { display: none !important; }
.toast-icon { color: var(--error); display: grid; place-items: center; }
.toast-close {
  background: none; border: none; color: var(--text-muted);
  font-size: 1.2rem; cursor: pointer; margin-left: 8px;
}

/* ── Animations ────────────────────────────────────── */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes floatUp {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-8px); }
}
@keyframes spin {
  to { transform: rotate(360deg); }
}
@keyframes hotspotPulse {
  0%, 100% { box-shadow: 0 0 20px rgba(99,102,241,0.2), 0 0 40px rgba(99,102,241,0.08); }
  50%      { box-shadow: 0 0 30px rgba(99,102,241,0.3), 0 0 60px rgba(99,102,241,0.15); }
}
@keyframes slideUp {
  from { opacity: 0; transform: translateX(-50%) translateY(20px); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* ── Responsive ────────────────────────────────────── */
@media (max-width: 860px) {
  .results-layout { flex-direction: column; }
  .viewer-panel { border-right: none; border-bottom: 1px solid var(--border); flex: 1; min-height: 300px; }
  .table-panel { min-width: unset; flex: 1; }
  #diagram-image { max-height: 40vh; }
  .steps-grid { grid-template-columns: repeat(2, 1fr); }
  .use-cases { grid-template-columns: 1fr; }
  .hero h2 { font-size: 2rem; }
}

@media (max-width: 500px) {
  .hero h2 { font-size: 1.6rem; }
  .hero { padding: 40px 0 28px; }
  .drop-zone { padding: 36px 20px; margin-bottom: 48px; }
  .steps-grid { grid-template-columns: 1fr; }
  .header-brand h1 { font-size: 1rem; }
}

/* ── Access Overlay ───────────────────────────────── */
.access-overlay {
  position: fixed;
  inset: 0;
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  animation: fadeIn 0.3s ease-out;
}

.access-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 48px 40px;
  max-width: 420px;
  width: 90%;
  text-align: center;
  box-shadow: var(--shadow-lg);
  animation: fadeInUp 0.4s ease-out;
}

.access-icon {
  color: var(--accent);
  margin-bottom: 12px;
}

.access-card h3 {
  font-size: 1.3rem;
  font-weight: 700;
  margin-bottom: 10px;
  color: var(--text-primary);
}

.access-card p {
  font-size: 0.9rem;
  color: var(--text-secondary);
  line-height: 1.6;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}
