/* ============================================
   Стили только для мобильной версии
   Подключается с media="(max-width: 767px)"
   ============================================ */

/* Контейнеры */
.container-fluid {
    padding-left: 15px;
    padding-right: 15px;
}

#mainContent {
    flex: 0 0 100% !important;
    max-width: 100% !important;
    padding: 15px !important;
}

.main-content {
    margin-left: 0 !important;
    padding: 15px !important;
}

.sidebar-expanded .main-content {
    margin-left: 0 !important;
    padding-left: 15px !important;
}

/* Навигация — фиксированная шапка */
.navbar {
    padding: 0.4rem 0.8rem;
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    z-index: 1030 !important;
    width: 100% !important;
}

.navbar-brand {
    font-size: 1rem;
}

.navbar-brand span {
    font-size: 0.85rem;
}

.user-name {
    display: none;
}

.nav-link .fa-user-circle {
    font-size: 1.5rem;
    margin-right: 0 !important;
}

.dropdown-arrow {
    display: none;
}

/* Таблицы — все колонки как на большом экране, горизонтальная прокрутка при необходимости */
.table-responsive {
    border: none;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    width: 100%;
}

.table-responsive .table {
    width: 100%;
    min-width: max-content;
    font-size: 0.85rem;
}

.table-responsive .table th,
.table-responsive .table td {
    padding: 0.5rem 0.375rem;
    white-space: nowrap;
}

/* Кнопки — удобные для касания */
.btn {
    min-height: 44px;
    padding: 0.625rem 1rem;
    touch-action: manipulation;
    font-size: 0.875rem;
}

.btn-sm {
    min-height: 40px;
    padding: 0.5rem 0.75rem;
    font-size: 0.8rem;
}

/* Карточки */
.card {
    border-radius: 12px;
    margin-bottom: 1.25rem;
}

.card-body {
    padding: 1.25rem;
}

.card-header {
    padding: 0.75rem 1rem;
    font-size: 0.95rem;
}

/* Формы — крупнее для пальцев и без зума iOS */
.form-control,
.form-select {
    min-height: 44px;
    padding: 0.875rem 1rem;
    font-size: 16px;
}

.form-label {
    font-size: 0.9rem;
    font-weight: 600;
}

/* Навигация */
.nav-link {
    min-height: 44px;
    padding: 0.75rem 1rem !important;
}

/* Модальные окна */
.modal-dialog {
    margin: 0.5rem;
    max-width: calc(100% - 1rem);
}

.modal-lg {
    max-width: calc(100% - 1rem);
}

.modal-body {
    padding: 1rem;
}

.modal-header,
.modal-footer {
    padding: 0.75rem 1rem;
}

/* Заголовки страницы */
.page-header-mobile-wrapper {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    width: 100%;
}

.page-header-title {
    flex: 1 1 auto;
    min-width: 0;
}

.page-header-title h1 {
    font-size: 1.25rem;
    margin-bottom: 0.25rem;
    line-height: 1.3;
}

.page-header-actions {
    flex: 0 0 auto;
    display: flex;
    flex-wrap: wrap;
    gap: 0.15rem;
    align-items: flex-end;
    justify-content: flex-end;
}

.page-header-btn {
    flex: 0 0 auto;
    min-height: 28px;
    padding: 0.2rem 0.4rem;
    font-size: 0.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
    touch-action: manipulation;
    white-space: nowrap;
}

.page-header-btn i {
    margin-right: 0;
    font-size: 0.8rem;
}

.page-header-btn span {
    display: none;
}

/* Сетка */
.row.g-3 {
    --bs-gutter-x: 1rem;
    --bs-gutter-y: 1rem;
}

/* Алерты */
.alert {
    padding: 0.75rem;
    font-size: 0.9rem;
    margin-bottom: 1rem;
}

