/**
 * Responsive Fixes - Кроссбраузерная адаптивность
 * Для всех браузеров и мобильных устройств
 */

/* ===== Базовые настройки ===== */
*, *::before, *::after {
  box-sizing: border-box;
  -webkit-box-sizing: border-box;
  -moz-box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  -ms-text-size-adjust: 100%;
  text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

body {
  min-height: 100vh;
  min-height: -webkit-fill-available;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

/* ===== Фиксы для мобильных Safari/Chrome ===== */
@supports (-webkit-touch-callout: none) {
  .min-h-screen {
    min-height: -webkit-fill-available;
  }
}

/* ===== Адаптивные изображения ===== */
img, video, svg {
  max-width: 100%;
  height: auto;
  display: block;
}

/* ===== Формы - фикс для iOS ===== */
input, textarea, select, button {
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  font-family: inherit;
  font-size: 16px; /* Предотвращает зум на iOS */
}

input:focus, textarea:focus, select:focus {
  outline: none;
}

/* ===== Кнопки - фикс для Safari ===== */
button {
  cursor: pointer;
  border: none;
  background: transparent;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.6;
}

/* ===== Ссылки - фикс для тач-устройств ===== */
a {
  text-decoration: none;
  color: inherit;
  -webkit-tap-highlight-color: rgba(0,0,0,0);
}

/* ===== Таблицы - горизонтальный скролл на мобильных ===== */
.table-responsive {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.table-responsive table {
  min-width: 640px;
}

/* ===== Мобильное меню ===== */
@media (max-width: 1024px) {
  .sidebar-desktop {
    display: none !important;
  }
  
  .mobile-menu-open {
    overflow: hidden;
  }
  
  .mobile-menu-open body {
    position: fixed;
    width: 100%;
    height: 100%;
  }
}

/* ===== Фикс для маленьких экранов ===== */
@media (max-width: 640px) {
  /* Текст */
  h1 { font-size: 1.5rem !important; }
  h2 { font-size: 1.25rem !important; }
  h3 { font-size: 1.125rem !important; }
  
  /* Отступы */
  .container {
    padding-left: 1rem !important;
    padding-right: 1rem !important;
  }
  
  /* Кнопки */
  .btn-mobile-full {
    width: 100%;
    justify-content: center;
  }
  
  /* Формы */
  .form-grid-mobile {
    grid-template-columns: 1fr !important;
  }
}

/* ===== Safari Flexbox ===== */
@supports (-webkit-overflow-scrolling: touch) {
  .flex-1 {
    -webkit-box-flex: 1;
    -webkit-flex: 1;
    -ms-flex: 1;
    flex: 1;
  }
}

/* ===== Анимации - отключить для prefers-reduced-motion ===== */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ===== Notch/Dynamic Island ===== */
@supports (padding-top: env(safe-area-inset-top)) {
  .safe-area-top {
    padding-top: env(safe-area-inset-top);
  }
  
  .safe-area-bottom {
    padding-bottom: env(safe-area-inset-bottom);
  }
}

/* ===== Chrome autofill ===== */
input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus,
textarea:-webkit-autofill,
textarea:-webkit-autofill:hover,
textarea:-webkit-autofill:focus,
select:-webkit-autofill,
select:-webkit-autofill:hover,
select:-webkit-autofill:focus {
  -webkit-text-fill-color: white;
  -webkit-box-shadow: 0 0 0px 1000px #1e293b inset;
  transition: background-color 5000s ease-in-out 0s;
}

/* ===== Aspect ratio fallback ===== */
@supports not (aspect-ratio: 16/9) {
  .aspect-video {
    position: relative;
    padding-bottom: 56.25%;
  }
  
  .aspect-video > * {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
  }
}
