/* PC Configurator Adapted Styles vFinal */

:root {
  /* Fluid Font Sizes using clamp() for responsiveness */
  /* Format: clamp(min-size, preferred-size, max-size) */
  --font-size-xs: clamp(0.6875rem, 1.2vw, 0.75rem); /* ~11px - 12px */
  --font-size-sm: clamp(0.75rem, 1.5vw, 0.875rem); /* ~12px - 14px */
  --font-size-base: clamp(0.875rem, 1.8vw, 1rem); /* ~14px - 16px */
  --font-size-lg: clamp(1rem, 2.2vw, 1.125rem); /* ~16px - 18px */
  --font-size-xl: clamp(1.125rem, 2.8vw, 1.375rem); /* ~18px - 22px */
  --font-size-xxl: clamp(1.375rem, 3.5vw, 1.5rem); /* ~22px - 24px */
  --font-size-xxxl: clamp(1.5rem, 4vw, 1.75rem); /* ~24px - 28px */
}

/* === Fix: Prevent body scroll when modal is open === */
body.configurator-modal-open {
  overflow: hidden;
}

/* Blur effect for when a modal is open */
#configurator-app.blur-active > .row {
  filter: blur(4px);
  transition: filter 0.3s ease;
}

#product-modal .modal-content.blur-active {
  filter: blur(4px);
  transition: filter 0.3s ease;
}

/* Make modal backdrop slightly transparent to see the blur */
.modal-backdrop.in {
  background-color: rgba(0, 0, 0, 0.3) !important;
  backdrop-filter: blur(2px);
}

/* Main Layout & Panels */
#pc-configurator .panel {
  background-color: var(--up-bg-wd);
  border: 1px solid var(--up-border-color);
  box-shadow: var(--up-box-shadow-1px);
  border-radius: var(--up-border-radius-large, 20px);
  margin-bottom: 20px;
}
#pc-configurator .panel-heading {
  background-color: transparent;
  border-bottom: 1px solid var(--up-border-color);
}
#pc-configurator .panel-title {
  color: var(--up-text-wd-color);
  font-size: var(--font-size-xl);
  font-weight: 600;
}

/* Summary Block */
#summary-container .panel-body {
  padding: 20px;
}
#summary-list-components .summary-item-list {
  font-size: var(--font-size-base);
  color: var(--up-text-color);
  margin-bottom: 15px;
}
#summary-list-components .summary-item-list li {
  padding: 3px 0;
}
#summary-list-components .component-name {
  font-weight: 500;
  color: var(--up-text-wd-color);
}

