/* CMS TipTap Editor Styles */

.cms-editor-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.25rem;
    padding: 0.375rem 0.5rem;
    border: 1px solid oklch(var(--bc) / 0.2);
    border-bottom: none;
    border-radius: var(--rounded-btn, 0.5rem) var(--rounded-btn, 0.5rem) 0 0;
    background: oklch(var(--b2));
}

.cms-editor-content {
    border: 1px solid oklch(var(--bc) / 0.2);
    border-radius: 0 0 var(--rounded-btn, 0.5rem) var(--rounded-btn, 0.5rem);
    min-height: 200px;
    padding: 1rem;
    cursor: text;
}

.cms-editor-content:focus-within {
    border-color: oklch(var(--p));
    outline: 1px solid oklch(var(--p));
}

/* ProseMirror editor element */
.cms-editor-content .tiptap {
    outline: none;
    min-height: 180px;
}

.cms-editor-content .tiptap > * + * {
    margin-top: 0.75em;
}

/* Typography */
.cms-editor-content .tiptap h2 {
    font-size: 1.5em;
    font-weight: 700;
    line-height: 1.3;
}

.cms-editor-content .tiptap h3 {
    font-size: 1.25em;
    font-weight: 600;
    line-height: 1.35;
}

.cms-editor-content .tiptap h4 {
    font-size: 1.1em;
    font-weight: 600;
    line-height: 1.4;
}

.cms-editor-content .tiptap ul {
    list-style-type: disc;
    padding-left: 1.5em;
}

.cms-editor-content .tiptap ol {
    list-style-type: decimal;
    padding-left: 1.5em;
}

.cms-editor-content .tiptap li > ul,
.cms-editor-content .tiptap li > ol {
    margin-top: 0.25em;
}

.cms-editor-content .tiptap blockquote {
    border-left: 3px solid oklch(var(--bc) / 0.3);
    padding-left: 1em;
    font-style: italic;
}

.cms-editor-content .tiptap code {
    background: oklch(var(--b2));
    padding: 0.15em 0.3em;
    border-radius: 0.25em;
    font-size: 0.9em;
}

.cms-editor-content .tiptap pre {
    background: oklch(var(--b2));
    padding: 1em;
    border-radius: 0.5em;
    overflow-x: auto;
}

.cms-editor-content .tiptap pre code {
    background: none;
    padding: 0;
}

.cms-editor-content .tiptap a {
    color: oklch(var(--p));
    text-decoration: underline;
}

.cms-editor-content .tiptap img {
    max-width: 100%;
    height: auto;
    border-radius: 0.25em;
}

.cms-editor-content .tiptap img.ProseMirror-selectednode {
    outline: 2px solid oklch(var(--p));
    outline-offset: 2px;
}

.cms-editor-content .tiptap hr {
    border: none;
    border-top: 2px solid oklch(var(--bc) / 0.15);
    margin: 1.5em 0;
}

/* ============================================================
   Widget - Editor
   ============================================================ */

/* Placeholder block shown inside the TipTap editor */
.cms-widget-placeholder {
    border: 2px dashed oklch(var(--bc) / 0.2);
    border-radius: 0.5rem;
    padding: 0.5rem 0.75rem;
    margin: 0.75em 0;
    background: oklch(var(--b2));
    cursor: default;
}

.cms-widget-placeholder-inner {
    font-size: 0.85em;
    font-weight: 600;
    color: oklch(var(--bc) / 0.4);
    text-align: center;
}

/* Iframe placeholder in editor */
.cms-iframe-placeholder {
    border: 2px dashed oklch(var(--bc) / 0.2);
    border-radius: 0.5rem;
    padding: 1rem;
    margin: 0.75em 0;
    background: oklch(var(--b2));
    text-align: center;
    cursor: default;
}

.cms-iframe-placeholder-label {
    font-size: 0.85em;
    font-weight: 600;
    color: oklch(var(--bc) / 0.4);
}

