/* ═══════════════════════════════════════════════════════════════
   Norviq — enhance-ui.css
   Premium upgrade for the Enhancement Block
   Drop this AFTER style.css in index.html:
     <link rel="stylesheet" href="enhance-ui.css"/>
   Zero functional changes. Pure visual uplift.
   ═══════════════════════════════════════════════════════════════ */


/* ─────────────────────────────────────────────────────────────
   01. ENHANCEMENT CONTAINER
   Elevated card that seamlessly attaches to the result box.
───────────────────────────────────────────────────────────── */
.nv-enhance-block {
  position:      relative;
  background:    linear-gradient(160deg, var(--s2) 0%, var(--s1) 100%);
  border:        1px solid var(--border-hi);
  border-top:    none;
  border-radius: 0 0 18px 18px;
  padding:       18px 22px 22px;
  overflow:      hidden;

  /* Subtle inner glow at top edge where it meets the result box */
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.03),
    0 8px 32px rgba(0, 0, 0, 0.35),
    0 2px 8px rgba(0, 0, 0, 0.2);

  transition: opacity 180ms var(--ease), transform 180ms var(--ease);
}

/* Decorative noise grain overlay — depth without weight */
.nv-enhance-block::before {
  content:          '';
  position:         absolute;
  inset:            0;
  border-radius:    inherit;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)' opacity='0.035'/%3E%3C/svg%3E");
  pointer-events:   none;
  z-index:          0;
  opacity:          0.6;
}

/* Divider line that replaces the missing top border — a luminous seam */
.nv-enhance-block::after {
  content:    '';
  position:   absolute;
  top:        0;
  left:       5%;
  width:      90%;
  height:     1px;
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(34, 197, 94, 0.18) 30%,
    rgba(34, 197, 94, 0.35) 50%,
    rgba(34, 197, 94, 0.18) 70%,
    transparent 100%
  );
}

/* All direct children above the grain */
.nv-enhance-block > * { position: relative; z-index: 1; }

/* ── Hidden & appear states (unchanged logic, refined animation) */
.nv-enhance-block.hidden { display: none; }

.nv-enhance-block.nv-enhance-appear {
  animation: nv-enhance-slide-in 280ms cubic-bezier(0.22, 1, 0.36, 1) both;
}
@keyframes nv-enhance-slide-in {
  from { opacity: 0; transform: translateY(-8px); }
  to   { opacity: 1; transform: translateY(0); }
}


/* ─────────────────────────────────────────────────────────────
   02. HEADER ROW — Title + Save Button
───────────────────────────────────────────────────────────── */
.nv-enhance-header {
  display:         flex;
  align-items:     center;
  justify-content: space-between;
  margin-bottom:   16px;
  padding-bottom:  14px;
  border-bottom:   1px solid rgba(255, 255, 255, 0.04);
}

/* Section title — "Enhance Prompt" */
.nv-enhance-title {
  display:        flex;
  align-items:    center;
  gap:            7px;
  font-size:      10px;
  font-weight:    700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color:          var(--text-3);

  /* Star icon colour */
  svg { color: var(--accent); opacity: 0.7; }
}

/* ── SAVE BUTTON — promoted to a real clickable component ── */
.nv-save-btn {
  display:        inline-flex;
  align-items:    center;
  gap:            6px;
  padding:        6px 14px;
  height:         30px;

  background:     var(--s3);
  border:         1px solid var(--border-hi);
  border-radius:  30px;

  font-family:    var(--f-ui);
  font-size:      11.5px;
  font-weight:    600;
  color:          var(--text-2);
  cursor:         pointer;
  white-space:    nowrap;

  transition:
    background   160ms var(--ease-std),
    border-color 160ms var(--ease-std),
    color        160ms var(--ease-std),
    box-shadow   160ms var(--ease-std),
    transform     80ms var(--ease-std);
}
.nv-save-btn:hover {
  background:   var(--s4);
  border-color: rgba(34, 197, 94, 0.35);
  color:        var(--text-1);
  box-shadow:   0 0 0 3px rgba(34, 197, 94, 0.08);
}
.nv-save-btn:active { transform: scale(0.97); }

