/* =========================================================
   ADMIN - PRODUCTS PAGE STYLES
   ========================================================= */

:root {
  --primary-color: #10B981;
  --primary-hover: #059669;
  --primary-light: #ECFDF5;
  --text-main: #222222;
  --text-muted: #757575;
  --bg-light: #F5F5F5;
  --border-color: #E8E8E8;
  --success-color: #26AA99;
  --warning-color: #FFB400;
  --danger-color: #EF4444;
  --white: #ffffff;
}

body {
  font-family: 'Inter', 'Roboto', sans-serif;
  color: var(--text-main);
  background-color: var(--bg-light);
  margin: 0;
}

.products-container {
  padding: 24px;
  max-width: 1600px;
  margin: 0 auto;
}

/* --- HEADER --- */
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
}

.page-title h1 {
  font-size: 24px;
  font-weight: 700;
  margin: 0;
}

.page-actions {
  display: flex;
  gap: 12px;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  border-radius: 2px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  border: 1px solid transparent;
}

.btn-primary {
  background-color: var(--primary-color);
  color: var(--white);
}

.btn-primary:hover {
  background-color: var(--primary-hover);
}

.btn-outline {
  background-color: var(--white);
  color: var(--text-main);
  border-color: var(--border-color);
}

.btn-outline:hover {
  background-color: var(--bg-light);
}

/* --- FILTER BAR --- */
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  background-color: var(--white);
  padding: 16px;
  border-radius: 8px;
  border: 1px solid var(--border-color);
  margin-bottom: 24px;
}

.filter-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.filter-group label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-main);
}

.filter-group input, 
.filter-group select {
  padding: 8px 12px;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  font-size: 14px;
  outline: none;
  background-color: var(--white);
  color: var(--text-main);
}

.filter-group input:focus, 
.filter-group select:focus {
  border-color: var(--primary-color);
}

.search-group {
  flex: 1;
  min-width: 250px;
}

.search-input {
  position: relative;
  display: flex;
  align-items: center;
}

.search-input input {
  width: 100%;
  padding-left: 36px;
  box-sizing: border-box;
}

.search-input i {
  position: absolute;
  left: 12px;
  color: var(--text-muted);
}

.price-inputs {
  display: flex;
  align-items: center;
  gap: 8px;
}

.price-inputs input {
  width: 100px;
}

.price-inputs span {
  color: var(--text-muted);
}

/* --- TABLE --- */
.table-container {
  background-color: var(--white);
  border-radius: 8px;
  border: 1px solid var(--border-color);
  overflow-x: auto;
  margin-bottom: 24px;
}

.products-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}

.products-table th, 
.products-table td {
  padding: 16px;
  border-bottom: 1px solid var(--border-color);
  font-size: 14px;
}

.products-table th {
  font-weight: 600;
  color: var(--text-muted);
  background-color: var(--bg-light);
}

.products-table tbody tr:hover {
  background-color: var(--bg-light);
}

.product-img {
  width: 48px;
  height: 48px;
  border-radius: 6px;
  object-fit: cover;
  border: 1px solid var(--border-color);
}

.product-name-col {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.product-name-col strong {
  color: var(--text-main);
  font-weight: 500;
}

.product-name-col span {
  font-size: 12px;
  color: var(--text-muted);
}

.badge {
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 500;
}

.badge-success {
  background-color: #d1fae5;
  color: #065f46;
}

.badge-danger {
  background-color: #fee2e2;
  color: #991b1b;
}

.action-btns {
  display: flex;
  gap: 8px;
}

.btn-icon {
  width: 32px;
  height: 32px;
  border-radius: 2px;
  border: 1px solid var(--border-color);
  background-color: var(--white);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text-muted);
  transition: all 0.2s;
}

.btn-icon:hover {
  background-color: var(--bg-light);
}

