/* BOLT - Custom Styles */

:root {
    /* Основные цвета BOLT */
    --primary-color: #2E7BB5;
    --secondary-color: #518AB5;
    --primary-dark: #024070;
    --primary-darker: #163953;
    --primary-deep: #002948;
    --success-color: #10b981;
    --danger-color: #ef4444;
    --warning-color: #8b88ff;
    --info-color: #2E7BB5;
    --dark-color: #1f2937;
    --light-color: #f3f4f6;
    
    /* Градиенты */
    --gradient-primary: linear-gradient(135deg, #024070, #2E7BB5);
    --gradient-secondary: linear-gradient(135deg, #2E7BB5, #518AB5);
}

[data-bs-theme="dark"] {
    --bg-color: #0f1115;
    --surface-color: #171a21;
    --surface-alt: #1f2430;
    --border-color: #2a3140;
    --text-color: #e6edf3;
    --muted-color: #9aa4b2;
    --accent-color: #2E7BB5;
    --accent-color-2: #518AB5;
    --success-color: #4ade80;
    --warning-color: #f5c451;
    --danger-color: #ff6b6b;
    --info-color: #2E7BB5;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: #f8f9fa;
    color: #212529;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    transition: background-color 0.3s ease, color 0.3s ease;
}

main {
    flex: 1;
}

/* Navbar customization */
.navbar-brand {
    font-weight: bold;
    font-size: 1.5rem;
}

.navbar-dark .navbar-nav .nav-link {
    color: rgba(255, 255, 255, 0.9);
    transition: all 0.3s ease;
}

.navbar-dark .navbar-nav .nav-link:hover {
    color: white;
    transform: translateY(-2px);
}

/* Cards */
.card {
    border: none;
    border-radius: 10px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    transition: transform 0.3s ease, box-shadow 0.3s ease, background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease;
}

.card:hover {
    transform: translateY(-5px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.card-header {
    border-top-left-radius: 10px !important;
    border-top-right-radius: 10px !important;
    font-weight: 600;
}

/* Dashboard Cards */
.card.bg-primary {
    background: var(--gradient-primary) !important;
    border: none;
}

.card.bg-success {
    background: linear-gradient(135deg, #10b981, #34d399) !important;
    border: none;
}

.card.bg-info {
    background: linear-gradient(135deg, var(--secondary-color), #38bdf8) !important;
    border: none;
}

.card.bg-warning {
    background: linear-gradient(135deg, #6f6cff, #8b88ff) !important;
    border: none;
}

.card.bg-danger {
    background: linear-gradient(135deg, #ef4444, #f87171) !important;
    border: none;
}

/* Buttons */
.btn {
    border-radius: 8px;
    padding: 0.5rem 1.5rem;
    font-weight: 500;
    transition: all 0.3s ease;
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

.btn-primary {
    background: var(--gradient-primary);
    border: none;
    color: white;
}

.btn-primary:hover {
    background: var(--gradient-secondary);
    color: white;
}

.btn-outline-primary {
    border: 2px solid var(--primary-color);
    color: var(--primary-color);
}

.btn-outline-primary:hover {
    background: var(--gradient-primary);
    border-color: transparent;
    color: white;
}

.btn-info {
    background: var(--secondary-color);
    border: none;
    color: white;
}

.btn-outline-info {
    border: 2px solid var(--secondary-color);
    color: var(--secondary-color);
}

.btn-outline-info:hover {
    background: var(--secondary-color);
    border-color: transparent;
    color: white;
}

/* Tables */
.table {
    background-color: white;
    transition: background-color 0.3s ease, color 0.3s ease;
}

.table thead th {
    background: var(--gradient-primary);
    color: white;
    border-bottom: 2px solid var(--primary-color);
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.875rem;
    letter-spacing: 0.5px;
}

.table tbody tr {
    transition: background-color 0.2s ease;
}

.table tbody tr:hover {
    background-color: var(--light-color);
}

/* Badges */
.badge {
    padding: 0.4rem 0.8rem;
    border-radius: 6px;
    font-weight: 500;
    font-size: 0.875rem;
}

.badge.bg-primary {
    background: var(--primary-color) !important;
}

.badge.bg-info {
    background: var(--secondary-color) !important;
}

/* Alerts */
.alert {
    border-radius: 10px;
    border: none;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* Footer */
.footer {
    margin-top: auto;
    border-top: 1px solid #dee2e6;
}

/* Avatar */
.avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
}

/* Loading spinner */
.spinner-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
}

/* Chat styles */
.chat-container {
    height: 600px;
    display: flex;
    flex-direction: column;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    background-color: white;
    border-radius: 10px;
    margin-bottom: 1rem;
}

.chat-message {
    margin-bottom: 1rem;
    padding: 0.75rem;
    border-radius: 10px;
    max-width: 70%;
    word-wrap: break-word;
}

.chat-message.sent {
    background: linear-gradient(135deg, rgba(30, 94, 255, 0.1), rgba(0, 212, 255, 0.1));
    border-left: 3px solid var(--primary-color);
    margin-left: auto;
    text-align: right;
}

.chat-message.received {
    background-color: #f5f5f5;
    border-left: 3px solid #cbd5e1;
    margin-right: auto;
}

.chat-message .time {
    font-size: 0.75rem;
    color: #999;
    margin-top: 0.25rem;
}

/* DSE List styles */
.dse-card {
    margin-bottom: 1rem;
}

.dse-card .card-body {
    padding: 1.5rem;
}

.dse-status {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-size: 0.875rem;
    font-weight: 500;
}

.dse-status.active {
    background-color: #d1fae5;
    color: #065f46;
}

.dse-status.pending {
    background-color: #fef3c7;
    color: #92400e;
}

.dse-status.completed {
    background-color: #dbeafe;
    color: #1e40af;
}

/* Responsive */
@media (max-width: 992px) {
        /* Планшеты и меньше */
        .chat-message {
            max-width: 80%;
        }
        
        .card {
            margin-bottom: 1rem;
        }
        
        .card-body {
            padding: 1rem !important;
        }
        
        .table th,
        .table td {
            padding: 0.75rem !important;
            font-size: 0.9rem;
        }
        
        .container-fluid {
            padding-left: 1rem;
            padding-right: 1rem;
        }
    }

    @media (max-width: 768px) {
        /* Мобильные устройства */
        
        /* Увеличиваем размер текста для лучшей читаемости */
        body {
            font-size: 16px;
        }
        
        /* Navbar мобильная */
        .navbar-brand {
            font-size: 1.2rem;
        }
        
        .navbar {
            padding: 0.5rem 1rem;
        }
        
        .navbar-nav {
            padding-top: 0.5rem;
        }
        
        .navbar-nav .nav-item {
            padding: 0.5rem 0;
        }
        
        /* Чаты на мобильных */
        .chat-message {
            max-width: 85%;
        }
        
        /* Карточки */
        .card {
            margin-bottom: 1rem;
            border-radius: 8px;
        }
        
        .card-body {
            padding: 1rem !important;
        }
        
        .card-header {
            padding: 0.75rem 1rem !important;
        }
        
        /* Таблицы */
        .table-responsive {
            font-size: 0.875rem;
            border-radius: 8px;
            overflow-x: auto;
            -webkit-overflow-scrolling: touch;
        }
        
        .table th,
        .table td {
            padding: 0.5rem !important;
            font-size: 0.875rem;
        }
        
        .table thead th {
            font-size: 0.75rem;
        }
        
        /* Кнопки */
        .btn {
            padding: 0.5rem 1rem;
            font-size: 0.9rem;
            min-height: 44px;
            min-width: 44px;
        }
        
        .btn-sm {
            padding: 0.25rem 0.5rem;
            font-size: 0.75rem;
        }
        
        .btn-mobile-full {
            width: 100%;
            margin-bottom: 0.5rem;
        }
        
        .btn:hover {
            transform: none;
        }
        
        /* Уменьшаем отступы */
        .container-fluid {
            padding-left: 0.75rem;
            padding-right: 0.75rem;
        }
        
        /* Модальные окна */
        .modal-dialog {
            margin: 0.5rem;
            width: calc(100% - 1rem);
            max-width: 90vw;
        }
        
        .modal-header {
            padding: 1rem;
        }
        
        .modal-body {
            padding: 1rem;
        }
        
        .modal-footer {
            padding: 0.75rem;
            gap: 0.5rem;
        }
        
        /* Быстрые действия */
        .row.g-3 > div {
            margin-bottom: 0.5rem;
        }
        
        /* Breadcrumb */
        .breadcrumb {
            font-size: 0.875rem;
            flex-wrap: wrap;
            margin-bottom: 0.75rem;
        }
        
        /* Формы */
        .form-control,
        .form-select {
            font-size: 16px;
            padding: 0.75rem;
            border-radius: 8px;
        }
        
        .form-label {
            font-size: 0.9rem;
            margin-bottom: 0.5rem;
        }
        
        /* Dashboard stats */
        .display-4 {
            font-size: 1.75rem !important;
        }
        
        .display-5 {
            font-size: 1.5rem !important;
        }
        
        .display-6 {
            font-size: 1.25rem !important;
        }
        
        /* Фото */
        .col-md-6 img {
            max-height: 300px;
            width: 100%;
            object-fit: cover;
            border-radius: 8px;
        }
        
        /* Dropdowns */
        .dropdown-menu {
            font-size: 0.9rem;
            border-radius: 8px;
        }
        
        .dropdown-item {
            padding: 0.75rem 1rem;
        }
        
        /* Alerts */
        .alert {
            padding: 0.75rem 1rem;
            margin-bottom: 0.75rem;
        }
        
        /* Badges */
        .badge {
            padding: 0.35rem 0.6rem;
            font-size: 0.75rem;
        }
        
        /* Утилиты */
        .mt-md, .my-md {
            margin-top: 0.5rem;
        }
        
        .mb-md, .my-md {
            margin-bottom: 0.5rem;
        }
        
        .p-md {
            padding: 0.75rem;
        }
        
        /* Скрываем элементы если нужно */
        .mobile-hide {
            display: none !important;
        }
        
        .mobile-show {
            display: block !important;
    }
}

@media (max-width: 576px) {
    /* Очень маленькие экраны */
    h1 {
        font-size: 1.75rem;
    }
    
    h2 {
        font-size: 1.5rem;
    }
    
    h3 {
        font-size: 1.25rem;
    }
    
    .card-header h5 {
        font-size: 1rem;
    }
    
    /* Уменьшаем padding у кнопок */
    .btn {
        padding: 0.5rem 1rem;
        font-size: 0.875rem;
    }
    
    .btn-sm {
        padding: 0.25rem 0.5rem;
        font-size: 0.75rem;
    }
    
    /* Скрываем иконки на очень маленьких экранах если нужно */
    .mobile-hide-icon i {
        display: none;
    }
}

/* Landscape orientation для телефонов */
@media (max-height: 500px) and (orientation: landscape) {
    .navbar {
        padding: 0.25rem 1rem;
    }
    
    .card {
        margin-bottom: 0.5rem;
    }
}

/* Tablet landscape */
@media (min-width: 769px) and (max-width: 1024px) {
    .container-fluid {
        padding-left: 2rem;
        padding-right: 2rem;
    }
}

/* Touch devices - увеличиваем области клика */
@media (hover: none) and (pointer: coarse) {
    .btn {
        min-height: 44px;
        min-width: 44px;
    }
    
    .nav-link {
        padding: 0.75rem 1rem;
    }
    
    .table tbody tr {
        cursor: pointer;
    }
}

/* Фото с обработкой ошибок */
.photo-with-error {
    background-color: #f3f4f6;
    background-image: linear-gradient(45deg, #e5e7eb 25%, transparent 25%),
                      linear-gradient(-45deg, #e5e7eb 25%, transparent 25%),
                      linear-gradient(45deg, transparent 75%, #e5e7eb 75%),
                      linear-gradient(-45deg, transparent 75%, #e5e7eb 75%);
    background-size: 20px 20px;
    background-position: 0 0, 0 10px, 10px -10px, -10px 0px;
}

.photo-with-error[src*="svg"] {
    background: #f8f9fa;
}

/* Skeleton loader для загрузки фото */
@keyframes shimmer {
    0% {
        background-position: -1000px 0;
    }
    100% {
        background-position: 1000px 0;
    }
}

.skeleton {
    animation: shimmer 2s infinite;
    background: linear-gradient(to right, #f3f4f6 4%, #e5e7eb 25%, #f3f4f6 36%);
    background-size: 1000px 100%;
}

.image-loading {
    position: relative;
    min-height: 200px;
    background: #f3f4f6;
    display: flex;
    align-items: center;
    justify-content: center;
}

.image-loading::after {
    content: "Загрузка...";
    color: #9ca3af;
    font-size: 0.875rem;
}


/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.fade-in {
    animation: fadeIn 0.5s ease-in;
}

/* Custom scrollbar */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
}

::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #555;
}

/* Modal */
.modal-content {
    border-radius: 15px;
    border: none;
}

.modal-header {
    border-bottom: 2px solid var(--light-color);
}

.modal-footer {
    border-top: 2px solid var(--light-color);
}

/* Forms */
.form-control,
.form-select {
    border-radius: 8px;
    border: 2px solid #e5e7eb;
    padding: 0.75rem;
    transition: border-color 0.3s ease;
}

.form-control:focus,
.form-select:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 0.2rem rgba(30, 94, 255, 0.25);
}

.form-label {
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--dark-color);
}

/* File upload */
.file-upload-wrapper {
    position: relative;
    overflow: hidden;
    display: inline-block;
}

.file-upload-wrapper input[type=file] {
    position: absolute;
    left: -9999px;
}

.file-upload-label {
    cursor: pointer;
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    background-color: var(--light-color);
    border: 2px dashed #cbd5e1;
    transition: all 0.3s ease;
}

.file-upload-label:hover {
    background-color: #e5e7eb;
    border-color: var(--primary-color);
}

/* Utility classes */
.text-gradient {
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.bg-primary {
    background: var(--gradient-primary) !important;
}

.bg-info {
    background: var(--secondary-color) !important;
}

.text-primary {
    color: var(--primary-color) !important;
}

.text-info {
    color: var(--secondary-color) !important;
}

.bg-warning {
    background: #8b88ff !important;
}

.bg-warning.text-dark {
    color: #ffffff !important;
}

.border-primary {
    border-color: var(--primary-color) !important;
}

.border-info {
    border-color: var(--secondary-color) !important;
}

.shadow-sm-hover:hover {
    box-shadow: 0 0.125rem 0.25rem rgba(30, 94, 255, 0.2) !important;
}

/* Темная тема - дополнительные стили */
[data-bs-theme="dark"] .chat-message.received {
    background-color: var(--surface-alt);
}

[data-bs-theme="dark"] .chat-messages {
    background-color: var(--surface-color);
    border-color: var(--border-color);
}

[data-bs-theme="dark"] .dse-status.active {
    background-color: rgba(74, 222, 128, 0.18);
    color: var(--success-color);
}

[data-bs-theme="dark"] .dse-status.pending {
    background-color: rgba(245, 196, 81, 0.18);
    color: var(--warning-color);
}

[data-bs-theme="dark"] .dse-status.completed {
    background-color: rgba(96, 165, 250, 0.18);
    color: var(--info-color);
}

[data-bs-theme="dark"] .photo-with-error {
    background-color: var(--surface-alt);
}

[data-bs-theme="dark"] .file-upload-label {
    background-color: var(--surface-alt);
    border-color: var(--border-color);
    color: var(--text-color);
}

[data-bs-theme="dark"] .file-upload-label:hover {
    background-color: #283143;
    border-color: var(--accent-color);
}

[data-bs-theme="dark"] .image-loading {
    background: var(--surface-alt);
}

[data-bs-theme="dark"] .image-loading::after {
    color: var(--muted-color);
}

[data-bs-theme="dark"] .skeleton {
    background: linear-gradient(to right, #1f2430 4%, #283143 25%, #1f2430 36%);
    background-size: 1000px 100%;
}

/* ========== ДОПОЛНИТЕЛЬНЫЕ МОБИЛЬНЫЕ СТИЛИ ========== */

/* Предотвращение горизонтального скролла */
body, html {
    overflow-x: hidden;
    max-width: 100%;
}

/* Адаптивный шрифт */
@media (max-width: 768px) {
    html {
        font-size: 14px;
    }
    
    body {
        font-size: 14px;
        line-height: 1.5;
    }
    
    h1 {
        font-size: 1.5rem;
        margin-bottom: 0.75rem;
    }
    
    h2 {
        font-size: 1.25rem;
        margin-bottom: 0.5rem;
    }
    
    h3 {
        font-size: 1.1rem;
        margin-bottom: 0.5rem;
    }
    
    h4, h5, h6 {
        font-size: 1rem;
        margin-bottom: 0.5rem;
    }
    
    p {
        margin-bottom: 0.75rem;
    }
}

/* Адаптивные grid/flex layouts */
@media (max-width: 768px) {
    .row {
        margin-right: 0;
        margin-left: 0;
    }
    
    .col {
        padding-right: 0.375rem;
        padding-left: 0.375rem;
    }
    
    [class*="col-"] {
        width: 100%;
        margin-bottom: 1rem;
    }
}

/* Адаптивные паддинги и маржины */
@media (max-width: 768px) {
    .container, .container-lg, .container-md, .container-sm, .container-xl, .container-xxl, .container-fluid {
        padding-left: 0.75rem;
        padding-right: 0.75rem;
    }
    
    .p-3 {
        padding: 0.75rem !important;
    }
    
    .p-4 {
        padding: 1rem !important;
    }
    
    .p-5 {
        padding: 1.25rem !important;
    }
    
    .px-3 {
        padding-left: 0.75rem !important;
        padding-right: 0.75rem !important;
    }
    
    .py-3 {
        padding-top: 0.75rem !important;
        padding-bottom: 0.75rem !important;
    }
    
    .m-3 {
        margin: 0.75rem !important;
    }
    
    .mx-auto {
        margin-left: auto;
        margin-right: auto;
    }
}

/* Адаптивные списки */
@media (max-width: 768px) {
    .list-group-item {
        padding: 0.75rem 0.5rem;
        font-size: 0.9rem;
    }
    
    .list-group-item:hover {
        background-color: transparent;
    }
}

/* Адаптивный navbar dropdown */
@media (max-width: 768px) {
    .dropdown-menu {
        max-height: 50vh;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    .dropdown-menu .dropdown-item {
        padding: 0.5rem 1rem;
    }
}

/* Адаптивные ссылки и кнопки */
@media (max-width: 768px) {
    a {
        -webkit-tap-highlight-color: rgba(0, 0, 0, 0.1);
    }
    
    button {
        -webkit-tap-highlight-color: transparent;
    }
}

/* Предотвращение зума при фокусе на input */
@media (max-width: 768px) {
    input[type="text"],
    input[type="email"],
    input[type="password"],
    input[type="search"],
    input[type="number"],
    input[type="tel"],
    textarea,
    select {
        font-size: 16px !important;
    }
}

/* Адаптивные картинки */
@media (max-width: 768px) {
    img {
        max-width: 100%;
        height: auto;
        display: block;
    }
    
    .img-fluid {
        max-width: 100%;
        height: auto;
    }
}

/* Адаптивные таблицы */
@media (max-width: 768px) {
    .table {
        font-size: 0.875rem;
        border: none;
    }
    
    .table thead {
        display: none;
    }
    
    .table,
    .table tbody,
    .table tr,
    .table td {
        display: block;
        width: 100%;
    }
    
    .table tr {
        border: 1px solid #e5e7eb;
        border-radius: 8px;
        overflow: hidden;
        margin-bottom: 1rem;
    }
    
    .table td {
        text-align: right;
        padding-left: 50%;
        padding-right: 1rem;
        position: relative;
        border: none;
        padding-top: 0.5rem;
        padding-bottom: 0.5rem;
    }
    
    .table td::before {
        content: attr(data-label);
        position: absolute;
        left: 1rem;
        font-weight: bold;
        text-align: left;
    }
}

/* Адаптивные панели боковой навигации */
@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        width: 100%;
        height: 100vh;
        z-index: 999;
        transform: translateX(-100%);
        transition: transform 0.3s ease;
    }
    
    .sidebar.active {
        transform: translateX(0);
    }
}

/* Адаптивные карточки в сетке */
@media (max-width: 768px) {
    .card {
        margin-bottom: 1rem;
        box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    }
    
    .card:hover {
        transform: none;
        box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    }
    
    .row.g-4 {
        gap: 1rem !important;
    }
}

/* Спрятать элементы на мобильных */
@media (max-width: 768px) {
    .d-none-mobile {
        display: none !important;
    }
    
    .d-block-mobile {
        display: block !important;
    }
    
    .d-flex-mobile {
        display: flex !important;
    }
}

/* Фиксированная footer на мобильных */
@media (max-width: 768px) {
    footer {
        padding: 0.75rem;
        font-size: 0.875rem;
        text-align: center;
    }
}

/* Безопасность для notch/safe area */
@supports (padding: max(0px)) {
    body {
        padding-left: max(0px, env(safe-area-inset-left));
        padding-right: max(0px, env(safe-area-inset-right));
        padding-top: max(0px, env(safe-area-inset-top));
        padding-bottom: max(0px, env(safe-area-inset-bottom));
    }
    
    .navbar {
        padding-left: max(0.5rem, env(safe-area-inset-left));
        padding-right: max(0.5rem, env(safe-area-inset-right));
        padding-top: max(0.5rem, env(safe-area-inset-top));
        padding-bottom: max(0.5rem, env(safe-area-inset-bottom));
    }
    
    main {
        padding-bottom: max(0px, env(safe-area-inset-bottom));
    }
    
    footer {
        padding-left: max(0.5rem, env(safe-area-inset-left));
        padding-right: max(0.5rem, env(safe-area-inset-right));
        padding-bottom: max(0.5rem, env(safe-area-inset-bottom));
    }
}

/* Улучшенная видимость фокуса на мобильных */
@media (hover: none) and (pointer: coarse) {
    a:active,
    button:active,
    input:active {
        background-color: rgba(0, 0, 0, 0.05);
    }
    
    .btn:active {
        opacity: 0.8;
    }
}

/* ======================== МОБИЛЬНАЯ АДАПТАЦИЯ ======================== */

/* Ориентация: все устройства */
@media (orientation: portrait) {
    /* Портретная ориентация */
}

@media (orientation: landscape) {
    /* Ландшафтная ориентация */
    @media (max-height: 500px) {
        .navbar {
            padding: 0.25rem 0.5rem;
        }
        
        main {
            padding: 0;
        }
    }
}

/* Адаптация для iPhone X/XS/11 Pro (пилотка сверху) */
@supports (padding: max(0px)) {
    @media (min-height: 812px) and (max-height: 920px) {
        body {
            padding-top: max(20px, env(safe-area-inset-top));
        }
    }
}

/* Удаление стилей тени при наведении на мобильных */
@media (hover: none) {
    .card:hover,
    .btn:hover,
    .shadow-sm-hover:hover {
        box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1) !important;
    }
    
    .card:hover {
        transform: none;
    }
}

/* Адаптивные навигационные элементы */
@media (max-width: 768px) {
    .navbar-collapse {
        max-height: 50vh;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }
}

/* ======================== КЛАССЫ ДЛЯ JS ======================== */

/* Классы обнаружения типа устройства */
html.is-mobile {
    /* Мобильные устройства */
}

html.is-tablet {
    /* Планшеты */
}

html.is-phone {
    /* Телефоны */
}

/* Классы ориентации */
html.landscape {
    /* Ландшафтная ориентация */
}

html.portrait {
    /* Портретная ориентация */
}

/* Виртуальная клавиатура открыта */
html.keyboard-open {
    /* Клавиатура открыта */
}

html.keyboard-open main {
    max-height: 100vh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

html.keyboard-open .chat-messages {
    max-height: calc(100vh - 300px);
}

/* Уменьшение padding при открытой клавиатуре */
html.keyboard-open .navbar {
    padding-top: 0.25rem;
    padding-bottom: 0.25rem;
}

html.keyboard-open .container,
html.keyboard-open .container-fluid {
    padding-left: 0.5rem;
    padding-right: 0.5rem;
}

/* ======================== УЛУЧШЕНИЕ СЕНСОРНОГО ВЗАИМОДЕЙСТВИЯ ======================== */

/* Увеличение размера области клика на touch devices */
@media (hover: none) and (pointer: coarse) {
    /* Кнопки */
    .btn {
        min-height: 44px;
        min-width: 44px;
        padding-top: max(0.5rem, env(safe-area-inset-top));
        padding-bottom: max(0.5rem, env(safe-area-inset-bottom));
    }
    
    .btn-sm {
        min-height: 36px;
    }
    
    /* Ссылки */
    a {
        min-height: 44px;
        display: inline-flex;
        align-items: center;
    }
    
    /* Навигация */
    .nav-link {
        padding: 0.75rem 1rem !important;
        min-height: 44px;
        display: flex;
        align-items: center;
    }
    
    .navbar-toggler {
        min-width: 44px;
        min-height: 44px;
        padding: 0.5rem;
    }
    
    /* Инпуты и селекты */
    input[type="text"],
    input[type="email"],
    input[type="password"],
    input[type="search"],
    input[type="number"],
    input[type="tel"],
    textarea,
    select,
    .form-control,
    .form-select {
        min-height: 44px;
        padding: 0.75rem 0.875rem !important;
        border-radius: 8px !important;
    }
    
    input[type="checkbox"],
    input[type="radio"] {
        min-width: 44px;
        min-height: 44px;
        margin: 0.25rem;
    }
    
    /* Таблицы */
    .table tbody tr {
        min-height: 44px;
    }
    
    /* Меню */
    .dropdown-item {
        padding: 0.75rem 1rem !important;
        min-height: 44px;
        display: flex;
        align-items: center;
    }
    
    /* Элементы списков */
    .list-group-item {
        min-height: 44px;
        padding: 0.75rem 0.5rem !important;
        display: flex;
        align-items: center;
    }
    
    /* Фокус и активность */
    button:focus,
    a:focus,
    input:focus,
    select:focus,
    textarea:focus {
        outline: 2px solid #1E5EFF;
        outline-offset: 2px;
    }
    
    /* Удаление синего выделения */
    input,
    textarea,
    select,
    button,
    a {
        -webkit-tap-highlight-color: transparent;
    }
}

/* ======================== ОПТИМИЗАЦИЯ ДЛЯ ЭКРАНОВ С ВЫСОКОЙ DPI ======================== */

@media (min-width: 481px) and (max-width: 768px) {
    /* iPad и планшеты */
    html {
        font-size: 15px;
    }
    
    .navbar-brand {
        font-size: 1.3rem;
    }
    
    .btn {
        padding: 0.6rem 1.2rem;
    }
}

@media (min-width: 1025px) {
    /* Большие экраны */
    html {
        font-size: 16px;
    }
}

/* ======================== ВЫСОКОПИКСЕЛЬНЫЕ ЭКРАНЫ ======================== */

@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    /* Retina дисплеи и экраны с высокой плотностью пикселей */
    
    /* Тонкие линии становятся виднее */
    .border, .border-top, .border-bottom, .border-left, .border-right {
        border-width: 1px;
    }
    
    /* Шрифты немного больше для лучшей читаемости */
    body {
        -webkit-font-smoothing: antialiased;
        -moz-osx-font-smoothing: grayscale;
    }
}

/* ======================== ЗАЩИТА ОТ ZOOM BUG НА iOS ======================== */

/* Предотвращение автозума при фокусе на input */
@media (max-width: 768px) {
    input[type="text"],
    input[type="email"],
    input[type="password"],
    input[type="search"],
    input[type="number"],
    input[type="tel"],
    textarea,
    select {
        font-size: 16px !important;
        /* Это предотвращает автозум на iOS Safari */
    }
}

/* ======================== СПЕЦИАЛЬНЫЕ СТИЛИ ДЛЯ iOS ======================== */

@supports (-webkit-appearance: none) {
    /* Только Safari/iOS */
    
    input[type="search"] {
        -webkit-appearance: none;
        border-radius: 8px;
    }
    
    input[type="checkbox"],
    input[type="radio"] {
        -webkit-appearance: none;
        -webkit-box-sizing: border-box;
    }
}

/* Фиксирование элементов при открытой клавиатуре */
html.keyboard-open {
    position: fixed;
    overflow: hidden;
}

html.keyboard-open body {
    position: fixed;
    width: 100%;
}

/* ======================== СТИЛИ ДЛЯ DIFFERENT NOTCHES ======================== */

/* iPhone X/XS/11 Pro */
@media (device-width: 375px) and (device-height: 812px) and (-webkit-device-pixel-ratio: 3) {
    body {
        padding-top: max(1rem, env(safe-area-inset-top));
    }
}

/* iPhone XS Max / 11 Pro Max */
@media (device-width: 414px) and (device-height: 896px) and (-webkit-device-pixel-ratio: 3) {
    body {
        padding-top: max(1rem, env(safe-area-inset-top));
    }
}

/* iPhone 12 / 13 */
@media (device-width: 390px) and (device-height: 844px) and (-webkit-device-pixel-ratio: 3) {
    body {
        padding-top: max(1rem, env(safe-area-inset-top));
    }
}

/* ======================== ПОЛЕЗНЫЕ УТИЛИТ-КЛАССЫ ======================== */

/* Скрыть на мобильных */
@media (max-width: 768px) {
    .d-none-mobile {
        display: none !important;
    }
    
    .d-block-mobile {
        display: block !important;
    }
    
    .d-flex-mobile {
        display: flex !important;
    }
    
    .d-grid-mobile {
        display: grid !important;
    }
    
    .d-inline-mobile {
        display: inline !important;
    }
}

/* Видимость по размеру экрана */
@media (max-width: 576px) {
    .d-none-xs {
        display: none !important;
    }
}

@media (min-width: 577px) and (max-width: 768px) {
    .d-none-sm {
        display: none !important;
    }
}

@media (min-width: 769px) and (max-width: 992px) {
    .d-none-md {
        display: none !important;
    }
}

@media (min-width: 993px) {
    .d-none-lg {
        display: none !important;
    }
}
