/*
 * 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_self
 */

/* Lexxy fallback styles that work even without a fresh Tailwind build. */
.lexxy-content ul,
.manual-content ul,
.content-prose ul,
.comment-content ul {
  list-style: disc outside;
  margin: 1rem 0 1rem 1.5rem;
  padding-left: 0.5rem;
}

.lexxy-content ol,
.manual-content ol,
.content-prose ol,
.comment-content ol {
  list-style: decimal outside;
  margin: 1rem 0 1rem 1.5rem;
  padding-left: 0.5rem;
}

.lexxy-content li,
.manual-content li,
.content-prose li,
.comment-content li {
  display: list-item;
  margin: 0.25rem 0;
}

/* Editor fallback styles for browsers where Lexxy nested CSS is not applied. */
.lexxy-editor__content ul {
  list-style: disc outside;
  margin: 1rem 0 1rem 1.5rem;
  padding-left: 0.5rem;
}

.lexxy-editor__content ol {
  list-style: decimal outside;
  margin: 1rem 0 1rem 1.5rem;
  padding-left: 0.5rem;
}

.lexxy-editor__content li {
  display: list-item;
  margin: 0.25rem 0;
}

.lexxy-content__strikethrough {
  text-decoration: line-through;
}

.lexxy-content__table-wrapper {
  overflow-x: auto;
}

.lexxy-editor__content table,
.lexxy-content table,
.manual-content table,
.content-prose table {
  border-collapse: collapse;
  width: 100%;
  margin: 1rem 0;
}

.lexxy-editor__content th,
.lexxy-editor__content td,
.lexxy-content th,
.lexxy-content td,
.manual-content th,
.manual-content td,
.content-prose th,
.content-prose td {
  border: 1px solid #d1d5db;
  padding: 0.5rem 0.625rem;
  vertical-align: top;
  text-align: left;
}

.lexxy-editor__content th,
.lexxy-content th,
.manual-content th,
.content-prose th {
  background: #f9fafb;
  font-weight: 600;
}

.editor-drop-indicator {
  height: 4px;
  border-radius: 9999px;
  background: #2563eb;
  margin: 6px 0;
  position: relative;
}

.editor-drop-indicator::after {
  content: "";
  position: absolute;
  left: 10px;
  top: -6px;
  width: 0;
  height: 0;
  border-left: 6px solid transparent;
  border-right: 6px solid transparent;
  border-bottom: 6px solid #2563eb;
}

.editor-drop-target {
  outline: 2px dashed #93c5fd;
  outline-offset: 4px;
}

/* Shared icon/button system for consistent action controls across the app. */
.ui-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  border-radius: 0.375rem;
  border: 1px solid transparent;
  padding: 0.5rem 0.75rem;
  font-size: 0.875rem;
  font-weight: 500;
  line-height: 1;
  transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.ui-btn-icon {
  width: 2rem;
  height: 2rem;
  padding: 0;
  border-radius: 9999px;
  gap: 0;
}

input[type="submit"].ui-btn-icon {
  width: auto;
  height: auto;
  padding: 0.5rem 0.75rem;
  border-radius: 0.375rem;
}

.app-fab.ui-btn-icon {
  width: 3rem;
  height: 3rem;
}

.ui-btn:focus-visible {
  outline: 2px solid #2563eb;
  outline-offset: 2px;
}

.ui-btn-secondary {
  border-color: #d1d5db;
  color: #374151;
  background: #ffffff;
}

.ui-btn-secondary:hover {
  background: #f9fafb;
}

.ui-btn-primary {
  border-color: #1e3a8a;
  color: #ffffff;
  background: #1e3a8a;
}

.ui-btn-primary:hover {
  background: #1e40af;
}

.ui-btn-danger {
  border-color: #fca5a5;
  color: #b91c1c;
  background: #ffffff;
}

.ui-btn-danger:hover {
  background: #fef2f2;
}

/* Reusable mobile layout helpers (reduce duplicated per-view spacing classes). */
@media (max-width: 639px) {
  .mobile-page-soft {
    padding-inline: 0.5rem;
  }

  .mobile-gutter-soft {
    padding-inline: 0.5rem;
  }

  .mobile-card-soft {
    margin-inline: 0.25rem;
    border-radius: 0.75rem;
  }
}

