/* ==========================================================================
   LinkCoo Storefront - Modern Responsive Design System
   ========================================================================== */

:root {
  --font-sans: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --color-primary: #2563eb;
  --color-primary-hover: #1d4ed8;
  --color-primary-light: #eff6ff;
  --color-success: #10b981;
  --color-text-main: #0f172a;
  --color-text-muted: #64748b;
  --color-bg-body: #f8fafc;
  --color-bg-card: #ffffff;
  --color-border: #e2e8f0;
  --color-border-subtle: #f1f5f9;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.08), 0 2px 4px -2px rgb(0 0 0 / 0.04);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.08), 0 4px 6px -4px rgb(0 0 0 / 0.03);
  --transition-fast: 0.15s ease-in-out;
}

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

body {
  font-family: var(--font-sans);
  background-color: var(--color-bg-body);
  color: var(--color-text-main);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.container {
  width: 100%;
  max-width: 1360px;
  margin: 0 auto;
  padding: 0 20px;
}

/* ==========================================================================
   Topbar & Navigation
   ========================================================================== */

.topbar {
  background: var(--color-bg-card);
  border-bottom: 1px solid var(--color-border);
  position: sticky;
  top: 0;
  z-index: 50;
  backdrop-filter: blur(8px);
  background-color: rgba(255, 255, 255, 0.95);
}

.topbar-inner {
  height: 70px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.brand-link {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--color-text-main);
}

.brand-logo {
  width: 38px;
  height: 38px;
  background: linear-gradient(135deg, #2563eb, #3b82f6);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  box-shadow: 0 4px 10px rgba(37, 99, 235, 0.25);
}

.brand-name {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.brand-sub {
  color: var(--color-primary);
  font-weight: 600;
}

/* Topbar Instant Search */
.topbar-search {
  flex: 1;
  max-width: 520px;
}

.search-input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
}

.search-icon {
  position: absolute;
  left: 14px;
  color: var(--color-text-muted);
  pointer-events: none;
}

.search-input-wrapper input {
  width: 100%;
  height: 42px;
  padding: 8px 38px 8px 42px;
  font-family: inherit;
  font-size: 0.9375rem;
  color: var(--color-text-main);
  background: var(--color-bg-body);
  border: 1px solid var(--color-border);
  border-radius: 9999px;
  outline: none;
  transition: all var(--transition-fast);
}

.search-input-wrapper input:focus {
  background: #fff;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.clear-search-btn {
  position: absolute;
  right: 12px;
  background: none;
  border: none;
  color: var(--color-text-muted);
  font-size: 1.25rem;
  line-height: 1;
  cursor: pointer;
  padding: 4px;
}

.clear-search-btn:hover {
  color: var(--color-text-main);
}

/* Social Media Icons */
.topbar-social {
  display: flex;
  align-items: center;
  gap: 12px;
}

.social-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 1px solid var(--color-border);
  background: #fff;
  color: var(--color-text-muted);
  text-decoration: none;
  transition: all var(--transition-fast);
}

.social-icon:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-sm);
}

.social-icon.youtube:hover {
  color: #ff0000;
  border-color: #ff0000;
  background-color: #fff5f5;
}

.social-icon.facebook:hover {
  color: #1877f2;
  border-color: #1877f2;
  background-color: #eff6ff;
}

.social-icon.tiktok:hover {
  color: #000;
  border-color: #000;
  background-color: #f8fafc;
}

/* ==========================================================================
   Main Content Layout (2-Column Grid)
   ========================================================================== */

.main-content {
  flex: 1;
  padding-top: 28px;
  padding-bottom: 48px;
}

.content-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 28px;
  align-items: start;
}

/* Products Section */
.products-section {
  display: flex;
  flex-direction: column;
  gap: 20px;
  min-width: 0;
}

/* Filters Card */
.filters-card {
  background: var(--color-bg-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
  box-shadow: var(--shadow-sm);
}

.filter-controls {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 14px;
}

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

.filter-group label {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--color-text-muted);
  white-space: nowrap;
}

