/* ============================================================
   TSMS – Products Page, Drawer & Comparison Tray
   ============================================================ */

/* ── PRODUCTS PAGE LAYOUT ── */
.products-page { background: var(--stone); padding: var(--section-padding); }

.products-section-label {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 2rem;
  margin-top: 3.5rem;
}
.products-section-label:first-of-type { margin-top: 3rem; }
.products-section-label h3 {
  font-family: var(--font-display);
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--charcoal);
  white-space: nowrap;
}
.products-section-label::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* Product cards grid */
.products-grid { display: grid; grid-template-columns: repeat(3,1fr); gap: 1.5rem; }

.product-card {
  background: var(--white);
  border-radius: var(--radius-lg);
  overflow: hidden;
  transition: transform 0.25s, box-shadow 0.25s;
  display: flex; flex-direction: column;
}
.product-card:hover { transform: translateY(-3px); box-shadow: 0 12px 32px rgba(0,0,0,0.09); }

.product-img {
  width: 100%; aspect-ratio: 4/3;
  background: var(--panel-bg);
  display: flex; align-items: center; justify-content: center;
  overflow: hidden; position: relative;
}
.product-img img {
  width: 100%; height: 100%; object-fit: cover;
  transition: transform 0.4s ease;
}
.product-card:hover .product-img img { transform: scale(1.04); }

.product-img-placeholder {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 0.5rem; width: 100%; height: 100%;
  color: var(--steel); font-size: 0.78rem;
}

.product-body { padding: 1.4rem; flex: 1; display: flex; flex-direction: column; }

.product-tag {
  display: inline-block;
  font-size: 0.68rem; font-weight: 600;
  letter-spacing: 1.5px; text-transform: uppercase;
  color: var(--charcoal); background: rgba(26,26,26,0.07);
  padding: 0.22rem 0.55rem; border-radius: 3px;
  margin-bottom: 0.55rem;
}

.product-name {
  font-family: var(--font-display);
  font-weight: 700; font-size: 1.1rem;
  color: var(--charcoal); margin-bottom: 0.45rem;
}
.product-desc { font-size: 0.85rem; line-height: 1.6; color: var(--mid); flex: 1; }

.product-actions {
  display: flex; gap: 0.6rem;
  padding: 0 1.4rem 1.4rem;
  flex-wrap: wrap;
}

.btn-specs {
  flex: 1;
  background: var(--charcoal); color: var(--white);
  border: none; padding: 0.6rem 1rem;
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: 0.82rem; font-weight: 600;
  cursor: pointer; transition: background var(--transition);
  text-align: center;
}
.btn-specs:hover { background: var(--green-light); }

.btn-compare {
  flex: 1;
  background: transparent;
  border: 1.5px solid var(--border);
  color: var(--charcoal);
  padding: 0.6rem 1rem;
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: 0.82rem; font-weight: 600;
  cursor: pointer;
  transition: border-color var(--transition), background var(--transition), color var(--transition);
  text-align: center;
}
.btn-compare:hover { border-color: var(--charcoal); }
.btn-compare.selected {
  background: var(--charcoal); color: var(--white);
  border-color: var(--charcoal);
}
.btn-compare.disabled { opacity: 0.35; cursor: not-allowed; }

/* ── DRAWER ── */
.drawer-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,0.45); z-index: 150;
  backdrop-filter: blur(3px);
}
.drawer-overlay.open { display: block; }

.drawer {
  position: fixed; top: 0; right: 0; bottom: 0;
  width: min(520px, 100vw);
  background: var(--white);
  z-index: 151;
  transform: translateX(100%);
  transition: transform 0.35s cubic-bezier(0.4,0,0.2,1);
  display: flex; flex-direction: column;
  overflow: hidden;
}
.drawer.open { transform: translateX(0); }

.drawer-img {
  width: 100%; aspect-ratio: 16/9;
  background: var(--panel-bg);
  flex-shrink: 0; overflow: hidden;
  display: flex; align-items: center; justify-content: center;
}
.drawer-img img { width: 100%; height: 100%; object-fit: cover; }

