﻿/* =========================================================
   ITEM DETAIL PAGE
   ========================================================= */

.item-detail-page {
    background: var(--mud-palette-background);
    min-height: 100vh;
    padding: 2rem 4rem;
}

/* Breadcrumb */
.item-detail-breadcrumb {
    margin-bottom: 2rem;
}

/* Main container */
.item-detail-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4rem;
    max-width: 1400px;
    margin: 0 auto;
    align-items: start;
}

/* =========================================================
   GALLERY
   ========================================================= */

.item-detail-gallery {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    position: sticky;
    top: 2rem;
}

.item-detail-main-image-wrapper {
    position: relative;
    width: 100%;
    aspect-ratio: 3 / 4;
    background: var(--mud-palette-surface);
    overflow: hidden;
    /* Let the browser keep vertical scrolling; horizontal swipes switch images */
    touch-action: pan-y;
}

.item-detail-main-image {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
    transition: transform 0.4s ease;
}

    .item-detail-main-image:hover {
        transform: scale(1.03);
    }

.item-detail-thumbnails {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.item-detail-thumbnail {
    width: 80px;
    height: 80px;
    overflow: hidden;
    cursor: pointer;
    border: 2px solid transparent;
    transition: border-color 0.2s ease;
    background: var(--mud-palette-surface);
}

    .item-detail-thumbnail:hover {
        border-color: var(--mud-palette-secondary);
    }

.item-detail-thumbnail--active {
    border-color: var(--mud-palette-primary) !important;
}

.item-detail-thumbnail-img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}

/* =========================================================
   INFO
   ========================================================= */

.item-detail-info {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.item-detail-category-text {
    letter-spacing: 0.12em;
    color: var(--mud-palette-secondary) !important;
    text-transform: uppercase;
}

.item-detail-name {
    line-height: 1.2;
    margin-top: 0.5rem;
}

.item-detail-owner {
    color: var(--mud-palette-text-secondary);
    margin-top: 0.25rem;
}

.item-detail-brand-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    column-gap: 1rem;
}

.item-detail-brand-row .item-detail-make-check {
    margin-top: 0.25rem;
}

.item-detail-price-wrapper {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    margin-top: 1rem;
}

.item-detail-price {
    color: var(--mud-palette-primary) !important;
}

.item-detail-price-note {
    color: var(--mud-palette-text-secondary) !important;
}

.item-detail-section-label {
    letter-spacing: 0.12em !important;
    color: var(--mud-palette-text-secondary) !important;
    text-transform: uppercase !important;
    margin-bottom: 0.75rem;
    display: block;
}

