/* ========================================
   MOBILE ADAPTIVE STYLES
   Улучшенная мобильная адаптация для всего сайта
   ======================================== */

/* ===== БАЗОВЫЕ НАСТРОЙКИ ===== */
* {
    box-sizing: border-box;
}

/* Улучшение читаемости на мобильных */
@media (max-width: 768px) {
    body {
        font-size: 16px !important; /* Предотвращаем зум в Safari */
        line-height: 1.5;
        -webkit-text-size-adjust: 100%;
        -ms-text-size-adjust: 100%;
    }
    
    /* Обеспечиваем минимальный размер тапа */
    a, button, input, select, textarea {
        min-height: 44px;
        min-width: 44px;
    }
}

/* ===== КОНТЕЙНЕРЫ И СЕТКИ ===== */
@media (max-width: 1200px) {
    .container {
        padding-left: 20px;
        padding-right: 20px;
    }
}

@media (max-width: 768px) {
    .container {
        padding-left: 15px;
        padding-right: 15px;
    }
    
    /* Превращаем сетки в одну колонку */
    .row > [class*="col-"] {
        flex: 0 0 100%;
        max-width: 100%;
        margin-bottom: 20px;
    }
    
    /* Сетки CSS Grid */
    .grid, .sections-grid, .files-grid, .materials-grid {
        grid-template-columns: 1fr !important;
        gap: 15px !important;
    }
}

/* ===== НАВИГАЦИЯ ===== */
@media (max-width: 992px) {
    /* Главная навигация */
    .gtec-navbar {
        padding: 10px 0;
    }
    
    .main-nav {
        flex-direction: column;
        gap: 10px;
        width: 100%;
    }
    
    .nav-link {
        width: 100%;
        text-align: center;
        padding: 12px 16px;
        font-size: 0.9rem;
    }
    
    /* Мобильное меню-гамбургер */
    .mobile-menu-toggle {
        display: block !important;
        background: none;
        border: none;
        font-size: 1.5rem;
        padding: 10px;
        color: #333;
    }
    
    .main-nav.mobile-hidden {
        display: none;
    }
    
    .main-nav.mobile-show {
        display: flex;
        position: fixed;
        top: 80px;
        left: 0;
        right: 0;
        background: white;
        box-shadow: 0 4px 20px rgba(0,0,0,0.1);
        z-index: 1000;
        padding: 20px;
    }
}

@media (max-width: 576px) {
    .nav-link {
        padding: 10px 12px;
        font-size: 0.8rem;
    }
}

/* ===== КНОПКИ И ФОРМЫ ===== */
@media (max-width: 768px) {
    /* Кнопки */
    .btn {
        padding: 12px 20px;
        font-size: 1rem;
        min-height: 44px;
        border-radius: 8px;
    }
    
    .btn-sm {
        padding: 8px 12px;
        font-size: 0.9rem;
        min-height: 36px;
    }
    
    /* Группы кнопок */
    .btn-group {
        flex-direction: column;
        gap: 10px;
    }
    
    .btn-group .btn {
        width: 100%;
        margin: 0;
    }
    
    /* Формы */
    .form-control {
        padding: 12px 16px;
        font-size: 1rem;
        min-height: 44px;
        border-radius: 8px;
    }
    
    .form-group {
        margin-bottom: 20px;
    }
    
    .form-label {
        font-size: 1rem;
        margin-bottom: 8px;
        display: block;
    }
    
    /* Горизонтальные формы становятся вертикальными */
    .form-horizontal .form-group {
        flex-direction: column;
    }
    
    .form-horizontal .form-label {
        margin-bottom: 8px;
        text-align: left;
    }
}

/* ===== КАРТОЧКИ И ПАНЕЛИ ===== */
@media (max-width: 768px) {
    .card, .panel, .admin-card {
        margin-bottom: 15px;
        border-radius: 12px;
        box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    }
    
    .card-body, .panel-body {
        padding: 20px 15px;
    }
    
    .card-header, .panel-heading {
        padding: 15px;
        font-size: 1.1rem;
    }
    
    /* Карточки секций */
    .section-card {
        padding: 20px;
        margin-bottom: 15px;
    }
    
    .section-card h3 {
        font-size: 1.2rem;
        margin-bottom: 10px;
    }
    
    .section-features {
        flex-direction: column;
        gap: 5px;
    }
}

