.admin-page-wrapper {
  padding: var(--page-padding);
  background-color: var(--bg-main);
  min-height: 100vh;
}

.admin-container {
  max-width: 1100px;
  margin: 0 auto;
}

.admin-container h1 {
  text-align: left;
  margin-bottom: 30px;
  font-size: 2.2rem;
}

/* Product Control Bar */
.admin-product-control-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 16px 24px;
  margin-bottom: 28px;
  box-shadow: var(--shadow-sm);
  gap: 16px;
  flex-wrap: wrap;
}

.admin-product-status {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.status-label {
  font-size: 0.9rem;
  color: var(--text-secondary);
  font-weight: 500;
}

.mode-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  border-radius: 4px;
  font-size: 0.88rem;
  font-weight: 600;
}

.mode-badge.new-mode {
  background: var(--bg-main);
  color: var(--text-main);
  border: 1px solid var(--border-color);
}

.mode-badge.edit-mode {
  background: rgba(74, 103, 65, 0.12);
  color: var(--stock-available);
  border: 1px solid rgba(74, 103, 65, 0.3);
}

:root.dark-theme .mode-badge.edit-mode {
  background: rgba(134, 163, 123, 0.15);
  color: var(--stock-available);
  border-color: rgba(134, 163, 123, 0.3);
}

.admin-product-bar-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.admin-bar-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  font-size: 0.88rem;
  font-weight: 600;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: var(--font-body);
}

.admin-bar-btn.select-btn {
  background: var(--text-main);
  color: var(--bg-main);
  border: 1px solid var(--text-main);
}

.admin-bar-btn.select-btn:hover {
  opacity: 0.9;
  transform: translateY(-1px);
}

.admin-bar-btn.create-btn {
  background: var(--bg-card);
  color: var(--text-main);
  border: 1px solid var(--border-color);
}

.admin-bar-btn.create-btn:hover {
  background: var(--bg-main);
  border-color: var(--text-main);
}

/* Product Selection Modal */
.product-select-modal-backdrop {
  align-items: center;
  justify-content: center;
  padding: 20px;
  box-sizing: border-box;
}

.product-select-modal-content {
  max-width: 1020px !important;
  width: 95% !important;
  height: 88vh !important;
  max-height: 88vh !important;
  padding: 24px 24px 16px 24px !important;
  display: flex !important;
  flex-direction: column !important;
  text-align: left !important;
  overflow: hidden !important;
  box-sizing: border-box;
  position: relative;
}

.product-modal-header {
  flex: 0 0 auto;
  margin-bottom: 16px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border-color);
}

.product-modal-title {
  font-size: 1.5rem !important;
  margin-bottom: 6px !important;
  color: var(--text-main);
  font-family: var(--font-heading);
  display: flex;
  align-items: center;
  gap: 10px;
}

.product-modal-subtitle {
  font-size: 0.88rem;
  color: var(--text-secondary);
  margin-bottom: 14px;
}

.product-search-wrapper {
  position: relative;
  width: 100%;
}

.product-search-wrapper .search-icon {
  position: absolute;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 0.9rem;
  pointer-events: none;
}

.product-search-input {
  width: 100%;
  padding: 11px 16px 11px 48px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background: var(--bg-main);
  color: var(--text-main);
  font-size: 0.92rem;
  font-family: var(--font-body);
  outline: none;
  transition: border-color 0.2s ease;
}

.product-search-input:focus {
  border-color: var(--text-main);
}

.product-select-grid-container {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  grid-auto-rows: max-content;
  align-content: start;
  gap: 18px;
  overflow-y: auto !important;
  overflow-x: hidden !important;
  flex: 1 1 0px !important;
  min-height: 0 !important;
  height: auto !important;
  padding: 8px 10px 32px 6px;
  scrollbar-width: thin;
  scrollbar-color: var(--border-color) transparent;
  box-sizing: border-box;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  touch-action: pan-y;
}

.product-select-grid-container::-webkit-scrollbar {
  width: 7px;
}

.product-select-grid-container::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 4px;
}

/* Product Card in Modal */
.admin-product-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: all 0.22s ease;
  position: relative;
  height: 100%;
  box-sizing: border-box;
}

