:root {
  --primary: #ee4d2d; /* Shopee Orange */
  --primary-hover: #d73211;
  --secondary: #f0f2f5;
  --text-main: #1c1e21;
  --text-muted: #65676b;
  --bg-page: #f8f9fa;
  --bg-card: #ffffff;
  --border: #e4e6eb;
  --radius: 12px;
  --shadow: 0 4px 20px rgba(0, 0, 0, 0.06);
}

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

body {
  font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background-color: var(--bg-page);
  color: var(--text-main);
  line-height: 1.5;
  padding: 40px 20px;
}

.container {
  max-width: 680px;
  margin: 0 auto;
}

.container-wide {
  max-width: 1200px;
  margin: 0 auto;
}

.header {
  text-align: center;
  margin-bottom: 28px;
}

.badge {
  display: inline-block;
  background: #ffebe7;
  color: var(--primary);
  font-size: 0.8rem;
  font-weight: 600;
  padding: 4px 12px;
  border-radius: 20px;
  margin-bottom: 12px;
}

.header h1 {
  font-size: 2rem;
  font-weight: 700;
  color: #111;
  margin-bottom: 8px;
}

.subtitle {
  color: var(--text-muted);
  font-size: 0.95rem;
}

.card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 28px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}

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

label {
  display: block;
  font-weight: 600;
  font-size: 0.9rem;
  margin-bottom: 8px;
}

input[type="text"],
input[type="url"],
input[type="password"] {
  width: 100%;
  padding: 12px 16px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-size: 0.95rem;
  transition: all 0.2s;
  outline: none;
}

input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(238, 77, 45, 0.15);
}

.input-with-button {
  display: flex;
  gap: 8px;
}

.input-with-button input {
  flex: 1;
}

.alias-input {
  display: flex;
  align-items: center;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  background: #fafafa;
}

.domain-prefix {
  padding: 0 14px;
  color: var(--text-muted);
  font-size: 0.9rem;
  font-weight: 500;
  border-right: 1px solid var(--border);
}

.alias-input input {
  border: none;
  background: #fff;
  border-radius: 0;
}

.alias-input input:focus {
  box-shadow: none;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 0.95rem;
  padding: 12px 20px;
  border-radius: 8px;
  cursor: pointer;
  border: none;
  transition: all 0.2s;
  text-decoration: none;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
}

.btn-primary:hover {
  background: var(--primary-hover);
}

.btn-secondary {
  background: var(--secondary);
  color: var(--text-main);
}

.btn-secondary:hover {
  background: #e4e6eb;
}

.btn-block {
  width: 100%;
  padding: 14px;
  font-size: 1rem;
}

.btn-sm {
  padding: 6px 14px;
  font-size: 0.85rem;
}

.link-btn {
  background: none;
  border: none;
  color: var(--primary);
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 600;
  text-decoration: underline;
}

.hint {
  display: block;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 6px;
}

.hidden {
  display: none !important;
}

/* Facebook Preview Box */
.preview-box {
  background: #fdfdfd;
  border: 1px solid #dcdfe4;
  border-radius: 10px;
  padding: 16px;
  margin-bottom: 20px;
}

.preview-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 12px;
  border-bottom: 1px dashed var(--border);
  padding-bottom: 8px;
}

.preview-content {
  display: flex;
  gap: 16px;
  background: #fff;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  overflow: hidden;
}

.preview-image-wrapper {
  width: 130px;
  height: 130px;
  flex-shrink: 0;
  background: #eee;
}

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

.preview-info {
  padding: 12px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  overflow: hidden;
}

