/* Aprilia Viewer / Brand-Page Consolidated Stylesheet */
/* Shared styles for index.html, category/model list pages, and parts fiche viewer pages */

:root {
  --aprilia-purple: #8b008b; /* Aprilia purple */
  --aprilia-purple-dark: #6a006a; /* Even darker shade for hover states */
  --aprilia-purple-light: #a020a0; /* Lighter shade for accents */
  --light-gray: #F5F5F5; /* Table backgrounds */
  --medium-gray: #E0E0E0; /* Borders and dividers */
  --dark-gray: #666666; /* Secondary text */
  --white: #FFFFFF; /* Main background */
  --text-dark: #333333; /* Primary text */
  --shadow: 0 2px 8px rgba(0,0,0,0.1); /* Subtle shadows */
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: #f0f0f0;
  color: #333;
  min-height: 100vh;
  line-height: 1.6;
}

/* Viewer pages use a white body background instead of the light-gray default */
body.viewer-body {
  background: #ffffff;
}

a { color: inherit; text-decoration: none; }

.cart-overlay {
  display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 2000;
}
.cart-overlay.open { display: block; }
.cart-drawer {
  position: fixed; top: 0; right: -420px; width: 380px; max-width: 90vw;
  height: 100vh; background: white; z-index: 2001; display: flex; flex-direction: column;
  transition: right 0.35s cubic-bezier(0.4,0,0.2,1);
  box-shadow: -4px 0 20px rgba(0,0,0,0.2);
}
.cart-drawer.open { right: 0; }
.cart-drawer-header {
  background: linear-gradient(135deg, #8b008b 0%, #5c005c 100%); color: white;
  padding: 18px 20px; display: flex; align-items: center; justify-content: space-between;
  flex-shrink: 0;
}
.cart-drawer-header h2 { margin: 0; font-size: 1.2em; letter-spacing: 0.05em; }
.cart-close-btn { background: none; border: none; color: white; font-size: 1.8rem; cursor: pointer; line-height: 1; padding: 0 4px; }
.cart-close-btn:hover { opacity: 0.7; }
.cart-drawer-body { flex: 1; overflow-y: auto; padding: 16px; }
.cart-empty { text-align: center; color: #888; font-style: italic; padding: 60px 20px; }
.cart-line-item {
  display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; padding: 12px 0;
  border-bottom: 1px solid #e0e0e0;
}
.cart-item-title { font-weight: bold; font-size: 0.85em; color: #333; grid-column: 1; }
.cart-item-sku { font-size: 0.75em; color: #888; grid-column: 1; }
.cart-item-qty-price { font-size: 0.85em; color: #333; grid-column: 1; }
.cart-item-remove {
  grid-column: 2; grid-row: 1 / 4; background: none; border: none; color: #999;
  font-size: 1.2rem; cursor: pointer; align-self: center; transition: color 0.2s; padding: 0 4px;
}
.cart-item-remove:hover { color: #8b008b; }
.cart-drawer-footer {
  padding: 16px; border-top: 2px solid #e0e0e0; flex-shrink: 0; background: #fafafa;
}
.cart-subtotal { display: flex; justify-content: space-between; font-weight: bold; color: #333; margin-bottom: 14px; }
.cart-checkout-btn {
  display: block; width: 100%; background: linear-gradient(135deg, #8b008b 0%, #5c005c 100%);
  color: white; border: none; padding: 14px; border-radius: 6px; font-size: 1rem;
  font-weight: 600; text-align: center; text-decoration: none; cursor: pointer;
}
.cart-checkout-btn:hover { opacity: 0.88; }
.cart-checkout-btn.disabled { opacity: 0.5; pointer-events: none; }

/* Main Content */
.container {
  margin: 0 auto;
  padding: 0.75rem 2rem 2rem 2rem;
}

/* Viewer pages use tighter side padding than the default */
.container.viewer-container {
  padding: 0 1.5rem 0;
}

/* Category Grid */
.category-card, .model-card {
  background-color: var(--white);
  border: 2px solid var(--aprilia-purple);
  border-radius: 8px;
  padding: 0;
  overflow: hidden;
  text-align: center;
  transition: all 0.3s ease;
  cursor: pointer;
  box-shadow: var(--shadow);
  text-decoration: none;
  color: inherit;
  display: block;
  position: relative;
}

/* Category image */
.category-image {
  width: 100%;
  height: 110px;
  background-color: var(--white);
  border-radius: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 0;
  overflow: hidden;
  padding: 0;
}

.category-image img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  transition: transform 0.3s ease;
}

.category-card:hover .category-image img {
  transform: scale(1.05);
}

.category-card:hover, .model-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 4px 16px rgba(139, 0, 139, 0.2);
  border-color: var(--aprilia-purple-dark);
}

.category-card h3, .model-card h3 {
  margin: 0;
  padding: 0.3rem 0.5rem;
  color: var(--aprilia-purple);
  font-size: clamp(0.75rem, 1.2vw, 1.2rem);
  font-weight: 700;
  background-color: var(--white);
}

/* Tables */
.data-table {
  width: 100%;
  border-collapse: collapse;
  margin: 2rem 0;
  background-color: var(--white);
  box-shadow: var(--shadow);
  border-radius: 8px;
  overflow: hidden;
}

.data-table th {
  background-color: var(--aprilia-purple);
  color: var(--white);
  padding: 1rem;
  text-align: left;
  font-weight: 600;
  font-size: 1rem;
}

.data-table td {
  padding: 1rem;
  border-bottom: 1px solid var(--medium-gray);
  color: var(--text-dark);
}

.data-table tr:nth-child(even) {
  background-color: var(--light-gray);
}

.data-table tr:hover {
  background-color: var(--aprilia-purple-light);
  color: var(--white);
}

.data-table tr:hover td {
  color: var(--white);
}

/* Forms */
.form-group {
  margin-bottom: 1.5rem;
}

.form-label {
  display: block;
  margin-bottom: 0.5rem;
  color: var(--aprilia-purple);
  font-weight: 600;
}

.form-input, .form-select, .form-textarea {
  width: 100%;
  padding: 0.75rem;
  border: 2px solid var(--medium-gray);
  border-radius: 4px;
  font-size: 1rem;
  transition: border-color 0.3s ease;
}

.form-input:focus, .form-select:focus, .form-textarea:focus {
  outline: none;
  border-color: var(--aprilia-purple);
  box-shadow: 0 0 0 3px rgba(139, 0, 139, 0.1);
}

.btn {
  background-color: var(--aprilia-purple);
  color: var(--white);
  border: none;
  padding: 0.75rem 2rem;
  font-size: 1rem;
  font-weight: 600;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.3s ease;
  text-decoration: none;
  display: inline-block;
}

.btn:hover {
  background-color: var(--aprilia-purple-dark);
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}

.btn-secondary {
  background-color: var(--medium-gray);
  color: var(--text-dark);
}

.btn-secondary:hover {
  background-color: var(--dark-gray);
  color: var(--white);
}

/* Status Messages */
.status {
  padding: 1rem;
  border-radius: 4px;
  margin: 1rem 0;
  font-weight: 500;
}

.status.success {
  background-color: #D4EDDA;
  color: #155724;
  border: 1px solid #C3E6CB;
}

.status.error {
  background-color: #F8D7DA;
  color: #721C24;
  border: 1px solid #F5C6CB;
}

.status.warning {
  background-color: #FFF3CD;
  color: #856404;
  border: 1px solid #FFEAA7;
}

/* Responsive Design */
@media (max-width: 768px) {
  body {
    padding: 0;
  }

  .container {
    padding: 0.75rem;
  }

  .category-grid, .model-grid {
    gap: 0.75rem;
  }

  .category-card h3, .model-card h3 {
    font-size: 0.8rem;
  }

  .category-image {
    height: 80px;
  }

  .variant-row {
    padding: 0.15rem 0.6rem;
    gap: 0.5rem;
  }

  .variant-label {
    min-width: unset;
    width: 100%;
    font-size: 0.88rem;
  }

  .years-row {
    gap: 0.25rem;
  }

  .year-btn {
    font-size: 0.75rem;
    padding: 0.28rem 0.55rem;
  }

  .data-table {
    font-size: 0.9rem;
  }

  .data-table th, .data-table td {
    padding: 0.5rem;
  }
}

@media (max-width: 480px) {
  .category-grid, .model-grid {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 0.5rem;
  }
  .category-card, .model-card {
    max-width: none !important;
    width: 100% !important;
  }
  .category-image {
    height: 70px !important;
  }
  .category-card h3, .model-card h3 {
    font-size: 0.75rem !important;
    padding: 0.25rem 0.3rem !important;
  }
}

/* Loading Spinner */
.loading {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 3px solid var(--light-gray);
  border-top: 3px solid var(--aprilia-purple);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* Breadcrumb */
.breadcrumb {
  margin-bottom: 0.2rem;
  color: var(--dark-gray);
  font-weight: 700;
  text-transform: uppercase;
}

.breadcrumb a {
  color: var(--aprilia-purple);
  text-decoration: none;
}

.breadcrumb a:hover {
  text-decoration: underline;
}

.breadcrumb .separator {
  margin: 0 0.5rem;
  color: var(--medium-gray);
}

/* Model Details */
.model-details {
  display: grid;
  grid-template-columns: 1fr 2fr;
  gap: 2rem;
  margin-top: 2rem;
}

.model-info h2 {
  color: var(--aprilia-purple);
  margin-bottom: 1rem;
}

.model-info .specs {
  background-color: var(--light-gray);
  padding: 1rem;
  border-radius: 4px;
  margin-top: 1rem;
}

.model-info .specs dt {
  color: var(--aprilia-purple);
  font-weight: 600;
  margin-top: 1rem;
}

.model-info .specs dd {
  color: var(--text-dark);
  margin-left: 0;
  margin-bottom: 0.5rem;
}

/* ── Model Year Selection Page ─────────────────────────── */
.variants-grid {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  margin-top: 0.6rem;
}

.variant-row {
  background-color: var(--white);
  border: 2px solid var(--aprilia-purple);
  border-radius: 6px;
  padding: 0.2rem 0.8rem;
  display: flex;
  align-items: center;
  gap: 0.9rem;
  box-shadow: var(--shadow);
  flex-wrap: wrap;
}

.variant-label {
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--aprilia-purple);
  min-width: 165px;
  line-height: 1.25;
}

.years-row {
  display: flex;
  flex-direction: row;
  gap: 0.35rem;
  flex-wrap: wrap;
}

.year-btn {
  background-color: var(--aprilia-purple);
  color: var(--white);
  border: none;
  padding: 0.35rem 0.7rem;
  border-radius: 3px;
  cursor: pointer;
  font-size: 0.8rem;
  font-weight: 600;
  text-decoration: none;
  display: inline-block;
  transition: all 0.3s ease;
}

.year-btn:hover {
  background-color: var(--aprilia-purple-dark);
  transform: translateY(-1px);
  box-shadow: var(--shadow);
}

.year-btn.unavailable {
  background-color: var(--medium-gray);
  color: var(--dark-gray);
  cursor: not-allowed;
  pointer-events: none;
  opacity: 0.6;
}



/* ===== Viewer-specific overrides ===== */

/* Aprilia Viewer Shared Stylesheet */
/* Single source of truth for all viewer pages pages (thousands of generated pages) */
/* Style-only changes here take effect on every viewer page without regeneration — */
/* just bump the ?v= query param on the <link> tag to bust the browser cache. */

/* ── Sticky footer: attach to bottom with no white gap ── */
html, body {
    min-height: 100vh;
    margin: 0;
    padding: 0;
}

body {
    min-height: 100vh;
    display: flex !important;
    flex-direction: column !important;
}

script {
    display: none !important;
}

.container {
    max-width: none !important;
    width: 100% !important;
    padding-bottom: 2rem !important;
}

.container,
#content {
    flex: 1 0 0 !important;
}

.site-footer {
    margin: 0 !important;
    margin-top: auto !important;
    align-self: stretch !important;
    width: 100% !important;
}

/* ── Section list (category grid of diagram sections) ── */
.section-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 15px;
    margin-bottom: 30px;
}

.section-card {
    background: #f5f5f5;
    padding: 20px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    border: 2px solid #e0e0e0;
}

.section-card:hover {
    border-color: #8b008b;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(139, 0, 139, 0.2);
}

.section-card h3 {
    color: #8b008b;
    margin-bottom: 10px;
    font-size: 1.2em;
}

.section-card .info {
    color: #666;
    font-size: 0.9em;
}

.section-detail {
    display: none;
    margin-top: 0;
}

.section-detail.active {
    display: block;
}

/* ── Fiche layout: header row + thumbnail row + diagram/parts row ── */
#section-detail .fiche-layout {
    display: grid;
    grid-template-columns: 55fr 45fr;
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    margin-bottom: 0;
    overflow: hidden;
}

#section-detail .fiche-layout .brand-subheader {
    grid-column: 1 / -1;
    margin: 0;
    border-radius: 0;
    box-shadow: none;
    background: #fff;
}

#section-detail .fiche-layout .thumbnail-panel {
    grid-column: 1 / -1;
    border-top: 2px solid #8b008b;
    border-bottom: 2px solid #8b008b;
    background: #fff;
    padding: 0 0 10px;
}

#section-detail .fiche-layout .thumbnail-panel .section-nav {
    display: flex;
    gap: 12px;
    overflow-x: auto;
    border: none;
    border-radius: 0;
    margin-bottom: 0;
    background: transparent;
    padding: 10px 8px 17px;
    scrollbar-width: auto;
    scrollbar-color: #8b008b #fff;
}

