/* ============================================================
   EDIT PRODUCT MODAL - Professional Design
   ============================================================ */

/* PIM style layout */
body[data-page="product-edit"] .product-edit-page {
  padding: 32px clamp(20px, 4vw, 64px) 56px;
  background: linear-gradient(180deg, #f6f9ff 0%, #fdfefe 90%);
}

.product-edit-shell {
  display: flex;
  flex-direction: column;
  gap: 32px;
  width: 100%;
  max-width: min(1680px, calc(100% - 48px));
  margin: 0 auto;
}

.product-edit-header {
  background: #ffffff;
  border-radius: 24px;
  padding: clamp(24px, 3vw, 40px);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  position: sticky;
  top: calc(var(--topbar-height, 72px) + 16px);
  z-index: 15;
  border: 1px solid rgba(148, 163, 184, 0.25);
  box-shadow: 0 18px 50px -30px rgba(15, 23, 42, 0.45);
}

.product-edit-header-info {
  display: flex;
  gap: 20px;
  align-items: center;
}

.product-edit-header-icon {
  width: 64px;
  height: 64px;
  border-radius: 18px;
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.1), rgba(14, 165, 233, 0.2));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  color: #2563eb;
}

.product-edit-eyebrow {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin: 0 0 6px 0;
  color: #94a3b8;
}

.product-edit-header h1 {
  font-size: 32px;
  margin: 0 0 8px 0;
  color: #0f172a;
}

.product-edit-subtitle {
  margin: 0;
  font-size: 15px;
  color: #475569;
}

.product-edit-header-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.product-edit-header-actions .btn {
  min-width: 170px;
  border-radius: 999px;
  font-weight: 600;
}

.product-edit-body {
  display: flex;
  gap: 32px;
  align-items: flex-start;
  width: 100%;
}

.product-edit-sidebar {
  flex: 0 0 260px;
  position: sticky;
  top: calc(var(--topbar-height, 72px) + 150px);
  background: #fefefe;
  border: 1px solid rgba(226, 232, 240, 0.9);
  border-radius: 22px;
  padding: 24px;
  box-shadow: 0 12px 45px -32px rgba(15, 23, 42, 0.6);
}

