/**
 * Hanteon Seller Portal
 * Custom seller-facing views.
 */

/**
 * Hide public shop category menu on seller portal pages.
 *
 * 6560 = Myyjän tuotteet
 * Later add:
 * 2271 = Myyjän työpöytä
 * 2705 = Yleiskatsaus
 */
body.page-id-6560 #menu-headermenu {
    display: none !important;
}

/* Add a little breathing room below the public header on seller product page. */
body.page-id-6560 .hsp-wrap {
    padding-top: 14px;
}

/* Product name/image links to Hanteon product editor. */
.hsp-product-link {
    display: flex;
    gap: 10px;
    align-items: center;
    color: inherit;
    text-decoration: none;
}

.hsp-product-link:hover strong {
    text-decoration: underline;
}

.hsp-product-thumb {
    width: 52px;
    min-width: 52px;
    display: inline-flex;
}

.hsp-product-info {
    display: grid;
    gap: 2px;
}

.hsp-product-id {
    font-size: 13px;
}

/* Seller orders page: hide public category menu and add spacing. */
body.page-id-6562 #menu-headermenu {
    display: none !important;
}

body.page-id-6562 .hsp-wrap {
    padding-top: 14px;
}

/* Seller portal pages: hide public category menu and add spacing. */
body.page-id-6560 #menu-headermenu,
body.page-id-6562 #menu-headermenu {
    display: none !important;
}

body.page-id-6560 .hsp-wrap,
body.page-id-6562 .hsp-wrap {
    padding-top: 14px !important;
}

/* Mobile: turn seller portal tables into cards to avoid horizontal scrolling. */
@media (max-width: 720px) {
    .hsp-products-view .hsd-card,
    .hsp-orders-view .hsd-card {
        overflow-x: visible !important;
    }

    .hsp-products-view table,
    .hsp-orders-view table,
    .hsp-products-view thead,
    .hsp-orders-view thead,
    .hsp-products-view tbody,
    .hsp-orders-view tbody,
    .hsp-products-view tr,
    .hsp-orders-view tr,
    .hsp-products-view th,
    .hsp-orders-view th,
    .hsp-products-view td,
    .hsp-orders-view td {
        display: block !important;
        width: 100% !important;
    }

    .hsp-products-view thead,
    .hsp-orders-view thead {
        display: none !important;
    }

    .hsp-products-view tr,
    .hsp-orders-view tr {
        border: 1px solid #e5e7eb;
        border-radius: 14px;
        padding: 12px;
        margin-bottom: 12px;
        background: #fff;
    }

    .hsp-products-view td,
    .hsp-orders-view td {
        border-bottom: 0 !important;
        padding: 7px 0 !important;
    }

    .hsp-products-view td::before,
    .hsp-orders-view td::before {
        display: block;
        font-size: 12px;
        font-weight: 600;
        opacity: 0.65;
        margin-bottom: 3px;
    }

    /* Product table labels */
    .hsp-products-view td:nth-child(1)::before { content: "Tuote"; }
    .hsp-products-view td:nth-child(2)::before { content: "Tila"; }
    .hsp-products-view td:nth-child(3)::before { content: "Hinta"; }
    .hsp-products-view td:nth-child(4)::before { content: "Varasto"; }
    .hsp-products-view td:nth-child(5)::before { content: "Päivitetty"; }
    .hsp-products-view td:nth-child(6)::before { content: "Toiminnot"; }

    /* Orders table labels */
    .hsp-orders-view td:nth-child(1)::before { content: "Tilaus"; }
    .hsp-orders-view td:nth-child(2)::before { content: "Päiväys"; }
    .hsp-orders-view td:nth-child(3)::before { content: "Tila"; }
    .hsp-orders-view td:nth-child(4)::before { content: "Tuotteet"; }
    .hsp-orders-view td:nth-child(5)::before { content: "Toimitus"; }
    .hsp-orders-view td:nth-child(6)::before { content: "Summa"; }

    .hsp-products-view td:first-child::before,
    .hsp-orders-view td:first-child::before {
        display: none;
    }

    .hsp-product-link {
        align-items: flex-start;
    }

    .hsp-order-items {
        padding-left: 18px !important;
    }
}

