/* HEXAI — mobile layout (phones & small tablets) */

@media (max-width: 768px) {
    html,
    body {
        overflow-x: hidden;
        width: 100%;
        max-width: 100%;
    }

    .auth-container,
    .auth-container .main-content,
    .auth-container .content-section,
    .main-content,
    .content-section,
    .content-wrapper,
    .users-table-container,
    .content-management,
    .support-groups-panel,
    .self-reset-card {
        width: 100%;
        max-width: 100%;
        box-sizing: border-box;
        overflow-x: hidden;
    }

    .main-content {
        width: 100% !important;
        max-width: 100% !important;
        margin-left: 0 !important;
        padding-left: 0.75rem !important;
        padding-right: 0.75rem !important;
    }

    .content-section {
        padding-left: 0.75rem !important;
        padding-right: 0.75rem !important;
    }

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

    canvas:not(.auth-wave-canvas) {
        max-width: 100%;
        height: auto;
    }

    .auth-wave-canvas {
        width: 100% !important;
        max-width: 100% !important;
        height: 100vh !important;
        height: 100dvh !important;
        max-height: none !important;
    }

    /* ── Bottom navigation instead of left sidebar ── */
    .sidebar {
        width: 100%;
        height: auto;
        min-height: 58px;
        top: auto;
        bottom: 0;
        left: 0;
        right: 0;
        flex-direction: row;
        align-items: stretch;
        padding: 0;
        padding-bottom: env(safe-area-inset-bottom, 0px);
        border-right: none;
        border-top: 1px solid rgba(255, 52, 52, 0.2);
        overflow: visible;
        z-index: 10050;
    }

    .sidebar:hover {
        width: 100%;
    }

    .sidebar .logo-container {
        display: none;
    }

    .sidebar .nav-menu {
        flex-direction: row;
        flex: 1;
        justify-content: space-around;
        align-items: stretch;
        gap: 0;
        padding: 0;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }

    .sidebar .nav-menu::-webkit-scrollbar {
        display: none;
    }

    .sidebar-footer {
        display: flex;
        align-items: stretch;
        padding: 0;
        border-top: none;
        flex-shrink: 0;
    }

    .sidebar .nav-item {
        flex: 1 1 0;
        min-width: 0;
        max-width: none;
        height: auto;
        min-height: 58px;
        flex-direction: column;
        justify-content: center;
        gap: 2px;
        padding: 6px 2px;
        border-radius: 0;
    }

    .sidebar .nav-item i {
        min-width: 0;
        width: auto;
        font-size: 1.05rem;
    }

    .sidebar .nav-item-coming-soon {
        min-width: 58px;
    }

    .sidebar .nav-item-coming-soon .nav-item-icon-stack {
        min-width: 0;
        width: auto;
        height: 29px;
        gap: 1px;
    }

    .sidebar .nav-item-coming-soon .nav-item-icon-stack i {
        font-size: 0.95rem;
    }

    .sidebar .nav-item-coming-soon .nav-soon-badge {
        font-size: 0.4rem;
    }

    .sidebar .nav-label {
        opacity: 1;
        transform: none;
        width: auto;
        margin-left: 0;
        font-size: 0.58rem;
        line-height: 1.1;
        text-align: center;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        max-width: 100%;
        padding: 0 2px;
    }

    .sidebar:hover .nav-label {
        opacity: 1;
        transform: none;
        width: auto;
    }

    /* ── Top bar & main content ── */
    .top-bar {
        left: 0;
        right: 0;
        height: 48px;
        padding-top: env(safe-area-inset-top, 0px);
    }

    .top-bar-content {
        padding: 0 0.5rem;
        justify-content: center;
    }

    .top-bar-nav {
        position: absolute;
        left: 50%;
        top: 50%;
        transform: translate(-50%, -50%);
        gap: 0.45rem;
        max-width: calc(100% - 108px);
        flex-wrap: nowrap;
        overflow: hidden;
    }

    .top-bar-link,
    .top-bar-link-btn {
        font-size: 0.68rem;
        padding: 0 0.12rem;
        color: #ff3434;
    }

    .top-language-switcher {
        right: 0.5rem;
    }

    .top-language-switcher .lang-btn {
        padding: 0.35rem 0.65rem;
        font-size: 0.8rem;
        min-width: 38px;
    }

    .top-support-modal-panel {
        width: min(340px, 100%);
    }

    .main-content {
        margin-left: 0;
        margin-top: 48px;
        margin-bottom: calc(58px + env(safe-area-inset-bottom, 0px));
        width: 100%;
        max-width: 100vw;
        padding: 0.75rem;
        min-height: calc(100vh - 48px - 58px - env(safe-area-inset-bottom, 0px));
        box-sizing: border-box;
    }

    .content-section {
        padding: 1rem 0.75rem;
        margin-bottom: 1rem;
        border-radius: 8px;
        max-width: 100%;
        overflow-x: hidden;
    }

    .section-title {
        margin-left: 0 !important;
        margin-right: 0;
        font-size: 1.35rem !important;
        text-align: left;
        word-break: break-word;
    }

    .main-content:has(.profile-page),
    .content-section:has(.profile-page) {
        padding-left: 0.5rem;
        padding-right: 0.5rem;
    }

    .profile-container,
    .profile-container.profile-page {
        max-width: 100%;
        padding: 0;
    }

    /* ── Notifications & modals ── */
    .notification-container,
    .software-status-notification {
        top: calc(48px + env(safe-area-inset-top, 0px) + 10px);
        left: 0.75rem;
        right: 0.75rem;
        transform: none;
        width: auto;
        min-width: 0;
        max-width: calc(100vw - 1.5rem);
        z-index: 3000;
    }

    .notification {
        min-width: 0;
        width: 100%;
        padding: 0.85rem 1rem;
        font-size: 0.9rem;
    }

    .subscription-modal {
        padding: 0.75rem !important;
        padding-top: calc(0.75rem + env(safe-area-inset-top, 0px)) !important;
        padding-bottom: calc(0.75rem + env(safe-area-inset-bottom, 0px)) !important;
        align-items: center !important;
        justify-content: center !important;
    }

    .subscription-modal .modal-content,
    .subscription-modal .subscription-content,
    .subscription-modal .post-modal-content,
    .telegram-modal {
        width: calc(100vw - 1.5rem) !important;
        max-width: 400px !important;
        margin-left: auto !important;
        margin-right: auto !important;
        max-height: calc(100dvh - 1.5rem - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px)) !important;
        overflow-y: auto !important;
    }

    .hex-notify-overlay {
        padding: 0.75rem;
        padding-top: calc(0.75rem + env(safe-area-inset-top, 0px));
        padding-bottom: calc(0.75rem + env(safe-area-inset-bottom, 0px));
        z-index: 10060;
    }

    .hex-notify-dialog {
        max-width: none;
        padding: 1.15rem 1rem 1rem;
        border-radius: 12px;
    }

    .hex-notify-title {
        font-size: 1rem;
    }

    .hex-notify-message {
        font-size: 0.9rem;
    }

    .hex-notify-actions {
        flex-direction: column-reverse;
        gap: 8px;
    }

    .hex-notify-btn {
        width: 100%;
        min-height: 44px;
        padding: 12px 16px;
    }

    .hex-notify-btn:only-child {
        max-width: none;
        margin-left: 0;
    }

    .modal {
        padding: 0.75rem !important;
        justify-content: center !important;
        align-items: center !important;
    }

    #telegramEditModal {
        padding-left: 0 !important;
        padding-right: 0 !important;
    }

    /* ── Landing / login page ── */
    .language-switcher,
    .language-selector {
        top: calc(10px + env(safe-area-inset-top, 0px));
        right: 10px;
    }

    .audio-controls {
        bottom: calc(10px + env(safe-area-inset-bottom, 0px));
        right: 10px;
    }

    .main-container {
        padding: 1rem;
        height: 100vh;
        height: 100dvh;
        box-sizing: border-box;
    }

    .content-wrapper {
        padding: 1rem 0.5rem;
        width: 100%;
        max-width: 100%;
    }

    .buttons-container {
        width: 100%;
        margin: 1.5rem 0;
    }

    .btn-custom {
        width: 100%;
        max-width: 280px;
        min-width: 0;
        margin: 0.35rem 0;
    }

    .accent-text,
    .project-title {
        font-size: 1.6rem;
    }

    .login-form {
        width: calc(100vw - 2rem);
        max-width: 400px;
        padding: 1.5rem;
        margin: 0 1rem;
    }

    .form-container {
        width: calc(100vw - 2rem) !important;
        max-width: 400px;
    }

    /* ── Settings page ── */
    .settings-container {
        max-width: 100%;
        padding: 0.5rem 0;
    }

    .settings-tabs {
        flex-wrap: wrap;
        gap: 4px;
        padding: 6px;
        margin-bottom: 12px;
    }

    .settings-grid,
    .settings-grid.aim-bots-grid {
        grid-template-columns: 1fr !important;
        gap: 12px;
    }

    .settings-item,
    .settings-item-content {
        max-width: 100%;
        min-width: 0;
    }

    .settings-row,
    .settings-item-header,
    .bind-row,
    .double-bind-row {
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 10px !important;
    }

    .settings-row > *,
    .select-container,
    .slider-container,
    .toggle-container,
    .input-container,
    .key-capture-btn,
    .custom-select,
    .settings-item .form-control,
    .settings-item select,
    .settings-item input[type="text"],
    .settings-item input[type="number"] {
        width: 100% !important;
        max-width: 100% !important;
        min-width: 0 !important;
        box-sizing: border-box;
    }

    .status-indicator-wrapper {
        bottom: calc(68px + env(safe-area-inset-bottom, 0px)) !important;
        right: 12px !important;
    }

    .status-indicator-tooltip {
        white-space: normal;
        min-width: 0;
        max-width: calc(100vw - 2rem);
    }

    /* ── Admin & Support tables ── */
    .admin-container,
    .faq-container,
    .news-creation-container {
        padding: 0;
        max-width: 100%;
    }

    .users-table-container,
    .table-responsive,
    .content-management {
        max-width: 100%;
        padding: 12px !important;
    }

    .table-wrapper {
        overflow-x: visible;
        max-width: 100%;
    }

    .table-header {
        flex-direction: column;
        align-items: stretch;
        gap: 0.75rem;
    }

    .table-header h3 {
        word-break: break-word;
    }

    .table-actions,
    .table-actions input,
    .search-container,
    .search-container input,
    #keysSearch,
    .table-header input[type="text"],
    .table-header input[type="date"] {
        width: 100% !important;
        max-width: 100% !important;
        box-sizing: border-box;
    }

    .table-header > div {
        width: 100%;
        display: flex;
        flex-wrap: wrap;
        gap: 8px;
        align-items: stretch;
    }

    .table-header button {
        flex: 1 1 auto;
        min-height: 40px;
    }

    /* Таблицы → карточки на телефоне */
    .users-table {
        min-width: 0 !important;
        width: 100%;
        border-collapse: separate;
        border-spacing: 0;
    }

    .users-table thead {
        display: none;
    }

    .users-table tbody tr {
        display: block;
        margin-bottom: 12px;
        padding: 12px;
        background: rgba(255, 52, 52, 0.05);
        border: 1px solid rgba(255, 52, 52, 0.15);
        border-radius: 10px;
    }

    .users-table tbody tr:hover {
        background: rgba(255, 52, 52, 0.08);
    }

    .users-table tbody td {
        display: flex;
        align-items: flex-start;
        justify-content: space-between;
        gap: 12px;
        padding: 8px 0;
        border-bottom: 1px solid rgba(255, 52, 52, 0.1);
        text-align: right;
        word-break: break-word;
        white-space: normal;
    }

    .users-table tbody td:last-child {
        border-bottom: none;
        flex-direction: column;
        align-items: stretch;
        padding-bottom: 0;
    }

    .users-table tbody td::before {
        content: attr(data-label);
        flex: 0 0 38%;
        max-width: 42%;
        font-weight: 600;
        color: rgba(255, 52, 52, 0.9);
        font-size: 0.72rem;
        text-align: left;
        text-transform: uppercase;
        letter-spacing: 0.04em;
        line-height: 1.35;
        padding-top: 2px;
    }

    .users-table tbody td[colspan] {
        display: block;
        text-align: center;
        padding: 20px 0;
    }

    .users-table tbody td[colspan]::before {
        display: none;
    }

    .users-table tbody td:last-child::before {
        margin-bottom: 6px;
    }

    .content-management {
        padding: 14px !important;
        margin-bottom: 16px !important;
    }

    .content-management-header {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
    }

    .content-management-actions {
        width: 100%;
    }

    .content-management-actions .create-news-btn,
    .content-management-actions .create-patch-btn {
        flex: 1;
        min-height: 44px;
        text-align: center;
    }

    .self-reset-card {
        padding: 14px !important;
    }

    .self-reset-card .action-buttons {
        flex-direction: column;
        align-items: stretch;
    }

    .self-reset-card .action-buttons .btn-custom {
        width: 100%;
        min-height: 44px;
        text-align: center;
    }

    .support-groups-panel {
        padding: 12px 14px !important;
        margin-top: 14px !important;
    }

    .support-groups-header {
        flex-wrap: nowrap;
        align-items: center;
        gap: 8px;
    }

    .support-groups-label {
        flex-shrink: 0;
        font-size: 0.88rem;
    }

    .support-groups-list {
        flex: 1;
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        padding-bottom: 2px;
    }

    .support-groups-list::-webkit-scrollbar {
        display: none;
    }

    .support-group-item {
        flex-shrink: 0;
    }

    .support-group-btn {
        min-height: 40px;
        padding: 8px 12px;
        font-size: 12px;
        white-space: nowrap;
    }

    .support-group-delete {
        min-width: 32px;
        min-height: 40px;
    }

    .support-group-add-btn {
        flex-shrink: 0;
        width: 40px;
        height: 40px;
    }

    .support-users-placeholder {
        padding: 32px 16px !important;
        margin-top: 16px !important;
    }

    .users-table .action-buttons {
        flex-direction: column;
        align-items: stretch;
        min-width: 0;
        width: 100%;
    }

    .users-table .action-buttons .btn-custom {
        width: 100%;
        min-height: 40px;
        text-align: center;
    }

    .pagination {
        display: flex;
        flex-wrap: wrap;
        gap: 6px;
        justify-content: center;
        margin-top: 12px;
    }

    .pagination .btn-custom {
        min-width: 40px;
        min-height: 40px;
    }

    .assign-group-list {
        max-height: 50dvh;
    }

    .subscription-buttons {
        grid-template-columns: 1fr !important;
    }

    .sub-btn {
        min-height: 44px;
    }

    /* ── FAQ ── */
    .faq-question {
        padding: 12px 14px;
        font-size: 0.95rem;
        gap: 10px;
    }

    .faq-question span,
    .faq-answer {
        word-break: break-word;
    }

    /* ── Profile extras ── */
    .key-activation {
        width: 100%;
    }

    .activation-input,
    .btn-activate {
        width: 100% !important;
        max-width: 100% !important;
    }

    .profile-panel-card--scroll {
        max-height: none;
    }

    /* ── Download page ── */
    .loader-download-section,
    .upload-section,
    .settings-section {
        padding: 1rem;
    }
}

@media (max-width: 480px) {
    .main-content {
        padding: 0.5rem;
    }

    .content-section {
        padding: 0.85rem 0.6rem;
    }

    .section-title {
        font-size: 1.2rem !important;
    }

    .sidebar .nav-label {
        font-size: 0.52rem;
    }

    .auth-container .top-bar-content {
        padding: 0 0.5rem !important;
        justify-content: center !important;
    }
}

@media (max-width: 360px) {
    .sidebar .nav-item {
        padding: 5px 1px;
    }

    .sidebar .nav-label {
        display: none;
    }

    .sidebar .nav-item i {
        font-size: 1.15rem;
    }
}