/* Заголовки */
h1 { font-size: 1.75rem; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.25rem; }
h4 { font-size: 1.1rem; }
h5 { font-size: 1rem; }
h6 { font-size: 0.9rem; }

/* Бейджи */
.badge {
    font-size: 0.7rem;
    padding: 0.35em 0.65em;
}

.badge.fs-6 {
    font-size: 0.65rem !important;
    padding: 0.25em 0.5em;
}

/* Dropdown пользователя */
.user-dropdown {
    min-width: 250px;
    right: 0;
    left: auto;
}

/* Панели инструментов — колонкой */
.d-flex.justify-content-between {
    flex-direction: column;
    gap: 1rem;
}

.d-flex.justify-content-between .btn {
    width: 100%;
    margin-bottom: 0.5rem;
}

.btn-group {
    display: flex;
    flex-direction: column;
    width: 100%;
}

.btn-group .btn {
    margin-bottom: 0.25rem;
    border-radius: var(--border-radius) !important;
}

/* Offcanvas меню */
.offcanvas {
    transition: transform 0.25s ease-out;
}

.offcanvas-start {
    top: 56px !important;
    height: calc(100vh - 56px) !important;
    transform: translateX(-100%);
}

.offcanvas.show {
    transform: translateX(0);
}

/* --- Очень маленькие экраны (до 576px) --- */
@media (max-width: 576px) {
    .container-fluid {
        padding-left: 10px;
        padding-right: 10px;
    }

    #mainContent {
        padding: 10px !important;
    }

    .navbar {
        padding: 0.25rem 0.5rem;
    }

    .navbar-brand img {
        width: 24px;
        height: 24px;
    }

    .btn-outline-secondary {
        padding: 0.25rem 0.5rem;
        font-size: 0.8rem;
    }

    .card {
        border-radius: 0.375rem;
    }

    .table-responsive .table {
        font-size: 0.8rem;
    }

    .table-responsive .table th,
    .table-responsive .table td {
        padding: 0.5rem 0.25rem;
        font-size: 0.8rem;
    }

    .table-responsive .badge {
        font-size: 0.7rem;
        padding: 0.2em 0.4em;
    }

    .page-header-mobile-wrapper {
        gap: 0.25rem;
    }

    .page-header-title h1 {
        font-size: 1.1rem;
    }

    .page-header-btn {
        min-height: 28px;
        padding: 0.15rem 0.35rem;
        font-size: 0.7rem;
    }

    .page-header-btn i {
        font-size: 0.75rem;
    }

    .btn {
        font-size: 0.8rem;
        padding: 0.5rem 0.75rem;
    }

    .btn-sm {
        font-size: 0.75rem;
        padding: 0.25rem 0.5rem;
    }

    .modal-dialog {
        margin: 0.25rem;
        max-width: calc(100% - 0.5rem);
    }

    h1 { font-size: 1.5rem; }
    h2 { font-size: 1.3rem; }
    h3 { font-size: 1.1rem; }
    h4 { font-size: 1rem; }
}

/* Стили для касаний (touch) */
@media (pointer: coarse) {
    .btn,
    .nav-link,
    .dropdown-item,
    .menu-item,
    .list-group-item-action {
        min-height: 44px;
        display: flex;
        align-items: center;
        touch-action: manipulation;
    }

    .btn:active,
    .nav-link:active,
    .dropdown-item:active {
        transform: scale(0.98);
        transition: all 0.1s ease;
    }
}

/* Ландшафт на маленькой высоте */
@media (orientation: landscape) and (max-height: 500px) {
    .navbar {
        padding: 0.25rem 1rem;
    }

    #mainContent {
        padding: 10px !important;
    }

    .modal-dialog {
        max-height: 90vh;
        overflow-y: auto;
    }
}

/* Утилиты: скрыть на мобильных */
.mobile-hide {
    display: none !important;
}

.mobile-w-100 {
    width: 100% !important;
}

.mobile-stack {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}
