/**
 * Product Plugin Styles
 * Front-end styles for Product plugin
 * Integrates with Core plugin's Tailwind CSS and design system
 */

/* Product Grid Layout - Global sidebar durumuna göre responsive grid */
.product-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.5rem;
    transition: grid-template-columns 0.3s ease;
    align-items: start; /* Ensure cards align at the top */
}

/* Ensure all cards in the grid have equal height */
.product-grid .product-card {
    height: 100%; /* Make all cards the same height */
    display: flex !important;
    flex-direction: column;
}

/* Global sidebar kapalı durumunda - maksimum 5 kart */
body:not(.sidebar-expanded) .product-grid {
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
}

/* Global sidebar açık durumunda - maksimum 4 kart */
body.sidebar-expanded .product-grid {
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
}

/* Ekran boyutlarına göre responsive ayarlar - Global sidebar kapalı */
@media (min-width: 640px) and (max-width: 1023px) {
    body:not(.sidebar-expanded) .product-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (min-width: 1024px) and (max-width: 1279px) {
    body:not(.sidebar-expanded) .product-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (min-width: 1280px) and (max-width: 1535px) {
    body:not(.sidebar-expanded) .product-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

@media (min-width: 1536px) {
    body:not(.sidebar-expanded) .product-grid {
        grid-template-columns: repeat(5, 1fr);
    }
}

/* Ekran boyutlarına göre responsive ayarlar - Global sidebar açık */
@media (min-width: 640px) and (max-width: 1023px) {
    body.sidebar-expanded .product-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (min-width: 1024px) and (max-width: 1279px) {
    body.sidebar-expanded .product-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (min-width: 1280px) and (max-width: 1535px) {
    body.sidebar-expanded .product-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

@media (min-width: 1536px) {
    body.sidebar-expanded .product-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

/* Çok küçük ekranlarda tek sütun */
@media (max-width: 639px) {
    .product-grid {
        grid-template-columns: 1fr;
    }
    
    /* Ensure cards maintain consistent height on mobile */
    .product-grid .product-card {
        min-height: 280px; /* Smaller on mobile */
    }
    
    /* Adjust title height for mobile */
    .product-card h2 {
        min-height: 2.2em; /* Smaller on mobile */
        max-height: 2.2em;
    }
}

/* Kart boyutları değişmeden ekrana sığmıyorsa otomatik azaltma */
@media (max-width: 1200px) {
    body.sidebar-expanded .product-grid {
        grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    }
}

@media (max-width: 1000px) {
    body:not(.sidebar-expanded) .product-grid {
        grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    }
}

/* JavaScript ile eklenen class'lar için ek stiller */
.product-grid.sidebar-expanded-grid {
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
}

.product-grid.sidebar-collapsed-grid {
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
}

/* JavaScript class'ları ile responsive ayarlar */
@media (min-width: 640px) and (max-width: 1023px) {
    .product-grid.sidebar-expanded-grid,
    .product-grid.sidebar-collapsed-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (min-width: 1024px) and (max-width: 1279px) {
    .product-grid.sidebar-collapsed-grid {
        grid-template-columns: repeat(3, 1fr);
    }
    .product-grid.sidebar-expanded-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (min-width: 1280px) and (max-width: 1535px) {
    .product-grid.sidebar-collapsed-grid {
        grid-template-columns: repeat(4, 1fr);
    }
    .product-grid.sidebar-expanded-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

@media (min-width: 1536px) {
    .product-grid.sidebar-collapsed-grid {
        grid-template-columns: repeat(5, 1fr);
    }
    .product-grid.sidebar-expanded-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

/* Product card styling - Using Tailwind classes in templates */
.product-card {
    @apply flex flex-col h-full;
    border: none !important;
    background-color: transparent !important;
    min-height: 320px; /* Reduced card height */
    display: flex !important; /* Force flex display */
}

/* High-quality image rendering for product images */
.product-card img {
    image-rendering: auto; /* Use browser's best quality algorithm */
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    transform: translateZ(0);
    -webkit-transform: translateZ(0);
    -webkit-font-smoothing: antialiased;
}

.product-card .p-4 {
    @apply flex flex-col flex-grow h-full justify-start p-4;
}

.product-card h2 {
    display: -webkit-box;
    -webkit-line-clamp: 2; /* Limit to 2 lines */
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.3;
    min-height: 2.6em; /* Reduced height for 2 lines */
    max-height: 2.6em; /* Prevent overflow */
    margin-bottom: 0.5rem; /* Reduced spacing */
    word-wrap: break-word; /* Handle long words */
    hyphens: auto; /* Add hyphenation for better text flow */
    flex-grow: 0; /* Don't expand title area */
}

/* Fallback for browsers that don't support -webkit-line-clamp */
@supports not (-webkit-line-clamp: 2) {
    .product-card h2 {
        display: block;
        height: 2.8em; /* Fixed height for 2 lines */
        overflow: hidden;
        position: relative;
    }
    
    .product-card h2::after {
        content: '...';
        position: absolute;
        bottom: 0;
        right: 0;
        background: inherit;
        padding-left: 0.5em;
    }
}

/* Ensure consistent spacing for all card elements */
.product-card .aspect-w-16 {
    @apply flex-shrink-0 mb-3;
}

.product-card .flex.items-center.justify-between {
    @apply flex-shrink-0 mb-1;
}

.product-card .product-price {
    @apply flex-shrink-0 mb-2;
}

.product-card .mt-4 {
    @apply flex-shrink-0;
    margin-top: 0.5rem !important; /* Reduced spacing between price and button */
}

/* Make the button more compact */
.product-card .mt-4 button {
    @apply py-2 px-4 text-sm;
}

/* Hide the icon in the button */
.product-card .mt-4 button svg {
    @apply hidden;
}

/* Product Price Styling - Using Tailwind classes in templates */
.product-price {
    @apply font-semibold;
}

.product-price .line-through {
    @apply line-through text-gray-500;
}

/* Product Gallery Styles - Using Tailwind classes in templates */
.product-gallery {
    @apply rounded-xl overflow-hidden shadow-lg;
    background-color: var(--color-card, #0f0f0f);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

.gallery-container {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

/* Desktop gallery layout - thumbnails on the right */
@media (min-width: 1024px) {
    .gallery-container {
        flex-direction: row;
        align-items: flex-start;
    }
}

.gallery-main {
    flex-grow: 1;
}

.main-image-container {
    position: relative;
    border-radius: 0.5rem;
    overflow: hidden;
    width: 100%;
    max-width: 1056px;
    aspect-ratio: 16/9;
    display: flex;
    align-items: center;
    justify-content: center;
}

.main-image-container img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* Mobile 16:9 aspect ratio */
@media (max-width: 1200px) {
    .main-image-container {
        aspect-ratio: 16/9;
        max-height: 594px;
    }
    
    .main-image-container img {
        height: 100%;
        object-fit: cover;
    }
}

/* Tablet 16:9 aspect ratio */
@media (max-width: 768px) {
    .main-image-container {
        aspect-ratio: 16/9;
        max-height: 400px;
    }
}

/* Mobile 16:9 aspect ratio */
@media (max-width: 480px) {
    .main-image-container {
        aspect-ratio: 16/9;
        max-height: 300px;
    }
}

.gallery-thumbnails {
    width: 100%;
}

/* Desktop gallery thumbnails */
@media (min-width: 1024px) {
    .gallery-thumbnails {
        width: 7rem; /* Increased width for better visibility */
        flex-shrink: 0;
    }
}

.thumbnails-scroll {
    display: flex;
    gap: 0.5rem;
    overflow-x: auto;
    -ms-overflow-style: none;
    scrollbar-width: none;
}

/* Desktop thumbnail layout */
@media (min-width: 1024px) {
    .thumbnails-scroll {
        flex-direction: column;
        overflow-y: auto;
        overflow-x: hidden;
        height: 100%; /* Match the height of main image container */
        padding-right: 4px; /* Add space for scrollbar */
        gap: 0.25rem; /* Gap between thumbnails */
    }
    
    /* Calculate thumbnail height for 5 images - Square thumbnails */
    .thumbnail-item {
        height: 80px; /* Smaller height to fit within main image */
        width: 80px; /* Square thumbnails */
        aspect-ratio: 1/1; /* Force square aspect ratio */
        flex-shrink: 0;
    }
}

.thumbnails-scroll::-webkit-scrollbar {
    display: none;
}

.thumbnail-item {
    cursor: pointer;
    border-radius: 0.5rem;
    overflow: hidden;
    transition: all 0.2s ease;
    border: 1px solid transparent;
    flex-shrink: 0;
}

.thumbnail-item img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.thumbnail-item:hover {
    opacity: 0.9;
}

/* Hide scrollbar for thumbnails */
.thumbnails-scroll { 
    -ms-overflow-style: none; 
    scrollbar-width: none; 
}

.thumbnails-scroll::-webkit-scrollbar { 
    display: none; 
}

/* Thumbnails baseline and active styles */
.thumbnail-item { 
    border-width: 1px; 
    border-color: transparent; 
    border-radius: 0.5rem; 
}

.thumbnail-item img { 
    display: block; 
}

.thumbnail-item.active { 
    border-color: #3b82f6; 
    transform: scale(1.05); 
    box-shadow: inset 0 0 0 1px rgba(59, 130, 246, 0.2); 
}

/* Product Details Section - Using Tailwind classes in templates */
.product-details {
    @apply bg-gray-900 rounded-lg p-6 mb-8;
}

.product-details h3 {
    @apply text-white text-xl font-bold mb-5 flex items-center;
}

.product-details h3 svg {
    @apply mr-2 text-blue-500;
}

.product-features-list {
    @apply list-none p-0 m-0 space-y-2;
}

.product-features-list li {
    @apply flex items-start;
}

.product-features-list li svg {
    @apply mr-2 mt-0.5 flex-shrink-0 text-blue-500;
}

.product-features-list li span {
    @apply text-gray-300;
}

/* Product Download Button - Using Tailwind classes in templates */
.product-details a[href*="download"] {
    @apply inline-flex items-center px-6 py-3 bg-blue-600 hover:bg-blue-700 text-white font-medium rounded-lg transition-all duration-200 hover:-translate-y-0.5;
}

.product-details a[href*="download"] svg {
    @apply mr-2;
}

/* Product Sidebar - Using Tailwind classes in templates */
.product-sidebar {
    @apply flex-shrink-0 relative;
}

.sticky-sidebar {
    @apply sticky top-0 z-10;
}

/* Product Categories Sidebar - Using Tailwind classes in templates */
#products-sidebar {
    @apply bg-gray-900 rounded-xl shadow-lg p-4;
}

#products-sidebar a {
    @apply inline-block transform-gpu transition-all duration-200;
}

#products-sidebar a:hover {
    @apply text-white;
    color: white !important;
}

/* Scale animation only on desktop */
@media (min-width: 768px) {
    #products-sidebar a:hover {
        transform: scale(1.05);
    }
}

#products-sidebar a span {
    @apply transition-colors duration-200;
}

#products-sidebar a:hover span {
    @apply text-white;
    color: white !important;
}

/* Filter toggle hover effect */
#filter-toggle {
    transform-origin: center;
}

#filter-toggle:hover {
    color: white !important;
}

#filter-toggle:hover span {
    color: white !important;
}

/* Scale animation only on desktop */
@media (min-width: 768px) {
    #filter-toggle:hover {
        transform: scale(1.05);
    }
}

/* Category Tree Styles - Using Tailwind classes in templates */
/* Category item styles are now handled by Tailwind classes in PHP template controller */
/* Only keeping styles that need special handling */
.subcategories.hidden {
    @apply hidden;
}

/* Responsive Design - Using Tailwind classes in templates */
/* Responsive styles are handled by Tailwind responsive prefixes in templates */

/* Product Archive Page Styles - Using Tailwind classes in templates */
.product-archive-content {
    @apply min-h-screen bg-gray-50 dark:bg-gray-900;
}

.products-header-container {
    @apply p-4 text-left md:text-center;
}

.category-description-wrapper p {
    @apply ml-0 mr-0 text-left;
}

/* No Products Message - Using Tailwind classes in templates */
.no-products {
    @apply bg-gray-900 rounded-xl p-8 text-center max-w-2xl w-full;
}

.no-products h2 {
    @apply text-white text-xl font-bold mb-2;
}

.no-products p {
    @apply text-gray-300;
}

/* Product Single Page Styles - Using Tailwind classes in templates */
.product-layout {
    @apply flex flex-col gap-8 lg:flex-row;
}

.product-main-content {
    @apply flex-1 overflow-x-hidden pb-2 px-2 sm:pl-6 lg:pl-8;
}

/* Product Gallery Mobile/Desktop Split - Using Tailwind classes in templates */
.product-gallery.lg\\:hidden {
    @apply mb-0;
}

.product-gallery.hidden.lg\\:block {
    @apply p-6;
}

/* Product Content Styling - Using Tailwind classes in templates */
.product-main-content .bg-gray-900 {
    @apply bg-gray-900 rounded-xl shadow-lg overflow-hidden;
}

/* Product Meta Information - Using Tailwind classes in templates */
.product-main-content .flex.items-center {
    @apply flex items-center flex-wrap gap-4 text-gray-400 text-sm mb-4;
}

.product-main-content .flex.items-center a {
    @apply text-gray-400 hover:text-blue-600 transition-colors duration-200;
}

/* Product Tags - Using Tailwind classes in templates */
.product-main-content .pt-6 {
    @apply pt-6 border-t border-gray-700;
}

.product-main-content .pt-6 h4 {
    @apply text-white text-lg font-medium mb-3;
}

.product-main-content .pt-6 a {
    @apply inline-block px-3 py-1.5 bg-gray-800 hover:bg-gray-700 text-gray-300 hover:text-white text-xs font-medium rounded-md transition-colors mr-2 mb-2;
}

/* Related Products - Using Tailwind classes in templates */
.related-product-card {
    @apply bg-gray-900 rounded-xl shadow-lg overflow-hidden transition-all duration-300 hover:-translate-y-0.5 hover:shadow-xl;
}

.related-product-card .p-4 {
    @apply p-4 flex flex-col;
}

.related-product-card h4 {
    @apply text-white text-lg font-semibold mb-3 leading-tight;
}

.related-product-card h4 a {
    @apply text-white hover:text-blue-600 transition-colors duration-200;
}

/* Author Bio Show More Functionality - Using Tailwind classes in templates */
.author-bio-short {
    @apply block;
}

.author-bio-full {
    @apply hidden;
}

.author-bio-full:not(.hidden) {
    @apply block;
}

.author-bio-short.hidden {
    @apply hidden;
}

.show-more-bio {
    @apply text-blue-600 hover:text-blue-700 text-xs mt-1 cursor-pointer transition-colors duration-200;
}

/* Comments Section - Using Tailwind classes in templates */
.product-main-content .bg-gray-900:last-of-type {
    @apply mb-0;
}

/* Pagination - Using Tailwind classes in templates */
.pagination-wrapper {
    @apply mt-8;
}

.pagination {
    @apply flex justify-center gap-2;
}

.page-link {
    @apply inline-block;
}

.page-link a {
    @apply inline-block px-3 py-2 bg-gray-800 hover:bg-gray-700 text-gray-300 hover:text-white rounded-md transition-colors duration-200;
}

.page-link .current {
    @apply bg-blue-600 text-white;
}

/* Sticky Sidebar for Desktop - Using Tailwind classes in templates */
@media (min-width: 1024px) {
    .single-product .sticky-sidebar {
        position: fixed !important;
        top: 5rem !important;
        right: 2rem !important;
        width: calc(33.333333% - 1rem) !important;
        max-width: 320px !important;
        z-index: 10 !important;
        max-height: calc(100vh - 5rem) !important;
        overflow-y: auto !important;
        transform: translateZ(0) !important;
        will-change: transform !important;
    }
}

/* Mobile Optimizations */
@media (max-width: 1023px) {
    .product-layout {
        flex-direction: column;
    }
    
    .product-sidebar {
        width: 100%;
    }
    
    .sticky-sidebar {
        position: relative;
        top: auto;
    }
    
    /* Mobil ekranlarda product-details için padding ve margin */
    .product-main-content .product-details {
        @apply p-6 mb-8;
    }
    
    /* Mobil ekranlarda "Bu ürüne dahil:" alanından sonraki içerik için boşluk */
    .product-details + .entry-content,
    .product-details ~ .entry-content {
        @apply mt-8 pt-0;
    }
    
    /* Product details bölümünden sonraki tüm içerik için boşluk */
    .product-main-content .product-details + * {
        @apply mt-8;
    }
    
    /* Entry content için mobilde ekstra boşluk - product-details'ten sonra */
    .product-main-content .product-details ~ .entry-content {
        @apply mt-10;
    }
    
    /* Product features list'ten sonraki boşluk */
    .product-features-list {
        @apply mb-0 pb-0;
    }
    
    /* Product details içindeki grid için mobil spacing */
    .product-details .grid {
        @apply gap-6;
    }
    
    /* Product details içindeki "Bu ürüne dahil:" bölümü için alt boşluk */
    .product-details .grid > div:last-child {
        @apply mb-0 pb-0;
    }
    
    /* Product details içindeki div'ler için mobil spacing */
    .product-details > div > div {
        @apply mb-4;
    }
    
    /* Product details'in kendisi için alt padding */
    .product-details {
        @apply pb-6;
    }
    
    /* Product details grid'inin altına ekstra boşluk */
    .product-details > .grid {
        @apply mb-0 pb-0;
    }
    
    /* Product details'ten sonraki dijital dosya butonu için boşluk */
    .product-details + div[class*="bg-blue-900"] {
        @apply mt-8;
    }
    
    /* Product details'ten sonraki entry-content için garantili boşluk */
    .product-main-content .product-details:not(:last-child) + .entry-content {
        @apply mt-10;
    }
}

/* Product Archive Gallery Thumbnails - Tailwind classes kullanılıyor */
/* Sadece JavaScript tarafından dinamik olarak eklenen stiller için */
.product-thumb-btn:focus {
    outline: 2px solid rgba(59, 130, 246, 0.5);
    outline-offset: 2px;
}

/* Active state - JavaScript tarafından bg-white class'ı eklendiğinde */
.product-thumb-btn.bg-white {
    background-color: white !important;
    transform: scale(1.4);
    box-shadow: 0 0 8px rgba(255, 255, 255, 0.8);
}

.product-thumb-btn.bg-white:hover {
    transform: scale(1.5);
    box-shadow: 0 0 12px rgba(255, 255, 255, 1);
}

/* Print Styles */
@media print {
    .product-sidebar,
    .product-gallery,
    .related-product-card {
        display: none;
    }
    
    .product-main-content {
        width: 100%;
        padding: 0;
    }
}

/* Archive Template Styles - JavaScript tarafından kullanılan CSS'ler */
/* Hide scrollbar for filters row but keep horizontal scroll */
.filters-scroll {
    -ms-overflow-style: none; /* IE and Edge */
    scrollbar-width: none; /* Firefox */
}
.filters-scroll::-webkit-scrollbar {
    display: none; /* Chrome, Safari, Opera */
}

/* Sidebar Sticky Behavior - JavaScript tarafından dinamik olarak ayarlanıyor */
#products-sidebar {
    position: fixed;
    top: 76px; /* Default with header - will be adjusted by JavaScript */
    width: 256px; /* w-64 = 16rem = 256px */
    z-index: 50;
    transition: top 0.15s ease, left 0.15s ease;
    display: block; /* Always visible */
}

/* Prevent transition on initial sticky positioning */
#products-sidebar.sticky.no-transition {
    transition: none !important;
}

/* Responsive adjustments for archive templates */
@media (max-width: 1024px) {
    .flex.gap-8 {
        flex-direction: column;
    }
    .w-64 {
        width: 100%;
    }
    #products-sidebar {
        position: relative !important;
        top: auto !important;
        left: auto !important;
        width: 100% !important;
    }
    #products-sidebar.sticky {
        position: relative !important;
        top: auto !important;
        left: auto !important;
        width: 100% !important;
    }
    
    /* Responsive adjustments for hierarchical structure */
    .category-item.level-1,
    .category-item.level-2,
    .category-item.level-3 {
        margin-left: 0.5rem;
    }
}




