/* InlineEditor — real-time writing suggestions styles */

/* ── SVG wavy underline data URI ──────────────────────────────────── */

/* Red wavy underline — grammar errors */
.ie-error {
  background-color: transparent;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='8' height='4'%3E%3Cpath d='M0 3 Q2 0 4 3 Q6 6 8 3' stroke='%23ef4444' fill='none' stroke-width='1'/%3E%3C/svg%3E");
  background-repeat: repeat-x;
  background-position: bottom;
  background-size: 8px 4px;
  padding-bottom: 2px;
  color: inherit;
}

/* Blue dotted underline — style suggestions */
.ie-style {
  background-color: transparent;
  border-bottom: 2px dotted #3b82f6;
  padding-bottom: 1px;
  color: inherit;
}

/* Yellow dashed underline — weak writing (hedge words, nominalizations) */
.ie-weak {
  background-color: transparent;
  border-bottom: 2px dashed #f59e0b;
  padding-bottom: 1px;
  color: inherit;
}

/* Purple dotted underline — passive voice */
.ie-passive {
  background-color: transparent;
  border-bottom: 2px dotted #a855f7;
  padding-bottom: 1px;
  color: inherit;
}

/* Gray dotted underline — academic */
.ie-academic {
  background-color: transparent;
  border-bottom: 2px dotted #6b7280;
  padding-bottom: 1px;
  color: inherit;
}

/* ── Mark animation: fade in ──────────────────────────────────────── */

.ie-mark-animated {
  animation: ieMarkFadeIn 0.3s ease-out;
}

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

/* Highlight flash when scrolling to an issue */
.ie-highlight-flash {
  animation: ieHighlightFlash 1.2s ease;
}

@keyframes ieHighlightFlash {
  0%   { background-color: rgba(59, 130, 246, 0.25); }
  50%  { background-color: rgba(59, 130, 246, 0.15); }
  100% { background-color: transparent; }
}

/* Accept flash — brief green glow */
.ie-accept-flash {
  animation: ieAcceptFlash 0.4s ease;
}

@keyframes ieAcceptFlash {
  0%   { background-color: rgba(34, 197, 94, 0.3); }
  100% { background-color: rgba(34, 197, 94, 0); }
}

/* Mark hover highlight */
mark[data-ie-id]:hover,
.ie-mark:hover {
  background-color: rgba(255, 255, 255, 0.08);
  cursor: pointer;
}

/* ── Textarea overlay wrapper ─────────────────────────────────────── */

.ie-textarea-wrapper {
  position: relative;
  display: block;
  width: 100%;
}

.ie-textarea-wrapper textarea {
  position: relative;
  z-index: 2;
  background: transparent;
}

.ie-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  overflow: hidden;
  white-space: pre-wrap;
  word-wrap: break-word;
  color: transparent;
  z-index: 1;
}

.ie-overlay .ie-mark {
  pointer-events: auto;
  cursor: pointer;
}

/* ── Tooltip ──────────────────────────────────────────────────────── */

