/* Custom CSS Overrides and Enhancements for Tailwind */

/* Smooth scrolling for sections */
html {
    scroll-behavior: smooth;
}

/* Section animation on scroll */
.section-animate {
    animation: slideIn 0.5s ease-out forwards;
}

@keyframes slideIn {
    0% {
        opacity: 0;
        transform: translateY(20px);
    }
    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Ensure catalog section text is readable */
.catalog-section {
    position: relative;
    overflow: hidden;
    background-color: #9F3133; /* Ensure solid background for contrast */
    padding: 20px 0; /* Adjust padding as needed */
}

.catalog-section .container {
    position: relative;
    z-index: 10; /* Bring content above any background elements */
}

/* Improve text contrast and readability */
.catalog-section h2,
.catalog-section p {
    color: #ffffff !important; /* Ensure white text for contrast */
    text-shadow: 1px 1px 3px rgba(0, 0, 0, 0.5); /* Optional: Add shadow for better readability */
}

.catalog-section .category-pills button,
.catalog-section .catalog-filters input,
.catalog-section .catalog-filters select {
    background-color: #ffffff !important; /* White background for filters */
    color: #9F3133 !important; /* Match primary color for text */
}

/* Underline for catalog section title */
.catalog-section h2 {
    position: relative;
    display: inline-block;
}
.catalog-section h2::after {
    content: "";
    position: absolute;
    bottom: -5px;
    left: 0;
    width: 100%;
    height: 2px;
    background-color: #ffffff; /* Match text color */
}

/* Ensure grid and pagination are not overlapped */
.catalog-gallery,
.catalog-pagination {
    position: relative;
    z-index: 10;
}

/* Ensure modal only shows on trigger */
.modal.fade {
    display: none;
}

.modal.show {
    display: block;
}

/* Base modal styles (reset conflicts) */
.modal-content {
    border-radius: 1rem;
    overflow: hidden;
}

.modal-header {
    border-bottom: 1px solid #e5e7eb;
}

.modal-title {
    font-size: 1rem; /* Default for mobile */
}

.modal-close {
    font-size: 1.5rem;
    transition: color 0.3s ease;
}

.modal-body {
    padding: 0.75rem; /* Default for mobile */
}

/* Image container and overlay */
.modal-image-container {
    position: relative;
    width: 100%;
}

.modal-product-image {
    width: 100%;
    height: 40vh; /* Default for mobile */
    object-fit: cover; /* Default for mobile */
    display: block;
}

.image-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(0, 0, 0, 0.6);
    padding: 0.5rem; /* Default for mobile */
    color: white;
}

/* Two-column layout for price/status and specs */
.modal-columns {
    display: flex;
    flex-direction: row; /* Default for mobile */
    justify-content: space-between;
    gap: 0.5rem;
}

.modal-price-status {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    background: #333;
    padding: 0.25rem; /* Default for mobile */
    border-radius: 0.25rem;
}

.modal-specs {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.modal-specs h5 {
    font-size: 0.875rem; /* Default for mobile */
    margin-bottom: 0.25rem;
}

.modal-specs ul {
    margin-top: 0;
    font-size: 0.75rem; /* Default for mobile */
}

.modal-price p {
    margin: 0;
    font-size: 0.875rem; /* Default for mobile */
    color: white;
}

#modalProductStatus {
    font-size: 0.75rem; /* Default for mobile */
    color: white;
}

.modal-actions .btn-primary {
    background-color: #9F3133;
}

.modal-actions .btn-primary:hover {
    background-color: #7A2527;
}

/* Smooth transition for product cards */
.product-card:hover {
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.1);
}

/* Custom loading spinner */
.catalog-loading .animate-spin {
    border-top-color: #9F3133;
}

/* Pagination Styling */
.catalog-pagination ul.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.catalog-pagination ul.pagination li {
    display: inline-block;
}

.catalog-pagination ul.pagination a {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.5rem;
    height: 2.5rem;
    background-color: #fff;
    color: #9F3133;
    border-radius: 50%;
    text-decoration: none;
    font-weight: 500;
    transition: all 0.3s ease;
}