.sidebar-title {
  font-weight: 600;
  margin-bottom: 16px;
  text-transform: uppercase;
  font-size: 12px;
  letter-spacing: 0.08em;
  color: var(--text-muted, #94a3b8);
}

.product-edit-nav {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.product-edit-nav-item {
  width: 100%;
  border: 1px solid transparent;
  border-radius: 16px;
  padding: 14px 16px;
  background: transparent;
  display: flex;
  gap: 12px;
  align-items: flex-start;
  cursor: pointer;
  transition: background 0.2s, border 0.2s, transform 0.2s;
  color: var(--text-primary, #0f172a);
}

.product-edit-nav-item span {
  font-weight: 700;
  font-size: 14px;
  color: #64748b;
  margin-top: 2px;
}

.product-edit-nav-item small {
  display: block;
  font-size: 12px;
  color: #94a3b8;
}

.product-edit-nav-item.active {
  border-color: rgba(59, 130, 246, 0.7);
  background: rgba(59, 130, 246, 0.08);
  color: #1d4ed8;
  transform: translateX(3px);
}

.product-edit-nav-item:not(.active):hover {
  border-color: rgba(148, 163, 184, 0.4);
  background: rgba(248, 250, 252, 0.75);
}

.product-edit-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 32px;
  min-width: 0;
}

.product-edit-section {
  display: none;
  scroll-margin-top: 140px;
}

.product-edit-section.active {
  display: block;
}

.product-edit-section .tab-content {
  display: none;
  background: #fff;
  border: 1px solid rgba(226, 232, 240, 0.9);
  border-radius: 24px;
  padding: clamp(20px, 3vw, 36px);
  box-shadow: 0 20px 60px -45px rgba(15, 23, 42, 0.65);
  backdrop-filter: blur(2px);
}

.product-edit-section .tab-content.active {
  display: block;
}

.product-edit-section .tab-section + .tab-section {
  margin-top: 24px;
}

.product-edit-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  background: #fff;
  border: 1px solid rgba(226, 232, 240, 0.9);
  border-radius: 22px;
  padding: 20px clamp(16px, 3vw, 36px);
  box-shadow: 0 15px 40px -35px rgba(15, 23, 42, 0.45);
  position: sticky;
  bottom: 24px;
  margin-top: 16px;
}

.footer-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

@media (max-width: 1024px) {
  .product-edit-body {
    flex-direction: column;
  }

  .product-edit-sidebar {
    position: relative;
    top: 0;
  }

  .product-edit-sidebar {
    width: 100%;
  }

  .product-edit-footer {
    position: static;
  }
}

@media (max-width: 640px) {
  body[data-page="product-edit"] .product-edit-page {
    padding: 16px;
  }

  .product-edit-header {
    position: static;
  }

  .product-edit-header-actions {
    width: 100%;
  }
}

.product-breadcrumbs {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
  font-size: 14px;
  flex-wrap: wrap;
  color: #64748b;
}

.product-breadcrumbs {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
  font-size: 14px;
  flex-wrap: wrap;
}

.product-breadcrumbs .breadcrumb-link {
  background: transparent;
  border: none;
  color: #0b6bff;
  font-weight: 600;
  cursor: pointer;
}

.product-breadcrumbs .breadcrumb-separator {
  color: #9ca3af;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

/* Modal Container */
.edit-product-modal {
  animation: slideUp 0.3s ease;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
}

@keyframes slideUp {
  from {
    transform: translateY(50px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

/* Modal Header with Gradient */
.modal-header-gradient {
  background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%) !important;
  color: white !important;
  padding: 2rem;
  border-radius: 1rem 1rem 0 0;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}

.modal-header-content {
  display: flex;
  gap: 1.5rem;
  align-items: center;
}

.modal-header-icon {
  width: 60px;
  height: 60px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.75rem;
  backdrop-filter: blur(10px);
}

.modal-header-text {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.modal-title {
  font-size: 1.75rem;
  font-weight: 700;
  margin: 0;
  color: white;
}

.modal-subtitle {
  font-size: 0.95rem;
  margin: 0;
  color: rgba(255, 255, 255, 0.9);
  font-weight: 400;
}

.modal-close-modern {
  background: rgba(255, 255, 255, 0.2);
  border: none;
  width: 40px;
  height: 40px;
  border-radius: 0.5rem;
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  transition: all 0.2s ease;
  backdrop-filter: blur(10px);
}

.modal-close-modern:hover {
  background: rgba(255, 255, 255, 0.3);
  transform: rotate(90deg);
}

/* Modal Tabs */
.modal-tabs {
  display: flex;
  background: var(--card-bg);
  border-bottom: 2px solid var(--border-color);
  padding: 0 2rem;
  gap: 0.5rem;
  overflow-x: auto;
  scrollbar-width: thin;
}

.modal-tabs::-webkit-scrollbar {
  height: 4px;
}

.modal-tabs::-webkit-scrollbar-thumb {
  background: var(--primary);
  border-radius: 2px;
}

.modal-tab {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 1rem 1.5rem;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  border-bottom: 3px solid transparent;
  transition: all 0.2s ease;
  white-space: nowrap;
  position: relative;
}

.modal-tab i {
  font-size: 1rem;
}

.modal-tab:hover {
  color: var(--primary);
  background: var(--hover-bg);
}

.modal-tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
  font-weight: 600;
}

.modal-tab.active::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--primary);
  animation: slideInTab 0.3s ease;
}

@keyframes slideInTab {
  from {
    transform: scaleX(0);
  }
  to {
    transform: scaleX(1);
  }
}

/* Modal Body with Tabs */
.modal-body-tabs {
  flex: 1;
  overflow-y: auto;
  padding: 0;
  scrollbar-width: thin;
}

.modal-body-tabs::-webkit-scrollbar {
  width: 8px;
}

.modal-body-tabs::-webkit-scrollbar-track {
  background: var(--hover-bg);
}

.modal-body-tabs::-webkit-scrollbar-thumb {
  background: var(--primary);
  border-radius: 4px;
}

.modal-body-tabs::-webkit-scrollbar-thumb:hover {
  background: #4f46e5;
}

/* Tab Content */
.tab-content {
  display: none;
  padding: 2rem;
  animation: fadeInTab 0.3s ease;
}

.tab-content.active {
  display: block;
}

@keyframes fadeInTab {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Tab Sections */
.tab-section {
  margin-bottom: 2.5rem;
}

.tab-section:last-child {
  margin-bottom: 0;
}

.tab-section-title {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: .5rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding-bottom: 0.75rem;
  border-bottom: 2px solid var(--border-color);
}

.tab-section-title i {
  color: var(--primary);
  font-size: 1.25rem;
}

/* Enhanced Form Grid */
.form-grid {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 1.5rem;
}

.form-group {
  grid-column: span 12;
}

.span-full { grid-column: span 12; }
.span-6 { grid-column: span 6; }
.span-4 { grid-column: span 4; }
.span-3 { grid-column: span 3; }
.span-2 { grid-column: span 2; }

/* Form Controls Enhanced */
.form-control-lg {
  font-size: 1.1rem;
  padding: 0.875rem 1rem;
  font-weight: 500;
}

.form-label {
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 0.5rem;
  display: block;
  font-size: 0.9rem;
}

.form-label.required::after {
  content: '*';
  color: var(--danger);
  margin-left: 0.25rem;
}

.form-hint {
  display: block;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 0.375rem;
  font-style: italic;
}

/* Input with Icon */
.input-with-icon {
  position: relative;
  display: flex;
  align-items: center;
}

.input-with-icon .input-icon {
  position: absolute;
  left: 1rem;
  color: var(--text-muted);
  font-size: 1rem;
  pointer-events: none;
  z-index: 1;
}

.input-with-icon .form-control {
  padding-left: 2.75rem;
}

/* Currency Input */
.input-currency {
  position: relative;
}

.currency-symbol {
  position: absolute;
  left: 1rem;
  top: 50%;
  transform: translateY(-50%);
  font-weight: 600;
  color: var(--text-secondary);
  font-size: 1rem;
  z-index: 1;
}

.input-currency .form-control {
  padding-left: 3rem;
  text-align: right;
  font-weight: 600;
  font-size: 1.1rem;
}

/* Stat Box */
.stat-box {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  color: white;
  padding: 1.25rem;
  border-radius: 0.75rem;
  text-align: center;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.2);
}

.stat-value {
  font-size: 1.75rem;
  font-weight: 700;
  margin-bottom: 0.25rem;
}

.stat-label {
  font-size: 0.8rem;
  opacity: 0.9;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Image Upload Area */
.image-upload-area {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.image-upload-dropzone {
  border: 2px dashed var(--border-color);
  border-radius: 1rem;
  padding: 3rem 2rem;
  text-align: center;
  cursor: pointer;
  transition: all 0.3s ease;
  background: #ffffff !important;
}

.image-upload-dropzone:hover {
  border-color: var(--primary);
  background: rgba(99, 102, 241, 0.05);
}

.image-upload-dropzone.dragover {
  border-color: var(--primary);
  background: rgba(99, 102, 241, 0.1);
  transform: scale(1.02);
}

.image-upload-dropzone i {
  font-size: 3rem;
  color: var(--primary);
  margin-bottom: 1rem;
  display: block;
}

.image-upload-dropzone p {
  font-size: 1rem;
  color: var(--text-primary);
  margin-bottom: 0.5rem;
}

.image-upload-dropzone small {
  color: var(--text-muted);
  font-size: 0.85rem;
}

/* Image Preview Grid */
.image-preview-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 1rem;
}

.image-preview-item {
  position: relative;
  aspect-ratio: 1;
  border-radius: 0.75rem;
  overflow: hidden;
  border: 2px solid var(--border-color);
  background: var(--hover-bg);
}

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

.image-preview-item .remove-image-btn {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(239, 68, 68, 0.9);
  color: white;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: all 0.2s ease;
  backdrop-filter: blur(4px);
}

.image-preview-item:hover .remove-image-btn {
  opacity: 1;
}

.image-preview-item .remove-image-btn:hover {
  background: #dc2626;
  transform: scale(1.1);
}

.image-preview-item .primary-badge {
  position: absolute;
  bottom: 0.5rem;
  left: 0.5rem;
  background: rgba(16, 185, 129, 0.9);
  color: white;
  padding: 0.25rem 0.75rem;
  border-radius: 0.25rem;
  font-size: 0.75rem;
  font-weight: 600;
  backdrop-filter: blur(4px);
}

/* Info Grid */
.info-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 1.5rem;
  background: var(--hover-bg);
  padding: 1.5rem;
  border-radius: 0.75rem;
  border: 1px solid var(--border-color);
}

.info-item {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
}

.info-item label {
  font-size: 0.8rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 600;
}

.info-item span {
  font-size: 0.95rem;
  color: var(--text-primary);
  font-weight: 500;
}

/* Modal Footer Enhanced */
.modal-footer-enhanced {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.5rem 2rem;
  background: var(--hover-bg);
  border-top: 1px solid var(--border-color);
  gap: 1rem;
  flex-wrap: wrap;
}

.modal-footer-left,
.modal-footer-right {
  display: flex;
  gap: 0.75rem;
  align-items: center;
}

.btn-lg {
  padding: 0.875rem 2rem;
  font-size: 1rem;
  font-weight: 600;
}

.btn-outline-danger {
  background: transparent;
  color: var(--danger);
  border: 2px solid var(--danger);
}

.btn-outline-danger:hover {
  background: var(--danger);
  color: white;
}

/* Select Enhancement */
optgroup {
  font-weight: 600;
  color: var(--text-primary);
  font-style: normal;
}

optgroup option {
  font-weight: 400;
  padding-left: 1rem;
}

/* Responsive */
@media (max-width: 1200px) {
  .span-4 {
    grid-column: span 6;
  }
}

@media (max-width: 768px) {
  .edit-product-modal {
    max-height: 95vh;
    margin: 1rem;
  }

  .modal-header-gradient {
    padding: 1.5rem;
  }

  .modal-header-icon {
    width: 50px;
    height: 50px;
    font-size: 1.5rem;
  }

  .modal-title {
    font-size: 1.5rem;
  }

  .modal-subtitle {
    font-size: 0.85rem;
  }

  .modal-tabs {
    padding: 0 1rem;
  }

  .modal-tab {
    padding: 0.875rem 1rem;
    font-size: 0.85rem;
  }

  .modal-tab span {
    display: none;
  }

  .modal-tab i {
    font-size: 1.25rem;
  }

  .tab-content {
    padding: 1.5rem;
  }

  .span-6,
  .span-4,
  .span-3,
  .span-2 {
    grid-column: span 12;
  }

  .modal-footer-enhanced {
    flex-direction: column;
    align-items: stretch;
  }

  .modal-footer-left,
  .modal-footer-right {
    width: 100%;
    flex-direction: column;
  }

  .modal-footer-left button,
  .modal-footer-right button {
    width: 100%;
  }

  .image-preview-grid {
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  }
}

/* Dark Mode Adjustments */
@media (prefers-color-scheme: dark) {
  .modal-header-gradient {
    background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
  }

  .stat-box {
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
  }
}

/* Loading State */
.form-control:disabled,
.form-select:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  background: var(--hover-bg);
}

/* Success State */
.form-control.is-valid {
  border-color: #10b981;
}

.form-control.is-invalid {
  border-color: var(--danger);
}

/* Animations */
@keyframes pulse {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.5;
  }
}

