/* Design Navigator — Shadow DOM Styles */

:host {
  --nav-bg: rgba(10, 10, 15, 0.85);
  --nav-border: rgba(255, 255, 255, 0.08);
  --nav-text: #e4e4e7;
  --nav-text-muted: #71717a;
  --nav-accent: #3b82f6;
  --nav-green: #22c55e;
  --nav-red: #ef4444;
  --nav-width: 220px;
  --nav-collapsed-width: 4px;
  --nav-transition: 280ms cubic-bezier(0.4, 0, 0.2, 1);
  --nav-z-sidebar: 10000;
  --nav-z-iframe: 9999;
  --nav-z-diff: 9998;

  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: var(--nav-z-sidebar);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 13px;
  line-height: 1.4;
  color: var(--nav-text);
  pointer-events: none;
}

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

/* --- Collapsed strip --- */

.nav-strip {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: var(--nav-collapsed-width);
  background: rgba(59, 130, 246, 0.15);
  cursor: pointer;
  pointer-events: auto;
  transition: width var(--nav-transition), background var(--nav-transition);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.nav-strip:hover {
  width: 20px;
  background: rgba(59, 130, 246, 0.3);
}

.nav-strip-arrow {
  opacity: 0;
  transition: opacity var(--nav-transition);
  color: var(--nav-accent);
  font-size: 10px;
  writing-mode: vertical-rl;
  user-select: none;
}

.nav-strip:hover .nav-strip-arrow {
  opacity: 1;
}

:host([expanded]) .nav-strip {
  display: none;
}

/* --- Sidebar panel --- */

.nav-panel {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: var(--nav-width);
  background: var(--nav-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-left: 1px solid var(--nav-border);
  transform: translateX(100%);
  transition: transform var(--nav-transition);
  pointer-events: auto;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

:host([expanded]) .nav-panel {
  transform: translateX(0);
}

/* --- Header --- */

.nav-header {
  padding: 12px 12px 8px;
  border-bottom: 1px solid var(--nav-border);
  flex-shrink: 0;
}

.nav-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.nav-title {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--nav-text-muted);
}

.nav-close-btn {
  background: none;
  border: none;
  color: var(--nav-text-muted);
  cursor: pointer;
  padding: 2px 4px;
  font-size: 14px;
  line-height: 1;
  border-radius: 3px;
  transition: color 150ms, background 150ms;
}

.nav-close-btn:hover {
  color: var(--nav-text);
  background: rgba(255, 255, 255, 0.08);
}

.nav-phase-label {
  font-size: 11px;
  color: var(--nav-text-muted);
  margin-top: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* --- Controls --- */

.nav-controls {
  padding: 8px 12px;
  display: flex;
  gap: 6px;
  border-bottom: 1px solid var(--nav-border);
  flex-shrink: 0;
}

.nav-btn {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--nav-border);
  color: var(--nav-text);
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 11px;
  cursor: pointer;
  transition: background 150ms, border-color 150ms;
  white-space: nowrap;
}

.nav-btn:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.15);
}

.nav-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.nav-btn--active {
  background: rgba(59, 130, 246, 0.2);
  border-color: rgba(59, 130, 246, 0.4);
  color: #93c5fd;
}

.nav-btn--live {
  background: rgba(34, 197, 94, 0.15);
  border-color: rgba(34, 197, 94, 0.3);
  color: var(--nav-green);
}

.nav-btn--live.nav-btn--active {
  background: rgba(34, 197, 94, 0.25);
  border-color: rgba(34, 197, 94, 0.5);
}

/* --- Iteration list --- */

.nav-list {
  flex: 1;
  overflow-y: auto;
  padding: 6px 0;
}

.nav-list::-webkit-scrollbar {
  width: 4px;
}

.nav-list::-webkit-scrollbar-track {
  background: transparent;
}

.nav-list::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.12);
  border-radius: 2px;
}