/* Widget editor panel below the WYSIWYG */
.cms-widget-panel {
    margin-top: 0.5rem;
}

.cms-widget-editor {
    border: 1px solid oklch(var(--bc) / 0.2);
    border-radius: 0.5rem;
    padding: 0.75rem;
    margin-bottom: 0.5rem;
    background: oklch(var(--b2));
}

.carousel-editor-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.carousel-editor-toggle {
    background: none;
    border: none;
    cursor: pointer;
    font-weight: 700;
    font-size: 0.85em;
    color: oklch(var(--bc) / 0.5);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 0;
}

.carousel-editor-toggle:hover {
    color: oklch(var(--bc) / 0.7);
}

.carousel-editor-body {
    margin-top: 0.5rem;
}

.carousel-editor-title {
    font-weight: 700;
    font-size: 0.85em;
    color: oklch(var(--bc) / 0.5);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.carousel-editor-settings {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    align-items: center;
    margin-bottom: 0.75rem;
    padding: 0.5rem;
    background: oklch(var(--b1));
    border-radius: 0.25rem;
}

.carousel-editor-settings label {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.8em;
    color: oklch(var(--bc) / 0.7);
}

.carousel-editor-checkbox {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.carousel-editor-add {
    width: 100%;
    margin-bottom: 0.5rem;
    border: 1px dashed oklch(var(--bc) / 0.3);
}

.carousel-editor-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 0.5rem;
}

.carousel-image-card {
    border: 1px solid oklch(var(--bc) / 0.15);
    border-radius: 0.375rem;
    padding: 0.375rem;
    background: oklch(var(--b1));
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.carousel-image-thumb {
    width: 100%;
    height: 90px;
    object-fit: cover;
    border-radius: 0.25rem;
}

.carousel-image-controls {
    display: flex;
    justify-content: center;
    gap: 0.125rem;
}

/* ============================================================
   Carousel - Public Rendering
   ============================================================ */

.cms-carousel {
    position: relative;
    width: 100%;
    overflow: hidden;
    border-radius: 0.5em;
}

.cms-carousel-track {
    position: relative;
    min-height: 300px;
}

/* Fade animation (default) */
.cms-carousel .carousel-item {
    display: none;
    width: 100%;
    text-align: center;
}

.cms-carousel .carousel-item.active {
    display: block;
    animation: carouselFadeIn 0.5s ease-in-out;
}

/* Slide animation */
.cms-carousel-track.cms-carousel-slide {
    display: flex;
    transition: transform 0.5s ease-in-out;
    min-height: auto;
}

.cms-carousel-track.cms-carousel-slide .carousel-item {
    display: block;
    flex: 0 0 100%;
}

.cms-carousel .carousel-item figure {
    margin: 0;
}

.cms-carousel .carousel-item img {
    max-width: 100%;
    max-height: 500px;
    height: auto;
    margin: 0 auto;
    border-radius: 0.25em;
}

.cms-carousel .carousel-item figcaption {
    margin-top: 0.5em;
    font-size: 0.9em;
    color: oklch(var(--bc) / 0.6);
    text-align: center;
}

.cms-carousel-indicators {
    display: flex;
    justify-content: center;
    gap: 0.5em;
    padding: 1em 0;
}

.cms-carousel-indicators .carousel-indicator {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    border: none;
    background: oklch(var(--bc) / 0.2);
    cursor: pointer;
    padding: 0;
    transition: background 0.2s;
}

.cms-carousel-indicators .carousel-indicator.active {
    background: oklch(var(--p));
}

@keyframes carouselFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* ============================================================
   Placeholder
   ============================================================ */

.cms-editor-content .tiptap p.is-editor-empty:first-child::before {
    content: attr(data-placeholder);
    float: left;
    color: oklch(var(--bc) / 0.35);
    pointer-events: none;
    height: 0;
}
