/* Mobile-first responsive design for billigholen.com */

/* Page layout */
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background-color: #f8f9fa;
    padding-bottom: 2rem;
}

.page-title {
    text-align: center;
    color: #343a40;
    font-weight: bold;
    margin: 1rem 0 1rem 0;
    font-size: 2rem;
}

/* Search bar styling */
.search-container {
    max-width: 800px;
    margin: 0 auto 2rem auto;
    padding: 0 1rem;
}

.search-input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    margin-bottom: 0.5rem;
}

.search-input {
    width: 100%;
    padding: 0.75rem 2.5rem 0.75rem 1rem;
    font-size: 1rem;
    border: 2px solid #e9ecef;
    border-radius: 8px;
    background-color: white;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    font-family: inherit;
}

.search-input:focus {
    outline: none;
    border-color: #007bff;
    box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.1);
}

.search-input::placeholder {
    color: #6c757d;
}

.search-clear {
    position: absolute;
    right: 0.5rem;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    font-size: 1.5rem;
    color: #6c757d;
    cursor: pointer;
    display: none;
    width: 2rem;
    height: 2rem;
    border-radius: 50%;
    transition: background-color 0.2s ease, color 0.2s ease;
}

.search-clear:hover {
    background-color: #f8f9fa;
    color: #343a40;
}

.search-clear:active {
    background-color: #e9ecef;
}

.search-results-info {
    font-size: 0.9rem;
    color: #6c757d;
    text-align: center;
}

.search-results-info.no-results {
    color: #dc3545;
    font-weight: 500;
}

/* Product list container */
.products-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    max-width: 800px;
    margin: 0 auto;
    padding: 0 1rem;
}

/* Individual product card */
.product-card {
    display: flex;
    align-items: center;
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    padding: 1rem;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 1px solid #e9ecef;
    min-height: 100px;
    /* Allow dynamic ordering for search prioritization */
    order: 0;
}

.product-card:hover,
.product-card:focus {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
    border-color: #007bff;
    outline: none;
}

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

/* Product image container */
.product-image-container {
    flex-shrink: 0;
    width: 80px;
    height: 80px;
    margin-right: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: #f8f9fa;
    border-radius: 4px;
    overflow: hidden;
}

.product-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 4px;
}

.product-image-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: #e9ecef;
    color: #6c757d;
    font-size: 0.75rem;
    text-align: center;
    border-radius: 4px;
}

/* Product information */
.product-info {
    flex: 1;
    min-width: 0;
    /* Allow text to truncate */
}

.product-title {
    margin: 0;
    font-size: 1rem;
    font-weight: 500;
    color: #343a40;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Product code display */
.product-code {
    margin: 0.5rem 0 0 0;
    font-size: 0.85rem;
    font-weight: 600;
    color: #007bff;
    background-color: #f8f9fa;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    display: inline-block;
    border: 1px solid #e9ecef;
}

/* Footer styling */
.footer {
    background-color: #f8f9fa;
    border-top: 1px solid #e9ecef;
    padding: 2rem 0 1rem 0;
    margin-top: 3rem;
}

.footer a {
    color: #007bff;
    text-decoration: none;
}

.footer a:hover {
    text-decoration: underline;
}

/* Tablet styles */
@media (min-width: 576px) {
    .product-image-container {
        width: 100px;
        height: 100px;
    }

    .product-title {
        font-size: 1.1rem;
    }

    .product-code {
        font-size: 0.9rem;
        margin: 0.6rem 0 0 0;
        padding: 0.3rem 0.6rem;
    }

    .page-title {
        font-size: 2.5rem;
    }

    .products-list {
        padding: 0 1.5rem;
    }

    .search-container {
        padding: 0 1.5rem;
    }

    .search-input {
        font-size: 1.1rem;
        padding: 1rem 2.5rem 1rem 1.5rem;
    }
}

/* Desktop styles */
@media (min-width: 768px) {
    .product-card {
        padding: 1.5rem;
        min-height: 120px;
    }

    .product-image-container {
        width: 120px;
        height: 120px;
        margin-right: 1.5rem;
    }

    .product-title {
        font-size: 1.2rem;
        -webkit-line-clamp: 2;
    }

    .product-code {
        font-size: 0.9rem;
        margin: 0.75rem 0 0 0;
    }

    .products-list {
        gap: 1.5rem;
    }
}

/* Large desktop styles */
@media (min-width: 992px) {
    .products-list {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 1.5rem;
        max-width: 1200px;
    }

    .product-card {
        flex-direction: column;
        text-align: center;
        min-height: 280px;
        padding: 1.5rem;
    }

    .product-image-container {
        width: 150px;
        height: 150px;
        margin: 0 0 1rem 0;
    }

    .product-title {
        font-size: 1.1rem;
        -webkit-line-clamp: 4;
    }

    .product-code {
        margin: 0.75rem 0 0 0;
    }
}

/* Extra large desktop - 3 columns */
@media (min-width: 1400px) {
    .products-list {
        grid-template-columns: repeat(3, 1fr);
    }

    .product-card {
        min-height: 300px;
    }
}

/* Touch device optimizations */
@media (pointer: coarse) {
    .product-card {
        min-height: 110px;
        padding: 1.2rem;
    }

    .product-card:hover {
        transform: none;
    }

    .product-card:active {
        background-color: #f8f9fa;
        transform: scale(0.98);
    }
}

/* High DPI display optimizations */
@media (-webkit-min-device-pixel-ratio: 2),
(min-resolution: 192dpi) {
    .product-card {
        border-width: 0.5px;
    }

    .footer {
        border-top-width: 0.5px;
    }
}

/* Dark mode support (if user prefers dark mode) */
@media (prefers-color-scheme: dark) {
    body {
        background-color: #1a1a1a;
        color: #ffffff;
    }

    .product-card {
        background-color: #2d2d2d;
        border-color: #404040;
        color: #ffffff;
    }

    .product-card:hover,
    .product-card:focus {
        border-color: #0d6efd;
        background-color: #353535;
    }

    .product-title {
        color: #ffffff;
    }

    .product-code {
        background-color: #404040;
        border-color: #555555;
        color: #0d6efd;
    }

    .product-image-placeholder {
        background-color: #404040;
        color: #adb5bd;
    }

    .footer {
        background-color: #212529;
        border-top-color: #404040;
    }

    .page-title {
        color: #ffffff;
    }
}

/* Accessibility improvements */
.product-card:focus {
    outline: 2px solid #0d6efd;
    outline-offset: 2px;
}

/* Loading state for images */
.product-image {
    transition: opacity 0.2s ease;
}

.product-image[loading] {
    opacity: 0.7;
}

/* Ensure proper spacing on very small screens */
@media (max-width: 320px) {
    .products-list {
        padding: 0 0.5rem;
        gap: 0.75rem;
    }

    .product-card {
        padding: 0.75rem;
        min-height: 90px;
    }

    .product-image-container {
        width: 60px;
        height: 60px;
        margin-right: 0.75rem;
    }

    .product-title {
        font-size: 0.9rem;
    }
}