/* Mobile product cards: cleaner layout, ready for future status/delete actions. */
@media (max-width: 720px) {
    .hsp-products-view tbody tr {
        display: grid !important;
        grid-template-columns: 1fr 1fr;
        gap: 0;
        padding: 14px !important;
    }

    .hsp-products-view tbody td {
        width: auto !important;
        padding: 9px 0 !important;
        border-bottom: 1px solid #e5e7eb !important;
    }

    .hsp-products-view tbody td:nth-child(1),
    .hsp-products-view tbody td:nth-child(6) {
        grid-column: 1 / -1;
    }

    .hsp-products-view tbody td:nth-child(2),
    .hsp-products-view tbody td:nth-child(3),
    .hsp-products-view tbody td:nth-child(4),
    .hsp-products-view tbody td:nth-child(5) {
        display: flex !important;
        flex-direction: column;
        justify-content: flex-start;
        min-height: 52px;
    }

    .hsp-products-view tbody td:nth-child(2),
    .hsp-products-view tbody td:nth-child(4) {
        padding-right: 10px !important;
    }

    .hsp-products-view tbody td:nth-child(3),
    .hsp-products-view tbody td:nth-child(5) {
        padding-left: 10px !important;
        border-left: 1px solid #eef2f7;
    }

    .hsp-products-view td:nth-child(1)::before {
        display: none !important;
    }

    .hsp-products-view td:nth-child(2)::before {
        content: "Tila";
    }

    .hsp-products-view td:nth-child(3)::before {
        content: "Hinta";
    }

    .hsp-products-view td:nth-child(4)::before {
        content: "Varastosaldo";
    }

    .hsp-products-view td:nth-child(5)::before {
        content: "Päivitetty";
    }

    .hsp-products-view tbody td:nth-child(6) {
        border-bottom: 0 !important;
        padding-top: 12px !important;
    }

    .hsp-products-view tbody td:nth-child(6)::before {
        content: "Toiminnot";
        display: block !important;
        margin-bottom: 8px;
    }

    .hsp-products-view tbody td:nth-child(6) .hsd-btn,
    .hsp-products-view tbody td:nth-child(6) a,
    .hsp-products-view tbody td:nth-child(6) button {
        width: 100%;
        box-sizing: border-box;
        text-align: center;
        justify-content: center;
    }

    .hsp-products-view .hsp-product-link {
        padding-bottom: 4px;
    }
}

/* Order detail accordion. */
.hsp-order-details {
    margin-top: 8px;
}

.hsp-order-details-summary {
    cursor: pointer;
    font-weight: 600;
    padding: 10px 0;
}

.hsp-order-detail-box {
    padding: 16px;
    border: 1px solid #e5e7eb;
    border-radius: 14px;
    background: #fafafa;
}

.hsp-order-detail-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
}

.hsp-order-detail-section {
    background: #fff;
    border: 1px solid #eef2f7;
    border-radius: 12px;
    padding: 14px;
}

.hsp-order-detail-section--wide {
    grid-column: 1 / -1;
}

.hsp-order-detail-section h3 {
    margin: 0 0 10px;
    font-size: 16px;
}

.hsp-order-detail-section address {
    font-style: normal;
    line-height: 1.5;
}

.hsp-order-totals {
    margin: 0;
}

.hsp-order-totals div {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 5px 0;
}

.hsp-order-totals dt,
.hsp-order-totals dd {
    margin: 0;
}

.hsp-order-total-final {
    border-top: 1px solid #e5e7eb;
    margin-top: 4px;
    padding-top: 8px !important;
    font-weight: 700;
}

.hsp-order-detail-item {
    display: grid;
    grid-template-columns: 52px 1fr auto;
    gap: 12px;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid #eef2f7;
}

.hsp-order-detail-item:last-child {
    border-bottom: 0;
}

.hsp-order-detail-item-image img,
.hsp-order-item-image {
    width: 52px;
    height: 52px;
    object-fit: cover;
    border-radius: 8px;
}

.hsp-refund-status {
    color: #b45309;
}

@media (max-width: 720px) {
    .hsp-order-details-row {
        margin-top: -8px !important;
        border-top: 0 !important;
    }

    .hsp-order-detail-grid {
        grid-template-columns: 1fr;
    }

    .hsp-order-detail-box {
        padding: 12px;
    }

    .hsp-order-detail-item {
        grid-template-columns: 52px 1fr;
    }

    .hsp-order-detail-item-total {
        grid-column: 2;
    }
}

