/* ==========================================
   1. MAIN & GLOBAL STYLES
   ========================================== */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Fira GO', sans-serif;
  background-color: #ffffff;
  color: #ffffff;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.hidden {
  display: none !important;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
  width: 12px;
}
::-webkit-scrollbar-track {
  background: #e0b81800;
}
::-webkit-scrollbar-thumb {
  background: #ff8140;
  border-radius: 8px;
}

/* Background Gradients */
.orange-gradient-bg {
  background: linear-gradient(90deg, rgba(255,255,255,0) 0%, rgba(255,225,170,0.6) 60%, rgba(255,198,105,0.85) 100%);
}

.modal-peach-bg {
  background-color: #fce1b6;
}

/* ==========================================
   2. APP CONTAINER & HEADER
   ========================================== */
#app {
  width: 100%;
  max-width: 768px;
  background-color: #ffffff;
  border-radius: 24px;
  padding: 20px;
  min-height: 650px;
  display: flex;
  flex-direction: column;
  position: relative;
}

.app-header {
  margin-bottom: 16px;
}

.header-user-view {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  padding: 0 4px;
}

.header-title {
  font-size: 24px;
  font-weight: 800;
  color: #3a280d;
}

.header-right-group {
  display: flex;
  align-items: center;
  gap: 12px;
}

.product-count {
  font-size: 16px;
  font-weight: 700;
  color: #3a280d;
}

/* HOME REDIRECT ICON STYLES */
.home-link-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background-color: #ffffff;
  border: 2px solid #808080;
  color: #555555;
  text-decoration: none;
  transition: all 0.2s;
}

.home-link-btn:hover {
  background-color: #f3f4f6;
  color: #111827;
  transform: scale(1.05);
}

.home-link-btn svg {
  width: 20px;
  height: 20px;
}

