/* ============================================================
   IESA RESPONSIVE CSS — v3.0 MOBILE-FIRST OVERHAUL
   
   Breakpoints (Bootstrap 5):
     xs  < 576px    — смартфоны (портрет)
     sm  576-767px  — смартфоны (альбом)
     md  768-991px  — планшеты
     lg  992-1199px — ноутбуки
     xl  1200px+    — десктопы
   
   Что здесь:
   1. Глобальные mobile-first базовые правила
   2. Navbar мобильное меню (нижняя панель + collapse)
   3. Типографика
   4. Hero + Homepage sections  
   5. Карточки и гриды
   6. Формы
   7. Таблицы (partner dashboard)
   8. Профиль / кабинет
   9. Аутентификация
   10. Галерея
   11. Блог / ивенты
   12. Футер
   13. Утилиты
   14. Safe-area insets (iOS нотч/home bar)
   15. Desktop hover-only правила
   16. Анимации + a11y
   ============================================================ */


/* ============================================================
   0. ГЛОБАЛЬНЫЕ MOBILE-FIRST ОСНОВЫ
   ============================================================ */

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

/* Все картинки адаптивны */
img {
  max-width: 100%;
  height: auto;
}

/* Минимальные tap-targets — только на touch-устройствах (U1-01) */
@media (hover: none) and (pointer: coarse) {
  a, button, [role="button"], label[for],
  input[type="checkbox"], input[type="radio"] {
    min-height: 44px;
    min-width: 44px;
  }
}

/* iOS zoom fix: font-size >= 16px on touch only — applied in mobile section below (U1-02) */

/* Таблицы не вываливаются */
table {
  max-width: 100%;
}

/* Длинные слова переносятся */
p, h1, h2, h3, h4, h5, h6,
.card-title, .card-text,
.post-title, .event-title {
  overflow-wrap: break-word;
  word-break: break-word;
}


/* ============================================================
   1. НИЖНЯЯ МОБИЛЬНАЯ НАВИГАЦИЯ (bottom nav)
   ============================================================ */

/* Контейнер нижней навигации — скрыт на десктопе */
.mobile-bottom-nav {
  display: none;
}

/* Avatar in mobile bottom-nav (U1-04: replaces inline styles) */
.mbn-avatar {
  width: clamp(20px, 5.5vw, 26px);
  height: clamp(20px, 5.5vw, 26px);
  border-radius: 50%;
  overflow: hidden;
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
}
.mbn-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

@media (max-width: 767.98px) {
  /* Нижняя навигация */
  .mobile-bottom-nav {
    display: flex;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 1040;
    background: rgba(14, 14, 24, 0.97);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-top: 1px solid rgba(255,255,255,0.06);
    box-shadow: 0 -4px 24px rgba(0,0,0,0.35);
    padding: 6px 4px;
    padding-bottom: calc(6px + env(safe-area-inset-bottom));
    justify-content: space-around;
    align-items: center;
  }

  .mobile-bottom-nav .mbn-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1;
    padding: 4px 0;
    color: rgba(255,255,255,0.45);
    text-decoration: none;
    font-size: 0.6rem;
    font-weight: 600;
    letter-spacing: 0.03em;
    gap: 3px;
    border-radius: 10px;
    transition: color 0.2s, background 0.2s;
    -webkit-tap-highlight-color: transparent;
    min-height: 48px;
  }

  .mobile-bottom-nav .mbn-item i {
    font-size: 1.15rem;
    line-height: 1;
  }

  .mobile-bottom-nav .mbn-item.active,
  .mobile-bottom-nav .mbn-item:active {
    color: #dc2626;
    background: rgba(220, 38, 38, 0.07);
  }

  .mobile-bottom-nav .mbn-item .mbn-badge {
    position: absolute;
    top: 2px;
    right: 10px;
    background: #dc2626;
    color: white;
    border-radius: 999px;
    font-size: 0.55rem;
    padding: 1px 5px;
    line-height: 1.4;
    min-width: 16px;
    text-align: center;
  }

  .mobile-bottom-nav .mbn-item-wrap {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    flex: 1;
  }

  /* Центральная кнопка (QR/Visit/+) — выступает вверх */
  .mobile-bottom-nav .mbn-center-btn {
    flex: 0 0 56px;
    width: 56px; height: 56px;
    border-radius: 50%;
    background: linear-gradient(135deg, #dc2626, #991b1b);
    border: none;
    color: #fff;
    font-size: 1.4rem;
    display: flex; align-items: center; justify-content: center;
    margin-bottom: 12px;
    box-shadow: 0 4px 20px rgba(220,38,38,.5);
    cursor: pointer; text-decoration: none;
    transition: transform .15s, box-shadow .15s;
    -webkit-tap-highlight-color: transparent;
    flex-direction: column; gap: 2px;
  }
  .mobile-bottom-nav .mbn-center-btn span {
    font-size: .55rem; font-weight: 700; color: rgba(255,255,255,.85);
  }
  .mobile-bottom-nav .mbn-center-btn:active {
    transform: scale(.93);
    box-shadow: 0 2px 10px rgba(220,38,38,.4);
  }
  /* mbn-qr-btn: чуть другой стиль через override */
  .mobile-bottom-nav .mbn-qr-btn {
    font-size: 1.35rem;
  }

  /* Отступ снизу для main чтобы не перекрывался навигацией */
  main#main-content {
    padding-bottom: calc(72px + env(safe-area-inset-bottom)) !important;
  }
}


