/* Адаптивные стили для мобильных устройств */

/* Базовые улучшения для мобильных */
@media (max-width: 768px) {
    /* Контейнер без отступов по бокам на мобильных */
    .container {
        padding-left: 10px;
        padding-right: 10px;
    }
    
    /* Уменьшаем отступы */
    .mt-2, .mb-2, .my-2 {
        margin-top: 0.5rem !important;
        margin-bottom: 0.5rem !important;
    }
    
    .mb-3, .my-3 {
        margin-bottom: 1rem !important;
    }
    
    .mb-4, .my-4 {
        margin-bottom: 1.25rem !important;
    }
    
    /* Навигация */
    .navbar-brand {
        font-size: 1rem;
    }
    
    .navbar-nav {
        margin-top: 0.5rem;
    }
    
    .nav-link {
        padding: 0.75rem 1rem;
        font-size: 0.95rem;
    }
    
    /* Карточки */
    .card {
        margin-bottom: 1rem;
        border-radius: 8px;
    }
    
    .card-body {
        padding: 1rem;
    }
    
    .card-header {
        padding: 0.75rem 1rem;
        font-size: 0.95rem;
    }
    
    /* Кнопки - увеличиваем для touch */
    .btn {
        padding: 0.625rem 1.25rem;
        font-size: 0.95rem;
        min-height: 44px; /* Минимальный размер для удобного нажатия */
        touch-action: manipulation;
    }
    
    .btn-sm {
        padding: 0.5rem 1rem;
        font-size: 0.875rem;
        min-height: 40px;
    }
    
    .btn-lg {
        padding: 0.75rem 1.5rem;
        font-size: 1.1rem;
        min-height: 48px;
    }
    
    /* Формы */
    .form-control, .form-select {
        font-size: 16px; /* Предотвращает zoom на iOS */
        padding: 0.625rem 0.75rem;
        min-height: 44px;
    }
    
    .form-label {
        font-size: 0.95rem;
        margin-bottom: 0.5rem;
    }
    
    /* Таблицы - горизонтальный скролл с улучшенной прокруткой */
    .table-responsive {
        -webkit-overflow-scrolling: touch;
        border-radius: 8px;
        position: relative;
        overflow-x: auto;
        overflow-y: visible;
        -ms-overflow-style: -ms-autohiding-scrollbar;
    }
    
    .table-responsive::-webkit-scrollbar {
        height: 8px;
    }
    
    .table-responsive::-webkit-scrollbar-track {
        background: #f1f1f1;
        border-radius: 4px;
    }
    
    .table-responsive::-webkit-scrollbar-thumb {
        background: #888;
        border-radius: 4px;
    }
    
    .table-responsive::-webkit-scrollbar-thumb:hover {
        background: #555;
    }
    
    .table {
        font-size: 0.875rem;
        min-width: 600px; /* Минимальная ширина для горизонтального скролла */
        margin-bottom: 0;
    }
    
    .table th,
    .table td {
        padding: 0.75rem 0.5rem;
        white-space: nowrap;
        vertical-align: middle;
    }
    
    .table th {
        font-size: 0.8rem;
        font-weight: 600;
        background-color: #f8f9fa;
        position: sticky;
        top: 0;
        z-index: 10;
    }
    
    /* Альтернативный вид таблиц как карточки на очень маленьких экранах */
    @media (max-width: 576px) {
        .table-responsive {
            overflow-x: visible;
        }
        
        .table,
        .table thead,
        .table tbody,
        .table th,
        .table td,
        .table tr {
            display: block;
        }
        
        .table thead tr {
            position: absolute;
            top: -9999px;
            left: -9999px;
        }
        
        .table tr {
            border: 1px solid #dee2e6;
            border-radius: 8px;
            margin-bottom: 1rem;
            padding: 0.75rem;
            background: white;
            box-shadow: 0 2px 4px rgba(0,0,0,0.1);
        }
        
        .table td {
            border: none;
            position: relative;
            padding-left: 40% !important;
            padding-top: 0.5rem;
            padding-bottom: 0.5rem;
            text-align: left;
            white-space: normal;
        }
        
        .table td:before {
            content: attr(data-label);
            position: absolute;
            left: 0.5rem;
            width: 35%;
            padding-right: 10px;
            white-space: nowrap;
            font-weight: 600;
            color: #6c757d;
            font-size: 0.8rem;
        }
        
        .table td:last-child {
            border-bottom: 0;
        }
    }
    
    /* Статистические карточки */
    .stat-card {
        padding: 1rem;
        margin-bottom: 0.75rem;
    }
    
    .stat-number {
        font-size: 1.75rem;
    }
    
    .stat-label {
        font-size: 0.85rem;
    }
    
    /* Заголовки */
    h1 {
        font-size: 1.75rem;
        margin-bottom: 1rem;
    }
    
    h2 {
        font-size: 1.5rem;
    }
    
    h3 {
        font-size: 1.25rem;
    }
    
    h4, h5, h6 {
        font-size: 1.1rem;
    }
    
    /* Бейджи и статусы */
    .badge {
        font-size: 0.75rem;
        padding: 0.35rem 0.65rem;
    }
    
    .status-badge {
        font-size: 0.7rem;
        padding: 0.3rem 0.6rem;
        max-width: 100%;
    }
    
    /* Информационные блоки */
    .info-grid {
        grid-template-columns: 1fr !important;
        gap: 0.75rem;
    }
    
    .info-item {
        padding: 0.75rem;
    }
    
    .info-label {
        font-size: 0.7rem;
    }
    
    .info-value {
        font-size: 0.9rem;
    }
    
    /* Клиентская информация */
    .client-info {
        grid-column: span 1 !important;
    }
    
    .client-name {
        font-size: 0.95rem;
    }
    
    .client-detail {
        font-size: 0.85rem;
        padding-left: 1.5rem;
    }
    
    /* Команда */
    .team-member-name {
        font-size: 0.95rem;
    }
    
    .team-member-detail {
        font-size: 0.85rem;
        padding-left: 1.5rem;
    }
    
    /* Звёздочки для оценок */
    .star-rating {
        font-size: 1.25rem;
    }
    
    .star-rating i {
        margin-right: 0.25rem;
    }
    
    /* Чат */
    .chat-message {
        padding: 0.75rem;
        margin-bottom: 0.75rem;
        font-size: 0.9rem;
    }
    
    .chat-message.own {
        margin-left: 10%;
    }
    
    /* Модальные окна */
    .modal-dialog {
        margin: 0.5rem;
    }
    
    .modal-content {
        border-radius: 8px;
    }
    
    .modal-header {
        padding: 1rem;
    }
    
    .modal-body {
        padding: 1rem;
        font-size: 0.9rem;
    }
    
    /* Фильтры и поиск */
    .input-group {
        margin-bottom: 0.75rem;
    }
    
    .input-group-sm .form-control {
        font-size: 14px;
    }
    
    /* Пагинация */
    .pagination {
        font-size: 0.875rem;
        flex-wrap: wrap;
    }
    
    .page-link {
        padding: 0.5rem 0.75rem;
        min-height: 40px;
    }
    
    /* Алерты */
    .alert {
        padding: 0.75rem 1rem;
        font-size: 0.9rem;
        margin-bottom: 0.75rem;
    }
    
    /* Хлебные крошки */
    .breadcrumb {
        font-size: 0.85rem;
        padding: 0.5rem 0;
        margin-bottom: 0.75rem;
    }
    
    /* Вкладки */
    .nav-tabs {
        font-size: 0.875rem;
        flex-wrap: wrap;
    }
    
    .nav-tabs .nav-link {
        padding: 0.5rem 0.75rem;
        font-size: 0.85rem;
    }
    
    /* Кнопки действий в таблицах */
    .d-flex.gap-2 {
        gap: 0.5rem !important;
        flex-wrap: wrap;
    }
    
    /* Админ-панель: статистика */
    .row.mb-4 .col-md-3 {
        margin-bottom: 0.75rem;
    }
    
    /* Улучшение для touch-событий */
    a, button, .btn, input[type="submit"], input[type="button"] {
        -webkit-tap-highlight-color: rgba(0, 0, 0, 0.1);
        touch-action: manipulation;
    }
    
    /* Оптимизация текста */
    p, span, div {
        word-wrap: break-word;
        overflow-wrap: break-word;
    }
    
    /* Скрываем некоторые элементы на мобильных */
    .text-muted.small {
        font-size: 0.8rem;
    }
}

