/* ========================================================================== */
/* GoodByte Mail - Mobile & Responsive Layer                                  */
/* Loaded last on purpose so it can safely override legacy and isolated CSS.  */
/* ========================================================================== */

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

body {
    min-width: 0;
}

img,
svg,
video,
canvas {
    max-width: 100%;
}

/* -------------------------------------------------------------------------- */
/* Main application shell                                                     */
/* -------------------------------------------------------------------------- */
.gb-shell {
    width: 100%;
    min-width: 0;
    min-height: 100dvh;
    display: grid !important;
    direction: inherit !important;
    grid-template-columns: minmax(0, 1fr) var(--gb-sidebar-width, 278px) !important;
    grid-template-areas: "main sidebar" !important;
}

html[dir="ltr"] .gb-shell {
    grid-template-columns: var(--gb-sidebar-width, 278px) minmax(0, 1fr) !important;
    grid-template-areas: "sidebar main" !important;
}

.gb-sidebar {
    grid-area: sidebar;
    width: auto !important;
    min-width: 0 !important;
    max-width: none;
    padding: 0 !important;
    display: flex !important;
    flex-direction: column;
    overflow: hidden;
}

.gb-main {
    grid-area: main;
    width: 100%;
    min-width: 0 !important;
    max-width: 100%;
}