/* ============================================================
   2. NAVBAR — МОБИЛЬНАЯ ВЕРСИЯ
   ============================================================ */

@media (max-width: 767.98px) {
  /* Скрываем основной navbar на маленьких экранах (используем bottom nav) */
  header .navbar {
    padding-top: 0.3rem !important;
    padding-bottom: 0.3rem !important;
  }

  .navbar-brand img,
  .navbar-brand .navbar-logo {
    height: 28px !important;
    max-width: 100px !important;
    width: auto;
  }

  /* Hamburger toggler — тёмный (единый стиль с navbar) */
  .navbar-toggler {
    border: 1px solid rgba(255,255,255,0.12);
    padding: 0.4rem 0.5rem;
    font-size: 1.2rem;
    color: rgba(255,255,255,0.75);
    border-radius: 10px;
    background: rgba(255,255,255,0.07);
  }

  .navbar-toggler:focus {
    box-shadow: 0 0 0 0.2rem rgba(220,38,38,0.25);
  }

  /* Collapse dropdown — стили оформления (position управляется layout.css) */
  .iesa-navbar .navbar-collapse {
    padding: .5rem 0 .75rem;
    background: rgba(10, 10, 15, 0.98);
    border-bottom: 1px solid rgba(255,255,255,0.08);
    box-shadow: 0 12px 40px rgba(0,0,0,.6);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
  }

  .navbar-nav .nav-link {
    padding: 0.6rem 0.75rem;
    border-radius: 10px;
    color: rgba(255,255,255,0.75);
    font-size: 0.95rem;
  }

  .navbar-nav .nav-link:hover,
  .navbar-nav .nav-link.active {
    background: rgba(220,38,38,0.12);
    color: #f87171;
  }

  .navbar-nav .dropdown-menu {
    position: static !important;
    transform: none !important;
    width: 100% !important;
    box-shadow: none;
    border: 1px solid rgba(255,255,255,0.06);
    border-radius: 12px;
    margin-top: 0.25rem;
    background: rgba(255,255,255,0.04);
  }

  /* Элементы внутри collapse — на всю ширину (НЕ .iesa-nav-mobile-wrap!) */
  .navbar-collapse .d-flex.align-items-center {
    flex-direction: column;
    align-items: stretch !important;
    gap: 0.5rem !important;
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px solid rgba(255,255,255,0.08);
  }

  /* Мобильный блок иконок — ВСЕГДА горизонтальный */
  .iesa-nav-mobile-wrap {
    flex-direction: row !important;
    align-items: center !important;
    gap: .35rem !important;
    margin-top: 0 !important;
    padding-top: 0 !important;
    border-top: none !important;
  }

  .navbar-btn {
    width: 100%;
    justify-content: center;
  }
}

@media (min-width: 768px) and (max-width: 991.98px) {
  .navbar-brand img {
    height: 30px;
  }

  .navbar-collapse .d-flex.align-items-center {
    gap: 0.35rem !important;
  }

  .navbar-btn {
    font-size: 0.82rem;
    padding: 0.35rem 0.75rem;
  }
}


/* ============================================================
   3. ТИПОГРАФИКА — МОБИЛЬНОЕ МАСШТАБИРОВАНИЕ
   ============================================================ */

@media (max-width: 575.98px) {
  h1, .h1 { font-size: clamp(1.6rem, 6vw, 2rem) !important; line-height: 1.2; }
  h2, .h2 { font-size: clamp(1.3rem, 5vw, 1.75rem) !important; line-height: 1.25; }
  h3, .h3 { font-size: clamp(1.1rem, 4.5vw, 1.5rem) !important; }
  h4, .h4 { font-size: clamp(1rem, 4vw, 1.25rem) !important; }
  h5, .h5 { font-size: 1rem !important; }
  h6, .h6 { font-size: 0.9rem !important; }

  .display-1 { font-size: clamp(2rem, 10vw, 3rem) !important; }
  .display-2 { font-size: clamp(1.8rem, 8vw, 2.5rem) !important; }
  .display-3 { font-size: clamp(1.5rem, 7vw, 2rem) !important; }
  .display-4 { font-size: clamp(1.3rem, 6vw, 1.75rem) !important; }

  .small, small { font-size: 0.875rem !important; }
  p { font-size: 0.95rem; line-height: 1.65; }
}