.nav-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 8px 12px;
  cursor: pointer;
  transition: background 150ms;
  border-left: 2px solid transparent;
}

.nav-item:hover {
  background: rgba(255, 255, 255, 0.04);
}

.nav-item--current {
  border-left-color: var(--nav-accent);
  background: rgba(59, 130, 246, 0.08);
}

.nav-item--viewing {
  border-left-color: #a78bfa;
  background: rgba(167, 139, 250, 0.08);
}

.nav-thumb {
  width: 36px;
  height: 24px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--nav-border);
  object-fit: cover;
  flex-shrink: 0;
}

.nav-thumb--placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 9px;
  color: var(--nav-text-muted);
}

.nav-item-info {
  flex: 1;
  min-width: 0;
}

.nav-item-header {
  display: flex;
  align-items: center;
  gap: 6px;
}

.nav-item-version {
  font-weight: 600;
  font-size: 12px;
}

.nav-badge {
  font-size: 9px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 1px 5px;
  border-radius: 3px;
  line-height: 1.4;
}

.nav-badge--approved {
  background: rgba(34, 197, 94, 0.15);
  color: var(--nav-green);
}

.nav-badge--rejected {
  background: rgba(239, 68, 68, 0.15);
  color: var(--nav-red);
}

.nav-badge--superseded {
  background: rgba(113, 113, 122, 0.2);
  color: var(--nav-text-muted);
}

.nav-badge--current,
.nav-badge--draft {
  background: rgba(59, 130, 246, 0.15);
  color: var(--nav-accent);
}

.nav-item-intent {
  font-size: 11px;
  color: var(--nav-text-muted);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.nav-item-feedback {
  font-size: 10px;
  color: var(--nav-red);
  margin-top: 2px;
  font-style: italic;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* --- History iframe overlay --- */

.nav-iframe-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: var(--nav-z-iframe);
  background: #000;
}

.nav-iframe-overlay iframe {
  width: 100%;
  height: 100%;
  border: none;
}

.nav-iframe-label {
  position: absolute;
  top: 8px;
  left: 8px;
  background: rgba(10, 10, 15, 0.9);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid var(--nav-border);
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 11px;
  color: #a78bfa;
  font-weight: 600;
  z-index: 1;
  pointer-events: none;
}

/* --- Diff overlay --- */

.nav-diff-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: var(--nav-z-diff);
  pointer-events: none;
  mix-blend-mode: multiply;
  opacity: 0.7;
}

.nav-diff-overlay img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: top left;
}

/* --- Empty state --- */

.nav-empty {
  padding: 24px 12px;
  text-align: center;
  color: var(--nav-text-muted);
  font-size: 12px;
}

/* --- Footer --- */

.nav-footer {
  padding: 8px 12px;
  border-top: 1px solid var(--nav-border);
  font-size: 10px;
  color: var(--nav-text-muted);
  text-align: center;
  flex-shrink: 0;
}

.nav-shortcut {
  display: inline-block;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--nav-border);
  border-radius: 3px;
  padding: 0 4px;
  font-family: monospace;
  font-size: 10px;
  margin: 0 2px;
}

/* --- Mobile: bottom sheet --- */

@media (max-width: 767px) {
  :host {
    top: auto;
    left: 0;
    right: 0;
    bottom: 0;
  }

  .nav-strip {
    top: auto;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: var(--nav-collapsed-width);
  }

  .nav-strip:hover {
    width: 100%;
    height: 20px;
  }

  .nav-strip-arrow {
    writing-mode: horizontal-tb;
  }

  .nav-panel {
    width: 100%;
    height: 50vh;
    max-height: 400px;
    top: auto;
    left: 0;
    right: 0;
    bottom: 0;
    border-left: none;
    border-top: 1px solid var(--nav-border);
    border-radius: 12px 12px 0 0;
    transform: translateY(100%);
  }

  :host([expanded]) .nav-panel {
    transform: translateY(0);
  }

  .nav-list {
    max-height: none;
  }
}