.btn-icon.view { color: var(--primary-color); }
.btn-icon.edit { color: #d97706; }
.btn-icon.delete { color: var(--danger-color); }

/* --- PAGINATION --- */
.pagination-bar {
  display: flex;
  justify-content: center;
  align-items: center;
  margin-bottom: 32px;
}

.display-info {
  font-size: 14px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 8px;
}

.display-info select {
  padding: 4px 8px;
  border: 1px solid var(--border-color);
  border-radius: 4px;
}

.pagination-controls {
  display: flex;
  gap: 4px;
}

.btn-page {
  min-width: 32px;
  height: 32px;
  border-radius: 2px;
  border: 1px solid var(--border-color);
  background-color: var(--white);
  color: var(--text-main);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-page:hover {
  background-color: var(--bg-light);
}

.btn-page.active {
  background-color: var(--primary-color);
  color: var(--white);
  border-color: var(--primary-color);
}

/* --- SUMMARY CARDS --- */
.summary-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
}

.summary-card {
  background-color: var(--white);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 16px;
  display: flex;
  align-items: flex-start;
  gap: 16px;
}

.summary-card .icon {
  width: 48px;
  height: 48px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
}

.icon.blue { background-color: var(--primary-light); color: var(--primary-color); }
.icon.green { background-color: #dcfce7; color: var(--success-color); }
.icon.red { background-color: #fee2e2; color: var(--danger-color); }
.icon.teal { background-color: #ccfbf1; color: #0d9488; }
.icon.light-blue { background-color: var(--primary-light); color: var(--primary-color); }

.summary-card .info {
  display: flex;
  flex-direction: column;
}

.summary-card .info span {
  font-size: 13px;
  color: var(--text-muted);
  font-weight: 500;
  margin-bottom: 4px;
}

.summary-card .info strong {
  font-size: 24px;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 4px;
}

.summary-card .info p {
  font-size: 12px;
  color: var(--text-muted);
  margin: 0;
}


/* =========================================================
   OFFCANVAS (SIDE PANEL)
   ========================================================= */

.offcanvas-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background-color: rgba(0, 0, 0, 0.4);
  z-index: 2000;
  display: none;
  opacity: 0;
  transition: opacity 0.3s;
}

.offcanvas-overlay.active {
  display: block;
  opacity: 1;
}

.offcanvas {
  position: fixed;
  top: 0;
  right: -450px;
  width: 400px;
  height: 100vh;
  background-color: var(--white);
  z-index: 2001;
  box-shadow: -4px 0 15px rgba(0,0,0,0.1);
  display: flex;
  flex-direction: column;
  transition: right 0.3s ease-in-out;
}

.offcanvas.active {
  right: 0;
}

.offcanvas-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.offcanvas-header h2 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
}

.btn-close {
  background: none;
  border: none;
  font-size: 20px;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
}

.btn-close:hover {
  color: var(--text-main);
}

.offcanvas-body {
  flex: 1;
  overflow-y: auto;
  padding: 0;
}

.tabs {
  display: flex;
  list-style: none;
  padding: 0 24px;
  margin: 0;
  border-bottom: 1px solid var(--border-color);
  background-color: #fcfcfc;
}

.tab {
  padding: 12px 16px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}

.tab.active {
  color: var(--primary-color);
  border-bottom-color: var(--primary-color);
}

.tab-content {
  display: none;
  padding: 24px;
}

.tab-content.active {
  display: block;
}

/* Form Styles inside Offcanvas */
.form-group {
  margin-bottom: 16px;
}

.form-row {
  display: flex;
  gap: 16px;
}

.form-row .form-group {
  flex: 1;
}

.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 8px;
  color: var(--text-main);
}

.form-group label span {
  color: var(--danger-color);
}

.form-group input, 
.form-group select, 
.form-group textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  font-size: 14px;
  box-sizing: border-box;
  font-family: inherit;
  outline: none;
}

.form-group input:focus, 
.form-group select:focus, 
.form-group textarea:focus {
  border-color: var(--primary-color);
}

.form-group input:disabled,
.form-group input.disabled-input {
  background-color: var(--bg-light);
  color: var(--text-muted);
  cursor: not-allowed;
}

.status-select {
  color: var(--success-color);
  font-weight: 500;
}

.image-uploader {
  border: 1px dashed var(--border-color);
  border-radius: 2px;
  padding: 20px;
  text-align: center;
  background-color: var(--bg-light);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.upload-placeholder {
  width: 64px;
  height: 64px;
  background-color: var(--white);
  border-radius: 2px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  color: var(--text-muted);
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.btn-upload {
  background-color: var(--white);
  border: 1px solid var(--border-color);
  padding: 6px 12px;
  border-radius: 2px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  color: var(--primary-color);
}

.help-text {
  font-size: 11px;
  color: var(--text-muted);
}

.offcanvas-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  background-color: var(--white);
}

/* =========================================================
   IMAGE GALLERY TAB STYLES
   ========================================================= */

.primary-image-wrapper {
  display: flex;
  justify-content: center;
  align-items: center;
  border: 1px solid var(--border-color);
  border-radius: 2px;
  padding: 16px;
  background-color: var(--bg-light);
  min-height: 200px;
  position: relative;
}

.primary-image-wrapper img {
  max-width: 100%;
  max-height: 250px;
  object-fit: contain;
  border-radius: 4px;
}

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  gap: 12px;
}