/* ===== ТАБЛИЦЫ ===== */
@media (max-width: 768px) {
    /* Горизонтальная прокрутка для таблиц */
    .table-responsive {
        -webkit-overflow-scrolling: touch;
    }
    
    .table {
        min-width: 600px;
        font-size: 0.9rem;
    }
    
    .table th,
    .table td {
        padding: 8px 6px;
        white-space: nowrap;
    }
    
    /* Стековые таблицы для очень маленьких экранов */
    .table-stack {
        display: block;
    }
    
    .table-stack thead {
        display: none;
    }
    
    .table-stack tbody,
    .table-stack tr,
    .table-stack td {
        display: block;
        width: 100%;
    }
    
    .table-stack tr {
        border: 1px solid #ddd;
        margin-bottom: 10px;
        border-radius: 8px;
        padding: 10px;
    }
    
    .table-stack td {
        border: none;
        padding: 5px 0;
        text-align: left;
    }
    
    .table-stack td:before {
        content: attr(data-label) ": ";
        font-weight: bold;
        color: #333;
    }
}

/* ===== МОДАЛЬНЫЕ ОКНА ===== */
@media (max-width: 768px) {
    .modal-dialog {
        margin: 10px;
        max-width: calc(100% - 20px);
    }
    
    .modal-content {
        border-radius: 12px;
    }
    
    .modal-header {
        padding: 20px 15px 15px;
    }
    
    .modal-body {
        padding: 15px;
    }
    
    .modal-footer {
        padding: 15px;
        flex-direction: column;
        gap: 10px;
    }
    
    .modal-footer .btn {
        width: 100%;
        margin: 0;
    }
}

/* ===== БОКОВЫЕ ПАНЕЛИ И САЙДБАРЫ ===== */
@media (max-width: 992px) {
    .sidebar, .stud-sidebar, .widgets-sidebar {
        position: static !important;
        width: 100% !important;
        margin-top: 30px;
    }
    
    .content-with-sidebar {
        flex-direction: column;
    }
    
    .main-content {
        width: 100%;
        margin-right: 0;
    }
}

/* ===== АДМИН ПАНЕЛЬ ===== */
@media (max-width: 992px) {
    .admin-sidebar {
        transform: translateX(-100%);
        position: fixed;
        z-index: 1000;
        transition: transform 0.3s ease;
    }
    
    .admin-sidebar.active {
        transform: translateX(0);
    }
    
    .admin-main {
        margin-left: 0;
        width: 100%;
    }
    
    .admin-mobile-toggle {
        display: block !important;
        position: fixed;
        top: 20px;
        left: 20px;
        z-index: 1001;
        background: #667eea;
        color: white;
        border: none;
        padding: 10px;
        border-radius: 8px;
        font-size: 1.2rem;
    }
}

@media (max-width: 768px) {
    .admin-header {
        padding: 15px;
    }
    
    .admin-header-content {
        flex-direction: column;
        gap: 15px;
        text-align: center;
    }
    
    .admin-title {
        font-size: 1.8rem;
    }
    
    .admin-actions {
        width: 100%;
        justify-content: center;
    }
    
    .admin-card {
        margin: 0 0 20px 0;
    }
    
    .form-grid {
        grid-template-columns: 1fr;
        gap: 15px;
    }
}

/* ===== HERO СЕКЦИИ ===== */
@media (max-width: 768px) {
    .hero, .kontrol-hero, .ymk-hero, .stud-hero {
        padding: 40px 0;
    }
    
    .hero-title {
        font-size: 2rem;
        line-height: 1.2;
        margin-bottom: 15px;
    }
    
    .hero-subtitle {
        font-size: 1rem;
        margin-bottom: 25px;
    }
    
    .hero-stats {
        flex-direction: column;
        gap: 15px;
        margin-top: 25px;
    }
    
    .stat-item {
        min-width: auto;
    }
    
    .stat-number {
        font-size: 2rem;
    }
}

