/**
 * Frontend CSS for Festo Search Plugin
 */

/* Main container */
.festo-search-widget {
    max-width: 1200px;
    margin: 0 auto;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
    /* Invaltech brand */
    --inv-primary: #0f5fa7;
    --inv-primary-600: #0d4f8b;
    --inv-tint-50: rgba(15,95,167,0.06);
}

/* Search form */
.festo-search-form {
    margin-bottom: 30px;
}

.search-input-container, .search-input-group {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
}

.festo-search-input {
    flex: 1;
    padding: 12px 16px;
    border: 2px solid #ddd;
    border-radius: 6px;
    font-size: 16px;
    transition: border-color 0.3s ease;
}

.festo-search-input:focus {
    outline: none;
    border-color: #0073aa;
    box-shadow: 0 0 0 3px rgba(0, 115, 170, 0.1);
}

.festo-search-button {
    padding: 12px 24px;
    background: #0073aa;
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.3s ease;
    display: flex;
    align-items: center;
    gap: 8px;
}

.festo-search-button:hover {
    background: #005a87;
}

.festo-search-button:disabled {
    background: #ccc;
    cursor: not-allowed;
}

/* Filters */
.festo-filters-container {
    background: #ffffff;
    padding: 20px;
    border-radius: 8px;
    margin-bottom: 30px;
}

/* Filters container now holds two rows: checkboxes row + others row */
#festo-filters {
    display: grid;
    grid-template-columns: 1fr; /* stack rows */
    gap: 16px;
}

/* Rows inside the filters container */
.festo-filter-row { display: grid; gap: 16px; }
.festo-filter-row-checkboxes { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.festo-filter-row-others { grid-template-columns: repeat(3, minmax(0, 1fr)); }

#festo-filters .filter-group {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 12px 14px;
}

#festo-filters .filter-group label {
    margin-bottom: 8px;
    font-weight: 600;
    color: #333;
}

/* Make checkbox lists compact and split into two columns inside each group */
#festo-filters .checkbox-group {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px 12px;
    max-height: 280px;
    overflow: auto;
    padding-right: 6px; /* room for scrollbar */
}

#festo-filters .checkbox-item {
    display: flex;
    align-items: flex-start;
    gap: 8px;
}

#festo-filters .checkbox-item label {
    line-height: 1.2;
}

.filter-title {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 1px solid #ddd;
}

.filter-title h3 {
    margin: 0;
    color: #333;
}

.reset-filters-btn {
    background: #6c757d;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
}

.reset-filters-btn:hover {
    background: #5a6268;
}

.festo-filters {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
}

.filter-group {
    display: flex;
    flex-direction: column;
}

.filter-group label {
    font-weight: 600;
    margin-bottom: 8px;
    color: #333;
}

.festo-dynamic-dropdown {
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    background: white;
    font-size: 14px;
}

.checkbox-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.checkbox-item {
    display: flex;
    align-items: center;
    gap: 8px;
}

.checkbox-item input[type="checkbox"] {
    margin: 0;
}

.checkbox-item label {
    margin: 0;
    font-weight: normal;
    cursor: pointer;
}

.festo-custom-slider {
    width: 100%;
    margin: 10px 0;
}

/* Loading */
.festo-loading {
    text-align: center;
    padding: 40px 20px;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #0073aa;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 20px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Results */
.festo-search-results {
    margin-top: 30px;
}

.no-results {
    text-align: center;
    padding: 60px 20px;
    color: #666;
}

.no-results i {
    font-size: 48px;
    margin-bottom: 20px;
    opacity: 0.5;
}

.no-results h3 {
    margin: 0 0 10px 0;
    color: #333;
}

.no-results p {
    margin: 0;
    font-size: 16px;
}

/* Products grid */
.festo-products-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 24px;
    margin-top: 20px;
}

/* Responsive columns: 3 on large tablets/smaller desktops, 2 on tablets, 1 on phones */
@media (max-width: 1200px) {
    .festo-products-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}
@media (max-width: 992px) {
    .festo-products-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Product card */
.festo-product-card {
    background: white;
    border: 1px solid #e1e1e1;
    border-radius: 8px;
    overflow: hidden;
    transition: box-shadow 0.3s ease, transform 0.2s ease;
    position: relative;
}

.festo-product-card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    transform: translateY(-2px);
}

.festo-product-card.discontinued {
    opacity: 0.7;
    border-color: #dc3545;
}

.product-image {
    position: relative;
    width: 100%;
    max-width: 1000px;
    /* Make image area square (500x500 on large screens, scales down responsively) */
    aspect-ratio: 1 / 1;
    height: auto;
    overflow: hidden;
    background: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto; /* center within card */
}

.product-image img {
    width: 40%;
    height: 40%;
    object-fit: contain;
    display: block;
}

/* Per-card image loading overlay */
.product-image .image-loading {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.9);
    pointer-events: none;
}
.product-image .image-loading .loading-spinner {
    width: 28px;
    height: 28px;
    border-width: 3px;
    margin: 0;
}

.discontinued-badge {
    position: absolute;
    top: 10px;
    right: 10px;
    background: #dc3545;
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
}

.product-info {
    padding: 20px;
}

.product-title {
    margin: 0 0 15px 0;
    font-size: 18px;
    font-weight: 600;
    color: #333;
    line-height: 1.3;
    /* Align titles across cards: reserve space for up to 2 lines */
    display: -webkit-box;
    line-clamp: 2;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
    min-height: 2.6em; /* 2 lines x 1.3 line-height */
}

.product-details {
    margin-bottom: 15px;
}

.product-details p {
    margin: 5px 0;
    font-size: 14px;
    color: #666;
}

.product-details strong {
    color: #333;
}