/* Saved state */
.nv-save-btn.saved {
  background:   rgba(34, 197, 94, 0.1);
  border-color: rgba(34, 197, 94, 0.5);
  color:        var(--accent);
  box-shadow:   0 0 0 3px rgba(34, 197, 94, 0.06);
}
.nv-save-btn svg { opacity: 0.7; flex-shrink: 0; }
.nv-save-btn:hover svg,
.nv-save-btn.saved svg { opacity: 1; }


/* ─────────────────────────────────────────────────────────────
   03. SECTION GROUPS
───────────────────────────────────────────────────────────── */
.nv-enhance-group {
  margin-bottom: 14px;
}
.nv-enhance-group:last-of-type { margin-bottom: 0; }

/* Group label — "Adapt for Platform" */
.nv-enhance-group-label {
  display:        flex;
  align-items:    center;
  gap:            6px;
  font-size:      9.5px;
  font-weight:    700;
  letter-spacing: 0.11em;
  text-transform: uppercase;
  color:          var(--text-3);
  margin:         0 0 9px;
}

/* Thin divider between the two sections */
.nv-enhance-group + .nv-enhance-group {
  padding-top:  14px;
  border-top:   1px solid rgba(255, 255, 255, 0.04);
}


/* ─────────────────────────────────────────────────────────────
   04. CHIPS — the most important piece
───────────────────────────────────────────────────────────── */
.nv-enhance-chips {
  display:   flex;
  flex-wrap: wrap;
  gap:       7px;
}

.nv-enhance-chip {
  /* Layout */
  display:     inline-flex;
  align-items: center;
  gap:         6px;
  padding:     6px 14px;
  height:      32px;
  white-space: nowrap;
  cursor:      pointer;

  /* Appearance */
  background:    var(--s3);
  border:        1px solid var(--border-hi);
  border-radius: 30px;

  font-family: var(--f-ui);
  font-size:   12.5px;
  font-weight: 500;
  color:       var(--text-2);

  /* Subtle depth */
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.04),
    0 1px 3px rgba(0, 0, 0, 0.25);

  /* Smooth multi-property transition */
  transition:
    background    160ms var(--ease-std),
    border-color  160ms var(--ease-std),
    color         160ms var(--ease-std),
    box-shadow    160ms var(--ease-std),
    transform      80ms var(--ease-std);

  /* Prevent text selection */
  user-select: none;
  -webkit-user-select: none;
}

/* Hover — green glow moment */
.nv-enhance-chip:hover {
  background:   var(--s4);
  border-color: rgba(34, 197, 94, 0.45);
  color:        var(--text-1);
  transform:    translateY(-2px);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.06),
    0 4px 12px rgba(0, 0, 0, 0.35),
    0 0 0 3px rgba(34, 197, 94, 0.08),
    0 0 16px rgba(34, 197, 94, 0.1);
}

/* Press / active */
.nv-enhance-chip:active {
  transform:  translateY(0) scale(0.98);
  box-shadow:
    inset 0 1px 3px rgba(0, 0, 0, 0.3),
    0 1px 2px rgba(0, 0, 0, 0.3);
}

/* Disabled during enhancement */
.nv-enhance-chip:disabled,
.nv-enhance-chip[disabled] {
  opacity:   0.38;
  cursor:    not-allowed;
  transform: none;
  box-shadow: none;
  pointer-events: none;
}

/* Icon & label subparts */
.nv-enh-icon {
  font-size:    13px;
  line-height:  1;
  flex-shrink:  0;
  transition:   transform 160ms var(--ease-std);
}
.nv-enhance-chip:hover .nv-enh-icon { transform: scale(1.15); }
.nv-enhance-chip:active .nv-enh-icon { transform: scale(1); }

.nv-enh-label {
  line-height: 1;
  font-weight: 500;
}

/* Platform chips get a slightly distinct tint to separate them visually */
#nv-platform-chips .nv-enhance-chip {
  background: linear-gradient(135deg, var(--s2) 0%, var(--s3) 100%);
  font-size:  12px;
}
#nv-platform-chips .nv-enhance-chip:hover {
  background: linear-gradient(135deg, var(--s3) 0%, var(--s4) 100%);
}