/* ===== ХЛЕБНЫЕ КРОШКИ ===== */
@media (max-width: 576px) {
    .breadcrumb {
        font-size: 0.8rem;
        padding: 10px 15px;
    }
    
    .breadcrumb-item {
        max-width: 100px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
}

/* ===== ФИКСИРОВАННЫЕ ЭЛЕМЕНТЫ ===== */
@media (max-width: 768px) {
    /* Фиксированные кнопки */
    .fixed-bottom-btn {
        position: fixed;
        bottom: 20px;
        left: 50%;
        transform: translateX(-50%);
        z-index: 1000;
        width: calc(100% - 40px);
        max-width: 300px;
    }
    
    /* Плавающие элементы */
    .floating-elements {
        display: none; /* Скрываем на мобильных */
    }
    
    /* Уведомления */
    .notification, .alert {
        position: fixed;
        top: 20px;
        left: 10px;
        right: 10px;
        z-index: 1050;
        margin: 0;
        border-radius: 8px;
    }
}

/* ===== УТИЛИТЫ ===== */
/* Скрытие элементов на мобильных */
@media (max-width: 768px) {
    .d-mobile-none {
        display: none !important;
    }
    
    .d-mobile-block {
        display: block !important;
    }
    
    .d-mobile-flex {
        display: flex !important;
    }
    
    .text-mobile-center {
        text-align: center !important;
    }
    
    .text-mobile-left {
        text-align: left !important;
    }
}

/* Показ элементов только на мобильных */
@media (min-width: 769px) {
    .d-mobile-only {
        display: none !important;
    }
}

@media (max-width: 768px) {
    .d-mobile-only {
        display: block !important;
    }
}

/* ===== ИСПРАВЛЕНИЯ ДЛЯ КОНКРЕТНЫХ КОМПОНЕНТОВ ===== */

/* Контрольные работы */
@media (max-width: 768px) {
    .specialty-tabs {
        flex-direction: column;
        gap: 10px;
    }
    
    .tab-btn {
        width: 100%;
        justify-content: center;
        padding: 12px 20px;
    }
    
    .quick-actions {
        grid-template-columns: 1fr;
        gap: 10px;
    }
    
    .quick-action {
        padding: 15px;
        text-align: center;
    }
}

/* УМК страница */
@media (max-width: 768px) {
    .course-header {
        padding: 15px 20px;
        flex-wrap: wrap;
    }
    
    .course-icon {
        font-size: 1.5rem;
    }
    
    .group-header {
        padding: 12px 15px;
        flex-wrap: wrap;
    }
    
    .materials-grid {
        grid-template-columns: 1fr;
        gap: 10px;
    }
    
    .material-item {
        padding: 12px 15px;
        font-size: 0.9rem;
    }
}

/* Файлы и загрузки */
@media (max-width: 768px) {
    .file-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
        padding: 15px;
    }
    
    .file-link {
        font-size: 0.9rem;
        line-height: 1.4;
    }
    
    .download-btn-small {
        align-self: stretch;
        width: 100%;
        justify-content: center;
    }
}

/* ===== УЛУЧШЕНИЯ ПРОИЗВОДИТЕЛЬНОСТИ ===== */
@media (max-width: 768px) {
    /* Отключаем анимации на медленных устройствах */
    @media (prefers-reduced-motion: reduce) {
        * {
            animation-duration: 0.01ms !important;
            animation-iteration-count: 1 !important;
            transition-duration: 0.01ms !important;
        }
    }
    
    /* Оптимизация изображений */
    img {
        height: auto;
        max-width: 100%;
    }
    
    .lazyload {
        opacity: 0;
        transition: opacity 0.3s;
    }
    
    .lazyloaded {
        opacity: 1;
    }
} 