.header-admin-view {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.admin-title-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.admin-actions-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Search Bar */
.search-container {
  display: flex;
  gap: 8px;
  align-items: center;
}

.search-box {
  position: relative;
  flex: 1;
  background-color: #ffffff;
  border-radius: 10px;
  border: 1px solid #d1d5db;
  display: flex;
  align-items: center;
  overflow: hidden;
  box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

.search-icon {
  position: absolute;
  left: 14px;
  color: #6b7280;
  width: 22px;
  height: 22px;
}

.search-input {
  width: 100%;
  padding: 12px 56px 12px 48px;
  background: transparent;
  font-size: 15px;
  font-weight: 500;
  color: #1f2937;
  border: none;
  outline: none;
}

.search-badge {
  position: absolute;
  right: 12px;
  font-size: 12px;
  font-weight: 600;
  color: #9ca3af;
  pointer-events: none;
}

/* Buttons */
.btn {
  border: none;
  border-radius: 12px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: inherit;
  font-weight: 600;
  transition: background-color 0.2s, transform 0.1s;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.btn:active {
  transform: scale(0.98);
}

.btn-icon {
  padding: 8px;
}

.btn-green {
  background-color: #80C21B;
  color: #ffffff;
}
.btn-green:hover {
  background-color: #72ad18;
}

.btn-orange {
  background-color: #f8941d;
  color: #ffffff;
  padding: 10px 14px;
  font-size: 13px;
  gap: 4px;
}
.btn-orange:hover {
  background-color: #e08312;
}

.btn-brown {
  background-color: #9d805b;
  color: #ffffff;
  padding: 10px 14px;
  font-size: 13px;
  gap: 4px;
}
.btn-brown:hover {
  background-color: #886d4b;
}

.btn-logout {
  background-color: #ffffff;
  color: #000000;
  padding: 10px;
  border-radius: 8px;
}
.btn-logout:hover {
  background-color: #ff0000;
}

.btn-back {
  background-color: #f2c921;
  color: #4a3400;
  padding: 8px 16px;
  font-size: 13px;
  border-radius: 12px;
  gap: 6px;
}
.btn-back:hover {
  background-color: #e0b818;
}

/* ==========================================
   3. PRODUCT LIST & CARDS
   ========================================== */
#product-list {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin: 4px 0;
  overflow-y: auto;
  
  padding-right: 4px;
  scroll-behavior: smooth;
}

.product-card {
  background-color: #ffffff;
  border-radius: 18px;
  padding: 12px;
  display: flex;
  align-items: center;
  gap: 14px;
  position: relative;
  border: 1px solid rgba(251, 191, 36, 0.4);
  box-shadow: inset -1px 1px 20px 0px rgb(255 210 87 / 55%);
  transition: box-shadow 0.2s;
}

.product-card:hover {
  box-shadow: 0 4px 6px rgb(87 51 6 / 65%);
}

.product-image-box {
  width: 150px;
  height: 150px;
  flex-shrink: 0;
  background-color: #e5e7eb;
  border-radius: 14px;
  overflow: hidden;
}

.product-image-box img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 14px;
  cursor: pointer;
}

.product-info-box {
  flex: 1;
  min-width: 0;
  height: 150px;
  padding: 12px 16px;
  border-radius: 14px;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
}

.product-title {
  font-weight: 800;
  color: #111827;
  font-size: 17px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 8px;
}

.product-desc {
  color: #4b5563;
  font-size: 13px;
  line-height: 1.45;
  display: -webkit-box;
  -webkit-line-clamp: 5;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.product-price-box {
  text-align: right;
  flex-shrink: 0;
  padding: 0 8px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: flex-end;
  min-width: 100px;
}

.price-label {
  font-size: 13px;
  color: #78350f;
  font-weight: 600;
  margin-top: 4px;
}

.price-value {
  font-size: 22px;
  font-weight: 900;
  color: #80C21B;
  display: flex;
  align-items: center;
  gap: 2px;
}

.status-dot {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  display: inline-block;
}

.status-dot.in-stock {
  background-color: #10b981;
}

.status-dot.out-of-stock {
  background-color: #ef4444;
}

.admin-actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding-left: 10px;
  border-left: 1px solid #e5e7eb;
  color: #6b7280;
  flex-shrink: 0;
}

.admin-action-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: #6b7280;
  padding: 4px;
  transition: color 0.2s, transform 0.1s;
}

.admin-action-btn svg {
  width: 20px !important;
  height: 20px !important;
}

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

.admin-action-btn.delete:hover { color: #ef4444; }
.admin-action-btn.edit:hover { color: #80C21B; }

/* ==========================================
   4. SCROLL TO TOP BUTTON (RED ARROW)
   ========================================== */
#scroll-top-btn {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background-color: #ff0000;
  color: #ffffff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 10px rgba(255, 0, 0, 0.4);
  z-index: 40;
  transition: transform 0.2s, background-color 0.2s;
}

#scroll-top-btn:hover {
  background-color: #cc0000;
  transform: scale(1.1);
}

#scroll-top-btn svg {
  width: 26px;
  height: 26px;
  stroke-width: 3px;
}

/* ==========================================
   5. MODALS & OVERLAYS
   ========================================== */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  backdrop-filter: blur(4px);
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal-content {
  background-color: #ffffff;
  border-radius: 24px;
  padding: 24px;
  max-width: 460px;
  width: 100%;
  box-shadow: 11px 10px 17px 3px rgb(183 113 0 / 60%);
  position: relative;
  border: 1px solid #f3f4f6;
}

.modal-header-icon {
  width: 56px;
  height: 56px;
  border-radius: 16px;
  border: 2px solid #b89130;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #8e6d1b;
  margin: 0 auto 12px auto;
}

.modal-title {
  font-size: 22px;
  font-weight: 700;
  color: #3a280d;
  text-align: center;
  margin-bottom: 16px;
}

.form-group {
  margin-bottom: 12px;
}

.input-text, .textarea-text {
  width: 100%;
  padding: 12px 14px;
  background-color: #ffffff;
  border: 2px solid #d1d5db;
  border-radius: 12px;
  font-size: 14px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s;
}