/* === INTEGRATED STEPPER & LIST STYLES === */
.steps-container .panel-body {
  padding: 20px 0 0 0;
}
.steps-container .list-group {
  position: relative;
  margin-left: 30px;
}
.steps-container .list-group::before {
  content: "";
  position: absolute;
  left: 18px;
  top: 25px;
  bottom: 25px;
  width: 2px;
  background-color: var(--up-border-color, #e0e0e0);
  z-index: 1;
}
.list-group-item-wrapper {
  padding-right: 10px;
  padding-left: 45px;
  position: relative;
  padding-bottom: 20px;
}
.list-group-item-wrapper:last-child {
  padding-bottom: 0;
}
.step-main-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 20px;
  background-color: var(--up-bg-main);
  border: 1px solid var(--up-border-color);
  border-radius: var(--up-border-radius-medium);
  transition: all 0.3s ease;
}
.step-visual {
  position: absolute;
  left: 0;
  top: 10px;
  z-index: 2;
}
.step-counter {
  height: 38px;
  width: 38px;
  background: var(--up-bg-wd, #fff);
  border: 2px solid var(--up-border-color, #e0e0e0);
  border-radius: 50%;
  display: flex;
  justify-content: center;
  align-items: center;
  font-weight: 600;
  color: var(--up-text-light-color, #aaa);
  transition: all 0.3s ease;
  font-size: var(--font-size-lg);
}
.step-info {
  display: flex;
  flex-direction: column;
  flex-grow: 1;
}
.step-name {
  font-weight: 600;
  font-size: var(--font-size-lg);
  color: var(--up-text-wd-color, #333);
  display: flex;
  align-items: center;
}
/* === Стили для SVG иконок === */
.svg-icon-wrapper {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-right: 8px;
  width: 20px;
  height: 20px;
  color: var(--up-text-gray-color);
  flex-shrink: 0;
}
.svg-icon-wrapper svg {
  width: 100%;
  height: 100%;
}
.step-required-badge {
  font-size: var(--font-size-xs);
  font-weight: 500;
  color: var(--up-text-gray-color);
  background-color: var(--up-bg-gray);
  padding: 2px 6px;
  border-radius: 4px;
  margin-top: 4px;
  display: inline-block;
}
.step-action {
  margin-left: 20px;
}

/* Step States */
.step-main-row.completed .step-counter {
  border-color: var(--up-color-success, #4caf50);
  background-color: var(--up-color-success, #4caf50);
  color: #fff;
}
.step-main-row.completed .step-name .svg-icon-wrapper {
  color: var(--up-color-success, #4caf50);
}
.step-main-row.active {
  border-color: var(--up-text-link, #2196f3);
  box-shadow: 0 0 8px rgba(33, 150, 243, 0.3);
}
.step-main-row.active .step-counter {
  border-color: var(--up-text-link, #2196f3);
  color: var(--up-text-link, #2196f3);
  transform: scale(1.1);
}
.step-main-row.active .step-name .svg-icon-wrapper {
  color: var(--up-text-link, #2196f3);
}
.step-main-row.missing .step-counter {
  border-color: var(--up-color-danger, #f44336);
  background-color: var(--up-bg-wd, #fff);
  color: var(--up-color-danger, #f44336);
}
.step-main-row.missing .step-name {
  color: var(--up-color-danger, #f44336);
}
.step-main-row.missing .step-name .svg-icon-wrapper {
  color: var(--up-color-danger, #f44336);
}
.step-counter .svg-icon-wrapper {
  width: 18px;
  height: 18px;
  margin: 0;
}

/* --- Animation for newly updated step --- */
@keyframes step-visual-pop {
  0% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.25);
    border-color: var(--up-color-warning, #ffc107);
  }
  100% {
    transform: scale(1);
  }
}

.step-main-row.step-just-updated .step-counter {
  animation: step-visual-pop 0.4s ease-in-out;
}

/* --- HOVER HIGHLIGHT START (THEME ADAPTIVE) --- */
.step-main-row.highlight-step {
  background-color: var(
    --up-bg-gray,
    #f0f2f5
  ); /* Адаптивный фон для подсветки */
  border-left: 4px solid var(--up-text-link, #2196f3);
}
/* --- HOVER HIGHLIGHT END --- */

/* Buttons */
#pc-configurator .choose-product-btn {
  color: var(--up-text-link, #4a71b1);
  background-color: transparent;
  border: 1px solid var(--up-text-link, #4a71b1);
  border-radius: var(--up-border-radius-small, 8px);
  font-size: var(--font-size-base);
  font-weight: 500;
  padding: 0px 20px;
  line-height: 44px;
  min-height: 44px;
  box-shadow: none;
  text-shadow: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}
#pc-configurator .choose-product-btn .svg-icon-wrapper {
  width: 16px;
  height: 16px;
  margin-right: 6px;
}
#pc-configurator .choose-product-btn:hover {
  color: var(--up-color-btn-primary, #fff);
  background-color: var(--up-text-link, #4a71b1);
  border-color: var(--up-text-link, #4a71b1);
}
#pc-configurator .add-another-btn {
  line-height: 34px;
  min-height: 34px;
  height: 34px;
  padding: 0 15px;
  font-size: var(--font-size-sm);
}
#pc-configurator #add-to-cart-btn {
  font-size: var(--font-size-lg);
  font-weight: 600;
  padding: 12px 25px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
#pc-configurator #add-to-cart-btn .svg-icon-wrapper {
  width: 18px;
  height: 18px;
  margin-right: 8px;
}

/* === MODIFICATION START: Updated disabled button styles === */
#pc-configurator #add-to-cart-btn:disabled {
  background-color: rgba(244, 67, 54, 0.1);
  border-color: rgba(244, 67, 54, 0.25);
  color: var(--up-color-danger, #f44336);
  opacity: 1;
  cursor: not-allowed;
  box-shadow: none;
}
#pc-configurator #add-to-cart-btn.btn-danger:disabled {
  background-color: rgba(244, 67, 54, 0.1);
  border-color: rgba(244, 67, 54, 0.25);
  color: var(--up-color-danger, #f44336);
  text-shadow: none;
  background-image: none;
  background-repeat: no-repeat;
}
/* === MODIFICATION END === */

.product-details-row .remove-product-btn {
  color: var(--up-text-gray-color, #a94442);
  background: transparent;
  border: none;
  padding: 5px;
  line-height: 1;
}
.product-details-row .remove-product-btn .svg-icon-wrapper {
  width: 16px;
  height: 16px;
  margin: 0;
}
.product-details-row .remove-product-btn:hover {
  opacity: 0.7;
  color: var(--up-text-wd-color);
}

/* === Product Details Row Animation === */
@keyframes product-add-animation {
  from {
    opacity: 0;
    transform: translateY(-20px);
    max-height: 0;
    padding-top: 0;
    padding-bottom: 0;
    margin-top: 0;
    margin-bottom: 0;
    border-width: 0;
  }
  50% {
    padding-top: 10px;
    padding-bottom: 10px;
    margin-top: 0;
    margin-bottom: 0;
    border-width: 1px;
    opacity: 0.8;
  }
  to {
    opacity: 1;
    transform: translateY(0);
    max-height: 100px; /* Adjust if content is taller */
  }
}

.product-details-row.newly-added {
  animation: product-add-animation 0.4s ease-in-out forwards;
}
/* === End Product Details Row Animation === */

/* Selected Product Details Row */
.product-details-row {
  display: flex;
  align-items: center;
  padding: 10px 20px;
  background-color: transparent;
  border: none !important;
  gap: 15px;
  overflow: hidden; /* Needed for height animation */
}
.product-details-image {
  width: 50px;
  height: 50px;
  object-fit: contain;
  background-color: var(--color-white, #fff);
  border: 1px solid var(--up-border-color, #eee);
  border-radius: var(--up-border-radius-small, 12px);
  flex-shrink: 0;
}
.product-details-name {
  flex-grow: 1;
  font-size: var(--font-size-base);
  color: var(--up-text-color, #555);
}
.product-details-price {
  font-weight: 600;
  font-size: var(--font-size-base);
  min-width: 120px;
  text-align: right;
  color: var(--up-text-wd-color, #333);
  flex-shrink: 0;
}
.add-another-wrapper {
  padding: 10px 20px 5px 20px;
  border-top: 1px dashed var(--up-border-color, #f0f0f0) !important;
}

/* Quantity Controls */
.quantity-control {
  display: flex;
  align-items: center;
  margin-left: auto;
  flex-shrink: 0;
}
.quantity-control .quantity-input {
  width: 50px;
  text-align: center;
  height: 28px;
  font-size: var(--font-size-sm);
  padding: 2px 4px;
  margin: 0 5px;
  border-radius: var(--up-border-radius-small, 8px);
  border: 1px solid var(--up-border-color);
}
.quantity-control .quantity-input::-webkit-outer-spin-button,
.quantity-control .quantity-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
.quantity-control .quantity-input[type="number"] {
  -moz-appearance: textfield;
}
.quantity-control .quantity-btn {
  width: 28px;
  height: 28px;
  line-height: 26px;
  padding: 0;
  font-size: var(--font-size-base);
  border-radius: 50%;
  border: 1px solid var(--up-border-color);
  background-color: var(--up-bg-main);
  color: var(--up-text-color);
}
.quantity-control .quantity-btn:hover {
  background-color: var(--up-border-color);
}

/* === MODIFICATION START: Adaptive Compatibility Notes Styles === */
#compatibility-notes .alert {
  margin-top: 20px;
  margin-bottom: 20px;
  border-radius: var(--up-border-radius-medium);
  padding: 15px;
  border-width: 1px;
  border-style: solid;
  text-shadow: none;
  color: var(--up-text-color); /* Default text color for the alert content */
}

#compatibility-notes .alert h5 {
  margin-top: 0;
  margin-bottom: 10px;
  font-weight: 600;
  color: var(--up-text-wd-color); /* Main heading color */
}

#compatibility-notes .alert ul {
  padding-left: 20px;
  margin-bottom: 0;
}

/* Success State */
#compatibility-notes .alert-success {
  background-color: rgba(76, 175, 80, 0.1); /* transparent green from #4CAF50 */
  border-color: rgba(76, 175, 80, 0.2);
  color: var(--up-color-success, #4caf50); /* Make the text green */
}
#compatibility-notes .alert-success h5 {
  color: var(--up-color-success, #4caf50); /* Also make the heading green */
}

/* Warning State */
#compatibility-notes .alert-warning {
  background-color: rgba(
    255,
    152,
    0,
    0.1
  ); /* transparent orange from #ff9800 */
  border-color: rgba(255, 152, 0, 0.2);
}
#compatibility-notes .alert-warning h5 {
  color: #ff9800; /* Orange color for heading */
}
#compatibility-notes .alert-warning ul {
  color: var(--up-text-color); /* Standard text color for details */
}

/* Danger State */
#compatibility-notes .alert-danger {
  background-color: rgba(244, 67, 54, 0.1); /* transparent red from #f44336 */
  border-color: rgba(244, 67, 54, 0.2);
}
#compatibility-notes .alert-danger h5 {
  color: var(--up-color-danger, #f44336); /* Red color for heading */
}
#compatibility-notes .alert-danger ul {
  color: var(--up-text-color); /* Standard text color for details */
}
/* === MODIFICATION END === */

.summary-actions {
  margin-top: 20px;
}
.configurator-cart-error {
  margin-top: 15px;
}

/* === MODAL WINDOW STYLES (UPDATED) === */
.modal-content {
  background-color: var(--up-modal-bg, #fff);
  border-radius: var(--up-border-radius-large, 20px);
  overflow: hidden;
  border: none;
  box-shadow: var(--up-box-shadow-large);
  height: 90vh;
  display: flex;
  flex-direction: column;
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-direction: row-reverse;
  border-bottom: 1px solid var(--up-border-color);
}
.modal-title {
  color: var(--up-text-wd-color);
  font-weight: 600;
}
.modal .close {
  color: var(--up-text-wd-color);
  opacity: 0.7;
  text-shadow: none;
}
.modal .close:hover {
  opacity: 1;
}
#product-modal .modal-dialog {
  width: 90%;
  max-width: 1600px;
  margin: 30px auto;
}
#product-modal .modal-body {
  position: relative;
  padding: 15px;
  flex-grow: 1;
  overflow-y: hidden;
}
#product-modal .modal-body > .row,
#product-modal .modal-body > .row > [class*="col-"] {
  height: 100%;
}
#modal-filters-container,
#modal-product-list-container {
  height: 100%;
  overflow-y: auto;
  padding-bottom: 50px;
}
#modal-filters-container {
  border-right: 1px solid var(--up-border-color);
}
#modal-filters-container::-webkit-scrollbar,
#modal-product-list-container::-webkit-scrollbar {
  width: 5px;
}
#modal-filters-container::-webkit-scrollbar-track,
#modal-product-list-container::-webkit-scrollbar-track {
  background: var(--up-bg-main);
}
#modal-filters-container::-webkit-scrollbar-thumb,
#modal-product-list-container::-webkit-scrollbar-thumb {
  background-color: var(--up-border-color);
  border-radius: 6px;
  border: 1px solid var(--up-bg-main);
}
#modal-filters-container::-webkit-scrollbar-thumb:hover,
#modal-product-list-container::-webkit-scrollbar-thumb:hover {
  background-color: var(--up-text-gray-color);
}

/* === New Loader Styles === */
.config-loader {
  background: var(--loader-overlay-bg);
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 40px 0;
  width: 100%;
}
.config-loader .dot {
  width: 15px;
  height: 15px;
  margin: 0 5px;
  background-color: var(--up-text-link); /* Adaptive color */
  border-radius: 50%;
  display: inline-block;
  animation: dot-pulse 1.4s infinite ease-in-out both;
}
.config-loader .dot:nth-child(1) {
  animation-delay: -0.32s;
}
.config-loader .dot:nth-child(2) {
  animation-delay: -0.16s;
}
@keyframes dot-pulse {
  0%,
  80%,
  100% {
    transform: scale(0);
  }
  40% {
    transform: scale(1);
  }
}
#modal-loader {
  padding-top: 40px;
}

/* === NEW: MODAL CONTROLS (SEARCH, SORT) === */
.modal-controls-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 0 15px 0;
  border-bottom: 1px solid var(--up-border-color);
  margin-bottom: 15px;
}
.modal-search-bar {
  flex-grow: 1;
  max-width: 40%;
  position: relative;
}
.modal-search-bar .form-control {
  background-color: var(--up-bg-main);
  border-color: var(--up-border-color);
  box-shadow: none;
  padding-left: 15px;
}
.modal-search-bar .form-control:focus {
  border-color: var(--up-text-link);
  box-shadow: 0 0 0 1px var(--up-text-link);
}

.modal-view-options {
  display: flex;
  align-items: center;
  gap: 20px;
}

/* === NEW: View Switcher Styles === */
.view-switcher-group {
  display: flex;
  background-color: var(--up-bg-main);
  border-radius: var(--up-border-radius-small);
  border: 1px solid var(--up-border-color);
  padding: 2px;
}
.view-switcher-btn {
  border: none !important;
  background-color: transparent !important;
  box-shadow: none !important;
  padding: 5px 10px !important;
  color: var(--up-text-gray-color) !important;
  transition: all 0.2s;
  border-radius: var(--up-border-radius-small);
  line-height: 0px;
}
.view-switcher-btn .svg-icon-wrapper {
  margin: 0;
  width: 20px;
  height: 20px;
}
.view-switcher-btn:not(.active):hover {
  color: var(--up-text-link) !important;
  background-color: transparent !important;
}
.view-switcher-btn.active {
  background-color: var(--up-text-link) !important;
  color: #fff !important;
  box-shadow: none !important;
}

.modal-sort-options {
  display: flex;
  align-items: center;
  gap: 10px;
}
.modal-sort-options label {
  margin: 0;
  font-weight: 500;
  color: var(--up-text-color);
}
.modal-sort-options .form-control {
  width: auto;
  background-color: var(--up-bg-main);
  border-color: var(--up-border-color);
  box-shadow: none;
}

/* Fix: Prevent scrollbar on filter apply */
#modal-product-list-container {
  position: relative;
  min-height: 400px;
}
#modal-product-list-paginated-loader {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--loader-overlay-bg);
  backdrop-filter: blur(2px);
  z-index: 10;
  display: none; /* Toggled by JS */
  justify-content: center;
  align-items: center;
}

/* === NEW: PAGINATION STYLES === */
.modal-pagination {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 0 0 0;
  margin-top: 20px;
  border-top: 1px solid var(--up-border-color);
}
.pagination-info {
  font-size: var(--font-size-base);
  color: var(--up-text-color);
}
.pagination-nav .pagination {
  margin: 0;
  box-shadow: none;
}
.pagination-nav .pagination > li > a,
.pagination-nav .pagination > li > span {
  background-color: var(--up-bg-main);
  border-color: var(--up-border-color);
  color: var(--up-text-link);
  border-radius: var(--up-border-radius-small);
  margin: 0 3px;
}
.pagination-nav .pagination > li > a:hover,
.pagination-nav .pagination > li > span:hover {
  background-color: var(--up-bg-gray);
  border-color: var(--up-text-link);
}
.pagination-nav .pagination > .active > span {
  background-color: var(--up-text-link);
  border-color: var(--up-text-link);
  color: #fff;
}
.pagination-nav .pagination > .disabled > span {
  background-color: var(--up-bg-gray);
  color: var(--up-text-gray-color);
  border-color: var(--up-border-color);
}

/* === MODAL FILTERS STYLING (EXISTING) === */
#modal-filters-content {
  padding: 10px;
}

#modal-filters-content h5 {
  font-size: var(--font-size-xl);
  font-weight: 600;
  color: var(--up-text-wd-color);
  padding-bottom: 15px;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--up-border-color);
}

