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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen,
    Ubuntu, Cantarell, sans-serif;
  background-color: #f5f5f0;
  color: #333;
  line-height: 1.6;
}

.app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.header {
  background: linear-gradient(135deg, #2d5a27 0%, #4a7c45 100%);
  color: white;
  padding: 2rem;
  text-align: center;
}

.header h1 {
  font-size: 2.5rem;
  margin-bottom: 0.5rem;
}

.header p {
  font-size: 1.1rem;
  opacity: 0.9;
}

.main {
  flex: 1;
  max-width: 1200px;
  margin: 0 auto;
  padding: 2rem;
  width: 100%;
}

/* Search Styles */
.search-container {
  margin-bottom: 1.5rem;
}

.search-box {
  display: flex;
  align-items: center;
  background: white;
  border: 2px solid #e8e8e0;
  border-radius: 30px;
  padding: 0.5rem 1rem;
  max-width: 500px;
  margin: 0 auto;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.search-box:focus-within {
  border-color: #4a7c45;
  box-shadow: 0 2px 8px rgba(74, 124, 69, 0.15);
}

.search-icon {
  font-size: 1.2rem;
  margin-right: 0.75rem;
  opacity: 0.6;
}

.search-input {
  flex: 1;
  border: none;
  outline: none;
  font-size: 1rem;
  padding: 0.5rem 0;
  background: transparent;
}

.search-input::placeholder {
  color: #999;
}

.clear-search {
  background: #e8e8e0;
  border: none;
  border-radius: 50%;
  width: 24px;
  height: 24px;
  font-size: 0.8rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #666;
  transition: background 0.2s ease;
}

.clear-search:hover {
  background: #d0d0c8;
}

.search-results-count {
  text-align: center;
  color: #666;
  margin-bottom: 1rem;
  font-size: 0.95rem;
}

.category-filter {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 2rem;
  justify-content: center;
  align-items: flex-start;
}

.category-group {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.category-btn {
  padding: 0.75rem 1.5rem;
  border: 2px solid #4a7c45;
  background: white;
  color: #4a7c45;
  border-radius: 25px;
  cursor: pointer;
  font-size: 1rem;
  font-weight: 500;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.category-btn:hover {
  background: #f0f7ef;
}

.category-btn.active {
  background: #4a7c45;
  color: white;
}

.category-btn.expanded {
  border-bottom-left-radius: 10px;
  border-bottom-right-radius: 10px;
}

.expand-icon {
  font-size: 0.7rem;
  margin-left: 0.25rem;
}

.subcategory-list {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  margin-top: 0.25rem;
  padding: 0.5rem;
  background: #f5f5f0;
  border-radius: 10px;
  min-width: 100%;
}

.subcategory-btn {
  padding: 0.5rem 1rem;
  border: 1px solid #4a7c45;
  background: white;
  color: #4a7c45;
  border-radius: 15px;
  cursor: pointer;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  transition: all 0.2s ease;
}

.subcategory-btn:hover {
  background: #f0f7ef;
}

.subcategory-btn.active {
  background: #4a7c45;
  color: white;
}

.subcategory-group {
  display: flex;
  flex-direction: column;
}

.subsubcategory-list {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  margin-left: 1rem;
  margin-top: 0.25rem;
  padding: 0.4rem;
  background: #e8e8e0;
  border-radius: 8px;
}

.subsubcategory-btn {
  padding: 0.4rem 0.8rem;
  border: 1px solid #6a9c65;
  background: white;
  color: #4a7c45;
  border-radius: 12px;
  cursor: pointer;
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  transition: all 0.2s ease;
}

.subsubcategory-btn:hover {
  background: #f0f7ef;
}

.subsubcategory-btn.active {
  background: #6a9c65;
  color: white;
}

.category-icon {
  font-size: 1.2rem;
}

.product-list {
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

.category-section {
  background: white;
  border-radius: 12px;
  padding: 1.5rem;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.category-title {
  font-size: 1.5rem;
  color: #2d5a27;
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 2px solid #e8e8e0;
}

.products-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.5rem;
}

.product-card {
  background: #fafaf8;
  border-radius: 10px;
  border: 1px solid #e8e8e0;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  overflow: hidden;
}

.product-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.product-card.out-of-stock {
  opacity: 0.6;
}

.product-image {
  width: 100%;
  height: 180px;
  overflow: hidden;
  background: #e8e8e0;
}

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

.product-image.placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  color: #999;
  font-size: 0.9rem;
}

/* Image Carousel */
.product-image-carousel {
  position: relative;
  width: 100%;
  height: 180px;
  overflow: hidden;
  background: #e8e8e0;
}

.carousel-container {
  width: 100%;
  height: 100%;
}

.carousel-container img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.carousel-btn {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(0, 0, 0, 0.5);
  color: white;
  border: none;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  font-size: 1.2rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.product-card:hover .carousel-btn {
  opacity: 1;
}

.carousel-btn.prev {
  left: 8px;
}

.carousel-btn.next {
  right: 8px;
}

.carousel-btn:hover {
  background: rgba(0, 0, 0, 0.7);
}

.carousel-dots {
  position: absolute;
  bottom: 8px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 6px;
}

.carousel-dots .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.5);
  border: none;
  cursor: pointer;
  padding: 0;
  transition: background 0.2s ease;
}

.carousel-dots .dot.active {
  background: white;
}

.carousel-dots .dot:hover {
  background: rgba(255, 255, 255, 0.8);
}

.product-image-carousel {
  cursor: pointer;
}

.image-zoom-hint {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(0, 0, 0, 0.6);
  color: white;
  padding: 0.5rem 1rem;
  border-radius: 20px;
  font-size: 0.85rem;
  opacity: 0;
  transition: opacity 0.2s ease;
  pointer-events: none;
}

.product-image-carousel:hover .image-zoom-hint {
  opacity: 1;
}

/* Image Modal */
.image-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.95);
  z-index: 2000;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.modal-close-btn {
  position: absolute;
  top: 1rem;
  right: 1rem;
  background: none;
  border: none;
  color: white;
  font-size: 2.5rem;
  cursor: pointer;
  z-index: 2001;
  opacity: 0.7;
  transition: opacity 0.2s ease;
}

.modal-close-btn:hover {
  opacity: 1;
}

.image-modal-content {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  position: relative;
  padding: 1rem;
}

.modal-image-container {
  max-width: 90%;
  max-height: 70vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-image-container img {
  max-width: 100%;
  max-height: 70vh;
  object-fit: contain;
  border-radius: 8px;
}

.modal-nav-btn {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(255, 255, 255, 0.1);
  color: white;
  border: none;
  width: 50px;
  height: 50px;
  border-radius: 50%;
  font-size: 2rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s ease;
}

.modal-nav-btn:hover {
  background: rgba(255, 255, 255, 0.2);
}

.modal-nav-btn.prev {
  left: 2rem;
}

.modal-nav-btn.next {
  right: 2rem;
}

.modal-footer {
  padding: 1rem 2rem 2rem;
  text-align: center;
  width: 100%;
}

.modal-product-name {
  color: white;
  font-size: 1.2rem;
  margin-bottom: 1rem;
}

.modal-thumbnails {
  display: flex;
  justify-content: center;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
  flex-wrap: wrap;
  max-width: 100%;
  overflow-x: auto;
  padding: 0.5rem;
}

.modal-thumbnail {
  width: 60px;
  height: 60px;
  border: 2px solid transparent;
  border-radius: 6px;
  overflow: hidden;
  cursor: pointer;
  padding: 0;
  background: none;
  opacity: 0.5;
  transition: opacity 0.2s ease, border-color 0.2s ease;
}

.modal-thumbnail:hover {
  opacity: 0.8;
}

.modal-thumbnail.active {
  border-color: white;
  opacity: 1;
}

.modal-thumbnail img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.modal-counter {
  color: rgba(255, 255, 255, 0.6);
  font-size: 0.9rem;
  margin: 0;
}

@media (max-width: 768px) {
  .modal-nav-btn {
    width: 40px;
    height: 40px;
    font-size: 1.5rem;
  }

  .modal-nav-btn.prev {
    left: 0.5rem;
  }

  .modal-nav-btn.next {
    right: 0.5rem;
  }

  .modal-thumbnail {
    width: 50px;
    height: 50px;
  }
}

.product-info {
  padding: 1.25rem;
}

.product-name {
  font-size: 1.2rem;
  color: #333;
  margin-bottom: 0.5rem;
}

.product-description {
  color: #666;
  font-size: 0.9rem;
  margin-bottom: 1rem;
}

.product-price {
  margin-bottom: 0.75rem;
}

.price {
  font-size: 1.4rem;
  font-weight: 700;
  color: #2d5a27;
}

.unit {
  font-size: 0.9rem;
  color: #888;
}

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

.stock-status.in-stock {
  background: #e8f5e9;
  color: #2e7d32;
}

.stock-status.no-stock {
  background: #ffebee;
  color: #c62828;
}

.no-products {
  text-align: center;
  color: #666;
  padding: 3rem;
  font-size: 1.1rem;
}

.footer {
  background: #333;
  color: white;
  text-align: center;
  padding: 1.5rem;
  margin-top: auto;
}

/* Admin Button */
.admin-toggle {
  position: absolute;
  top: 1rem;
  right: 1rem;
  padding: 0.5rem 1rem;
  background: rgba(255, 255, 255, 0.2);
  border: 1px solid white;
  color: white;
  border-radius: 5px;
  cursor: pointer;
  font-size: 0.9rem;
  transition: background 0.2s;
}

.admin-toggle:hover {
  background: rgba(255, 255, 255, 0.3);
}

.header {
  position: relative;
}

/* Admin Panel Styles */
.admin-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
  padding: 1rem;
}

.admin-panel {
  background: white;
  border-radius: 12px;
  width: 100%;
  max-width: 900px;
  max-height: 90vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.admin-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.5rem;
  background: #2d5a27;
  color: white;
}

.admin-header h2 {
  margin: 0;
}

.admin-header-buttons {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.close-btn {
  background: none;
  border: none;
  color: white;
  font-size: 1.2rem;
  cursor: pointer;
  padding: 0.25rem 0.5rem;
}

.logout-btn {
  background: rgba(255, 255, 255, 0.2);
  border: 1px solid white;
  color: white;
  padding: 0.4rem 0.8rem;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.85rem;
}

.logout-btn:hover {
  background: rgba(255, 255, 255, 0.3);
}

/* Login Panel */
.login-panel {
  background: white;
  border-radius: 12px;
  width: 100%;
  max-width: 400px;
  overflow: hidden;
}

.login-form {
  padding: 2rem;
}

.login-error {
  background: #ffebee;
  color: #c62828;
  padding: 0.75rem;
  border-radius: 5px;
  margin-bottom: 1rem;
  text-align: center;
}

.login-btn {
  width: 100%;
  padding: 0.75rem;
  background: #4a7c45;
  color: white;
  border: none;
  border-radius: 5px;
  font-size: 1rem;
  cursor: pointer;
  margin-top: 1rem;
}

.login-btn:hover {
  background: #2d5a27;
}

.admin-toolbar {
  padding: 1rem 1.5rem;
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid #e8e8e0;
}

.add-btn {
  padding: 0.75rem 1.5rem;
  background: #4a7c45;
  color: white;
  border: none;
  border-radius: 5px;
  cursor: pointer;
  font-size: 1rem;
}

.add-btn:hover {
  background: #2d5a27;
}

.admin-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
}

.admin-search {
  position: relative;
  display: flex;
  align-items: center;
}

.admin-search input {
  padding: 0.5rem 2rem 0.5rem 0.75rem;
  border: 1px solid #ccc;
  border-radius: 5px;
  font-size: 0.9rem;
  width: 200px;
}

.admin-search input:focus {
  outline: none;
  border-color: #4a7c45;
}

.clear-search-btn {
  position: absolute;
  right: 0.5rem;
  background: none;
  border: none;
  font-size: 1.1rem;
  color: #999;
  cursor: pointer;
  padding: 0;
}

.clear-search-btn:hover {
  color: #333;
}

.admin-filter-select {
  padding: 0.5rem 0.75rem;
  border: 1px solid #ccc;
  border-radius: 5px;
  font-size: 0.9rem;
  background: white;
  cursor: pointer;
}

.admin-filter-select:focus {
  outline: none;
  border-color: #4a7c45;
}

.admin-results-info {
  padding: 0.5rem 1.5rem;
  font-size: 0.85rem;
  color: #666;
  background: #f9f9f7;
}

.admin-table-container {
  overflow-x: auto;
  padding: 0 1.5rem 1.5rem;
  flex: 1;
  overflow-y: auto;
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
}

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

.admin-table th {
  background: #f5f5f0;
  font-weight: 600;
}

.stock-yes {
  color: #2e7d32;
}

.stock-no {
  color: #c62828;
}

.table-images {
  position: relative;
  display: inline-block;
}

.table-image {
  width: 50px;
  height: 50px;
  object-fit: cover;
  border-radius: 5px;
}

.image-count {
  position: absolute;
  bottom: -2px;
  right: -2px;
  background: #4a7c45;
  color: white;
  font-size: 0.65rem;
  padding: 1px 4px;
  border-radius: 8px;
}

.no-image {
  color: #999;
}

/* Image Upload Styles */
.image-upload-container {
  margin-bottom: 1rem;
}

.image-upload-box {
  border: 2px dashed #ccc;
  border-radius: 8px;
  padding: 2rem;
  text-align: center;
  position: relative;
}

.image-upload-box input[type="file"] {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}

.upload-label {
  color: #666;
  cursor: pointer;
}

.image-preview {
  position: relative;
  display: inline-block;
}

.image-preview img {
  max-width: 200px;
  max-height: 150px;
  border-radius: 8px;
  border: 1px solid #e8e8e0;
}

.remove-image-btn {
  position: absolute;
  top: -8px;
  right: -8px;
  background: #c62828;
  color: white;
  border: none;
  border-radius: 50%;
  width: 24px;
  height: 24px;
  font-size: 0.7rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Multiple Image Upload */
.multi-image-upload {
  margin-bottom: 0.5rem;
}

.images-preview-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
}

.image-preview-item {
  position: relative;
  width: 80px;
  height: 80px;
  border-radius: 8px;
  overflow: hidden;
  border: 2px solid #e8e8e0;
}

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

.image-preview-item .image-actions {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  justify-content: center;
  gap: 2px;
  padding: 2px;
  opacity: 0;
  transition: opacity 0.2s ease;
}

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

.image-preview-item .image-actions button {
  background: rgba(255, 255, 255, 0.2);
  border: none;
  color: white;
  width: 20px;
  height: 20px;
  font-size: 0.75rem;
  cursor: pointer;
  border-radius: 3px;
}

.image-preview-item .image-actions button:hover {
  background: rgba(255, 255, 255, 0.4);
}

.image-preview-item .image-actions .remove-btn {
  background: rgba(198, 40, 40, 0.8);
}

.image-preview-item .main-badge {
  position: absolute;
  top: 4px;
  left: 4px;
  background: #4a7c45;
  color: white;
  font-size: 0.6rem;
  padding: 2px 6px;
  border-radius: 4px;
}

.image-upload-box-small {
  width: 80px;
  height: 80px;
  border: 2px dashed #ccc;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  cursor: pointer;
}

.image-upload-box-small:hover {
  border-color: #4a7c45;
}

.image-upload-box-small input[type="file"] {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}

.upload-label-small {
  font-size: 2rem;
  color: #ccc;
  pointer-events: none;
}

.image-upload-box-small:hover .upload-label-small {
  color: #4a7c45;
}

.upload-hint {
  font-size: 0.8rem;
  color: #888;
  margin: 0;
}

.edit-btn,
.delete-btn {
  padding: 0.4rem 0.8rem;
  margin-right: 0.5rem;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.85rem;
}

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

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

/* Visibility Toggle */
.visibility-btn {
  background: none;
  border: 1px solid #ccc;
  border-radius: 4px;
  padding: 0.3rem 0.5rem;
  cursor: pointer;
  font-size: 1rem;
  transition: all 0.2s ease;
}

.visibility-btn.visible {
  background: #e8f5e9;
  border-color: #4a7c45;
}

.visibility-btn.hidden {
  background: #ffebee;
  border-color: #c62828;
  opacity: 0.7;
}

.visibility-btn:hover {
  transform: scale(1.1);
}

.row-hidden {
  background: #f5f5f5;
  opacity: 0.7;
}

.hidden-badge {
  display: inline-block;
  background: #ff9800;
  color: white;
  font-size: 0.65rem;
  padding: 2px 6px;
  border-radius: 4px;
  margin-left: 0.5rem;
  vertical-align: middle;
}

.admin-form {
  padding: 1.5rem;
  overflow-y: auto;
}

.admin-form h3 {
  margin-bottom: 1rem;
  color: #2d5a27;
}

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

.form-group label {
  display: block;
  margin-bottom: 0.25rem;
  font-weight: 500;
}

.form-group input[type="text"],
.form-group input[type="number"],
.form-group input[type="password"],
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 0.6rem;
  border: 1px solid #ccc;
  border-radius: 5px;
  font-size: 1rem;
}

.form-row {
  display: flex;
  gap: 1rem;
}

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

.checkbox-group label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
}

.checkbox-group input[type="checkbox"] {
  width: 18px;
  height: 18px;
}

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

.cancel-btn,
.save-btn {
  padding: 0.75rem 1.5rem;
  border: none;
  border-radius: 5px;
  cursor: pointer;
  font-size: 1rem;
}

.cancel-btn {
  background: #e0e0e0;
  color: #333;
}

.save-btn {
  background: #4a7c45;
  color: white;
}

/* Admin Error Message */
.admin-error {
  background: #ffebee;
  color: #c62828;
  padding: 1rem 1.5rem;
  margin: 1rem 1.5rem;
  border-radius: 8px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
}

.admin-error .retry-btn {
  background: #c62828;
  color: white;
  border: none;
  padding: 0.5rem 1rem;
  border-radius: 5px;
  cursor: pointer;
  white-space: nowrap;
}

.admin-error .retry-btn:hover {
  background: #b71c1c;
}

@media (max-width: 600px) {
  .header h1 {
    font-size: 1.8rem;
  }

  .main {
    padding: 1rem;
  }

  .category-btn {
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
  }

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