.gb-sidebar-header {
    min-height: 82px;
    padding: 16px 15px !important;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.gb-brand {
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 10px;
}

.gb-brand-text {
    min-width: 0;
    display: grid;
    gap: 2px;
}

.gb-brand-text strong,
.gb-brand-text span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.gb-sidebar-scroll {
    min-height: 0;
    flex: 1 1 auto;
    overflow-y: auto !important;
    overflow-x: hidden;
    overscroll-behavior: contain;
}

.gb-server-status {
    display: grid;
    grid-template-columns: auto minmax(0,1fr);
    align-items: center;
    gap: 9px;
}

.gb-sidebar-overlay {
    display: none;
}

.gb-mobile-menu-button {
    display: none;
    width: 40px;
    height: 40px;
    flex: 0 0 40px;
    place-items: center;
    border: 1px solid var(--gb-border, #dce9ec);
    border-radius: 10px;
    background: #fff;
    color: #174956;
    font: inherit;
    font-size: 20px;
    cursor: pointer;
}

.gb-topbar {
    width: 100%;
    min-width: 0;
}

.gb-topbar-start,
.gb-topbar-end {
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 10px;
}

.gb-page-brand {
    min-width: 0;
    display: grid;
    gap: 2px;
}

.gb-page-brand strong,
.gb-page-brand span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.gb-online-indicator {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    white-space: nowrap;
}

/* -------------------------------------------------------------------------- */
/* Shared responsive content                                                  */
/* -------------------------------------------------------------------------- */
.gb-content,
.client-main,
.public-main {
    min-width: 0;
    max-width: 100%;
}

.gb-content > *,
.client-main > *,
.public-main > * {
    min-width: 0;
    max-width: 100%;
}

.gb-content :is(.panel,.card,.gb-page-card,.table-card,.profile-card,.stat,.stat-card,.feature-tile),
.client-main :is(.panel,.card) {
    min-width: 0;
}

.gb-content :is(.actions,.actions-bar,.inline-filter,.panel-head,.page-head,.page-header,.gb-page-head,.gb-page-actions,.toolbar,.filters,.actions-row,.form-actions),
.client-main :is(.actions,.actions-bar,.toolbar,.filters) {
    max-width: 100%;
}

.gb-content :is(input,select,textarea,button),
.client-main :is(input,select,textarea,button) {
    max-width: 100%;
}

.gb-content :is(input:not([type="checkbox"]):not([type="radio"]),select,textarea),
.client-main :is(input:not([type="checkbox"]):not([type="radio"]),select,textarea) {
    width: 100%;
    min-width: 0;
}

.gb-content :is(.table-wrap,.data-table,.gb-table-wrap,.table-card),
.client-main :is(.table-wrap,.data-table,.gb-table-wrap,.table-card) {
    width: 100%;
    max-width: 100%;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch;
}

.gb-content table,
.client-main table {
    max-width: none;
}

.gb-content :is(.data-head,.data-row) {
    max-width: none;
}

/* -------------------------------------------------------------------------- */
/* Tablet                                                                     */
/* -------------------------------------------------------------------------- */
@media (max-width: 1120px) {
    .gb-shell,
    html[dir="ltr"] .gb-shell {
        display: block !important;
        grid-template-columns: none !important;
        grid-template-areas: none !important;
    }

    .gb-main {
        width: 100% !important;
    }

    .gb-sidebar {
        position: fixed !important;
        top: 0 !important;
        bottom: 0 !important;
        inset-inline-start: 0 !important;
        z-index: 5000 !important;
        width: min(320px, 88vw) !important;
        max-width: 88vw !important;
        height: 100dvh !important;
        border-radius: 0 !important;
        box-shadow: 0 0 45px rgba(0,0,0,.24) !important;
        transition: transform .22s ease !important;
        will-change: transform;
    }

    html[dir="rtl"] .gb-sidebar {
        right: 0 !important;
        left: auto !important;
        transform: translateX(110%) !important;
    }

    html[dir="ltr"] .gb-sidebar {
        left: 0 !important;
        right: auto !important;
        transform: translateX(-110%) !important;
    }

    .gb-sidebar.gb-sidebar-open {
        transform: translateX(0) !important;
    }

    .gb-sidebar-overlay {
        position: fixed;
        inset: 0;
        z-index: 4900;
        display: block !important;
        width: 100vw;
        height: 100dvh;
        padding: 0;
        border: 0;
        background: rgba(3, 34, 43, .52);
        backdrop-filter: blur(2px);
        cursor: default;
    }

    .gb-mobile-menu-button {
        display: grid !important;
    }

    .gb-sidebar-close {
        display: grid !important;
        place-items: center;
    }

    .gb-content {
        width: 100% !important;
        max-width: 100% !important;
        padding: 18px 16px 34px !important;
    }

    .gb-topbar {
        padding-inline: 14px !important;
    }

    .gb-content :is(.form-grid.four,.four,.gb-stats-grid,.stats-grid,.six-cards,.as-cards,.mon-cards,.rep-cards,.s6-cards,.ds-stats) {
        grid-template-columns: repeat(2, minmax(0,1fr)) !important;
    }
}

/* -------------------------------------------------------------------------- */
/* Mobile                                                                     */
/* -------------------------------------------------------------------------- */
@media (max-width: 760px) {
    :root {
        --gb-mobile-gap: 10px;
    }

    .gb-topbar {
        position: sticky;
        top: 0;
        z-index: 3000;
        height: auto !important;
        min-height: 60px !important;
        padding: 8px 10px !important;
        gap: 8px !important;
        flex-wrap: nowrap;
    }

    .gb-topbar-start {
        flex: 1 1 auto;
        min-width: 0;
        gap: 8px;
    }

    .gb-page-brand {
        flex: 1 1 auto;
        min-width: 0;
    }

    .gb-page-brand strong {
        font-size: 12px !important;
    }

    .gb-page-brand span {
        display: none !important;
    }

    .gb-topbar-end {
        flex: 0 0 auto;
        gap: 5px !important;
    }

    .gb-online-indicator {
        display: none !important;
    }

    .gb-logout-button {
        min-height: 38px !important;
        padding-inline: 9px !important;
        font-size: 10px !important;
    }

    .gb-language-switcher {
        max-width: 118px;
    }

    .gb-content {
        padding: 10px 9px 28px !important;
    }

    .gb-content > h1,
    .gb-content :is(.page-title,.gb-page-head h1,.page-head h1,.page-header h1,.head h1) {
        font-size: clamp(21px, 6.5vw, 27px) !important;
        line-height: 1.35 !important;
        overflow-wrap: anywhere;
    }

    .gb-content .lead,
    .gb-content :is(.gb-page-head p,.page-head p,.page-header p) {
        font-size: 12px !important;
        line-height: 1.75 !important;
    }

    .gb-content :is(.panel,.card,.gb-page-card,.table-card,.profile-card,.stat,.stat-card) {
        padding: 13px !important;
        border-radius: 13px !important;
    }

    .gb-content :is(.panel-head,.page-head,.page-header,.gb-page-head,.head,.mig-head,.em-head,.s6-head,.ed-head,.hc-head,.hf-head,.sa-head,.st-head,.n-head,.rep-head,.as-head,.mon-head) {
        display: flex !important;
        flex-direction: column !important;
        align-items: stretch !important;
        justify-content: flex-start !important;
        gap: 10px !important;
        width: 100% !important;
        max-width: 100% !important;
    }

    .gb-content :is(.inline-filter,.actions,.actions-bar,.gb-page-actions,.page-actions,.toolbar,.filters,.quick-actions>div,.compose-actions,.form-actions) {
        display: flex !important;
        flex-wrap: wrap !important;
        width: 100% !important;
        gap: 8px !important;
    }

    .gb-content :is(.inline-filter,.actions-bar,.gb-page-actions,.page-actions,.form-actions) > * {
        min-width: 0 !important;
        flex: 1 1 140px;
    }

    .gb-content :is(button,.btn,.primary,.ghost,.mini,.gb-action-primary,.gb-action-secondary) {
        min-height: 42px;
        white-space: normal;
    }

    .gb-content .field.small {
        min-width: 0 !important;
        width: 100% !important;
    }

    /* Collapse the major page grids to one column. */
    .gb-content :is(
        .grid,
        .cards,
        .stats,
        .stats-grid,
        .gb-stats-grid,
        .gb-metric-grid,
        .six-cards,
        .dashboard-grid,
        .gb-dashboard-grid,
        .form,
        .form-grid,
        .form-grid.two,
        .form-grid.three,
        .form-grid.four,
        .form-grid.v2,
        .field-grid,
        .four,
        .plans,
        .plan-cards,
        .profile-grid,
        .profile-meta,
        .services-grid,
        .gb-services-grid,
        .gb-products-grid,
        .gb-cart-layout,
        .gb-catalog-toolbar,
        .as-cards,
        .as-form,
        .as-grid,
        .dns-overview-grid,
        .dns-record,
        .ds-grid.two,
        .ds-result,
        .ds-stats,
        .em-grid,
        .em-stats,
        .hf-grid,
        .journey,
        .mail-section,
        .mail-window-body,
        .mon-cards,
        .mon-details,
        .platform-section,
        .preview-body,
        .preview-cards,
        .record-content,
        .register-benefits,
        .rep-cards,
        .s6-cards,
        .sa-grid,
        .search-grid,
        .st-grid,
        .why-grid
    ) {
        grid-template-columns: minmax(0,1fr) !important;
    }

    .gb-content :is(.gb-cart-item,.gb-services-grid a) {
        grid-template-columns: minmax(0,1fr) !important;
    }

    /* Horizontal data grids remain readable instead of being squeezed. */
    .gb-content :is(.data-table,.table-wrap,.gb-table-wrap,.table-card) {
        margin-inline: 0 !important;
        border-radius: 11px !important;
    }

    .gb-content :is(.data-head,.data-row) {
        min-width: 680px !important;
    }

    .gb-content table {
        min-width: 680px;
        font-size: 12px;
    }

    .gb-content table :is(th,td) {
        white-space: nowrap;
        padding: 10px !important;
    }

    .gb-content :is(.aliases-header,.alias-row,.backup-header,.backup-row,.domains-header,.domain-row,.trace-header,.trace-row) {
        min-width: 680px !important;
    }

    /* Modals and dialogs */
    .modal-back,
    .wm-modal-back {
        padding: 10px !important;
        align-items: center !important;
    }

    .compose-card,
    .modal,
    .dialog,
    .wm-modal,
    .gb-modal {
        width: min(100%, 560px) !important;
        max-width: 100% !important;
        max-height: calc(100dvh - 20px) !important;
        overflow: auto !important;
        border-radius: 15px !important;
    }

    .compose-card {
        padding: 16px !important;
    }

    .compose-head {
        gap: 8px;
    }

    .client-topbar {
        min-height: 60px !important;
        height: auto !important;
        padding: 7px 9px !important;
        gap: 7px !important;
        flex-wrap: wrap;
    }

    .client-brand {
        min-width: 0;
        flex: 1 1 auto;
    }

    .client-brand img {
        max-width: 96px !important;
        height: auto !important;
    }

    .client-brand > div,
    .client-account-copy {
        display: none !important;
    }

    .client-account {
        gap: 5px !important;
        flex-wrap: wrap;
        justify-content: flex-end;
    }

    .client-avatar {
        width: 34px !important;
        height: 34px !important;
        flex: 0 0 34px;
    }

    .client-logout {
        min-height: 36px !important;
        padding-inline: 8px !important;
        font-size: 10px !important;
    }

    .client-main {
        min-height: calc(100dvh - 60px) !important;
    }

    /* Public / registration pages */
    .customer-register,
    .gb-mail-login,
    .gb-login-layout {
        max-width: 100vw !important;
        overflow-x: hidden !important;
    }

    .customer-register .register-shell,
    .gb-mail-login .login-shell {
        width: 100% !important;
        max-width: 100% !important;
        grid-template-columns: minmax(0,1fr) !important;
    }

    .customer-register .register-main,
    .gb-mail-login .form-container {
        width: 100% !important;
        min-width: 0 !important;
    }

    .landing-header,
    .landing-footer,
    .hero {
        grid-template-columns: minmax(0,1fr) !important;
    }
}

@media (max-width: 440px) {
    .gb-topbar {
        padding-inline: 7px !important;
    }

    .gb-page-brand strong {
        max-width: 130px;
    }

    .gb-mobile-menu-button {
        width: 38px;
        height: 38px;
        flex-basis: 38px;
    }

    .gb-content {
        padding-inline: 7px !important;
    }

    .gb-content :is(.panel,.card,.gb-page-card,.table-card) {
        padding: 11px !important;
    }

    .gb-content :is(.data-head,.data-row),
    .gb-content table,
    .gb-content :is(.aliases-header,.alias-row,.backup-header,.backup-row,.domains-header,.domain-row,.trace-header,.trace-row) {
        min-width: 620px !important;
    }
}

/* ========================================================================== */
/* Responsive correctness V2 - page headers + tablet/mobile content           */
/* The legacy app.css used `main header`, which fixed every page header to     */
/* 68px. These rules also guard against old cached/isolated CSS.               */
/* ========================================================================== */

/* Never let a page-level header inherit the old shell header dimensions. */
.gb-content > header,
.gb-content :is(
    .gb-dashboard-hero,
    .profile-hero,
    .gb-catalog-hero,
    .gb-cart-header,
    .gb-page-head,
    .wm-list-head,
    .wm-reader-head
) {
    height: auto !important;
    min-height: 0 !important;
    overflow: visible;
}

.gb-content :is(
    .gb-dashboard-hero,
    .profile-hero,
    .gb-catalog-hero,
    .gb-cart-header,
    .gb-page-head
) > div {
    min-width: 0;
}

/* The layout switches to an off-canvas sidebar at this width, so page content
   must switch to its tablet layout at the same breakpoint rather than waiting
   until 760/820px. */
@media (max-width: 1120px) {
    .gb-topbar {
        min-height: 64px !important;
        height: auto !important;
        padding-block: 8px !important;
    }

    .gb-topbar-start,
    .gb-topbar-end {
        flex-wrap: nowrap !important;
    }

    .gb-topbar-start {
        flex: 1 1 auto;
    }

    .gb-topbar-end {
        flex: 0 0 auto;
    }

    /* Customer dashboard */
    .gb-customer-dashboard {
        padding: 14px !important;
    }

    .gb-dashboard-hero {
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 16px !important;
        padding: 20px !important;
    }

    .gb-dashboard-hero h1 {
        margin-top: 5px !important;
        font-size: clamp(23px, 4vw, 30px) !important;
        line-height: 1.35 !important;
    }

    .gb-dashboard-hero p {
        line-height: 1.75 !important;
    }

    .gb-hero-actions {
        width: 100%;
        display: grid !important;
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 8px !important;
    }

    .gb-hero-actions a {
        min-width: 0;
        text-align: center;
        white-space: normal !important;
    }

    .gb-dashboard-grid {
        grid-template-columns: minmax(0, 1fr) !important;
    }

    .gb-stats-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
    }

    .gb-services-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    }

    /* Customer profile */
    .customer-profile-page {
        width: 100%;
        max-width: 100% !important;
        padding: 14px !important;
    }

    .profile-hero {
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 16px !important;
        padding: 22px !important;
    }

    .profile-hero h1 {
        font-size: clamp(24px, 4vw, 31px) !important;
        line-height: 1.35 !important;
    }

    .profile-completeness {
        width: 100% !important;
        min-width: 0 !important;
        box-sizing: border-box;
    }

    .profile-grid {
        grid-template-columns: repeat(2, minmax(0,1fr)) !important;
    }

    .profile-meta {
        grid-template-columns: repeat(3, minmax(0,1fr)) !important;
    }

    /* Service catalog */
    .gb-catalog-page {
        width: 100%;
        max-width: 100%;
        padding: 14px !important;
    }

    .gb-catalog-hero {
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 14px !important;
        padding: 20px !important;
    }

    .gb-catalog-hero h1 {
        font-size: clamp(23px, 4vw, 29px) !important;
        line-height: 1.35 !important;
    }

    .gb-catalog-hero p {
        line-height: 1.75 !important;
    }

    .gb-cart-link {
        align-self: flex-start;
    }

    .gb-catalog-toolbar {
        grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) !important;
    }

    .gb-products-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    }

    /* Common page headings used by the admin/operations screens. */
    .gb-page-head,
    .page-head,
    .page-header,
    .head,
    .mig-head,
    .em-head,
    .s6-head,
    .ed-head,
    .hc-head,
    .hf-head,
    .sa-head,
    .st-head,
    .n-head,
    .rep-head,
    .as-head,
    .mon-head {
        height: auto !important;
        min-height: 0 !important;
        overflow: visible !important;
    }
}