.admin-product-card:hover {
  border-color: var(--text-main);
  transform: translateY(-3px);
  box-shadow: var(--shadow-sm);
}

.admin-product-card.active {
  border: 2px solid var(--text-main);
  box-shadow: var(--shadow-sm);
}

.admin-product-card-img-wrap {
  width: 100%;
  aspect-ratio: 4 / 5;
  background: var(--bg-main);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
  border-bottom: 1px solid var(--border-color);
  flex-shrink: 0;
}

.admin-product-card-img-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  padding: 0;
  display: block;
  transition: transform 0.3s ease;
}

.admin-product-card:hover .admin-product-card-img-wrap img {
  transform: scale(1.03);
}

.admin-product-card-img-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.2rem;
  color: var(--text-muted);
}

.card-id-badge {
  position: absolute;
  top: 8px;
  left: 8px;
  background: rgba(0, 0, 0, 0.7);
  color: #ffffff;
  padding: 2px 7px;
  border-radius: 4px;
  font-size: 0.72rem;
  font-weight: 600;
  backdrop-filter: blur(3px);
  z-index: 2;
}

.card-active-badge {
  position: absolute;
  top: 8px;
  right: 8px;
  background: var(--stock-available);
  color: #ffffff;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 0.72rem;
  font-weight: 600;
  z-index: 2;
}

.admin-product-card-body {
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
}

.admin-product-card-title {
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--text-main);
  line-height: 1.35;
  word-break: break-word;
  white-space: normal;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  min-height: 2.5em;
}

.admin-product-card-meta {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 0.8rem;
  color: var(--text-secondary);
  border-top: 1px solid var(--border-light);
  padding-top: 8px;
  margin-top: auto;
}

.admin-product-card-meta-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 6px;
  line-height: 1.35;
}

.admin-product-card-meta .price-val {
  font-weight: 600;
  color: var(--text-main);
}

.admin-product-card-meta .price-val-none {
  color: var(--text-muted);
  font-size: 0.78rem;
}

.admin-product-card-meta .stock-val {
  font-size: 0.78rem;
  color: var(--stock-available);
  font-weight: 500;
}

.admin-product-card-meta .stock-val.out {
  color: var(--accent-red);
}

/* Create New Product Card */
.admin-product-card.create-new {
  border: 2px dashed var(--border-color);
  background: var(--bg-card);
  align-items: center;
  justify-content: center;
  text-align: center;
  min-height: 240px;
  height: 100%;
  padding: 20px 15px;
  box-sizing: border-box;
}

.admin-product-card.create-new:hover {
  border-color: var(--text-main);
  background: var(--bg-main);
}

.admin-product-card.create-new.active {
  border-color: var(--text-main);
  border-style: solid;
}

.create-new-icon-wrap {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--bg-main);
  border: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  color: var(--text-main);
  margin-bottom: 14px;
  transition: all 0.2s ease;
}

.admin-product-card.create-new:hover .create-new-icon-wrap {
  background: var(--text-main);
  color: var(--bg-main);
  transform: scale(1.1);
}

.create-new-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-main);
  margin-bottom: 6px;
}

.create-new-subtitle {
  font-size: 0.78rem;
  color: var(--text-secondary);
  line-height: 1.35;
}

.product-select-empty {
  grid-column: 1 / -1;
  text-align: center;
  padding: 40px 20px;
  color: var(--text-secondary);
}

.product-select-empty i {
  font-size: 2.5rem;
  color: var(--text-muted);
  margin-bottom: 12px;
}

.admin-grid {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 30px;
}

