/* ========================================
   CUSTOM BUILDER STYLES
   Elementor-compatible CSS for custom builder blocks
   ======================================== */

/* ========================================
   CONTAINER STYLES
   ======================================== */

.custom-builder-container {
    width: 100%;
    display: flex;
    flex-direction: column;
    --cb-heading-h1: clamp(2.5rem, calc(1.5rem + 2vw), 3.5rem);
    --cb-heading-h2: clamp(2.125rem, calc(1.35rem + 1.6vw), 3rem);
    --cb-heading-h3: clamp(1.75rem, calc(1.15rem + 1.3vw), 2.5rem);
    --cb-heading-h4: clamp(1.5rem, calc(1rem + 1vw), 2rem);
    --cb-heading-h5: clamp(1.25rem, calc(0.9rem + 0.8vw), 1.6rem);
    --cb-heading-h6: clamp(1.0625rem, calc(0.85rem + 0.6vw), 1.25rem);
    --cb-heading-size-xl: clamp(2.25rem, calc(1.35rem + 1.8vw), 3rem);
    --cb-heading-size-lg: clamp(1.75rem, calc(1.1rem + 1.4vw), 2.25rem);
    --cb-heading-size-md: clamp(1.35rem, calc(0.95rem + 1vw), 1.75r~em);
    --cb-heading-size-sm: clamp(1.1rem, calc(0.85rem + 0.7vw), 1.35rem);
    --cb-rich-h1: clamp(2rem, calc(1.2rem + 1.4vw), 2.6rem);
    --cb-rich-h2: clamp(1.75rem, calc(1.1rem + 1.1vw), 2.2rem);
    --cb-rich-h3: clamp(1.5rem, calc(1rem + 0.9vw), 1.85rem);
    --cb-rich-h4: clamp(1.25rem, calc(0.9rem + 0.7vw), 1.55rem);
    --cb-rich-h5: clamp(1.125rem, calc(0.85rem + 0.5vw), 1.35rem);
    --cb-rich-h6: clamp(1rem, calc(0.8rem + 0.4vw), 1.2rem);
}

/* Max Width Variants */
.custom-builder-container.container-full {
    position: relative;
    width: 100vw;
    max-width: 100vw;
    margin: 0;
    left: 50%;
    right: 50%;
    transform: translateX(-50%);
}

.custom-builder-container.container-container-fluid {
    max-width: 100%;
    margin: 0 auto;
}

.custom-builder-container.container-container {
    max-width: 1200px;
    margin: 0 auto;
}

.custom-builder-container.container-container-wide {
    max-width: 1440px;
    margin: 0 auto;
}

.custom-builder-container.container-container-xxl {
    max-width: 1600px;
    margin: 0 auto;
}

.custom-builder-container.container-container-narrow {
    max-width: 960px;
    margin: 0 auto;
}

.custom-builder-container.container-sm {
    max-width: 640px;
    margin: 0 auto;
}

.custom-builder-container.container-md {
    max-width: 768px;
    margin: 0 auto;
}

.custom-builder-container.container-lg {
    max-width: 1024px;
    margin: 0 auto;
}

.custom-builder-container.container-xl {
    max-width: 1280px;
    margin: 0 auto;
}

/* Padding Variants */
.custom-builder-container.p-none {
    padding: 0;
}

.custom-builder-container.p-sm {
    padding: 0.5rem;
}

.custom-builder-container.p-md {
    padding: 1rem;
}

.custom-builder-container.p-lg {
    padding: 2rem;
}

.custom-builder-container.p-xl {
    padding: 3rem;
}

/* Background Variants */
.custom-builder-container.bg-white {
    background-color: #ffffff;
}

.custom-builder-container.bg-gray {
    background-color: #f3f4f6;
}

.custom-builder-container.bg-light {
    background-color: #f9fafb;
}

.custom-builder-container.bg-dark {
    background-color: #1f2937;
}

/* Text Alignment */
.custom-builder-container.text-left {
    text-align: left;
}

