/* Shared UI quality layer for responsive layout, touch targets and accessibility. */

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

body {
    font-size: 16px;
    line-height: 1.5;
}

.muted,
small,
.ai-settings-field-hint {
    color: #4b5563;
}

small {
    font-size: 14px;
}

button,
input,
select {
    min-height: 44px;
    font-size: 15px;
}

textarea {
    font-size: 15px;
}

button,
input,
select,
textarea {
    max-width: 100%;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
[role="tab"]:focus-visible {
    outline: 3px solid currentColor;
    outline-offset: 2px;
}

main,
.app,
.page-title,
.table-card,
.ops-panel,
.regulations-layout,
.accounts-grid,
.admin-access-row {
    min-width: 0;
    max-width: 100%;
}

.table-wrap,
.ops-table-wrap,
.regulations-table-wrap,
.admin-access-list {
    max-width: 100%;
    overflow-x: auto;
    overscroll-behavior-inline: contain;
    -webkit-overflow-scrolling: touch;
}

.products-table,
.users-table,
.audit-table,
.regulations-table,
.ops-table-wrap table {
    min-width: max-content;
}

.mobile-nav-toggle {
    display: none;
}

.password-input-row {
    display: flex;
    gap: 8px;
    align-items: stretch;
    width: 100%;
}

.password-input-row > input {
    flex: 1 1 auto;
    min-width: 0;
}

.password-toggle {
    flex: 0 0 auto;
    white-space: nowrap;
}

.password-recovery {
    margin-top: 8px;
}

.password-recovery-note {
    margin: 8px 0 16px;
    padding: 10px 12px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    color: #374151;
    background: #f9fafb;
}

.ops-pagination {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin: 12px 0 24px;
}

.ops-pagination-info {
    color: #374151;
    text-align: center;
}

.ai-settings-clear-key {
    padding: 12px;
    border: 1px solid #b91c1c;
    border-radius: 8px;
    background: #fff7f7;
}

.ai-settings-clear-key span {
    color: #991b1b;
    font-weight: 600;
}

.ai-settings-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

.ai-settings-actions #testAiSettingsButton {
    background: transparent;
}

.ai-settings-actions #saveAiSettingsButton {
    order: -1;
}

@media (max-width: 760px) {
    header {
        flex-wrap: wrap;
        gap: 10px;
        padding-inline: 12px;
    }

    .mobile-nav-toggle {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        margin-left: auto;
    }

    header .top-nav {
        display: none;
        order: 10;
        flex: 1 0 100%;
        width: 100%;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 8px;
    }

    header .top-nav.mobile-open {
        display: grid;
    }

    header .top-nav .nav-button {
        width: 100%;
        min-width: 0;
        white-space: normal;
    }

    header .user-box {
        flex: 1 0 100%;
        justify-content: space-between;
        min-width: 0;
    }

    main {
        width: 100%;
        padding-inline: 12px;
    }

    .page-title,
    .ops-toolbar,
    .ops-toolbar-wrap,
    .feedback-filters,
    .audit-filters,
    .table-tools,
    .modal-actions,
    .ai-settings-actions {
        align-items: stretch;
        flex-direction: column;
    }

    .page-title > *,
    .ops-toolbar > *,
    .feedback-filters > *,
    .audit-filters > * {
        min-width: 0;
        width: 100%;
    }

    .table-wrap,
    .ops-table-wrap,
    .regulations-table-wrap {
        width: 100%;
        border-radius: 8px;
    }

    .products-table {
        min-width: 1050px;
    }

    .modal {
        width: calc(100vw - 24px);
        max-width: calc(100vw - 24px);
        max-height: calc(100vh - 24px);
        overflow: auto;
    }

    .ops-pagination {
        flex-wrap: wrap;
    }

    .ops-pagination > button {
        flex: 1 1 120px;
    }

    .ops-pagination-info {
        flex: 1 0 100%;
        order: -1;
    }
}

@media (min-width: 761px) and (max-width: 900px) {
    header {
        flex-wrap: wrap;
    }

    header .top-nav {
        flex-wrap: wrap;
    }
}

.page-help-button {
    display: inline-flex;
    align-items: center;
    min-height: 30px;
    margin-top: 7px;
    padding: 4px 9px;
    color: #4b5563;
    background: #fff;
    border: 1px solid #d6dbe3;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
}

.page-help-button:hover:not(:disabled) {
    color: #111827;
    background: #f7f8fa;
}

.page-help-backdrop {
    position: fixed;
    inset: 0;
    z-index: 1600;
    display: grid;
    place-items: start center;
    padding: 5vh 20px 24px;
    overflow-y: auto;
    background: rgba(17, 24, 39, .42);
}

.page-help-dialog {
    width: min(760px, 100%);
    max-height: calc(100vh - 10vh);
    overflow: auto;
    color: #1f2937;
    background: #fff;
    border: 1px solid #dfe3e8;
    border-radius: 10px;
    box-shadow: 0 18px 55px rgba(17, 24, 39, .22);
}

.page-help-header {
    position: sticky;
    top: 0;
    z-index: 1;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    padding: 18px 20px 14px;
    background: #fff;
    border-bottom: 1px solid #e5e7eb;
}

.page-help-header h2 {
    margin: 3px 0 0;
    color: #111827;
    font-size: 19px;
    line-height: 1.3;
}

.page-help-eyebrow {
    color: #7a8495;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .04em;
    text-transform: uppercase;
}

.page-help-close {
    min-width: 34px;
    min-height: 34px;
    padding: 0;
    font-size: 22px;
    line-height: 1;
}

.page-help-content {
    display: grid;
    gap: 16px;
    padding: 18px 20px 22px;
}

.page-help-purpose {
    margin: 0;
    color: #283241;
    font-size: 14px;
    line-height: 1.55;
}

.page-help-section {
    display: grid;
    gap: 7px;
}

.page-help-section h3 {
    margin: 0;
    color: #374151;
    font-size: 13px;
}

.page-help-section p,
.page-help-section ul {
    margin: 0;
    color: #596579;
    font-size: 13px;
    line-height: 1.55;
}

.page-help-section ul {
    display: grid;
    gap: 5px;
    padding-left: 20px;
}

.page-help-footer {
    margin: 0;
    padding-top: 12px;
    color: #7a8495;
    border-top: 1px solid #eceef1;
    font-size: 11px;
    line-height: 1.45;
}

body.page-help-open {
    overflow: hidden;
}

@media (max-width: 760px) {
    .page-help-backdrop {
        padding: 12px;
    }

    .page-help-dialog {
        width: 100%;
        max-height: calc(100vh - 24px);
    }

    .page-help-header,
    .page-help-content {
        padding-left: 14px;
        padding-right: 14px;
    }

    .page-help-button {
        min-height: 34px;
    }
}

