/* Apply border-box globally inside docs page content to ensure padding does not stretch layouts */
.docs-page-content *,
.docs-page-content *::before,
.docs-page-content *::after {
    box-sizing: border-box !important;
}

@media (max-width: 1024px) {
    .docs-page-content {
        padding: 50px 0px;
    }
}

/* Constrain HTML and BODY width to prevent horizontal overflow scrolling on mobile/tablet */
@media (max-width: 991px) {

    html,
    body {
        max-width: 100% !important;
        overflow-x: hidden !important;
    }
}

/* Ensure docs components fit within 100% viewport width without stretching parent containers on mobile and tablets */
@media (max-width: 991px) {

    .docs-page-content,
    .docs-container,
    .docs-content,
    .docs-sidebar,
    .docs-tab-panel,
    .docs-section {
        max-width: 100% !important;
        width: 100% !important;
        min-width: 0 !important;
    }
}

/* Force code blocks to restrict width and render scrollbars instead of pushing page widths */
.code-block-container {
    max-width: 100% !important;
    width: 100% !important;
    overflow: hidden !important;
}

.code-block-container pre {
    max-width: 100% !important;
    width: 100% !important;
    overflow-x: auto !important;
    white-space: pre !important;
}

/* Restrict table wrapper widths and force internal scrolling */
.table-responsive {
    max-width: 100% !important;
    width: 100% !important;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch;
}

.docs-table {
    width: 100% !important;
    min-width: 600px !important;
    /* Forces internal horizontal scroll inside table-responsive container */
}

@media (max-width: 860px) {
  .invoice-guide-wrap .wp-field-row {
    grid-template-columns: 1fr;
  }
  .invoice-guide-wrap .inv-meta-row {
    grid-template-columns: 1fr;
  }
  .invoice-guide-wrap .cert-grid,
  .invoice-guide-wrap .cert-stone-grid {
    grid-template-columns: 1fr 1fr;
  }
  .invoice-guide-wrap .qr-grid {
    grid-template-columns: 1fr;
  }
}

/* Ensure footer links wrap correctly on smaller mobile viewports */
@media (max-width: 768px) {
    .footer-legal-links {
        justify-content: center !important;
        flex-wrap: wrap !important;
        gap: 15px !important;
    }
}

@media (max-width: 1200px) {
    .docs-container {
        gap: 30px;
    }

    .docs-sidebar {
        flex: 0 0 300px;
        width: 300px;
    }

    .docs-content {
        padding: 35px 40px;
    }
}

/* ── Medium & Tablet Screens (768px - 991px) ── */
@media (max-width: 991px) {
    .docs-container {
        flex-direction: column;
        gap: 25px;
        width: 100%;
    }

    .docs-sidebar {
        width: 100% !important;
        flex: none !important;
        position: relative !important;
        top: 0 !important;
        padding: 20px 15px;
        border-radius: 12px;
    }

    .docs-content {
        width: 100%;
        padding: 30px 25px;
        border-radius: 12px;
        min-height: auto;
    }

    .docs-hero {
        padding: 70px 0 50px;
    }

    .docs-hero h1 {
        font-size: 38px;
    }
}

/* ── Mobile Landscape & Mid-range Devices (576px - 767px) ── */
@media (max-width: 767px) {
    .docs-hero {
        padding: 60px 15px 45px;
    }

    .docs-hero h1 {
        font-size: 32px;
        letter-spacing: -1px;
    }

    .docs-hero p {
        font-size: 15px;
    }

    .docs-tab-panel h2 {
        font-size: 26px;
        margin-bottom: 15px;
    }

    .docs-tab-panel .lead-text {
        font-size: 15px;
        margin-bottom: 25px;
    }

    .docs-section {
        margin-top: 30px;
        padding-top: 25px;
    }

    .premium-feature-list-docs {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .docs-table th,
    .docs-table td {
        padding: 12px 14px;
        font-size: 13.5px;
    }
}

/* ── Mobile Portrait & Narrow Widths (320px - 575px) ── */
@media (max-width: 575px) {
    .docs-page-content {
        padding: 30px 0 60px;
    }

    .docs-hero h1 {
        font-size: 28px;
        margin-bottom: 10px;
    }

    .docs-hero p {
        font-size: 14px;
        line-height: 1.4;
    }

    .docs-sidebar {
        padding: 12px;
        border-radius: 10px;
    }

    .docs-nav-tabs {
        gap: 8px;
    }

    .docs-nav-link {
        padding: 12px 14px;
        font-size: 13.5px;
        gap: 12px;
        border-radius: 8px;
    }

    .docs-nav-link .tab-icon {
        font-size: 16px;
        width: 20px;
        height: 20px;
    }

    .docs-content {
        padding: 24px 16px;
        border-radius: 10px;
    }

    .docs-tab-panel h2 {
        font-size: 22px;
        line-height: 1.3;
    }

    .docs-section h3 {
        font-size: 18px;
        margin-bottom: 12px;
    }

    .docs-table th,
    .docs-table td {
        padding: 10px 8px;
        font-size: 12.5px;
    }

    .docs-table code {
        font-size: 11px;
        padding: 2px 4px;
        word-break: break-all;
    }

    .code-block-container pre {
        padding: 15px;
    }

    .code-block-container code {
        font-size: 12.5px;
    }
}

/* ── Micro Screens (320px - 400px) ── */
@media (max-width: 400px) {
    .docs-hero h1 {
        font-size: 24px;
    }

    .docs-tab-panel h2 {
        font-size: 20px;
    }

    .code-header {
        padding: 10px 12px;
    }

    .copy-code-btn {
        padding: 4px 10px;
        font-size: 10.5px;
    }

    .code-header span {
        font-size: 10px;
    }

    .docs-table th,
    .docs-table td {
        padding: 8px 6px;
        font-size: 12px;
    }

    /* Prevent long API attribute words from causing horizontal scroll */
    .docs-table td {
        word-break: break-word;
    }
}

/* --- GOLD SAVINGS SCHEME RESPONSIVE STYLES --- */
@media (max-width: 767px) {
    .pt-docs-steps {
        width: 100%;
        overflow-x: scroll;
    }
}

/* Enable sticky sidebar scrolling by resetting html and body overflow properties on desktop */
@media (min-width: 992px) {

    html,
    body {
        overflow: visible !important;
        overflow-x: visible !important;
        overflow-y: visible !important;
    }
}