.custom-builder-container.text-center {
    text-align: center;
}

.custom-builder-container.text-right {
    text-align: right;
}

/* ========================================
   ROW STYLES (GRID LAYOUT)
   ========================================*/

.custom-builder-row {
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    width: 100%;
}

/* Gap Variants */
.custom-builder-row.gap-none {
    gap: 0;
}

.custom-builder-row.gap-sm {
    gap: 0.5rem;
}

.custom-builder-row.gap-md {
    gap: 1rem;
}

.custom-builder-row.gap-lg {
    gap: 2rem;
}

/* ========================================
   COLUMN STYLES
   ======================================== */

.custom-builder-column {
    display: flex;
    flex-direction: column;
}

/* Width Variants (12-column grid) */
.custom-builder-column.col-12 {
    grid-column: span 12;
}

.custom-builder-column.col-6 {
    grid-column: span 6;
}

.custom-builder-column.col-4 {
    grid-column: span 4;
}

.custom-builder-column.col-3 {
    grid-column: span 3;
}

.custom-builder-column.col-8 {
    grid-column: span 8;
}

.custom-builder-column.col-9 {
    grid-column: span 9;
}

/* ========================================
   HEADING STYLES
   ======================================== */

.custom-heading {
    margin: 1rem 0;
    font-family: inherit;
    line-height: 1.2;
    text-align: left;
}

.custom-heading:is(h1) {
    font-size: var(--cb-heading-h1);
    line-height: 1.2;
}

.custom-heading:is(h2) {
    font-size: var(--cb-heading-h2);
    line-height: 1.25;
}

.custom-heading:is(h3) {
    font-size: var(--cb-heading-h3);
    line-height: 1.35;
}

.custom-heading:is(h4) {
    font-size: var(--cb-heading-h4);
    line-height: 1.4;
}

.custom-heading:is(h5) {
    font-size: var(--cb-heading-h5);
    line-height: 1.45;
}

.custom-heading:is(h6) {
    font-size: var(--cb-heading-h6);
    line-height: 1.5;
}

/* Color Variants */
.custom-heading.text-primary {
    color: #0066ff;
}

.custom-heading.text-secondary {
    color: #6c757d;
}

.custom-heading.text-text {
    color: #333;
}

.custom-heading.text-gray {
    color: #6b7280;
}

/* Size Variants */
.custom-heading.text-sm {
    font-size: var(--cb-heading-size-sm);
    line-height: 1.3;
}

.custom-heading.text-md {
    font-size: var(--cb-heading-size-md);
    line-height: 1.3;
}

.custom-heading.text-lg {
    font-size: var(--cb-heading-size-lg);
    line-height: 1.2;
}

.custom-heading.text-xl {
    font-size: var(--cb-heading-size-xl);
    line-height: 1.2;
}

/* Weight Variants */
.custom-heading.font-bold {
    font-weight: bold;
}

/* ========================================
   TEXT STYLES
   ======================================== */

.custom-text {
    margin: 0.5rem 0;
    line-height: 1.6;
    font-size: 1rem;
}

/* TinyMCE Accordion Styling */
.custom-text details.mce-accordion,
.custom-builder-container details.mce-accordion {
    border: 1px solid #e2e8f0;
    border-radius: 16px;
    margin: 1rem 0;
    background: #ffffff;
    box-shadow: 0 10px 30px rgba(15, 23, 42, 0.08);
    overflow: hidden;
    transition: box-shadow 0.2s ease, border-color 0.2s ease;
}

.custom-text details.mce-accordion:not(:first-of-type),
.custom-builder-container details.mce-accordion:not(:first-of-type) {
    margin-top: 1.25rem;
}

