/*
 * This is a manifest file that'll be compiled into application.css.
 *
 * With Propshaft, assets are served efficiently without preprocessing steps. You can still include
 * application-wide styles in this file, but keep in mind that CSS precedence will follow the standard
 * cascading order, meaning styles declared later in the document or manifest will override earlier ones,
 * depending on specificity.
 *
 * Consider organizing styles into separate files for maintainability.
 */

/*
 *= require tailwind
 */

/* wow */

/* Editor.js Styling - Custom styles for Editor.js blocks */
.ce-block {
  margin: 0.5rem 0;
}

.ce-paragraph {
  color: var(--color-foreground);
  line-height: 1.6;
}

.ce-header {
  font-weight: 600;
  color: var(--color-foreground);
}

/* Editor.js toolbar and UI elements */
.codex-editor__redactor {
  padding-bottom: 0 !important;
}

.ce-toolbar__content,
.ce-block__content {
  max-width: 100%;
}

/* Ensure Editor.js toolbar and popovers appear above other content */
.ce-toolbar {
  z-index: 50 !important;
}

.ce-toolbar__actions {
  z-index: 51 !important;
}

/* Editor.js toolbar buttons - theme compatible colors */
.ce-toolbar__plus,
.ce-toolbar__settings-btn {
  color: var(--color-muted-foreground) !important;
  background-color: transparent !important;
  border-radius: 4px;
  opacity: 0.6;
  transition: opacity 0.15s ease, color 0.15s ease;
}

.ce-toolbar__plus:hover,
.ce-toolbar__settings-btn:hover {
  color: var(--color-foreground) !important;
  background-color: var(--color-muted) !important;
  opacity: 1;
}

.ce-toolbar__plus svg,
.ce-toolbar__settings-btn svg {
  color: inherit !important;
}

.ce-toolbar__plus svg path,
.ce-toolbar__settings-btn svg path {
  stroke: currentColor !important;
}

/* Soften the Editor.js block focus indicator */
.ce-block--focused {
  background-color: transparent !important;
}

.cdx-block:focus {
  outline: none !important;
}

/* Remove focus ring from Editor.js contenteditable elements */
.codex-editor *:focus-visible,
.codex-editor *:focus {
  outline: none !important;
  box-shadow: none !important;
}

/* Remove focus ring from editor wrapper and container */
.editor-wrapper *:focus-visible,
.editor-wrapper *:focus,
.editor-wrapper *:focus-within,
.editor-wrapper:has(:focus) .border {
  outline: none !important;
  box-shadow: none !important;
  border-color: var(--color-border) !important;
}

/* Make the Editor.js selected block border more subtle */
.ce-block--selected .ce-block__content {
  background-color: oklch(from var(--color-primary) l c h / 0.05) !important;
}

.ce-popover,
.ce-popover--opened {
  z-index: 52 !important;
  position: relative;
}

.ce-popover__container {
  z-index: 53 !important;
}

/* Editor.js placeholder text */
.ce-block--focused .ce-block__content [contenteditable][data-placeholder]:empty::before,
.ce-block__content [contenteditable][data-placeholder]:empty::before {
  color: var(--color-muted-foreground);
  opacity: 0.5;
}

/* Editor.js inline toolbar - Override Editor.js CSS variables for theme compatibility */
.ce-inline-toolbar,
.ce-conversion-toolbar,
.ce-settings,
.ce-popover,
.ce-popover__container {
  --color-text-primary: var(--color-popover-foreground) !important;
  --color-bg-primary: var(--color-popover) !important;
  --color-text-secondary: var(--color-muted-foreground) !important;
  --color-bg-secondary: var(--color-accent) !important;
  background: var(--color-popover) !important;
  border-color: var(--color-border) !important;
  color: var(--color-popover-foreground) !important;
}

/* All inline tool buttons - including italic and link */
.ce-inline-tool,
.ce-conversion-tool,
.ce-settings__button,
.ce-popover__item,
.ce-popover-item,
.ce-popover-item-html button,
.ce-popover-item__icon {
  color: var(--color-popover-foreground) !important;
}