.section-nav::-webkit-scrollbar {
    height: 32px;
    background: #fff;
}

.section-nav::-webkit-scrollbar-track {
    background: #fff;
    border-radius: 4px;
}

.section-nav::-webkit-scrollbar-thumb {
    background: #8b008b;
    border-radius: 4px;
}

/* ── Diagram panel: centered, stretch to fill height ── */
.diagram-panel {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    padding: 20px;
    text-align: center;
    border-right: 1px solid #e0e0e0;
}

.diagram-panel h3 {
    color: #8b008b;
    margin-bottom: 15px;
    font-size: 1.2em;
}

#detail-diagram {
    width: 100%;
}

.diagram-panel img,
#detail-diagram img {
    width: 100%;
    max-width: 100%;
    height: auto;
    display: block;
    border-radius: 4px;
    cursor: zoom-in;
    transition: transform 0.2s;
}

.diagram-panel img:hover {
    transform: scale(1.02);
}

/* ── Parts panel ── */
.parts-panel {
    display: flex;
    flex-direction: column;
    max-height: 700px;
}

.parts-table-container {
    flex: 1;
    overflow-y: auto;
    font-size: 0.85em;
    padding: 0 10px 4px;
    position: relative;
}

.parts-table-container::-webkit-scrollbar {
    width: 8px;
}

