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

:root {
  --ducati-red: #B00E0A; /* Darker Ducati red */
  --ducati-red-dark: #8A0B08; /* Even darker shade for hover states */
  --ducati-red-light: #D41A15; /* 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 */
}

* {
  box-sizing: border-box;
}

body {
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  margin: 0;
  padding: 0;
  background-color: var(--white);
  color: var(--ducati-red);
  line-height: 1.6;
  min-height: 100vh;
}

.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, #cc0000 0%, #8b0000 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: #cc0000; }
.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, #cc0000 0%, #8b0000 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;
}

/* Category Grid */
.category-card, .model-card {
  background-color: var(--white);
  border: 2px solid var(--ducati-red);
  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(220, 20, 60, 0.2);
  border-color: var(--ducati-red-dark);
}

.category-card h3, .model-card h3 {
  margin: 0;
  padding: 0.3rem 0.5rem;
  color: var(--ducati-red);
  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(--ducati-red);
  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(--ducati-red-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(--ducati-red);
  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(--ducati-red);
  box-shadow: 0 0 0 3px rgba(220, 20, 60, 0.1);
}

.btn {
  background-color: var(--ducati-red);
  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(--ducati-red-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);
    gap: 0.5rem;
  }
}

/* Loading Spinner */
.loading {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 3px solid var(--light-gray);
  border-top: 3px solid var(--ducati-red);
  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(--ducati-red);
  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(--ducati-red);
  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(--ducati-red);
  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(--ducati-red);
  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(--ducati-red);
  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(--ducati-red);
  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(--ducati-red-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 ===== */

/* Ducati Viewer Shared Stylesheet */
/* Overrides and additions for viewer-*.html pages */
/* Injected via batch script — safe to edit for future changes */

/* ── 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;
}

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

/* ── Brand-page style header / footer ── */
.brand-page__header {
    background: linear-gradient(135deg, #cc0000 0%, #8b0000 100%);
    color: white;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.3);
    margin: 12px 20px 30px 20px;
    position: static !important;
}

.brand-page__header-inner {
    width: 100%;
    padding: 12px 30px 0;
    display: flex;
    flex-direction: column;
}

.brand-page__header-top {
    display: flex;
    align-items: center;
    width: 100%;
    gap: 15px;
    min-height: 70px;
}

.brand-page__header-logo { height: 70px; width: auto; filter: brightness(0) invert(1); }

.brand-page__header-title {
    margin: 0;
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.25em;
    color: white;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    font-size: 2rem;
}

.brand-page__header-title .brand-page__header-label { font-size: 1em; }
.brand-page__header-title .brand-page__header-model {
    font-size: 0.8em;
    max-width: 25ch;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    cursor: help;
    text-shadow: 0 1px 2px rgba(0,0,0,0.5);
}

.brand-page__header-contact {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.25rem;
    font-size: 0.75rem;
    color: rgba(255,255,255,0.9);
}

.brand-page__header-contact a {
    color: rgba(255,255,255,0.9);
    text-decoration: none;
    transition: color 0.15s;
    text-transform: uppercase;
}

.brand-page__header-contact a:hover { color: white; }

.brand-page__header-social {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.25rem;
    align-items: center;
}

.brand-page__header-social a { color: rgba(255,255,255,0.9); text-decoration: none; transition: color 0.15s; }
.brand-page__header-social a:hover { color: white; }
.brand-page__header-social img { filter: brightness(0) invert(1); vertical-align: middle; }

.brand-page__header-nav {
    border-top: 1px solid rgba(255,255,255,0.2);
    margin-top: 8px;
    padding-top: 4px;
    padding-bottom: 4px;
    display: flex;
    gap: 2rem;
    justify-content: center;
}

.brand-page__header-nav a {
    color: rgba(255,255,255,0.8);
    font-size: 0.875rem;
    font-weight: 500;
    text-decoration: none;
    transition: color 0.15s;
    text-transform: uppercase;
}

.brand-page__header-nav a:hover { color: white; }
.brand-page__header-nav-sep { color: rgba(255,255,255,0.3); }

.brand-page__header-cart {
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    color: white;
    text-decoration: none;
    margin-left: 20px;
    background: transparent;
    border: none;
    padding: 0;
    cursor: pointer;
}

.brand-page__header-cart svg { width: 45px; height: 45px; fill: currentColor; }
.brand-page__header-cart-count {
    position: absolute; top: -10px; right: -12px; background: white; color: #cc0000;
    font-size: 0.75rem; font-weight: 700; width: 20px; height: 20px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center; line-height: 1;
}

.brand-page__footer {
    background: linear-gradient(135deg, #cc0000 0%, #8b0000 100%);
    color: rgba(255,255,255,0.9);
    padding: 0.6rem 20px;
    width: 100%;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.brand-page__footer p { margin: 0; }
.brand-page__footer-inner {
    width: 100%;
    text-align: center;
    font-size: 0.8rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.4rem;
}

.brand-page__footer-links { display: flex; gap: 1.5rem; flex-wrap: wrap; justify-content: center; }
.brand-page__footer-links a { color: rgba(255,255,255,0.8); text-decoration: none; transition: color 0.15s; }
.brand-page__footer-links a:hover { color: white; }
.brand-page__footer-contact { font-size: 0.75rem; color: rgba(255,255,255,0.7); }

/* ── Desktop: 55% diagram / 45% parts list ── */
.fiche-layout {
    grid-template-columns: 55fr 45fr !important;
}

/* ── Section filter back button ── */
.section-filter-back {
    background: #f5f5f5;
    color: #333;
    border: 1px solid #e0e0e0;
    padding: 8px 16px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 0.9em;
    font-weight: 500;
    transition: all 0.3s;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    white-space: nowrap;
}

.section-filter-back:hover {
    background: #cc0000;
    border-color: #cc0000;
    color: white;
}

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

    /* Brand-page header mobile */
    .brand-page__header {
        margin: 6px 10px 16px 10px !important;
        border-radius: 6px !important;
    }

    .brand-page__header-inner {
        padding: 0.75rem 1rem 0 !important;
    }

    .brand-page__header-top {
        display: grid !important;
        grid-template-columns: auto 1fr auto !important;
        grid-template-rows: auto auto !important;
        gap: 10px 12px !important;
        align-items: start !important;
    }

    .brand-page__header-logo {
        height: 60px !important;
        grid-column: 1 !important;
        grid-row: 1 !important;
    }

    .brand-page__header-contact {
        grid-column: 2 !important;
        grid-row: 1 !important;
        justify-self: end !important;
        align-items: flex-end !important;
        justify-content: flex-start !important;
        flex-direction: column !important;
        flex-wrap: nowrap !important;
        gap: 0.15rem !important;
        font-size: 0.7rem !important;
    }

    .brand-page__header-social {
        justify-content: flex-end !important;
    }

    .brand-page__header-cart {
        grid-column: 3 !important;
        grid-row: 1 !important;
        margin-left: 0 !important;
        align-self: start !important;
    }

    .brand-page__header-cart svg {
        width: 45px !important;
        height: 45px !important;
    }

    .brand-page__header-title {
        grid-column: 1 / -1 !important;
        grid-row: 2 !important;
        font-size: 1.3rem !important;
        justify-content: center !important;
        width: 100% !important;
    }

    .brand-page__header-title .brand-page__header-model {
        max-width: 100% !important;
        white-space: normal !important;
        overflow: visible !important;
        text-overflow: unset !important;
    }

    .brand-page__header-nav {
        flex-wrap: wrap !important;
        gap: 0.25rem 0.6rem !important;
        justify-content: center !important;
        margin-top: 6px !important;
        padding-top: 2px !important;
        padding-bottom: 2px !important;
    }

    .brand-page__header-nav a {
        font-size: 0.7rem !important;
    }

    /* Stack diagram on top, parts table below */
    .fiche-layout {
        grid-template-columns: 1fr !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 */
    .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-bottom: 0 !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;
    }
}

/* ── Center main diagram vertically and stretch horizontally ── */
.diagram-panel {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    height: 100% !important;
}

#detail-diagram {
    width: 100% !important;
}

.diagram-panel img,
#detail-diagram img {
    width: 100% !important;
    height: auto !important;
    display: block !important;
    border-radius: 4px !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.9rem, 1.4vw, 1.4rem) !important;
    flex-shrink: 0 !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;
}
