/* Contexa Search Frontend Styles */

.contexa-search-wrapper {
    margin: 20px 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
}

/* Search Box */
.contexa-search-box {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    max-width: 600px;
    position: relative;
}

/* Suggestions Dropdown */
.contexa-suggestions-list {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 1000;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-top: none;
    border-radius: 0 0 8px 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    list-style: none;
    margin: 0;
    padding: 4px 0;
    max-height: 240px;
    overflow-y: auto;
}

.contexa-suggestion-item {
    padding: 10px 16px;
    font-size: 14px;
    color: #334155;
    cursor: pointer;
    transition: background 0.1s;
}

.contexa-suggestion-item:hover {
    background: #f1f5f9;
}

.contexa-suggestion-item strong {
    color: #0f0f23;
    font-weight: 700;
}

/* Autocomplete wrapper for inline suggestions */
.contexa-autocomplete-wrapper {
    position: relative;
    flex: 1;
}

.contexa-search-input {
    width: 100%;
    padding: 12px 16px;
    font-size: 16px;
    border: 2px solid #ddd;
    border-radius: 4px;
    transition: border-color 0.3s ease;
    box-sizing: border-box;
}

/* Ghost input (grey suggestion text) */
.contexa-ghost-input {
    position: absolute;
    top: 0;
    left: 0;
    color: #999;
    background: transparent;
    border-color: transparent;
    pointer-events: none;
    z-index: 1;
}

/* Real input (user typing) */
.contexa-real-input {
    position: relative;
    background: transparent;
    z-index: 2;
}

.contexa-search-input:focus {
    outline: none;
    border-color: #0073aa;
}

.contexa-search-button {
    padding: 12px 24px;
    font-size: 16px;
    font-weight: 600;
    color: #fff;
    background-color: #0073aa;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.3s ease;
}

.contexa-search-button:hover {
    background-color: #005177;
}

.contexa-search-button:disabled {
    background-color: #ccc;
    cursor: not-allowed;
}

/* Status Messages */
.contexa-search-status {
    margin-bottom: 20px;
}

.contexa-status-loading {
    padding: 12px 16px;
    background-color: #e3f2fd;
    color: #1976d2;
    border-left: 4px solid #1976d2;
    border-radius: 4px;
}

.contexa-status-error {
    padding: 12px 16px;
    background-color: #ffebee;
    color: #c62828;
    border-left: 4px solid #c62828;
    border-radius: 4px;
}

.contexa-status-info {
    padding: 12px 16px;
    background-color: #fff3e0;
    color: #e65100;
    border-left: 4px solid #e65100;
    border-radius: 4px;
}

/* Products Grid */
.contexa-products-grid {
    display: grid;
    gap: 20px;
    margin-top: 20px;
}

.contexa-products-grid.contexa-columns-1 {
    grid-template-columns: 1fr;
}

.contexa-products-grid.contexa-columns-2 {
    grid-template-columns: repeat(2, 1fr);
}

.contexa-products-grid.contexa-columns-3 {
    grid-template-columns: repeat(3, 1fr);
}

.contexa-products-grid.contexa-columns-4 {
    grid-template-columns: repeat(4, 1fr);
}

.contexa-products-grid.contexa-columns-5 {
    grid-template-columns: repeat(5, 1fr);
}

.contexa-products-grid.contexa-columns-6 {
    grid-template-columns: repeat(6, 1fr);
}

/* Responsive Grid */
@media (max-width: 1440px) {
    .contexa-products-grid.contexa-columns-6 {
        grid-template-columns: repeat(5, 1fr);
    }
}

@media (max-width: 1200px) {
    .contexa-products-grid.contexa-columns-5,
    .contexa-products-grid.contexa-columns-6 {
        grid-template-columns: repeat(4, 1fr);
    }
}