/* ─────────────────────────────────────────────────────────────
   05. LOADING OVERLAY — blurred, spinner, polished
───────────────────────────────────────────────────────────── */
.nv-enhance-loading {
  position:         absolute;
  inset:            0;
  background:       rgba(5, 7, 10, 0.72);
  backdrop-filter:  blur(6px) saturate(0.5);
  -webkit-backdrop-filter: blur(6px) saturate(0.5);
  border-radius:    0 0 18px 18px;

  display:          none;   /* shown via .is-enhancing */
  align-items:      center;
  justify-content:  center;
  gap:              10px;

  font-size:        12.5px;
  font-weight:      500;
  letter-spacing:   0.02em;
  color:            var(--text-2);
  z-index:          10;

  /* Fade in */
  animation: nv-loading-fade 180ms var(--ease-std) both;
}
@keyframes nv-loading-fade {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.nv-enhance-block.is-enhancing .nv-enhance-loading { display: flex; }

/* Spinner */
.nv-enhance-spinner {
  width:         18px;
  height:        18px;
  border:        2px solid rgba(34, 197, 94, 0.18);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation:     nv-spin 650ms linear infinite;
  flex-shrink:   0;
}
@keyframes nv-spin {
  to { transform: rotate(360deg); }
}

/* Pulse ring around spinner for extra visual richness */
.nv-enhance-spinner::after {
  content:       '';
  position:      absolute;
  width:         26px;
  height:        26px;
  border-radius: 50%;
  border:        1px solid rgba(34, 197, 94, 0.12);
  animation:     nv-pulse-ring 1.4s ease-out infinite;
}
@keyframes nv-pulse-ring {
  0%   { transform: scale(0.85); opacity: 0.8; }
  70%  { transform: scale(1.2);  opacity: 0; }
  100% { transform: scale(1.2);  opacity: 0; }
}


/* ─────────────────────────────────────────────────────────────
   06. RESULT GLOW — richer, smoother fade-out
───────────────────────────────────────────────────────────── */
@keyframes nv-result-glow {
  0%   {
    box-shadow:
      0 0 0 0   rgba(34, 197, 94, 0.5),
      0 0 20px  rgba(34, 197, 94, 0.15);
  }
  40%  {
    box-shadow:
      0 0 0 4px rgba(34, 197, 94, 0.12),
      0 0 32px  rgba(34, 197, 94, 0.18);
  }
  100% {
    box-shadow:
      0 0 0 0   rgba(34, 197, 94, 0),
      0 0 0     rgba(34, 197, 94, 0);
  }
}
.nv-result-glow {
  animation: nv-result-glow 800ms cubic-bezier(0.16, 1, 0.3, 1) both;
}


/* ─────────────────────────────────────────────────────────────
   07. HISTORY BUTTON (topbar) — kept cohesive with chip style
───────────────────────────────────────────────────────────── */
.nv-history-btn {
  position:    relative;
  display:     inline-flex;
  align-items: center;
  gap:         6px;
  padding:     5px 12px;
  height:      30px;

  background:    var(--s2);
  border:        1px solid var(--border-hi);
  border-radius: 30px;

  font-family: var(--f-ui);
  font-size:   11.5px;
  font-weight: 600;
  color:       var(--text-2);
  cursor:      pointer;
  white-space: nowrap;

  transition:
    background   160ms var(--ease-std),
    border-color 160ms var(--ease-std),
    color        160ms var(--ease-std),
    box-shadow   160ms var(--ease-std);
}
.nv-history-btn:hover {
  background:   var(--s3);
  border-color: rgba(34, 197, 94, 0.3);
  color:        var(--text-1);
  box-shadow:   0 0 0 3px rgba(34, 197, 94, 0.07);
}

.nv-history-badge {
  display:          inline-flex;
  align-items:      center;
  justify-content:  center;
  min-width:        17px;
  height:           17px;
  padding:          0 4px;
  background:       var(--accent);
  border-radius:    10px;
  font-size:        9.5px;
  font-weight:      700;
  color:            #000;
  line-height:      1;
}
.nv-history-badge:empty { display: none; }


/* ─────────────────────────────────────────────────────────────
   08. HISTORY PANEL — polished slide-down drawer
───────────────────────────────────────────────────────────── */
.nv-history-panel {
  position:       fixed;
  top:            calc(var(--topbar-h, 56px) + 8px);
  right:          16px;
  width:          360px;
  max-height:     calc(100dvh - 80px);

  background:     var(--s1);
  border:         1px solid var(--border-hi);
  border-radius:  16px;
  box-shadow:
    0 24px 64px rgba(0, 0, 0, 0.55),
    0 8px  24px rgba(0, 0, 0, 0.3),
    0 0    0 1px rgba(34, 197, 94, 0.06);

  z-index:        9999;
  display:        none;
  flex-direction: column;
  overflow:       hidden;

  transform:      translateY(-10px) scale(0.98);
  opacity:        0;
  transform-origin: top right;
  transition:
    transform 200ms cubic-bezier(0.22, 1, 0.36, 1),
    opacity   180ms var(--ease-std);
}
.nv-history-panel.is-open {
  display:   flex;
  transform: translateY(0) scale(1);
  opacity:   1;
}

.nv-history-panel__header {
  display:         flex;
  align-items:     center;
  justify-content: space-between;
  padding:         14px 16px;
  border-bottom:   1px solid rgba(255, 255, 255, 0.04);
  flex-shrink:     0;
}
.nv-history-panel__title {
  font-family:    var(--f-display);
  font-size:      13.5px;
  font-weight:    700;
  letter-spacing: -0.01em;
  color:          var(--text-1);
}
.nv-history-panel__close {
  width:           28px;
  height:          28px;
  display:         flex;
  align-items:     center;
  justify-content: center;
  background:      var(--s2);
  border:          1px solid var(--border);
  border-radius:   50%;
  cursor:          pointer;
  color:           var(--text-3);
  transition:      background 120ms, color 120ms, border-color 120ms;
}
.nv-history-panel__close:hover {
  background:   var(--s3);
  border-color: var(--border-hi);
  color:        var(--text-1);
}

.nv-history-list {
  overflow-y:     auto;
  flex:           1;
  padding:        10px;
  display:        flex;
  flex-direction: column;
  gap:            7px;
}

.nv-history-empty {
  padding:     32px 24px;
  text-align:  center;
  font-size:   13px;
  color:       var(--text-3);
  line-height: 1.6;
}

.nv-history-item {
  background:    var(--s2);
  border:        1px solid var(--border);
  border-radius: 12px;
  padding:       12px 14px;
  transition:    border-color 150ms, background 150ms;
}
.nv-history-item:hover {
  background:   var(--s3);
  border-color: var(--border-hi);
}
.nv-history-item__meta {
  display:       flex;
  align-items:   center;
  gap:           6px;
  margin-bottom: 7px;
}
.nv-history-item__mode { font-size: 13px; }
.nv-history-item__time {
  font-size:   10px;
  color:       var(--text-3);
  font-family: var(--f-mono);
}
.nv-history-item__text {
  font-size:   12px;
  color:       var(--text-2);
  line-height: 1.6;
  margin:      0 0 10px;
  word-break:  break-word;
}
.nv-history-item__actions {
  display:         flex;
  align-items:     center;
  justify-content: space-between;
}
.nv-history-item__use {
  font-size:     11px;
  font-weight:   600;
  color:         var(--accent);
  background:    transparent;
  border:        1px solid var(--accent-bd);
  border-radius: 20px;
  padding:       4px 12px;
  cursor:        pointer;
  transition:    background 130ms, box-shadow 130ms;
}
.nv-history-item__use:hover {
  background:  var(--accent-dim);
  box-shadow:  0 0 0 3px rgba(34, 197, 94, 0.07);
}
.nv-history-item__del {
  width:           26px;
  height:          26px;
  display:         flex;
  align-items:     center;
  justify-content: center;
  background:      transparent;
  border:          none;
  border-radius:   8px;
  cursor:          pointer;
  color:           var(--text-3);
  transition:      color 120ms, background 120ms;
}
.nv-history-item__del:hover {
  color:      var(--red, #f03e5a);
  background: rgba(240, 62, 90, 0.1);
}


/* ─────────────────────────────────────────────────────────────
   09. OFFLINE BADGE — amber, cohesive
───────────────────────────────────────────────────────────── */
.offline-badge {
  display:       flex !important;
  align-items:   center;
  gap:           9px;
  padding:       10px 14px;
  background:    rgba(245, 158, 11, 0.07);
  border:        1px solid rgba(245, 158, 11, 0.22);
  border-radius: 12px;
  margin-bottom: 12px;
  font-size:     12px;
  color:         #fbbf24;
  flex-wrap:     wrap;
  box-shadow:    inset 0 1px 0 rgba(255, 255, 255, 0.03);
}
.offline-badge svg { flex-shrink: 0; color: #fbbf24; }
.offline-badge #offlineText { flex: 1; }

.nv-offline-retry {
  margin-left:  auto;
  padding:      4px 11px;
  background:   rgba(245, 158, 11, 0.12);
  border:       1px solid rgba(245, 158, 11, 0.28);
  border-radius: 20px;
  font-size:    11px;
  font-weight:  600;
  color:        #fbbf24;
  cursor:       pointer;
  white-space:  nowrap;
  transition:   background 130ms, box-shadow 130ms;
}
.nv-offline-retry:hover {
  background:  rgba(245, 158, 11, 0.22);
  box-shadow:  0 0 0 3px rgba(245, 158, 11, 0.07);
}


/* ─────────────────────────────────────────────────────────────
   10. LIGHT MODE ADJUSTMENTS
───────────────────────────────────────────────────────────── */
body.light .nv-enhance-block {
  background:  linear-gradient(160deg, var(--s2) 0%, var(--s1) 100%);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.8),
    0 4px 16px rgba(0, 0, 0, 0.08),
    0 1px 4px  rgba(0, 0, 0, 0.05);
}
body.light .nv-enhance-block::before { display: none; }
body.light .nv-enhance-loading {
  background:          rgba(242, 244, 247, 0.80);
  backdrop-filter:     blur(6px);
  -webkit-backdrop-filter: blur(6px);
}
body.light .nv-enhance-chip {
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.9),
    0 1px 3px rgba(0, 0, 0, 0.08);
}
body.light .nv-enhance-chip:hover {
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.9),
    0 4px 12px rgba(0, 0, 0, 0.12),
    0 0 0 3px rgba(34, 197, 94, 0.1);
}
body.light .nv-history-panel {
  box-shadow:
    0 16px 48px rgba(0, 0, 0, 0.14),
    0 4px  12px rgba(0, 0, 0, 0.08),
    0 0    0 1px rgba(34, 197, 94, 0.08);
}