/* SVG icons inside inline tools need to inherit color for stroke */
.ce-inline-tool svg,
.ce-popover-item svg,
.ce-popover-item-html svg,
.ce-popover-item__icon svg {
  color: inherit !important;
}

/* Ensure paths with currentColor work properly */
.ce-inline-tool svg path,
.ce-popover-item svg path,
.ce-popover-item-html svg path,
.ce-popover-item__icon svg path {
  stroke: currentColor !important;
}

.ce-inline-tool:hover,
.ce-conversion-tool:hover,
.ce-settings__button:hover,
.ce-popover__item:hover,
.ce-popover-item:hover,
.ce-popover-item-html button:hover {
  background-color: var(--color-accent) !important;
}

.ce-inline-tool--active,
.ce-popover-item--active {
  background-color: var(--color-accent) !important;
  color: var(--color-accent-foreground) !important;
}

/* EditorJS Header Level Styling - target the actual heading elements */
h1.ce-header {
  font-size: 2rem;
  line-height: 1.125;
}

h2.ce-header {
  font-size: 1.5rem;
  line-height: 1.25;
}

h3.ce-header {
  font-size: 1.25rem;
  line-height: 1.375;
}

h4.ce-header {
  font-size: 1.125rem;
  line-height: 1.375;
}

h5.ce-header {
  font-size: 1rem;
  line-height: 1.5;
}

h6.ce-header {
  font-size: 0.875rem;
  line-height: 1.5;
}

/* Rich text content styling */
.prose {
  line-height: 1.6;
  word-wrap: break-word;
  overflow-wrap: break-word;
  hyphens: auto;
}

/* Mobile-specific prose improvements */
@media (max-width: 640px) {
  .prose {
    font-size: 0.9rem;
    line-height: 1.5;
  }

  .prose h1 { font-size: 1.5rem; }
  .prose h2 { font-size: 1.25rem; }
  .prose h3 { font-size: 1.125rem; }
  .prose h4 { font-size: 1rem; }
  .prose h5 { font-size: 0.95rem; }
  .prose h6 { font-size: 0.9rem; }

  .prose p { margin-bottom: 0.75em; }
  .prose ul, .prose ol { padding-left: 1.25em; }
}

.prose h1 {
  margin-top: 1.5em;
  margin-bottom: 0.5em;
  font-weight: 600;
  font-size: 2rem;
  line-height: 1.125;
}

.prose h2 {
  margin-top: 1.5em;
  margin-bottom: 0.5em;
  font-weight: 600;
  font-size: 1.5rem;
  line-height: 1.25;
}

.prose h3 {
  margin-top: 1.5em;
  margin-bottom: 0.5em;
  font-weight: 600;
  font-size: 1.25rem;
  line-height: 1.375;
}

.prose h4 {
  margin-top: 1.25em;
  margin-bottom: 0.5em;
  font-weight: 600;
  font-size: 1.125rem;
  line-height: 1.375;
}

.prose h5 {
  margin-top: 1.25em;
  margin-bottom: 0.5em;
  font-weight: 600;
  font-size: 1rem;
  line-height: 1.5;
}

.prose h6 {
  margin-top: 1.25em;
  margin-bottom: 0.5em;
  font-weight: 600;
  font-size: 0.875rem;
  line-height: 1.5;
}

.prose p {
  margin-bottom: 1em;
}

.prose ul,
.prose ol {
  margin-bottom: 1em;
  padding-left: 1.5em;
  list-style-position: outside;
}

.prose ul {
  list-style-type: disc;
}

.prose ol {
  list-style-type: decimal;
}

.prose li {
  margin-bottom: 0.375rem;
}

.prose pre {
  background-color: var(--color-muted);
  color: var(--color-foreground);
  padding: 1em;
  border-radius: 0.375rem;
  overflow-x: auto;
  word-wrap: normal;
  white-space: pre;
}

/* Mobile code block improvements */
@media (max-width: 640px) {
  .prose pre {
    padding: 0.75em;
    font-size: 0.8rem;
    border-radius: 0.25rem;
  }
}

.prose code {
  background-color: var(--color-muted);
  color: var(--color-foreground);
  padding: 0.125rem 0.25rem;
  border-radius: 0.25rem;
  font-size: 0.875em;
}

