/* app/assets/stylesheets/text_patches.css */
/* Text Patch Feature Styles
 * Includes: patch highlighting, context menu, tooltips, and modal styling
 */

/* ================================
 * PATCH HIGHLIGHTING (Inline)
 * ================================ */

/* Base patch styling */
.text-patch {
  position: relative;
  cursor: pointer !important;
  transition: background-color 0.2s ease;
  padding: 2px 4px;
  border-radius: 3px;
  display: inline;
}

.text-patch * {
  cursor: pointer !important;
}

/* Hover effect for patches */
.text-patch:hover {
  background-color: rgba(59, 130, 246, 0.1); /* blue-500 with 10% opacity */
}

/* Deletion patches - red strikethrough */
.text-patch-deletion {
  color: #dc2626; /* red-600 */
  text-decoration: line-through;
  text-decoration-color: #dc2626;
  text-decoration-thickness: 2px;
  text-decoration-style: solid;
  background-color: rgba(220, 38, 38, 0.1); /* red-600 with 10% opacity */
}

.text-patch-deletion del {
  cursor: pointer;
}

.text-patch-deletion:hover {
  background-color: rgba(220, 38, 38, 0.2); /* red-600 with 20% opacity */
}

/* Replacement patches - container */
.text-patch-replacement {
  display: inline;
}

/* Replacement patches - original text (strikethrough red) */
.text-patch-replacement del,
.text-patch-replacement .text-patch-original {
  color: #dc2626; /* red-600 */
  text-decoration: line-through;
  text-decoration-color: #dc2626;
  text-decoration-thickness: 2px;
  text-decoration-style: solid;
  cursor: pointer;
}

/* Replacement patches - new text (underlined green) */
.text-patch-replacement ins,
.text-patch-replacement .text-patch-new {
  color: #16a34a; /* green-600 */
  text-decoration: underline;
  text-decoration-color: #16a34a;
  text-decoration-thickness: 2px;
  text-decoration-style: solid;
  font-weight: 500;
  cursor: pointer;
}

/* Dark mode adjustments for patches */
@media (prefers-color-scheme: dark) {
  .text-patch:hover {
    background-color: rgba(59, 130, 246, 0.2);
  }

  .text-patch-deletion {
    color: #f87171; /* red-400 */
    text-decoration-color: #f87171;
    background-color: rgba(248, 113, 113, 0.1);
  }

  .text-patch-deletion:hover {
    background-color: rgba(248, 113, 113, 0.2);
  }

  .text-patch-replacement del,
  .text-patch-replacement .text-patch-original {
    color: #f87171; /* red-400 */
    text-decoration-color: #f87171;
  }

  .text-patch-replacement ins,
  .text-patch-replacement .text-patch-new {
    color: #4ade80; /* green-400 */
    text-decoration-color: #4ade80;
  }
}

/* ================================
 * CONTEXT MENU
 * ================================ */

.text-patch-context-menu {
  position: fixed;
  z-index: 1000;
  background: white;
  border: 1px solid #e5e7eb; /* gray-200 */
  border-radius: 0.5rem; /* rounded-lg */
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1),
    0 4px 6px -2px rgba(0, 0, 0, 0.05);
  display: none;
  min-width: 200px;
  overflow: hidden;
}

.text-patch-context-menu.active {
  display: block !important;
  animation: contextMenuFadeIn 0.15s ease-out;
}

.text-patch-context-menu.hidden {
  display: none !important;
}

/* Context menu item */
.context-menu-item {
  border: none;
  background: transparent;
  font-size: 0.875rem; /* text-sm */
  transition: background-color 0.15s ease;
}

.context-menu-item:focus {
  outline: 2px solid #3b82f6; /* blue-500 */
  outline-offset: -2px;
}

/* Dark mode for context menu */
@media (prefers-color-scheme: dark) {
  .text-patch-context-menu {
    background: #1f2937; /* gray-800 */
    border-color: #374151; /* gray-700 */
  }

  .context-menu-item {
    color: #f9fafb; /* gray-50 */
  }
}