.filter-group {
  margin-bottom: 20px;
  padding: 15px;
  background-color: var(--up-bg-main);
  border: 1px solid var(--up-border-color);
  border-radius: var(--up-border-radius-medium, 12px);
}

.filter-group:last-child {
  margin-bottom: 0;
}

.filter-title {
  font-size: var(--font-size-base);
  font-weight: 600;
  color: var(--up-text-wd-color);
  margin-bottom: 15px;
  padding-bottom: 10px;
  border-bottom: 1px dashed var(--up-border-color);
  margin-top: 0;
}

.filter-sub-group {
  margin-top: 15px;
}

.filter-sub-title {
  font-size: var(--font-size-sm);
  font-weight: 500;
  color: var(--up-text-color);
  margin-bottom: 10px;
  padding-left: 5px;
}

/* === MODIFICATION: REMOVED max-height === */
.filter-options {
  overflow-y: auto;
  padding-right: 10px;
}

/* === NEW: Compatibility Filter Switch === */
.compatibility-filter-group .filter-title {
  margin-bottom: 10px;
  padding-bottom: 0;
  border-bottom: none;
}
.compatibility-switch-container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-weight: 500;
  color: var(--up-text-color);
}
.compatibility-switch {
  position: relative;
  display: inline-block;
  width: 50px;
  height: 28px;
  flex-shrink: 0;
}
.compatibility-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}
.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #ccc;
  transition: 0.4s;
  border-radius: 28px;
}
.slider:before {
  position: absolute;
  content: "";
  height: 20px;
  width: 20px;
  left: 4px;
  bottom: 4px;
  background-color: white;
  transition: 0.4s;
  border-radius: 50%;
}
input:checked + .slider {
  background-color: var(--up-color-success, #4caf50);
}
input:focus + .slider {
  box-shadow: 0 0 1px var(--up-color-success, #4caf50);
}
input:checked + .slider:before {
  transform: translateX(22px);
}

/* === CUSTOM CHECKBOX STYLES (FIX 2.0) === */
.filter-options .checkbox {
  margin: 0 0 2px 0;
  position: relative;
}

.filter-options .checkbox input[type="checkbox"] {
  position: absolute;
  opacity: 0;
  cursor: pointer;
  height: 0;
  width: 0;
}

.filter-options .checkbox label {
  display: block;
  position: relative;
  padding: 8px 12px 8px 35px;
  border-radius: var(--up-border-radius-small, 8px);
  transition: background-color 0.2s ease;
  cursor: pointer;
  width: 100%;
  font-weight: 500;
  color: var(--up-text-color);
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
}

.filter-options .checkbox label:hover {
  background-color: var(--up-bg-gray);
  color: var(--up-text-wd-color);
}

.filter-options .checkbox label::before {
  content: "";
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  height: 18px;
  width: 18px;
  background-color: var(--up-bg-wd);
  border: 1px solid var(--up-border-color);
  border-radius: 4px;
  transition: all 0.2s ease;
}

.filter-options .checkbox label:hover::before {
  border-color: var(--up-text-link);
}

.filter-options .checkbox input[type="checkbox"]:checked + label::before {
  background-color: var(--up-text-link);
  border-color: var(--up-text-link);
}

.filter-options .checkbox label::after {
  content: "";
  position: absolute;
  display: none;
  left: 16px;
  top: 50%;
  width: 5px;
  height: 10px;
  border: solid white;
  border-width: 0 2px 2px 0;
  transform: translateY(-60%) rotate(45deg);
}

.filter-options .checkbox input[type="checkbox"]:checked + label::after {
  display: block;
}

/* === New: Price Filter Styles === */
.price-filter {
  display: flex;
  align-items: center;
  gap: 10px;
}
.price-filter span {
  color: var(--up-text-color);
}
.price-filter input.form-control {
  background-color: var(--up-bg-wd);
  border: 1px solid var(--up-border-color);
  border-radius: var(--up-border-radius-small, 8px);
  color: var(--up-text-wd-color);
  box-shadow: none;
  text-align: center;
  padding: 8px;
  height: auto;
  font-weight: 600;
  width: 100px;
}

.price-filter input.form-control:focus {
  border-color: var(--up-text-link);
}

.filter-options::-webkit-scrollbar {
  width: 6px;
}
.filter-options::-webkit-scrollbar-track {
  background: transparent;
  margin: 5px 0;
}
.filter-options::-webkit-scrollbar-thumb {
  background: var(--up-border-color);
  border-radius: 3px;
}
.filter-options::-webkit-scrollbar-thumb:hover {
  background: var(--up-text-gray-color);
}

/* === PRODUCT GRID VIEW === */
#modal-product-list.product-grid-view {
  display: grid !important;
  grid-template-columns: repeat(5, 1fr);
  gap: 15px;
}
@media (max-width: 1600px) {
  #modal-product-list.product-grid-view {
    grid-template-columns: repeat(4, 1fr);
  }
}
@media (max-width: 1200px) {
  #modal-product-list.product-grid-view {
    grid-template-columns: repeat(3, 1fr);
  }
}
@media (max-width: 992px) {
  #modal-product-list.product-grid-view {
    grid-template-columns: repeat(2, 1fr);
  }
}
@media (max-width: 767px) {
  #modal-product-list.product-grid-view {
    grid-template-columns: 1fr;
  }
}
.modal-product-card {
  display: flex;
  flex-direction: column;
  background-color: var(--up-bg-main);
  border: 1px solid var(--up-border-color);
  border-radius: var(--up-border-radius-medium);
  overflow: hidden;
  transition: box-shadow 0.2s, border-color 0.2s;
}
.card-clickable-area {
  cursor: pointer;
  flex-grow: 1;
  display: flex;
  flex-direction: column;
}
.modal-product-card:hover {
  box-shadow: var(--up-box-shadow-small);
  border-color: var(--up-text-link);
}
.card-image {
  text-align: center;
  padding: 15px;
  min-height: 160px;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: var(--color-white);
}
.card-image img {
  max-width: 100%;
  max-height: 130px;
  object-fit: contain;
}
.card-body-main {
  padding: 15px;
  display: flex;
  flex-direction: column;
  flex-grow: 1;
}
.card-name {
  font-size: var(--font-size-base);
  font-weight: 500;
  line-height: 1.4;
  color: var(--up-text-wd-color);
  min-height: 56px;
  margin-bottom: 10px;
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.card-price {
  font-size: var(--font-size-xl);
  font-weight: 600;
  color: var(--up-color-price, var(--up-text-wd-color));
  margin-bottom: 15px;
}
.product-grid-view .attributes-list {
  list-style: none;
  padding: 0;
  margin: 0 0 15px 0;
  font-size: var(--font-size-sm);
  color: var(--up-text-color);
  border-top: 1px solid var(--up-border-color);
  padding-top: 10px;
}
.product-grid-view .attributes-list li {
  display: flex;
  justify-content: space-between;
  padding: 2px 0;
}
.product-grid-view .attributes-list li span {
  color: var(--up-text-gray-color);
  padding-right: 5px;
}
.product-grid-view .attributes-list li strong {
  font-weight: 600;
  color: var(--up-text-wd-color);
}
.card-footer {
  padding: 0 15px 15px 15px;
  margin-top: auto;
}
.card-footer .btn-add-to-build {
  font-size: var(--font-size-base);
  font-weight: 600;
}
.product-image {
  background-color: var(--color-white, #fff);
  display: flex;
  align-items: center;
  justify-content: center;
}

/* === PRODUCT LIST VIEW (ИЗМЕНЕНО) === */
#modal-product-list.product-list-view .list-group-item {
  display: flex;
  align-items: center;
  gap: 15px;
  background-color: var(--up-bg-main);
  border: 1px solid var(--up-border-color);
  border-radius: var(--up-border-radius-medium);
  margin-bottom: 10px;
  padding: 15px;
  transition: box-shadow 0.2s, border-color 0.2s;
}
#modal-product-list.product-list-view .list-group-item:hover {
  border-color: var(--up-text-link);
  box-shadow: var(--up-box-shadow-small);
}
.list-clickable-area {
  flex-grow: 1;
  display: flex;
  align-items: flex-start;
  gap: 15px;
  cursor: pointer;
  min-width: 0;
}
.list-image-container {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.list-image {
  width: 80px;
  height: 80px;
  padding: 5px;
  border: 1px solid var(--up-border-color);
  border-radius: var(--up-border-radius-small);
  flex-shrink: 0;
  margin-right: 15px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.list-image img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.list-details {
  flex-grow: 1;
  min-width: 0;
}
.list-name {
  font-size: var(--font-size-lg);
  font-weight: 500;
  color: var(--up-text-wd-color);
  margin-bottom: 10px;
  line-height: 1.3;
}
.list-attributes .attributes-list {
  border: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.list-attributes .attributes-list li {
  display: inline-flex;
  align-items: center;
  background-color: var(--up-bg-menu-hover);
  border-radius: 12px;
  padding: 4px 10px;
  font-size: var(--font-size-sm);
  line-height: 1.4;
  white-space: break-spaces;
  border: 1px solid transparent;
}
.list-attributes .attributes-list li span {
  color: var(--up-text-gray-color);
  padding-right: 5px;
}
.list-attributes .attributes-list li strong {
  color: var(--up-text-wd-color);
  font-weight: 500;
}
.list-attributes .attributes-list li .stock-status-badge {
  background-color: transparent;
  padding: 0;
  border-radius: 0;
  font-size: inherit;
  color: var(--up-color-success);
  font-weight: 600;
}
.list-attributes .attributes-list li:has(.stock-status-badge) {
  background-color: rgba(76, 175, 80, 0.1);
  border-color: rgba(76, 175, 80, 0.2);
}
.list-price {
  font-size: var(--font-size-xl);
  font-weight: 500;
  color: var(--up-color-price, var(--up-text-wd-color));
  min-width: 150px;
  text-align: right;
  padding: 0 15px;
}

.list-price.mobile-price {
  display: none;
  font-size: var(--font-size-lg);
  font-weight: 500;
  margin-top: 5px;
  text-align: left;
  padding: 0;
}

@media (max-width: 767px) {
  .list-price.desktop-price {
    display: none;
  }

  .list-price.mobile-price {
    display: block;
  }

  .list-image {
    margin-right: 0;
  }

  .list-attributes .attributes-list {
    margin: 0;
    padding: 0;
    list-style: none;
  }

  .list-attributes .attributes-list li {
    margin-bottom: 4px;
    white-space: normal;
    line-height: 1.4;
  }
  .list-attributes .attributes-list li span {
    color: var(--up-text-gray-color);
    margin-right: 5px;
  }
  .list-attributes .attributes-list li strong {
    color: var(--up-text-wd-color);
  }
  .list-attributes .attributes-list li .stock-status-badge {
    display: inline-block;
    padding: 2px 6px;
    font-size: var(--font-size-xs);
    font-weight: 600;
    border-radius: 4px;
  }
  .list-price {
    font-size: var(--font-size-xl);
    font-weight: 500;
    color: var(--up-text-wd-color);
    min-width: 0px;
    text-align: center;
    padding: 0;
  }
}
.list-action {
  margin-left: auto;
  padding-left: 20px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.list-action .list-price {
  text-align: center;
  margin-bottom: 8px;
  padding: 0;
}

.list-action .btn-add-to-build {
  min-width: 150px;
  font-size: var(--font-size-base);
  font-weight: 600;
}

/* === Product Details Modal Styles (Redesigned) === */
#product-details-modal .modal-content {
  background-color: var(--up-bg-wd, #fff);
  border: 1px solid var(--up-border-color, #e0e0e0);
  box-shadow: var(--up-box-shadow-1px, 0 2px 8px rgba(0, 0, 0, 0.1));
}

#product-details-modal .modal-header {
  background-color: transparent;
  border-bottom: 1px solid var(--up-border-color, #e0e0e0);
  padding: 15px 25px;
}

#product-details-modal .modal-title {
  font-size: var(--font-size-xl);
  font-weight: 600;
  color: var(--up-text-wd-color, #333);
  display: none;
}

#product-details-modal .modal-lg {
  width: 90%;
  max-width: 1100px;
}

#product-details-modal .modal-body {
  padding: 25px 30px;
}

/* Left column (Images) */
.details-image-main {
  margin-bottom: 15px;
  padding: 15px;
  border: 1px solid var(--up-border-color);
  border-radius: var(--up-border-radius-medium);
  min-height: 400px;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: var(--color-white, #fff);
  position: relative;
  overflow: hidden;
}

.details-image-main img {
  max-height: 370px;
  max-width: 100%;
  object-fit: contain;
  transition: transform 0.3s ease;
}

.details-image-main:hover img {
  transform: scale(1.05);
}

.details-image-thumbnails {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.details-image-thumbnails .thumbnail-item {
  width: 80px;
  height: 80px;
  padding: 5px;
  border: 2px solid var(--up-border-color);
  border-radius: var(--up-border-radius-small);
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: var(--color-white, #fff);
}

.details-image-thumbnails .thumbnail-item:hover {
  border-color: var(--up-text-link);
  transform: translateY(-2px);
}
.details-image-thumbnails .thumbnail-item.active {
  border-color: var(--up-text-link);
  box-shadow: 0 0 8px rgba(33, 150, 243, 0.4);
}

.details-image-thumbnails .thumbnail-item img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

/* Right column (Info) */
#details-modal-name {
  font-size: var(--font-size-xxxl);
  font-weight: 700;
  line-height: 1.3;
  margin-top: 0;
  margin-bottom: 10px;
  color: var(--up-text-wd-color);
}

.details-meta {
  display: flex;
  gap: 20px;
  font-size: var(--font-size-sm);
  color: var(--up-text-color);
  margin-bottom: 15px;
  padding-bottom: 15px;
  border-bottom: 1px solid var(--up-border-color);
}
.details-meta strong {
  color: var(--up-text-wd-color);
  font-weight: 500;
}

.details-price {
  font-size: var(--font-size-xxl);
  font-weight: 700;
  color: var(--up-color-price, var(--up-text-wd-color));
  margin-bottom: 20px;
}

.details-actions {
  background-color: var(--up-bg-main);
  padding: 20px;
  border-radius: var(--up-border-radius-medium);
  margin-bottom: 20px;
}

#details-modal-add-btn {
  font-size: var(--font-size-lg);
  font-weight: 600;
  padding: 12px 25px;
  width: 100%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
#details-modal-add-btn .svg-icon-wrapper {
  width: 18px;
  height: 18px;
  margin-right: 8px;
}

.attributes-container {
  margin-top: 20px;
  max-height: 350px;
  overflow-y: auto;
  padding-right: 15px; /* For scrollbar spacing on desktop */
}

@media (max-width: 767px) {
  .attributes-container {
    max-height: none;
    overflow-y: visible;
    padding-right: 0; /* No scrollbar on mobile, so no padding needed */
  }
}

.attributes-container::-webkit-scrollbar {
  width: 6px;
}
.attributes-container::-webkit-scrollbar-track {
  background: transparent;
  margin: 5px 0;
}
.attributes-container::-webkit-scrollbar-thumb {
  background: var(--up-border-color);
  border-radius: 3px;
}
.attributes-container::-webkit-scrollbar-thumb:hover {
  background: var(--up-text-gray-color);
}

.attributes-container .attribute-group {
  margin-bottom: 15px;
}
.attributes-container .attribute-group:last-child {
  margin-bottom: 5px;
}

.attributes-container .attribute-group-name {
  font-size: var(--font-size-lg);
  font-weight: 600;
  padding-bottom: 8px;
  margin-bottom: 12px;
  border-bottom: 1px solid var(--up-border-color);
  color: var(--up-text-wd-color);
}

.attributes-container .attribute-table {
  width: 100%;
  font-size: var(--font-size-base);
  border-collapse: collapse;
}

.attributes-container .attribute-table tr {
  transition: background-color 0.2s ease;
}

.attributes-container .attribute-table tr:hover {
  background-color: var(--up-bg-main);
}

.attributes-container .attribute-table td {
  padding: 10px 8px;
  border-bottom: 1px solid var(--up-border-color);
}

.attributes-container .attribute-table tr:last-child td {
  border-bottom: none;
}

.attributes-container .attribute-table td:first-child {
  width: 45%;
  color: var(--up-text-color);
  font-weight: 400;
}

.attributes-container .attribute-table td:last-child {
  font-weight: 500;
  color: var(--up-text-wd-color);
}

/* === NEW: Summary Cards (Task 2) === */
#summary-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 15px;
  list-style: none;
  padding: 0;
  margin: 0;
}

/* Override old li styles */
#summary-list li {
  display: block;
  padding: 0;
  font-weight: normal;
}
#summary-list li strong {
  font-size: inherit;
  font-weight: normal;
  color: inherit;
}

.summary-card {
  background-color: var(--up-bg-wd);
  border-radius: var(--up-border-radius-medium, 12px);
  padding: 15px 20px;
  display: flex;
  align-items: center;
  gap: 15px;
  border: 1px solid var(--up-border-color);
}

.summary-card-icon {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.summary-card-icon .svg-icon-wrapper {
  width: 22px;
  height: 22px;
  margin: 0;
}

.power-card .svg-icon-wrapper {
  color: #ecc94b;
}

.price-card .svg-icon-wrapper {
  color: #48bb78;
}

.summary-card-icon .svg-icon-wrapper svg {
  stroke-width: 2;
}

.summary-card.power-card .summary-card-icon {
  background-color: rgba(236, 201, 75, 0.15);
  color: #ecc94b;
}

.summary-card.power-card .summary-card-value span {
  color: #ecc94b;
}

.summary-card.price-card .summary-card-icon {
  background-color: rgba(72, 187, 120, 0.15);
  color: #48bb78;
}

.summary-card.price-card .summary-card-value span {
  color: #48bb78;
}

.summary-card-value {
  display: flex;
  flex-direction: column;
  line-height: 1.3;
  overflow: hidden;
}

.summary-card-value span {
  font-size: var(--font-size-xxl);
  font-weight: 700;
  white-space: nowrap;
}

.summary-card-value small {
  font-size: var(--font-size-sm);
  font-weight: 500;
  color: var(--up-text-gray-color);
  text-transform: uppercase;
}

hr {
  border-top: 1px solid var(--up-border-color);
}

/* === ИЗМЕНЕНИЕ НАЧАЛО: Стили для кликабельного названия товара и иконок в сводке === */

/* Стиль для кликабельного названия выбранного товара */
.view-details-link {
  cursor: pointer;
  transition: color 0.2s ease;
}
.view-details-link:hover {
  color: var(--up-text-link, #2196f3);
  text-decoration: underline;
}

/* Стили для списка компонентов в сводке с иконками */
#summary-list-components .summary-item-list li {
  display: flex;
  align-items: center;
  gap: 8px; /* Расстояние между иконкой и текстом */
  padding: 5px 0; /* Увеличенный отступ */
}

#summary-list-components .component-icon .svg-icon-wrapper {
  width: 20px;
  height: 20px;
  color: var(--up-text-gray-color);
  flex-shrink: 0;
  margin-right: 0; /* Убираем правый отступ по умолчанию */
}
/* === ИЗМЕНЕНИЕ КОНЕЦ === */

/* --- ИЗМЕНЕНИЕ НАЧАЛО: Улучшенная анимация добавления в сборку --- */
@keyframes fly-to-target {
  0% {
    transform: scale(1);
    opacity: 1;
  }
  50% {
    opacity: 0.8;
  }
  100% {
    left: var(--target-x);
    top: var(--target-y);
    transform: scale(0.1);
    opacity: 0;
  }
}

.fly-to-cart-clone {
  position: fixed;
  z-index: 9999;
  width: 100px;
  height: 100px;
  border-radius: var(--up-border-radius-medium, 12px);
  background-color: var(--color-white, #fff);
  border: 2px solid var(--up-text-link, #2196f3);
  box-shadow: var(--up-box-shadow-large);
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  padding: 5px;
  transition: left 0.6s cubic-bezier(0.29, 0.53, 0.58, 1),
    top 0.6s cubic-bezier(0.29, 0.53, 0.58, 1);
}

.fly-to-cart-clone.is-flying {
  animation: fly-to-target 0.6s cubic-bezier(0.29, 0.53, 0.58, 1) forwards;
}

.fly-to-cart-clone img,
.fly-to-cart-clone .svg-icon-wrapper {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.fly-to-cart-clone .svg-icon-wrapper {
  width: 50%;
  height: 50%;
  color: var(--up-text-link);
}
/* --- ИЗМЕНЕНИЕ КОНЕЦ --- */

/* === NEW: Power Bar Indicator Styles === */
#summary-power-indicator-container {
  grid-column: 1 / -1; /* Span full width of the grid */
}

.summary-power-indicator {
  background-color: var(--up-bg-wd);
  border: 1px solid var(--up-border-color);
  border-radius: var(--up-border-radius-medium, 12px);
  padding: 15px 20px;
  width: 100%;
}

.power-labels {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
  font-size: var(--font-size-base);
}

.power-label-title {
  font-weight: 600;
  color: var(--up-text-wd-color);
}

.power-label-value {
  font-weight: 500;
  color: var(--up-text-color);
  font-family: monospace; /* For better number alignment */
}

.power-bar-container {
  height: 16px; /* Slightly taller */
  background-color: var(--up-bg-gray);
  border-radius: 8px;
  overflow: hidden;
  width: 100%;
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.1);
}

.power-bar {
  height: 100%;
  border-radius: 8px;
  transition: width 0.5s ease-in-out, background-color 0.5s ease;
}

.power-bar.green {
  background: linear-gradient(to right, #48bb78, #38a169); /* success color */
}

.power-bar.yellow {
  background: linear-gradient(to right, #f6e05e, #ecc94b); /* warning color */
}

.power-bar.red {
  background: linear-gradient(to right, #f56565, #e53e3e); /* danger color */
}

/* Override for the fallback card */
#summary-power-indicator-container .summary-card {
  margin-bottom: 0;
}

/* === NEW START (Task 1): Stock Status Highlight === */
.stock-status-badge {
  font-weight: 600;
  color: var(--up-color-success, #4caf50);
  background-color: rgba(76, 175, 80, 0.1);
  padding: 3px 8px;
  border-radius: var(--up-border-radius-small, 8px);
  font-size: var(--font-size-xs);
}
/* === NEW END === */

/* === FIX START (Task 4): Disabled Button Tooltip on Hover === */
.summary-actions .tooltip-wrapper {
  position: relative;
}
.summary-actions .disabled-tooltip {
  visibility: hidden; /* Hidden by default */
  opacity: 0;
  position: absolute;
  bottom: 115%;
  left: 50%;
  transform: translateX(-50%);
  background-color: var(--up-bg-tooltip, #2d3748);
  color: var(--up-text-tooltip-color, #fff);
  padding: 8px 12px;
  border-radius: var(--up-border-radius-small, 8px);
  font-size: var(--font-size-sm);
  font-weight: 500;
  z-index: 10;
  box-shadow: var(--up-box-shadow-large);
  pointer-events: none;
  transition: opacity 0.2s ease, visibility 0.2s ease;
}

/* Show tooltip on hover of the wrapper *only if* it has the 'has-tooltip' class */
.summary-actions .tooltip-wrapper.has-tooltip:hover .disabled-tooltip {
  visibility: visible;
  opacity: 1;
}

/* Tooltip arrow */
.summary-actions .disabled-tooltip::after {
  content: "";
  position: absolute;
  top: 100%;
  left: 50%;
  margin-left: -6px;
  border-width: 6px;
  border-style: solid;
  border-color: var(--up-bg-tooltip, #2d3748) transparent transparent
    transparent;
}
/* === FIX END === */

/* === NEW (Task 2): Case Image in Summary === */
#summary-case-image-container {
  text-align: center;
  margin-bottom: 15px;
}
.summary-case-title {
  font-size: var(--font-size-lg);
  font-weight: 600;
  color: var(--up-text-wd-color);
  margin-top: 0;
  margin-bottom: 15px;
}
.summary-case-image img {
  max-width: 100%;
  height: auto;
  border-radius: var(--up-border-radius-medium);
}
/* === END NEW === */

/* ==========================================================================
   Responsive Design
   ========================================================================== */

/* --- Main Layout --- */
@media (max-width: 991px) {
  #configurator-app .row > [class*="col-"] {
    width: 100%;
    float: none;
    margin-bottom: 25px;
  }
  #configurator-app .row > [class*="col-"]:last-child {
    margin-bottom: 0;
  }
}

/* --- Stepper --- */
@media (max-width: 767px) {
  .steps-container .list-group {
    margin-left: 5px;
  }
  .list-group-item-wrapper {
    padding-right: 5px;
  }
  .step-main-row {
    flex-direction: column;
    align-items: flex-start;
    padding: 15px;
  }
  .step-visual {
    top: 15px;
  }
  .step-info {
    margin-bottom: 10px;
  }
  .step-action {
    margin-left: 0;
    width: 100%;
  }
  .step-action .choose-product-btn {
    width: 100%;
  }
  .product-details-row {
    flex-wrap: wrap;
    padding: 10px;
    padding-bottom: 0;
    row-gap: 5px;
    align-items: center;
  }
  .product-details-image {
    width: 100%;
    text-align: center;
    margin-bottom: 0;
  }
  .product-details-name {
    flex-basis: 100%;
    margin-bottom: 0;
  }
  .product-details-price {
    text-align: left;
  }
  .quantity-control {
    flex: 1 1 140px;
    margin-right: 10px;
  }
  .product-details-price {
    flex: 0 1 auto;
    margin-right: 10px;
    font-size: var(--font-size-lg);
    white-space: nowrap;
  }
  .remove-product-btn {
    height: 40px;
    width: 40px;
    margin-left: auto;
  }
}

/* --- Modal --- */
@media (max-width: 991px) {
  #product-modal .modal-dialog {
    width: 95%;
    max-width: 900px;
    margin: 15px auto;
  }
  #modal-product-list-container {
    height: calc(100vh - 220px);
  }
  #modal-filters-container {
    height: calc(100vh - 150px);
  }
}

@media (max-width: 767px) {
  #product-modal .modal-dialog {
    margin: 0;
    width: 100%;
  }
  #product-modal .modal-content {
    border-radius: 0;
    min-height: 100vh;
    border: none;
    overflow: hidden;
  }

  #product-modal .modal-body {
    padding: 0;
    overflow-y: auto;
    overflow-x: hidden;
    flex-grow: 1;
  }
  #modal-filters-container {
    padding-top: 20px;
    width: 100%;
    max-width: 100%;
    border-right: none;
  }
  #modal-product-list-container {
    width: 100%;
    height: auto;
  }
  .modal-controls-header {
    flex-direction: column;
    gap: 10px;
  }
  .modal-search-bar,
  .modal-view-options,
  .modal-sort-options {
    width: 100%;
  }
}