.filter-select {
  height: 38px;
  padding: 6px 12px;
  font-family: inherit;
  font-size: 0.875rem;
  color: var(--color-text-main);
  background-color: var(--color-bg-body);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  outline: none;
  cursor: pointer;
  transition: border-color var(--transition-fast);
}

.filter-select:focus {
  border-color: var(--color-primary);
  background-color: #fff;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-family: inherit;
  font-weight: 600;
  font-size: 0.875rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition-fast);
  border: 1px solid transparent;
  text-decoration: none;
}

.btn-sm {
  height: 36px;
  padding: 0 12px;
}

.btn-secondary {
  background: #fff;
  border-color: var(--color-border);
  color: var(--color-text-muted);
}

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

.results-stats {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--color-text-muted);
}

/* ==========================================================================
   Products Table Card
   ========================================================================== */

.table-card {
  background: var(--color-bg-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.table-wrapper {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.products-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.9375rem;
}

.products-table thead {
  background-color: #f8fafc;
  border-bottom: 2px solid var(--color-border);
}

.products-table th {
  padding: 14px 16px;
  font-size: 0.8125rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-text-muted);
  white-space: nowrap;
}

.products-table td {
  padding: 16px;
  border-bottom: 1px solid var(--color-border-subtle);
  vertical-align: middle;
}

.products-table tr:hover {
  background-color: #fafbfc;
}

/* Column specific widths & alignment */
.col-stt {
  width: 60px;
  text-align: center;
}

.td-stt {
  text-align: center;
  font-weight: 600;
  color: var(--color-text-muted);
}

.col-nhom {
  width: 120px;
}

.badge-nhom {
  display: inline-block;
  padding: 4px 10px;
  font-size: 0.75rem;
  font-weight: 600;
  border-radius: 9999px;
  background-color: var(--color-primary-light);
  color: var(--color-primary);
  white-space: nowrap;
}

.col-phanloai {
  width: 130px;
  color: var(--color-text-muted);
  font-size: 0.875rem;
}

.col-ten {
  min-width: 200px;
  font-weight: 600;
  color: var(--color-text-main);
}

.col-thongso {
  min-width: 260px;
}

.col-action {
  width: 130px;
  text-align: center;
}

.td-action {
  text-align: center;
}

/* Action Button "Xem chi tiết" */
.btn-detail {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 14px;
  font-size: 0.8125rem;
  font-weight: 600;
  color: #fff;
  background: var(--color-primary);
  border: none;
  border-radius: var(--radius-sm);
  text-decoration: none;
  transition: all var(--transition-fast);
  box-shadow: 0 2px 4px rgba(37, 99, 235, 0.2);
  white-space: nowrap;
}

.btn-detail:hover {
  background: var(--color-primary-hover);
  transform: translateY(-1px);
  box-shadow: 0 4px 8px rgba(37, 99, 235, 0.3);
}

/* ==========================================================================
   Embedded Markdown Table Styling (Thông số sản phẩm)
   ========================================================================== */

.spec-markdown-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8125rem;
  background: #f8fafc;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  margin: 2px 0;
}

.spec-markdown-table thead {
  background: #f1f5f9;
  border-bottom: 1px solid var(--color-border);
}

.spec-markdown-table th {
  padding: 6px 10px;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--color-text-muted);
  text-transform: none;
  letter-spacing: normal;
}

.spec-markdown-table td {
  padding: 6px 10px;
  border-bottom: 1px solid #eef2f6;
  color: #334155;
}

.spec-markdown-table tr:last-child td {
  border-bottom: none;
}

.spec-markdown-table tr:nth-child(even) td {
  background-color: #ffffff;
}

/* ==========================================================================
   Chatbox Sidebar & Container
   ========================================================================== */

.chatbox-sidebar {
  position: sticky;
  top: 98px;
}

