/**
 * ZHK PAGE STYLES - Стили для страницы ЖК
 * Шахматка квартир, фильтры, модальные окна
 */

/* Hero/gallery sliders must stay inside viewport on mobile */
.hero-gallery-swiper,
.gallery-swiper {
  max-width: 100%;
  overflow: hidden;
  contain: layout paint;
}

.hero-gallery-swiper .swiper-slide,
.gallery-swiper .swiper-slide {
  max-width: 100%;
}

/* ========================================
   FULL-BUILDING CHESSBOARD - Шахматка здания
   ======================================== */

/* Building container */
.chessboard-building {
  display: flex;
  flex-direction: column;
  min-width: 600px;
  padding: 8px;
  gap: 3px;
}

/* Single floor row */
.chessboard-row {
  display: flex;
  gap: 3px;
  align-items: stretch;
}

/* Floor label on the left */
.chessboard-floor-label {
  flex: 0 0 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 13px;
  color: #6B7280;
  background: #F9FAFB;
  border-radius: 6px;
  user-select: none;
}

/* Apartment cell */
.chessboard-cell {
  position: relative;
  min-height: 56px;
  flex-basis: 0;
  min-width: 0;
  border-radius: 6px;
  padding: 4px 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  overflow: hidden;
}

/* Cell inner text styles */
.cell-number {
  font-size: 9px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.7);
  line-height: 1;
}

.cell-rooms {
  font-size: 15px;
  font-weight: 800;
  color: white;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
  line-height: 1.1;
}

.cell-area {
  font-size: 9px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.9);
  line-height: 1;
}

.cell-price {
  font-size: 10px;
  font-weight: 700;
  color: white;
  line-height: 1;
}

.cell-price::after {
  content: ' млн';
  font-size: 8px;
  font-weight: 600;
}