/* --- Modal Filters --- */
@media (max-width: 767px) {
  .filter-panel .panel-body {
    padding: 15px;
  }
  .price-filter-inputs {
    display: flex;
    justify-content: space-between;
    gap: 10px;
  }
  .price-filter-inputs .price-filter-separator {
    display: none;
  }
  .price-filter-inputs input {
    width: calc(50% - 5px);
    text-align: center;
  }
}

/* --- Modal Product List --- */
@media (max-width: 575px) {
  #modal-product-list.product-grid-view {
    grid-template-columns: 1fr;
  }

  .list-clickable-area {
    align-items: flex-start;
  }
  .list-image {
    margin-bottom: 10px;
  }
  .list-details {
    width: 100%;
  }
  .list-action {
    margin-top: 10px;
    padding-left: 0;
    width: 100%;
  }
  .list-action .btn {
    width: 100%;
  }
}

/* --- Product Details Modal --- */
@media (max-width: 767px) {
  #product-details-modal .modal-dialog {
    width: 100%;
    margin: 0;
    height: 100%;
  }

  #product-details-modal .modal-content {
    height: 100%;
    border-radius: 0;
    border: none;
  }

  #product-details-modal .modal-body {
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    flex-grow: 1;
    padding: 15px;
  }

  #product-details-modal .details-image-column {
    margin-bottom: 20px;
  }

  #product-details-modal .details-info-column {
    margin-top: 0;
  }

  #details-modal-name {
    font-size: var(--font-size-xl);
  }

  .details-price {
    font-size: var(--font-size-xl);
  }
}