.prose blockquote {
  border-left: 4px solid var(--color-border);
  padding-left: 1em;
  margin: 1em 0;
  font-style: italic;
  color: var(--color-muted-foreground);
}

/* Enhanced Annotation Styles - Theme Aware */
.annotation-marker {
  background-color: oklch(from var(--color-warning) l c h / 0.2);
  border-bottom: 2px solid var(--color-warning);
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
  padding: 1px 2px;
  border-radius: 2px;
}

.annotation-marker:hover {
  background-color: oklch(from var(--color-warning) l c h / 0.4);
  box-shadow: 0 2px 4px var(--color-accent-glow);
}

/* New DOM-based annotation highlights */
.annotation-highlight {
  background-color: oklch(from var(--color-warning) l c h / 0.3);
  border-bottom: 2px solid var(--color-warning);
  cursor: pointer;
  transition: all 0.2s ease;
  padding: 1px 2px;
  border-radius: 2px;
  position: relative;
  color: var(--color-foreground);
}

.annotation-highlight:hover {
  background-color: oklch(from var(--color-warning) l c h / 0.5);
  box-shadow: 0 2px 4px var(--color-accent-glow);
  color: var(--color-foreground);
}

/* Status-specific annotation styles */
.annotation-highlight[data-status="resolved"] {
  background-color: oklch(from var(--color-success) l c h / 0.2);
  border-bottom-color: var(--color-success);
  color: var(--color-foreground);
}

.annotation-highlight[data-status="hidden"] {
  background-color: oklch(from var(--color-muted) l c h / 0.3);
  border-bottom-color: var(--color-muted-foreground);
  color: var(--color-foreground);
}

.annotation-resolved {
  background-color: oklch(from var(--color-success) l c h / 0.2);
  border-bottom: 2px solid var(--color-success);
  color: var(--color-foreground);
}

.annotation-resolved:hover {
  background-color: oklch(from var(--color-success) l c h / 0.4);
  color: var(--color-foreground);
}

/* Annotation threading indicators */
.annotation-thread-indicator {
  position: absolute;
  left: -8px;
  top: 50%;
  transform: translateY(-50%);
  width: 4px;
  height: 4px;
  background-color: var(--color-info);
  border-radius: 50%;
}

.annotation-highlight[data-thread-depth="1"] .annotation-thread-indicator {
  background-color: var(--color-primary);
}

.annotation-highlight[data-thread-depth="2"] .annotation-thread-indicator {
  background-color: var(--color-destructive);
}

/* Annotation popup and panels */
.annotation-popup {
  box-shadow:
    0 10px 15px -3px rgba(0, 0, 0, 0.1),
    0 4px 6px -2px rgba(0, 0, 0, 0.05);
  border: 1px solid var(--color-border);
  background: var(--color-popover);
  z-index: 1000;
  border-radius: 8px;
  backdrop-filter: blur(8px);
}

.annotation-detail-panel {
  transform: translateX(100%);
  transition: transform 0.3s ease-in-out;
  box-shadow:
    -10px 0 15px -3px rgba(0, 0, 0, 0.1),
    -4px 0 6px -2px rgba(0, 0, 0, 0.05);
}

.annotation-detail-panel.show {
  transform: translateX(0);
}

/* Annotation sidebar */
.annotation-sidebar {
  background: var(--color-card);
  backdrop-filter: blur(8px);
  border-left: 1px solid var(--color-border);
}

/* Annotation creation modal */
.annotation-modal-backdrop {
  backdrop-filter: blur(4px);
}

/* Annotation status badges */
.annotation-status-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 6px;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 500;
}

.annotation-status-active {
  background-color: oklch(from var(--color-info) l c h / 0.2);
  color: var(--color-info);
}

.annotation-status-resolved {
  background-color: oklch(from var(--color-success) l c h / 0.2);
  color: var(--color-success);
}

.annotation-status-hidden {
  background-color: var(--color-muted);
  color: var(--color-muted-foreground);
}

/* Post highlighting */
.post-highlight {
  transition: all 0.3s ease;
}

.post-highlight .border {
  border-color: var(--color-primary) !important;
  border-width: 2px !important;
}