@media (max-width: 1024px) {
    .contexa-products-grid.contexa-columns-4,
    .contexa-products-grid.contexa-columns-5,
    .contexa-products-grid.contexa-columns-6 {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 768px) {
    .contexa-products-grid.contexa-columns-3,
    .contexa-products-grid.contexa-columns-4,
    .contexa-products-grid.contexa-columns-5,
    .contexa-products-grid.contexa-columns-6 {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 480px) {
    .contexa-products-grid.contexa-columns-2,
    .contexa-products-grid.contexa-columns-3,
    .contexa-products-grid.contexa-columns-4,
    .contexa-products-grid.contexa-columns-5,
    .contexa-products-grid.contexa-columns-6 {
        grid-template-columns: 1fr;
    }

    .contexa-search-box {
        flex-direction: column;
    }
}

/* Product Card */
.contexa-product-card {
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    overflow: hidden;
    transition: box-shadow 0.3s ease, transform 0.3s ease;
}

.contexa-product-card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    transform: translateY(-4px);
}

/* Product Image */
.contexa-product-image {
    position: relative;
    width: 100%;
    padding-top: 100%; /* 1:1 Aspect Ratio */
    overflow: hidden;
    background-color: #f5f5f5;
}

.contexa-product-image a {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.contexa-product-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.contexa-product-card:hover .contexa-product-image img {
    transform: scale(1.05);
}

.contexa-sale-badge {
    position: absolute;
    top: 10px;
    right: 10px;
    padding: 4px 8px;
    background-color: #e91e63;
    color: #fff;
    font-size: 12px;
    font-weight: 600;
    border-radius: 4px;
    text-transform: uppercase;
    z-index: 1;
}

/* Product Info */
.contexa-product-info {
    padding: 16px;
}

.contexa-product-title {
    margin: 0 0 8px;
    font-size: 18px;
    font-weight: 600;
    line-height: 1.4;
}

.contexa-product-title a {
    color: #333;
    text-decoration: none;
    transition: color 0.3s ease;
}

.contexa-product-title a:hover {
    color: #0073aa;
}

.contexa-product-categories {
    margin-bottom: 8px;
    font-size: 13px;
    color: #666;
}

.contexa-product-description {
    margin-bottom: 12px;
    font-size: 14px;
    color: #555;
    line-height: 1.5;
}

.contexa-product-price {
    margin-bottom: 12px;
    font-size: 20px;
    font-weight: 700;
    color: #333;
}

.contexa-product-price del {
    font-size: 16px;
    color: #999;
    margin-right: 8px;
}

.contexa-product-price ins {
    text-decoration: none;
    color: #e91e63;
}

/* Stock Status */
.contexa-stock-status {
    margin-bottom: 12px;
    font-size: 13px;
    font-weight: 600;
}

.contexa-stock-status .in-stock {
    color: #4caf50;
}

.contexa-stock-status .out-of-stock {
    color: #f44336;
}

/* Product Actions */
.contexa-product-actions {
    margin-top: 12px;
}

.contexa-button {
    display: inline-block;
    padding: 10px 20px;
    font-size: 14px;
    font-weight: 600;
    text-align: center;
    text-decoration: none;
    border-radius: 4px;
    transition: background-color 0.3s ease, color 0.3s ease;
}

.contexa-button-primary {
    color: #fff;
    background-color: #0073aa;
    border: 2px solid #0073aa;
}

.contexa-button-primary:hover {
    background-color: #005177;
    border-color: #005177;
}

.contexa-button-secondary {
    color: #0073aa;
    background-color: transparent;
    border: 2px solid #0073aa;
}

.contexa-button-secondary:hover {
    color: #fff;
    background-color: #0073aa;
}

/* Loading Animation */
@keyframes contexa-spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.contexa-loading {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid #f3f3f3;
    border-top: 2px solid #0073aa;
    border-radius: 50%;
    animation: contexa-spin 1s linear infinite;
}

/* Search Results Sections */
.contexa-search-results {
    margin: 20px 0;
}

.contexa-results-section {
    margin-bottom: 40px;
}

.contexa-section-title {
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 2px solid #e0e0e0;
}

/* Posts and Recipes Lists */
.contexa-posts-list,
.contexa-recipes-list,
.contexa-generic-list {
    display: grid;
    gap: 16px;
}

.contexa-post-card,
.contexa-recipe-card,
.contexa-generic-card {
    padding: 16px;
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    transition: box-shadow 0.3s ease;
}

.contexa-post-card:hover,
.contexa-recipe-card:hover,
.contexa-generic-card:hover {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.contexa-post-title,
.contexa-recipe-title,
.contexa-generic-title {
    margin: 0 0 12px;
    font-size: 18px;
    font-weight: 600;
}

.contexa-post-title a,
.contexa-recipe-title a,
.contexa-generic-title a {
    color: #333;
    text-decoration: none;
    transition: color 0.3s ease;
}

.contexa-post-title a:hover,
.contexa-recipe-title a:hover,
.contexa-generic-title a:hover {
    color: #0073aa;
}

.contexa-read-more,
.contexa-view-recipe {
    display: inline-block;
    color: #0073aa;
    text-decoration: none;
    font-weight: 600;
    transition: color 0.3s ease;
}

.contexa-read-more:hover,
.contexa-view-recipe:hover {
    color: #005177;
}

/* Product Excerpt */
.contexa-product-excerpt {
    margin-bottom: 12px;
    font-size: 14px;
    color: #666;
    line-height: 1.5;
}

/* Product Actions */
.contexa-product-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

/* Quantity Input */
.contexa-quantity-wrapper {
    display: inline-block;
}

.contexa-quantity-input {
    width: 60px;
    padding: 10px 8px;
    font-size: 14px;
    font-weight: 600;
    text-align: center;
    border: 2px solid #ddd;
    border-radius: 4px;
    transition: border-color 0.3s ease;
}

.contexa-quantity-input:focus {
    outline: none;
    border-color: #0073aa;
}

/* Remove spinner arrows in Chrome, Safari, Edge, Opera */
.contexa-quantity-input::-webkit-outer-spin-button,
.contexa-quantity-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

/* Remove spinner arrows in Firefox */
.contexa-quantity-input[type=number] {
    -moz-appearance: textfield;
}

.screen-reader-text {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0,0,0,0);
    white-space: nowrap;
    border-width: 0;
}

/* Add to Cart and View Product Buttons */
.contexa-add-to-cart-btn,
.contexa-view-product {
    display: inline-block;
    padding: 10px 20px;
    font-size: 14px;
    font-weight: 600;
    text-decoration: none;
    border-radius: 4px;
    transition: all 0.3s ease;
    cursor: pointer;
    border: 2px solid;
}

.contexa-add-to-cart-btn {
    color: #fff;
    background-color: #4caf50;
    border-color: #4caf50;
}

.contexa-add-to-cart-btn:hover:not(:disabled) {
    background-color: #388e3c;
    border-color: #388e3c;
}

.contexa-add-to-cart-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.contexa-view-product {
    color: #0073aa;
    background-color: transparent;
    border: 2px solid #0073aa;
}

.contexa-view-product:hover {
    color: #fff;
    background-color: #0073aa;
}

.contexa-out-of-stock {
    display: inline-block;
    padding: 10px 20px;
    color: #666;
    background-color: #f5f5f5;
    border-radius: 4px;
    font-weight: 600;
}

/* No Results */
.contexa-no-results {
    padding: 40px 20px;
    text-align: center;
    background: #f9f9f9;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
}

.contexa-no-results p {
    margin: 0;
    font-size: 18px;
    color: #666;
}

/* ========================================
   TEMPLATE STYLES
   ======================================== */

/* Template 1: Classic Grid (Default) */
.contexa-template-1 .contexa-product-card {
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    background: #fff;
    transition: transform 0.2s, box-shadow 0.2s;
}

.contexa-template-1 .contexa-product-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

/* Template 2: Minimal Clean */
.contexa-template-2 .contexa-product-card {
    border: none;
    border-bottom: 1px solid #f0f0f0;
    border-radius: 0;
    background: transparent;
    padding: 20px 0;
}

.contexa-template-2 .contexa-product-card:hover {
    background: #fafafa;
}

.contexa-template-2 .contexa-product-image {
    border-radius: 12px;
    overflow: hidden;
}

.contexa-template-2 .contexa-product-image img {
    transition: transform 0.3s;
}

.contexa-template-2 .contexa-product-card:hover .contexa-product-image img {
    transform: scale(1.05);
}

/* Template 3: Card with Shadow */
.contexa-template-3 .contexa-product-card {
    border: none;
    border-radius: 12px;
    background: #fff;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    overflow: hidden;
    transition: box-shadow 0.3s;
}

.contexa-template-3 .contexa-product-card:hover {
    box-shadow: 0 8px 24px rgba(0,0,0,0.15);
}

.contexa-template-3 .contexa-product-image {
    background: #f8f8f8;
}

.contexa-template-3 .contexa-product-info {
    padding: 16px;
}

/* Template 4: Modern Bordered */
.contexa-template-4 .contexa-product-card {
    border: 2px solid #000;
    border-radius: 0;
    background: #fff;
    transition: background 0.2s, color 0.2s;
}

.contexa-template-4 .contexa-product-card:hover {
    background: #000;
    color: #fff;
}

.contexa-template-4 .contexa-product-card:hover .contexa-product-title a {
    color: #fff;
}

.contexa-template-4 .contexa-product-card:hover .contexa-product-price {
    color: #fff;
}

.contexa-template-4 .contexa-product-card:hover .contexa-product-excerpt {
    color: #ddd;
}

.contexa-template-4 .contexa-add-to-cart-btn,
.contexa-template-4 .contexa-view-product {
    background: #000;
    color: #fff;
    border: 2px solid #000;
}

.contexa-template-4 .contexa-product-card:hover .contexa-add-to-cart-btn,
.contexa-template-4 .contexa-product-card:hover .contexa-view-product {
    background: #fff;
    color: #000;
}

/* Template 5: Colorful Gradient */
.contexa-template-5 .contexa-product-card {
    border: none;
    border-radius: 16px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    overflow: hidden;
    position: relative;
}

.contexa-template-5 .contexa-product-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255,255,255,0);
    transition: background 0.3s;
    z-index: 1;
}