@media (min-width: 576px) and (max-width: 767.98px) {
  h1, .h1 { font-size: clamp(1.75rem, 5vw, 2.25rem) !important; }
  h2, .h2 { font-size: clamp(1.4rem, 4.5vw, 1.875rem) !important; }
  h3, .h3 { font-size: clamp(1.15rem, 3.5vw, 1.5rem) !important; }
}


/* ============================================================
   4. КНОПКИ — МОБИЛЬНЫЕ ПРАВИЛА
   ============================================================ */

@media (max-width: 767.98px) {
  .btn {
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
    touch-action: manipulation;
    font-size: 0.9rem;
    padding: 0.55rem 1rem;
    min-height: 44px;
  }

  .btn:hover {
    transform: none !important;
  }

  /* Группы кнопок — стекаются вертикально */
  .btn-group-mobile-stack {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
  }

  .btn-group-mobile-stack .btn {
    width: 100%;
  }
}


/* ============================================================
   5. HERO SECTION
   ============================================================ */

@media (max-width: 767.98px) {
  .hero-section,
  .hero-showcase {
    padding: 1.5rem 1rem;
    border-radius: 16px;
  }

  .hero-section h1,
  .hero-showcase h1 {
    font-size: clamp(1.5rem, 6vw, 2rem);
    line-height: 1.2;
  }

  .hero-section .hero-description,
  .hero-showcase .hero-description {
    font-size: 0.9rem;
    line-height: 1.6;
  }

  .hero-stats {
    gap: 0.75rem;
  }

  .hero-stat-value {
    font-size: 1.5rem;
  }

  .hero-badge {
    font-size: 0.75rem;
    padding: 0.35rem 0.7rem;
    max-width: 95%;
  }

  /* Канвас-частицы — уменьшаем интенсивность (JS может ставить inline opacity) */
  #hero-canvas, canvas.particles-canvas {
    opacity: 0.4 !important;
  }
}

@media (max-width: 575.98px) {
  .hero-section,
  .hero-showcase {
    padding: 1.25rem 0.75rem;
  }
}


/* ============================================================
   6. HOMEPAGE SECTIONS — ОБЩИЕ
   ============================================================ */

@media (max-width: 767.98px) {
  .section-padding,
  section[id$="-section"] {
    padding-top: 2rem;
    padding-bottom: 2rem;
    padding-left: 0.75rem;
    padding-right: 0.75rem;
  }

  .section-title {
    font-size: 0.7rem;
  }

  .section-title::before,
  .section-title::after {
    width: 14px;
  }

  #events-section,
  #about-section,
  #partners-section,
  #iesa-offers {
    padding-left: 0.75rem;
    padding-right: 0.75rem;
  }
}


/* ============================================================
   7. ГРИДЫ И КАРТОЧКИ
   ============================================================ */

@media (max-width: 767.98px) {
  /* Принудительно в 1 колонку */
  .grid-cols-2,
  .grid-cols-3,
  .grid-cols-4,
  .grid {
    grid-template-columns: 1fr;
    gap: 1rem;
  }

  /* Карточки */
  .card {
    border-radius: 14px;
  }

  .card-body {
    padding: 1rem;
  }

  /* Partner card compact — вертикальный layout */
  .partner-card-compact .d-flex.align-items-start.gap-3 {
    flex-direction: column;
    align-items: stretch;
  }

  .partner-logo-compact {
    margin: 0 auto;
  }

  .partner-card-compact .d-flex.gap-2,
  .partner-card-compact .btn-group {
    flex-direction: column;
    gap: 0.5rem;
  }

  .partner-card-compact .d-flex.gap-2 .btn {
    width: 100%;
  }

  /* Benefit cards */
  .benefit-card {
    border-radius: 16px;
    padding: 1.25rem;
  }

  .benefit-card:hover,
  .benefit-card:hover .benefit-icon-box {
    transform: none;
  }

  /* Product cards */
  .product-card {
    border-radius: 14px;
    margin-bottom: 0.75rem;
  }

  .product-card-title {
    font-size: 1rem;
  }

  /* Event cards */
  .event-card {
    margin-bottom: 0.75rem;
  }

  .event-card:hover {
    transform: none;
  }

  /* Member cards */
  .member-card:hover {
    transform: none;
  }

  .member-avatar {
    width: 80px;
    height: 80px;
  }

  /* iesa offers grid */
  .iesa-offers-grid {
    grid-template-columns: 1fr;
    gap: 1rem;
  }

  .offer-card {
    padding: 1.25rem;
  }

  .offer-icon {
    width: 48px;
    height: 48px;
  }

  /* Offers actions */
  .offers-actions {
    flex-direction: column;
    align-items: stretch;
    gap: 0.5rem;
  }

  .offers-actions .btn,
  .offers-cta-actions .btn {
    width: 100%;
    justify-content: center;
  }

  .offers-cta-actions {
    flex-direction: column;
    width: 100%;
    gap: 0.5rem;
  }

  .offers-cta-title {
    font-size: 1.3rem;
  }

  /* Min-width overrides */
  .min-w-280, .min-w-340 {
    min-width: 0;
  }
}