/* Status Colors */
.chessboard-cell.status-available {
  background: linear-gradient(135deg, #10B981 0%, #059669 100%);
}

.chessboard-cell.status-available:hover {
  transform: scale(1.08);
  z-index: 10;
  box-shadow: 0 6px 20px rgba(16, 185, 129, 0.5);
}

.chessboard-cell.status-booked {
  background: linear-gradient(135deg, #FCD34D 0%, #F59E0B 100%);
}

.chessboard-cell.status-booked:hover {
  transform: scale(1.08);
  z-index: 10;
  box-shadow: 0 6px 20px rgba(245, 158, 11, 0.5);
}

.chessboard-cell.status-sold {
  background: linear-gradient(135deg, #9CA3AF 0%, #6B7280 100%);
  cursor: not-allowed;
  opacity: 0.5;
}

.chessboard-cell.status-sold:hover {
  transform: none;
  box-shadow: none;
}

.chessboard-cell.status-special {
  background: linear-gradient(135deg, #8B5CF6 0%, #7C3AED 100%);
  border: 2px solid gold;
  animation: glow-special 2s ease-in-out infinite;
}

.chessboard-cell.status-special:hover {
  transform: scale(1.08);
  z-index: 10;
  box-shadow: 0 6px 24px rgba(139, 92, 246, 0.6);
}

@keyframes glow-special {
  0%, 100% {
    box-shadow: 0 0 12px rgba(251, 191, 36, 0.3);
  }
  50% {
    box-shadow: 0 0 20px rgba(251, 191, 36, 0.6);
  }
}

/* Responsive */
@media (min-width: 1024px) {
  .chessboard-building {
    min-width: auto;
  }

  .chessboard-cell {
    min-height: 56px;
  }
}

@media (min-width: 768px) and (max-width: 1023px) {
  .chessboard-cell {
    min-height: 48px;
  }

  .cell-rooms {
    font-size: 13px;
  }

  .cell-price {
    font-size: 9px;
  }
}

@media (max-width: 767px) {
  .chessboard-building {
    min-width: 0;
    padding: 4px;
    gap: 2px;
  }

  .chessboard-row {
    gap: 2px;
  }

  .chessboard-cell {
    min-height: 40px;
    padding: 3px 4px;
    border-radius: 4px;
  }

  .cell-area,
  .cell-price {
    display: none;
  }

  .cell-rooms {
    font-size: 12px;
  }

  .cell-number {
    font-size: 7px;
  }

  .chessboard-floor-label {
    flex: 0 0 28px;
    font-size: 10px;
    border-radius: 4px;
  }
}

/* Old Grid Styles (keep for compatibility) */
.chessboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  padding: 0;
}

@media (min-width: 640px) {
  .chessboard-grid {
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 16px;
  }
}

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

/* ========================================
   APARTMENT CELL - Ячейка квартиры
   ======================================== */

.apartment-cell {
  position: relative;
  background: white;
  border: 2px solid transparent;
  border-radius: 16px;
  padding: 16px;
  min-height: 140px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  transition: all 0.3s ease;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.apartment-cell:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.15);
}

.apartment-number {
  font-size: 18px;
  font-weight: 700;
  color: white;
  margin-bottom: 8px;
}

.apartment-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.apartment-rooms {
  font-size: 14px;
  font-weight: 600;
  color: white;
  opacity: 0.95;
}

.apartment-area {
  font-size: 13px;
  color: white;
  opacity: 0.9;
}

.apartment-price {
  font-size: 14px;
  font-weight: 700;
  color: white;
  margin-top: 4px;
}

.apartment-badge {
  position: absolute;
  top: 8px;
  right: 8px;
  background: gold;
  color: #1F2937;
  font-size: 10px;
  font-weight: 700;
  padding: 4px 8px;
  border-radius: 6px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* ========================================
   STATUS COLORS - Цвета статусов
   ======================================== */

.status-available {
  background: linear-gradient(135deg, var(--color-apartment-available) 0%, var(--color-apartment-available-dark) 100%);
  border-color: var(--color-apartment-available);
}

.status-available:hover {
  border-color: var(--color-apartment-available-dark);
  box-shadow: 0 8px 25px rgba(16, 185, 129, 0.4);
}

.status-booked {
  background: linear-gradient(135deg, var(--color-apartment-booked-light) 0%, var(--color-apartment-booked) 100%);
  border-color: var(--color-apartment-booked);
}

.status-booked:hover {
  border-color: var(--color-apartment-booked);
  box-shadow: 0 8px 25px rgba(245, 158, 11, 0.4);
}

.status-sold {
  background: linear-gradient(135deg, var(--color-apartment-sold-light) 0%, var(--color-apartment-sold) 100%);
  border-color: var(--color-apartment-sold);
  cursor: not-allowed;
  opacity: 0.6;
}

.status-sold:hover {
  transform: none;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.status-special {
  background: linear-gradient(135deg, var(--color-apartment-special) 0%, var(--color-apartment-special-dark) 100%);
  border-color: gold;
  border-width: 3px;
  animation: pulse-border 2s ease-in-out infinite;
}

.status-special:hover {
  border-color: gold;
  box-shadow: 0 8px 30px rgba(139, 92, 246, 0.5);
}

@keyframes pulse-border {
  0%, 100% {
    border-color: gold;
  }
  50% {
    border-color: #FCD34D;
  }
}

/* ========================================
   FILTER STATES - Состояния фильтрации
   ======================================== */

.filtered-out {
  opacity: 0.15;
  pointer-events: none;
  filter: grayscale(1);
}

.filtered-in {
  animation: highlight-pulse 0.6s ease-in-out;
}

@keyframes highlight-pulse {
  0%, 100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.06);
    box-shadow: 0 4px 16px rgba(59, 130, 246, 0.4);
  }
}

/* ========================================
   TOOLTIP - Всплывающая подсказка
   ======================================== */

.apartment-tooltip {
  position: fixed;
  background: rgba(31, 41, 55, 0.97);
  backdrop-filter: blur(10px);
  color: white;
  padding: 0;
  border-radius: 12px;
  font-size: 14px;
  pointer-events: none;
  z-index: 9999;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
  animation: tooltip-appear 0.2s ease;
  overflow: hidden;
  width: 200px;
}

.tooltip-plan-img {
  display: block;
  width: 100%;
  height: 140px;
  object-fit: cover;
  background: #374151;
}

.tooltip-info {
  padding: 8px 12px;
}

@keyframes tooltip-appear {
  from {
    opacity: 0;
    transform: translateY(5px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* (Building tabs and filter buttons now use .btn-tab and .btn-filter from components.css) */

/* ========================================
   STATUS BADGE - Бейдж статуса
   ======================================== */

.status-badge {
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.status-badge.status-available {
  background: var(--color-apartment-available);
  color: white;
}

.status-badge.status-booked {
  background: var(--color-apartment-booked);
  color: white;
}

.status-badge.status-sold {
  background: var(--color-apartment-sold);
  color: white;
}

.status-badge.status-special {
  background: var(--color-apartment-special);
  color: white;
}

/* ========================================
   MOBILE CHESSBOARD TABS - Табы корпусов на мобильных
   ======================================== */

@media (max-width: 640px) {
  /* Section padding */
  #chessboard-section {
    padding-left: 12px;
    padding-right: 12px;
  }

  /* Chessboard container */
  #chessboard-container {
    border-radius: 12px;
  }

  #chessboard-container > .px-6 {
    padding-left: 12px;
    padding-right: 12px;
  }

  #chessboard-header {
    font-size: 14px;
  }

  /* Building tabs — grid 2 or 3 columns on mobile */
  #chessboard-section .btn-tab {
    font-size: 11px;
    padding: 8px 6px;
    min-height: 36px;
    line-height: 1.2;
  }

  /* Legend — tighter on mobile */
  #chessboard-section .grid.grid-cols-2 {
    gap: 6px;
  }

  #chessboard-section .grid.grid-cols-2 > div {
    padding: 6px 8px;
    gap: 8px;
  }

  #chessboard-section .grid.grid-cols-2 .w-10 {
    width: 28px;
    height: 28px;
    min-width: 28px;
  }
}

