/**
 * H2W Catalog System - Frontend Styles
 *
 * Professional styling for catalog taxonomy archives, product pages,
 * and interactive datatable components.
 *
 * @package H2W_Catalog
 */

/* ==========================================================================
   Variables & Base Styles
   ========================================================================== */

:root {
    --h2w-primary: #0066cc;
    --h2w-primary-dark: #004d99;
    --h2w-secondary: #666666;
    --h2w-border: #e0e0e0;
    --h2w-bg-light: #f8f9fa;
    --h2w-bg-white: #ffffff;
    --h2w-text-dark: #333333;
    --h2w-text-light: #666666;
    --h2w-success: #28a745;
    --h2w-spacing-sm: 0.5rem;
    --h2w-spacing-md: 1rem;
    --h2w-spacing-lg: 1.5rem;
    --h2w-spacing-xl: 2rem;
    --h2w-radius: 8px;
    --h2w-shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.1);
    --h2w-shadow-md: 0 4px 6px rgba(0, 0, 0, 0.1);
    --h2w-transition: all 0.2s ease-in-out;
}

/* ==========================================================================
   Catalog Term Block (Family/Series Archives)
   ========================================================================== */

.wp-block-h2w-catalog-term {
    margin: var(--h2w-spacing-xl) 0;
}

/* Hero Section */
.catalog-hero {
    position: relative;
    margin-bottom: var(--h2w-spacing-xl);
    border-radius: var(--h2w-radius);
    overflow: hidden;
}

.catalog-hero-image {
    position: relative;
    width: 100%;
    height: 300px;
    background-size: cover;
    background-position: center;
    background-color: var(--h2w-bg-light);
}

.catalog-hero-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.catalog-hero-content {
    padding: var(--h2w-spacing-lg);
    background: var(--h2w-bg-white);
}

.catalog-hero h1 {
    margin: 0 0 var(--h2w-spacing-md);
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--h2w-text-dark);
    line-height: 1.2;
}

.catalog-intro {
    font-size: 1.1rem;
    line-height: 1.6;
    color: var(--h2w-text-light);
    max-width: 800px;
}

/* Series Cards Grid (Family Archive) */
.series-cards-grid {
    display: flex;
    flex-direction: column;
    gap: var(--h2w-spacing-lg);
    margin-top: var(--h2w-spacing-xl);
}

.series-card {
    background: var(--h2w-bg-white);
    border: 1px solid var(--h2w-border);
    border-radius: var(--h2w-radius);
    overflow: hidden;
    transition: var(--h2w-transition);
    box-shadow: var(--h2w-shadow-sm);
}

.series-card:hover {
    box-shadow: var(--h2w-shadow-md);
    transform: translateX(4px);
}

.series-card-link {
    display: flex;
    flex-direction: row;
    text-decoration: none;
    color: inherit;
    min-height: 180px;
}

.series-card-image {
    width: 280px;
    min-width: 280px;
    height: auto;
    background-color: var(--h2w-bg-light);
    position: relative;
    overflow: hidden;
}

.series-card-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: var(--h2w-transition);
}

.series-card:hover .series-card-image img {
    transform: scale(1.05);
}

.series-card-image.placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--h2w-secondary);
}

.series-card-image.placeholder .dashicons {
    font-size: 4rem;
    width: 4rem;
    height: 4rem;
}

.series-card-content {
    padding: var(--h2w-spacing-lg);
    position: relative;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.series-card-title {
    margin: 0 0 var(--h2w-spacing-sm);
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--h2w-text-dark);
    transition: var(--h2w-transition);
}

.series-card:hover .series-card-title {
    color: var(--h2w-primary);
}

.series-card-description {
    margin-bottom: var(--h2w-spacing-md);
    color: var(--h2w-text-light);
    line-height: 1.5;
    font-size: 0.95rem;
}

.series-card-meta {
    display: flex;
    align-items: center;
    gap: var(--h2w-spacing-md);
    padding-top: var(--h2w-spacing-sm);
    border-top: 1px solid var(--h2w-border);
    font-size: 0.9rem;
    color: var(--h2w-secondary);
}

.series-card-arrow {
    position: absolute;
    right: var(--h2w-spacing-lg);
    bottom: var(--h2w-spacing-lg);
    font-size: 1.5rem;
    color: var(--h2w-primary);
    transition: var(--h2w-transition);
}

