@import url('https://fonts.googleapis.com/css2?family=Nunito+Sans:ital,opsz,wght@0,6..12,200..1000;1,6..12,200..1000&display=swap');
@import 'components/tiptap_editor.css';
@import 'actiontext.css';

/* Trix Editor Styling */
trix-editor {
  min-height: 300px !important;
  padding: 0.75rem !important;
}

/* Make headings visible in the editor */
trix-editor h1 {
  font-size: 1.8em !important;
  font-weight: bold !important;
  margin-bottom: 0.5em !important;
}

trix-editor h2 {
  font-size: 1.5em !important;
  font-weight: bold !important;
  margin-bottom: 0.5em !important;
}

trix-editor h3 {
  font-size: 1.3em !important;
  font-weight: bold !important;
  margin-bottom: 0.5em !important;
}

trix-editor h4 {
  font-size: 1.1em !important;
  font-weight: bold !important;
  margin-bottom: 0.5em !important;
}

/* Show links properly in the editor */
trix-editor a {
  color: var(--color-violet-500) !important;
  text-decoration: underline !important;
  cursor: pointer !important;
}

trix-editor a:hover {
  color: var(--color-violet-700) !important;
}

/* Show lists properly in editor */
trix-editor ul {
  list-style-type: disc !important;
  padding-left: 2em !important;
  margin-bottom: 1em !important;
}

trix-editor ol {
  list-style-type: decimal !important;
  padding-left: 2em !important;
  margin-bottom: 1em !important;
}

trix-editor li {
  display: list-item !important;
  margin-bottom: 0.3em !important;
}

/* Custom Trix Editor Content Styles */
.trix-content h1 {
  font-size: 1.8em;
  font-weight: bold;
  margin-bottom: 0.5em;
}

.trix-content h2 {
  font-size: 1.5em;
  font-weight: bold;
  margin-bottom: 0.5em;
}

.trix-content h3 {
  font-size: 1.3em;
  font-weight: bold;
  margin-bottom: 0.5em;
}

.trix-content h4 {
  font-size: 1.1em;
  font-weight: bold;
  margin-bottom: 0.5em;
}

/* Links in rendered content */
.trix-content a {
  color: var(--color-violet-500);
  text-decoration: underline;
  cursor: pointer;
}

.trix-content a:hover {
  color: var(--color-violet-700);
}

.trix-content ul {
  list-style-type: disc;
  padding-left: 2em;
  margin-bottom: 1em;
}

.trix-content ol {
  list-style-type: decimal;
  padding-left: 2em;
  margin-bottom: 1em;
}

.trix-content li {
  margin-bottom: 0.3em;
}

/* Fix for Trix toolbar buttons */
.trix-button-group {
  border: 1px solid #bbb;
  border-radius: 3px;
  margin-bottom: 0.5em;
}

.trix-button--icon {
  width: 2.5em;
  height: 1.5em;
}

.chat-feedback-message p{
    margin-bottom: 10px;
}

.chat-feedback-message p:last-child{
    margin-bottom: 0;
}

.animate-pulse {
    animation: var(--animate-pulse);
}

@keyframes pulse {
    50% {
        opacity: 0.5;
    }
}

#noticePopup {
    position: fixed;
    bottom: 1rem;
    right: 1rem;
}

/* Button with loading state */
.with-loading-state {
    position: relative;
    pointer-events: none;
}

.with-loading-state:disabled {
    opacity: 0.7;
    padding-left: 3rem;
}

/* Create the loading spinner with CSS */
.with-loading-state:after {
    content: "";
    position: absolute;
    width: 1rem;
    height: 1rem;
    top: calc(50% - 0.5rem);
    left: 1rem;
    border-radius: 50%;
    border: 2px solid transparent;
    border-top-color: currentColor;
    border-right-color: currentColor;
    animation: button-spinner 0.6s linear infinite;
}

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

/* If you want to fade the text */
.with-loading-state>* {
    opacity: 0.7;
}

.article-content {
    h1, h2, h3, h4, h5 {
        margin-bottom: 1rem;
        margin-top: 1rem;
        font-weight: 600;
    }

    h1 {
        font-size: 2.7rem;
        line-height: 1.2;
        margin-top: 0;
    }

    h2 {
        font-size: 2rem;
    }

    h3 {
        font-size: 1.5rem;
    }

    h4 {
        font-size: 1.25rem;
    }

    h5 {
        font-size: 1rem;
    }

    p {
        margin-bottom: 1rem;
    }

    p:last-child {
        margin-bottom: 0;
    }

    ul, ol{
        margin-bottom: 1rem;
        list-style-type: disc;
        padding-left: 1.5rem;

        li {
            margin-bottom: 0.5rem;
        }

        li:last-child {
            margin-bottom: 0;
        }
    }

    ol {
        list-style-type: decimal;
    }

    ul:last-child, ol:last-child {
        margin-bottom: 0;
    }

    hr {
        margin-bottom: 1rem;
    }

    a {
        color: #8470ff;
        font-weight: 600;
        text-decoration: underline;

        &:hover {
            text-decoration: none;
        }
    }

    img {
        border-radius: 10px;
        box-shadow: 0 0 10px 0 rgba(0, 0, 0, 0.1);
        margin-bottom: 2rem;
    }

    table {
        width: 100%;
        border-collapse: collapse;
        margin-bottom: 2rem;
        
        th,
        td {
            padding-top: 10px;
            padding-right: 10px;
            padding-bottom: 10px;
            padding-left: 10px;
            border: 1px solid #bfc4cd;
            line-height: 1.1em;
            background-color: #f9fafb;
        }
    
        th:not([align]) {
            text-align: inherit;
        }
    }
    
    /* Header element
     * ================================= */
    
    thead {
        th, td {
            background-color: #eee;
        }
    }
}