/* Очень маленькие экраны (до 576px) */
@media (max-width: 576px) {
    .container {
        padding-left: 8px;
        padding-right: 8px;
    }
    
    h1 {
        font-size: 1.5rem;
    }
    
    .stat-number {
        font-size: 1.5rem;
    }
    
    .btn {
        width: 100%;
        margin-bottom: 0.5rem;
    }
    
    .btn-group {
        width: 100%;
    }
    
    .btn-group .btn {
        flex: 1;
    }
    
    .table {
        font-size: 0.8rem;
        min-width: 500px;
    }
    
    .table th,
    .table td {
        padding: 0.5rem 0.4rem;
    }
    
    .card-body {
        padding: 0.75rem;
    }
    
    .modal-dialog {
        margin: 0.25rem;
    }
    
    .navbar-brand {
        font-size: 0.9rem;
    }
}

/* Ландшафтная ориентация на мобильных */
@media (max-width: 768px) and (orientation: landscape) {
    .navbar {
        padding: 0.25rem 0;
    }
    
    .container {
        padding-left: 15px;
        padding-right: 15px;
    }
}

/* Улучшения для iOS Safari */
@supports (-webkit-touch-callout: none) {
    @media (max-width: 768px) {
        .form-control,
        .form-select,
        textarea {
            font-size: 16px; /* Предотвращает автоматический zoom */
        }
        
        input[type="text"],
        input[type="email"],
        input[type="tel"],
        input[type="password"],
        textarea {
            font-size: 16px;
        }
    }
}

/* Улучшения для Android Chrome */
@media (max-width: 768px) {
    /* Убираем outline при фокусе на touch-устройствах */
    *:focus {
        outline: none;
    }
    
    /* Улучшаем видимость активных элементов */
    .btn:active,
    .nav-link:active {
        opacity: 0.8;
        transform: scale(0.98);
    }
}
