/* ============================================
   УНИВЕРСАЛЬНАЯ АДАПТАЦИЯ ДЛЯ ТЕЛЕФОНОВ И ПЛАНШЕТОВ
   ============================================ */

/* === ПЛАНШЕТЫ (до 992px) === */
@media (max-width: 992px) {
    /* Общие контейнеры */
    .container, .nav-container {
        padding: 0 15px;
    }
    
    /* Навигация */
    .navbar {
        padding: 10px 0;
    }
    
    .nav-container {
        flex-wrap: wrap;
        justify-content: space-between;
    }
    
    .nav-menu {
        position: fixed;
        top: 70px;
        left: -100%;
        width: 80%;
        max-width: 300px;
        height: calc(100vh - 70px);
        background: linear-gradient(180deg, var(--dark-green, #1e3c1e) 0%, var(--primary-green, #2a5934) 100%);
        flex-direction: column;
        padding: 20px;
        transition: left 0.3s ease;
        z-index: 999;
        overflow-y: auto;
    }
    
    .nav-menu.show {
        left: 0;
    }
    
    .nav-menu li {
        width: 100%;
    }
    
    .nav-menu .nav-link {
        display: block;
        padding: 12px 20px;
        font-size: 1rem;
        text-align: left;
    }
    
    .mobile-menu-btn {
        display: block !important;
    }
    
    /* Скрываем обычную кнопку входа на мобильных */
    .login-btn {
        display: none !important;
    }
    
    /* Показываем мобильную кнопку входа в меню */
    .mobile-login-btn {
        display: block;
        margin-top: 20px;
        padding: 12px 20px;
        background: linear-gradient(135deg, #4caf50, #2e7d32);
        color: white;
        text-align: center;
        border-radius: 30px;
        text-decoration: none;
        font-weight: 600;
    }
    
    /* Логотип */
    .logo-image {
        width: 45px;
        height: 45px;
    }
    
    .logo-text h2 {
        font-size: 1.1rem;
    }
    
    .logo-text p {
        font-size: 0.7rem;
    }
    
    /* Заголовки */
    h1, .hero h1, .home1 h1, .calendar-hero h1 {
        font-size: 2rem !important;
    }
    
    h2, .section-title, .calendar-intro h2 {
        font-size: 1.8rem !important;
    }
    
    /* Сетки */
    .stats-grid, .events-grid, .about-grid, .feed-grid,
    .branches-grid, .cards-row, .dates-container {
        grid-template-columns: 1fr !important;
        gap: 20px !important;
    }
    
    /* Карточки */
    .date-card.large {
        flex-direction: column !important;
    }
    
    .date-card.large .earth-icon {
        width: 100% !important;
        padding: 20px !important;
    }
    
    .date-card.vertical {
        grid-template-columns: 1fr !important;
    }
    
    .date-card.vertical .date-header {
        flex-direction: row !important;
        justify-content: center !important;
        gap: 20px !important;
        padding: 20px !important;
    }
    
    /* Таймлайн */
    .timeline::before {
        left: 20px !important;
    }
    
    .timeline-dot {
        left: 20px !important;
    }
    
    .timeline-content {
        width: calc(100% - 50px) !important;
        margin-left: 50px !important;
        margin-right: 0 !important;
    }
    
    /* Модальное окно */
    .modal-content {
        width: 95% !important;
        max-width: 500px !important;
        margin: 20px !important;
    }
    
    .form-row {
        flex-direction: column !important;
        gap: 15px !important;
    }
    
    .modal-footer {
        flex-direction: column !important;
    }
    
    .modal-footer .btn {
        width: 100% !important;
    }
    
    /* Админ панель */
    .admin-sidebar {
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        z-index: 1002;
    }
    
    .admin-sidebar.active {
        transform: translateX(0);
    }
    
    .admin-header {
        left: 0 !important;
    }
    
    .admin-main {
        margin-left: 0 !important;
    }
    
    .mobile-menu-btn.admin-btn {
        display: flex !important;
        position: fixed;
        top: 15px;
        left: 15px;
        z-index: 1003;
    }
    
    /* Формы админки */
    .grid-2, .main-content {
        grid-template-columns: 1fr !important;
    }
    
    .form-container, .form-card, .section {
        padding: 20px !important;
    }
    
    /* Контакты */
    .contact-info-item {
        flex-direction: column !important;
        text-align: center !important;
    }
    
    .work-hours-day {
        flex-direction: column !important;
        gap: 5px !important;
    }
    
    /* Уведомления */
    .notification {
        top: auto !important;
        bottom: 20px !important;
        right: 20px !important;
        left: 20px !important;
        max-width: none !important;
    }
}

/* === ТЕЛЕФОНЫ (до 768px) === */
@media (max-width: 768px) {
    /* Общие отступы */
    body {
        padding: 0;
        overflow-x: hidden;
    }
    
    .container {
        padding: 0 12px;
    }
    
    /* Навигация */
    .navbar {
        padding: 8px 0;
    }
    
    .nav-container {
        padding: 0 12px;
    }
    
    .logo-image {
        width: 40px;
        height: 40px;
    }
    
    .logo-text h2 {
        font-size: 0.95rem;
    }
    
    .logo-text p {
        font-size: 0.6rem;
    }
    
    /* Hero секции */
    .hero, .home1, .calendar-hero, .hero-section {
        padding: 60px 0 !important;
        min-height: auto !important;
    }
    
    .hero h1, .home1 h1, .calendar-hero h1, .hero-section h1 {
        font-size: 1.8rem !important;
    }
    
    .hero p, .home1 p, .calendar-hero p, .hero-section p {
        font-size: 1rem !important;
        padding: 0 15px !important;
    }
    
    /* Заголовки */
    .section-title, .calendar-intro h2, .contact-info-title {
        font-size: 1.6rem !important;
    }
    
    /* Карточки */
    .event-card, .feed-card, .modern-event-card, .about-card, .month-card {
        margin: 0 0 15px 0 !important;
    }
    
    .event-header {
        padding: 15px !important;
    }
    
    .event-content, .card-content {
        padding: 15px !important;
    }
    
    .event-title, .card-title {
        font-size: 1.2rem !important;
    }
    
    /* Таймлайн */
    .timeline-content {
        padding: 15px !important;
    }
    
    .timeline-year {
        font-size: 1.3rem !important;
    }
    
    .timeline-content h3 {
        font-size: 1.1rem !important;
    }
    
    /* Формы */
    .form-group input, 
    .form-group textarea, 
    .form-group select,
    .form-control {
        padding: 10px 12px !important;
        font-size: 14px !important;
    }
    
    .btn, .modern-register-btn, .action-btn {
        padding: 10px 18px !important;
        font-size: 0.9rem !important;
    }
    
    /* Админ панель */
    .admin-header .header-content {
        padding: 0 12px !important;
    }
    
    .admin-logo h1 {
        font-size: 1rem !important;
    }
    
    .admin-logo i {
        font-size: 1.5rem !important;
    }
    
    .admin-main {
        padding: 80px 12px 20px !important;
    }
    
    .welcome-card {
        padding: 20px !important;
    }
    
    .welcome-card h2 {
        font-size: 1.3rem !important;
    }
    
    .stat-card {
        padding: 15px !important;
    }
    
    .stat-value {
        font-size: 1.8rem !important;
    }
    
    .chart-container {
        height: 250px !important;
    }
    
    /* Новостная лента */
    .feed-controls {
        flex-direction: column !important;
        align-items: stretch !important;
    }
    
    .filter-buttons {
        flex-wrap: wrap;
        justify-content: center;
        gap: 8px;
    }
    
    .filter-btn {
        padding: 6px 12px !important;
        font-size: 0.8rem !important;
    }
    
    .search-box {
        width: 100%;
    }
    
    .search-input {
        padding: 10px 15px 10px 40px !important;
        font-size: 14px !important;
    }
    
    /* Подписка */
    .newsletter-wrapper {
        grid-template-columns: 1fr !important;
        gap: 25px !important;
    }
    
    .newsletter-content h2 {
        font-size: 1.3rem !important;
    }
    
    .newsletter-form {
        padding: 20px !important;
    }
    
    /* Футер */
    .footer {
        padding: 30px 0 15px !important;
        margin-top: 40px !important;
    }
    
    .footer-content {
        grid-template-columns: 1fr !important;
        gap: 25px !important;
        padding: 0 15px !important;
    }
    
    .footer-section {
        text-align: center;
    }
    
    .footer-section h4 {
        font-size: 1.1rem !important;
    }
    
    .footer-section h4::after {
        left: 50% !important;
        transform: translateX(-50%);
    }
    
    .footer-links {
        display: flex;
        flex-direction: column;
        align-items: center;
    }
    
    .social-links {
        justify-content: center;
    }
    
    .copyright {
        font-size: 0.75rem !important;
        padding: 15px 10px 0 !important;
    }
    
    /* Контакты */
    .contact-info-section {
        padding: 20px 15px !important;
        margin: 20px 0 !important;
    }
    
    .contact-icon-large {
        width: 45px !important;
        height: 45px !important;
        font-size: 1.2rem !important;
    }
    
    .contact-label {
        font-size: 0.9rem !important;
    }
    
    .contact-value {
        font-size: 0.9rem !important;
    }
    
    /* Мероприятия */
    .events-section {
        padding: 40px 0 !important;
    }
    
    .event-footer {
        flex-direction: column !important;
        gap: 10px !important;
    }
    
    .modern-register-btn {
        width: 100% !important;
        justify-content: center !important;
    }
    
    .share-btn {
        align-self: center !important;
    }
    
    /* Знаменательные дни */
    .dates-section {
        padding: 30px 0 !important;
    }
    
    .date-actions {
        flex-direction: column !important;
    }
    
    .action-btn {
        width: 100% !important;
        justify-content: center !important;
    }
    
    /* Календарь */
    .month-header {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 10px !important;
    }
    
    .month-header h3 {
        font-size: 1.5rem !important;
    }
    
    .event-row {
        flex-direction: column !important;
        align-items: center !important;
        text-align: center !important;
    }
    
    .event-date {
        margin-bottom: 10px !important;
    }
}

/* === ОЧЕНЬ МАЛЕНЬКИЕ ТЕЛЕФОНЫ (до 480px) === */
@media (max-width: 480px) {
    /* Навигация */
    .logo-text p {
        display: none !important;
    }
    
    .logo-text h2 {
        font-size: 0.85rem !important;
    }
    
    .logo-image {
        width: 35px !important;
        height: 35px !important;
    }
    
    /* Заголовки */
    h1, .hero h1, .home1 h1 {
        font-size: 1.5rem !important;
    }
    
    h2, .section-title {
        font-size: 1.4rem !important;
    }
    
    h3, .event-title, .card-title {
        font-size: 1.2rem !important;
    }
    
    /* Кнопки */
    .btn, .modern-register-btn {
        padding: 8px 15px !important;
        font-size: 0.85rem !important;
    }
    
    /* Формы */
    .form-group label {
        font-size: 0.85rem !important;
    }
    
    /* Статистика в админке */
    .stat-card {
        text-align: center;
    }
    
    .stat-header {
        justify-content: center;
    }
    
    /* Модальное окно */
    .modal-header {
        padding: 15px !important;
    }
    
    .modal-header h3 {
        font-size: 1.2rem !important;
    }
    
    .modal-body {
        padding: 15px !important;
    }
    
    .event-info-label {
        width: 80px !important;
        font-size: 0.85rem !important;
    }
    
    /* Футер */
    .footer-section h4 {
        font-size: 1rem !important;
    }
    
    .footer-section p, 
    .footer-links a,
    .contact-info p {
        font-size: 0.8rem !important;
    }
    
    .social-links a {
        width: 35px !important;
        height: 35px !important;
        font-size: 1rem !important;
    }
}

/* === АЛЬБОМНАЯ ОРИЕНТАЦИЯ НА ТЕЛЕФОНАХ === */
@media (max-width: 800px) and (orientation: landscape) {
    .nav-menu {
        height: calc(100vh - 60px);
        overflow-y: auto;
    }
    
    .hero, .home1 {
        padding: 40px 0 !important;
        min-height: auto !important;
    }
    
    .admin-sidebar {
        overflow-y: auto;
    }
}

/* === КНОПКА МОБИЛЬНОГО МЕНЮ (общие стили) === */
.mobile-menu-btn {
    display: none;
    background: none;
    border: none;
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 8px 12px;
    transition: all 0.3s ease;
    border-radius: 8px;
}

.mobile-menu-btn:hover {
    background: rgba(255, 255, 255, 0.1);
}

/* Оверлей для мобильного меню */
.menu-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 998;
}

.menu-overlay.active {
    display: block;
}

/* === УЛУЧШЕНИЯ ДЛЯ ТАЧ-УСТРОЙСТВ === */
@media (hover: none) and (pointer: coarse) {
    /* Увеличиваем область нажатия для кнопок */
    .btn, 
    .modern-register-btn,
    .action-btn,
    .nav-link,
    .filter-btn,
    .share-btn {
        min-height: 44px;
    }
    
    /* Убираем hover-эффекты на тач-устройствах */
    .btn:hover,
    .card:hover,
    .event-card:hover {
        transform: none;
    }
    
    /* Увеличиваем отступы для лучшего тача */
    .nav-link {
        padding: 12px 16px;
    }
    
    .form-control,
    input,
    select,
    textarea {
        font-size: 16px !important; /* Предотвращает масштабирование на iOS */
    }
}

/* === АНИМАЦИЯ ДЛЯ МОБИЛЬНОГО МЕНЮ === */
.nav-menu {
    transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* === СКРОЛЛ ДЛЯ МОБИЛЬНЫХ УСТРОЙСТВ === */
@media (max-width: 768px) {
    .events-grid,
    .feed-grid,
    .articles-grid {
        max-height: none;
        overflow: visible;
    }
    
    /* Горизонтальный скролл для таблиц, если нужно */
    .table-responsive {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
}

/* === ОТСТУПЫ ДЛЯ ФИКСИРОВАННОЙ НАВИГАЦИИ === */
@media (max-width: 992px) {
    body {
        padding-top: 0;
    }
    
    /* Компенсация для якорных ссылок */
    section[id] {
        scroll-margin-top: 80px;
    }
}