/* --- Burger Menu for Filters --- */
.filter-toggle-btn {
  display: none; /* Hidden by default */
  align-items: center;
  gap: 8px;
  font-weight: 600;
}

@media (max-width: 1439px) {
  .filter-toggle-btn {
    display: flex; /* Показываем кнопку-бургер */
  }

  /* Заставляем тело модалки занимать всю высоту */
  #product-modal .modal-body {
    position: relative;
  }

  #modal-filters-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 350px;
    max-width: 90%;
    height: 100%;
    background-color: var(--up-bg-wd);
    z-index: 1051; /* Выше чем modal-backdrop (1040) и overlay (1045) */

    transform: translateX(-100%);
    visibility: hidden;
    transition: transform 0.35s cubic-bezier(0.25, 0.46, 0.45, 0.94),
      visibility 0s 0.35s;

    box-shadow: none;
    border-right: 1px solid var(--up-border-color);
  }

  #modal-filters-container.open {
    transform: translateX(0);
    visibility: visible;
    transition: transform 0.35s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    box-shadow: 0 5px 25px rgba(0, 0, 0, 0.2);
  }

  /* Продукты занимают всю ширину, т.к. фильтры теперь в отдельном слое */
  #modal-product-list-container {
    width: 100%;
    flex: 0 0 100%;
    max-width: 100%;
  }

  #product-modal .modal-body > .row {
    /* Это предотвратит "схлопывание" ряда, если в нем останется один элемент */
    flex-wrap: nowrap;
    margin-left: 0;
    margin-right: 0;
  }
}

