/* Reset and Base Styles */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  line-height: 1.6;
  color: #1d1d1f;
  background-color: #f5f5f7;
  overflow-x: hidden;
}

/* Admin Header */
.admin-header {
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid rgba(0, 0, 0, 0.1);
  position: sticky;
  top: 0;
  z-index: 1000;
}

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

.header-left {
  display: flex;
  align-items: center;
  gap: 2rem;
}

.back-link {
  color: #007aff;
  text-decoration: none;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  transition: color 0.3s ease;
}

.back-link:hover {
  color: #0056b3;
}

.header-left h1 {
  font-size: 1.8rem;
  font-weight: 700;
  color: #1d1d1f;
}

.save-btn {
  background: #007aff;
  color: white;
  border: none;
  padding: 12px 24px;
  border-radius: 10px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.save-btn:hover {
  background: #0056b3;
  transform: translateY(-2px);
}

/* Main Content */
.admin-main {
  min-height: calc(100vh - 70px);
}

.admin-container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 20px;
  display: grid;
  grid-template-columns: 300px 1fr;
  gap: 2rem;
}

/* Sidebar */
.admin-sidebar {
  background: white;
  border-radius: 20px;
  padding: 2rem;
  height: fit-content;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.1);
  border: 1px solid rgba(0, 0, 0, 0.05);
}

.sidebar-section {
  margin-bottom: 2rem;
}

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

.sidebar-section h3 {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 1rem;
  color: #1d1d1f;
  border-bottom: 2px solid #f0f0f0;
  padding-bottom: 0.5rem;
}

.sidebar-btn {
  width: 100%;
  padding: 12px 16px;
  border: 2px solid transparent;
  border-radius: 10px;
  background: #f8f9fa;
  color: #1d1d1f;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.3s ease;
  margin-bottom: 0.75rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.sidebar-btn:hover {
  background: #e9ecef;
  transform: translateY(-2px);
}

.sidebar-btn.primary {
  background: #007aff;
  color: white;
}

.sidebar-btn.primary:hover {
  background: #0056b3;
}

.stat-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 0;
  border-bottom: 1px solid #f0f0f0;
}

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

.stat-label {
  color: #6c757d;
  font-size: 0.9rem;
}

.stat-value {
  font-weight: 700;
  color: #007aff;
  font-size: 1.1rem;
}

.file-input-group {
  margin-bottom: 1rem;
}

.file-label {
  display: block;
  color: #6c757d;
  font-size: 0.9rem;
  margin-bottom: 0.5rem;
  cursor: pointer;
}

.file-input {
  width: 100%;
  padding: 8px;
  border: 2px solid #e9ecef;
  border-radius: 8px;
  font-size: 0.9rem;
}

/* Main Content Area */
.admin-content {
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

/* Product Form Section */
.product-form-section {
  background: white;
  border-radius: 20px;
  padding: 2rem;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.1);
  border: 1px solid rgba(0, 0, 0, 0.05);
}

.form-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2rem;
  padding-bottom: 1rem;
  border-bottom: 2px solid #f0f0f0;
}

.form-header h2 {
  font-size: 1.5rem;
  font-weight: 700;
  color: #1d1d1f;
}

.cancel-btn {
  background: #6c757d;
  color: white;
  border: none;
  padding: 8px 16px;
  border-radius: 8px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.cancel-btn:hover {
  background: #5a6268;
}

.product-form {
  width: 100%;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  margin-bottom: 2rem;
}

.form-group.full-width {
  grid-column: 1 / -1;
}

.form-group label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: 600;
  color: #1d1d1f;
}

.form-group input,
.form-group textarea,
.form-group select {
  width: 100%;
  padding: 12px 16px;
  border: 2px solid #e9ecef;
  border-radius: 10px;
  font-size: 1rem;
  transition: border-color 0.3s ease;
  background: white;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
  outline: none;
  border-color: #007aff;
}

.link-input-group {
  display: flex;
  gap: 0.75rem;
  align-items: center;
}

.link-input-group input[type="url"] {
  flex: 2;
}

.supplier-input {
  flex: 1;
  min-width: 120px;
}

.price-input {
  position: relative;
  display: flex;
  align-items: center;
}

.currency {
  position: absolute;
  left: 16px;
  color: #6c757d;
  font-weight: 500;
}

.price-input input {
  padding-left: 2.5rem;
}

.image-preview {
  margin-top: 1rem;
  width: 100%;
  height: 120px;
  background: #f8f9fa;
  border: 2px dashed #dee2e6;
  border-radius: 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: #6c757d;
  font-size: 0.9rem;
}

.image-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 8px;
}

.image-preview i {
  font-size: 2rem;
  margin-bottom: 0.5rem;
}

.form-actions {
  text-align: right;
}

.submit-btn {
  background: #007aff;
  color: white;
  border: none;
  padding: 16px 32px;
  border-radius: 10px;
  font-weight: 600;
  font-size: 1rem;
  cursor: pointer;
  transition: all 0.3s ease;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.submit-btn:hover {
  background: #0056b3;
  transform: translateY(-2px);
}

/* Products List Section */
.products-list-section {
  background: white;
  border-radius: 20px;
  padding: 2rem;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.1);
  border: 1px solid rgba(0, 0, 0, 0.05);
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2rem;
  padding-bottom: 1rem;
  border-bottom: 2px solid #f0f0f0;
}

.section-header h2 {
  font-size: 1.5rem;
  font-weight: 700;
  color: #1d1d1f;
}

.list-controls {
  display: flex;
  gap: 1rem;
  align-items: center;
}

