/* Базовые критические стили для всего приложения */

/* Критические стили для первоначальной загрузки */
html {
  font-size: 14px;
  height: 100%;
  position: relative;
  min-height: 100%;
}

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  margin-bottom: 60px;
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  background-color: #f8f9fa;
  /* Оптимизация рендеринга */
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

@media (min-width: 768px) {
  html {
    font-size: 16px;
  }
}

/* Оптимизированные фокусы */
.btn:focus, .btn:active:focus, .btn-link.nav-link:focus, .form-control:focus, .form-check-input:focus {
  box-shadow: 0 0 0 0.1rem white, 0 0 0 0.25rem #258cfb;
  outline: none;
}

/* Типография */
h1, h2, h3, h4, h5, h6 {
  font-weight: 600;
  margin-bottom: 1rem;
  line-height: 1.3;
}

h1 {
  font-size: 2.5rem;
  font-weight: 700;
}

h2 {
  font-size: 2rem;
}

h3 {
  font-size: 1.75rem;
}

p {
  margin-bottom: 1.2rem;
}

/* Навигация */
.navbar-brand {
  font-weight: 700;
  font-size: 1.5rem;
}

.navbar-nav .nav-link {
  font-weight: 500;
  transition: color 0.3s ease;
  display: flex;
  align-items: center;
}

.navbar-nav .nav-link i {
  margin-right: 0.5rem;
  font-size: 1rem;
  vertical-align: middle;
}

.navbar-nav .nav-link:hover {
  color: rgba(255, 255, 255, 0.8) !important;
}

/* Кнопки */
.btn {
  border-radius: 10px;
  font-weight: 500;
  padding: 0.5rem 1.25rem;
  transition: all 0.3s cubic-bezier(0.165, 0.84, 0.44, 1);
  letter-spacing: 0.02em;
  text-transform: none;
}

