/* Стили только для планшетов и мобильных устройств */

/* Базовые стили для мобильной панели */
.color-panel.mobile-panel {
  position: fixed !important;
  bottom: 0 !important;
  left: 0 !important;
  right: 0 !important;
  top: auto !important;
  width: 100% !important;
  transform: translateY(100%) !important;
  transition: transform 0.3s ease !important;
  z-index: 1000;
}

.color-panel.mobile-panel.active {
  transform: translateY(0) !important;
}

/* Планшеты (769px - 1024px) */
@media (min-width: 769px) and (max-width: 1024px) {
  .visualizer-main {
    height: 80vh;
    max-height: 80vh;
  }

  .house-container {
    padding-left: 240px;
    padding-right: 20px;
  }

  .color-panel {
    width: 220px;
    left: 10px;
    padding: 20px;
  }

  /* Сетка цветов 2 колонки для планшетов */
  .color-options {
    display: -webkit-box !important; /* Safari 6.1+ */
    display: -webkit-flex !important; /* Safari 6.1+ */
    display: -ms-flexbox !important; /* IE 10 */
    display: flex !important;
    -webkit-flex-wrap: wrap !important; /* Safari 6.1+ */
    -ms-flex-wrap: wrap !important; /* IE 10 */
    flex-wrap: wrap !important;
    max-height: 300px;
    overflow-y: auto;
  }
  
  .color-option {
    width: calc(50% - 5px);
    margin: 2.5px;
  }

  .color-option {
    display: -webkit-box !important; /* Safari 6.1+ */
    display: -webkit-flex !important; /* Safari 6.1+ */
    display: -ms-flexbox !important; /* IE 10 */
    display: flex !important;
    -webkit-box-orient: vertical !important; /* Safari 6.1+ */
    -webkit-box-direction: normal !important; /* Safari 6.1+ */
    -webkit-flex-direction: column !important; /* Safari 6.1+ */
    -ms-flex-direction: column !important; /* IE 10 */
    flex-direction: column !important;
    -webkit-box-align: center !important; /* Safari 6.1+ */
    -webkit-align-items: center !important; /* Safari 6.1+ */
    -ms-flex-align: center !important; /* IE 10 */
    align-items: center !important;
    padding: 8px;
    border-radius: 8px;
    cursor: pointer;
    border: 2px solid transparent;
    -webkit-transition: all 0.2s ease;
    transition: all 0.2s ease;
    background: #f8f9fa;
    min-height: 70px;
  }

  .color-option:hover {
    border-color: #e74c3c;
    background: #fff5f3;
    transform: scale(1.02);
  }

  .color-option.active {
    border-color: #e74c3c;
    background: #ffecea;
    transform: scale(1.02);
  }

  .color-swatch {
    width: 36px;
    height: 36px;
    border-radius: 6px;
    border: 1px solid rgba(0,0,0,0.1);
    flex-shrink: 0;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
  }

  .color-label {
    font-size: 11px;
    font-weight: 500;
    color: #333;
    text-align: center;
    line-height: 1.2;
  }

  /* Крупные маркеры для планшетов */
  .marker-dot {
    width: 24px;
    height: 24px;
    border: 3px solid #fff;
    background: #dc3545; /* Красный цвет */
  }

  .marker-label {
    font-size: 12px;
    padding: 6px 10px;
  }

  /* Горизонтальная прокрутка для вариантов */
  .variant-options {
    display: flex !important;
    flex-direction: row !important;
    gap: 8px;
    margin-bottom: 15px;
    overflow-x: auto;
    padding-bottom: 5px;
  }

  .variant-option {
    display: flex !important;
    align-items: center !important;
    gap: 6px;
    font-size: 12px;
    cursor: pointer;
    padding: 8px 12px;
    border-radius: 20px;
    transition: all 0.2s ease;
    white-space: nowrap;
    flex-shrink: 0;
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    min-height: 40px;
  }

  .variant-option:hover {
    background: #e9ecef;
  }

  .variant-option input[type="radio"]:checked {
    background: #ffecea;
    border-color: #e74c3c;
  }
}