.chatbox-card {
  background: var(--color-bg-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.chatbox-card-header {
  padding: 16px 20px;
  background: linear-gradient(135deg, #1e293b, #0f172a);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.chatbox-title-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
}

.chatbox-title-wrap h3 {
  font-size: 1rem;
  font-weight: 600;
}

.live-dot {
  width: 9px;
  height: 9px;
  background-color: #22c55e;
  border-radius: 50%;
  box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.3);
}

.chatbox-badge {
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  background: rgba(255, 255, 255, 0.15);
  padding: 2px 8px;
  border-radius: 9999px;
  color: #e2e8f0;
}

.chatbox-container {
  padding: 16px;
  min-height: 380px;
  display: flex;
  flex-direction: column;
}

.chatbox-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  color: var(--color-text-muted);
  font-size: 0.875rem;
  height: 250px;
}

/* Chatbox Inner Sample Widget Style */
.chatbox-widget-card {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 340px;
}

.chatbox-header {
  font-weight: 600;
  font-size: 0.875rem;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.chatbox-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--color-success);
}

.chatbox-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 14px;
}

.chat-bubble {
  max-width: 90%;
  padding: 10px 14px;
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  line-height: 1.45;
}

.chat-bubble.bot {
  background-color: var(--color-bg-body);
  border: 1px solid var(--color-border);
  color: var(--color-text-main);
  align-self: flex-start;
  border-bottom-left-radius: 2px;
}

.chatbox-footer {
  display: flex;
  gap: 8px;
}

.chat-input {
  flex: 1;
  height: 38px;
  padding: 8px 12px;
  font-family: inherit;
  font-size: 0.875rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  outline: none;
}

.chat-input:focus {
  border-color: var(--color-primary);
}

.chat-send-btn {
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--color-primary);
  border: none;
  border-radius: var(--radius-sm);
  color: #fff;
  cursor: pointer;
  transition: background var(--transition-fast);
}

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

/* ==========================================================================
   Pagination & Empty States
   ========================================================================== */

.pagination-wrapper {
  padding: 16px 20px;
  border-top: 1px solid var(--color-border-subtle);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.page-btn {
  height: 36px;
  padding: 0 14px;
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--color-text-main);
  background: #fff;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.page-btn:hover:not(:disabled) {
  border-color: var(--color-primary);
  color: var(--color-primary);
}

.page-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.page-numbers {
  display: flex;
  gap: 6px;
}

.page-num {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.875rem;
  font-weight: 600;
  border-radius: var(--radius-sm);
  border: 1px solid var(--color-border);
  background: #fff;
  color: var(--color-text-main);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.page-num.active {
  background: var(--color-primary);
  color: #fff;
  border-color: var(--color-primary);
}

.empty-state {
  padding: 48px 24px;
  text-align: center;
  color: var(--color-text-muted);
}

.empty-icon {
  font-size: 2.5rem;
  margin-bottom: 12px;
}

.empty-state h3 {
  font-size: 1.125rem;
  color: var(--color-text-main);
  margin-bottom: 6px;
}

/* Skeleton Loading */
.skeleton-line {
  height: 20px;
  background: linear-gradient(90deg, #f1f5f9 25%, #e2e8f0 50%, #f1f5f9 75%);
  background-size: 200% 100%;
  animation: skeleton-loading 1.5s infinite;
  border-radius: 4px;
}

@keyframes skeleton-loading {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.spinner {
  width: 24px;
  height: 24px;
  border: 3px solid rgba(37, 99, 235, 0.2);
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ==========================================================================
   Footer
   ========================================================================== */

.footer {
  margin-top: auto;
  border-top: 1px solid var(--color-border);
  background: #fff;
  padding: 24px 0;
  text-align: center;
  font-size: 0.875rem;
  color: var(--color-text-muted);
}

/* ==========================================================================
   Responsive Breakpoints
   ========================================================================== */

@media (max-width: 1024px) {
  .content-layout {
    grid-template-columns: 1fr;
  }

  .chatbox-sidebar {
    position: static;
  }
}

@media (max-width: 768px) {
  .topbar-inner {
    height: auto;
    padding: 12px 0;
    flex-wrap: wrap;
  }

  .topbar-search {
    order: 3;
    max-width: 100%;
    width: 100%;
  }

  .filters-card {
    flex-direction: column;
    align-items: stretch;
  }

  .filter-controls {
    flex-direction: column;
    align-items: stretch;
  }

  .filter-group {
    justify-content: space-between;
  }

  .filter-select {
    flex: 1;
  }
}
