* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background-color: #f5f5f5;
  color: #333;
  line-height: 1.6;
}

.header {
  background-color: #1976d2;
  color: white;
  padding: 1rem 0;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.header-content {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.header h1 {
  font-size: 1.5rem;
  font-weight: 600;
}

.user-info {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.user-info span {
  font-size: 0.9rem;
}

.main-content {
  max-width: 1200px;
  margin: 2rem auto;
  padding: 0 20px;
}

.products-section,
.documents-section {
  background: white;
  padding: 2rem;
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
  margin-bottom: 2rem;
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
}

.section-header h2 {
  margin: 0;
  color: #1976d2;
}

.bulk-actions {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.selected-count {
  color: #757575;
  font-size: 0.9rem;
}

.documents-section h2 {
  margin-bottom: 1rem;
  color: #1976d2;
}

.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 1rem;
  margin-top: 1.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid #e0e0e0;
}

#page-info {
  color: #757575;
  font-size: 0.95rem;
}

.search-bar {
  display: flex;
  gap: 1rem;
}

.search-bar input {
  flex: 1;
  padding: 0.75rem;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 1rem;
}

.search-bar input:focus {
  outline: none;
  border-color: #1976d2;
}

.btn {
  padding: 0.75rem 1.5rem;
  border: none;
  border-radius: 4px;
  font-size: 1rem;
  cursor: pointer;
  transition: background-color 0.2s;
}

.btn-primary {
  background-color: #1976d2;
  color: white;
}

.btn-primary:hover {
  background-color: #1565c0;
}

.btn-secondary {
  background-color: #757575;
  color: white;
}

.btn-secondary:hover {
  background-color: #616161;
}

.btn-success {
  background-color: #388e3c;
  color: white;
  padding: 0.5rem 1rem;
  font-size: 0.9rem;
}

.btn-success:hover {
  background-color: #2e7d32;
}

.btn-danger {
  background-color: #d32f2f;
  color: white;
  padding: 0.5rem 1rem;
  font-size: 0.9rem;
}

.btn-danger:hover {
  background-color: #c62828;
}

.btn-view {
  background-color: #0288d1;
  color: white;
  padding: 0.5rem 1rem;
  font-size: 0.9rem;
  text-decoration: none;
  display: inline-block;
}

.btn-view:hover {
  background-color: #0277bd;
}

.loading {
  text-align: center;
  padding: 2rem;
}

.spinner {
  border: 4px solid #f3f3f3;
  border-top: 4px solid #1976d2;
  border-radius: 50%;
  width: 40px;
  height: 40px;
  animation: spin 1s linear infinite;
  margin: 0 auto 1rem;
}

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

.no-results {
  text-align: center;
  padding: 2rem;
  color: #757575;
}

.products-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 1rem;
}

.products-table th,
.products-table td {
  padding: 0.75rem;
  text-align: left;
  border-bottom: 1px solid #ddd;
}

.products-table th {
  background-color: #f5f5f5;
  font-weight: 600;
  color: #1976d2;
}

.products-table tr:hover {
  background-color: #f9f9f9;
}

.products-table td {
  font-size: 0.9rem;
}

.actions {
  display: flex;
  gap: 0.5rem;
}

.badge {
  display: inline-block;
  padding: 0.25rem 0.75rem;
  border-radius: 12px;
  font-size: 0.85rem;
  font-weight: 500;
}

.badge-success {
  background-color: #c8e6c9;
  color: #2e7d32;
}

.badge-none {
  background-color: #ffecb3;
  color: #f57f17;
}

/* Document icons */
.document-icons {
  font-size: 1.2rem;
}

.document-icons i {
  margin-right: 0.5rem;
  color: #1976d2;
}

/* Small buttons for individual documents */
.btn-sm {
  padding: 0.35rem 0.75rem;
  font-size: 0.85rem;
}

/* Files table in upload modal */
#files-table-container {
  margin: 1.5rem 0;
}

#files-table-container h4 {
  margin-bottom: 0.75rem;
  color: #1976d2;
  font-size: 1rem;
}

.files-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.files-table th,
.files-table td {
  padding: 0.5rem;
  text-align: left;
  border-bottom: 1px solid #e0e0e0;
}

.files-table th {
  background-color: #f5f5f5;
  font-weight: 600;
  color: #333;
}

.files-table select {
  width: 100%;
  padding: 0.5rem;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 0.9rem;
}