.custom-text details.mce-accordion summary,
.custom-builder-container details.mce-accordion summary {
    list-style: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.85rem;
    padding: 1rem 1.25rem;
    font-weight: 600;
    color: #0f172a;
    background: linear-gradient(135deg, #f8fafc, #edf2f7);
    transition: background 0.2s ease, color 0.2s ease;
    position: relative;
}

.custom-text details.mce-accordion summary::-webkit-details-marker,
.custom-builder-container details.mce-accordion summary::-webkit-details-marker {
    display: none;
}

.custom-text details.mce-accordion summary::after,
.custom-builder-container details.mce-accordion summary::after {
    content: '';
    width: 0.65rem;
    height: 0.65rem;
    border-right: 2px solid currentColor;
    border-bottom: 2px solid currentColor;
    transform: rotate(45deg);
    transition: transform 0.2s ease;
}

.custom-text details.mce-accordion[open] summary,
.custom-builder-container details.mce-accordion[open] summary {
    background: linear-gradient(135deg, #dbeafe, #d9f4ff);
    color: #0c4a6e;
}

.custom-text details.mce-accordion[open] summary::after,
.custom-builder-container details.mce-accordion[open] summary::after {
    transform: rotate(225deg);
}

.custom-text details.mce-accordion>*:not(summary),
.custom-builder-container details.mce-accordion>*:not(summary) {
    padding: 1.1rem 1.35rem 1.25rem;
    border-top: 1px solid #e2e8f0;
    background: #ffffff;
    animation: cb-accordion-fade 0.25s ease;
    margin-bottom: 0;
}

.custom-text details.mce-accordion p:last-child,
.custom-builder-container details.mce-accordion p:last-child {
    margin-bottom: 0;
}

@keyframes cb-accordion-fade {
    from {
        opacity: 0;
        transform: translateY(-6px);
    }

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

.custom-text h1 {
    font-size: var(--cb-rich-h1) !important;
    line-height: 1.25;
    text-align: left;
}

.custom-text h2 {
    font-size: var(--cb-rich-h2) !important;
    line-height: 1.3;
    text-align: left;
}

.custom-text h3 {
    font-size: var(--cb-rich-h3) !important;
    line-height: 1.35;
    text-align: left;
}

.custom-text h4 {
    font-size: var(--cb-rich-h4) !important;
    line-height: 1.35;
    text-align: left;
}

.custom-text h5 {
    font-size: var(--cb-rich-h5) !important;
    line-height: 1.4;
    text-align: left;
}

.custom-text h6 {
    font-size: var(--cb-rich-h6) !important;
    line-height: 1.4;
    text-align: left;
}

/* Color Variants */
.custom-text.text-primary {
    color: #0066ff;
}

.custom-text.text-secondary {
    color: #6c757d;
}

.custom-text.text-text {
    color: #333;
}

.custom-text.text-gray {
    color: #6b7280;
}

/* Builder-wide links */
.custom-builder-container a {
    color: #2a9d8f;
    font-weight: 600;
    text-decoration: none;
    transition: color 0.2s ease;
}

.custom-builder-container a:hover,
.custom-builder-container a:focus-visible {
    color: #1f6b62;
}

/* Lists */
.custom-builder-container ul,
.custom-builder-container ol {
    margin: 0.85rem 0 1.25rem;
    padding-left: 1.75rem;
    list-style-position: outside;
}

.custom-builder-container ul {
    list-style-type: disc;
}

.custom-builder-container ul ul {
    list-style-type: circle;
}

.custom-builder-container ol {
    list-style-type: decimal;
}

.custom-builder-container li {
    margin-bottom: 0.4rem;
    line-height: 1.6;
}

/* Tables */

.cb-rich-text-wrapper {
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: 18px;
    margin: 1.5rem 0;
    border: 1px solid #dbe4f3;
    background: #ffffff;
    box-shadow: 0 12px 35px rgba(15, 23, 42, 0.08);
}

.cb-rich-text-wrapper table {
    width: max-content;
    min-width: 640px;
    margin: 0;
    border-radius: 0;
    box-shadow: none;
}

.cb-rich-text-wrapper::-webkit-scrollbar {
    height: 8px;
}

.cb-rich-text-wrapper::-webkit-scrollbar-thumb {
    background: rgba(36, 99, 157, 0.55);
    border-radius: 999px;
}

.cb-rich-text-wrapper::-webkit-scrollbar-track {
    background: rgba(148, 163, 184, 0.3);
}

.custom-builder-container table {
    width: 100%;
    margin: 0;
    border-collapse: collapse;
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 12px 35px rgba(15, 23, 42, 0.08);
}

.custom-builder-container table p {
    margin: 0;
}

.custom-builder-container table caption {
    text-align: left;
    font-weight: 600;
    color: #475569;
    margin-bottom: 0.75rem;
}

.custom-builder-container table thead {
    background: #f1f5f9;
    color: #0f172a;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.custom-builder-container table th,
.custom-builder-container table td {
    padding: 0.85rem 1.25rem;
    border: 1px solid #e2e8f0;
    text-align: left;
}

.custom-builder-container table tbody tr:nth-child(even) {
    background: #f9fafb;
}

.custom-builder-container table tbody tr:hover {
    background: #edf2f7;
}

.custom-builder-container table strong {
    color: inherit;
}

.custom-builder-container hr {
    border: 0;
    border-top: 1px solid #e2e8f0;
    margin: 2rem 0;
    opacity: 1;
}

/* Size Variants */
.custom-text.text-sm {
    font-size: 0.875rem;
}

.custom-text.text-md {
    font-size: 1rem;
}

.custom-text.text-lg {
    font-size: 1.125rem;
}

.custom-text.text-xl {
    font-size: 1.25rem;
}

/* ========================================
   PARAGRAPH STYLES
   ======================================== */

.custom-paragraph {
    margin: 1rem 0;
    line-height: 1.8;
    color: #333;
    font-size: 1rem;
}

/* Color Variants */
.custom-paragraph.text-primary {
    color: #0066ff;
}

.custom-paragraph.text-secondary {
    color: #6c757d;
}

.custom-paragraph.text-text {
    color: #333;
}

.custom-paragraph.text-gray {
    color: #6b7280;
}

/* Size Variants */
.custom-paragraph.text-sm {
    font-size: 0.875rem;
}

.custom-paragraph.text-md {
    font-size: 1rem;
}

.custom-paragraph.text-lg {
    font-size: 1.125rem;
}

/* ========================================
   IMAGE STYLES
   ======================================== */

.custom-image {
    max-width: 100%;
    height: auto;
    display: block;
    margin: 1rem 0;
}

/* Border Radius Variants */
.custom-image.border-radius-none {
    border-radius: 0;
}

.custom-image.border-radius-sm {
    border-radius: 0.25rem;
}

.custom-image.border-radius-md {
    border-radius: 0.5rem;
}

.custom-image.border-radius-lg {
    border-radius: 1rem;
}

/* Width Variants */
.custom-image.w-50 {
    width: 50%;
}

.custom-image.w-75 {
    width: 75%;
}

.custom-image.w-100 {
    width: 100%;
}

/* ========================================
   RESPONSIVE MEDIA QUERIES (768px breakpoint)
   Matches Elementor default breakpoint
   ======================================== */

@media (max-width: 768px) {

    .custom-builder-container {
        --cb-heading-h1: clamp(2.1rem, calc(1.35rem + 3vw), 2.6rem);
        --cb-heading-h2: clamp(1.8rem, calc(1.2rem + 2.4vw), 2.3rem);
        --cb-heading-h3: clamp(1.5rem, calc(1rem + 2vw), 2rem);
        --cb-heading-h4: clamp(1.3rem, calc(0.95rem + 1.6vw), 1.6rem);
        --cb-heading-h5: clamp(1.1rem, calc(0.85rem + 1.2vw), 1.4rem);
        --cb-heading-h6: clamp(0.95rem, calc(0.8rem + 0.8vw), 1.2rem);
        --cb-heading-size-xl: clamp(2rem, calc(1.2rem + 2.6vw), 2.5rem);
        --cb-heading-size-lg: clamp(1.6rem, calc(1rem + 2vw), 2rem);
        --cb-heading-size-md: clamp(1.3rem, calc(0.9rem + 1.5vw), 1.6rem);
        --cb-heading-size-sm: clamp(1.05rem, calc(0.85rem + 1vw), 1.3rem);
        --cb-rich-h1: clamp(1.8rem, calc(1.1rem + 2.4vw), 2.2rem);
        --cb-rich-h2: clamp(1.55rem, calc(1rem + 2vw), 1.95rem);
        --cb-rich-h3: clamp(1.35rem, calc(0.95rem + 1.6vw), 1.7rem);
        --cb-rich-h4: clamp(1.15rem, calc(0.9rem + 1.2vw), 1.4rem);
        --cb-rich-h5: clamp(1rem, calc(0.85rem + 1vw), 1.25rem);
        --cb-rich-h6: clamp(0.9rem, calc(0.8rem + 0.6vw), 1.1rem);
    }

    /* Columns - Stack on mobile */
    .custom-builder-column.col-6 {
        grid-column: span 12;
    }

    .custom-builder-column.col-4 {
        grid-column: span 12;
    }

    .custom-builder-column.col-3 {
        grid-column: span 12;
    }

    .custom-builder-column.col-8 {
        grid-column: span 12;
    }

    .custom-builder-column.col-9 {
        grid-column: span 12;
    }

    /* Container - Reduce padding */
    .custom-builder-container.p-lg {
        padding: 1rem;
    }

    .custom-builder-container.p-xl {
        padding: 1.5rem;
    }

    /* Row - Reduce gap */
    .custom-builder-row.gap-lg {
        gap: 1rem;
    }

    /* Text - Adjust for mobile */
    .custom-text {
        margin: 0.25rem 0;
    }

    /* Paragraph - Adjust for mobile */
    .custom-paragraph {
        margin: 0.75rem 0;
        line-height: 1.6;
    }
}

/* ========================================
   EXTRA SMALL DEVICES (< 480px)
   ======================================== */

@media (max-width: 480px) {

    .custom-builder-container {
        --cb-heading-h1: clamp(1.85rem, calc(1.2rem + 3.5vw), 2.1rem);
        --cb-heading-h2: clamp(1.55rem, calc(1rem + 3vw), 1.85rem);
        --cb-heading-h3: clamp(1.35rem, calc(0.95rem + 2.5vw), 1.6rem);
        --cb-heading-h4: clamp(1.15rem, calc(0.9rem + 2vw), 1.35rem);
        --cb-heading-h5: clamp(1rem, calc(0.85rem + 1.5vw), 1.2rem);
        --cb-heading-h6: clamp(0.875rem, calc(0.8rem + 1vw), 1.05rem);
        --cb-heading-size-xl: clamp(1.75rem, calc(1.1rem + 3vw), 2rem);
        --cb-heading-size-lg: clamp(1.4rem, calc(0.95rem + 2.4vw), 1.7rem);
        --cb-heading-size-md: clamp(1.15rem, calc(0.85rem + 1.8vw), 1.4rem);
        --cb-heading-size-sm: clamp(0.95rem, calc(0.8rem + 1.2vw), 1.15rem);
        --cb-rich-h1: clamp(1.65rem, calc(1.05rem + 3.2vw), 1.95rem);
        --cb-rich-h2: clamp(1.4rem, calc(0.95rem + 2.6vw), 1.7rem);
        --cb-rich-h3: clamp(1.25rem, calc(0.9rem + 2vw), 1.45rem);
        --cb-rich-h4: clamp(1.1rem, calc(0.85rem + 1.6vw), 1.3rem);
        --cb-rich-h5: clamp(0.95rem, calc(0.8rem + 1.2vw), 1.15rem);
        --cb-rich-h6: clamp(0.85rem, calc(0.75rem + 0.9vw), 1rem);
    }

    /* Container - Very tight padding */
    .custom-builder-container.p-md {
        padding: 0.5rem;
    }

    .custom-builder-container.p-lg {
        padding: 0.75rem;
    }

    .custom-builder-container.p-xl {
        padding: 1rem;
    }

    /* Row - No gap */
    .custom-builder-row.gap-md {
        gap: 0.5rem;
    }

    .custom-builder-row.gap-lg {
        gap: 0.75rem;
    }

}

/* ========================================
   UTILITIES
   ======================================== */

/* Clear default margins on first/last children */
.custom-builder-container>*:first-child {
    margin-top: 0;
}

.custom-builder-container>*:last-child {
    margin-bottom: 0;
}

/* Image hover effect (optional) */
.custom-image {
    transition: transform 0.3s ease, opacity 0.3s ease;
}

.custom-image:hover {
    opacity: 0.95;
}

/* Fix for images in columns */
.custom-builder-column img {
    display: block;
}

/* ========================================
   BUTTON WIDGET STYLES
   ======================================== */

.custom-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    border-radius: 4px;
    transition: all 0.3s ease;
    cursor: pointer;
    font-weight: 500;
    border: 2px solid transparent;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.custom-button.btn-dynamic-color:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.12);
}

.custom-button.btn-inline {
    width: auto;
    align-self: flex-start;
}

/* Button Sizes */
.custom-button.btn-sm {
    padding: 8px 16px;
    font-size: 12px;
}

.custom-button.btn-md {
    padding: 12px 24px;
    font-size: 14px;
}

.custom-button.btn-lg {
    padding: 16px 32px;
    font-size: 16px;
}

.custom-button.btn-xl {
    padding: 20px 40px;
    font-size: 18px;
}

/* ========================================
   DIVIDER WIDGET STYLES
   ======================================== */

.custom-divider {
    width: 100%;
    display: block;
}

.custom-divider-line {
    display: block;
    width: 100%;
    border-top: 2px solid #d1d5db;
}

/* Divider Colors */
.custom-divider-line.divider-gray {
    border-top-color: #d1d5db;
}

.custom-divider-line.divider-primary {
    border-top-color: #0066ff;
}

.custom-divider-line.divider-secondary {
    border-top-color: #111827;
}

.custom-divider-line.divider-light {
    border-top-color: #e5e7eb;
}

.custom-divider-line.divider-dark {
    border-top-color: #1f2937;
}

/* Divider Margins */
.custom-divider.mt-none {
    margin-top: 0;
}

.custom-divider.mt-sm {
    margin-top: 12px;
}

.custom-divider.mt-md {
    margin-top: 24px;
}

.custom-divider.mt-lg {
    margin-top: 36px;
}

.custom-divider.mt-xl {
    margin-top: 48px;
}

.custom-divider.mb-none {
    margin-bottom: 0;
}

.custom-divider.mb-sm {
    margin-bottom: 12px;
}

.custom-divider.mb-md {
    margin-bottom: 24px;
}

.custom-divider.mb-lg {
    margin-bottom: 36px;
}

.custom-divider.mb-xl {
    margin-bottom: 48px;
}

/* ========================================
   SPACER WIDGET STYLES
   ======================================== */

.custom-spacer {
    display: block;
}

/* Spacer Heights */
.custom-spacer.spacer-xs {
    height: 10px;
}

.custom-spacer.spacer-sm {
    height: 20px;
}

.custom-spacer.spacer-md {
    height: 40px;
}

.custom-spacer.spacer-lg {
    height: 60px;
}

.custom-spacer.spacer-xl {
    height: 80px;
}

.custom-spacer.spacer-2xl {
    height: 100px;
}

.custom-spacer.spacer-3xl {
    height: 120px;
}

/* Responsive Spacer */
@media (max-width: 768px) {
    .custom-spacer.spacer-xs {
        height: 8px;
    }

    .custom-spacer.spacer-sm {
        height: 15px;
    }

    .custom-spacer.spacer-md {
        height: 30px;
    }

    .custom-spacer.spacer-lg {
        height: 45px;
    }

    .custom-spacer.spacer-xl {
        height: 60px;
    }

    .custom-spacer.spacer-2xl {
        height: 80px;
    }

    .custom-spacer.spacer-3xl {
        height: 100px;
    }
}