@media (max-width: 767px) {
  #modal-filters-container {
    padding-top: 20px;
  }

  .filter-panel .panel-body {
    padding: 15px;
  }

  .price-filter-inputs {
    display: flex;
    justify-content: space-between;
    gap: 10px;
  }
  .price-filter-inputs .price-filter-separator {
    display: none;
  }
  .price-filter-inputs input {
    width: calc(50% - 5px);
    text-align: center;
  }
}

/* Фильтр-бургер и сайдбар */
#filters-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.4);
  z-index: 1045; /* Ниже панели фильтров, выше остального */
  display: none; /* Скрыто по умолчанию, управляется JS */
}

.filter-toggle-btn {
  display: none;
  position: relative;
  z-index: 10;
}

@media (max-width: 1439px) {
  .filter-toggle-btn {
    display: flex;
  }

  #modal-filters-container {
    position: fixed;
    top: 0;
    left: 0;
    transform: translateX(-105%);
    width: 350px;
    max-width: 90%;
    background-color: var(--up-bg-wd);
    z-index: 1051; /* Выше чем modal-backdrop (1040) и overlay (1045) */
    transition: transform 0.35s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    box-shadow: none;
    border-right: 1px solid var(--up-border-color);
  }

  #modal-filters-container.open {
    transform: translateX(0);
    box-shadow: 0 5px 25px rgba(0, 0, 0, 0.2);
  }

  #modal-product-list-container {
    width: 100%;
    flex: 0 0 100%;
    max-width: 100%;
    padding-left: 15px; /* Сохраняем отступ */
  }

  #product-modal .modal-body > .row {
    flex-wrap: nowrap; /* Предотвращает перенос, если что-то пойдет не так */
  }
}

