/**
 * WooAI Documentation Styles
 * Scoped under .wooai-doc-content
 */

/* CSS Variables */
.wooai-doc-content {
    --primary-color: #10B981;
    --primary-dark: #059669;
    --secondary-color: #3B82F6;
    --text-primary: #1F2937;
    --text-secondary: #6B7280;
    --text-light: #9CA3AF;
    --bg-primary: #FFFFFF;
    --bg-secondary: #F9FAFB;
    --bg-tertiary: #F3F4F6;
    --border-color: #E5E7EB;
    --code-bg: #1F2937;
    --success-color: #10B981;
    --warning-color: #F59E0B;
    --error-color: #EF4444;
    --info-color: #3B82F6;

    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 16px;
    line-height: 1.7;
    color: var(--text-primary);
    max-width: 900px;
    margin: 0 auto;
    padding: 24px;
}

/* Typography */
.wooai-doc-content h1 {
    font-size: 36px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 16px;
    line-height: 1.2;
}

.wooai-doc-content .doc-intro {
    font-size: 18px;
    color: var(--text-secondary);
    margin-bottom: 48px;
    line-height: 1.6;
}

.wooai-doc-content h2 {
    font-size: 24px;
    font-weight: 600;
    color: var(--text-primary);
    margin-top: 48px;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border-color);
}

.wooai-doc-content h3 {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
    margin-top: 32px;
    margin-bottom: 12px;
}

.wooai-doc-content h4 {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    margin-top: 24px;
    margin-bottom: 8px;
}

.wooai-doc-content p {
    margin-bottom: 16px;
    color: var(--text-secondary);
}

/* Links */
.wooai-doc-content a {
    color: var(--secondary-color);
    text-decoration: none;
}

.wooai-doc-content a:hover {
    color: var(--primary-dark);
    text-decoration: underline;
}

/* Lists */
.wooai-doc-content ul,
.wooai-doc-content ol {
    margin-bottom: 16px;
    padding-left: 24px;
}

.wooai-doc-content li {
    margin-bottom: 8px;
    color: var(--text-secondary);
}

/* Callouts / Alert Boxes */
.wooai-doc-content .callout {
    padding: 16px 20px;
    border-radius: 8px;
    margin: 24px 0;
    display: flex;
    gap: 12px;
}

.wooai-doc-content .callout-icon {
    flex-shrink: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
}

.wooai-doc-content .callout-content {
    flex: 1;
}

.wooai-doc-content .callout-title {
    font-weight: 600;
    margin-bottom: 4px;
}

/* most callouts are written as .callout > (.callout-title + <p>) with no
   .callout-content wrapper, so the title was landing in the icon column and
   wrapping one word per line. Stack those on their own rows. The icon +
   .callout-content variant keeps the original side-by-side row. */
.wooai-doc-content .callout:not(:has(> .callout-content)) {
    flex-wrap: wrap;
    row-gap: 4px;
}
.wooai-doc-content .callout:not(:has(> .callout-content)) > .callout-title { flex: 0 0 100%; }
.wooai-doc-content .callout:not(:has(> .callout-content)) > p,
.wooai-doc-content .callout:not(:has(> .callout-content)) > ul,
.wooai-doc-content .callout:not(:has(> .callout-content)) > ol { flex: 1 1 100%; }
.wooai-doc-content .callout-content { min-width: 0; }

.wooai-doc-content .callout-info {
    background: #EFF6FF;
    border: 1px solid #BFDBFE;
}