.series-card:hover .series-card-arrow {
    transform: translateX(4px);
}

/* Product Cards Grid (Family Archive - Direct Products) */
.family-products-grid {
    margin-top: var(--h2w-spacing-xxl);
}

.products-grid-title {
    font-size: 1.75rem;
    font-weight: 600;
    margin: 0 0 var(--h2w-spacing-lg);
    color: var(--h2w-text-dark);
}

.products-cards-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: var(--h2w-spacing-lg);
    margin-top: var(--h2w-spacing-lg);
}

.product-card {
    background: var(--h2w-bg-white);
    border: 1px solid var(--h2w-border);
    border-radius: var(--h2w-radius);
    overflow: hidden;
    transition: var(--h2w-transition);
    box-shadow: var(--h2w-shadow-sm);
}

.product-card:hover {
    box-shadow: var(--h2w-shadow-md);
    transform: translateY(-4px);
}

.product-card-link {
    display: flex;
    flex-direction: column;
    text-decoration: none;
    color: inherit;
    height: 100%;
}

.product-card-image {
    width: 100%;
    aspect-ratio: 1 / 1;
    background-color: var(--h2w-bg-light);
    position: relative;
    overflow: hidden;
}

.product-card-image img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    transition: var(--h2w-transition);
}

.product-card:hover .product-card-image img {
    transform: scale(1.05);
}

.product-card-image.placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--h2w-secondary);
}

.product-card-image.placeholder .dashicons {
    font-size: 4rem;
    width: 4rem;
    height: 4rem;
}

.product-card-title {
    padding: var(--h2w-spacing-md);
    margin: 0;
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--h2w-text-dark);
    text-align: center;
    transition: var(--h2w-transition);
}

.product-card:hover .product-card-title {
    color: var(--h2w-primary);
}

/* Responsive adjustments for product cards */
@media (max-width: 1024px) {
    .products-cards-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 768px) {
    .products-cards-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: var(--h2w-spacing-md);
    }
}

@media (max-width: 480px) {
    .products-cards-grid {
        gap: var(--h2w-spacing-sm);
    }

    .product-card-title {
        font-size: 1rem;
        padding: var(--h2w-spacing-sm);
    }
}

/* ==========================================================================
   Series DataTable Block
   ========================================================================== */

.wp-block-h2w-series-datatable {
    margin: var(--h2w-spacing-xl) 0;
}

/* DataTable Controls */
.datatable-controls {
    display: flex;
    flex-wrap: wrap;
    gap: var(--h2w-spacing-md);
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--h2w-spacing-lg);
    padding: var(--h2w-spacing-lg);
    background: var(--h2w-bg-light);
    border-radius: var(--h2w-radius);
}

.datatable-controls-left {
    display: flex;
    flex-wrap: wrap;
    gap: var(--h2w-spacing-md);
    align-items: center;
    flex: 1;
}

.datatable-controls-right {
    display: flex;
    gap: var(--h2w-spacing-md);
}

.datatable-search {
    position: relative;
    flex: 1;
    min-width: 250px;
}

.datatable-search-input {
    width: 100%;
    padding: 0.625rem 1rem;
    border: 1px solid var(--h2w-border);
    border-radius: var(--h2w-radius);
    font-size: 0.95rem;
    transition: var(--h2w-transition);
}

.datatable-search-input:focus {
    outline: none;
    border-color: var(--h2w-primary);
    box-shadow: 0 0 0 3px rgba(0, 102, 204, 0.1);
}

.datatable-count {
    font-size: 0.9rem;
    color: var(--h2w-text-light);
    white-space: nowrap;
}

.datatable-button {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.625rem 1rem;
    background: var(--h2w-bg-white);
    border: 1px solid var(--h2w-border);
    border-radius: var(--h2w-radius);
    font-size: 0.9rem;
    color: var(--h2w-text-dark);
    cursor: pointer;
    transition: var(--h2w-transition);
    white-space: nowrap;
}

.datatable-button:hover {
    background: var(--h2w-primary);
    color: white;
    border-color: var(--h2w-primary);
}

/* DataTable Wrapper */
.datatable-wrapper {
    background: var(--h2w-bg-white);
    border: 1px solid var(--h2w-border);
    border-radius: var(--h2w-radius);
    overflow: hidden;
}