@media (max-width: 767px) {
  #modal-filters-container {
    padding-top: 20px;
  }
}

@media (min-width: 768px) and (max-width: 1200px) {
  .modal-controls-header {
    flex-wrap: wrap;
    gap: 10px;
  }
  .modal-search-bar {
    flex-basis: 100%;
    order: 1; /* Поиск всегда первый */
  }
  .view-switcher-group {
    order: 2;
  }
  .modal-sort-options {
    flex-grow: 1;
    order: 3;
  }
}

/* === Responsive Filter Panel Fixes === */
@media (min-width: 992px) and (max-width: 1439px) {
  #modal-filters-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 350px;
    max-width: 90%;
    height: 100%;
    background-color: var(--up-bg-wd);
    z-index: 1051;
    transform: translateX(-100%);
    visibility: hidden;
    transition: transform 0.35s cubic-bezier(0.25, 0.46, 0.45, 0.94),
      visibility 0s 0.35s;
    box-shadow: none;
    border-right: 1px solid var(--up-border-color);
    padding-top: 20px;
  }
  #modal-filters-container.open {
    transform: translateX(0);
    visibility: visible;
    transition: transform 0.35s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    box-shadow: 0 5px 25px rgba(0, 0, 0, 0.2);
  }
  #product-modal .modal-body > .row {
    flex-wrap: nowrap;
  }
  #modal-filters-column {
    width: 0;
    padding: 0;
    flex: 0 0 0;
    border: 0;
  }
  #modal-products-column {
    padding: 0;
    width: 100%;
    flex: 0 0 100%;
    max-width: 100%;
  }
}