@media (max-width: 768px) {
  .product-select-modal-content {
    width: 96% !important;
    height: 92vh !important;
    max-height: 92vh !important;
    padding: 20px 16px 14px 16px !important;
  }

  .product-select-grid-container {
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 12px;
    padding: 6px 6px 28px 6px;
  }

  .admin-product-card-body {
    padding: 10px;
  }

  .admin-product-card-title {
    font-size: 0.86rem;
  }

  .admin-grid {
    grid-template-columns: 1fr;
  }

  .admin-page-wrapper {
    padding: 100px 4% 60px 4%;
  }

  .admin-container h1 {
    font-size: 1.8rem;
  }

  .admin-card {
    padding: 20px 15px;
  }

  .form-row {
    flex-direction: column;
    gap: 15px;
  }

  .admin-actions {
    flex-direction: column;
    align-items: stretch;
    gap: 25px;
  }

  .display-site-toggle {
    align-items: flex-start;
  }

  .display-site-toggle label {
    line-height: 1.4;
    font-size: 0.9rem;
  }

  .admin-actions > div:last-child {
    flex-direction: column;
    width: 100%;
    gap: 12px !important;
  }

  .save-product-btn {
    width: 100%;
    padding: 16px 20px;
  }
}

.admin-card {
  background: var(--bg-card);
  padding: 30px;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  margin-bottom: 30px;
  border: 1px solid var(--border-light);
}

.admin-card h3 {
  font-family: var(--font-body);
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 25px;
  padding-bottom: 15px;
  border-bottom: 1px solid var(--border-light);
  color: var(--text-main);
}

.form-group {
  margin-bottom: 20px;
}

.form-row {
  display: flex;
  gap: 20px;
}

.form-row .form-group {
  flex: 1;
}

label {
  display: block;
  margin-bottom: 8px;
  font-family: var(--font-body);
  font-weight: 500;
  font-size: 0.9rem;
  color: var(--text-secondary);
}

.required {
  color: var(--accent-red);
}

input[type="text"],
input[type="number"],
textarea,
.custom-select {
  width: 100%;
  padding: 12px 15px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: 0.95rem;
  color: var(--text-main);
  background-color: var(--bg-main);
  transition: all 0.3s ease;
}

input[type="text"]:focus,
input[type="number"]:focus,
textarea:focus,
.custom-select:focus {
  outline: none;
  border-color: var(--text-main);
  background-color: var(--bg-card);
  box-shadow: 0 0 0 3px rgba(17, 17, 17, 0.05);
}

textarea {
  height: 140px;
  resize: vertical;
}

.form-group-checkboxes {
  margin-bottom: 25px;
}

.group-label {
  margin-bottom: 12px;
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.checkbox-row label {
  margin-bottom: 0;
  cursor: pointer;
  color: var(--text-main);
}

.checkbox-row input[type="checkbox"] {
  cursor: pointer;
  width: 18px;
  height: 18px;
  accent-color: var(--text-main);
}

.file-upload-wrapper {
  position: relative;
  margin-bottom: 10px;
}

.file-input {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

.file-upload-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 30px;
  border: 2px dashed var(--border-color);
  border-radius: var(--radius-md);
  background-color: var(--bg-main);
  cursor: pointer;
  transition: all 0.3s ease;
}

.file-upload-box:hover {
  border-color: var(--text-main);
  background-color: var(--border-light);
}

.upload-icon {
  font-size: 2rem;
  color: var(--text-secondary);
  margin-bottom: 10px;
}

.upload-text {
  font-size: 0.9rem;
  color: var(--text-main);
  font-family: var(--font-body);
}

.file-hint {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 5px;
}

.image-preview-container {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 15px;
}

.preview-item {
  position: relative;
  width: 90px;
  height: 90px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 2px solid var(--border-color);
  cursor: pointer;
  transition: all 0.3s ease;
}

.preview-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.preview-item.main-image {
  border-color: var(--text-main);
  box-shadow: var(--shadow-md);
}

.preview-item.main-image::after {
  content: "Головна";
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  background: rgba(17, 17, 17, 0.85);
  color: var(--bg-card);
  font-size: 0.65rem;
  text-align: center;
  padding: 3px 0;
  font-family: var(--font-body);
  font-weight: 500;
}

.admin-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 20px;
  padding-top: 20px;
  border-top: 1px solid var(--border-color);
}

.display-site-toggle {
  margin-bottom: 0;
}

.save-product-btn {
  background: var(--text-main);
  color: var(--bg-card);
  border: none;
  padding: 14px 30px;
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.3s ease;
  letter-spacing: 1px;
  text-transform: uppercase;
}

.save-product-btn:hover {
  background: var(--text-secondary);
  box-shadow: var(--shadow-sm);
}

.mt-3 {
  margin-top: 20px;
}