/* Series Table */
.h2w-series-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.95rem;
}

.h2w-series-table thead {
    background: var(--h2w-bg-light);
    border-bottom: 2px solid var(--h2w-border);
}

.h2w-series-table th {
    padding: 1rem;
    text-align: left;
    font-weight: 600;
    color: var(--h2w-text-dark);
    border-bottom: 2px solid var(--h2w-border);
    white-space: nowrap;
}

.h2w-series-table th.sortable {
    cursor: pointer;
    user-select: none;
    position: relative;
    padding-right: 2rem;
}

.h2w-series-table th.sortable:hover {
    background: rgba(0, 102, 204, 0.05);
}

.h2w-series-table tbody tr {
    border-bottom: 1px solid var(--h2w-border);
    transition: var(--h2w-transition);
}

.h2w-series-table tbody tr:hover {
    background: var(--h2w-bg-light);
}

.h2w-series-table td {
    padding: 0.875rem 1rem;
    color: var(--h2w-text-dark);
}

.h2w-series-table td.product-number {
    font-weight: 600;
}

.h2w-series-table td.product-number a {
    color: var(--h2w-primary);
    text-decoration: none;
    transition: var(--h2w-transition);
}

.h2w-series-table td.product-number a:hover {
    color: var(--h2w-primary-dark);
    text-decoration: underline;
}

/* Thumbnail Column */
.h2w-series-table td.thumbnail-cell {
    width: 80px;
    padding: 0.5rem;
    text-align: center;
    vertical-align: middle;
}

.h2w-series-table th:first-child {
    width: 80px;
    text-align: center;
}

.product-thumbnail-link {
    display: block;
    width: 60px;
    height: 60px;
    margin: 0 auto;
    overflow: hidden;
    border-radius: 4px;
    border: 1px solid var(--h2w-border);
    background: var(--h2w-bg-light);
    transition: var(--h2w-transition);
}

.product-thumbnail-link:hover {
    border-color: var(--h2w-primary);
    box-shadow: 0 2px 8px rgba(0, 102, 204, 0.2);
    transform: scale(1.05);
}

.product-thumbnail-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* DataTables Plugin Overrides */
.h2w-series-table.dataTable thead .sorting,
.h2w-series-table.dataTable thead .sorting_asc,
.h2w-series-table.dataTable thead .sorting_desc {
    background-image: none;
}

.h2w-series-table.dataTable thead .sorting::after,
.h2w-series-table.dataTable thead .sorting_asc::after,
.h2w-series-table.dataTable thead .sorting_desc::after {
    position: absolute;
    right: 0.75rem;
    font-family: dashicons;
    font-size: 16px;
}

.h2w-series-table.dataTable thead .sorting::after {
    content: "\f156";
    color: var(--h2w-secondary);
}

.h2w-series-table.dataTable thead .sorting_asc::after {
    content: "\f142";
    color: var(--h2w-primary);
}

.h2w-series-table.dataTable thead .sorting_desc::after {
    content: "\f140";
    color: var(--h2w-primary);
}

/* Responsive Table */
.h2w-series-table.dtr-inline.collapsed tbody tr td.dtr-control {
    position: relative;
}

.h2w-series-table.dtr-inline.collapsed tbody tr td.dtr-control::before {
    background-color: var(--h2w-primary);
}

/* ==========================================================================
   Product Specifications Block
   ========================================================================== */

.wp-block-h2w-product-specs {
    margin: var(--h2w-spacing-xl) 0;
}

.h2w-product-specifications {
    display: flex;
    flex-direction: column;
    gap: var(--h2w-spacing-lg);
}

.spec-group {
    background: var(--h2w-bg-white);
    border: 1px solid var(--h2w-border);
    border-radius: var(--h2w-radius);
    overflow: hidden;
    box-shadow: var(--h2w-shadow-sm);
}

.spec-group-title {
    margin: 0;
    padding: var(--h2w-spacing-lg);
    background: var(--h2w-bg-light);
    border-bottom: 2px solid var(--h2w-border);
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--h2w-text-dark);
}

.spec-table {
    width: 100%;
    border-collapse: collapse;
}

.spec-row {
    border-bottom: 1px solid var(--h2w-border);
}

.spec-row:last-child {
    border-bottom: none;
}

.spec-row.custom-spec {
    background: rgba(40, 167, 69, 0.03);
}

