/* General reset */
*,
*::before,
*::after {
  box-sizing: border-box;
}

:root {
  --color-bg: #f9f9f9;
  --color-surface: #ffffff;
  --color-surface-muted: #f5f5f5;
  --color-text: #333333;
  --color-text-muted: #444444;
  --color-text-subtle: #666666;
  --color-border: #dddddd;
  --color-border-soft: #e5e5e5;
  --color-brand: #cc0000;
  --color-brand-dark: #a00000;
  --color-brand-soft: #fff5f5;
  --color-overlay: rgba(0, 0, 0, 0.5);
  --shadow-table: 0 12px 28px rgba(15, 23, 42, 0.07);
  --shadow-card: 0 12px 28px rgba(15, 23, 42, 0.07);
  --shadow-modal: 0 10px 30px rgba(0, 0, 0, 0.3);
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 14px;
  --radius-xl: 18px;
  --motion-fast: 180ms;
  --motion-base: 240ms;
  --ease-standard: cubic-bezier(0.22, 1, 0.36, 1);
}

body {
  margin: 0;
  font-family: 'Inter', system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial,
    sans-serif;
  background-color: var(--color-bg);
  color: var(--color-text);
}

/* Header */


header .controls {
  margin-top: 8px;
  padding: 12px 0;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
}

header input,
header select {
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  border: none;
  font-size: 14px;
  width: 100%;
  max-width: 280px;
}

/* Table Layout */
.table-container {
  padding: 16px 20px;
  max-width: 1260px;
  margin: 0 auto;
}

.pagination-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-top: 18px;
  padding-bottom: 4px;
}

.pagination-status {
  margin: 0;
  color: var(--color-text-subtle);
  font-size: 14px;
}

.pagination-actions {
  display: flex;
  gap: 10px;
}

.pagination-btn {
  padding: 10px 16px;
  border: 1px solid var(--color-brand);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  color: var(--color-brand);
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
}

.pagination-btn:hover:not(:disabled) {
  background: var(--color-brand);
  color: var(--color-surface);
}

.pagination-btn:disabled {
  border-color: var(--color-border);
  color: var(--color-text-subtle);
  cursor: not-allowed;
  opacity: 0.7;
}

.pagination-btn:focus-visible:not(:disabled) {
  outline: 2px solid var(--color-brand);
  outline-offset: 3px;
}

table {
  width: 100%;
  border-collapse: collapse;
  background-color: var(--color-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-table);
  display: table;
}

th,
td {
  padding: 12px 8px;
  text-align: left;
  border-bottom: 1px solid var(--color-border);
  vertical-align: top;
  word-wrap: break-word;
}

th {
  background-color: var(--color-surface-muted);
  font-weight: bold;
}

/* Desktop column widths */
th:nth-child(1),
td:nth-child(1) {
  width: 120px;
}
th:nth-child(2),
td:nth-child(2) {
  width: 160px;
}
th:nth-child(3),
td:nth-child(3) {
  width: 40%;
}
th:nth-child(4),
td:nth-child(4) {
  width: 120px;
}

/* Product Table */
#products-table {
  table-layout: fixed;
}

#products-table .product-col-image {
  width: 145px;
}

#products-table .product-col-name {
  width: 180px;
}

#products-table .product-col-description {
  width: auto;
}

#products-table .product-col-category {
  width: 140px;
}

#products-table th,
#products-table td {
  padding: 12px 10px;
}

#products-table th:nth-child(1),
#products-table td:nth-child(1) {
  text-align: center;
  vertical-align: middle;
}

#products-table th:nth-child(2),
#products-table td:nth-child(2),
#products-table th:nth-child(3),
#products-table td:nth-child(3),
#products-table th:nth-child(4),
#products-table td:nth-child(4) {
  vertical-align: middle;
}

.product-name-cell,
.product-description-cell {
  text-align: left;
}

.product-description-cell {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 10px;
}

.product-name {
  margin: 0;
  font-size: 16px;
  font-weight: bold;
  line-height: 1.4;
  display: flex;
  align-items: flex-start;
  min-height: 2.8em;
}

.product-description-cell .description-text {
  margin: 0;
  min-height: 4.2em;
  display: flex;
  align-items: center;
}

.product-description-cell .view-more {
  display: inline-flex;
  align-items: center;
  margin-top: 0;
  align-self: flex-start;
}

.product-image-cell {
  padding: 12px;
}

.product-image {
  width: 117px;
  height: 87px;
  object-fit: contain;
  object-position: center;
  border-radius: var(--radius-sm);
  display: block;
  margin: 0 auto;
  background-color: var(--color-surface);
}

