/* Global responsive improvements for Waplix */

html,
body {
    max-width: 100%;
    overflow-x: hidden;
}

body.documentation-body {
    overflow-x: clip;
}

img,
video,
svg,
canvas,
iframe {
    max-width: 100%;
    height: auto;
}

.app-shell,
.app-main,
.app-main > .container-fluid,
.dashboard-page,
.instance-page,
.developer-page,
.billing-page,
.settings-page,
.documentation-page,
.documentation-body .documentation-page {
    min-width: 0;
}

.container-fluid,
.row,
[class*="grid"],
[class*="-grid"],
[class*="-wrap"],
[class*="-shell"] {
    min-width: 0;
}

.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.table-responsive > .table {
    min-width: 640px;
}

pre,
code,
.code-card pre,
.docs-code-block,
.developer-response-panel,
.endpoint-row code {
    max-width: 100%;
    overflow-x: auto;
    word-break: break-word;
}

.endpoint-row,
.secret-row,
.developer-copy-box,
.docs-playground-card,
.settings-field-grid.two {
    min-width: 0;
}

@media (max-width: 1023px) {
    .developer-stats-grid,
    .dash-stats-grid,
    .dash-chart-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .developer-main-grid,
    .developer-code-grid {
        grid-template-columns: 1fr;
    }

    .documentation-body .documentation-page {
        grid-template-columns: 1fr;
        width: 100%;
    }

    body.documentation-body .docs-layout > .docs-shell,
    body.documentation-body .docs-layout > .docs-shell > .documentation-page {
        margin-left: 0 !important;
    }
}

@media (max-width: 900px) {
    .app-topbar .container-fluid {
        gap: 10px;
        flex-wrap: nowrap;
    }

    .topbar-profile-name {
        max-width: 110px !important;
    }

    .settings-v2-head {
        flex-direction: column;
        align-items: stretch;
    }

    .settings-save-all {
        width: 100%;
    }

    .endpoint-row {
        grid-template-columns: 1fr;
        gap: 8px;
    }

    .endpoint-head {
        display: none;
    }

    .endpoint-row > span:not(.method-pill) {
        display: block;
    }

    .secret-row {
        grid-template-columns: 1fr;
    }

    .login-card,
    .login-card.register-card {
        grid-template-columns: 1fr;
        width: 100%;
        max-width: 100%;
    }

    .login-shell {
        width: min(100% - 24px, 560px);
        margin: 0 auto;
        padding: 0;
    }

    .login-visual-panel,
    .register-visual-panel {
        min-height: 320px;
        padding: 28px;
    }

    .documentation-body .docs-playground {
        position: static;
        max-height: none;
    }
}

@media (max-width: 768px) {
    body.subscriptions-body .my-subscriptions-page {
        padding-left: max(12px, env(safe-area-inset-left));
        padding-right: max(12px, env(safe-area-inset-right));
    }

    body.subscriptions-body .billing-page.my-subscriptions-page {
        margin: 0 !important;
    }

    body.subscriptions-body .my-subscriptions-page .billing-table-scroll {
        max-width: 100%;
        margin-left: 0;
        margin-right: 0;
        padding-bottom: 4px;
    }
}

