html {
    scroll-behavior: smooth;
}

body {
    padding-bottom: 5rem;
}

*:focus-visible {
    outline: 2px solid hsl(var(--p));
    outline-offset: 2px;
    border-radius: var(--rounded-btn, 0.5rem);
}

[x-cloak] {
    display: none !important;
}

main.border-x {
    border-color: hsl(var(--b3));
}

/* Animations & Keyframes */
@keyframes highlight-and-fade {
    0% { background-color: hsla(var(--p) / 0.2); }
    100% { background-color: transparent; }
}

@keyframes slide-in-fade {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes slideInFromRight {
    from { opacity: 0; transform: translateX(20px); }
    to { opacity: 1; transform: translateX(0); }
}

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

.highlight-new,
.highlight-new-message {
    animation: highlight-and-fade 3s ease-out;
}

.new-comment-animate {
    animation: slide-in-fade 0.5s ease-out;
}

.animate-message-sent {
    animation: slideInFromRight 0.3s ease-out;
}

.animate-message-received {
    animation: slideInFromLeft 0.3s ease-out;
}

/* Component Styles */
.dropdown-content-glass {
    background-color: hsla(var(--b2) / 0.6);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid hsla(var(--b3) / 0.3);
}

.auth-left-pane {
    color: hsl(var(--pc));
    background: linear-gradient(45deg, hsl(var(--p)), hsl(var(--a)));
    padding: 2rem;
    display: flex;
    flex-direction: column;
    justify-content: center;
    text-align: center;
}

.auth-left-pane i {
    font-size: 3rem;
    margin-bottom: 1rem;
}

.chat-bubble {
    overflow: visible;
}

.lg-sidebar-scroll {
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    -ms-overflow-style: none;
    scrollbar-width: none;
}

.lg-sidebar-scroll::-webkit-scrollbar {
    display: none;
}

/* Utility Styles */
.break-words {
    overflow-wrap: break-word;
    word-wrap: break-word;
    word-break: break-word;
}

.aspect-w-16 {
    position: relative;
    padding-bottom: 56.25%;
}

.aspect-h-9 > * {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

.prose-fade::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 5rem;
    background: linear-gradient(to top, hsl(var(--b1)), transparent);
    pointer-events: none;
}

/* Prose (Markdown) Styles */
.prose {
    overflow-wrap: break-word;
    word-wrap: break-word;
    word-break: break-word;
    color: hsl(var(--bc));
    line-height: 1.7;
    max-width: 100%;
}

.prose h1, .prose h2, .prose h3, .prose h4, .prose h5, .prose h6 {
    color: hsl(var(--bc));
    line-height: 1.3;
    margin-top: 1.5em;
    margin-bottom: 0.75em;
}

.prose h1 {
    font-size: 2.25em;
    font-weight: 800;
    padding-bottom: 0.3em;
    border-bottom: 2px solid hsl(var(--b3));
}

.prose h2 {
    font-size: 1.8em;
    font-weight: 700;
    padding-bottom: 0.3em;
    border-bottom: 1px solid hsl(var(--b3));
}

.prose h3 {
    font-size: 1.5em;
    font-weight: 600;
}

.prose h4 {
    font-size: 1.25em;
    font-weight: 600;
}

.prose h5, .prose h6 {
    font-size: 1.1em;
    font-weight: 600;
    color: hsla(var(--bc) / 0.85);
}

.prose p {
    margin-top: 0;
    margin-bottom: 1.25em;
}

.prose a {
    color: #5865F2;
    text-decoration: underline;
    text-underline-offset: 3px;
    text-decoration-thickness: 1px;
    transition: color 0.2s ease-in-out;
    font-weight: 500;
}

.prose a:hover {
    color: #434ed1;
}

html[data-theme="dark"] .prose a {
    color: #7289da;
}

html[data-theme="dark"] .prose a:hover {
    color: #99aab5;
}

.prose strong {
    font-weight: 700;
    color: hsl(var(--bc));
}

.prose ul, .prose ol {
    margin-top: 1.25em;
    margin-bottom: 1.25em;
    padding-left: 1.75rem;
}

.prose ul { list-style-type: disc; }
.prose ol { list-style-type: decimal; }
.prose li { margin-top: 0.5em; margin-bottom: 0.5em; }

.prose blockquote {
    background-color: #f3f4f6;
    color: #374151;
    padding: 15px 20px !important;
    margin: 1em 0 !important;
    border-radius: 4px !important;
    border-left: 4px solid #7289da !important;
    border-right: none !important;
    font-style: italic;
}

.prose blockquote p {
    margin: 0;
}

html[data-theme="dark"] .prose blockquote {
    background-color: #2f3136 !important;
    color: #ffffff !important;
}

html[dir="rtl"] .prose blockquote {
    border-left: none !important;
    border-right: 4px solid #7289da !important;
}

.prose pre {
    background-color: #f3f4f6 !important;
    color: #111827 !important;
    border: 1px solid #d1d5db !important;
    border-radius: 6px !important;
    padding: 15px !important;
    overflow-x: auto !important;
    font-size: 0.875rem;
    line-height: 1.71;
    margin-top: 1.5em;
    margin-bottom: 1.5em;
}

.prose code {
    background-color: #e5e7eb !important;
    color: #be123c !important;
    padding: 3px 6px !important;
    border-radius: 3px !important;
    font-family: Consolas, "Liberation Mono", Courier, monospace !important;
    font-weight: 600;
}
.prose code::before, .prose code::after { content: ""; }

.prose pre code {
    background-color: transparent !important;
    color: inherit !important;
    padding: 0 !important;
    font-weight: normal;
}

.prose kbd {
    background-color: #e5e7eb !important;
    color: #374151 !important;
    border: 1px solid #d1d5db !important;
    box-shadow: 0 2px 0 0 #9ca3af !important;
    padding: 2px 6px !important;
    border-radius: 3px !important;
    font-family: sans-serif !important;
    font-size: 0.9em !important;
    white-space: nowrap !important;
}

html[data-theme="dark"] .prose pre {
    background-color: #282c34 !important;
    color: #abb2bf !important;
    border: 1px solid #3e4451 !important;
}

html[data-theme="dark"] .prose code {
    background-color: #3e4451 !important;
    color: #d19a66 !important;
}

html[data-theme="dark"] .prose pre code {
    background-color: transparent !important;
    color: inherit !important;
}

html[data-theme="dark"] .prose kbd {
    background-color: #3e4451 !important;
    color: #abb2bf !important;
    border: 1px solid #5a6272 !important;
    box-shadow: 0 2px 0 0 #5a6272 !important;
}

.prose table {
    width: 100%;
    table-layout: auto;
    text-align: left;
    margin-top: 2em;
    margin-bottom: 2em;
    font-size: 0.875rem;
    line-height: 1.71;
}

.prose thead {
    border-bottom: 2px solid hsl(var(--b3));
    color: hsl(var(--bc));
    font-weight: 600;
}

.prose tbody tr {
    border-bottom: 1px solid hsl(var(--b3));
}

.prose th, .prose td {
    padding: 0.5rem 1rem;
}

.prose-sm {
    font-size: 0.875rem;
    line-height: 1.5;
}

/* Third-party Plugin Styles: EasyMDE */
.EasyMDEContainer .CodeMirror {
    background-color: #ffffff !important;
    color: #1f2937 !important;
    border-color: #e5e7eb !important;
}

.EasyMDEContainer .editor-toolbar {
    background-color: #f9fafb;
    border-color: #e5e7eb;
    position: -webkit-sticky;
    position: sticky;
    top: 68px; 
    z-index: 25; 
}

.EasyMDEContainer .editor-toolbar button {
    color: #4b5563;
}

.EasyMDEContainer .editor-toolbar button:hover,
.EasyMDEContainer .editor-toolbar button.active {
    background: #e5e7eb;
    border-color: #d1d5db;
}

.EasyMDEContainer .editor-toolbar i.separator {
    border-left-color: #e5e7eb;
    border-right-color: #f9fafb;
}

.EasyMDEContainer .editor-preview,
.EasyMDEContainer .editor-preview-side {
    background-color: #ffffff !important;
}

/* Ensure prose inside the preview is always styled for a light background */
.EasyMDEContainer .editor-preview .prose,
.EasyMDEContainer .editor-preview-side .prose {
    color: #374151 !important;
}
.EasyMDEContainer .editor-preview .prose h1, .EasyMDEContainer .editor-preview-side .prose h1,
.EasyMDEContainer .editor-preview .prose h2, .EasyMDEContainer .editor-preview-side .prose h2,
.EasyMDEContainer .editor-preview .prose h3, .EasyMDEContainer .editor-preview-side .prose h3,
.EasyMDEContainer .editor-preview .prose h4, .EasyMDEContainer .editor-preview-side .prose h4,
.EasyMDEContainer .editor-preview .prose h5, .EasyMDEContainer .editor-preview-side .prose h5,
.EasyMDEContainer .editor-preview .prose h6, .EasyMDEContainer .editor-preview-side .prose h6 {
    color: #111827 !important;
}
.EasyMDEContainer .editor-preview .prose a, .EasyMDEContainer .editor-preview-side .prose a {
    color: #2563eb !important;
}
.EasyMDEContainer .editor-preview .prose strong, .EasyMDEContainer .editor-preview-side .prose strong {
    color: #111827 !important;
}
.EasyMDEContainer .editor-preview .prose code, .EasyMDEContainer .editor-preview-side .prose code {
    color: #be123c !important;
    background-color: #fee2e2 !important;
}
.EasyMDEContainer .editor-preview .prose blockquote, .EasyMDEContainer .editor-preview-side .prose blockquote {
    border-left-color: #d1d5db !important;
    color: #6b7280 !important;
}
.EasyMDEContainer .editor-preview .prose pre, .EasyMDEContainer .editor-preview-side .prose pre {
    background-color: #f3f4f6 !important;
    color: #111827 !important;
}


/* Fullscreen and Dark Mode overrides for Editor */
.CodeMirror-fullscreen {
    z-index: 1000 !important;
    top: 0; left: 0; right: 0; bottom: 0;
    height: auto; width: auto;
}

.editor-toolbar.fullscreen {
    position: fixed !important;
    top: 0 !important;
    z-index: 1001 !important;
}

html[data-theme="dark"] .EasyMDEContainer .editor-toolbar {
    background-color: hsl(var(--b3)) !important; /* Match dark theme background for sticky state */
}


/* Third-party Plugin Styles: Plyr.js */
.plyr--video .plyr__menu,
.plyr--audio .plyr__menu {
    z-index: 2;
}

html[data-theme="dark"] .plyr--audio .plyr__controls {
    background-color: hsl(var(--b2));
    color: hsl(var(--bc));
    border-top: 1px solid hsl(var(--b3));
}

html[data-theme="dark"] .plyr--audio .plyr__controls button,
html[data-theme="dark"] .plyr--audio .plyr__controls button svg {
    color: hsl(var(--bc));
    fill: hsl(var(--bc));
}

html[data-theme="dark"] .plyr--audio .plyr__controls button:hover,
html[data-theme="dark"] .plyr--audio .plyr__controls button:focus {
    background-color: hsl(var(--b3));
    color: hsl(var(--p));
}

html[data-theme="dark"] .plyr--audio .plyr__controls button:hover svg,
html[data-theme="dark"] .plyr--audio .plyr__controls button:focus svg {
    fill: hsl(var(--p));
}

html[data-theme="dark"] .plyr__progress input[type=range],
html[data-theme="dark"] .plyr__volume input[type=range] {
    color: hsl(var(--p));
}

html[data-theme="dark"] .plyr__progress__buffer {
    background-color: hsla(var(--bc) / 0.1);
}

html[data-theme="dark"] .plyr__tooltip {
    background: hsl(var(--n));
    color: hsl(var(--nc));
    border-radius: var(--rounded-btn, 0.5rem);
}

.plyr__menu__container {
    background: hsl(var(--b2));
    border-radius: var(--rounded-box, 1rem);
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    color: hsl(var(--bc));
    padding: 0.5rem;
}

.plyr__menu__container .plyr__control {
    width: 100%;
    text-align: left;
    padding: 0.5rem 1rem;
    border-radius: var(--rounded-btn, 0.5rem);
    background-color: transparent;
    transition: background-color 0.2s ease-in-out;
}

.plyr__menu__container .plyr__control:hover {
    background-color: hsl(var(--b3));
}

.plyr__menu__container .plyr__control--radio[aria-checked=true] {
    background-color: hsl(var(--p));
    color: hsl(var(--pc));
}

.plyr__menu__container .plyr__control--radio::before {
    background-color: hsl(var(--b1));
    border: 1px solid hsl(var(--bc) / 0.2);
    box-shadow: none;
}

.plyr__menu__container .plyr__control--radio[aria-checked=true]::before {
    background-color: hsl(var(--pc));
}

.plyr__menu__container .plyr__control--radio[aria-checked=true]::after {
    background-color: hsl(var(--p));
}

/* Responsive Styles */
@media (min-width: 1024px) {
    body {
        padding-bottom: 0;
    }
}

@media (max-width: 480px) {
    .plyr__controls .plyr__progress__container {
        flex-grow: 1 !important;
        margin-left: 5px !important;
        margin-right: 5px !important;
    }

    .plyr__controls {
        padding-left: 5px !important;
        padding-right: 5px !important;
    }

    .plyr__controls input[data-plyr="volume"] {
        display: none !important;
    }
    
    .plyr__controls button[data-plyr="mute"] {
        display: inline-block !important;
    }

    .plyr__time {
        font-size: 12px !important;
    }
}