/* ======================================= */
/* MOBILE: turn table → card layout */
/* ======================================= */

@media (max-width: 768px) {
  #products-table colgroup {
    display: none;
  }

  #products-table thead {
    display: none;
  }

  #products-table {
    display: block;
    width: 100%;
    background: transparent;
    box-shadow: none;
    border-radius: 0;
  }

  #products-table tbody {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
  }

  #products-table tr {
    display: flex;
    flex-direction: column;
    background-color: white;
    border-radius: var(--radius-xl);
    border: 1px solid var(--color-border-soft);
    box-shadow: var(--shadow-card);
    padding: 12px;
    gap: 8px;
    min-width: 0;
    height: 100%;
  }

  #products-table th,
  #products-table td {
    padding: 4px 0;
    border: none;
    display: flex;
    flex-direction: column;
    width: auto;
  }

  #products-table .product-image-cell {
    padding: 0;
  }

  #products-table .product-image {
    width: 100%;
    height: 132px;
    object-fit: contain;
    object-position: center;
    border-radius: 8px;
    margin: 0;
    display: block;
    background-color: #fff;
  }

  #products-table .product-name-cell {
    min-height: 0;
    display: flex;
    align-items: flex-start;
  }

  #products-table .product-name {
    min-height: 2.7em;
    margin: 0;
    font-size: 14px;
    line-height: 1.35;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    overflow: hidden;
  }

  #products-table .product-description-cell {
    flex: 1;
    gap: 8px;
    display: flex;
    justify-content: flex-start;
  }

  #products-table .description-text {
    font-size: 12px;
    -webkit-line-clamp: 2;
    min-height: 2.8em;
    max-height: 2.8em;
  }

  #products-table .view-more {
    align-self: flex-start;
    padding: 5px 8px;
    font-size: 11px;
    margin-top: auto;
  }

  #products-table td:last-child {
    font-size: 12px;
    color: #666;
  }

  .table-container {
    padding: 10px 12px;
  }

  .pagination-bar {
    flex-direction: column;
    align-items: stretch;
  }

  .pagination-actions {
    width: 100%;
  }

  .pagination-btn {
    flex: 1;
  }

  header h1 {
    font-size: 1.2rem;
  }

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

  header input,
  header select {
    max-width: 100%;
  }
}

@media (max-width: 480px) {
  #products-table tbody {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  #products-table tr {
    gap: 7px;
    padding: 11px;
  }

  #products-table .product-name {
    min-height: 2.9em;
    font-size: 13px;
    line-height: 1.38;
  }

  #products-table .description-text {
    min-height: 3em;
    max-height: 3em;
    font-size: 11.5px;
    line-height: 1.3;
  }

  #products-table .view-more {
    margin-top: auto;
  }

  #products-table .product-image {
    height: 120px;
  }

  .table-container {
    padding: 8px 10px;
  }
}

@media (max-width: 430px) {
  #products-table tbody {
    gap: 10px;
  }

  #products-table tr {
    gap: 6px;
    padding: 10px;
  }

  #products-table .product-image {
    height: 112px;
  }

  #products-table .product-name {
    min-height: 2.85em;
    font-size: 12.5px;
    line-height: 1.34;
  }

  #products-table .description-text {
    min-height: 2.9em;
    max-height: 2.9em;
    font-size: 11px;
    line-height: 1.32;
  }

  #products-table .view-more {
    padding: 5px 7px;
    font-size: 10.5px;
  }
}

/* Description truncation (desktop) */
.description-text {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
  overflow: hidden;
  line-height: 1.4;
  max-height: 4.2em;
  white-space: pre-line;
  word-break: break-word;
}

/* States */
tr:hover {
  background-color: #f1f1f1;
}

/* Modal */
.modal {
  display: none;
  position: fixed;
  z-index: 1000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  padding: 24px 16px;
  background: rgba(15, 23, 42, 0.46);
  backdrop-filter: blur(6px);
}

.modal-content {
  position: relative;
  background-color: var(--color-surface);
  margin: 3vh auto;
  padding: 30px 30px 24px;
  border-radius: 20px;
  width: 90%;
  max-width: 680px;
  max-height: min(84vh, 760px);
  overflow-y: auto;
  overscroll-behavior: contain;
  border: 1px solid rgba(15, 23, 42, 0.08);
  box-shadow: 0 22px 56px rgba(15, 23, 42, 0.16);
}

.modal-content__header {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 0 52px 18px 0;
  border-bottom: 1px solid rgba(15, 23, 42, 0.08);
}