/* Selection styles */
::selection {
  background-color: oklch(from var(--color-primary) l c h / 0.3);
  color: var(--color-foreground);
}

::-moz-selection {
  background-color: oklch(from var(--color-primary) l c h / 0.3);
  color: var(--color-foreground);
}

/* Annotation count badge */
.annotation-count {
  font-size: 0.75rem;
  background-color: var(--color-warning);
  color: var(--color-warning-foreground);
  border-radius: 9999px;
  padding: 0.125rem 0.375rem;
  margin-left: 0.25rem;
}

/* Deep link animations */
@keyframes highlightPulse {
  0% {
    background-color: oklch(from var(--color-warning) l c h / 0.3);
  }
  50% {
    background-color: oklch(from var(--color-warning) l c h / 0.5);
  }
  100% {
    background-color: transparent;
  }
}

.deep-link-highlight {
  animation: highlightPulse 2s ease-out;
}

/* Editor.js Image Block Styles */
.editor-image {
  margin: 1.5rem 0;
  text-align: center;
}

.editor-image img {
  max-width: 100%;
  height: auto;
  border-radius: 0.5rem;
  box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
}

.editor-image.with-border img {
  border: 1px solid var(--color-border);
}

.editor-image.with-background {
  background-color: var(--color-muted);
  padding: 1rem;
  border-radius: 0.5rem;
}

.editor-image.stretched img {
  width: 100%;
}

.image-caption {
  margin-top: 0.5rem;
  font-size: 0.875rem;
  color: var(--color-muted-foreground);
  font-style: italic;
}

/* Editor.js Attachment Block Styles */
.editor-attachment {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem;
  margin: 1rem 0;
  border: 1px solid var(--color-border);
  border-radius: 0.5rem;
  background-color: var(--color-muted);
  transition: background-color 0.2s ease;
}

.editor-attachment:hover {
  background-color: var(--color-accent);
}

.attachment-icon {
  flex-shrink: 0;
  width: 3rem;
  height: 3rem;
  background-color: var(--color-primary);
  border-radius: 0.375rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.file-extension {
  color: var(--color-primary-foreground);
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
}

.attachment-details {
  flex-grow: 1;
  min-width: 0;
}

.attachment-title {
  font-weight: 600;
  color: var(--color-foreground);
  margin-bottom: 0.25rem;
  word-wrap: break-word;
}

.attachment-name {
  color: var(--color-foreground);
  font-size: 0.875rem;
  word-wrap: break-word;
}

.attachment-size {
  color: var(--color-muted-foreground);
  font-size: 0.75rem;
  margin-top: 0.125rem;
}

.attachment-download {
  flex-shrink: 0;
  background-color: var(--color-primary);
  color: var(--color-primary-foreground);
  padding: 0.5rem 1rem;
  border-radius: 0.375rem;
  text-decoration: none;
  font-size: 0.875rem;
  font-weight: 500;
  transition: background-color 0.2s ease;
}

.attachment-download:hover {
  background-color: var(--color-primary);
  opacity: 0.9;
  color: white;
  text-decoration: none;
}

/* ============================================
   MENTION STYLING - Theme Aware
   ============================================ */

.mention,
.mention-valid {
  color: var(--color-info);
  background-color: var(--color-info);
  opacity: 1;
  background: oklch(from var(--info) l c h / 0.15);
  padding: 2px 6px;
  border-radius: 4px;
  font-weight: 500;
  text-decoration: none;
  transition: background-color 0.2s ease;
}

.mention:hover,
.mention-valid:hover {
  background: oklch(from var(--info) l c h / 0.25);
}

.mention-invalid {
  color: var(--color-destructive);
  background: oklch(from var(--destructive) l c h / 0.15);
  padding: 2px 6px;
  border-radius: 4px;
  text-decoration: none;
}

.mention-invalid:hover {
  background: oklch(from var(--destructive) l c h / 0.25);
}

/* ============================================
   PRIORITY INDICATORS - Theme Aware
   ============================================ */

.priority-low {
  color: var(--color-muted-foreground);
}

.priority-medium {
  color: var(--color-warning);
}

.priority-high {
  color: var(--color-destructive);
}

/* ============================================
   ROLE BADGES - Theme Aware
   ============================================ */

.role-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 500;
}