.search-input,
.category-filter {
  padding: 8px 16px;
  border: 2px solid #e9ecef;
  border-radius: 8px;
  font-size: 0.9rem;
  transition: border-color 0.3s ease;
}

.search-input:focus,
.category-filter:focus {
  outline: none;
  border-color: #007aff;
}

.products-table-container {
  overflow-x: auto;
}

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

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

.products-table th {
  background: #f8f9fa;
  font-weight: 600;
  color: #1d1d1f;
  position: sticky;
  top: 0;
}

.products-table td {
  vertical-align: middle;
}

.product-image-cell {
  width: 80px;
}

.product-image-cell img {
  width: 60px;
  height: 60px;
  object-fit: cover;
  border-radius: 8px;
}

.product-image-cell .placeholder {
  width: 60px;
  height: 60px;
  background: #f8f9fa;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #6c757d;
}

.product-name {
  font-weight: 600;
  color: #1d1d1f;
  max-width: 200px;
}

.product-description {
  color: #6c757d;
  max-width: 300px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.product-price {
  font-weight: 700;
  color: #007aff;
}

.product-category {
  padding: 4px 12px;
  background: #e9ecef;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 500;
  color: #6c757d;
  text-transform: capitalize;
}

.action-buttons {
  display: flex;
  gap: 0.5rem;
}

.action-btn {
  padding: 6px 12px;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.3s ease;
  font-size: 0.8rem;
  font-weight: 500;
}

.edit-btn {
  background: #007aff;
  color: white;
}

.edit-btn:hover {
  background: #0056b3;
}

.delete-btn {
  background: #dc3545;
  color: white;
}

.delete-btn:hover {
  background: #c82333;
}

/* JSON Output Section */
.json-output-section {
  background: white;
  border-radius: 20px;
  padding: 2rem;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.1);
  border: 1px solid rgba(0, 0, 0, 0.05);
}

.json-output-section .section-header {
  margin-bottom: 1rem;
}

.copy-btn {
  background: #28a745;
  color: white;
  border: none;
  padding: 8px 16px;
  border-radius: 8px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.copy-btn:hover {
  background: #218838;
}

#output {
  width: 100%;
  height: 300px;
  padding: 1rem;
  border: 2px solid #e9ecef;
  border-radius: 10px;
  font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
  font-size: 0.9rem;
  line-height: 1.5;
  resize: vertical;
  background: #f8f9fa;
}

/* Modal */
.modal {
  display: none;
  position: fixed;
  z-index: 2000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(5px);
}

.modal-content {
  background-color: white;
  margin: 5% auto;
  border-radius: 20px;
  width: 90%;
  max-width: 500px;
  position: relative;
  animation: modalSlideIn 0.3s ease;
}

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

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

.modal-header h3 {
  font-size: 1.3rem;
  font-weight: 600;
  color: #1d1d1f;
}

.close {
  font-size: 1.5rem;
  cursor: pointer;
  color: #6c757d;
  transition: color 0.3s ease;
}

.close:hover {
  color: #1d1d1f;
}

.modal-body {
  padding: 1.5rem 2rem;
}

.modal-body p {
  color: #6c757d;
  margin-bottom: 1.5rem;
}

.import-options {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.import-option {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.modal-footer {
  padding: 1rem 2rem 2rem;
  display: flex;
  gap: 1rem;
  justify-content: flex-end;
}

.btn {
  padding: 12px 24px;
  border: none;
  border-radius: 8px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.3s ease;
}

.btn.primary {
  background: #007aff;
  color: white;
}

.btn.primary:hover {
  background: #0056b3;
}

.btn.secondary {
  background: #6c757d;
  color: white;
}

.btn.secondary:hover {
  background: #5a6268;
}

/* Toast */
.toast {
  position: fixed;
  top: 20px;
  right: 20px;
  padding: 1rem 1.5rem;
  border-radius: 10px;
  color: white;
  font-weight: 500;
  z-index: 3000;
  transform: translateX(400px);
  transition: transform 0.3s ease;
}

.toast.show {
  transform: translateX(0);
}

.toast.success {
  background: #28a745;
}

.toast.error {
  background: #dc3545;
}

/* Responsive Design */
@media (max-width: 1200px) {
  .admin-container {
    grid-template-columns: 1fr;
  }
  
  .admin-sidebar {
    order: 2;
  }
  
  .admin-content {
    order: 1;
  }
}

@media (max-width: 768px) {
  .header-container {
    padding: 0 15px;
  }
  
  .header-left h1 {
    font-size: 1.5rem;
  }
  
  .admin-container {
    padding: 15px;
  }
  
  .form-grid {
    grid-template-columns: 1fr;
  }
  
  .section-header {
    flex-direction: column;
    gap: 1rem;
    align-items: flex-start;
  }
  
  .list-controls {
    width: 100%;
    flex-direction: column;
  }
  
  .search-input,
  .category-filter {
    width: 100%;
  }
  
  .products-table {
    font-size: 0.8rem;
  }
  
  .products-table th,
  .products-table td {
    padding: 0.75rem 0.5rem;
  }
  
  .action-buttons {
    flex-direction: column;
  }
}

@media (max-width: 480px) {
  .header-left {
    gap: 1rem;
  }
  
  .header-left h1 {
    font-size: 1.3rem;
  }
  
  .save-btn {
    padding: 10px 16px;
    font-size: 0.9rem;
  }
  
  .admin-container {
    padding: 10px;
  }
  
  .product-form-section,
  .products-list-section,
  .json-output-section {
    padding: 1.5rem;
  }
}