.modal-content__eyebrow {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  padding: 6px 10px;
  border-radius: 999px;
  background: #f8fafc;
  color: #64748b;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  border: 1px solid rgba(15, 23, 42, 0.08);
}

.modal-content h3 {
  margin: 0;
  color: #111827;
  font-size: clamp(1.35rem, 2vw, 1.72rem);
  font-weight: 700;
  line-height: 1.2;
}

.modal-content__category {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  padding: 0;
  border-radius: 0;
  background: transparent;
  color: #6b7280;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.modal-content__body {
  padding-top: 20px;
}

.modal-content__layout {
  display: grid;
  grid-template-columns: minmax(220px, 0.78fr) minmax(0, 1fr);
  gap: 22px;
  align-items: start;
}

.modal-content__media {
  border: 1px solid rgba(15, 23, 42, 0.08);
  border-radius: 18px;
  background:
    radial-gradient(circle at top, rgba(255, 255, 255, 0.96) 0%, rgba(248, 250, 252, 0.92) 52%, rgba(239, 244, 248, 0.92) 100%),
    linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.52),
    0 12px 30px rgba(15, 23, 42, 0.08);
  overflow: hidden;
  aspect-ratio: 1 / 1;
  padding: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-content__media img {
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  object-position: center;
  display: block;
}

.modal-content__copy {
  min-width: 0;
}

#modalDescription {
  color: #4b5563;
  font-size: 14px;
  line-height: 1.75;
  word-break: break-word;
}

#modalDescription p {
  margin: 0 0 1em;
}

#modalDescription p:last-child {
  margin-bottom: 0;
}

.modal-content__footer {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid rgba(15, 23, 42, 0.08);
}

.close {
  position: absolute;
  right: 20px;
  top: 20px;
  color: #64748b;
  font-size: 20px;
  font-weight: 700;
  cursor: pointer;
  border: none;
  background: #ffffff;
  line-height: 1;
  width: 40px;
  height: 40px;
  padding: 0;
  border-radius: 50%;
  border: 1px solid rgba(15, 23, 42, 0.08);
  transition:
    color var(--motion-fast) var(--ease-standard),
    background-color var(--motion-fast) var(--ease-standard),
    border-color var(--motion-fast) var(--ease-standard);
}

.close:hover {
  color: #111827;
  background: #f8fafc;
  border-color: rgba(15, 23, 42, 0.14);
}

.close:focus-visible {
  outline: 2px solid var(--color-brand);
  outline-offset: 2px;
}

/* Buttons */
.inquire-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 12px 18px;
  background: #111827;
  color: var(--color-surface);
  border: none;
  border-radius: 12px;
  cursor: pointer;
  width: 100%;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.01em;
  box-shadow: none;
  transition:
    transform var(--motion-fast) var(--ease-standard),
    background-color var(--motion-fast) var(--ease-standard);
}

.inquire-btn:hover {
  background: #1f2937;
  transform: translateY(-1px);
}

.inquire-btn:focus-visible {
  outline: 2px solid var(--color-brand-dark);
  outline-offset: 3px;
}

.view-more {
  margin-top: 8px;
  padding: 6px 10px;
  border: 1px solid var(--color-brand);
  background-color: transparent;
  color: var(--color-brand);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 12px;
}

.view-more:hover {
  background-color: var(--color-brand);
  color: var(--color-surface);
}

.view-more:focus-visible {
  outline: 2px solid var(--color-brand);
  outline-offset: 2px;
}

@media (max-width: 768px) {
  .modal {
    padding: 18px 12px;
  }

  .modal-content {
    margin: 2vh auto;
    width: 100%;
    padding: 24px 20px 20px;
    border-radius: 18px;
    max-height: 88vh;
  }

  .modal-content__header {
    padding-right: 44px;
    gap: 10px;
    padding-bottom: 16px;
  }

  .modal-content__eyebrow,
  .modal-content__category {
    font-size: 10px;
  }

  .modal-content h3 {
    font-size: 1.24rem;
  }

  #modalDescription {
    font-size: 13.5px;
    line-height: 1.72;
  }

  .modal-content__body {
    padding-top: 18px;
  }

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

  .modal-content__media {
    aspect-ratio: 4 / 3;
    border-radius: 16px;
    padding: 22px;
  }

  .modal-content__footer {
    margin-top: 18px;
    padding-top: 16px;
  }

  .close {
    right: 16px;
    top: 16px;
    width: 36px;
    height: 36px;
    font-size: 18px;
  }
}