@media (max-width: 820px) {
    .gb-online-indicator {
        display: none !important;
    }

    .profile-grid,
    .profile-meta,
    .gb-catalog-toolbar {
        grid-template-columns: minmax(0, 1fr) !important;
    }

    .gb-cart-link {
        width: 100%;
        box-sizing: border-box;
        justify-content: center;
    }
}

@media (max-width: 760px) {
    .gb-topbar {
        min-height: 58px !important;
        padding: 7px 8px !important;
        gap: 7px !important;
    }

    .gb-topbar-start {
        gap: 7px !important;
    }

    .gb-page-brand strong {
        max-width: min(44vw, 210px);
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .gb-topbar-end {
        gap: 4px !important;
    }

    .gb-language-switcher {
        min-height: 32px !important;
        max-width: none !important;
        padding: 3px 5px !important;
        gap: 2px !important;
        box-shadow: none !important;
    }

    .gb-language-option {
        padding: 5px 6px !important;
        font-size: 10px !important;
    }

    .gb-language-divider {
        font-size: 9px !important;
    }

    .gb-logout-button {
        min-height: 34px !important;
        padding: 0 8px !important;
        font-size: 10px !important;
    }

    .gb-content {
        padding: 9px 8px 26px !important;
    }

    .gb-customer-dashboard,
    .customer-profile-page,
    .gb-catalog-page {
        padding: 8px !important;
    }

    .gb-dashboard-hero,
    .profile-hero,
    .gb-catalog-hero {
        padding: 17px 15px !important;
        border-radius: 15px !important;
    }

    .gb-hero-actions {
        grid-template-columns: minmax(0,1fr) !important;
    }

    .gb-stats-grid,
    .gb-services-grid,
    .gb-products-grid {
        grid-template-columns: minmax(0, 1fr) !important;
    }

    .profile-actions {
        flex-direction: column-reverse !important;
    }

    .profile-actions > * {
        width: 100%;
        box-sizing: border-box;
    }

    .gb-category-tabs {
        margin-inline: -8px !important;
        padding-inline: 8px !important;
        scroll-padding-inline: 8px;
    }
}

@media (max-width: 480px) {
    .gb-page-brand strong {
        max-width: 34vw;
        font-size: 11px !important;
    }

    .gb-language-option {
        font-size: 9px !important;
        padding-inline: 5px !important;
    }

    .gb-logout-button {
        padding-inline: 7px !important;
    }

    .gb-dashboard-hero h1,
    .profile-hero h1,
    .gb-catalog-hero h1 {
        font-size: 23px !important;
    }
}