@media (min-width: 576px) and (max-width: 767.98px) {
  /* Планшет-горизонталь: 2 колонки */
  .grid-cols-3,
  .benefit-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .iesa-offers-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}


/* ============================================================
   8. SHOWCASE СЕКЦИИ
   ============================================================ */

@media (max-width: 767.98px) {
  .hero-showcase,
  .mission-showcase,
  .about-showcase {
    border-radius: 16px;
  }

  .mission-showcase .mission-panel,
  .events-showcase .showcase-card,
  .about-showcase .member-showcase-card,
  .partners-showcase .partner-showcase-card {
    border-radius: 12px;
  }

  .president-card {
    padding: 1.5rem 1rem;
  }

  .president-card .president-avatar {
    width: 100px;
    height: 100px;
  }

  .president-photo {
    width: 120px;
    height: 120px;
  }

  .team-members-grid {
    grid-template-columns: 1fr;
    gap: 1rem;
  }
}


/* ============================================================
   9. ФОРМЫ
   ============================================================ */

@media (max-width: 767.98px) {
  .form-control,
  .form-select,
  input[type="text"],
  input[type="email"],
  input[type="password"],
  input[type="search"],
  input[type="tel"],
  input[type="number"],
  input[type="url"],
  textarea,
  select {
    font-size: 16px !important; /* Предотвращает zoom на iOS */
    min-height: 44px;
    border-radius: 10px;
  }

  textarea {
    min-height: 80px;
  }

  .form-label {
    font-size: 0.875rem;
    font-weight: 600;
  }

  /* Поиск */
  .search-form,
  .filter-form {
    flex-direction: column;
    gap: 0.5rem;
  }

  .search-form .btn,
  .filter-form .btn {
    width: 100%;
  }

  /* Profile edit form */
  .edit-actions {
    flex-direction: column;
    gap: 0.5rem;
  }

  .edit-actions .btn {
    width: 100%;
    text-align: center;
  }

  .profile-edit-card {
    padding: 1.25rem;
  }

  .edit-card-header {
    flex-wrap: wrap;
    gap: 0.75rem;
  }
}


/* ============================================================
   10. ТАБЛИЦЫ (PARTNER DASHBOARD)
   ============================================================ */

@media (max-width: 767.98px) {
  .table-responsive {
    border-radius: 12px;
    overflow: hidden;
    -webkit-overflow-scrolling: touch;
  }

  /* Card-style таблица для мобильных */
  .table-mobile-cards thead {
    display: none;
  }

  .table-mobile-cards tbody tr {
    display: block;
    border: 1px solid var(--border-dark);
    border-radius: 12px;
    margin-bottom: 0.75rem;
    padding: 0.75rem;
    background: var(--bg-surface);
    box-shadow: 0 2px 8px rgba(0,0,0,0.25);
  }

  .table-mobile-cards tbody td {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.35rem 0.5rem;
    border: none;
    border-bottom: 1px solid rgba(0,0,0,0.05);
    font-size: 0.875rem;
  }

  .table-mobile-cards tbody td:last-child {
    border-bottom: none;
  }

  .table-mobile-cards tbody td::before {
    content: attr(data-label);
    font-weight: 700;
    font-size: 0.75rem;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    flex-shrink: 0;
    margin-right: 0.5rem;
  }

  /* Dashboard stat cards */
  .dashboard-stats .row {
    gap: 0;
  }

  .dashboard-stat-card {
    border-radius: 12px;
    padding: 1rem;
  }

  /* Search + filter row на дашборде */
  .partner-search-row {
    flex-direction: column;
    gap: 0.75rem;
  }

  .partner-search-row .col-lg-5,
  .partner-search-row .col-lg-7 {
    width: 100%;
  }
}


/* ============================================================
   11. ПРОФИЛЬ ПОЛЬЗОВАТЕЛЯ
   ============================================================ */