.parts-table-container::-webkit-scrollbar-track {
    background: #e0e0e0;
    border-radius: 4px;
}

.parts-table-container::-webkit-scrollbar-thumb {
    background: #8b008b;
    border-radius: 4px;
}

/* ── Brand subheader (back link / title / filter buttons / diagram name row) ── */
.brand-subheader {
    width: 100%;
    background: #fff;
    color: #333;
    padding: 0.75rem 1rem;
    display: flex;
    flex-wrap: wrap;
    align-items: stretch;
    justify-content: space-between;
    gap: 0.75rem 1rem;
}

.brand-subheader .breadcrumb {
    color: #666;
    font-size: 0.9rem;
    margin-bottom: 0;
    display: flex !important;
    flex-direction: column !important;
    align-items: flex-start !important;
    justify-content: center;
    gap: 2px;
    text-transform: none !important;
    font-weight: 500 !important;
}

.brand-subheader .breadcrumb a {
    color: #8b008b;
    text-decoration: none;
}

.brand-subheader .breadcrumb a:hover {
    text-decoration: underline;
}

.brand-subheader h1 {
    font-size: 0.9rem;
    color: #8b008b;
    margin: 0;
    font-weight: bold;
    text-transform: uppercase;
}

.brand-subheader .section-filter {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: nowrap;
    gap: 10px;
    margin: 0;
}

