
/* /assets/css/grammar-corrections-popup.css */
/* Inline grammar correction popups – dark theme */

.grammar-popup-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 9998;
  pointer-events: none;
}

.grammar-popup {
  position: absolute;
  z-index: 9999;
  background: var(--surface-raised, #1e2333);
  border: 2px solid #3b82f6;
  border-radius: 8px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
  padding: 16px;
  min-width: 320px;
  max-width: 400px;
  max-height: calc(100vh - 40px);
  overflow-y: auto;
  box-sizing: border-box;
  font-family: system-ui, -apple-system, sans-serif;
  pointer-events: auto;
  color: var(--text-primary, #e2e8f0);
}

.grammar-popup.grammar-popup-centered {
  width: min(420px, calc(100vw - 32px));
}

.grammar-popup.grammar-popup-centered .grammar-popup-arrow {
  display: none;
}

.grammar-popup-arrow {
  position: absolute;
  width: 12px;
  height: 12px;
  background: var(--surface-raised, #1e2333);
  border: 2px solid #3b82f6;
  transform: rotate(45deg);
  z-index: -1;
}

.grammar-popup-arrow.arrow-left {
  left: -7px;
  top: 20px;
  border-right: none;
  border-bottom: none;
}

.grammar-popup-arrow.arrow-right {
  right: -7px;
  top: 20px;
  border-left: none;
  border-top: none;
}

.grammar-popup-arrow.arrow-top {
  top: -7px;
  left: 20px;
  border-bottom: none;
  border-right: none;
}

.grammar-popup-arrow.arrow-bottom {
  bottom: -7px;
  left: 20px;
  border-top: none;
  border-left: none;
}

.grammar-popup-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--card-border, #2a2f45);
}

.grammar-popup-progress {
  font-size: 12px;
  color: var(--text-secondary, #94a3b8);
  font-weight: 500;
}

.grammar-popup-close {
  background: none;
  border: none;
  color: var(--text-muted, #64748b);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  padding: 0;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  transition: background 0.15s;
}

.grammar-popup-close:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-primary, #e2e8f0);
}

.grammar-popup-change {
  margin-bottom: 12px;
}

.grammar-popup-text {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.grammar-popup-original {
  color: #fca5a5;
  font-weight: 500;
  padding: 2px 6px;
  background: rgba(220, 38, 38, 0.15);
  border-radius: 4px;
}

.grammar-popup-arrow-symbol {
  color: var(--text-muted, #64748b);
  font-size: 14px;
}

.grammar-popup-corrected {
  color: #6ee7b7;
  font-weight: 500;
  padding: 2px 6px;
  background: rgba(5, 150, 105, 0.15);
  border-radius: 4px;
}

/* Ensure hidden elements are truly hidden */
.grammar-popup-arrow-symbol[style*="display: none"],
.grammar-popup-corrected[style*="display: none"] {
  display: none !important;
  visibility: hidden !important;
}

.grammar-popup-category {
  display: inline-block;
  font-size: 11px;
  text-transform: uppercase;
  font-weight: 600;
  color: var(--text-secondary, #94a3b8);
  background: var(--surface, #1a1f2e);
  padding: 2px 6px;
  border-radius: 3px;
  margin-bottom: 8px;
}

.grammar-popup-description {
  font-size: 14px;
  color: var(--text-primary, #e2e8f0);
  line-height: 1.5;
  margin-bottom: 8px;
}

.grammar-popup-explanation {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--card-border, #2a2f45);
}

.grammar-popup-concept-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary, #e2e8f0);
  margin-bottom: 6px;
}

.grammar-popup-concept-text {
  font-size: 13px;
  color: var(--text-secondary, #94a3b8);
  line-height: 1.6;
  max-height: 120px;
  overflow-y: auto;
}

.grammar-popup-concept-text::-webkit-scrollbar {
  width: 6px;
}

.grammar-popup-concept-text::-webkit-scrollbar-track {
  background: var(--surface, #1a1f2e);
  border-radius: 3px;
}

.grammar-popup-concept-text::-webkit-scrollbar-thumb {
  background: var(--card-border, #2a2f45);
  border-radius: 3px;
}

.grammar-popup-actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

.grammar-popup-btn {
  flex: 1;
  padding: 8px 16px;
  border: 1px solid var(--card-border, #2a2f45);
  border-radius: 6px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  background: var(--surface, #1a1f2e);
  color: var(--text-primary, #e2e8f0);
}

.grammar-popup-btn:hover {
  background: var(--surface-raised, #1e2333);
  border-color: var(--text-muted, #64748b);
}

.grammar-popup-btn-accept {
  background: #3b82f6;
  color: white;
  border-color: #3b82f6;
}

.grammar-popup-btn-accept:hover {
  background: #2563eb;
  border-color: #2563eb;
}

.grammar-popup-btn-reveal {
  background: #10b981;
  color: white;
  border-color: #10b981;
}

.grammar-popup-btn-reveal:hover {
  background: #059669;
  border-color: #059669;
}

.grammar-popup-btn-skip {
  background: var(--surface, #1a1f2e);
  color: var(--text-muted, #64748b);
  border-color: var(--card-border, #2a2f45);
}

.grammar-popup-btn-skip:hover {
  background: var(--surface-raised, #1e2333);
  color: var(--text-primary, #e2e8f0);
}

/* Highlight the error in the textarea */
.grammar-highlight-active::selection {
  background: rgba(239, 68, 68, 0.3) !important;
  color: inherit;
}

.grammar-highlight-active::-moz-selection {
  background: rgba(239, 68, 68, 0.3) !important;
  color: inherit;
}

/* Enhance the textarea when showing corrections */
.grammar-highlight-active {
  background: rgba(239, 68, 68, 0.08) !important;
  transition: background 0.2s;
}

/* Animation */
@keyframes popup-appear {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.grammar-popup {
  animation: popup-appear 0.2s ease-out;
}

/* Mobile responsive */
@media (max-width: 640px) {
  .grammar-popup {
    min-width: 280px;
    max-width: calc(100vw - 40px);
    font-size: 13px;
  }

  .grammar-popup-text {
    flex-direction: column;
    align-items: flex-start;
  }

  .grammar-popup-actions {
    flex-direction: column;
  }
}

@supports (height: 100svh) {
  .grammar-popup {
    max-height: calc(100svh - 40px);
  }
}