@media (max-width: 767.98px) {
  .profile-page {
    padding-top: 0.75rem;
    padding-bottom: 0.75rem;
  }

  .profile-header {
    padding: 1.25rem;
    border-radius: 16px;
    text-align: center;
  }

  .profile-avatar,
  .profile-avatar-fallback {
    width: 90px;
    height: 90px;
    font-size: 2.25rem;
    border-width: 3px;
    margin: 0 auto;
  }

  .profile-name {
    font-size: 1.25rem;
  }

  .profile-email {
    font-size: 0.875rem;
  }

  .profile-id-badge {
    display: block;
    width: 100%;
    word-break: break-all;
    text-align: center;
    font-size: 0.875rem;
  }

  .profile-links-card,
  .profile-activity-card,
  .profile-posts-card,
  .profile-qr-card {
    padding: 1rem;
    border-radius: 14px;
  }

  .link-chip-group {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.5rem;
  }

  .link-chip {
    justify-content: center;
  }

  .profile-activity-points,
  .profile-stat-value {
    font-size: 1.75rem;
  }

  .profile-qr-card img {
    width: 150px;
    height: 150px;
  }

  .profile-stat-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  /* Инфо-грид: 1 колонка на маленьком */
  .profile-info-grid {
    grid-template-columns: 1fr;
  }

  .profile-user-stats {
    flex-wrap: wrap;
    gap: 0.5rem;
  }

  .stat-item {
    min-width: 60px;
  }
}

@media (max-width: 575.98px) {
  .profile-stat-grid {
    grid-template-columns: 1fr;
  }
}


/* ============================================================
   12. MEMBER CABINET (DARK GLASS)
   ============================================================ */

@media (max-width: 767.98px) {
  /* Hero band */
  .cabinet-hero,
  [class*="cabinet"] .hero-band {
    padding: 1.25rem 1rem;
    border-radius: 16px;
  }

  /* PIN block */
  .pin-display,
  .pin-digits,
  [class*="pin-code"],
  [class*="pin-value"] {
    font-size: clamp(2rem, 10vw, 3rem);
    letter-spacing: 0.15em;
  }

  /* Step grid */
  .step-grid,
  [class*="steps-grid"] {
    grid-template-columns: 1fr;
    gap: 0.75rem;
  }

  /* Telegram CTA */
  .tg-cta-block,
  [class*="telegram-cta"] {
    padding: 1.25rem;
    border-radius: 16px;
  }

  /* Cards в кабинете */
  [class*="cabinet"] .card,
  [class*="cabinet"] .glass-card {
    border-radius: 14px;
    padding: 1rem;
  }
}


/* ============================================================
   13. АУТЕНТИФИКАЦИЯ (login, register)
   ============================================================ */

@media (max-width: 767.98px) {
  /* Auth card — убираем двухколоночный layout */
  .auth-card-new {
    flex-direction: column;
    border-radius: 16px;
    margin: 0.5rem;
    max-height: none;
    overflow: visible;
  }

  .auth-card-new .row.g-0 {
    flex-direction: column;
  }

  .auth-dark-side {
    display: none !important; /* Скрываем декоративную панель */
  }

  .auth-light-side {
    width: 100%;
    padding: 1.5rem;
    border-radius: 16px;
  }

  .auth-container {
    margin: 0.75rem;
    padding: 0;
  }

  /* OTP boxes (connect telegram) */
  .otp-input {
    width: 40px;
    height: 48px;
    font-size: 1.25rem;
  }

  .otp-box-row {
    gap: 0.4rem;
  }
}

@media (max-width: 575.98px) {
  .auth-light-side {
    padding: 1.25rem;
  }
}


/* ============================================================
   14. ГАЛЕРЕЯ
   ============================================================ */

@media (max-width: 575.98px) {
  .gallery-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.5rem;
  }
}

@media (min-width: 576px) and (max-width: 767.98px) {
  .gallery-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 0.75rem;
  }
}

@media (min-width: 768px) and (max-width: 991.98px) {
  .gallery-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (min-width: 992px) {
  .gallery-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}


/* ============================================================
   15. БЛОГ / ИВЕНТЫ
   ============================================================ */

@media (max-width: 767.98px) {
  /* Post list */
  .post-card {
    border-radius: 14px;
  }

  /* Post detail */
  .post-detail-content {
    font-size: 1rem;
    line-height: 1.7;
  }

  .post-detail-content img {
    border-radius: 10px;
    margin: 0.5rem 0;
  }

  /* Event cards */
  .event-date-chip-compact {
    width: 54px;
    padding: 0.35rem;
  }

  .event-date-day {
    font-size: 1.15rem;
  }

  /* Event filters */
  #event-filters {
    flex-direction: column;
    gap: 0.5rem;
  }

  #event-filters .form-select {
    width: 100%;
  }

  /* Post create form */
  .post-create-form .card {
    border-radius: 14px;
  }
}


/* ============================================================
   16. МОДАЛЬНЫЕ ОКНА
   ============================================================ */

@media (max-width: 575.98px) {
  .modal-dialog {
    margin: 0.5rem;
    max-width: calc(100vw - 1rem);
  }

  .modal-content {
    border-radius: 16px;
  }

  .modal-body {
    padding: 1.25rem;
  }

  .modal-footer {
    flex-direction: column;
    gap: 0.5rem;
  }

  .modal-footer .btn {
    width: 100%;
  }
}