.preview-info h3 {
  font-size: 0.95rem;
  color: #111;
  margin-bottom: 4px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.preview-info p {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 6px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.preview-site {
  font-size: 0.7rem;
  font-weight: 700;
  color: #888;
  letter-spacing: 0.5px;
}

.edit-fields {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

/* Result Box */
.result-box {
  margin-top: 24px;
  padding: 20px;
  background: #f0fdf4;
  border: 1.5px solid #bbf7d0;
  border-radius: 10px;
}

.result-box h3 {
  color: #166534;
  font-size: 1.05rem;
  margin-bottom: 12px;
}

.result-input-group {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.result-input-group input {
  background: #fff;
  font-weight: 600;
  color: #0f172a;
}

.result-actions {
  display: flex;
  gap: 16px;
}

.action-link {
  font-size: 0.85rem;
  color: #15803d;
  font-weight: 600;
  text-decoration: none;
}

.action-link:hover {
  text-decoration: underline;
}

/* ================= SẢN PHẨM TIẾP THỊ LIÊN KẾT (AFFILIATE GRID) ================= */
.affiliate-section {
  margin-top: 50px;
  padding-top: 30px;
  border-top: 1px dashed #e2e8f0;
}

.section-title-wrap {
  text-align: center;
  margin-bottom: 24px;
}

.section-title-wrap h2 {
  font-size: 1.45rem;
  font-weight: 700;
  color: #0f172a;
  margin-bottom: 6px;
}

.section-title-wrap p {
  font-size: 0.92rem;
  color: var(--text-muted);
}

.affiliate-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 20px;
}

.product-card {
  background: #fff;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--border);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.04);
  transition: all 0.25s ease;
  cursor: pointer;
  display: flex;
  flex-direction: column;
}

.product-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 12px 24px rgba(238, 77, 45, 0.14);
  border-color: #f87171;
}

.product-thumb {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  background: #ffffff;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px;
  border-bottom: 1px solid #f1f5f9;
}

.product-thumb img {
  width: 100%;
  height: 100%;
  object-fit: contain; /* Hiển thị trọn vẹn 100% ảnh, không bị cắt xén chữ hay lấp góc */
  transition: transform 0.3s ease;
}

.product-card:hover .product-thumb img {
  transform: scale(1.04);
}

.shopee-tag {
  display: none; /* Bỏ tag đè góc ảnh để tránh che khuất sản phẩm */
}

.product-details {
  padding: 14px;
  display: flex;
  flex-direction: column;
  flex: 1;
  justify-content: space-between;
}

.product-name {
  font-size: 0.92rem;
  font-weight: 600;
  color: #1e293b;
  line-height: 1.45;
  margin-bottom: 12px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  min-height: 2.7em;
}

.product-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: auto;
  padding-top: 8px;
  border-top: 1px solid #f1f5f9;
}

.product-price {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--primary);
}

.btn-buy {
  background: #fff1ee;
  color: var(--primary);
  border: 1px solid #fecaca;
  font-size: 0.8rem;
  font-weight: 700;
  padding: 6px 12px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s;
}

.product-card:hover .btn-buy {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

@media (max-width: 600px) {
  .affiliate-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
  }
  .product-details {
    padding: 10px;
  }
  .product-name {
    font-size: 0.84rem;
  }
  .product-price {
    font-size: 0.92rem;
  }
  .btn-buy {
    padding: 4px 8px;
    font-size: 0.72rem;
  }
}

.footer {
  text-align: center;
  margin-top: 40px;
  color: var(--text-muted);
  font-size: 0.85rem;
}

/* ================= ADMIN DASHBOARD STYLES ================= */
.admin-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  text-align: left;
}

.auth-card {
  max-width: 450px;
  margin: 40px auto;
}

.error-text {
  color: #dc2626;
  font-size: 0.85rem;
  margin-top: 10px;
}

.admin-tabs {
  display: flex;
  gap: 12px;
  margin-bottom: 20px;
}

.tab-btn {
  background: #e2e8f0;
  border: none;
  padding: 12px 20px;
  border-radius: 8px;
  font-weight: 700;
  font-size: 0.95rem;
  color: #475569;
  cursor: pointer;
  transition: all 0.2s;
}

.tab-btn.active {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 4px 12px rgba(238, 77, 45, 0.25);
}

.add-affiliate-card {
  margin-bottom: 20px;
}

.add-affiliate-card h3 {
  margin-bottom: 6px;
  color: #0f172a;
}

.form-row {
  display: flex;
  gap: 16px;
}

.flex-1 { flex: 1; }
.flex-2 { flex: 2; }

@media (max-width: 768px) {
  .form-row {
    flex-direction: column;
    gap: 0;
  }
}

.table-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.stats-counter {
  font-size: 0.9rem;
  color: var(--text-muted);
}

.table-responsive {
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}

.data-table th,
.data-table td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.data-table th {
  background: #f8fafc;
  color: #475569;
  font-weight: 600;
  text-align: left;
}

.table-thumb {
  width: 50px;
  height: 50px;
  border-radius: 6px;
  object-fit: cover;
  border: 1px solid #eee;
}

.table-no-thumb {
  width: 50px;
  height: 50px;
  border-radius: 6px;
  background: #eee;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  color: #999;
}

.table-code {
  display: flex;
  align-items: center;
  gap: 6px;
}

.btn-copy-code {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 0.9rem;
}

.short-link-href {
  color: var(--primary);
  text-decoration: none;
}

.product-title-cell {
  font-weight: 600;
  max-width: 250px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.product-desc-cell {
  display: block;
  color: var(--text-muted);
  max-width: 250px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.orig-link {
  color: #2563eb;
  text-decoration: none;
}

.click-badge {
  display: inline-block;
  background: #e0f2fe;
  color: #0369a1;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 0.85rem;
}

.btn-delete {
  background: #fee2e2;
  color: #b91c1c;
  border: none;
  padding: 6px 12px;
  border-radius: 6px;
  font-weight: 600;
  cursor: pointer;
  font-size: 0.8rem;
}

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