.brand-subheader .model-meta {
    font-size: 0.85rem;
    color: #666;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    justify-content: center;
    gap: 2px;
}

.brand-subheader .model-meta strong {
    color: #333;
}

.brand-subheader .model-meta .diagram-name {
    color: #8b008b;
    font-weight: bold;
}

/* ── Thumbnail nav cards ── */
.section-nav-item {
    flex-shrink: 0;
    cursor: pointer;
    transition: all 0.3s;
}

.section-nav-card {
    background: white;
    border: none;
    border-radius: 8px;
    padding: 0 0 3px 0;
    width: 170px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    transition: all 0.3s;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
}

.section-nav-item:hover .section-nav-card {
    box-shadow: 0 2px 8px rgba(139, 0, 139, 0.25);
}

.section-nav-item.active .section-nav-card {
    outline: 3px solid #8b008b;
}

.section-nav-text {
    font-size: 0.7em;
    color: #333;
    line-height: 1.2;
    text-align: center;
    word-wrap: break-word;
    min-height: 2.4em;
    display: flex;
    align-items: center;
    justify-content: center;
}

.section-nav-item.active .section-nav-text {
    color: #8b008b;
    font-weight: bold;
}

.section-nav-thumb {
    width: 100%;
    height: 100px;
    object-fit: contain;
    border-radius: 4px;
    display: block;
    background: #fff;
}