/* ============================================================
   17. ФУТЕР
   ============================================================ */

@media (max-width: 767.98px) {
  .footer-enhanced {
    text-align: center;
  }

  .footer-enhanced .col-6 {
    text-align: center;
  }

  .footer-links {
    text-align: center;
  }

  .footer-social {
    width: 44px;
    height: 44px;
    margin: 0 auto;
  }

  .footer-about-text {
    max-width: 100%;
    font-size: 0.9rem;
  }
}


/* ============================================================
   18. УТИЛИТЫ
   ============================================================ */

@media (max-width: 767.98px) {
  /* Скрытие */
  .hide-mobile { display: none !important; }
  .auth-card-left { display: none !important; }

  /* Показ только на мобильных */
  .show-mobile { display: block !important; }
  .show-mobile-flex { display: flex !important; }

  /* Центровка контента */
  .mobile-center { text-align: center !important; }
  .mobile-center-col { align-items: center !important; flex-direction: column !important; }

  /* Уменьшение паддингов */
  .mobile-p0 { padding: 0 !important; }
  .mobile-px-0 { padding-left: 0 !important; padding-right: 0 !important; }

  /* Back to top */
  #back-to-top {
    bottom: calc(80px + env(safe-area-inset-bottom));
    right: 1rem;
    width: 40px;
    height: 40px;
    font-size: 0.875rem;
  }

  /* Dropdown меню */
  .dropdown-menu {
    max-width: calc(100vw - 1rem);
  }

  /* Skeleton size */
  .skeleton {
    height: 160px !important;
  }
}

@media (min-width: 768px) {
  /* Скрыто на десктопе */
  .show-mobile { display: none !important; }
  .show-mobile-flex { display: none !important; }
}


/* ============================================================
   19. SAFE-AREA INSETS (iOS нотч, dynamic island, home bar)
   ============================================================ */

header {
  padding-top: env(safe-area-inset-top, 0px);
}

.modal-dialog {
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

/* Фиксированные элементы */
.sticky-bottom-fix {
  padding-bottom: env(safe-area-inset-bottom, 0px);
}


/* ============================================================
   20. TABLET (768px – 991px) СПЕЦИФИКА
   ============================================================ */

@media (min-width: 768px) and (max-width: 991.98px) {
  .profile-detail-card {
    padding: 1.25rem;
  }

  .grid-cols-3,
  .benefit-grid {
    grid-template-columns: repeat(2, 1fr) !important;
  }

  .gallery-grid {
    grid-template-columns: repeat(3, 1fr);
  }

  /* Профиль-грид на планшете */
  .profile-stat-grid {
    grid-template-columns: repeat(3, 1fr) !important;
  }
}


/* ============================================================
   21. DESKTOP — HOVER EFFECTS (только pointer: fine)
   ============================================================ */

@media (min-width: 992px) {
  /* Hover effects only on desktop — all use --card-hover-lift token (U4-17) */
  .card:hover {
    transform: translateY(var(--card-hover-lift));
    transition: transform var(--transition-smooth), box-shadow var(--transition-smooth);
  }

  .btn:hover {
    transform: translateY(-1px);
  }

  .profile-detail-card:hover,
  .profile-stat-card:hover {
    transform: translateY(var(--card-hover-lift));
  }

  /* Show on desktop */
  .show-desktop { display: block !important; }
}

/* Отключаем hover для touch-устройств */
@media (hover: none), (pointer: coarse) {
  .hero-badge:hover,
  .benefit-card:hover,
  .benefit-card:hover .benefit-icon-box,
  .product-card:hover,
  .product-card:hover .product-card-image,
  .event-card:hover,
  .member-card:hover,
  .partner-card-compact:hover,
  .pagination-btn:hover,
  .card:hover,
  .btn:hover,
  .profile-detail-card:hover,
  .profile-stat-card:hover {
    transform: none !important;
    box-shadow: inherit !important;
  }

  .benefit-card:hover::before,
  .product-card:hover::before {
    left: -100% !important;
    width: 0 !important;
  }
}


/* ============================================================
   22. ВЫСОТА VIEWPORT (исправление iOS 100vh)
   ============================================================ */

/* Используем динамический viewport на мобильных */
@supports (height: 100dvh) {
  .min-vh-100 {
    min-height: 100dvh !important;
  }
  .vh-100 {
    height: 100dvh !important;
  }
}


/* ============================================================
   23. PRINT
   ============================================================ */

@media print {
  header, footer, .navbar, .btn, .modal, #back-to-top,
  .mobile-bottom-nav, .no-print, .dev-banner {
    display: none !important;
  }

  body {
    background: white !important;
    color: black !important;
  }

  .card {
    border: 1px solid #ddd !important;
    box-shadow: none !important;
  }

  a {
    color: black !important;
    text-decoration: underline !important;
  }

  .page-break-before { page-break-before: always; }
  .page-break-after { page-break-after: always; }
  .avoid-break { page-break-inside: avoid; }
}


/* ============================================================
   24. REDUCED MOTION + HIGH CONTRAST
   ============================================================ */

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }

  .animate-fade-in,
  .animate-fade-in-up,
  .animate-scale-in,
  .animate-slide-in-right,
  .animate-pulse,
  .animate-spin,
  [data-reveal],
  .fade-up,
  .fade-in-up {
    animation: none !important;
    opacity: 1 !important;
    transform: none !important;
    transition: none !important;
  }
}