@media (min-width: 640px) {
  .with-desktop-sidebar {
    padding-left: 16rem;
    transition: padding-left 0.2s ease;
  }

  html.desktop-sidebar-collapsed .with-desktop-sidebar,
  body.desktop-sidebar-collapsed .with-desktop-sidebar {
    padding-left: 4.75rem;
  }

  .desktop-sidebar {
    width: 16rem;
    transition: width 0.2s ease;
  }

  html.desktop-sidebar-collapsed .desktop-sidebar,
  .desktop-sidebar.is-collapsed {
    width: 4.75rem;
  }

  .desktop-sidebar .sidebar-label {
    white-space: nowrap;
    transition: opacity 0.12s ease, max-width 0.12s ease, margin 0.12s ease;
    max-width: 220px;
  }

  html.desktop-sidebar-collapsed .desktop-sidebar .sidebar-label,
  .desktop-sidebar.is-collapsed .sidebar-label {
    opacity: 0;
    max-width: 0;
    margin: 0;
    overflow: hidden;
    pointer-events: none;
  }

  .desktop-sidebar-link {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    border-radius: 0.5rem;
    padding: 0.55rem 0.75rem;
    color: #374151;
    font-size: 0.95rem;
    font-weight: 500;
    transition: background-color 0.15s ease, color 0.15s ease;
  }

  .desktop-sidebar-link:hover {
    background: #f3f4f6;
    color: #111827;
  }

  .desktop-sidebar-link.is-active {
    background: #e0e7ff;
    color: #1e3a8a;
  }

  html.desktop-sidebar-collapsed .desktop-sidebar .desktop-sidebar-link,
  .desktop-sidebar.is-collapsed .desktop-sidebar-link {
    justify-content: center;
    padding-left: 0.5rem;
    padding-right: 0.5rem;
  }

  .desktop-sidebar-icon {
    display: inline-flex;
    width: 1.25rem;
    justify-content: center;
    flex-shrink: 0;
  }
}

.editor-drag-ghost {
  position: fixed;
  z-index: 9999;
  pointer-events: none;
  width: 88px;
  height: 64px;
  border-radius: 8px;
  border: 1px solid #93c5fd;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.18);
  overflow: hidden;
}

.editor-drag-ghost img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.unsaved-guard-sheet {
  position: fixed;
  inset: 0;
  z-index: 2400;
}

.unsaved-guard-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(17, 24, 39, 0.45);
}

.unsaved-guard-panel {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  border-radius: 1rem 1rem 0 0;
  border-top: 1px solid #e5e7eb;
  background: #fff;
  padding: 1rem;
  box-shadow: 0 -10px 28px rgba(0, 0, 0, 0.18);
}

@media (min-width: 640px) {
  .unsaved-guard-panel {
    left: 50%;
    right: auto;
    bottom: 1rem;
    width: min(30rem, calc(100vw - 2rem));
    transform: translateX(-50%);
    border-radius: 0.75rem;
    border: 1px solid #e5e7eb;
  }
}

.unsaved-guard-title {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
  color: #111827;
}

.unsaved-guard-message {
  margin-top: 0.5rem;
  color: #4b5563;
  font-size: 0.875rem;
}

.unsaved-guard-actions {
  margin-top: 1rem;
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
}

trix-editor figure.attachment img,
lexxy-editor img {
  touch-action: none;
}

/* Ensure manual editor attachments stay visible in edit mode across breakpoints. */
trix-editor figure.attachment,
lexxy-editor figure.attachment,
lexxy-editor action-text-attachment {
  display: block;
  max-width: 100%;
}

trix-editor figure.attachment img,
lexxy-editor figure.attachment img,
lexxy-editor action-text-attachment img {
  display: block !important;
  max-width: 100% !important;
  height: auto !important;
}

/* Hide image captions/placeholders for cleaner manual content and editor view. */
lexxy-editor figure.attachment--preview .attachment__caption,
.lexxy-content figure.attachment--preview .attachment__caption,
.manual-content figure.attachment--preview .attachment__caption {
  display: none;
}

/* Persistent attachment sizing classes (used by editor image tools). */
lexxy-editor figure.attachment.attachment--size-100,
.manual-content figure.attachment.attachment--size-100,
.lexxy-content figure.attachment.attachment--size-100 {
  width: 100%;
  max-width: 100%;
}

lexxy-editor figure.attachment.attachment--size-75,
.manual-content figure.attachment.attachment--size-75,
.lexxy-content figure.attachment.attachment--size-75 {
  width: 75%;
  max-width: 100%;
}

lexxy-editor figure.attachment.attachment--size-50,
.manual-content figure.attachment.attachment--size-50,
.lexxy-content figure.attachment.attachment--size-50 {
  width: 50%;
  max-width: 100%;
}