.wooai-doc-content .callout-info .callout-icon { color: var(--info-color); }
.wooai-doc-content .callout-info .callout-title { color: #1E40AF; }

.wooai-doc-content .callout-warning {
    background: #FFFBEB;
    border: 1px solid #FDE68A;
}

.wooai-doc-content .callout-warning .callout-icon { color: var(--warning-color); }
.wooai-doc-content .callout-warning .callout-title { color: #92400E; }

.wooai-doc-content .callout-success {
    background: #ECFDF5;
    border: 1px solid #A7F3D0;
}

.wooai-doc-content .callout-success .callout-icon { color: var(--success-color); }
.wooai-doc-content .callout-success .callout-title { color: #065F46; }

.wooai-doc-content .callout-error {
    background: #FEF2F2;
    border: 1px solid #FECACA;
}

.wooai-doc-content .callout-error .callout-icon { color: var(--error-color); }
.wooai-doc-content .callout-error .callout-title { color: #991B1B; }

/* Info/Warning/Tip/Danger boxes (alternate class names) */
.wooai-doc-content .info-box {
    background: #EFF6FF;
    border: 1px solid #BFDBFE;
    padding: 16px 20px;
    border-radius: 8px;
    margin: 24px 0;
}

.wooai-doc-content .warning-box {
    background: #FFFBEB;
    border: 1px solid #FDE68A;
    padding: 16px 20px;
    border-radius: 8px;
    margin: 24px 0;
}

.wooai-doc-content .tip-box {
    background: #ECFDF5;
    border: 1px solid #A7F3D0;
    padding: 16px 20px;
    border-radius: 8px;
    margin: 24px 0;
}

.wooai-doc-content .danger-box {
    background: #FEF2F2;
    border: 1px solid #FECACA;
    padding: 16px 20px;
    border-radius: 8px;
    margin: 24px 0;
}

/* Code */
.wooai-doc-content code {
    font-family: 'SF Mono', 'Monaco', 'Inconsolata', 'Roboto Mono', monospace;
    font-size: 14px;
    background: var(--bg-tertiary);
    padding: 2px 6px;
    border-radius: 4px;
    color: var(--text-primary);
}

.wooai-doc-content pre {
    background: var(--code-bg);
    border-radius: 8px;
    padding: 20px;
    overflow-x: auto;
    margin: 16px 0;
}

.wooai-doc-content pre code {
    background: none;
    padding: 0;
    color: #E5E7EB;
    font-size: 13px;
    line-height: 1.6;
}

/* Images / Screenshots */
.wooai-doc-content .doc-image {
    margin: 24px 0;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid var(--border-color);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.wooai-doc-content .doc-image img {
    width: 100%;
    height: auto;
    display: block;
}

.wooai-doc-content .doc-image-caption {
    padding: 12px 16px;
    background: var(--bg-secondary);
    font-size: 13px;
    color: var(--text-light);
    text-align: center;
}

.wooai-doc-content .screenshot {
    margin: 24px 0;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid var(--border-color);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.wooai-doc-content .screenshot img {
    width: 100%;
    height: auto;
    display: block;
    border-radius: 8px;
}

/* Steps */
.wooai-doc-content .steps {
    counter-reset: step-counter;
    margin: 24px 0;
}

.wooai-doc-content .step {
    display: flex;
    gap: 16px;
    margin-bottom: 24px;
    padding-bottom: 24px;
    border-bottom: 1px solid var(--border-color);
}

.wooai-doc-content .step:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.wooai-doc-content .step-number {
    counter-increment: step-counter;
    width: 32px;
    height: 32px;
    background: var(--primary-color);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 14px;
    flex-shrink: 0;
}

.wooai-doc-content .step-number::before {
    content: counter(step-counter);
}

.wooai-doc-content .step-content {
    flex: 1;
}

.wooai-doc-content .step-title {
    font-weight: 600;
    font-size: 16px;
    color: var(--text-primary);
    margin-bottom: 8px;
}

/* Tables */
.wooai-doc-content table {
    width: 100%;
    border-collapse: collapse;
    margin: 16px 0;
}

.wooai-doc-content th,
.wooai-doc-content td {
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.wooai-doc-content th {
    background: var(--bg-secondary);
    font-weight: 600;
    font-size: 14px;
    color: var(--text-primary);
}

.wooai-doc-content td {
    font-size: 14px;
    color: var(--text-secondary);
}

.wooai-doc-content tr:last-child td {
    border-bottom: none;
}

/* Status Badges */
.wooai-doc-content .status-badge {
    display: inline-flex;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
}

.wooai-doc-content .status-required {
    background: #FEE2E2;
    color: #991B1B;
}

.wooai-doc-content .status-recommended {
    background: #FEF3C7;
    color: #92400E;
}

.wooai-doc-content .status-optional {
    background: #E0E7FF;
    color: #3730A3;
}

/* Feature Grid */
.wooai-doc-content .feature-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 16px;
    margin: 24px 0;
}

.wooai-doc-content .feature-card {
    padding: 20px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
}

.wooai-doc-content .feature-card h3,
.wooai-doc-content .feature-card h4 {
    margin-top: 8px;
}

/* Navigation Footer */
.wooai-doc-content .doc-nav-footer {
    display: flex;
    justify-content: space-between;
    margin-top: 64px;
    padding-top: 32px;
    border-top: 1px solid var(--border-color);
}

.wooai-doc-content .doc-nav-link {
    display: flex;
    gap: 8px;
    padding: 16px 20px;
    background: var(--bg-secondary);
    border-radius: 8px;
    text-decoration: none;
    transition: all 0.2s ease;
}

.wooai-doc-content .doc-nav-link:hover {
    background: var(--bg-tertiary);
    text-decoration: none;
}

.wooai-doc-content .doc-nav-link-label {
    font-size: 12px;
    color: var(--text-light);
    margin-bottom: 4px;
}

.wooai-doc-content .doc-nav-link-title {
    font-weight: 600;
    color: var(--text-primary);
}

/* Breadcrumb */
.wooai-doc-content .breadcrumb {
    display: flex;
    gap: 8px;
    font-size: 14px;
    color: var(--text-light);
    margin-bottom: 24px;
}

.wooai-doc-content .breadcrumb a {
    color: var(--text-secondary);
    text-decoration: none;
}

.wooai-doc-content .breadcrumb a:hover {
    color: var(--primary-color);
}

/* Responsive */
@media (max-width: 768px) {
    .wooai-doc-content {
        padding: 16px;
    }

    .wooai-doc-content h1 {
        font-size: 28px;
    }

    .wooai-doc-content h2 {
        font-size: 20px;
    }

    .wooai-doc-content .step {
        flex-direction: column;
        gap: 8px;
    }

    .wooai-doc-content .feature-grid {
        grid-template-columns: 1fr;
    }

    .wooai-doc-content .doc-nav-footer {
        flex-direction: column;
        gap: 12px;
    }
}

/* RTL Support for Hebrew */
[dir="rtl"] .wooai-doc-content,
.wooai-doc-content[dir="rtl"] {
    direction: rtl;
    text-align: right;
}

[dir="rtl"] .wooai-doc-content ul,
[dir="rtl"] .wooai-doc-content ol {
    padding-left: 0;
    padding-right: 24px;
}

[dir="rtl"] .wooai-doc-content th,
[dir="rtl"] .wooai-doc-content td {
    text-align: right;
}

[dir="rtl"] .wooai-doc-content .callout {
    flex-direction: row-reverse;
}

[dir="rtl"] .wooai-doc-content .step {
    flex-direction: row-reverse;
}

[dir="rtl"] .wooai-doc-content .breadcrumb {
    flex-direction: row-reverse;
}

[dir="rtl"] .wooai-doc-content code {
    direction: ltr;
    unicode-bidi: isolate;
}

[dir="rtl"] .wooai-doc-content pre {
    direction: ltr;
    text-align: left;
}


/* ==========================================================================
   LAYOUT - Docs page structure (sidebar + content)
   ========================================================================== */

.wooai-docs-layout {
    min-height: calc(100vh - 80px);
}

.wooai-docs-sidebar-col {
    background: #F9FAFB;
    border-right: 1px solid #E5E7EB;
    min-width: 280px;
    max-width: 280px;
}

[dir="rtl"] .wooai-docs-sidebar-col {
    border-right: none;
    border-left: 1px solid #E5E7EB;
}


/* ==========================================================================
   SIDEBAR NAVIGATION
   ========================================================================== */

.wooai-docs-nav {
    position: sticky;
    top: 32px;
    padding: 24px 16px;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 14px;
    max-height: calc(100vh - 64px);
    overflow-y: auto;
}

/* Search */
.wooai-docs-search {
    display: flex;
    margin-bottom: 20px;
    border: 1px solid #E5E7EB;
    border-radius: 6px;
    overflow: hidden;
    background: #fff;
}

.wooai-docs-search__input {
    flex: 1;
    padding: 8px 12px;
    border: none;
    outline: none;
    font-size: 13px;
    font-family: inherit;
    background: transparent;
}

.wooai-docs-search__input::placeholder {
    color: #9CA3AF;
}

.wooai-docs-search__btn {
    padding: 8px 10px;
    border: none;
    background: transparent;
    cursor: pointer;
    font-size: 14px;
    color: #6B7280;
}

.wooai-docs-search__btn:hover {
    color: #10B981;
}

/* Search wrapper (positions dropdown relative to form) */
.wooai-docs-search-wrap {
    position: relative;
    margin-bottom: 20px;
}

.wooai-docs-search {
    margin-bottom: 0;
}

/* Predictive results dropdown */
.wooai-docs-search__results {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    z-index: 50;
    background: #ffffff;
    border: 1px solid #E5E7EB;
    border-radius: 10px;
    box-shadow: 0 4px 12px rgba(10,11,20,.08), 0 2px 4px rgba(10,11,20,.04);
    overflow: hidden;
}

.wooai-docs-search__results[hidden] {
    display: none;
}

.wooai-docs-search__result {
    display: block;
    padding: 10px 14px;
    text-decoration: none;
    color: inherit;
    border-bottom: 1px solid #F3F4F6;
    transition: background 0.12s ease;
}

.wooai-docs-search__result:last-child {
    border-bottom: none;
}

.wooai-docs-search__result:hover,
.wooai-docs-search__result.is-active {
    background: #EEF2FF;
}

.wooai-docs-search__result-title {
    font-size: 13px;
    font-weight: 500;
    color: #0A0B14;
    line-height: 1.4;
}

.wooai-docs-search__result:hover .wooai-docs-search__result-title,
.wooai-docs-search__result.is-active .wooai-docs-search__result-title {
    color: #2F436F;
}

.wooai-docs-search__result-excerpt {
    font-size: 12px;
    color: #6B7280;
    margin-top: 2px;
    line-height: 1.4;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.wooai-docs-search__mark {
    background: #FEF3C7;
    padding: 0 2px;
    border-radius: 3px;
    font-style: normal;
}

@media (max-width: 600px) {
    .wooai-docs-search__results {
        border-radius: 8px;
    }
    .wooai-docs-search__result {
        padding: 12px 14px;
    }
}

/* Nav groups */
.wooai-docs-nav__group {
    margin-bottom: 8px;
}

.wooai-docs-nav__group > summary {
    list-style: none;
    cursor: pointer;
    padding: 8px 12px;
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #6B7280;
    border-radius: 4px;
    user-select: none;
    display: flex;
    align-items: center;
    gap: 6px;
}

.wooai-docs-nav__group > summary::-webkit-details-marker {
    display: none;
}

.wooai-docs-nav__group > summary::before {
    content: '\25B6';
    font-size: 8px;
    transition: transform 0.2s ease;
    display: inline-block;
}

.wooai-docs-nav__group[open] > summary::before {
    transform: rotate(90deg);
}

.wooai-docs-nav__group > summary:hover {
    background: #F3F4F6;
    color: #374151;
}

/* Nav list */
.wooai-docs-nav__list {
    list-style: none;
    padding: 0 0 0 8px;
    margin: 4px 0 8px;
}

.wooai-docs-nav__item {
    margin: 0;
}

.wooai-docs-nav__link {
    display: block;
    padding: 6px 12px;
    color: #4B5563;
    text-decoration: none;
    border-radius: 4px;
    font-size: 13px;
    line-height: 1.4;
    border-left: 2px solid transparent;
    transition: all 0.15s ease;
}

.wooai-docs-nav__link:hover {
    color: #10B981;
    background: rgba(16, 185, 129, 0.05);
    text-decoration: none;
}

.wooai-docs-nav__item.active .wooai-docs-nav__link {
    color: #10B981;
    font-weight: 500;
    border-left-color: transparent;
    background: rgba(16, 185, 129, 0.08);
}

[dir="rtl"] .wooai-docs-nav__link {
    border-left: none;
    border-right: 2px solid transparent;
}

[dir="rtl"] .wooai-docs-nav__item.active .wooai-docs-nav__link {
    border-left-color: transparent;
    border-right-color: #10B981;
}

[dir="rtl"] .wooai-docs-nav__list {
    padding: 0 8px 0 0;
}


/* ==========================================================================
   TABLE OF CONTENTS (right side, floating)
   ========================================================================== */

.wooai-toc {
    position: sticky;
    top: 100px;
    width: 100%;
    max-width: 260px;
    max-height: calc(100vh - 130px);
    overflow-y: auto;
    padding: 16px 18px;
    font-size: 13px;
    background: #ffffff;
    z-index: 5;
    border: 1px solid #E5E7EB;
    border-radius: 12px;
    box-shadow: 0 4px 16px rgba(15, 23, 42, 0.04);
    align-self: start;
    transition: max-height 0.25s ease, padding 0.25s ease;
}

.wooai-toc-col {
    position: relative;
    align-self: stretch;
}

.wooai-toc__title {
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #6B7280;
    margin-bottom: 12px;
    padding-left: 12px;
}

.wooai-toc__list {
    list-style: none;
    padding: 0;
    margin: 0;
    border-left: 1px solid #E5E7EB;
}

.wooai-toc__sublist {
    list-style: none;
    padding: 0;
    margin: 0;
}

.wooai-toc__link {
    display: block;
    padding: 4px 12px;
    color: #6B7280;
    text-decoration: none;
    line-height: 1.4;
    border-left: 2px solid transparent;
    margin-left: -1px;
    transition: all 0.15s ease;
}

.wooai-toc__link:hover {
    color: #10B981;
    text-decoration: none;
}

/* --- collapse toggle --- */
.wooai-toc__toggle {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 28px;
    height: 28px;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 6px;
    color: #6B7280;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.25s ease, background 0.15s, border-color 0.15s;
}
.wooai-toc__toggle:hover {
    background: #F3F4F6;
    border-color: #E5E7EB;
    color: #1F2937;
}
.wooai-toc--collapsed .wooai-toc__toggle {
    transform: rotate(180deg);
}
.wooai-toc--collapsed {
    padding: 12px 18px;
    max-height: 52px;
    overflow: hidden;
}
.wooai-toc--collapsed .wooai-toc__title {
    margin-bottom: 0;
}
.wooai-toc--collapsed .wooai-toc__list,
.wooai-toc--collapsed .wooai-toc__sublist {
    display: none;
}
.wooai-toc__title {
    margin: 0 28px 12px 0;
}
/* --- end collapse toggle --- */

.wooai-toc__link.is-active {
    color: #10B981;
    border-left-color: #10B981;
    font-weight: 500;
}

.wooai-toc__item--h3 .wooai-toc__link {
    padding-left: 24px;
    font-size: 12px;
}

[dir="rtl"] .wooai-toc {
    /* RTL: no positional offset needed in grid column */
}

[dir="rtl"] .wooai-toc__title {
    padding-left: 0;
    padding-right: 12px;
}

[dir="rtl"] .wooai-toc__list {
    border-left: none;
    border-right: 1px solid #E5E7EB;
}

[dir="rtl"] .wooai-toc__link {
    border-left: none;
    border-right: 2px solid transparent;
    margin-left: 0;
    margin-right: -1px;
    padding-left: 12px;
    padding-right: 12px;
}

[dir="rtl"] .wooai-toc__link.is-active {
    border-right-color: #10B981;
}

[dir="rtl"] .wooai-toc__item--h3 .wooai-toc__link {
    padding-left: 12px;
    padding-right: 24px;
}


/* ==========================================================================
   BREADCRUMB (outside .wooai-doc-content scope)
   ========================================================================== */

nav.breadcrumb {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 14px;
    color: #9CA3AF;
    margin-bottom: 8px;
}

.breadcrumb__list {
    display: flex;
    align-items: center;
    gap: 0;
    list-style: none;
    padding: 0;
    margin: 0;
    flex-wrap: wrap;
}

.breadcrumb__item {
    display: inline;
}

.breadcrumb__separator {
    padding: 0 6px;
    color: #D1D5DB;
}

.breadcrumb__link {
    color: #6B7280;
    text-decoration: none;
}

.breadcrumb__link:hover {
    color: #10B981;
}

.breadcrumb__item--current {
    color: #1F2937;
    font-weight: 500;
}


/* ==========================================================================
   PREV/NEXT NAV (appended outside .wooai-doc-content by filter)
   ========================================================================== */

.doc-nav-footer {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    margin-top: 48px;
    padding-top: 32px;
    border-top: 1px solid #E5E7EB;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

.doc-nav-link {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 16px 20px;
    background: #F9FAFB;
    border: 1px solid #E5E7EB;
    border-radius: 8px;
    text-decoration: none;
    transition: all 0.2s ease;
    min-width: 0;
    max-width: 48%;
}

.doc-nav-link:hover {
    background: #F3F4F6;
    border-color: #10B981;
    text-decoration: none;
}

.doc-nav-link--next {
    text-align: end;
    margin-inline-start: auto;
}

.doc-nav-link--empty {
    visibility: hidden;
}

.doc-nav-link-label {
    font-size: 12px;
    color: #9CA3AF;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.doc-nav-link-title {
    font-weight: 600;
    font-size: 14px;
    color: #1F2937;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}


/* ==========================================================================
   ARCHIVE CARDS
   ========================================================================== */

.wooai-docs-card {
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.wooai-docs-card:hover {
    border-color: #10B981 !important;
    box-shadow: 0 2px 8px rgba(16, 185, 129, 0.1);
}


/* ==========================================================================
   RESPONSIVE
   ========================================================================== */

@media (max-width: 1200px) {
    .wooai-doc-main {
        grid-template-columns: 260px 1fr !important;
    }
    .wooai-toc-col {
        display: none;
    }
}

@media (max-width: 768px) {
    .wooai-doc-main {
        grid-template-columns: 1fr !important;
    }
    .wooai-doc-main > aside:first-child {
        display: none;
    }
    .wooai-toc-col {
        display: none;
    }
}

@media (max-width: 900px) {
    .wooai-docs-sidebar-col {
        display: none;
    }

    .wooai-docs-layout {
        flex-direction: column;
    }

    /* Prev/next stay SIDE BY SIDE on narrow screens (QA #662, 2026-07-27).
       They used to stack, which left two half-width cards in a full-width
       column and pushed the footer down for no reason. Two flex:1 cards fit:
       165 + 12 + 165 = 342 in the 343px content column at 375px. */
    .doc-nav-footer {
        flex-direction: row;
        gap: 12px;
    }

    .doc-nav-link {
        flex: 1 1 0;
        max-width: none;
        padding: 14px 16px;
    }

    .doc-nav-link--next {
        text-align: end;
        margin-inline-start: 0;
    }
}

@media (max-width: 768px) {
    .wooai-docs-content-col .wp-block-group {
        padding-left: 16px !important;
        padding-right: 16px !important;
    }
}


/* ==========================================================================
   COPY CODE BUTTON
   ========================================================================== */

.wooai-doc-content pre {
    position: relative;
}

.wooai-copy-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    background: rgba(255, 255, 255, 0.95);
    border: 1px solid #E5E7EB;
    border-radius: 6px;
    color: #4B5563;
    font-size: 12px;
    font-weight: 500;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.15s ease, background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
    z-index: 2;
    line-height: 1;
}

.wooai-doc-content pre:hover .wooai-copy-btn,
.wooai-doc-content pre .wooai-copy-btn:focus-visible {
    opacity: 1;
}

.wooai-copy-btn:hover {
    background: #F9FAFB;
    border-color: #D1D5DB;
    color: #1F2937;
}

.wooai-copy-btn:active {
    background: #F3F4F6;
}

.wooai-copy-btn--success {
    background: #ECFDF5;
    border-color: #10B981;
    color: #065F46;
    opacity: 1 !important;
}

.wooai-copy-btn svg {
    flex-shrink: 0;
}

/* Touch devices - always visible since no hover */
@media (hover: none) {
    .wooai-copy-btn { opacity: 1; }
}

/* ==========================================================================
   RESPONSIVE FIX (2026-07-25) — docs pages were overflowing on mobile
   Root cause: the .wooai-doc-main grid collapses to one column on mobile,
   but grid items default to min-width:auto so the column could not shrink
   below the content's intrinsic width (wide tables / code), forcing
   horizontal overflow. Let the column shrink, and make wide content scroll.
   ========================================================================== */

/* 1. Let the collapsed grid column shrink below its content min-content width */
.wooai-doc-main { max-width: 100%; }
.wooai-doc-main > * { min-width: 0; }
.wooai-doc-page,
.wooai-docs-content-col,
.wooai-doc-content { min-width: 0; max-width: 100%; }

/* 2. Never let anything push the page wider than the viewport */
.wooai-doc-content { overflow-wrap: break-word; word-wrap: break-word; }
.wooai-doc-content img { max-width: 100%; height: auto; }
.wooai-doc-content pre { overflow-x: auto; max-width: 100%; }
.wooai-doc-content pre code { white-space: pre; }

/* 3. Wide tables scroll horizontally instead of stretching the page.
      Gutenberg wraps tables in figure.wp-block-table; bare .doc-table (dev docs)
      is made scrollable directly. */
.wooai-doc-content figure.wp-block-table { overflow-x: auto; max-width: 100%; -webkit-overflow-scrolling: touch; margin-left: 0; margin-right: 0; }
.wooai-doc-content figure.wp-block-table > table { min-width: 480px; }

/* .doc-table has no figure wrapper, so it must scroll on its own - at EVERY
   width, not just on phones. Gating this at 768px left the 769-1399px band
   uncovered: the analytics event table is intrinsically ~1020px wide, so it
   pushed the whole page 156-536px sideways on tablets and small laptops
   (measured at 820/900/1024/1100/1200). In RTL it broke out leftwards instead
   (left:-420px), which a right-edge-only check does not see. */
.wooai-doc-content table.doc-table,
.wooai-doc-content .doc-table {
  display: block;
  overflow-x: auto;
  max-width: 100%;
  -webkit-overflow-scrolling: touch;
}

@media (max-width: 768px) {
  /* main grid: single column, full width, comfortable padding */
  .wooai-doc-main {
    grid-template-columns: 1fr !important;
    padding: 20px 16px !important;
    margin: 16px auto !important;
    gap: 16px !important;
  }
  .wooai-doc-main > aside { display: none; }
  .wooai-toc-col { display: none; }

  /* on a phone the technical tables also stop wrapping, so a row stays one
     line and the horizontal scroll (declared unconditionally above) is what
     you use to read it */
  .wooai-doc-content table.doc-table,
  .wooai-doc-content .doc-table { white-space: nowrap; }

  /* tighten headings/spacing on small screens.
     The page H1 lives in .wooai-doc-page > article, OUTSIDE .wooai-doc-content,
     so the .wooai-doc-content h1 rule never reached it and every doc title
     stayed at its 48px desktop size on a phone. "Troubleshooting" is a single
     unbreakable word and overflowed its own 343px box by 21px because of it. */
  .wooai-doc-page > article > h1,
  .wooai-doc-page h1 { font-size: 30px; line-height: 1.2; overflow-wrap: break-word; }
  .wooai-doc-content h1 { font-size: 26px; line-height: 1.2; word-break: break-word; }
  .wooai-doc-content h2 { font-size: 20px; }
  .wooai-doc-content h3 { font-size: 17px; }

  /* callouts / info boxes: stack icon above text, no fixed side column */
  .wooai-doc-content .callout,
  .wooai-doc-content .info-box { flex-direction: column; }
}

/* the docs pages do not load the landing footer stylesheet, so the footer link
   row falls back to inline anchors with no separation */
.site-footer .footer-links,
footer .footer-links {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 22px;
  align-items: center;
}

/* Section rhythm - ALL widths, not just phones (QA #659, 2026-07-27).
   The shared landing stylesheet sets `section { padding-block: 120px }`, which
   is a marketing-page rhythm. It leaks into the docs, where a section end
   (120) + the next section start (120) + the h2 margin (48) stacked up to a
   376px void between subtopics on desktop - measured on /docs/ai-providers/.
   Gating the override at max-width:768px fixed only phones and left every
   desktop reader staring at the hole. Scoped to .wooai-doc-content so the
   landing page keeps its own 120px rhythm. */
.wooai-doc-content section { padding-top: 24px; padding-bottom: 24px; }
.wooai-doc-content section > h2:first-child { margin-top: 16px; }

/* The last block inside a section also contributes its own bottom margin on
   top of the section padding - a callout adds 24, a steps list 16 - so the
   space between two subtopics was being counted twice. Zero it and let the
   section padding alone decide the rhythm: 24 + 24 + 16 = 64px between the
   end of one subtopic and the next heading. */
.wooai-doc-content section > *:last-child { margin-bottom: 0; }

/* Anchor targets must clear the sticky header (QA #660, 2026-07-27).
   .nav is position:sticky and 73px tall, and nothing declared scroll-margin,
   so clicking an "On this page" entry parked the heading at viewport top:0 -
   completely behind the header - and the reader landed mid-paragraph. */
.wooai-doc-content :is(h1, h2, h3, h4)[id],
.wooai-doc-content section[id],
.wooai-doc-page :is(h1, h2, h3, h4)[id] {
  scroll-margin-top: 90px;
}

/* ---- docs archive (/docs/, /he/docs/) ---- */
.wooai-docs-archive { max-width: 1200px; margin: 40px auto; padding: 0 20px; }
.wooai-docs-archive__title { margin: 0 0 32px; }
.wooai-docs-archive__grid { display: grid; grid-template-columns: 280px minmax(0, 1fr); gap: 40px; }
.wooai-docs-archive__grid > * { min-width: 0; }
.wooai-docs-archive__list ul { list-style: none; padding: 0; margin: 0; }
.wooai-docs-archive__list li { margin-bottom: 16px; }
.wooai-docs-archive__list li a { font-size: 18px; font-weight: 500; color: #2F436F; }
.wooai-docs-archive__list li p { margin: 4px 0 0; color: #6B7280; }

@media (max-width: 900px) {
  .wooai-docs-archive__grid { grid-template-columns: 1fr; gap: 24px; }
}
@media (max-width: 768px) {
  .wooai-docs-archive { margin: 24px auto; padding: 0 16px; }
  .wooai-docs-archive__title { font-size: 32px; line-height: 1.15; margin-bottom: 20px; }
}

@media (max-width: 768px) {
  /* tables written as bare <table> inside a <section> have no .wp-block-table
     scroll wrapper, so a wide one gets its last column clipped */
  .wooai-doc-content section > table,
  .wooai-doc-content > table {
    display: block;
    overflow-x: auto;
    max-width: 100%;
    -webkit-overflow-scrolling: touch;
  }
}

@media (max-width: 768px) {
  /* wide tables scroll sideways, but nothing on screen says so - paint a soft
     shadow on whichever edge still has content behind it (background-attachment
     local pins the mask to the content, scroll pins the shadow to the frame) */
  .wooai-doc-content .wp-block-table,
  .wooai-doc-content section > table,
  .wooai-doc-content > table {
    background-image:
      linear-gradient(to right, #FAFAFA 40%, rgba(250, 250, 250, 0)),
      linear-gradient(to left,  #FAFAFA 40%, rgba(250, 250, 250, 0)),
      linear-gradient(to right, rgba(15, 23, 42, .13), rgba(15, 23, 42, 0)),
      linear-gradient(to left,  rgba(15, 23, 42, .13), rgba(15, 23, 42, 0));
    background-position: 0 0, 100% 0, 0 0, 100% 0;
    background-repeat: no-repeat;
    background-size: 28px 100%, 28px 100%, 12px 100%, 12px 100%;
    background-attachment: local, local, scroll, scroll;
  }
}