@media (prefers-contrast: high) {
  :root {
    --border-color: var(--gray-400);
    --text-muted: var(--gray-700);
  }

  .btn {
    border-width: 2px;
  }

  .card {
    border-width: 2px;
  }
}


/* ============================================================
   25. АНИМАЦИОННЫЕ КЛАССЫ
   ============================================================ */

@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(24px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@keyframes scaleIn {
  from { opacity: 0; transform: scale(0.9); }
  to   { opacity: 1; transform: scale(1); }
}

@keyframes slideInRight {
  from { opacity: 0; transform: translateX(16px); }
  to   { opacity: 1; transform: translateX(0); }
}

@keyframes slideInUp {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.55; }
}

@keyframes spin {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}

@keyframes skeleton-loading {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.animate-fade-in      { animation: fadeIn 0.3s ease-out; }
.animate-fade-in-up   { animation: fadeInUp 0.4s ease-out; }
.animate-scale-in     { animation: scaleIn 0.3s ease-out; }
.animate-slide-in-right { animation: slideInRight 0.3s ease-out; }
.animate-pulse        { animation: pulse 2s infinite; }
.animate-spin         { animation: spin 1s linear infinite; }

.fade-in-up { animation: fadeInUp 0.6s ease-out forwards; }


/* ============================================================
   26. HTMX / LOADING
   ============================================================ */

.htmx-indicator {
  display: none;
}
.htmx-request .htmx-indicator,
.htmx-request.htmx-indicator {
  display: inline-block;
}

.skeleton {
  background: linear-gradient(
    90deg,
    rgba(255,255,255,.06) 25%,
    rgba(255,255,255,.1) 50%,
    rgba(255,255,255,.06) 75%
  );
  background-size: 200% 100%;
  animation: skeleton-loading 1.5s infinite;
  border-radius: 8px;
}

/* ═══════════════════════════════════════════════════════════════
   КОМПЛЕКСНЫЙ МОБИЛЬНЫЙ ФИКС (добавлено после аудита скриншота)
   ═══════════════════════════════════════════════════════════════ */

/* ── Предотвращаем горизонтальный скролл ── */
html { overflow-x: hidden !important; }
body { overflow-x: hidden !important; max-width: 100vw; }

/* ── iOS: предотвращаем zoom на input (font-size >= 16px) ── */
@media (max-width: 767.98px) {
  input, select, textarea {
    font-size: 16px !important;
  }
  /* Но оставляем мелкий для placeholder */
  input::placeholder, textarea::placeholder {
    font-size: 14px !important;
  }
}

/* ── Touch targets: минимум 44×44px ── */
@media (hover: none) and (pointer: coarse) {
  .btn-nav-icon, .nav-mob-btn, .iesa-toggler,
  .mbn-item, .mbn-center-btn {
    min-width: 44px !important;
    min-height: 44px !important;
  }
}

/* ── Profile dropdown: не вылезает за экран ── */
@media (max-width: 575.98px) {
  .prof-nav-drop-menu {
    min-width: min(320px, calc(100vw - 1rem)) !important;
    max-width: calc(100vw - 1rem) !important;
    right: 0 !important;
    left: auto !important;
  }
  .notifications-dropdown {
    min-width: min(340px, calc(100vw - 1rem)) !important;
    max-width: calc(100vw - 1rem) !important;
    right: 0 !important; left: auto !important;
  }
  .navbar-search-dropdown {
    min-width: min(320px, calc(100vw - 1rem)) !important;
    right: 0 !important; left: auto !important;
  }
}

/* ── Таблицы в партнёрском портале ── */
@media (max-width: 767.98px) {
  .dash-table { font-size: .76rem; }
  .dash-table th, .dash-table td { padding: .45rem .55rem; }
  /* Горизонтальный скролл для таблиц */
  .pp-table-wrap, .dash-card__body [style*="overflow-x:auto"],
  div[style*="overflow-x:auto"] { -webkit-overflow-scrolling: touch; }
  /* Скрываем колонки которые не влезают */
  .dash-table .col-hide-xs { display: none; }
}

/* ── Партнёрский дашборд: адаптация колонок ── */
@media (max-width: 767.98px) {
  /* Sidebar + content → только content */
  .dash-root { grid-template-columns: 1fr !important; }
  .dash-sidebar { display: none !important; }
  .dash-main { padding: .75rem !important; }
  /* Статы в 2 колонки */
  .dash-stat-grid { grid-template-columns: 1fr 1fr !important; }
  /* Две карточки рядом → одна */
  div[style*="grid-template-columns:1fr 1fr"] {
    grid-template-columns: 1fr !important;
  }
}

/* ── Карточки партнёрской аналитики ── */
@media (max-width: 767.98px) {
  .pp-stats { grid-template-columns: repeat(2, 1fr) !important; }
  .pp-charts { grid-template-columns: 1fr !important; }
  .pp-hero { padding: 24px 16px 20px !important; }
  .pp-section { padding: 20px 16px 0 !important; }
}

/* ── Профиль: hero section ── */
@media (max-width: 575.98px) {
  .cab-hero { padding: 1.25rem 1rem 1rem !important; }
  .cab-avatar { width: 72px !important; height: 72px !important; }
  .cab-username { font-size: 1.1rem !important; }
  .hero-actions { flex-wrap: wrap; gap: .5rem !important; }
  .btn-cab-primary, .btn-cab-outline {
    font-size: .8rem !important;
    padding: .45rem .9rem !important;
  }
}

/* ── Формы: кнопки на всю ширину на маленьких экранах ── */
@media (max-width: 575.98px) {
  .auth-btn { width: 100% !important; }
  .hero-btn-p, .hero-btn-g { width: 100% !important; justify-content: center !important; }
}

/* ── Hero section главной страницы ── */
@media (max-width: 575.98px) {
  .hero-title { font-size: clamp(1.8rem, 7vw, 2.5rem) !important; }
  .hero-subtitle { font-size: .88rem !important; }
  /* Контейнер не должен иметь горизонтальный overflow */
  .container-limited { padding-left: 1rem !important; padding-right: 1rem !important; }
}

/* ── Blog: карточки постов ── */
@media (max-width: 575.98px) {
  .iesa-article { border-radius: 14px; }
  .art-body { padding: 1rem !important; }
  /* Carousel похожих постов: ширина карточки */
  .pd-rec-card { flex: 0 0 240px !important; }
}

/* ── Уведомления: более компактные ── */
@media (max-width: 575.98px) {
  .notification-item { padding: .75rem .85rem !important; }
  .notification-title { font-size: .82rem !important; }
  .notification-message { font-size: .8rem !important; }
}

/* ── Календарь: двухколоночный layout → одноколоночный ── */
@media (max-width: 1024px) {
  .cal-layout { grid-template-columns: 1fr !important; }
}
@media (max-width: 767.98px) {
  .cal-hour-grid-inner { min-height: 300px; }
}

/* ── Bottom sheet: полная ширина ── */
@media (max-width: 575.98px) {
  .iesa-bottom-sheet { border-radius: 16px 16px 0 0; }
}

/* ── FAB: выше bottom nav на мобиле ── */
@media (max-width: 767.98px) {
  .dash-fab-wrap {
    bottom: calc(80px + env(safe-area-inset-bottom, 0px)) !important;
  }
}

/* ── Dashboard: мобильное меню (sidebar nav замена) ── */
@media (max-width: 767.98px) {
  /* Вверху страницы добавляем горизонтальный scroll-nav */
  .dash-mobile-nav-hint {
    display: block;
    padding: .5rem .75rem;
    background: rgba(255,255,255,.04);
    border-bottom: 1px solid rgba(255,255,255,.06);
    font-size: .75rem; color: rgba(255,255,255,.4);
    text-align: center;
  }
}

/* ── Изображения не вылезают ── */
img, video, iframe { max-width: 100%; }
.gallery-card img { width: 100%; height: 100%; }

/* ── iOS Safari: safe area padding ── */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
  .mobile-bottom-nav {
    padding-bottom: calc(6px + env(safe-area-inset-bottom)) !important;
  }
  main#main-content {
    padding-bottom: calc(72px + env(safe-area-inset-bottom)) !important;
  }
}

/* ── Hover эффекты ТОЛЬКО на устройствах с мышью ── */
@media (hover: none) {
  /* Убираем hover-трансформации на тач */
  .gallery-card:hover { transform: none !important; }
  .iesa-article:hover { transform: none !important; }
  .card:hover { transform: none !important; }
  /* Убираем магнитные кнопки */
  .hero-btn-p, .hero-btn-g { transition: opacity .2s !important; }
}

/* ── Иконки без hover-overlay на touch ── */
@media (hover: none) and (pointer: coarse) {
  .btn-nav-icon:hover { background: transparent !important; }
  a:hover, button:hover { opacity: 1 !important; }
}

