/* Product Management Component Styles */

/* Grid Layout for Product List */
.inventory-grid {
  display: grid;
  grid-template-columns: 80px 120px 1fr 140px 200px 80px;
  align-items: center;
  gap: 16px;
}

.inventory-grid > div {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Responsive Grid Adjustments */
@media (max-width: 1024px) {
  .inventory-grid {
    grid-template-columns: 80px 120px 1fr 140px 80px;
  }
}

@media (max-width: 768px) {
  .inventory-grid {
    grid-template-columns: 80px 1fr 120px 80px;
  }
}

/* Product Image Styles */
.product-image-container {
  position: relative;
  width: 48px;
  height: 48px;
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid #e9ecef;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: #f8f9fa;
}

.product-image {
  width: 32px;
  height: 32px;
  object-fit: contain;
}

.no-image-placeholder {
  font-size: 10px;
  font-weight: 600;
  color: #6c757d;
  text-align: center;
  line-height: 1.2;
}

/* Product Details Panel */
.product-details-panel {
  background-color: white;
  border: 1px solid #e9ecef;
  border-radius: 8px;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.08);
  margin: 16px 0;
  overflow: hidden;
}

/* Large Product Image in Details */
.product-image-large {
  width: 176px;
  height: 176px;
  border: 1px solid #e9ecef;
  border-radius: 8px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: #f8f9fa;
  margin-bottom: 16px;
}

.product-image-large img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.no-image-large {
  font-size: 18px;
  font-weight: 600;
  color: #6c757d;
}

/* Product Dialog Styles */
.product-dialog-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  backdrop-filter: blur(3px);
}

.product-dialog-content {
  background-color: white;
  border-radius: 12px;
  padding: 32px;
  width: 100%;
  max-width: 600px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.15);
  animation: slideUp 0.3s ease;
}

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

.dialog-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
}

.dialog-title {
  font-size: 24px;
  font-weight: 600;
  color: #495057;
}

.close-button {
  background: none;
  border: none;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #6c757d;
  transition: all 0.2s ease;

  &:hover {
    background-color: #f8f9fa;
    color: #495057;
  }
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 32px;
  padding-top: 24px;
  border-top: 1px solid #e9ecef;
}

/* Flash Messages */
.flash-message {
  display: flex;
  align-items: center;
  padding: 8px 16px;
  border-radius: 6px;
  margin-right: 16px;
  font-size: 14px;
  font-weight: 500;

  &.success {
    background-color: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
  }

  &.error {
    background-color: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
  }

  .icon {
    margin-right: 8px;
  }
}

/* Form Field Customizations */
.mat-mdc-form-field {
  &.w-full {
    width: 100%;
  }
  
  &.flex-1 {
    flex: 1;
  }
}

/* File Upload Styling */
input[type="file"] {
  padding: 8px;
  border: 2px dashed #ced4da;
  border-radius: 6px;
  background-color: #f8f9fa;
  cursor: pointer;
  transition: all 0.2s ease;
  width: 100%;

  &:hover {
    border-color: #1976d2;
    background-color: #f0f7ff;
  }
}

/* Loading Animation for Spinner Icons */
.animate-spin {
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* Button Hover Effects */
.mat-mdc-raised-button,
.mat-mdc-flat-button {
  transition: all 0.2s ease;

  &:hover:not([disabled]) {
    transform: translateY(-1px);
    box-shadow: 0 4px 10px rgba(25, 118, 210, 0.3);
  }
}

/* Product Row Hover Effect */
.inventory-grid:not(.sticky) {
  transition: background-color 0.2s ease;

  &:hover {
    background-color: rgba(0, 0, 0, 0.02);
  }
}

/* Details Toggle Button */
button[mat-stroked-button] {
  border-radius: 6px;
  transition: all 0.2s ease;

  &:hover {
    background-color: rgba(25, 118, 210, 0.05);
    border-color: #1976d2;
  }
}

/* Empty State Styling */
.empty-state {
  text-align: center;
  padding: 80px 20px;
  color: #6c757d;

  .empty-icon {
    width: 64px;
    height: 64px;
    margin: 0 auto 16px;
    opacity: 0.3;
  }

  h3 {
    font-size: 24px;
    margin-bottom: 8px;
    color: #495057;
  }

  p {
    font-size: 16px;
    margin-bottom: 24px;
  }
}

/* Responsive Design */
@media (max-width: 768px) {
  .product-dialog-content {
    margin: 16px;
    max-width: calc(100% - 32px);
    padding: 24px;
  }

  .dialog-title {
    font-size: 20px;
  }

  /* Stack form fields on mobile */
  .flex.gap-4 {
    flex-direction: column;
    gap: 0;
  }
}

/* Dark Mode Support */
:host-context(.dark) {
  .product-dialog-content {
    background-color: #2d3748;
    color: #e2e8f0;
  }

  .dialog-title {
    color: #e2e8f0;
  }

  .close-button {
    color: #a0aec0;

    &:hover {
      background-color: #4a5568;
      color: #e2e8f0;
    }
  }

  input[type="file"] {
    background-color: #4a5568;
    border-color: #718096;
    color: #e2e8f0;

    &:hover {
      border-color: #63b3ed;
      background-color: #2d3748;
    }
  }

  .flash-message {
    &.success {
      background-color: rgba(72, 187, 120, 0.2);
      color: #68d391;
      border-color: rgba(72, 187, 120, 0.3);
    }

    &.error {
      background-color: rgba(245, 101, 101, 0.2);
      color: #fc8181;
      border-color: rgba(245, 101, 101, 0.3);
    }
  }

  .inventory-grid:not(.sticky):hover {
    background-color: rgba(255, 255, 255, 0.05);
  }
}

/* Material Design Overrides */
.mat-mdc-paginator {
  border-radius: 8px;
}

.mat-mdc-form-field-subscript-wrapper {
  margin-top: 0.25rem;
}

/* Custom scrollbar for dialog */
.product-dialog-content::-webkit-scrollbar {
  width: 6px;
}

.product-dialog-content::-webkit-scrollbar-track {
  background: #f1f1f1;
  border-radius: 3px;
}

.product-dialog-content::-webkit-scrollbar-thumb {
  background: #c1c1c1;
  border-radius: 3px;

  &:hover {
    background: #a8a8a8;
  }
}