/* ── Section filter buttons (Frame / Engine / Electric/Electrical) ── */
.section-filter {
    display: flex;
    gap: 10px;
    margin: 10px 0;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
}

.section-filter button {
    background: #f5f5f5;
    color: #333;
    border: 1px solid #e0e0e0;
    padding: 10px 20px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 0.9em;
    font-weight: 500;
    transition: all 0.3s;
}

.section-filter button:hover {
    background: #8b008b;
    border-color: #8b008b;
    color: white;
}

.section-filter button.active {
    background: #8b008b;
    border-color: #8b008b;
    color: white;
}

.section-filter-link {
    background: #f5f5f5;
    color: #333;
    border: 1px solid #e0e0e0;
    padding: 10px 20px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 0.9em;
    font-weight: 500;
    transition: all 0.3s;
    text-decoration: none;
    display: inline-block;
    line-height: normal;
    white-space: nowrap;
}

.section-filter-link:hover {
    background: #8b008b;
    border-color: #8b008b;
    color: white;
}

/* ── Section filter back button (plain link style on viewer pages) ── */
.section-filter-back {
    color: #666 !important;
    font-size: 0.9rem !important;
    font-weight: 500 !important;
    text-transform: none !important;
    text-decoration: none !important;
    display: inline-flex !important;
    align-items: center;
    gap: 6px;
    transition: color 0.15s;
    background: none !important;
    border: none !important;
    padding: 0 !important;
    border-radius: 0 !important;
}

.section-filter-back:hover {
    color: #8b008b !important;
    text-decoration: underline !important;
}

/* ── Parts table ── */
.parts-table {
    width: 100%;
    border-collapse: collapse;
}

.parts-table th,
.parts-table td {
    padding: 8px 6px;
    text-align: left;
    border-bottom: 1px solid #e0e0e0;
    font-size: 0.9em;
    white-space: nowrap;
}

.parts-table td:nth-child(3),
.parts-table th:nth-child(3) {
    white-space: normal;
    width: 99%;
}

.parts-table th:nth-child(1), .parts-table td:nth-child(1) { width: 36px;  min-width: 36px; }
.parts-table th:nth-child(2), .parts-table td:nth-child(2) { width: 90px;  min-width: 90px; }
.parts-table th:nth-child(4), .parts-table td:nth-child(4) { width: 28px;  min-width: 28px; }
.parts-table th:nth-child(5), .parts-table td:nth-child(5) { width: 62px;  min-width: 62px; }
.parts-table th:nth-child(6), .parts-table td:nth-child(6) { width: 44px;  min-width: 44px; text-align: center; }
.parts-table th:nth-child(7), .parts-table td:nth-child(7) { width: 48px;  min-width: 48px; }
.parts-table th:nth-child(8), .parts-table td:nth-child(8) { width: 60px;  min-width: 60px; padding-left: 16px; }