.files-table .btn-remove {
  background-color: #d32f2f;
  color: white;
  border: none;
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.85rem;
}

.files-table .btn-remove:hover {
  background-color: #c62828;
}

/* Source products list in copy modal */
#source-products-container {
  margin-top: 1rem;
}

#source-products-container h4 {
  margin-bottom: 0.75rem;
  color: #1976d2;
  font-size: 0.95rem;
}

#source-products-list {
  max-height: 300px;
  overflow-y: auto;
  border: 1px solid #e0e0e0;
  border-radius: 4px;
}

.source-product-item {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid #e0e0e0;
  cursor: pointer;
  transition: background-color 0.2s;
}

.source-product-item:last-child {
  border-bottom: none;
}

.source-product-item:hover {
  background-color: #f5f5f5;
}

.source-product-item h5 {
  margin: 0 0 0.25rem 0;
  font-size: 0.95rem;
  color: #333;
}

.source-product-item p {
  margin: 0;
  font-size: 0.85rem;
  color: #757575;
}

.source-product-item .doc-count {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  margin-top: 0.5rem;
  padding: 0.25rem 0.5rem;
  background-color: #e3f2fd;
  color: #1976d2;
  border-radius: 12px;
  font-size: 0.8rem;
  font-weight: 500;
}

/* Modal */
.modal {
  display: none;
  position: fixed;
  z-index: 1000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0,0,0,0.5);
  animation: fadeIn 0.2s;
}

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

.modal.active {
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-content {
  background-color: white;
  border-radius: 8px;
  width: 90%;
  max-width: 500px;
  max-height: 90vh;
  overflow-y: auto;
  animation: slideIn 0.3s;
}

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

.modal-header {
  padding: 1.5rem;
  border-bottom: 1px solid #ddd;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-header h2 {
  color: #1976d2;
  font-size: 1.25rem;
}

.modal-close {
  background: none;
  border: none;
  font-size: 2rem;
  cursor: pointer;
  color: #757575;
  line-height: 1;
}

.modal-close:hover {
  color: #333;
}

.modal-body {
  padding: 1.5rem;
}

.modal-body p {
  margin: 0;
  line-height: 1.6;
}

.modal-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid #e0e0e0;
  display: flex;
  gap: 1rem;
  justify-content: flex-end;
}

.modal-small {
  max-width: 400px;
}

.form-group {
  margin-bottom: 1.5rem;
}

.form-group label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: 500;
  color: #333;
}

.form-group input[type="text"],
.form-group input[type="file"],
.form-group select {
  width: 100%;
  padding: 0.75rem;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 1rem;
}

.form-group input[type="text"]:read-only {
  background-color: #f5f5f5;
}

.form-group small {
  display: block;
  margin-top: 0.25rem;
  color: #757575;
  font-size: 0.85rem;
}

.form-actions {
  display: flex;
  gap: 1rem;
  margin-top: 1.5rem;
}

.error-message {
  background-color: #ffebee;
  color: #c62828;
  padding: 0.75rem;
  border-radius: 4px;
  margin-bottom: 1rem;
}

.progress-bar {
  width: 100%;
  height: 4px;
  background-color: #e0e0e0;
  border-radius: 2px;
  overflow: hidden;
  margin: 1rem 0;
}

.progress-fill {
  height: 100%;
  background-color: #1976d2;
  width: 0%;
  animation: progress 2s ease-in-out infinite;
}

@keyframes progress {
  0% { width: 0%; }
  50% { width: 100%; }
  100% { width: 0%; }
}

/* Toast */
.toast {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  background-color: #323232;
  color: white;
  padding: 1rem 1.5rem;
  border-radius: 4px;
  box-shadow: 0 4px 8px rgba(0,0,0,0.2);
  display: none;
  animation: slideUp 0.3s;
  z-index: 2000;
}

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

.toast.success {
  background-color: #388e3c;
}

.toast.error {
  background-color: #d32f2f;
}

.toast.show {
  display: block;
}

/* Responsive */
@media (max-width: 768px) {
  .header-content {
    flex-direction: column;
    gap: 1rem;
  }

  .search-bar {
    flex-direction: column;
  }

  .products-table {
    font-size: 0.85rem;
  }

  .actions {
    flex-direction: column;
  }

  .modal-content {
    width: 95%;
  }
}
