/* Дополнительные адаптивные правки поверх styles.css */

html,
body {
    overflow-x: hidden;
}

@media (max-width: 1024px) {
    .app-container,
    #appContainer.visible {
        height: 100dvh;
    }

    .main-layout,
    .content-area {
        min-height: 0;
    }

    .header {
        position: sticky;
        top: 0;
        z-index: 150;
    }

    .header-center {
        min-width: 0;
        overflow-x: auto;
        scrollbar-width: none;
        -ms-overflow-style: none;
    }

    .header-center::-webkit-scrollbar {
        display: none;
    }

    .header-center .nav-item {
        min-height: 42px;
        white-space: nowrap;
    }

    .messages-list,
    .documents-list,
    .chat-list,
    .chat-messages,
    .sidebar-nav,
    .modal-body {
        -webkit-overflow-scrolling: touch;
    }

    .message-header-left {
        width: 100%;
    }

    .message-mail-actions {
        width: 100%;
    }

    .message-mail-action-btn,
    .btn-assignment-work {
        min-height: 40px;
    }

    .users-list {
        padding: 12px;
    }

    .user-item {
        align-items: flex-start;
        gap: 10px;
    }

    .chat-header {
        gap: 8px;
    }

    .chat-header-info {
        min-width: 0;
    }

    .chat-header-name {
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .chat-header-actions {
        flex-shrink: 0;
    }

    .chat-room-members-panel {
        max-height: 40vh;
        overflow-y: auto;
    }
}

@media (max-width: 768px) {
    .mail-list-area,
    .message-detail,
    .documents-list-wrap,
    .chat-container {
        width: 100%;
        max-width: 100%;
    }

    .message-detail {
        border-left: none;
        border-top: 1px solid var(--border-color);
    }

    .chat-sidebar {
        max-height: 38dvh;
    }

    .chat-header-search-input {
        width: min(56vw, 220px);
    }

    .chat-item-room-delete {
        width: 26px;
        height: 26px;
        border-radius: 8px;
    }

    .modal-content {
        width: min(100%, 680px);
        max-height: 90dvh;
    }
}

@media (max-width: 480px) {
    .header {
        height: auto;
        min-height: 56px;
        flex-wrap: wrap;
        align-items: center;
        row-gap: 8px;
        padding-top: 8px;
        padding-bottom: 8px;
        padding-left: max(10px, env(safe-area-inset-left));
        padding-right: max(10px, env(safe-area-inset-right));
    }

    .header-left {
        flex: 1 1 auto;
        min-width: 0;
        gap: 8px;
    }

    .header-right {
        flex: 0 0 auto;
        min-width: 0;
    }

    .header-center {
        order: 10;
        width: 100%;
        flex: 0 0 100%;
        display: flex;
        justify-content: flex-start;
        gap: 8px;
        overflow-x: auto;
        padding: 2px 0 2px;
        scrollbar-width: none;
        -ms-overflow-style: none;
    }

    .header-center::-webkit-scrollbar {
        display: none;
    }

    .header-center .nav-item {
        flex: 0 0 auto;
        min-width: 44px;
        min-height: 38px;
        padding: 8px 10px;
    }

    .logo .brand-name {
        font-size: 18px;
    }

    .logo .brand-logo-img {
        height: 28px;
    }

    .main-layout {
        padding-bottom: env(safe-area-inset-bottom);
    }

    .sidebar {
        max-width: 92vw;
    }

    .section-header {
        gap: 10px;
    }

    .section-title {
        font-size: 16px;
    }

    .btn-primary,
    .btn-secondary,
    .user-action-btn,
    .chat-action-btn,
    .chat-send-btn,
    .chat-attach-btn {
        min-height: 40px;
    }

    .user-item {
        flex-direction: column;
        align-items: stretch;
    }

    .user-info {
        width: 100%;
    }

    .user-actions {
        width: 100%;
        justify-content: flex-end;
    }

    .message-header {
        padding: 10px 12px;
    }

    .message-body,
    .message-detail-body--letter {
        padding: 12px;
    }

    .chat-main {
        min-height: 0;
    }

    .chat-sidebar {
        max-height: 45dvh;
    }

    .chat-message {
        max-width: 92%;
    }

    .chat-item-header {
        gap: 6px;
    }

    .chat-item-time {
        font-size: 11px;
    }

    .chat-item-preview {
        font-size: 12px;
    }

    .chat-header {
        padding: 10px 12px;
    }

    .chat-header-name {
        font-size: 15px;
    }

    .chat-header-meta {
        font-size: 12px;
    }

    .chat-header-search-input {
        width: min(52vw, 180px);
        font-size: 12px;
    }

    .chat-input-area {
        padding: 8px 10px;
        gap: 8px;
    }

    .chat-message-input {
        min-height: 38px;
    }

    .chat-attachment-image {
        max-width: 130px;
        max-height: 100px;
    }

    .modal-content {
        width: 100%;
        border-radius: 12px 12px 0 0;
        margin-top: auto;
        padding-bottom: calc(8px + env(safe-area-inset-bottom));
    }

    .modal-header,
    .modal-footer {
        padding: 12px 14px;
    }

    .modal-body {
        padding: 14px;
    }
}

@media (max-width: 360px) {
    .chat-header-search-input {
        width: 46vw;
    }

    .chat-item-avatar,
    .chat-message-avatar {
        width: 34px;
        height: 34px;
        font-size: 11px;
    }
}