.drawer-body {
  padding: 1.8rem 2rem;
  overflow-y: auto; flex: 1;
}
.drawer-tag {
  font-size: 0.68rem; font-weight: 600;
  letter-spacing: 1.5px; text-transform: uppercase;
  color: var(--mid); margin-bottom: 0.4rem;
}
.drawer-name {
  font-family: var(--font-display);
  font-size: 1.6rem; font-weight: 700;
  color: var(--charcoal); margin-bottom: 0.8rem; line-height: 1.2;
}
.drawer-desc {
  font-size: 0.9rem; line-height: 1.7;
  color: var(--mid); margin-bottom: 1.8rem;
  padding-bottom: 1.5rem; border-bottom: 1px solid var(--border);
}

/* Spec table */
.spec-table { width: 100%; border-collapse: collapse; margin-bottom: 2rem; }
.spec-table tr { border-bottom: 1px solid var(--border); }
.spec-table tr:last-child { border-bottom: none; }
.spec-table td {
  padding: 0.65rem 0;
  font-size: 0.875rem; line-height: 1.5;
  vertical-align: top;
}
.spec-table td:first-child {
  color: var(--mid); font-weight: 500;
  width: 42%; padding-right: 1rem;
}
.spec-table td:last-child { color: var(--charcoal); font-weight: 400; }

/* Colour swatches */
.colour-swatches { display: flex; gap: 0.5rem; margin-top: 0.2rem; flex-wrap: wrap; }
.swatch {
  width: 22px; height: 22px; border-radius: 50%;
  border: 2px solid rgba(0,0,0,0.1);
  cursor: default; position: relative;
}
.swatch[title]:hover::after {
  content: attr(title);
  position: absolute; bottom: 130%; left: 50%; transform: translateX(-50%);
  background: var(--charcoal); color: var(--white);
  font-size: 0.7rem; padding: 0.2rem 0.5rem;
  border-radius: 3px; white-space: nowrap; z-index: 10;
}

.drawer-cta {
  width: 100%; background: var(--charcoal); color: var(--white);
  border: none; padding: 0.9rem;
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: 0.95rem; font-weight: 600;
  cursor: pointer; transition: background var(--transition);
}
.drawer-cta:hover { background: var(--green-light); }

.drawer-close {
  position: absolute; top: 1rem; right: 1rem;
  width: 36px; height: 36px; border-radius: 50%;
  background: rgba(255,255,255,0.9); border: none;
  font-size: 1.1rem; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
  transition: background var(--transition); z-index: 5;
}
.drawer-close:hover { background: var(--white); }

/* ── COMPARISON TRAY ── */
.compare-tray {
  position: fixed; bottom: 0; left: 0; right: 0;
  background: var(--charcoal);
  z-index: 140;
  transform: translateY(100%);
  transition: transform 0.35s cubic-bezier(0.4,0,0.2,1);
  padding: 1rem 5%;
  display: flex; align-items: center; gap: 1.5rem;
  flex-wrap: wrap;
}
.compare-tray.visible { transform: translateY(0); }

.tray-label {
  font-size: 0.8rem; font-weight: 600;
  color: var(--sand); letter-spacing: 0.5px;
  text-transform: uppercase; flex-shrink: 0;
}

.tray-items {
  display: flex; gap: 0.75rem; flex: 1; flex-wrap: wrap;
}

.tray-item {
  display: flex; align-items: center; gap: 0.5rem;
  background: rgba(255,255,255,0.1);
  border-radius: var(--radius-sm);
  padding: 0.4rem 0.8rem;
  font-size: 0.85rem; font-weight: 500; color: var(--white);
}
.tray-item-remove {
  background: none; border: none;
  color: rgba(255,255,255,0.5);
  cursor: pointer; font-size: 1rem; line-height: 1;
  padding: 0; margin-left: 0.2rem;
  transition: color var(--transition);
}
.tray-item-remove:hover { color: var(--white); }

