.line-clamp-3 {
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Custom Scrollbar for Webkit */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: #f8fafc;
}

::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* Animations */
.section {
    animation: fadeIn 0.3s ease-in-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Clean section headers — no numbered badge */
.form-section-title {
    font-size: 0.95rem;
    font-weight: 600;
    color: #1e293b;
    padding-bottom: 0.75rem;
    margin-bottom: 1rem;
    border-bottom: 1px solid #e2e8f0;
    position: relative;
    padding-left: 0.75rem;
}

.form-section-title .num {
    width: 1.5rem;
    height: 1.5rem;
    border-radius: 9999px;
    background: #128C7E;
    color: #fff;
    font-size: 0.75rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.form-section-title::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0.15rem;
    bottom: 0.9rem;
    width: 3px;
    border-radius: 2px;
    background: var(--tw-color-primary, #128C7E);
}

/* Toggle switch (used in place of plain checkboxes throughout the editor) */
.switch {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    user-select: none;
}

.switch input {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.dropzone {
    border: 2px dashed #cbd5e1;
    border-radius: 0.5rem;
    padding: 1.5rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
}

.dropzone:hover {
    border-color: #128C7E;
    background: #eff6ff;
}

.attachment-preview img,
.attachment-preview video {
    width: 3.5rem;
    height: 3.5rem;
    object-fit: cover;
    border-radius: 0.375rem;
    border: 1px solid #e2e8f0;
}

.switch .track {
    width: 2.25rem;
    height: 1.25rem;
    background: #cbd5e1;
    border-radius: 9999px;
    transition: background-color 0.15s ease;
    flex-shrink: 0;
}

.switch .track::after {
    content: '';
    display: block;
    width: 1rem;
    height: 1rem;
    margin: 0.125rem;
    background: #fff;
    border-radius: 9999px;
    transition: transform 0.15s ease;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

.switch input:checked+.track {
    background: var(--tw-color-primary, #128C7E);
}

.switch input:checked+.track::after {
    transform: translateX(1rem);
}

.switch input:focus-visible+.track {
    outline: 2px solid var(--tw-color-primary, #128C7E);
    outline-offset: 2px;
}

/* Multi-select dropdown for label picker */
.multiselect-panel {
    max-height: 14rem;
    overflow-y: auto;
}

/* Shared "drop design" — a styled button + floating panel used for every single-select
       field in the editor, instead of a plain native <select>. */
.dd-btn {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    background: #fff;
    border: 1px solid #cbd5e1;
    border-radius: 0.5rem;
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    color: #1e293b;
    text-align: left;
    transition: border-color 0.15s ease;
}

.dd-btn:hover,
.dd-btn:focus-visible {
    border-color: var(--tw-color-primary, #128C7E);
    outline: none;
}

/* Smaller variant used inside reminder rows / secondary fields */
.dd-btn-sm {
    padding: 0.5rem 0.75rem;
    font-size: 0.875rem;
}

.dd-panel {
    position: absolute;
    z-index: 20;
    margin-top: 0.25rem;
    width: 100%;
    max-height: 14rem;
    overflow-y: auto;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 0.5rem;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
    padding: 0.25rem 0;
}

.dd-option {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    font-size: 0.875rem;
    color: #334155;
    cursor: pointer;
}

.dd-option:hover {
    background: #f8fafc;
}

.dd-option.is-selected {
    background: #f8fafc;
    color: var(--tw-color-primary, #128C7E);
    font-weight: 500;
}

.dd-empty {
    padding: 0.5rem 0.75rem;
    font-size: 0.75rem;
    color: #94a3b8;
}

/* Attachment previews */
.attach-tile {
    position: relative;
    width: 4.5rem;
    height: 4.5rem;
    border-radius: 0.5rem;
    overflow: hidden;
    border: 1px solid #e2e8f0;
    background: #f8fafc;
    flex-shrink: 0;
}

/* Force attachment previews to fully fill their tile via plain CSS rather than
       relying only on the w-full/h-full/object-cover Tailwind utility classes on the
       <img>/<video> tags. If this template's file type isn't picked up by Tailwind's
       content scanner, those utility classes get purged from the build and the media
       falls back to its natural size — a small picture sitting inside an otherwise
       correctly-sized empty tile. This rule guarantees the fill regardless of that. */
.attach-tile img,
.attach-tile video {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

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

.attach-remove {
    position: absolute;
    top: -0.25rem;
    right: -0.25rem;
    background: #dc2626;
    color: #fff;
    border-radius: 9999px;
    width: 1.1rem;
    height: 1.1rem;
    font-size: 0.7rem;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.15s ease;
}

.group:hover .attach-remove {
    opacity: 1;
}

.video-play-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(15, 23, 42, 0.35);
    cursor: pointer;
}

.pending-chip {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.25rem 0.5rem;
    background: #fff7ed;
    border: 1px solid #fed7aa;
    color: #9a3412;
    border-radius: 0.375rem;
    font-size: 0.75rem;
}

/* ---- WhatsApp-style green theme, scoped to this page ---- */
/* Sets the shared --tw-color-primary var (already read by .form-section-title,
       .switch, .dd-btn, etc. above) so this page's own accent CSS turns green too. */
#page-root {
    --tw-color-primary: #128C7E;
    --tw-color-primary-hover: #075E54;
}

/* Tailwind's `bg-primary` / `text-primary` / `border-primary` / `ring-primary` /
       `hover:bg-primaryHover` utilities are re-pointed explicitly (rather than relying
       purely on the CSS var above) so the theme holds regardless of how those utilities
       are wired in the global Tailwind config. */
#page-root .bg-primary {
    background-color: #128C7E !important;
}

#page-root .hover\:bg-primaryHover:hover {
    background-color: #075E54 !important;
}

#page-root .text-primary {
    color: #0d6e62 !important;
}

#page-root .border-primary,
#page-root .hover\:border-primary:hover,
#page-root .focus\:border-primary:focus {
    border-color: #128C7E !important;
}

#page-root .focus\:ring-primary:focus,
#page-root .ring-primary {
    --tw-ring-color: #128C7E !important;
}

/* Pagination controls */
.page-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 2rem;
    height: 2rem;
    padding: 0 0.5rem;
    border-radius: 0.5rem;
    border: 1px solid #cbd5e1;
    background: #fff;
    color: #334155;
    font-size: 0.8rem;
    font-weight: 500;
    transition: all 0.15s ease;
}

.page-btn:hover:not(:disabled) {
    border-color: #128C7E;
    color: #075E54;
    background: #f0fdfa;
}

.page-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* Skeleton loading rows for the flow list */
.skeleton-bar {
    height: 0.75rem;
    border-radius: 0.25rem;
    background: linear-gradient(90deg, #f1f5f9 25%, #e2e8f0 37%, #f1f5f9 63%);
    background-size: 400% 100%;
    animation: skeleton-shimmer 1.4s ease infinite;
}

@keyframes skeleton-shimmer {
    0% {
        background-position: 100% 50%;
    }

    100% {
        background-position: 0 50%;
    }
}

.spin {
    animation: spin 0.7s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* ---- Editor sections as clean, evenly-spaced cards ---- */
.form-section {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 0.75rem;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
}

/* Soft info/callout panel — used for the AI-driven config blocks (Extract, AI notice)
       so they read as "AI assisted" without breaking from the page's green theme. */
.ai-callout {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    background: rgba(18, 140, 126, 0.06);
    border: 1px solid rgba(18, 140, 126, 0.2);
    border-radius: 0.5rem;
    padding: 0.625rem 0.75rem;
}

/* Small pill used for "insert field" chips — a lighter tint of the theme so they
       read as a secondary action next to the primary buttons. */
.field-chip {
    display: inline-flex;
    align-items: center;
    padding: 0.125rem 0.5rem;
    background: rgba(18, 140, 126, 0.08);
    color: #0d6e62;
    border: 1px solid rgba(18, 140, 126, 0.25);
    border-radius: 0.375rem;
    font-size: 0.75rem;
    cursor: grab;
}

.field-chip:hover {
    background: rgba(18, 140, 126, 0.15);
}

.field-chip:active {
    cursor: grabbing;
}

/* Pagination page-size dropdown trigger — a compact variant of .dd-btn */
.dd-btn-xs {
    padding: 0.375rem 0.6rem;
    font-size: 0.8rem;
    width: auto;
    min-width: 4.5rem;
}