.contexa-template-5 .contexa-product-card:hover::before {
    background: rgba(255,255,255,0.1);
}

.contexa-template-5 .contexa-product-image {
    position: relative;
    z-index: 2;
}

.contexa-template-5 .contexa-product-info {
    position: relative;
    z-index: 2;
}

.contexa-template-5 .contexa-product-title a {
    color: #fff;
}

.contexa-template-5 .contexa-product-price {
    color: #fff;
    font-weight: bold;
}

.contexa-template-5 .contexa-product-excerpt {
    color: rgba(255,255,255,0.9);
}

.contexa-template-5 .contexa-add-to-cart-btn,
.contexa-template-5 .contexa-view-product {
    background: #fff;
    color: #667eea;
    border: 2px solid #fff;
    font-weight: 600;
}

.contexa-template-5 .contexa-add-to-cart-btn:hover,
.contexa-template-5 .contexa-view-product:hover {
    background: transparent;
    color: #fff;
}

.contexa-template-5 .contexa-sale-badge {
    background: #ffd700;
    color: #000;
}

/* ========================================
   LIST LAYOUT
   ======================================== */

.contexa-products-list {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.contexa-products-list .contexa-product-card {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 20px;
    padding-left: 20px;
    width: 100%;
}

.contexa-products-list .contexa-product-image {
    flex-shrink: 0;
    width: 120px;
    padding-top: 120px; /* Square aspect ratio - smaller */
}

/* Actions (quantity + add to cart) - horizontal row after image */
.contexa-products-list .contexa-product-actions {
    flex-shrink: 0;
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 12px;
    margin-top: 0;
}

/* Product details (title + price + description) - RIGHT column */
.contexa-products-list .contexa-product-details {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.contexa-products-list .contexa-product-details .contexa-product-price {
    margin-bottom: 0;
}

.contexa-products-list .contexa-product-title {
    margin: 0;
}

.contexa-products-list .contexa-product-price {
    margin: 0;
}

.contexa-products-list .contexa-product-excerpt {
    margin: 0;
}

.contexa-products-list .contexa-add-to-cart-btn {
    white-space: nowrap;
    min-width: auto;
}

.contexa-products-list .contexa-cart-success-message {
    font-size: 13px;
    color: #4caf50;
    font-weight: 600;
    margin: 0;
    margin-left: 12px;
}

/* ========================================
   VARIATION OPTIONS
   ======================================== */

.contexa-variation-options {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 10px;
    width: 100%;
}

.contexa-variation-select {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 1;
    min-width: 120px;
}

.contexa-variation-select label {
    font-size: 12px;
    font-weight: 600;
    color: #555;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.contexa-variation-dropdown {
    padding: 8px 10px;
    font-size: 13px;
    border: 1px solid #ddd;
    border-radius: 4px;
    background: #fff;
    color: #333;
    cursor: pointer;
    transition: border-color 0.2s ease;
    appearance: auto;
}

.contexa-variation-dropdown:focus {
    outline: none;
    border-color: #0073aa;
    box-shadow: 0 0 0 1px #0073aa;
}

.contexa-variation-dropdown:invalid,
.contexa-variation-dropdown[style*="border-color: rgb(220, 38, 38)"] {
    border-color: #dc2626;
}

/* List layout: variation options inline */
.contexa-products-list .contexa-variation-options {
    flex-direction: row;
}

/* Grid layout: variation options stack */
.contexa-products-grid .contexa-variation-options {
    flex-direction: column;
}

/* ========================================
   QUANTITY SELECTOR WITH +/- BUTTONS
   ======================================== */

.contexa-quantity-selector {
    display: inline-flex;
    align-items: center;
    border-radius: 4px;
    overflow: hidden;
}

.contexa-qty-btn {
    background: #fff;
    border: none;
    width: 32px;
    height: 36px;
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
    transition: background 0.2s;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.contexa-qty-btn:hover {
    background: #f5f5f5;
}

.contexa-qty-btn:active {
    background: #e0e0e0;
}

.contexa-quantity-selector .contexa-quantity-input {
    width: 50px;
    height: 36px;
    border: none;
    border-left: 1px solid #ddd;
    border-right: 1px solid #ddd;
    text-align: center;
    font-size: 14px;
    font-weight: 600;
    padding: 0;
    margin: 0;
    -moz-appearance: textfield;
}

.contexa-quantity-selector .contexa-quantity-input::-webkit-outer-spin-button,
.contexa-quantity-selector .contexa-quantity-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.contexa-quantity-selector .contexa-quantity-input:focus {
    outline: none;
}

/* Grid layout keeps original wrapper structure */
.contexa-products-grid .contexa-product-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
    align-items: stretch;
}
.contexa-products-grid .contexa-product-details{
    text-align: center;
}
.contexa-products-grid .contexa-quantity-selector {
    justify-content: center;
}

.contexa-products-grid .contexa-add-to-cart-btn {
    width: 100%;
}

/* Responsive adjustments for list layout */
@media (max-width: 768px) {
    .contexa-products-list .contexa-product-card {
        flex-direction: column;
    }

    .contexa-products-list .contexa-product-image {
        width: 100%;
        max-width: 300px;
    }

    .contexa-products-list .contexa-product-actions {
        margin-left: 0;
        width: 100%;
    }
}