.catalog-pagination ul.pagination a:hover,
.catalog-pagination ul.pagination a.active {
    background-color: #9F3133;
    color: #fff;
    transform: scale(1.1);
}

.catalog-pagination ul.pagination a:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Mobile-specific styles (max-width: 640px) */
@media (max-width: 640px) {
    .modal-dialog {
        margin: 1rem;
        max-width: 90%;
        height: auto;
        max-height: 80vh;
        display: flex;
        flex-direction: column;
    }
    .modal-content {
        height: 100%;
        display: flex;
        flex-direction: column;
    }
    .modal-body {
        flex-grow: 1;
        overflow-y: auto;
        padding: 0.75rem;
    }
    .modal-title {
        font-size: 1rem;
    }
    .modal-actions a {
        font-size: 0.875rem;
        width: 100%;
        display: block;
    }
    .modal-product-image {
        height: 40vh;
        object-fit: cover;
    }
    .image-overlay {
        padding: 0.5rem;
    }
    .modal-columns {
        flex-direction: row;
        gap: 0.5rem;
    }
    .modal-price-status {
        padding: 0.25rem;
    }
    .modal-specs h5 {
        font-size: 0.875rem;
    }
    .modal-specs ul {
        font-size: 0.75rem;
    }
    .modal-price p {
        font-size: 0.875rem;
    }
    #modalProductStatus {
        font-size: 0.75rem;
    }
}

/* Desktop-specific styles (min-width: 641px) */
@media (min-width: 641px) {
    .modal-content {
        max-width: 600px;
        margin: 2rem auto;
        display: block; /* Override flex for desktop */
        height: auto; /* Let content determine height */
    }
    .modal-body {
        padding: 1.5rem;
        overflow-y: visible; /* No scrolling on desktop */
    }
    .modal-title {
        font-size: 1.5rem;
    }
    .modal-product-image {
        height: auto; /* Allow natural height */
        max-height: 400px; /* Cap to prevent oversized images */
        object-fit: contain; /* Prevent cropping */
    }
    .image-overlay {
        padding: 1rem;
    }
    .modal-columns {
        flex-direction: row;
        gap: 2rem;
    }
    .modal-price-status {
        padding: 1rem;
    }
    .modal-specs h5 {
        font-size: 1.25rem;
    }
    .modal-specs ul {
        font-size: 1rem;
    }
    .modal-price p {
        font-size: 1.25rem;
    }
    #modalProductStatus {
        font-size: 1rem;
    }
    .modal-actions a {
        font-size: 1rem;
        width: auto;
        display: inline-block;
        padding: 0.75rem 1.5rem;
        border-radius: 2rem;
    }
}

/* Responsive adjustments for catalog grid */
@media (max-width: 640px) {
    .catalog-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.5rem;
    }
    .product-card {
        transform: scale(0.95);
        overflow: hidden;
    }
    .product-card .aspect-square {
        padding-top: 100%;
        position: relative;
    }
    .product-card img {
        max-height: 100%;
        width: 100%;
        height: 100%;
        object-fit: cover;
        position: absolute;
        top: 0;
        left: 0;
    }
    .product-card .p-4 {
        padding: 0.5rem;
    }
    .product-card h3 {
        font-size: 0.875rem;
        white-space: normal;
    }
    .product-card .text-lg {
        font-size: 0.75rem;
    }
    .product-card .px-4 {
        padding-left: 0.75rem;
        padding-right: 0.75rem;
    }
    .product-card .py-2 {
        padding-top: 0.5rem;
        padding-bottom: 0.5rem;
    }
    .product-card .w-10 {
        width: 2rem;
    }
    .product-card .h-10 {
        height: 2rem;
    }
    .product-card .text-gray-600 i {
        font-size: 0.875rem;
    }
}

@media (min-width: 768px) {
    .catalog-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (min-width: 1024px) {
    .catalog-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}