@media (max-width: 768px) {
    .dashboard-page,
    .instance-page,
    .developer-page,
    .billing-page:not(.subscriptions-page),
    .settings-page.settings-v2 {
        margin: 0;
        padding: 14px 12px 80px;
    }

    .settings-v2 .settings-shell-card {
        margin-top: 4px;
    }

    .developer-hero {
        display: grid;
        gap: 14px;
    }

    .developer-hero-actions {
        width: 100%;
    }

    .developer-hero-actions a,
    .developer-hero-actions button {
        width: 100%;
    }

    .developer-main-grid,
    .developer-code-grid,
    .api-terminal-wrap {
        min-width: 0;
        max-width: 100%;
    }

    .language-pills {
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        padding-bottom: 4px;
        margin-right: -4px;
    }

    .language-pills button {
        flex: 0 0 auto;
        white-space: nowrap;
    }

    .developer-code-card pre,
    .developer-response-panel,
    .endpoint-table {
        max-width: 100%;
        overflow-x: auto;
    }

    .secret-row,
    .developer-copy-box {
        grid-template-columns: 1fr;
    }

    .developer-copy-box button {
        width: 100%;
    }

    .dash-stats-grid,
    .dash-chart-grid,
    .developer-stats-grid {
        grid-template-columns: 1fr;
    }

    .settings-field-grid.two {
        grid-template-columns: 1fr;
    }

    .settings-v2-tabs {
        overflow-x: auto;
        flex-wrap: nowrap;
        -webkit-overflow-scrolling: touch;
    }

    .settings-v2-tabs a {
        flex: 0 0 auto;
        white-space: nowrap;
    }

    .settings-profile-form {
        display: grid;
        gap: 14px;
    }

    .settings-submit-btn,
    .settings-danger-btn-v2,
    .dash-primary-btn,
    .add-funds-btn {
        width: 100%;
    }

    .modal-dialog {
        margin: 12px;
        max-width: calc(100vw - 24px);
    }

    .waplix-toast-region {
        padding: max(16px, env(safe-area-inset-top)) 16px 16px;
    }

    .waplix-toast-stack {
        width: min(360px, calc(100vw - 32px));
    }

    .waplix-flash {
        padding: 24px 20px 20px;
        border-radius: 20px;
        gap: 10px;
    }

    .waplix-flash-icon {
        width: 48px;
        height: 48px;
        font-size: 1.25rem;
    }

    .waplix-flash-title {
        font-size: 1rem;
    }

    .waplix-flash-message {
        font-size: 0.86rem;
        max-width: 100%;
    }
}

@media (max-width: 560px) {
    .login-page-layout {
        width: calc(100% - max(20px, env(safe-area-inset-left) + env(safe-area-inset-right)));
        gap: 12px;
        padding-top: max(10px, env(safe-area-inset-top));
        padding-bottom: max(16px, env(safe-area-inset-bottom));
    }

    .login-shell {
        width: 100%;
        padding: 0;
    }

    .login-form-panel,
    .settings-v2 .settings-shell-card {
        padding: 18px;
    }

    .login-card {
        border-radius: 24px;
    }

    .login-heading h1 {
        font-size: clamp(1.85rem, 9vw, 2.5rem);
    }

    .login-register {
        font-size: 0.92rem;
        line-height: 1.5;
    }

    .topbar-profile-trigger {
        padding-right: 8px !important;
    }

    .theme-segmented-control {
        width: 100%;
    }

    .theme-segmented-control button,
    .theme-segmented-option span {
        flex: 1 1 auto;
        min-width: 0;
    }

    .mobile-bottom-nav {
        padding-bottom: env(safe-area-inset-bottom, 0px);
    }
}

@media (min-width: 901px) {
    .sidebar-toggle-btn {
        display: none;
    }

    body.sidebar-collapsed .app-main {
        margin-left: 0 !important;
    }
}

@media (max-width: 900px) {
    body.sidebar-open {
        overflow: hidden;
    }

    .app-sidebar {
        position: fixed;
        top: 0;
        left: 0;
        z-index: 100000;
        height: 100vh;
        transform: translateX(-105%);
        transition: transform 0.24s ease;
    }

    body.sidebar-open .app-sidebar {
        transform: translateX(0);
    }

    .sidebar-backdrop {
        display: none;
        position: fixed;
        inset: 0;
        z-index: 99990;
        border: 0;
        background: rgba(0, 0, 0, 0.45);
    }

    body.sidebar-open .sidebar-backdrop {
        display: block;
    }
}

@media (max-width: 360px) {
    .topbar-profile-name {
        display: none !important;
    }

    .navbar-brand {
        font-size: 1rem !important;
    }
}