.loading-pulse {
  animation: pulse 1.5s ease-in-out infinite;
}

/* ========================================
   VARIATIONS TABLE
   ======================================== */
.variations-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 1rem;
}

.variations-table thead {
  background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
  color: white;
}

.variations-table th {
  padding: 0.875rem 1rem;
  text-align: left;
  font-weight: 600;
  font-size: 0.875rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.variations-table tbody tr {
  border-bottom: 1px solid #e5e7eb;
  transition: background-color 0.2s ease;
}

.variations-table tbody tr:hover {
  background-color: #f9fafb;
}

.variations-table td {
  padding: 0.875rem 1rem;
  font-size: 0.9375rem;
}

.variations-table td code {
  background: #f3f4f6;
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  font-family: 'Monaco', 'Courier New', monospace;
  font-size: 0.875rem;
  color: #4f46e5;
}

.variations-table .badge {
  padding: 0.25rem 0.75rem;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
}

.variations-table .badge-success {
  background: #10b981;
  color: white;
}

.variations-table .table-responsive {
  overflow-x: auto;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

#variationsContainer,
#noVariationsMessage {
  margin-top: 1rem;
}

.size-badge {
  display: inline-block;
  padding: 0.25rem 0.5rem;
  margin: 0.125rem;
  background: #e0e7ff;
  color: #4f46e5;
  border-radius: 4px;
  font-size: 0.8125rem;
  font-weight: 600;
}