/* ─────────────────────────────────────────────────────────────
   11. RESPONSIVE — mobile-first wrapping
───────────────────────────────────────────────────────────── */
@media (max-width: 600px) {
  .nv-enhance-block {
    padding: 14px 16px 18px;
  }

  .nv-enhance-chips { gap: 6px; }

  .nv-enhance-chip {
    padding: 5px 11px;
    height:  30px;
    font-size: 12px;
  }

  .nv-save-btn {
    padding: 5px 11px;
    font-size: 11px;
  }
}

@media (max-width: 480px) {
  .nv-history-panel {
    right:  8px;
    left:   8px;
    width:  auto;
    border-radius: 14px;
  }

  /* On tiny screens, hide history button label — icon + badge only */
  .nv-history-btn #nv-history-btn-label { display: none; }

  .nv-enhance-header {
    flex-wrap: wrap;
    gap: 8px;
  }
}


/* ─────────────────────────────────────────────────────────────
   12. RESULT BOX — flat bottom when enhance block is visible
───────────────────────────────────────────────────────────── */
.output-panel {
  border-radius: 16px 16px 0 0;
}
.output-panel + .nv-enhance-block.hidden {
  display: none;
}
.output-panel:has(+ .nv-enhance-block:not(.hidden)) {
  border-radius: 16px 16px 0 0;
  border-bottom-color: rgba(34, 197, 94, 0.1);
}