@media (max-width: 480px) {
  .modal-content {
    padding: 22px 18px 18px;
    border-radius: 16px;
  }

  .modal-content__layout {
    gap: 16px;
  }

  .modal-content__media {
    aspect-ratio: 1 / 1;
    padding: 20px;
  }

  .modal-content h3 {
    font-size: 1.12rem;
  }

  #modalDescription {
    font-size: 13px;
    line-height: 1.68;
  }
}

/* Inquiry Panel */
#products-container tr {
  cursor: pointer;
  transition: background-color var(--motion-fast) var(--ease-standard), box-shadow var(--motion-fast) var(--ease-standard), border-color var(--motion-fast) var(--ease-standard);
}

#products-container tr.product-selected {
  border: 1px solid var(--color-brand) !important;
  background-color: var(--color-brand-soft);
  box-shadow: 0 0 0 2px rgba(204, 0, 0, 0.08);
}

/* Floating inquiry button */
.floating-inquiry-btn {
  position: fixed;
  right: 16px;
  bottom: 16px;
  width: 58px;
  height: 58px;
  border: none;
  border-radius: 50%;
  background: var(--color-brand);
  color: var(--color-surface);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.18);
  cursor: pointer;
  z-index: 1200;
}

.floating-inquiry-btn:hover {
  background: var(--color-brand-dark);
  transform: translateY(-2px);
}

.floating-inquiry-btn:focus-visible {
  outline: 3px solid #ffffff;
  outline-offset: 3px;
  box-shadow: 0 0 0 4px rgba(204, 0, 0, 0.45);
}

.floating-inquiry-icon {
  font-size: 22px;
  line-height: 1;
}

.floating-inquiry-count {
  position: absolute;
  top: -4px;
  right: -2px;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  border-radius: 999px;
  background: #111;
  color: #fff;
  font-size: 11px;
  font-weight: bold;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Panel overlay */
.inquiry-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--motion-base) var(--ease-standard), visibility var(--motion-base) var(--ease-standard);
  z-index: 1190;
}

.inquiry-overlay.active {
  opacity: 1;
  visibility: visible;
}

/* Inquiry panel */
.inquiry-panel {
  position: fixed;
  top: 0;
  right: -360px;
  width: 340px;
  max-width: 92%;
  height: 100vh;
  background: var(--color-surface);
  box-shadow: -12px 0 28px rgba(15, 23, 42, 0.14);
  z-index: 1201;
  transition: right var(--motion-base) var(--ease-standard);
  display: flex;
  flex-direction: column;
}

.inquiry-panel.open {
  right: 0;
}

.inquiry-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px;
  border-bottom: 1px solid #eee;
}

.inquiry-panel-header h3 {
  margin: 0;
  color: var(--color-brand);
  font-size: 18px;
}

.close-panel-btn {
  border: none;
  background: #f3f3f3;
  color: var(--color-text);
  width: 34px;
  height: 34px;
  border-radius: 50%;
  cursor: pointer;
}

.close-panel-btn:hover {
  background: #e6e6e6;
}

.close-panel-btn:focus-visible {
  outline: 2px solid var(--color-brand);
  outline-offset: 2px;
}

.inquiry-empty {
  padding: 16px;
  color: #777;
  font-size: 14px;
}

.inquiry-list {
  padding: 8px 16px 16px;
  overflow-y: auto;
  flex: 1;
}

.inquiry-panel-actions {
  padding: 0 16px 16px;
  border-top: 1px solid #f0f0f0;
  background: var(--color-surface);
}

.inquiry-now-btn {
  width: 100%;
  margin-top: 16px;
  border: none;
  background: var(--color-brand);
  color: var(--color-surface);
  padding: 12px 16px;
  border-radius: var(--radius-md);
  cursor: pointer;
  font-size: 14px;
  font-weight: 700;
  transition: background-color var(--motion-fast) var(--ease-standard), opacity var(--motion-fast) var(--ease-standard);
}

.inquiry-now-btn:hover:not(:disabled) {
  background: #a80000;
}

.inquiry-now-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.inquiry-now-btn:focus-visible:not(:disabled) {
  outline: 2px solid #ffffff;
  outline-offset: 3px;
  box-shadow: 0 0 0 4px rgba(204, 0, 0, 0.35);
}

.inquiry-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 0;
  border-bottom: 1px solid #f0f0f0;
}

.inquiry-item-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--color-text);
}

.remove-inquiry-item {
  border: none;
  background: #fff0f0;
  color: var(--color-brand);
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 12px;
}

.remove-inquiry-item:hover {
  background: #ffdede;
}

@media (max-width: 768px) {
  .floating-inquiry-btn {
    right: 12px;
    bottom: 12px;
    width: 54px;
    height: 54px;
  }

  .inquiry-panel {
    width: 300px;
  }
}