.ie-tooltip {
  position: absolute;
  z-index: var(--z-tooltip);
  background: var(--color-bg-card, #1a2233);
  border: 1px solid var(--color-border, #2a3a52);
  border-radius: var(--radius-md, 10px);
  box-shadow: var(--shadow-lg, 0 8px 30px rgba(0,0,0,0.5));
  padding: 12px 16px;
  font-size: 0.8125rem;
  line-height: 1.5;
  color: var(--color-text, #e2e8f0);
  max-width: 360px;
  min-width: 240px;
  animation: ieTooltipSlideUp 0.2s ease;
}

/* Tooltip arrow pointer */
.ie-tooltip::before {
  content: '';
  position: absolute;
  top: -6px;
  left: 20px;
  width: 12px;
  height: 12px;
  background: var(--color-bg-card, #1a2233);
  border-left: 1px solid var(--color-border, #2a3a52);
  border-top: 1px solid var(--color-border, #2a3a52);
  transform: rotate(45deg);
}

@keyframes ieTooltipSlideUp {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.ie-tooltip-header {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 6px;
}

.ie-tooltip-cat-icon {
  font-size: 0.875rem;
  line-height: 1;
}

.ie-tooltip-type {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.ie-tooltip-type-grammar {
  background: rgba(239, 68, 68, 0.15);
  color: #ef4444;
}

.ie-tooltip-type-style {
  background: rgba(59, 130, 246, 0.15);
  color: #3b82f6;
}

.ie-tooltip-type-weak {
  background: rgba(245, 158, 11, 0.15);
  color: #f59e0b;
}

.ie-tooltip-type-passive {
  background: rgba(168, 85, 247, 0.15);
  color: #a855f7;
}

.ie-tooltip-type-academic {
  background: rgba(107, 114, 128, 0.15);
  color: #6b7280;
}

.ie-tooltip-message {
  margin-bottom: 8px;
  color: var(--color-text-muted, #8896ab);
}

.ie-tooltip-suggestion {
  margin-bottom: 10px;
  padding: 6px 10px;
  background: rgba(59, 130, 246, 0.08);
  border-radius: 6px;
  font-size: 0.8125rem;
}

.ie-tooltip-suggestion-label {
  color: var(--color-text-dim, #5a6a80);
  font-weight: 500;
}

.ie-tooltip-suggestion-text {
  color: var(--color-accent, #06d6a0);
  font-weight: 500;
}

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

/* Learn more section in tooltip */
.ie-tooltip-learn-more {
  margin-top: 8px;
  border-top: 1px solid var(--color-border, #2a3a52);
  padding-top: 8px;
}

.ie-tooltip-learn-more summary {
  cursor: pointer;
  color: var(--color-primary, #3b82f6);
  font-size: 0.75rem;
  font-weight: 500;
}

.ie-tooltip-learn-more summary:hover {
  text-decoration: underline;
}

.ie-tooltip-learn-more p {
  margin: 6px 0 0;
  font-size: 0.75rem;
  color: var(--color-text-muted, #8896ab);
  line-height: 1.5;
}

/* ── Tooltip action buttons ───────────────────────────────────────── */

.ie-accept-btn,
.ie-dismiss-btn {
  padding: 4px 12px;
  border: none;
  border-radius: var(--radius-sm, 6px);
  font-family: var(--font-sans, 'Inter', sans-serif);
  font-size: 0.75rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
}

.ie-accept-btn {
  background: var(--color-primary, #3b82f6);
  color: #fff;
}

.ie-accept-btn:hover {
  background: var(--color-primary-hover, #2563eb);
  transform: translateY(-1px);
}

.ie-dismiss-btn {
  background: transparent;
  color: var(--color-text-muted, #8896ab);
  border: 1px solid var(--color-border, #2a3a52);
}

.ie-dismiss-btn:hover {
  background: var(--color-bg-hover, #1f2d42);
  color: var(--color-text, #e2e8f0);
}

/* ── Issue count badge ────────────────────────────────────────────── */

.ie-issue-count {
  position: absolute;
  top: -8px;
  right: -8px;
  display: flex;
  gap: 4px;
  z-index: 5;
  font-size: 0.6875rem;
  font-weight: 600;
}

.ie-badge-item {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 5px;
  border-radius: 10px;
  color: #fff;
}

.ie-badge-grammar {
  background: #ef4444;
}

.ie-badge-style {
  background: #3b82f6;
}

.ie-badge-weak {
  background: #f59e0b;
  color: #000;
}

/* ── Performance Score Badge (circular, CSS-only) ──────────────────── */

.ie-score-badge {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  cursor: pointer;
  background: conic-gradient(
    var(--ie-score-color, #22c55e) var(--ie-score-deg, 360deg),
    rgba(255, 255, 255, 0.1) var(--ie-score-deg, 360deg)
  );
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.ie-score-badge:hover {
  transform: scale(1.1);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
}

.ie-score-badge::after {
  content: '';
  position: absolute;
  inset: 4px;
  border-radius: 50%;
  background: var(--color-bg-card, #1a2233);
}

.ie-score-number {
  position: relative;
  z-index: 1;
  font-size: 0.75rem;
  font-weight: 700;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

/* ── Language Detection Badge ──────────────────────────────────────── */

.ie-lang-badge {
  position: absolute;
  bottom: 8px;
  right: 80px;
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 600;
  line-height: 1.4;
  z-index: 10;
  pointer-events: none;
  opacity: 0.85;
  background: rgba(59, 130, 246, 0.12);
  color: #3b82f6;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  animation: ieMarkFadeIn 0.3s ease-out;
}

/* ── Issue Sidebar Panel ──────────────────────────────────────────── */

.ie-sidebar {
  position: fixed;
  top: 0;
  right: 0;
  width: 320px;
  height: 100vh;
  background: var(--color-bg-card, #1a2233);
  border-left: 1px solid var(--color-border, #2a3a52);
  box-shadow: -4px 0 24px rgba(0, 0, 0, 0.3);
  z-index: var(--z-popover);
  overflow-y: auto;
  font-family: var(--font-sans, 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif);
  color: var(--color-text, #e2e8f0);
  transform: translateX(100%);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.ie-sidebar-open {
  transform: translateX(0);
}

.ie-sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 16px 12px;
  border-bottom: 1px solid var(--color-border, #2a3a52);
  position: sticky;
  top: 0;
  background: var(--color-bg-card, #1a2233);
  z-index: 2;
}

.ie-sidebar-title {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
}

.ie-sidebar-total {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  margin-left: 6px;
  border-radius: 11px;
  background: var(--color-primary, #3b82f6);
  color: #fff;
  font-size: 0.6875rem;
  font-weight: 700;
}

.ie-sidebar-close {
  background: none;
  border: none;
  color: var(--color-text-muted, #8896ab);
  font-size: 1.25rem;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 4px;
  line-height: 1;
  transition: all 0.15s ease;
}

.ie-sidebar-close:hover {
  background: var(--color-bg-hover, #1f2d42);
  color: var(--color-text, #e2e8f0);
}

/* Category chip bar */
.ie-sidebar-categories {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--color-border, #2a3a52);
}

.ie-sidebar-cat-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.06);
  font-size: 0.6875rem;
  font-weight: 500;
  cursor: default;
}

.ie-sidebar-cat-icon {
  font-size: 0.75rem;
  line-height: 1;
}

.ie-sidebar-cat-label {
  color: var(--color-text-muted, #8896ab);
}

.ie-sidebar-cat-count {
  font-weight: 700;
  color: var(--color-text, #e2e8f0);
}

/* Group within sidebar */
.ie-sidebar-group {
  border-bottom: 1px solid var(--color-border, #2a3a52);
}

.ie-sidebar-group-header {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 16px;
  background: rgba(255, 255, 255, 0.02);
}

.ie-sidebar-group-icon {
  font-size: 0.875rem;
  line-height: 1;
}

.ie-sidebar-group-label {
  flex: 1;
  font-size: 0.8125rem;
  font-weight: 600;
}

.ie-sidebar-group-actions {
  display: flex;
  gap: 4px;
}

.ie-sidebar-accept-all,
.ie-sidebar-dismiss-all {
  padding: 2px 8px;
  border: 1px solid var(--color-border, #2a3a52);
  border-radius: 4px;
  background: transparent;
  color: var(--color-text-muted, #8896ab);
  font-size: 0.625rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
}

.ie-sidebar-accept-all:hover {
  background: var(--color-primary, #3b82f6);
  color: #fff;
  border-color: var(--color-primary, #3b82f6);
}

.ie-sidebar-dismiss-all:hover {
  background: var(--color-bg-hover, #1f2d42);
  color: var(--color-text, #e2e8f0);
}

/* Individual issue row */
.ie-sidebar-issue {
  padding: 10px 16px;
  cursor: pointer;
  transition: background 0.15s ease;
  border-top: 1px solid rgba(255, 255, 255, 0.03);
}

.ie-sidebar-issue:hover {
  background: rgba(255, 255, 255, 0.04);
}

.ie-sidebar-issue:focus {
  outline: 2px solid var(--color-primary, #3b82f6);
  outline-offset: -2px;
}

.ie-sidebar-issue-excerpt {
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--color-text, #e2e8f0);
  margin-bottom: 2px;
}

.ie-sidebar-issue-message {
  font-size: 0.75rem;
  color: var(--color-text-muted, #8896ab);
  margin-bottom: 4px;
  line-height: 1.4;
}

.ie-sidebar-issue-suggestion {
  font-size: 0.75rem;
  color: var(--color-accent, #06d6a0);
  margin-bottom: 6px;
}

.ie-sidebar-sug-arrow {
  color: var(--color-text-dim, #5a6a80);
}

.ie-sidebar-issue-actions {
  display: flex;
  gap: 6px;
}

.ie-sidebar-accept,
.ie-sidebar-dismiss {
  padding: 2px 10px;
  font-size: 0.6875rem;
}

.ie-sidebar-empty {
  padding: 40px 16px;
  text-align: center;
  color: var(--color-text-muted, #8896ab);
  font-size: 0.875rem;
}

/* ── Light theme overrides ────────────────────────────────────────── */

[data-theme="light"] .ie-tooltip {
  background: #ffffff;
  border-color: #e2e8f0;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.12);
}

[data-theme="light"] .ie-tooltip::before {
  background: #ffffff;
  border-color: #e2e8f0;
}

[data-theme="light"] .ie-tooltip-suggestion {
  background: rgba(37, 99, 235, 0.06);
}

[data-theme="light"] mark[data-ie-id]:hover,
[data-theme="light"] .ie-mark:hover {
  background-color: rgba(0, 0, 0, 0.04);
}

[data-theme="light"] .ie-sidebar {
  background: #ffffff;
  border-left-color: #e2e8f0;
  box-shadow: -4px 0 24px rgba(0, 0, 0, 0.08);
}

[data-theme="light"] .ie-sidebar-header {
  background: #ffffff;
  border-bottom-color: #e2e8f0;
}

[data-theme="light"] .ie-sidebar-cat-chip {
  background: rgba(0, 0, 0, 0.04);
}

[data-theme="light"] .ie-sidebar-group {
  border-bottom-color: #e2e8f0;
}

[data-theme="light"] .ie-sidebar-group-header {
  background: rgba(0, 0, 0, 0.02);
}

[data-theme="light"] .ie-sidebar-issue:hover {
  background: rgba(0, 0, 0, 0.03);
}

[data-theme="light"] .ie-score-badge::after {
  background: #ffffff;
}

/* ── Mobile responsive: sidebar becomes bottom sheet ──────────────── */

@media (max-width: 768px) {
  .ie-sidebar {
    width: 100%;
    height: 50vh;
    top: auto;
    bottom: 0;
    right: 0;
    border-left: none;
    border-top: 1px solid var(--color-border, #2a3a52);
    border-radius: 16px 16px 0 0;
    box-shadow: 0 -4px 24px rgba(0, 0, 0, 0.3);
    transform: translateY(100%);
  }

  .ie-sidebar-open {
    transform: translateY(0);
  }

  .ie-score-badge {
    width: 36px;
    height: 36px;
    top: 4px;
    right: 4px;
  }

  .ie-score-number {
    font-size: 0.625rem;
  }

  .ie-lang-badge {
    right: 50px;
    font-size: 9px;
  }
}