/* Context menu animation */
@keyframes contextMenuFadeIn {
  from {
    opacity: 0;
    transform: scale(0.95);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

/* ================================
 * TOOLTIP (Hoverable)
 * ================================ */

.text-patch-tooltip {
  position: fixed;
  z-index: 999;
  background: #1f2937; /* gray-800 */
  color: white;
  padding: 0.5rem;
  border-radius: 0.5rem; /* rounded-lg */
  font-size: 0.875rem; /* text-sm */
  display: none;
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.3),
    0 4px 6px -2px rgba(0, 0, 0, 0.2);
  animation: tooltipFadeIn 0.15s ease-out;
}

.text-patch-tooltip.active {
  display: block;
}

/* Tooltip content padding */
.text-patch-tooltip-content {
  padding: 0;
}

/* Tooltip animation */
@keyframes tooltipFadeIn {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Tooltip buttons */
.text-patch-tooltip button {
  font-size: 0.75rem; /* text-xs */
  font-weight: 500;
  transition: all 0.15s ease;
  border: none;
  cursor: pointer;
}

.text-patch-tooltip button:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1),
    0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

.text-patch-tooltip button:active {
  transform: translateY(0);
}

.text-patch-tooltip button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

/* Dark mode for tooltip */
@media (prefers-color-scheme: dark) {
  .text-patch-tooltip {
    background: #111827; /* gray-900 */
    border: 1px solid #374151; /* gray-700 */
  }
}

/* ================================
 * MODAL BACKDROP & DIALOG
 * ================================ */

.text-patch-modal-backdrop {
  backdrop-filter: blur(2px);
  transition: opacity 0.2s ease;
}

.text-patch-modal-backdrop.hidden {
  display: none;
}

.text-patch-modal-dialog {
  max-height: 90vh;
  overflow-y: auto;
}

/* Smooth scroll for modal content */
.text-patch-modal-dialog::-webkit-scrollbar {
  width: 8px;
}

.text-patch-modal-dialog::-webkit-scrollbar-track {
  background: #f3f4f6; /* gray-100 */
  border-radius: 4px;
}

.text-patch-modal-dialog::-webkit-scrollbar-thumb {
  background: #9ca3af; /* gray-400 */
  border-radius: 4px;
}

.text-patch-modal-dialog::-webkit-scrollbar-thumb:hover {
  background: #6b7280; /* gray-500 */
}

/* Dark mode scrollbar */
@media (prefers-color-scheme: dark) {
  .text-patch-modal-dialog::-webkit-scrollbar-track {
    background: #374151; /* gray-700 */
  }

  .text-patch-modal-dialog::-webkit-scrollbar-thumb {
    background: #4b5563; /* gray-600 */
  }

  .text-patch-modal-dialog::-webkit-scrollbar-thumb:hover {
    background: #6b7280; /* gray-500 */
  }
}

/* ================================
 * FORM ELEMENTS
 * ================================ */

/* Readonly textarea styling */
textarea[readonly] {
  cursor: not-allowed;
  opacity: 0.8;
}

/* Focus states for form fields */
.text-patch-modal-dialog input:focus,
.text-patch-modal-dialog textarea:focus {
  outline: none;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

/* ================================
 * ACCESSIBILITY ENHANCEMENTS
 * ================================ */

/* Focus visible for keyboard navigation */
.text-patch:focus-visible {
  outline: 2px solid #3b82f6; /* blue-500 */
  outline-offset: 2px;
  border-radius: 3px;
}

/* Reduce motion for users who prefer it */
@media (prefers-reduced-motion: reduce) {
  .text-patch,
  .text-patch-context-menu,
  .text-patch-tooltip,
  .text-patch-modal-backdrop,
  .text-patch-modal-dialog,
  button {
    animation: none;
    transition: none;
  }
}

/* ================================
 * RESPONSIVE DESIGN
 * ================================ */

/* Mobile adjustments */
@media (max-width: 640px) {
  .text-patch-modal-dialog {
    max-width: 95%;
    margin-top: 2rem;
    padding: 1rem;
  }

  .text-patch-tooltip {
    max-width: 90vw;
    min-width: 250px;
    font-size: 0.8125rem; /* slightly smaller text */
  }

  .text-patch-context-menu {
    min-width: 180px;
  }
}

/* ================================
 * UTILITY CLASSES
 * ================================ */

/* Loading state for buttons */
.btn-loading {
  position: relative;
  color: transparent;
}

.btn-loading::after {
  content: "";
  position: absolute;
  width: 16px;
  height: 16px;
  top: 50%;
  left: 50%;
  margin-left: -8px;
  margin-top: -8px;
  border: 2px solid #ffffff;
  border-radius: 50%;
  border-top-color: transparent;
  animation: spinner 0.6s linear infinite;
}

@keyframes spinner {
  to {
    transform: rotate(360deg);
  }
}

/* Success/Error message animations */
.alert-enter {
  animation: alertSlideIn 0.3s ease-out;
}

@keyframes alertSlideIn {
  from {
    opacity: 0;
    transform: translateY(-20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ================================
 * PRINT STYLES
 * ================================ */

@media print {
  .text-patch-context-menu,
  .text-patch-tooltip,
  .text-patch-modal-backdrop {
    display: none !important;
  }

  .text-patch {
    background-color: transparent !important;
  }

  /* Show patches in print with clear indicators */
  .text-patch-deletion::after {
    content: " [DELETED]";
    font-size: 0.75em;
    color: #dc2626;
  }

  .text-patch-replacement .text-patch-new::after {
    content: " [REPLACEMENT]";
    font-size: 0.75em;
    color: #16a34a;
  }
}
