html, body { min-height: 100%; }

html { background: #0b1220; }
body { background: transparent; }
body::before {
  content: "";
  position: fixed;
  left: 0; top: 0; right: 0; bottom: 0;
  background: url('/rustgif.gif') no-repeat center center, #0b1220;
  background-size: cover;
  z-index: -1;
  pointer-events: none;
}

main.container {
  max-width: 1200px;
}

.glass {
  background: rgba(17, 24, 39, 0.50);
  border: 1px solid rgba(255, 255, 255, 0.10);
}

/* Повышаем читаемость текста внутри стеклянных блоков */
.glass, .glass * { color-scheme: dark; }
.glass .text-gray-300 { color: #e5e7eb; }
.glass .text-gray-300\/70 { color: rgba(229, 231, 235, 0.85); }

.card-hover {
  transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
}

.card-hover:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(0,0,0,.25);
  border-color: rgba(245, 158, 11, 0.20);
}

.btn-primary {
  background: linear-gradient(135deg, #f59e0b, #ef4444);
  color: #fff;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,0.12);
}

.btn-primary:hover {
  filter: brightness(1.05);
}

/* Единые стили кнопок и элементов управления */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,0.12);
  transition: filter .15s ease, background-color .15s ease, color .15s ease;
}

.btn-secondary {
  background: linear-gradient(135deg, #2563eb, #4f46e5);
  color: #ffffff;
}
.btn-secondary:hover { filter: brightness(1.05); }

.btn-admin {
  background: linear-gradient(135deg, #10b981, #22c55e);
  color: #ffffff;
}
.btn-admin:hover { filter: brightness(1.05); }

.btn-outline {
  background: transparent;
  color: #e5e7eb;
  border-color: rgba(255,255,255,0.24);
}
.btn-outline:hover {
  background: rgba(255,255,255,0.06);
}

.btn-danger {
  background: linear-gradient(135deg, #ef4444, #b91c1c);
  color: #fff;
}
.btn-danger:hover { filter: brightness(1.05); }

/* Таблицы админки */
.table-admin {
  width: 100%;
  border-collapse: collapse;
}
.table-admin th,
.table-admin td {
  border: 1px solid rgba(255,255,255,0.12);
  padding: 10px 12px;
}
.table-admin thead tr {
  background: rgba(255,255,255,0.9);
}
.table-admin tbody tr:hover { background: rgba(255,255,255,0.85); }
.table-admin th { color: #111827; font-weight: 600; }
.table-admin td { color: #111827; background: rgba(255,255,255,0.95); }

/* Единые поля форм */
.form-input, .form-select, .form-textarea {
  width: 100%;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.24);
  background: rgba(255,255,255,0.12);
  color: #e7eaf0;
}
.form-input::placeholder, .form-textarea::placeholder { color: #cbd5e1; }
.form-input:focus, .form-select:focus, .form-textarea:focus {
  outline: none;
  border-color: #60a5fa;
  box-shadow: 0 0 0 3px rgba(96,165,250,0.25);
}

.badge-hot {
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid rgba(239, 68, 68, 0.35);
  color: #fecaca;
}

/* --- Мобильные улучшения и читаемость --- */
/* Базовые улучшения для форм: контрастный текст и плейсхолдеры */
.glass input,
.glass select,
.glass textarea {
  background-color: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.24);
  color: #e7eaf0; /* чуть ярче для читабельности */
}

/* Стили для выпадающих опций селекта (насколько позволяет браузер) */
.glass select option {
  color: #0b1220; /* тёмный текст на светлом фоне списка */
  background-color: #ffffff;
}

.glass input::placeholder,
.glass textarea::placeholder {
  color: #cbd5e1; /* text-slate-300 */
  opacity: 1;
}

/* Уточняем контраст для селектов */
.glass select { color: #e7eaf0; }

/* Читаемость текста на карточках товара */
.product-card .product-subtitle { color: #e5e7eb; opacity: 0.95; }
.product-card .font-semibold { color: #f8fafc; }

/* Компактный мобильный режим */
@media (max-width: 640px) {
  /* Включается, если на body есть класс .mobile-compact */
  .mobile-compact .hero-actions a {
    font-size: 0.9rem;
    padding: 0.5rem 0.75rem; /* меньше, чем px-5 py-3 */
    border-radius: 0.75rem;
  }

  .mobile-compact .steam-login {
    font-size: 0.9rem;
    padding: 0.45rem 0.65rem; /* компактная кнопка в шапке */
    border-radius: 0.6rem;
  }

  /* Сетка товаров: 2 колонки на мобильных вместо одной */
  .mobile-compact .product-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.5rem; /* уже, чем gap-4 */
  }

  /* Карточка товара компактнее */
  .mobile-compact .product-card .p-4 {
    padding: 0.75rem; /* было 1rem */
  }

  .mobile-compact .product-card .h-36 { height: 6.5rem; }
  .mobile-compact .product-card .h-32 { height: 6rem; }
  .mobile-compact .product-card img { opacity: 0.95; }

  .mobile-compact .product-card .font-semibold { font-size: 0.95rem; }
  .mobile-compact .product-card .text-lg { font-size: 1rem; }

  /* Кнопка "В корзину" компактная */
  .mobile-compact .product-card button {
    padding: 0.4rem 0.6rem;
    font-size: 0.85rem;
    border-radius: 0.6rem;
  }

  /* Уменьшаем внешние отступы контейнеров до минимума */
  .mobile-compact main.container { padding-left: 4px; padding-right: 4px; }
}

/* --- Мобильная нижняя панель и отступы --- */
@media (max-width: 768px) {
  body { 
    padding-bottom: 80px; /* Увеличенный отступ, чтобы контент и футер не перекрывались панелью */
  }
  .mobile-bottom-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 60;
    background: rgba(17, 24, 39, 0.98);
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    height: 56px;
  }
  .mobile-bottom-bar .bar-content {
    /* Grid layout controlled by Tailwind classes in HTML */
    height: 100%;
  }
  .mobile-bottom-bar .bar-btn {
    /* Resetting previous flex styles to allow Tailwind flex-col */
    background: transparent;
    border: none;
    color: #9ca3af; /* text-gray-400 */
    border-radius: 0;
  }
  .mobile-bottom-bar .bar-btn.active,
  .mobile-bottom-bar .bar-btn:hover, 
  .mobile-bottom-bar .bar-btn:focus {
      color: #fbbf24; /* text-yellow-400 */
      background: rgba(255,255,255,0.03);
  }
  #vk_widget_wrapper {
    bottom: 70px !important;
  }
}

/* --- Компактный виджет VK --- */
.vk-widget-compact {
  position: fixed;
  z-index: 70; /* Выше мобильного меню (60) */
  bottom: 70px; /* Над меню (56px + отступ) */
  right: 12px;
  width: 300px;
  max-width: 90vw;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 6px 18px rgba(0,0,0,.28);
  transition: transform 0.3s ease, bottom 0.3s ease;
}
.vk-widget-compact.bottom-left { right: auto; left: 12px; }

.vk-widget-toggle {
  position: fixed;
  z-index: 71; /* Кнопка выше виджета */
  bottom: 70px; /* Над меню */
  right: 12px;
  transition: transform 0.3s ease, bottom 0.3s ease;
}
.vk-widget-toggle.bottom-left { right: auto; left: 12px; }

/* Компактность на мобильных */
@media (max-width: 640px) {
  .vk-widget-compact {
    transform: scale(0.75);
    transform-origin: bottom right;
    bottom: 65px;
    right: 8px;
  }
  .vk-widget-compact.bottom-left {
    transform-origin: bottom left;
    left: 8px;
  }
  
  .vk-widget-toggle {
    transform: scale(0.8);
    transform-origin: bottom right;
    bottom: 65px;
    right: 8px;
  }
  .vk-widget-toggle.bottom-left {
    transform-origin: bottom left;
    left: 8px;
  }
}

/* Дропдаун пользователя — поверх всего */
#user-menu { z-index: 1000; }

/* --- Сворачиваемая панель фильтров --- */
.filter-panel {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 56px; /* место над нижней панелью */
  z-index: 55;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(17, 24, 39, 0.9);
  max-height: 60vh;
  overflow-y: auto;
  transform: translateY(100%);
  transition: transform 0.25s ease;
}
.filter-panel.open { transform: translateY(0); }
.filter-panel .panel-content { padding: 12px; }

/* --- Компактные подзаголовки и бейджи --- */
.product-subtitle { font-size: 11px; opacity: 0.8; margin-bottom: 6px; }
.badge-featured { display:inline-flex; align-items:center; gap:6px; font-size:11px; padding:4px 8px; border-radius:9999px; background: rgba(234,179,8,0.15); color:#fde68a; border:1px solid rgba(234,179,8,0.35); }
.badge-sold { display:inline-flex; align-items:center; gap:6px; font-size:11px; padding:4px 8px; border-radius:9999px; background: rgba(99,102,241,0.15); color:#c7d2fe; border:1px solid rgba(99,102,241,0.35); }

/* --- Прокручиваемый список категорий на мобильных --- */
.mobile-category-list { max-height: 220px; overflow-y: auto; border: 1px solid rgba(255,255,255,0.1); border-radius: 12px; padding: 6px; background: rgba(255,255,255,0.04); }
.mobile-category-item { display:flex; align-items:center; gap:8px; padding:6px 8px; border-radius: 8px; }
.mobile-category-item:hover { background: rgba(255,255,255,0.06); }

/* --- Контраст в админке для светлых блоков и форм --- */
.bg-white,
.bg-white * {
  color: #1f2937;
}

.bg-white input,
.bg-white select,
.bg-white textarea {
  background-color: #ffffff;
  color: #111827;
  border-color: #d1d5db;
}

.bg-white input::placeholder,
.bg-white textarea::placeholder {
  color: #6b7280;
}

.bg-white input:focus,
.bg-white select:focus,
.bg-white textarea:focus {
  outline: none;
  border-color: #60a5fa;
  box-shadow: 0 0 0 3px rgba(96, 165, 250, 0.35);
}
.admin-subnav {
  background: rgba(17, 24, 39, 0.9);
}
.admin-subnav .btn {
  border-color: rgba(255,255,255,0.18);
}

/* --- Mobile Admin UI Fixes --- */
@media (max-width: 768px) {
  /* Ensure content is not hidden behind fixed bottom navigation */
  body, main {
    padding-bottom: 90px !important;
  }

  /* Lift fixed action buttons above the bottom navigation */
  .admin-save-button,
  .fixed-action-btn {
    bottom: 80px !important;
  }
  
  /* Lift sticky save buttons on mobile so they are not covered by bottom bar */
  @media (max-width: 768px) {
    .admin-save-button {
      position: sticky;
      bottom: 120px; /* Increased from 80px to avoid overlap with bottom menu */
      z-index: 40;
      background: rgba(255, 255, 255, 0.95);
      padding: 12px;
      border-radius: 12px;
      box-shadow: 0 -4px 12px rgba(0,0,0,0.15);
      margin-top: 20px;
      border: 1px solid rgba(0,0,0,0.05);
    }
  }
  
  /* Ensure save buttons in forms have space below them */
  form button[type="submit"] {
    margin-bottom: 20px;
  }

  /* Dashboard graph optimization for mobile */
  #salesChart {
    max-height: 300px;
  }
  
  /* Admin table responsive wrapper */
  .table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin-bottom: 1rem;
  }
}