.product-downloads {
    padding: 15px 20px;
    background: #ffffff;
    border-top: 1px solid #e1e1e1;
}

.product-downloads h4 {
    margin: 0 0 10px 0;
    font-size: 16px;
    color: #333;
}

.product-downloads ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.product-downloads li {
    margin: 5px 0;
}

.product-downloads a {
    color: #0073aa;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    transition: color 0.3s ease;
}

.product-downloads a:hover {
    color: #005a87;
    text-decoration: underline;
}

.product-actions {
    padding: 20px;
    display: flex;
    gap: 10px;
    border-top: 1px solid #e1e1e1;
}

/* Extended details */
.product-details-extended {
    background: #ffffff;
    border-top: 1px solid #e1e1e1;
}
.product-details-extended .extended-inner {
    padding: 15px 20px;
}
.product-details-extended h4 {
    margin: 0 0 10px 0;
    font-size: 16px;
    color: #333;
}
.product-details-extended .extended-sections {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
}
.extended-specs { width: 100%; }
.specs-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    overflow: hidden;
    background: #fff;
}
.specs-table td {
    border-bottom: 1px solid #eef1f4;
    padding: 14px 18px; /* extra space from borders */
    font-size: 14px;
    color: #2f3b45;
    vertical-align: top;
    word-break: break-word;
    overflow-wrap: anywhere;
}
.specs-table td + td { border-left: 1px solid #eef1f4; }
.specs-table tr:last-child td { border-bottom: none; }
.specs-table td:first-child {
    background: var(--inv-tint-50);
    font-weight: 600;
    color: #11314f;
    width: 38%;
}
.specs-table td:last-child { width: 62%; }
.extended-specs h4 { margin-bottom: 10px; color: var(--inv-primary); }
.extended-docs h4 { margin-bottom: 10px; }
.docs-list li { margin: 8px 0; }

/* Hover effect for better row distinction */
.specs-table tr:hover td {
    background: #fbfdff;
}

/* Responsive tweaks for narrow screens */
@media (max-width: 480px) {
    .specs-table td { font-size: 13px; padding: 8px 10px; }
    .specs-table td:first-child { width: 45%; }
}
.docs-list {
    list-style: none;
    padding: 0;
    margin: 0;
}
.docs-list li { margin: 6px 0; }
.docs-list a { color: var(--inv-primary); text-decoration: none; }
.docs-list a:hover { text-decoration: underline; color: var(--inv-primary-600); }

/* Buttons */
.festo-btn {
    padding: 10px 16px;
    border: none;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    text-align: center;
    transition: all 0.3s ease;
    flex: 1;
}

.festo-btn-primary {
    background: #0073aa;
    color: white;
}

.festo-btn-primary:hover {
    background: #005a87;
}

.festo-btn-secondary {
    background: #6c757d;
    color: white;
}

.festo-btn-secondary:hover {
    background: #5a6268;
}

.festo-btn-disabled {
    background: #e9ecef;
    color: #6c757d;
    cursor: not-allowed;
}

.festo-btn:disabled {
    background: #e9ecef;
    color: #6c757d;
    cursor: not-allowed;
}

    /* Replacement link for added items should look like a button and use brand blue */
    .festo-btn.festo-see-quote {
        background: var(--inv-primary);
        color: #ffffff;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        width: auto; /* don't force full width */
        white-space: nowrap; /* keep on one line */
        padding: 8px 14px; /* a bit smaller */
        font-size: 13px; /* slightly smaller text */
        flex: 0 0 auto; /* prevent stretching in flex container */
    }
    .festo-btn.festo-see-quote:hover {
        background: var(--inv-primary-600);
        color: #ffffff;
        text-decoration: none;
    }

/* Notifications */
.festo-notification {
    padding: 15px 20px;
    margin-bottom: 20px;
    border-radius: 6px;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.festo-notification-success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.festo-notification-error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.festo-notification-warning {
    background: #fff3cd;
    color: #856404;
    border: 1px solid #ffeaa7;
}

.notification-close {
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    color: inherit;
    margin-left: 15px;
}

/* YITH RFQ table thumbnail sizing */
#yith-ywrq-table-list td.product-thumbnail,
#yith-ywrq-table-list .product-thumbnail {
    width: 180px;
}

#yith-ywrq-table-list td.product-thumbnail a,
#yith-ywrq-table-list .product-thumbnail a {
    display: inline-block;
    width: 160px;
    height: 160px;
}

#yith-ywrq-table-list td.product-thumbnail img,
#yith-ywrq-table-list .product-thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    background: #fff;
    border: 1px solid #eee;
    border-radius: 8px;
    padding: 8px;
    display: block;
}

@media (max-width: 768px) {
    #yith-ywrq-table-list td.product-thumbnail { width: 140px; }
    #yith-ywrq-table-list td.product-thumbnail a,
    #yith-ywrq-table-list .product-thumbnail a { width: 120px; height: 120px; }
}

/* Responsive design */
@media (max-width: 768px) {
    .search-input-container {
        flex-direction: column;
    }
    
    .festo-filters {
        grid-template-columns: 1fr;
    }
    .festo-filter-row-checkboxes,
    .festo-filter-row-others {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
    
    .festo-products-grid {
        grid-template-columns: 1fr;
    }
    
    .product-actions {
        flex-direction: column;
    }
}

@media (max-width: 480px) {
    .festo-search-widget {
        padding: 0 15px;
    }
    
    .festo-product-card {
        margin: 0 -15px;
        border-radius: 0;
        border-left: none;
        border-right: none;
    }
    .festo-filter-row-checkboxes,
    .festo-filter-row-others { grid-template-columns: 1fr; }
}