.btn-primary {
  background: linear-gradient(135deg, #007bff 0%, #0056b3 100%);
  border: none;
  box-shadow: 0 4px 10px rgba(0, 123, 255, 0.25);
}

.btn-primary:hover {
  background: linear-gradient(135deg, #0056b3 0%, #004085 100%);
  box-shadow: 0 6px 15px rgba(0, 123, 255, 0.35);
}

.btn-success {
  background: linear-gradient(135deg, #28a745 0%, #1e7e34 100%);
  border: none;
  box-shadow: 0 4px 10px rgba(40, 167, 69, 0.25);

}

.btn-success:hover {
  background: linear-gradient(135deg, #1e7e34 0%, #155724 100%);
  box-shadow: 0 6px 15px rgba(40, 167, 69, 0.35);
}

/* Бейджи */
.badge {
  font-weight: 500;
  border-radius: 6px;
}

/* Формы */
.form-control, .form-select {
  border-radius: 8px;
  border: 1px solid #dee2e6;
  transition: all 0.3s ease;
}

.form-control:focus, .form-select:focus {
  border-color: #007bff;
  box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25);
}

/* Модальные окна */
.modal-content {
  border-radius: 16px;
  border: none;
  box-shadow: 0 15px 35px rgba(0, 0, 0, 0.2);
  overflow: hidden;
}

.modal-header {
  border-bottom: 1px solid #e9ecef;
  padding: 1.25rem 1.5rem;
}

.modal-body {
  padding: 1.5rem;
}

.modal-footer {
  border-top: 1px solid #e9ecef;
  padding: 1.25rem 1.5rem;
}

/* Пагинация */
.pagination .page-link {
  border-radius: 8px;
  margin: 0 2px;
  border: 1px solid #dee2e6;
  color: #007bff;
  transition: all 0.3s ease;
}

.pagination .page-link:hover {
  background-color: #e9ecef;
  border-color: #adb5bd;
}

.pagination .page-item.active .page-link {
  background: linear-gradient(135deg, #007bff 0%, #0056b3 100%);
  border-color: #007bff;
}

/* Алерты */
.alert {
  border-radius: 8px;
  border: none;
}

.alert-info {
  background: linear-gradient(135deg, #d1ecf1 0%, #bee5eb 100%);
  color: #0c5460;
}

/* Анимации */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

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

/* Адаптивность */
@media (max-width: 768px) {
  .hero-section {
    padding: 3rem 0;
  }

  .hero-section .display-4 {
    font-size: 2rem;
  }

  .app-card:hover,
  .user-card:hover,
  .category-card:hover {
    transform: none;
  }
}

/* Предотвращение layout shift */
.card-img-top-wrapper {
  position: relative;
  overflow: hidden;
}

/* Мобильные улучшения */
@media (max-width: 576px) {
  .hero-section h1 {
    font-size: 2rem !important;
  }

  .hero-section .lead {
    font-size: 1rem !important;
  }

  .app-card .card-title {
    font-size: 0.9rem;
  }

  .app-card .card-text {
    font-size: 0.8rem;
    -webkit-line-clamp: 2;
    line-clamp: 2;
  }

  .app-card .card-body {
    padding: 0.75rem;
  }

  .rating small {
    font-size: 0.7rem;
  }

  .stat-card {
    padding: 1rem !important;
  }

  .stat-card h3 {
    font-size: 1.25rem !important;
  }
}

/* Улучшения для тач-устройств */
@media (hover: none) and (pointer: coarse) {
  .btn,
  .nav-link,
  .dropdown-item {
    min-height: 44px;
    display: flex;
    align-items: center;
  }

  .app-card:hover,
  .category-card:hover,
  .user-card:hover {
    transform: none;
  }

  * {
    -webkit-overflow-scrolling: touch;
  }
}

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

/* Дополнительные утилиты */
.text-shadow {
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

.box-shadow-sm {
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.box-shadow {
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

.box-shadow-lg {
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.15);
}

.border-radius-lg {
  border-radius: 12px;
}

.border-radius-xl {
  border-radius: 16px;
}

/* Загрузка изображений */
.img-loading {
  background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
  background-size: 200% 100%;
  animation: loading 1.5s infinite;
}

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

/* Скроллбар */
::-webkit-scrollbar {
  width: 8px;
}

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

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

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

/* Адаптивность */
@media (max-width: 768px) {
  .hero-section {
    padding: 3rem 0;
  }

  .hero-section .display-4 {
    font-size: 2rem;
  }

  .app-card:hover,
  .user-card:hover,
  .category-card:hover {
    transform: none;
  }
}

/* Темная тема (опционально) */
@media (prefers-color-scheme: dark) {
  body {
    background-color: #1a1a1a;
    color: #e9ecef;
  }
}

/* Продолжение темной темы */
@media (prefers-color-scheme: dark) {
  .card {
    background-color: #2d3748;
    border-color: #4a5568;
  }
}

/* Drag and Drop стили для скриншотов */
.screenshot-item,
.screenshot-new-item {
  transition: all 0.3s ease;
  cursor: move;
}

.screenshot-item.drag-over,
.screenshot-new-item.drag-over {
  border: 2px dashed #007bff;
  background-color: rgba(0, 123, 255, 0.1);
  border-radius: 8px;
}

.screenshot-item img,
.screenshot-new-item img {
  user-select: none;
  -webkit-user-drag: none;
}

.screenshot-item[draggable="true"]:active,
.screenshot-new-item[draggable="true"]:active {
  cursor: grabbing;
}

/* Визуальная индикация при перетаскивании */
.screenshot-item.dragging,
.screenshot-new-item.dragging {
  opacity: 0.5;

}

/* Маленькая кнопка удаления */
.btn-xs {
  font-size: 0.7rem !important;
  padding: 0.2rem 0.4rem !important;
  line-height: 1.2;
}

.btn-xs i {
  font-size: 0.65rem;
}

/* Номера скриншотов */
.screenshot-number {
  font-weight: bold;
  font-size: 0.875rem;
}

/* Плавная анимация при изменении порядка */
.screenshot-item,
.screenshot-new-item {
  animation: slideIn 0.3s ease;
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateX(-10px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

/* Дополнительные утилиты */
.text-shadow {
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

.box-shadow-sm {
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.box-shadow {
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

.box-shadow-lg {
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.15);
}

.border-radius-lg {
  border-radius: 12px;
}

.border-radius-xl {
  border-radius: 16px;
}

/* Оптимизация загрузки изображений */
img {
  /* Ленивая загрузка изображений */
  loading: lazy;
  /* Оптимизация декодирования */
  decoding: async;
}

/* Плейсхолдер для изображений во время загрузки */
.img-placeholder {
  background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
  background-size: 200% 100%;
  animation: loading 1.5s infinite;
}

/* Оптимизация для критических изображений */
.critical-img {
  loading: eager;
}

/* Прелоадер для страниц */
.page-loader {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(255, 255, 255, 0.9);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 9999;
  opacity: 1;
  transition: opacity 0.3s ease;
}

.page-loader.hidden {
  opacity: 0;
  pointer-events: none;
}

.loader-spinner {
  width: 40px;
  height: 40px;
  border: 4px solid #f3f3f3;
  border-top: 4px solid #007bff;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* Оптимизация для мобильных устройств */
@media (max-width: 768px) {
  .app-card:hover,
  .user-card:hover,
  .category-card:hover {
    transform: none;
  }

  /* Отключаем анимации на мобильных для экономии батареи */
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* Prefetch для критических ресурсов */
.prefetch-hint {
  display: none;
}

/* Оптимизации производительности - ленивая загрузка */
.lazy-load {
  opacity: 0;
  transition: opacity 0.3s ease-in-out;
}

.lazy-load.loaded {
  opacity: 1;
}

/* Оптимизация анимаций */
.app-card {
  transition: transform 0.2s ease-in-out;
  will-change: transform;
}

.app-card:hover {
  /* Убираем эффект подпрыгивания */
}

/* Предотвращение layout shift */
.card-img-top-wrapper {
  position: relative;
  overflow: hidden;
}

/* Оптимизация для мобильных устройств */
@media (max-width: 768px) {
  .app-card:hover {
    transform: none;
  }
}