.input-text:focus, .textarea-text:focus {
  border-color: #80C21B;
}

.textarea-text {
  resize: none;
}

.image-upload-box {
  position: relative;
  width: 100%;
  height: 150px;
  border-radius: 16px;
  border: 2px dashed #e3c193;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: #8d6935;
  cursor: pointer;
  overflow: hidden;
}

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

.file-input-hidden {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}

.modal-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  align-items: start;
  margin-bottom: 12px;
}

.radio-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  padding: 6px 8px;
  font-size: 13px;
  font-weight: 600;
  color: #374151;
  border-radius: 8px;
}

.radio-label:hover {
  background-color: #fef3c7;
}

.modal-action-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: none;
  border: none;
  width: 100%;
  cursor: pointer;
  font-weight: 600;
  font-size: 13px;
  color: #1f2937;
  padding: 6px 0;
}

.modal-action-row:hover {
  color: #80C21B;
}

.modal-action-row.delete-btn:hover {
  color: #dc2626;
}

.icon-badge {
  padding: 6px;
  border-radius: 8px;
  color: #ffffff;
  display: inline-flex;
}

.icon-badge.green { background-color: #80C21B; }
.icon-badge.red { background-color: #ef4444; }

.image-preview-content {
  position: relative;
  background-color: #ffffff;
  padding: 8px;
  border-radius: 24px;
  width: 550px;
  height: 550px;
  max-width: 90vw;
  max-height: 90vw;
  display: flex;
  align-items: center;
  justify-content: center;
}

.close-btn {
  position: absolute;
  top: 16px;
  right: 16px;
  background-color: rgba(255,255,255,0.8);
  border: none;
  border-radius: 50%;
  padding: 8px;
  cursor: pointer;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
  z-index: 10;
}

.close-btn:hover {
  background-color: #ffffff;
}

#toast-notification {
  position: fixed;
  bottom: 20px;
  right: 20px;
  padding: 12px 18px;
  border-radius: 16px;
  color: #ffffff;
  font-size: 14px;
  font-weight: 500;
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
  z-index: 100;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  gap: 8px;
}

#toast-notification.success { background-color: #059669; }
#toast-notification.error { background-color: #dc2626; }

/* ==========================================
   6. MOBILE RESPONSIVE STYLES
   ========================================== */
@media (max-width: 640px) {
  body {
    padding: 8px;
  }

  #app {
    padding: 12px;
    border-radius: 16px;
    min-height: auto;
  }

  .header-title {
    font-size: 18px;
  }

  .product-count {
    font-size: 14px;
  }

  .header-admin-view {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }

  .admin-actions-group {
    justify-content: space-between;
    width: 100%;
  }

  .admin-actions-group .btn {
    flex: 1;
    text-align: center;
    padding: 8px 6px;
    font-size: 11px;
  }

  .product-card {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    padding: 10px;
  }

  .product-image-box {
    width: 100%;
    height: 180px;
  }

  .product-info-box {
    width: 100%;
    height: auto;
    min-height: auto;
    padding: 10px;
  }

  .product-desc {
    -webkit-line-clamp: 3;
  }

  .product-price-box {
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    min-width: 0;
    padding: 4px 0;
    border-top: 1px dashed #e5e7eb;
  }

  .price-label {
    margin-top: 0;
  }

  .admin-actions {
    flex-direction: row;
    justify-content: flex-end;
    gap: 16px;
    padding-left: 0;
    padding-top: 8px;
    border-left: none;
    border-top: 1px solid #e5e7eb;
  }

  .modal-content {
    padding: 16px;
    max-width: 100%;
    border-radius: 16px;
  }

  .modal-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .image-upload-box {
    height: 120px;
  }

  #scroll-top-btn {
    bottom: 16px;
    right: 16px;
    width: 40px;
    height: 40px;
  }

  #toast-notification {
    left: 10px;
    right: 10px;
    bottom: 10px;
    text-align: center;
    justify-content: center;
  }
}