/* Мобильные устройства (до 768px) */
@media (max-width: 768px) {
  .visualizer-main {
    height: 100vh;
    max-height: 100vh;
    overflow: hidden;
  }

  .house-container {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .house-image {
    position: relative;
    width: 100%;
    height: 55vh;
    max-height: 55vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 10px;
  }

  .facade-image {
    width: 100%;
    height: 100%;
    object-fit: contain;
    border-radius: 10px;
    box-shadow: 0 10px 20px rgba(0,0,0,0.1);
  }

  /* Мобильная панель - снизу */
  .color-panel {
    position: fixed !important;
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
    top: auto !important;
    width: 100% !important;
    height: 45vh;
    max-height: 45vh;
    background: #fff;
    border-radius: 20px 20px 0 0;
    box-shadow: 0 -10px 30px rgba(0,0,0,0.15);
    padding: 20px;
    overflow-y: auto;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    transform: translateY(100%);
    z-index: 1000;
  }

  .color-panel.active {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
  }

  /* Увеличиваем маркеры для мобильных */
  .marker-dot {
    width: 32px !important;
    height: 32px !important;
    border: 3px solid #fff;
    background: #dc3545 !important; /* Красный цвет */
  }

  .marker-label {
    font-size: 12px;
    padding: 6px 10px;
  }

  /* Цветовые опции - сетка 3 колонки */
  .color-options {
    display: -webkit-box !important; /* Safari 6.1+ */
    display: -webkit-flex !important; /* Safari 6.1+ */
    display: -ms-flexbox !important; /* IE 10 */
    display: flex !important;
    -webkit-flex-wrap: wrap !important; /* Safari 6.1+ */
    -ms-flex-wrap: wrap !important; /* IE 10 */
    flex-wrap: wrap !important;
    max-height: 250px;
    overflow-y: auto;
    padding: 5px;
  }
  
  .color-option {
    width: calc(33.333% - 8px);
    margin: 4px;
  }

  .color-option {
    display: -webkit-box !important; /* Safari 6.1+ */
    display: -webkit-flex !important; /* Safari 6.1+ */
    display: -ms-flexbox !important; /* IE 10 */
    display: flex !important;
    -webkit-box-orient: vertical !important; /* Safari 6.1+ */
    -webkit-box-direction: normal !important; /* Safari 6.1+ */
    -webkit-flex-direction: column !important; /* Safari 6.1+ */
    -ms-flex-direction: column !important; /* IE 10 */
    flex-direction: column !important;
    -webkit-box-align: center !important; /* Safari 6.1+ */
    -webkit-align-items: center !important; /* Safari 6.1+ */
    -ms-flex-align: center !important; /* IE 10 */
    align-items: center !important;
    padding: 12px 8px;
    border-radius: 12px;
    cursor: pointer;
    border: 2px solid transparent;
    -webkit-transition: all 0.2s ease;
    transition: all 0.2s ease;
    background: #f8f9fa;
    min-height: 90px;
  }

  .color-option:hover,
  .color-option:active {
    border-color: #e74c3c;
    background: #fff5f3;
    transform: scale(1.05);
  }

  .color-option.active {
    border-color: #e74c3c;
    background: #ffecea;
    transform: scale(1.05);
  }

  .color-swatch {
    width: 44px;
    height: 44px;
    border-radius: 10px;
    border: 2px solid rgba(0,0,0,0.1);
    flex-shrink: 0;
    box-shadow: 0 3px 6px rgba(0,0,0,0.15);
  }

  .color-label {
    font-size: 11px;
    font-weight: 500;
    color: #333;
    text-align: center;
    line-height: 1.2;
  }

  /* Варианты выбора - горизонтально */
  .variant-options {
    display: flex !important;
    flex-direction: row !important;
    gap: 10px;
    margin-bottom: 20px;
    overflow-x: auto;
    padding-bottom: 8px;
    scrollbar-width: none;
    -ms-overflow-style: none;
  }

  .variant-options::-webkit-scrollbar {
    display: none;
  }

  .variant-option {
    display: flex !important;
    align-items: center !important;
    gap: 8px;
    font-size: 13px;
    cursor: pointer;
    padding: 10px 16px;
    border-radius: 25px;
    transition: all 0.2s ease;
    white-space: nowrap;
    flex-shrink: 0;
    background: #f8f9fa;
    border: 2px solid #e9ecef;
    min-height: 48px;
  }

  .variant-option:hover,
  .variant-option:active {
    background: #e9ecef;
    transform: scale(1.02);
  }

  .variant-option input[type="radio"] {
    display: none;
  }

  .variant-option input[type="radio"] + span::before {
    content: '';
    display: inline-block;
    width: 18px;
    height: 18px;
    border: 2px solid #ddd;
    border-radius: 50%;
    margin-right: 8px;
    vertical-align: middle;
    transition: all 0.2s ease;
  }

  .variant-option input[type="radio"]:checked + span::before {
    border-color: #e74c3c;
    background: #e74c3c;
    box-shadow: 0 0 0 3px rgba(231,76,60,0.2);
  }

  .variant-option input[type="radio"]:checked + span {
    color: #e74c3c;
    font-weight: 600;
  }

  .variant-option input[type="radio"]:checked {
    background: #ffecea;
    border-color: #e74c3c;
    transform: scale(1.02);
  }

  /* Кнопка закрытия */
  .mobile-close-btn {
    position: absolute;
    top: 15px;
    right: 20px;
    background: none;
    border: none;
    font-size: 22px;
    color: #666;
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    z-index: 1001;
  }

  .mobile-close-btn:hover,
  .mobile-close-btn:active {
    background: #f0f0f0;
    color: #333;
    transform: scale(1.1);
  }

  /* Индикатор панели */
  .color-panel::before {
    content: '';
    position: absolute;
    top: 12px;
    left: 50%;
    transform: translateX(-50%);
    width: 50px;
    height: 5px;
    background: #ddd;
    border-radius: 3px;
  }

  /* Очень маленькие экраны */
  @media (max-width: 480px) {
    .house-image {
      height: 50vh;
      max-height: 50vh;
    }

    .color-panel {
      height: 50vh;
      max-height: 50vh;
      padding: 15px;
    }

    .color-options {
      grid-template-columns: repeat(3, 1fr) !important;
      gap: 10px;
    }

    .color-swatch {
      width: 40px;
      height: 40px;
    }

    .marker-dot {
      width: 28px !important;
      height: 28px !important;
      background: #dc3545 !important; /* Красный цвет */
    }

    .marker-label {
      font-size: 11px;
      padding: 5px 8px;
    }

    .variant-option {
      padding: 8px 12px;
      font-size: 12px;
      min-height: 44px;
    }
  }

  /* Горизонтальная ориентация */
  @media (max-width: 768px) and (orientation: landscape) {
    .visualizer-main {
      height: 100vh;
    }

    .house-image {
      height: 75vh;
      max-height: 75vh;
    }

    .color-panel {
      height: 25vh;
      max-height: 25vh;
      padding: 15px;
    }

    .color-options {
      grid-template-columns: repeat(4, 1fr) !important;
      max-height: 100px;
      gap: 8px;
    }

    .color-swatch {
      width: 32px;
      height: 32px;
    }

    .color-option {
      min-height: 60px;
      padding: 8px 6px;
    }

    .variant-options {
      margin-bottom: 10px;
    }

    .variant-option {
      padding: 6px 10px;
      font-size: 11px;
      min-height: 36px;
    }
  }
}

/* Улучшения для сенсорных устройств (только планшеты и мобильные) */
@media (hover: none) and (pointer: coarse) and (max-width: 1024px) {
  .marker {
    min-width: 48px;
    min-height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .color-option {
    min-height: 90px;
    touch-action: manipulation;
  }

  .variant-option {
    min-height: 48px;
    touch-action: manipulation;
  }

  .mobile-close-btn {
    min-width: 44px;
    min-height: 44px;
    touch-action: manipulation;
  }

  /* Улучшенная обратная связь для касаний */
  .marker:active {
    transform: scale(0.95);
  }

  .color-option:active {
    transform: scale(0.98);
  }

  .variant-option:active {
    transform: scale(0.98);
  }
}

/* Поддержка темной темы (только для планшетов и мобильных) */
@media (prefers-color-scheme: dark) and (max-width: 1024px) {
  .color-panel {
    background: #1a1a1a;
    color: #fff;
  }

  .panel-header h3 {
    color: #fff;
  }

  .panel-header p {
    color: #ccc;
  }

  .variant-option {
    background: #2a2a2a;
    border-color: #3a3a3a;
    color: #fff;
  }

  .color-option {
    background: #2a2a2a;
    color: #fff;
  }

  .color-label {
    color: #fff;
  }
}
