/**
 * Mobile layout for staff editor pages (/editor/*).
 */

body:has(.editor-container) {
    padding: var(--m-space-lg) !important;
    padding-top: calc(var(--m-space-lg) + env(safe-area-inset-top, 0px)) !important;
    padding-bottom: calc(var(--m-space-2xl) + var(--m-safe-bottom)) !important;
}

body:has(.editor-container) .editor-container {
    max-width: 100% !important;
    padding: var(--m-space-lg) !important;
    border-radius: var(--m-radius-lg) !important;
    margin: 0 !important;
}

.editor-header {
    margin-bottom: var(--m-space-lg) !important;
    padding-bottom: var(--m-space-md) !important;
}

.editor-header h1 {
    font-size: 22px !important;
}

.editor-nav,
.editor-menu {
    display: flex !important;
    flex-direction: column !important;
    gap: var(--m-space-sm) !important;
}

.editor-nav a,
.editor-menu a,
.editor-link-card {
    min-height: var(--m-touch-min) !important;
    display: flex !important;
    align-items: center !important;
    padding: var(--m-space-md) !important;
    border-radius: var(--m-radius-md) !important;
}

.editor-page .main-content,
.editor-layout .main-content {
    padding-top: calc(var(--m-header-h) + env(safe-area-inset-top, 0px) + var(--m-space-md)) !important;
}

.editor-page table,
.editor-layout table {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    max-width: 100%;
}

.editor-page thead,
.editor-layout thead {
    display: table-header-group;
}

.editor-page tbody tr,
.editor-layout tbody tr {
    border-bottom: 1px solid var(--tg-border-light);
}

.editor-toolbar {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: var(--m-space-sm) !important;
}

.editor-toolbar .btn,
.editor-toolbar button,
.editor-actions button {
    width: 100% !important;
    min-height: var(--m-touch-min) !important;
}

.editor-form .form-row {
    flex-direction: column !important;
}

.editor-knowledge-edit-page .editor-js-container {
    min-height: 50vh;
}

.editor-support-chats-page .chat-layout {
    flex-direction: column !important;
    height: calc(100dvh - var(--m-header-h));
}

.editor-support-chats-page .chats-list {
    max-height: 40vh;
    overflow-y: auto;
}

.editor-main-grid {
    grid-template-columns: 1fr !important;
    gap: var(--m-space-md) !important;
}

.editor-card {
    border-radius: var(--m-radius-lg) !important;
    padding: var(--m-space-lg) !important;
}

/* Card fallback for editor tables */
@media (max-width: 768px) {
    .editor-mobile-card {
        background: var(--tg-bg-card);
        border: 1px solid var(--tg-border-light);
        border-radius: var(--m-radius-md);
        padding: var(--m-space-md);
        margin-bottom: var(--m-space-sm);
    }

    .editor-mobile-card__title {
        font-weight: 700;
        font-size: var(--m-font-body);
        margin-bottom: var(--m-space-xs);
    }

    .editor-mobile-card__meta {
        font-size: var(--m-font-meta);
        color: var(--tg-text-secondary);
    }
}