/* ========================================
   MOBILE FILTERS - Мобильные фильтры
   ======================================== */

@media (max-width: 1023px) {
  #filter-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: white;
    z-index: 9999;
    overflow-y: auto;
    padding: 24px;
    transform: translateY(100%);
    transition: transform 0.3s ease;
  }

  #filter-sidebar.mobile-open {
    transform: translateY(0);
  }

  #filter-sidebar::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 60px;
    background: linear-gradient(to bottom, white, transparent);
    pointer-events: none;
  }
}

/* ========================================
   FORM INPUTS - Формы
   ======================================== */

.form-input {
  width: 100%;
  padding: 12px 16px;
  border: 2px solid var(--color-border);
  border-radius: 12px;
  font-size: 14px;
  font-family: var(--font-body);
  transition: all 0.3s ease;
  background: white;
}

.form-input:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.form-select {
  width: 100%;
  padding: 12px 16px;
  border: 2px solid var(--color-border);
  border-radius: 12px;
  font-size: 14px;
  font-family: var(--font-body);
  transition: all 0.3s ease;
  background: white;
  cursor: pointer;
}

.form-select:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

/* (Buttons now use unified .btn-primary and .btn-secondary from components.css) */

/* ========================================
   MODAL - Модальное окно
   ======================================== */

#apartment-modal {
  animation: modal-appear 0.3s ease;
}

@keyframes modal-appear {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

#apartment-modal .bg-white {
  animation: modal-slide-up 0.3s ease;
}

@keyframes modal-slide-up {
  from {
    opacity: 0;
    transform: translateY(50px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ========================================
   SWIPER CUSTOMIZATION - Кастомизация Swiper
   ======================================== */

.swiper-button-next,
.swiper-button-prev {
  width: 44px;
  height: 44px;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(10px);
  border-radius: 50%;
  color: var(--color-primary);
}

.swiper-button-next:after,
.swiper-button-prev:after {
  font-size: 18px;
  font-weight: 700;
}

.swiper-pagination-bullet {
  width: 10px;
  height: 10px;
  background: white;
  opacity: 0.7;
}

.swiper-pagination-bullet-active {
  background: var(--color-primary);
  opacity: 1;
}

/* ========================================
   ANIMATIONS - Анимации
   ======================================== */

@keyframes slide-up {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.animate-slide-up {
  animation: slide-up 0.3s ease forwards;
}

/* ========================================
   RESPONSIVE - Адаптивность
   ======================================== */

@media (max-width: 640px) {
  .chessboard-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
  }

  .apartment-cell {
    padding: 12px;
    min-height: 120px;
  }

  .apartment-number {
    font-size: 16px;
  }

  .apartment-rooms,
  .apartment-price {
    font-size: 12px;
  }

  .apartment-area {
    font-size: 11px;
  }

  /* (Building tabs and filter buttons now use .btn-tab and .btn-filter responsive rules from components.css) */
}

@media (max-width: 320px) {
  .chessboard-grid {
    grid-template-columns: 1fr;
  }

  .apartment-cell {
    min-height: 100px;
  }
}

/* ========================================
   ACCESSIBILITY - Доступность
   ======================================== */

/* Увеличенные touch targets для мобильных */
@media (hover: none) and (pointer: coarse) {
  .apartment-cell {
    min-height: 140px;
    padding: 16px;
  }

  .btn-tab,
  .btn-filter {
    min-height: 44px;
    padding: 12px 20px;
  }
}

/* Focus states */
.chessboard-cell:focus,
.apartment-cell:focus,
.btn-tab:focus,
.btn-filter:focus,
.btn:focus {
  outline: 3px solid var(--color-primary);
  outline-offset: 2px;
}

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

/* High contrast mode */
@media (prefers-contrast: high) {
  .apartment-cell {
    border-width: 3px;
  }

  .status-available,
  .status-booked,
  .status-special {
    border-color: currentColor;
  }
}

/* Dark mode support (если потребуется) */
@media (prefers-color-scheme: dark) {
  /* Можно добавить темную тему позже */
}