.avail-circle {
    display: inline-block;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    vertical-align: middle;
}
.avail-circle.green  { background: #2e7d32; }
.avail-circle.yellow { background: #f3cd33; }
.avail-circle.red    { background: #cc0000; }
.avail-circle.grey {
    background: #bbb;
    animation: avail-pulse 1.2s ease-in-out infinite;
}

@keyframes avail-pulse {
    0%, 100% { background: #bbb; box-shadow: 0 0 0 0 rgba(187,187,187,0.7); }
    50%       { background: #ddd; box-shadow: 0 0 0 5px rgba(187,187,187,0); }
}

.cart-qty-input {
    width: 44px;
    padding: 3px 4px;
    border: 1px solid #ccc;
    border-radius: 4px;
    text-align: center;
    font-size: 0.85em;
}

.add-btn {
    background: #8b008b;
    color: white;
    border: none;
    padding: 4px 8px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.8em;
    font-weight: bold;
    white-space: nowrap;
    transition: background 0.2s;
}

.add-btn:hover { background: #6a006a; }

.add-btn.success {
    background: #2e7d32;
    cursor: default;
}

.add-btn.error {
    background: #555;
    cursor: default;
}

.parts-table tr:hover .cart-qty-input {
    border-color: white;
}

.parts-table th {
    background: white;
    color: #8b008b;
    font-weight: bold;
    border-bottom: 2px solid #8b008b;
}

.parts-table tr:hover {
    background: #8b008b;
    color: white;
}

.parts-table tr:hover .price {
    color: white;
}

.parts-table .price {
    color: #333333;
    font-weight: bold;
}

.no-parts {
    text-align: center;
    padding: 40px;
    color: #888;
    font-style: italic;
}

.loading {
    text-align: center;
    padding: 60px;
    color: #888;
}

.loading::after {
    content: '...';
    animation: dots 1.5s steps(4, end) infinite;
}

@keyframes dots {
    0%, 20% { content: '.'; }
    40% { content: '..'; }
    60%, 100% { content: '...'; }
}

/* ── Image lightbox modal ── */
.image-modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.9);
    cursor: pointer;
}

.image-modal.active {
    display: flex;
    align-items: center;
    justify-content: center;
}

.image-modal img {
    max-width: 95%;
    max-height: 95%;
    object-fit: contain;
    border-radius: 4px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.5);
}

.image-modal .close-btn {
    position: absolute;
    top: 20px;
    right: 40px;
    color: white;
    font-size: 40px;
    font-weight: bold;
    cursor: pointer;
    z-index: 1001;
}

.image-modal .close-btn:hover {
    color: #8b008b;
}

/* ── Fiche details SEO summary block: no extra top/bottom whitespace ── */
.fiche-details-wrapper {
    padding: 0 !important;
}

/* ── Cart icon button (in shared header) ── */
.cart-icon-btn {
    position: relative;
    background: rgba(255,255,255,0.2);
    border: 2px solid white;
    border-radius: 5px;
    padding: 8px 14px;
    cursor: pointer;
    color: white;
    font-size: 1.3em;
    line-height: 1;
    transition: background 0.3s;
    display: flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
    width: 140px;
    justify-content: center;
}
.cart-icon-btn:hover { background: rgba(255,255,255,0.35); }
.cart-badge {
    position: absolute;
    top: -7px;
    right: -7px;
    background: white;
    color: #8b008b;
    font-size: 0.65em;
    font-weight: bold;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.2s;
}
.cart-badge.visible { opacity: 1; }
.cart-badge.bump { animation: badge-bump 0.3s ease; }
@keyframes badge-bump {
    0%   { transform: scale(1); }
    50%  { transform: scale(1.5); }
    100% { transform: scale(1); }
}

/* ── Mobile: Stack diagram above parts table ── */
@media (max-width: 768px) {
    body {
        padding: 0 !important;
    }

    .brand-subheader {
        flex-direction: column !important;
        align-items: center !important;
        text-align: center !important;
        gap: 0.5rem !important;
    }

    .brand-subheader .breadcrumb {
        align-items: center !important;
    }

    .brand-subheader .section-filter {
        width: 100% !important;
        margin: 0 !important;
    }

    .brand-subheader .model-meta {
        align-items: center !important;
        text-align: center !important;
    }

    /* Stack diagram on top, parts table below */
    #section-detail .fiche-layout {
        grid-template-columns: 1fr !important;
    }

    .diagram-panel {
        border-right: none !important;
        border-bottom: 1px solid #e0e0e0 !important;
    }

    .diagram-panel img {
        max-height: 320px !important;
    }

    .parts-table-container {
        max-height: none !important;
        overflow-y: visible !important;
    }

    .section-list {
        grid-template-columns: 1fr !important;
    }

    .panel-tabs {
        flex-wrap: wrap !important;
    }

    .section-filter {
        flex-wrap: wrap !important;
        gap: 6px !important;
    }

    .section-filter-back {
        width: 100% !important;
        flex: none !important;
        order: -1 !important;
        margin-bottom: 6px !important;
        text-align: center !important;
        justify-content: center !important;
    }

    .section-filter button, .section-filter-link {
        font-size: 0.75em !important;
        padding: 7px 10px !important;
        flex: 1 !important;
        text-align: center !important;
        white-space: nowrap !important;
    }

    .breadcrumb {
        flex-wrap: wrap !important;
        font-size: 0.8em !important;
    }

    /* Diagram thumbnail selector: 3-column grid, scroll vertically */
    .thumbnail-panel .section-nav {
        display: grid !important;
        grid-template-columns: repeat(3, 1fr) !important;
        gap: 8px !important;
        overflow-x: visible !important;
        overflow-y: auto !important;
        max-height: 340px !important;
        padding: 10px 8px !important;
    }

    .section-nav-item {
        flex-shrink: unset !important;
    }

    .section-nav-card {
        width: 100% !important;
    }

    .section-nav-text {
        font-size: 0.65em !important;
    }

    /* Hide less critical columns on mobile: Req (4), Qty (7) */
    .parts-table th:nth-child(4),
    .parts-table td:nth-child(4),
    .parts-table th:nth-child(7),
    .parts-table td:nth-child(7) {
        display: none !important;
    }

    /* Shrink Part # and fixed cols to save space */
    .parts-table th:nth-child(1), .parts-table td:nth-child(1) { width: 28px !important; min-width: 28px !important; }
    .parts-table th:nth-child(2), .parts-table td:nth-child(2) { width: 70px !important; min-width: 70px !important; font-size: 0.78em !important; }
    .parts-table th:nth-child(5), .parts-table td:nth-child(5) { width: 52px !important; min-width: 52px !important; }
    .parts-table th:nth-child(6), .parts-table td:nth-child(6) { width: 36px !important; min-width: 36px !important; }
    .parts-table th:nth-child(8), .parts-table td:nth-child(8) { width: 52px !important; min-width: 52px !important; padding-left: 4px !important; }

    .parts-table-container {
        overflow-x: hidden !important;
    }

    .parts-table th, .parts-table td {
        padding: 6px 4px !important;
        font-size: 0.72em !important;
    }
}

/* ── Responsive category/model grids: fixed 200x160 cards, wrap as page shrinks ── */
.category-grid, .model-grid {
    display: grid !important;
    grid-template-columns: repeat(auto-fit, 200px) !important;
    width: 100% !important;
    justify-content: center !important;
    gap: 1rem !important;
}

.category-card, .model-card {
    max-width: 200px !important;
    width: 100% !important;
    aspect-ratio: 5 / 4 !important;
    display: flex !important;
    flex-direction: column !important;
    min-height: 0 !important;
}

.category-card h3, .model-card h3 {
    font-size: clamp(0.65rem, 1vw, 1rem) !important;
    flex-shrink: 0 !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
}

.category-image {
    flex: 1 1 auto !important;
    height: auto !important;
    min-height: 0 !important;
}

.category-image img {
    width: 100% !important;
    height: 100% !important;
    object-fit: contain !important;
}

/* Make model-card .link an invisible overlay so model cards look/feel like category cards */
.model-card {
    position: relative !important;
}

.model-card .link {
    position: absolute !important;
    inset: 0 !important;
    background: transparent !important;
    color: transparent !important;
    padding: 0 !important;
    margin: 0 !important;
    font-size: 0 !important;
    z-index: 10 !important;
}

.model-card .link::after {
    content: none !important;
}