@media (max-width: 991px) {
  #modal-filters-column {
    height: 0 !important;
  }
  #modal-filters-column,
  #modal-products-column {
    padding: 0;
    width: 100%;
    flex: 0 0 100%;
    max-width: 100%;
  }
  #modal-filters-container {
    border-right: none;
    border-bottom: 1px solid var(--up-border-color);
    margin-bottom: 15px;
  }
  #modal-product-list-container {
    padding-right: 0;
  }
}

@media (max-width: 767px) {
  #product-details-modal .modal-body {
    flex-direction: column;
  }
}

#modal-product-list-wrapper {
  height: 100%;
}
#modal-product-list-container {
  height: 100%;
  overflow-y: auto;
  padding: 15px 15px 50px 15px;
}
#modal-filters-container {
  border-right: 1px solid var(--up-border-color);
}

@media (max-width: 767px) {
  #modal-product-list.product-list-view .list-group-item {
    flex-direction: column;
    align-items: baseline;
  }
  .list-image {
    margin-right: 0;
    margin-bottom: 15px;
  }
  .list-price {
    text-align: left;
    margin-left: 0;
    margin-top: 10px;
  }
  .list-action {
    margin-left: 0;
    margin-top: 15px;
  }
  .list-action .btn {
    width: 100%;
  }
  #modal-filter-toggle {
    width: -webkit-fill-available;
  }
  .modal-search-bar {
    max-width: 100%;
  }
  .modal-sort-options .form-control {
    width: 100%;
  }
  #modal-product-list.product-list-view .list-group-item {
    padding: 10px;
  }

  #product-modal .modal-body > .row,
  #product-modal .modal-body > .row > [class*="col-"] {
    padding: 0;
  }

  #modal-product-list-container {
    padding: 15px;
  }

  /* FIX: Скрываем скроллбар в модальном окне на мобильных устройствах */
  #modal-product-list-container,
  #modal-filters-container {
    -ms-overflow-style: none; /* IE and Edge */
    scrollbar-width: none; /* Firefox */
  }

  #modal-product-list-container::-webkit-scrollbar,
  #modal-filters-container::-webkit-scrollbar {
    display: none; /* Safari and Chrome */
  }
}

/* === FIX: Remove horizontal scroll in mobile modal === */
@media (max-width: 767px) {
  /* Ensure the modal and its key containers don’t create horizontal overflow */
  #product-modal,
  #product-modal .modal-dialog,
  #product-modal .modal-content,
  #product-modal .modal-body,
  #modal-product-list-container,
  #modal-filters-container {
    overflow-x: hidden !important;
  }

  /* Neutralise Bootstrap row negative margins that can cause overflow */
  #product-modal .modal-body > .row {
    margin-left: 0 !important;
    margin-right: 0 !important;
  }
}