.role-badge-owner {
  background-color: var(--color-primary);
  opacity: 0.15;
  color: var(--color-primary);
}

.role-badge-admin {
  background-color: var(--color-info);
  opacity: 0.15;
  color: var(--color-info);
}

.role-badge-member {
  background-color: var(--color-muted);
  color: var(--color-muted-foreground);
}

/* ============================================
   EDITOR ENHANCEMENTS
   ============================================ */

/* Editor wrapper focus state */
.editor-wrapper .border:focus-within {
  border-color: var(--color-ring);
}

/* Editor toolbar */
.editor-toolbar {
  border-color: var(--color-border);
}

.editor-toolbar button:focus {
  outline: none;
  ring: 2px;
  ring-color: var(--color-ring);
}

/* Block insertion animation */
.ce-block {
  animation: blockFadeIn 0.2s ease-out;
}

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

/* Better delimiter visibility */
.ce-delimiter {
  padding: 1rem 0;
}

.ce-delimiter::before {
  content: '';
  display: block;
  height: 2px;
  background: linear-gradient(
    to right,
    transparent,
    var(--color-border) 20%,
    var(--color-border) 80%,
    transparent
  );
}

/* Code block improvements */
.ce-code__textarea {
  background-color: var(--color-muted) !important;
  color: var(--color-foreground) !important;
  border: 1px solid var(--color-border) !important;
  border-radius: 0.375rem;
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

/* Table improvements */
.tc-table {
  border-collapse: collapse;
  width: 100%;
}

.tc-table td,
.tc-table th {
  border: 1px solid var(--color-border);
  padding: 0.5rem;
}

.tc-table th {
  background-color: var(--color-muted);
  font-weight: 600;
}

/* Mobile toolbar improvements */
@media (max-width: 640px) {
  .editor-toolbar {
    gap: 0.25rem;
    padding: 0.5rem;
  }

  .editor-toolbar button {
    padding: 0.5rem;
  }

  .editor-toolbar .w-px {
    display: none;
  }
}

/* ============================================
   TOAST ANIMATIONS
   ============================================ */

.animate-in {
  animation-duration: 0.2s;
  animation-fill-mode: both;
}

.animate-out {
  animation-duration: 0.15s;
  animation-fill-mode: both;
}

.slide-in-from-top-2 {
  animation-name: slideInFromTop;
}

.slide-out-to-top-2 {
  animation-name: slideOutToTop;
}

@keyframes slideInFromTop {
  from {
    opacity: 0;
    transform: translateY(-0.5rem);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes slideOutToTop {
  from {
    opacity: 1;
    transform: translateY(0);
  }
  to {
    opacity: 0;
    transform: translateY(-0.5rem);
  }
}

/* Toast theme colors */
.bg-success {
  background-color: oklch(from var(--color-success) l c h / 1);
}

.text-success-foreground {
  color: white;
}

.bg-info {
  background-color: oklch(from var(--color-info) l c h / 1);
}

.text-info-foreground {
  color: white;
}

/* ============================================
   LOADING SKELETON
   ============================================ */

.editor-loading {
  min-height: 100px;
}

/* ============================================
   IMPROVED MENTION DROPDOWN
   ============================================ */

.mention-autocomplete {
  max-height: 200px;
  overflow-y: auto;
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1),
              0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

.mention-autocomplete .mention-item {
  transition: background-color 0.1s ease;
}

.mention-autocomplete .mention-item.selected,
.mention-autocomplete .mention-item:hover {
  background-color: var(--color-accent);
}

/* Fix mention dropdown positioning on mobile */
@media (max-width: 640px) {
  .mention-autocomplete {
    position: fixed !important;
    left: 1rem !important;
    right: 1rem !important;
    width: auto !important;
    max-width: calc(100vw - 2rem);
  }
}

/* ============================================
   UPLOAD PROGRESS
   ============================================ */

.upload-progress-bar {
  transition: width 0.3s ease;
}

/* ============================================
   KEYBOARD SHORTCUT HINTS
   ============================================ */

kbd {
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.75rem;
}