.tray-slots {
  display: flex; gap: 0.5rem;
}
.tray-slot {
  width: 100px; height: 36px;
  border: 1.5px dashed rgba(255,255,255,0.2);
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  font-size: 0.72rem; color: rgba(255,255,255,0.3);
}

.tray-actions { display: flex; gap: 0.75rem; flex-shrink: 0; }

.btn-do-compare {
  background: var(--sand); color: var(--charcoal);
  border: none; padding: 0.6rem 1.4rem;
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: 0.875rem; font-weight: 700;
  cursor: pointer; transition: opacity var(--transition);
}
.btn-do-compare:hover { opacity: 0.88; }

.btn-clear-compare {
  background: transparent;
  border: 1px solid rgba(255,255,255,0.25);
  color: rgba(255,255,255,0.7);
  padding: 0.6rem 1rem;
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: 0.82rem; font-weight: 500;
  cursor: pointer; transition: border-color var(--transition), color var(--transition);
}
.btn-clear-compare:hover { border-color: rgba(255,255,255,0.5); color: var(--white); }

/* ── COMPARISON TABLE MODAL ── */
.compare-modal-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,0.6); z-index: 160;
  backdrop-filter: blur(4px);
  align-items: flex-start; justify-content: center;
  padding: 2rem 1rem; overflow-y: auto;
}
.compare-modal-overlay.open { display: flex; }

.compare-modal {
  background: var(--white);
  border-radius: var(--radius-lg);
  width: 100%; max-width: 900px;
  overflow: hidden;
  margin: auto;
}

.compare-modal-header {
  padding: 1.5rem 2rem;
  display: flex; justify-content: space-between; align-items: center;
  border-bottom: 1px solid var(--border);
}
.compare-modal-header h3 {
  font-family: var(--font-display);
  font-size: 1.3rem; font-weight: 700; color: var(--charcoal);
}
.compare-modal-close {
  background: none; border: none;
  font-size: 1.3rem; cursor: pointer;
  color: var(--mid); transition: color var(--transition);
}
.compare-modal-close:hover { color: var(--charcoal); }

.compare-table-wrap { overflow-x: auto; }

.compare-table {
  width: 100%; border-collapse: collapse;
  min-width: 480px;
}

/* Column headers with product names */
.compare-table thead tr th {
  padding: 1.2rem 1.5rem;
  text-align: left;
  border-bottom: 2px solid var(--border);
  vertical-align: top;
}
.compare-table thead tr th:first-child {
  width: 28%; color: var(--mid);
  font-size: 0.75rem; letter-spacing: 1px;
  text-transform: uppercase; font-weight: 500;
}
.compare-col-name {
  font-family: var(--font-display);
  font-size: 1.1rem; font-weight: 700;
  color: var(--charcoal); display: block; margin-bottom: 0.2rem;
}
.compare-col-tag {
  font-size: 0.7rem; color: var(--mid);
  text-transform: uppercase; letter-spacing: 1px;
}

/* Rows */
.compare-table tbody tr { border-bottom: 1px solid var(--border); }
.compare-table tbody tr:last-child { border-bottom: none; }
.compare-table tbody tr:hover { background: var(--stone); }

.compare-table tbody td {
  padding: 0.7rem 1.5rem;
  font-size: 0.875rem; vertical-align: top;
}
.compare-table tbody td:first-child {
  color: var(--mid); font-weight: 500;
  font-size: 0.82rem;
}

/* Highlight differing values */
.compare-table tbody td.diff {
  background: rgba(200,184,154,0.15);
  font-weight: 600;
}

.compare-modal-footer {
  padding: 1.2rem 2rem;
  border-top: 1px solid var(--border);
  display: flex; justify-content: flex-end; gap: 0.75rem;
}

/* ── RESPONSIVE ── */
@media (max-width: 900px) {
  .products-grid { grid-template-columns: 1fr 1fr; }
  .drawer { width: 100vw; }
}
@media (max-width: 580px) {
  .products-grid { grid-template-columns: 1fr; }
  .tray-slots { display: none; }
  .compare-tray { gap: 0.75rem; }
}