.item-detail-description {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.item-detail-description-text {
    line-height: 1.8;
    color: var(--mud-palette-text-secondary) !important;
}

.item-detail-materials {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-top: 1rem;
}

.item-detail-materials-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

/* Details rows */
.item-detail-details {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.item-detail-detail-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.6rem 0;
    border-bottom: 1px solid var(--mud-palette-divider);
}

.item-detail-detail-label {
    color: var(--mud-palette-text-secondary) !important;
}

.item-detail-detail-value {
    font-weight: 600;
}

/* Makers */
.item-detail-makers {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.item-detail-makers-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.item-detail-maker-chip {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    background: var(--mud-palette-background);
    border-radius: 4px;
}

.item-detail-maker-icon {
    font-size: 1rem !important;
    color: var(--mud-palette-secondary) !important;
}

.item-detail-maker-times {
    color: var(--mud-palette-text-secondary);
    font-size: 0.85rem;
}

/* Actions */
.item-detail-actions {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-top: 0.5rem;
}

.item-detail-order-button {
    letter-spacing: 0.08em;
    height: 52px;
}

.item-detail-favorite-button {
    letter-spacing: 0.08em;
    height: 52px;
    border-color: var(--mud-palette-divider) !important;
}

    .item-detail-favorite-button:hover {
        border-color: var(--mud-palette-secondary) !important;
        color: var(--mud-palette-secondary) !important;
    }

/* Unavailable / hidden item banner */
.item-detail-unavailable-banner {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 1rem;
    border-radius: 8px;
    background: var(--mud-palette-background-grey);
    border: 1px solid var(--mud-palette-divider);
}

.item-detail-unavailable-banner--owner {
    flex-wrap: wrap;
}

.item-detail-unavailable-icon {
    color: var(--mud-palette-text-secondary);
    margin-top: 0.15rem;
    flex-shrink: 0;
}

.item-detail-unavailable-text {
    flex: 1;
    min-width: 200px;
}

.item-detail-unavailable-action {
    flex-shrink: 0;
}

/* Pattern purchase (maker-only) */
.item-detail-pattern-section {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.item-detail-pattern-hint {
    color: var(--mud-palette-text-secondary);
    margin-bottom: 0.5rem;
}

.item-detail-pattern-detail-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
    padding: 0.4rem 0;
    border-bottom: 1px solid var(--mud-palette-divider);
}

.item-detail-pattern-detail-label {
    color: var(--mud-palette-text-secondary) !important;
    flex-shrink: 0;
}

.item-detail-pattern-detail-value {
    font-weight: 600;
    text-align: right;
}

.item-detail-fabric-table {
    width: 100%;
    border-collapse: collapse;
    margin: 0.5rem 0;
}

    .item-detail-fabric-table th,
    .item-detail-fabric-table td {
        border: 1px solid var(--mud-palette-divider);
        padding: 0.4rem;
        text-align: center;
        font-size: 0.85rem;
    }

    .item-detail-fabric-table th {
        color: var(--mud-palette-text-secondary);
        font-weight: 500;
        white-space: nowrap;
    }

.item-detail-pattern-actions {
    display: flex;
    gap: 0.75rem;
}

.item-detail-pattern-button {
    letter-spacing: 0.08em;
    height: 52px;
}

@media (max-width: 600px) {
    .item-detail-pattern-actions {
        flex-direction: column;
    }

    .item-detail-pattern-button {
        height: 48px;
    }
}

/* =========================================================
   READY-MADE LISTINGS
   ========================================================= */

.item-detail-ready-made-section {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.item-detail-ready-made-hint {
    color: var(--mud-palette-text-secondary);
    margin-bottom: 0.5rem;
}

.item-detail-size-table-link {
    display: flex;
    align-items: center;
    gap: 0.15rem;
    margin-bottom: 0.5rem;
}

/* Size chart dialog */

.size-chart-row--recommended {
    background: rgba(var(--mud-palette-success-rgb), 0.12);
}

.item-detail-ready-made-recommend-hint {
    color: var(--mud-palette-text-secondary);
}

.item-detail-ready-made-size-chooser {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin: 0.5rem 0;
}

.item-detail-ready-made-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

/* One listing: photos of that exact piece on top, its size, price and stock below */
.item-detail-ready-made-card {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    padding: 0.75rem;
    border: 1px solid var(--mud-palette-lines-default);
    border-radius: 8px;
}

.item-detail-ready-made-card--own {
    background: var(--mud-palette-action-default-hover);
}

.item-detail-ready-made-photos {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
}

.item-detail-ready-made-photo {
    position: relative;
    width: 64px;
    height: 64px;
    padding: 0;
    border: 1px solid var(--mud-palette-lines-default);
    border-radius: 4px;
    overflow: hidden;
    background: none;
    cursor: pointer;
}

    .item-detail-ready-made-photo img {
        width: 100%;
        height: 100%;
        object-fit: cover;
        display: block;
    }

.item-detail-ready-made-photo-more {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.5);
    color: #fff;
    font-weight: 600;
}

.item-detail-ready-made-info {
    flex: 1;
    min-width: 0;
}

.item-detail-ready-made-description {
    overflow-wrap: anywhere;
}

.item-detail-ready-made-no-photos {
    color: var(--mud-palette-warning) !important;
}

.item-detail-ready-made-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
}

.item-detail-ready-made-maker {
    color: var(--mud-palette-text-secondary) !important;
}

.item-detail-ready-made-out-of-stock {
    color: var(--mud-palette-error);
}

.item-detail-ready-made-actions {
    display: flex;
    gap: 0.25rem;
    flex-shrink: 0;
}

@media (max-width: 600px) {
    .item-detail-ready-made-row {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }
}

/* =========================================================
   Ready-made stock dialog and its photo picker
   ========================================================= */

/* Size, price and stock side by side, stacking on a phone */

.ready-made-photo-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin: 0.5rem 0;
}