/* Enhance Trix toolbar appearance */
.trix-button {
  background: none !important;
  border: none !important;
  margin: 0 !important;
  padding: 0.25rem !important;
  opacity: 0.7 !important;
  cursor: pointer !important;
}

.trix-button:hover {
  opacity: 1 !important;
}

.trix-button.trix-active {
  opacity: 1 !important;
  background-color: #e9ecef !important;
}

/* Make the toolbar more prominent */
.trix-toolbar {
  border: 1px solid #ced4da !important;
  padding: 0.5rem !important;
  border-bottom: none !important;
  border-top-left-radius: 0.375rem !important;
  border-top-right-radius: 0.375rem !important;
  background-color: #f8f9fa !important;
}

/* The container for the editor */
.trix-editor-container {
  margin-bottom: 1rem !important;
}

/* Style for heading buttons in toolbar */
button.trix-button[data-trix-attribute^="heading"] {
  width: auto !important;
  padding: 0 6px !important;
  font-weight: bold !important;
  display: inline-block !important;
  margin: 0 2px !important;
  line-height: 1.8 !important;
  border-radius: 3px !important;
}

/* Active state for heading buttons */
button.trix-button[data-trix-attribute^="heading"].trix-active {
  background-color: #d1d5db !important;
  color: #111827 !important;
  opacity: 1 !important;
}

/* Hover state for heading buttons */
button.trix-button[data-trix-attribute^="heading"]:hover {
  background-color: #e5e7eb !important;
}

/* Specific font sizes for each heading button */
button.trix-button[data-trix-attribute="heading1"] {
  font-size: 1rem !important;
}

button.trix-button[data-trix-attribute="heading2"] {
  font-size: 0.9rem !important;
}

button.trix-button[data-trix-attribute="heading3"] {
  font-size: 0.8rem !important;
}

button.trix-button[data-trix-attribute="heading4"] {
  font-size: 0.7rem !important;
}

/* Style images in Trix editor */
trix-editor figure img, 
trix-editor img {
  border-radius: 8px !important;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1) !important;
  max-width: 100% !important;
  margin: 1rem 0 !important;
}

/* Style images in rendered content */
.trix-content figure img,
.trix-content img {
  border-radius: 8px;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.4);
  margin: 1rem 0;
}

/* Ensure GIFs maintain their animation */
.trix-content img[src*=".gif"],
.trix-content figure img[src*=".gif"] {
  image-rendering: auto;
  animation: none;
}

/* Also ensure GIFs work in the editor */
trix-editor img[src*=".gif"] {
  image-rendering: auto !important;
  animation: none !important;
}

/* Hide figcaptions in Trix editor */
trix-editor figcaption {
  display: none !important;
}

.trix-content figcaption {
  display: none !important;
}

/* Video placeholder styles in Trix editor */
trix-editor p:has(strong:contains("📺 [VIDEO:")),
.trix-content p:has(strong:contains("📺 [VIDEO:")) {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  padding: 1rem;
  border-radius: 8px;
  text-align: center;
  font-weight: bold;
  margin: 1rem 0;
  cursor: pointer;
  border: 2px dashed rgba(255, 255, 255, 0.3);
}

/* Alternative approach using attribute selector */
trix-editor strong[textContent*="📺 [VIDEO:"],
.trix-content strong[textContent*="📺 [VIDEO:"] {
  display: block;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  padding: 1rem;
  border-radius: 8px;
  text-align: center;
  font-weight: bold;
  margin: 1rem 0;
  cursor: pointer;
  border: 2px dashed rgba(255, 255, 255, 0.3);
}

/* Fallback: style any text containing video placeholder */
trix-editor *:contains("📺 [VIDEO:"),
.trix-content *:contains("📺 [VIDEO:") {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  padding: 1rem;
  border-radius: 8px;
  text-align: center;
  font-weight: bold;
  margin: 1rem 0;
  cursor: pointer;
  border: 2px dashed rgba(255, 255, 255, 0.3);
}

/* Video embed styles for rendered content */
.trix-content .video-embed {
  position: relative;
  padding-bottom: 56.25%; /* 16:9 aspect ratio */
  height: 0;
  overflow: hidden;
  max-width: 100%;
  margin: 1rem 0;
  border-radius: 8px;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

.trix-content .video-embed iframe {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border: none;
  border-radius: 8px;
}