.gallery-item {
  position: relative;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  overflow: hidden;
  aspect-ratio: 1;
  background-color: var(--bg-light);
}

.gallery-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.gallery-item .item-actions {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  opacity: 0;
  transition: opacity 0.2s;
  gap: 8px;
}

.gallery-item:hover .item-actions {
  opacity: 1;
}

.gallery-item .btn-action {
  background: var(--white);
  border: none;
  border-radius: 4px;
  padding: 4px 8px;
  font-size: 11px;
  cursor: pointer;
  font-weight: 500;
  color: var(--text-main);
}

.gallery-item .btn-action.delete {
  color: var(--danger-color);
}

.gallery-item .btn-action:hover {
  background: var(--bg-light);
}

.empty-state {
  color: var(--text-muted);
  font-size: 14px;
  text-align: center;
  padding: 20px;
}


/* =========================================================
   RESPONSIVE — PRODUCTS PAGE
   ========================================================= */

/* --- Laptop (992px - 1199px) --- */
@media (max-width: 1199px) {
  .products-container {
    padding: 20px;
  }
}

/* --- Tablet (768px - 991px) --- */
@media (max-width: 991px) {
  .products-container {
    padding: 70px 16px 16px; /* top: offset menu-toggle */
  }

  .page-header {
    flex-wrap: wrap;
    gap: 12px;
  }

  .page-title h1 {
    font-size: 20px;
  }

  .page-actions {
    flex-wrap: wrap;
  }

  /* Filter bar */
  .filter-bar {
    padding: 12px;
    gap: 12px;
  }

  .search-group {
    min-width: 100%;
  }

  /* Table: cho phép horizontal scroll có kiểm soát */
  .table-container {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .products-table {
    min-width: 700px;
  }

  .products-table th,
  .products-table td {
    padding: 12px 10px;
    font-size: 13px;
  }

  /* Offcanvas — thu hẹp lại trên tablet */
  .offcanvas {
    width: 380px;
    right: -400px;
  }
}

/* --- Mobile (< 768px) --- */
@media (max-width: 767px) {
  .products-container {
    padding: 60px 12px 12px; /* top: offset menu-toggle */
  }

  .page-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
    margin-bottom: 16px;
  }

  .page-title h1 {
    font-size: 18px;
  }

  .page-actions {
    width: 100%;
    justify-content: flex-end;
  }

  /* Filter bar */
  .filter-bar {
    padding: 10px;
    gap: 10px;
    margin-bottom: 16px;
  }

  .filter-group {
    width: 100%;
  }

  .filter-group input,
  .filter-group select {
    width: 100%;
    box-sizing: border-box;
  }

  .search-group {
    min-width: 0;
    width: 100%;
  }

  /* Table scroll */
  .table-container {
    margin-bottom: 16px;
  }

  .products-table {
    min-width: 600px;
  }

  .products-table th,
  .products-table td {
    padding: 10px 8px;
    font-size: 12px;
  }

  /* Hide less-important columns on small mobile */
  .products-table .hide-mobile {
    display: none;
  }

  /* Offcanvas — full-width trên mobile */
  .offcanvas {
    width: 100%;
    right: -100%;
    border-radius: 0;
  }

  /* Form row — 1 cột trên mobile */
  .form-row {
    flex-direction: column;
    gap: 0;
  }

  .offcanvas-header {
    padding: 16px 18px;
  }

  .offcanvas-header h2 {
    font-size: 16px;
  }

  .tab-content {
    padding: 16px 18px;
  }

  /* Pagination */
  .pagination-bar {
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 8px;
  }

  .pagination-controls {
    flex-wrap: wrap;
    justify-content: center;
    gap: 4px;
  }

  .btn-page {
    min-width: 36px;
    height: 36px;
    font-size: 13px;
  }
}

/* --- Mobile nhỏ (< 480px) --- */
@media (max-width: 479px) {
  .products-container {
    padding: 10px;
  }

  .page-title h1 {
    font-size: 16px;
  }

  .btn {
    padding: 7px 12px;
    font-size: 13px;
  }

  .products-table th,
  .products-table td {
    padding: 8px 6px;
    font-size: 11px;
  }

  .product-img {
    width: 38px;
    height: 38px;
  }

  .offcanvas-footer {
    padding: 12px 16px;
  }
}