/* Removed (Custom) label - custom specs now integrate seamlessly into existing groups */

.spec-label {
    width: 40%;
    padding: 0.875rem var(--h2w-spacing-lg);
    text-align: left;
    font-weight: 500;
    color: var(--h2w-text-light);
    background: var(--h2w-bg-light);
    vertical-align: top;
}

.spec-value {
    padding: 0.875rem var(--h2w-spacing-lg);
    color: var(--h2w-text-dark);
    vertical-align: top;
}

.specs-preview-message,
.specs-preview-note {
    padding: var(--h2w-spacing-lg);
    background: #e3f2fd;
    border: 1px solid #90caf9;
    border-radius: var(--h2w-radius);
    color: #1565c0;
    text-align: center;
}

.specs-preview-note {
    margin-top: var(--h2w-spacing-md);
    font-size: 0.9em;
}

/* ==========================================================================
   Responsive Design
   ========================================================================== */

@media (max-width: 768px) {
    .catalog-hero h1 {
        font-size: 2rem;
    }

    .catalog-hero-image {
        height: 200px;
    }

    .series-card-link {
        flex-direction: column;
        min-height: auto;
    }

    .series-card-image {
        width: 100%;
        min-width: 100%;
        height: 200px;
    }

    .datatable-controls {
        flex-direction: column;
        align-items: stretch;
        gap: var(--h2w-spacing-sm);
    }

    .datatable-controls-left {
        flex-direction: column;
        width: 100%;
        gap: var(--h2w-spacing-sm);
    }

    .datatable-search {
        min-width: 100%;
    }

    /* Mobile Card Layout for Product Table */
    .datatable-wrapper {
        border: none;
        background: transparent;
    }

    .h2w-series-table {
        display: block;
        border: none;
    }

    .h2w-series-table thead {
        display: none; /* Hide table headers on mobile */
    }

    .h2w-series-table tbody {
        display: flex;
        flex-direction: column;
        gap: var(--h2w-spacing-md);
    }

    .h2w-series-table tbody tr {
        display: flex;
        flex-direction: column;
        background: var(--h2w-bg-white);
        border: 1px solid var(--h2w-border);
        border-radius: var(--h2w-radius);
        padding: var(--h2w-spacing-md);
        box-shadow: var(--h2w-shadow-sm);
    }

    .h2w-series-table tbody tr:hover {
        background: var(--h2w-bg-white);
        box-shadow: var(--h2w-shadow-md);
    }

    .h2w-series-table td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 0.5rem 0;
        border-bottom: 1px solid var(--h2w-border);
    }

    .h2w-series-table td:last-child {
        border-bottom: none;
    }

    /* Thumbnail at top, centered */
    .h2w-series-table td.thumbnail-cell {
        justify-content: center;
        padding: 0 0 var(--h2w-spacing-md) 0;
        border-bottom: 2px solid var(--h2w-border);
    }

    .product-thumbnail-link {
        width: 80px;
        height: 80px;
    }

    /* Add data labels before each cell */
    .h2w-series-table td:not(.thumbnail-cell)::before {
        content: attr(data-label);
        font-weight: 600;
        color: var(--h2w-text-light);
        flex: 0 0 40%;
        text-align: left;
    }

    .h2w-series-table td:not(.thumbnail-cell) {
        text-align: right;
    }

    /* Responsive spec table */
    .spec-label,
    .spec-value {
        display: block;
        width: 100%;
        padding: 0.5rem var(--h2w-spacing-md);
    }

    .spec-label {
        padding-bottom: 0.25rem;
        border-bottom: none;
    }

    .spec-value {
        padding-top: 0.25rem;
        font-weight: 600;
    }
}

@media (max-width: 480px) {
    .catalog-hero h1 {
        font-size: 1.5rem;
    }

    .spec-group-title {
        font-size: 1.1rem;
        padding: var(--h2w-spacing-md);
    }
}

/* ==========================================================================
   Print Styles
   ========================================================================== */

@media print {
    .datatable-controls,
    .series-card-arrow,
    .datatable-button {
        display: none !important;
    }

    .h2w-series-table {
        font-size: 0.8rem;
    }

    .h2w-series-table th,
    .h2w-series-table td {
        padding: 0.5rem;
    }

    .spec-group {
        page-break-inside: avoid;
    }
}