.ready-made-photo-tile {
    position: relative;
    width: 88px;
    height: 88px;
    border: 1px solid var(--mud-palette-lines-default);
    border-radius: 6px;
    overflow: hidden;
    background: var(--mud-palette-background);
}

.ready-made-photo-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.ready-made-photo-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.25rem;
    height: 100%;
    padding: 0.25rem;
    color: var(--mud-palette-text-secondary);
}

.ready-made-photo-name {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ready-made-photo-cover {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    padding: 1px 0;
    background: rgba(0, 0, 0, 0.55);
    color: #fff;
    font-size: 0.7rem;
    text-align: center;
}

.ready-made-photo-remove {
    position: absolute !important;
    top: 2px;
    right: 2px;
    padding: 2px !important;
    background: rgba(255, 255, 255, 0.85) !important;
    color: rgba(0, 0, 0, 0.75) !important;
}

.ready-made-photo-actions {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

/* Full-size photo viewer */

/* =========================================================
   NOT FOUND
   ========================================================= */

.item-detail-not-found {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 60vh;
    gap: 1rem;
    text-align: center;
}

.item-detail-not-found-icon {
    font-size: 4rem !important;
    color: var(--mud-palette-text-secondary) !important;
}

.item-detail-not-found-text {
    color: var(--mud-palette-text-secondary) !important;
    max-width: 400px;
}

/* =========================================================
   ORDER DIALOG
   ========================================================= */

/* Fabric preference (order dialog) */

/* Reference / swatch thumbnails, shared by the dialogs, order page and maker orders */

/* Material options (send offer dialog) */

/* How a purchase reaches the buyer: shipping address or pickup */

/* Shipping / pickup choice in the offer form, and the town asked for when ordering */

.send-offer-option {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem 0.75rem;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    border: 1px solid transparent;
}

    .send-offer-option--included {
        border-color: var(--mud-palette-secondary);
        background: var(--mud-palette-surface);
    }

/* The name keeps a minimum width (wrapping long names) so it never runs under the price box;
   when the row is too narrow, the price and star wrap onto their own line instead. */

/* !important: MudBlazor's input control otherwise stretches to fill the row */

/* Material filter bar (offer dialog + Materials profile tab) */
.material-filter-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.material-filter-search {
    flex: 2 1 12rem;
}

.material-filter-type {
    flex: 1 1 10rem;
}

/* Maker material dialog */

/* Order dialog measurements */

/* Order dialog lines (size/material/quantity, one per negotiated order) */

@media (max-width: 960px) {
    .item-detail-page {
        padding: 1.5rem;
    }

    .item-detail-container {
        grid-template-columns: 1fr;
        gap: 2rem;
    }

    /* Gallery no longer sticky once stacked */
    .item-detail-gallery {
        position: static;
    }

    .item-detail-breadcrumb {
        margin-bottom: 1.5rem;
    }
}

@media (max-width: 600px) {
    .item-detail-page {
        padding: 1rem;
    }

    .item-detail-name {
        font-size: 2rem !important;
    }

    .item-detail-thumbnails {
        gap: 0.5rem;
    }

    /* Smaller thumbnails to fit more per row */
    .item-detail-thumbnail {
        width: 64px;
        height: 64px;
    }

    /* Action buttons a touch shorter */
    .item-detail-order-button,
    .item-detail-favorite-button {
        height: 48px;
    }

    /* Detail rows — let long values wrap instead of crushing */
    .item-detail-detail-row {
        gap: 1rem;
    }

    .item-detail-detail-value {
        text-align: right;
    }
}

/* Touch devices — kill the image hover zoom that sticks on tap */
@media (hover: none) {
    .item-detail-main-image:hover {
        transform: none;
    }
}

/* =========================================================
   RESPONSIVE — DIALOGS (order + send offer)
   ========================================================= */

@media (max-width: 600px) {
    /* Measurements header stacks so the link doesn't crowd the title */

}

/* Report dialog (Components/Dialogs/ReportDialog.razor), opened from the report link below the item */

.item-detail-report {
    margin-top: 1.5rem;
}

    .item-detail-report .mud-button-root {
        color: var(--mud-palette-text-secondary);
    }