/* Desktop order details: keep accordion content wide under the order row. */
@media (min-width: 721px) {
    .hsp-orders-view .hsp-order-details-row {
        display: table-row !important;
        width: 100% !important;
    }

    .hsp-orders-view .hsp-order-details-row td {
        display: table-cell !important;
        width: auto !important;
    }

    .hsp-orders-view .hsp-order-details-row td::before {
        display: none !important;
        content: none !important;
    }

    .hsp-orders-view .hsp-order-detail-grid {
        display: grid !important;
        grid-template-columns: minmax(0, 1.4fr) minmax(280px, 0.8fr);
        gap: 14px;
        align-items: start;
    }

    .hsp-orders-view .hsp-order-detail-section--wide {
        grid-column: 1 / -1;
    }
}

/* Clickable order rows. */
.hsp-orders-view .hsp-order-clickable-row {
    cursor: pointer;
}

.hsp-orders-view .hsp-order-clickable-row:hover td {
    background: #fafafa;
}

.hsp-orders-view .hsp-order-clickable-row.is-open td {
    background: #f8faf9;
}

.hsp-order-row-toggle {
    display: block;
    margin-top: 8px;
    margin-left: auto;
    padding: 7px 12px;
    border: 1px solid #cfd8d2;
    border-radius: 10px;
    background: #fff;
    color: #2d4f3c;
    font-weight: 600;
    cursor: pointer;
}

.hsp-order-row-toggle:hover {
    background: #f3f7f4;
}

/* Keep the native details element accessible but don't show a second "Näytä tiedot" label. */
.hsp-order-details > summary {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
}

.hsp-order-details {
    margin-top: 0;
}

@media (max-width: 720px) {
    .hsp-order-row-toggle {
        width: 100%;
        margin-top: 10px;
        text-align: center;
    }
}

/* Order detail product links. */
.hsp-order-product-link {
    color: inherit;
    text-decoration: none;
}

.hsp-order-product-link:hover strong {
    text-decoration: underline;
}

.hsp-order-detail-item-image a {
    display: inline-flex;
}

/* Seller product preview page. */
.hsp-preview-top {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: center;
    flex-wrap: wrap;
    margin-bottom: 18px;
}

.hsp-preview-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.hsp-product-preview-card {
    display: grid;
    grid-template-columns: minmax(260px, 0.8fr) minmax(0, 1.2fr);
    gap: 24px;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 16px;
    padding: 20px;
}

.hsp-product-preview-media {
    background: #fafafa;
    border: 1px solid #eef2f7;
    border-radius: 14px;
    padding: 14px;
}

.hsp-product-preview-image {
    width: 100%;
    height: auto;
    border-radius: 12px;
    display: block;
}

.hsp-product-preview-main h1 {
    margin: 8px 0 10px;
}

.hsp-preview-status {
    display: inline-flex;
    padding: 5px 10px;
    border-radius: 999px;
    background: #eef6f0;
    color: #2d4f3c;
    font-weight: 600;
    font-size: 13px;
}

.hsp-preview-price {
    font-size: 22px;
    font-weight: 700;
    margin: 12px 0 18px;
}

.hsp-preview-meta {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin: 0 0 18px;
}

.hsp-preview-meta div {
    border: 1px solid #eef2f7;
    border-radius: 12px;
    padding: 10px;
}

.hsp-preview-meta dt {
    font-size: 12px;
    font-weight: 600;
    opacity: 0.7;
    margin-bottom: 4px;
}

.hsp-preview-meta dd {
    margin: 0;
}

.hsp-preview-section {
    border-top: 1px solid #eef2f7;
    padding-top: 14px;
    margin-top: 14px;
}

.hsp-preview-section h2 {
    font-size: 18px;
    margin: 0 0 8px;
}

@media (max-width: 720px) {
    .hsp-product-preview-card {
        grid-template-columns: 1fr;
        padding: 14px;
    }

    .hsp-preview-meta {
        grid-template-columns: 1fr;
    }

    .hsp-preview-actions,
    .hsp-preview-actions .hsd-btn,
    .hsp-preview-top > .hsd-btn {
        width: 100%;
    }
}

/* Seller product preview page: hide public category menu and add spacing. */
body.page-id-6565 #menu-headermenu {
    display: none !important;
}

body.page-id-6565 .hsp-wrap {
    padding-top: 14px;
}