.btn-delete {
  background-color: var(--accent-red);
  border-color: var(--accent-red);
}
.btn-delete:hover {
  background-color: #a30000;
}

.help-text-preview {
  width: 100%;
  font-size: 0.85rem;
  color: var(--accent-red);
  margin-top: 10px;
}

/* Hero Images Draggable List & Blur Deletion */
.hero-preview-item {
  position: relative;
  width: 150px;
  height: 150px;
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 2px solid var(--border-color);
  cursor: grab;
  transition: all 0.25s ease;
  user-select: none;
}

.hero-preview-item:active {
  cursor: grabbing;
}

.hero-preview-item.dragging {
  opacity: 0.4;
  transform: scale(0.95);
  border: 2px dashed var(--text-main);
}

.hero-preview-item.drag-over {
  border-color: var(--text-main);
  transform: scale(1.05);
  box-shadow: var(--shadow-md);
}

.hero-preview-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition:
    filter 0.3s ease,
    transform 0.3s ease;
}

.hero-delete-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(194, 48, 48, 0.45);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: all 0.25s ease;
  z-index: 5;
}

.hero-delete-overlay i {
  font-size: 3.5rem;
  color: #ffffff;
  filter: drop-shadow(0 2px 8px rgba(0, 0, 0, 0.4));
  transform: scale(0.7);
  transition: transform 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

/* Marked for deletion state */
.hero-preview-item.marked-delete .hero-preview-image {
  filter: blur(8px) grayscale(40%);
  transform: scale(0.95);
}

.hero-preview-item.marked-delete .hero-delete-overlay {
  opacity: 1;
  visibility: visible;
}

.hero-preview-item.marked-delete .hero-delete-overlay i {
  transform: scale(1);
}

/* Dynamic Size & Stock Manager in Admin */
.form-hint-text {
  font-size: 0.82rem;
  color: var(--text-secondary);
  margin-bottom: 16px;
  line-height: 1.4;
}

.size-rows-container {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 12px;
}

.size-stock-row {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  background: var(--bg-main);
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
}

.size-field-group {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.size-field-group.stock-field-group {
  flex: 0 0 130px;
}

.size-field-label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  font-weight: 500;
}

.size-name-input,
.size-stock-input {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  color: var(--text-main);
  font-size: 0.88rem;
  font-family: var(--font-body);
}

.size-remove-btn {
  background: transparent;
  border: none;
  color: var(--accent-red);
  cursor: pointer;
  padding: 9px 10px;
  font-size: 0.95rem;
  border-radius: var(--radius-sm);
  transition: background 0.2s ease, transform 0.2s ease;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.size-remove-btn:hover {
  background: rgba(194, 48, 48, 0.12);
  transform: scale(1.08);
}

.size-actions-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 10px;
  padding-bottom: 12px;
}

.admin-btn-secondary {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  font-size: 0.82rem;
  font-weight: 600;
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  color: var(--text-main);
  border: 1px solid var(--border-color);
  cursor: pointer;
  transition: all 0.2s ease;
}

.admin-btn-secondary:hover {
  background: var(--text-main);
  color: var(--bg-card);
}

.total-stock-summary {
  font-size: 0.88rem;
  color: var(--text-secondary);
}

.total-stock-summary strong {
  color: var(--text-main);
}

.quick-sizes-wrapper {
  margin-top: 10px;
  padding-top: 12px;
  border-top: 1px solid var(--border-light);
}

.quick-sizes-label {
  font-size: 0.76rem;
  color: var(--text-muted);
  display: block;
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.quick-sizes-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.quick-size-btn {
  background: var(--bg-main);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  font-size: 0.76rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

.quick-size-btn:hover {
  background: var(--text-main);
  color: var(--bg-card);
}

.admin-product-card-sizes {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 6px;
  padding-top: 4px;
  border-top: 1px dashed var(--border-light);
}

.admin-size-badge {
  font-size: 0.7rem;
  padding: 2px 6px;
  border-radius: 3px;
  background: var(--bg-main);
  color: var(--text-secondary);
  border: 1px solid var(--border-color);
}

.admin-size-badge.out {
  opacity: 0.45;
  text-decoration: line-through;
}
