/* /assets/css/grammar-corrections-popup.css */
/* Inline grammar correction popups that appear near errors */

.grammar-popup-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.15);
  z-index: 9998;
  pointer-events: none;
  backdrop-filter: blur(2px);
}

.grammar-popup {
  position: absolute;
  z-index: 9999;
  background: var(--bg-card, white);
  border: 2px solid var(--primary, #5B47E5);
  border-radius: 12px;
  box-shadow: var(--shadow-xl, 0 8px 24px rgba(0, 0, 0, 0.12), 0 4px 8px rgba(0, 0, 0, 0.08));
  padding: 1.25rem;
  min-width: 320px;
  max-width: 420px;
  font-family: var(--font-body, system-ui, -apple-system, sans-serif);
  pointer-events: auto;
}

.grammar-popup-arrow {
  position: absolute;
  width: 12px;
  height: 12px;
  background: var(--bg-card, white);
  border: 2px solid var(--primary, #5B47E5);
  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: 0.875rem;
  padding-bottom: 0.625rem;
  border-bottom: 1px solid var(--border, #e5e7eb);
}

.grammar-popup-progress {
  font-size: 0.75rem;
  color: var(--text-muted, #6b7280);
  font-weight: 500;
}

.grammar-popup-close {
  background: none;
  border: none;
  color: var(--text-muted, #6b7280);
  font-size: 1.25rem;
  line-height: 1;
  cursor: pointer;
  padding: 0;
  width: 1.75rem;
  height: 1.75rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm, 0.375rem);
  transition: all var(--transition-fast, 0.15s);
}

.grammar-popup-close:hover {
  background: var(--bg-hover, #f3f4f6);
  color: var(--text-primary, #374151);
  transform: scale(1.1);
}

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

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

.grammar-popup-original {
  color: #dc2626;
  font-weight: 500;
  padding: 2px 6px;
  background: #fee2e2;
  border-radius: 4px;
}

.grammar-popup-arrow-symbol {
  color: #6b7280;
  font-size: 14px;
}

.grammar-popup-corrected {
  color: #059669;
  font-weight: 500;
  padding: 2px 6px;
  background: #d1fae5;
  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: #6b7280;
  background: #f3f4f6;
  padding: 2px 6px;
  border-radius: 3px;
  margin-bottom: 8px;
}

.grammar-popup-description {
  font-size: 14px;
  color: #374151;
  line-height: 1.5;
  margin-bottom: 8px;
}

.grammar-popup-explanation {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid #e5e7eb;
}

.grammar-popup-concept-title {
  font-size: 13px;
  font-weight: 600;
  color: #1f2937;
  margin-bottom: 6px;
}

.grammar-popup-concept-text {
  font-size: 13px;
  color: #4b5563;
  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: #f3f4f6;
  border-radius: 3px;
}

.grammar-popup-concept-text::-webkit-scrollbar-thumb {
  background: #d1d5db;
  border-radius: 3px;
}

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

.grammar-popup-btn {
  flex: 1;
  padding: 0.625rem 1.25rem;
  border: 1px solid var(--border, #d1d5db);
  border-radius: var(--radius-md, 0.5rem);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-base, 0.2s);
  background: var(--bg-card, white);
  color: var(--text-secondary, #374151);
  box-shadow: var(--shadow-sm, 0 1px 2px rgba(0, 0, 0, 0.04));
}

.grammar-popup-btn:hover {
  background: var(--bg-hover, #f9fafb);
  border-color: var(--text-muted, #9ca3af);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md, 0 2px 4px rgba(0, 0, 0, 0.08));
}

.grammar-popup-btn-accept {
  background: linear-gradient(135deg, var(--primary, #5B47E5) 0%, var(--primary-dark, #4338ca) 100%);
  color: white;
  border-color: var(--primary, #5B47E5);
  box-shadow: 0 3px 8px rgba(91, 71, 229, 0.3);
}

.grammar-popup-btn-accept:hover {
  box-shadow: 0 5px 12px rgba(91, 71, 229, 0.4);
  transform: translateY(-2px);
}

.grammar-popup-btn-reveal {
  background: linear-gradient(135deg, var(--success-light, #10b981) 0%, var(--success, #059669) 100%);
  color: white;
  border-color: var(--success, #059669);
  box-shadow: 0 3px 8px rgba(5, 150, 105, 0.3);
}

.grammar-popup-btn-reveal:hover {
  box-shadow: 0 5px 12px rgba(5, 150, 105, 0.4);
  transform: translateY(-2px);
}

.grammar-popup-btn-skip {
  background: var(--bg-card, white);
  color: var(--text-muted, #6b7280);
  border-color: var(--border, #d1d5db);
}

.grammar-popup-btn-skip:hover {
  background: var(--bg-hover, #f9fafb);
  color: var(--text-secondary, #374151);
}

/* 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: #fef2f2 !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;
  }
}