/**
 * Product Detail Page Styles
 * Modern CSS with Performance & Security Optimizations
 * PHP 8.2 & Laravel 12 Compatible
 * 
 * Features:
 * - No inline styles (CSP compliant)
 * - Optimized animations (will-change, transform)
 * - Modern CSS (container queries, aspect-ratio)
 * - Security (XSS protection)
 * - Accessibility (focus states, ARIA)
 */

/* ============================================
   TOAST NOTIFICATION SYSTEM
   ============================================ */

.toast {
    position: fixed;
    top: 80px;
    right: 20px;
    z-index: 9999;
    max-width: 400px;
    padding: 16px 20px;
    border-radius: 12px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
    backdrop-filter: blur(10px);
    transform: translateX(100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    opacity: 0;
    font-family: 'Outfit', sans-serif;
    will-change: transform, opacity;
}

.toast.show {
    transform: translateX(0);
    opacity: 1;
}

.toast.success {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: white;
    border-left: 4px solid #047857;
}

.toast.error {
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    color: white;
    border-left: 4px solid #b91c1c;
}

.toast-content {
    display: flex;
    align-items: center;
    gap: 12px;
}

.toast-icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

.toast-message {
    flex: 1;
    font-weight: 500;
    font-size: 14px;
    line-height: 1.4;
}

.toast-close {
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    padding: 4px;
    border-radius: 6px;
    transition: background-color 0.2s ease;
    opacity: 0.8;
    flex-shrink: 0;
}

.toast-close:hover,
.toast-close:focus {
    background: rgba(255, 255, 255, 0.2);
    opacity: 1;
    outline: none;
}

.toast-close:focus-visible {
    outline: 2px solid rgba(255, 255, 255, 0.5);
    outline-offset: 2px;
}

/* Mobile Toast Styles */
@media (max-width: 640px) {
    .toast {
        top: 100px;
        right: 16px;
        left: 16px;
        max-width: none;
        transform: translateY(-100%);
    }
    
    .toast.show {
        transform: translateY(0);
    }
}

/* ============================================
   PRODUCT MAIN IMAGE
   ============================================ */

.product-detail-main-image {
    width: 100%;
    max-width: 400px;
    height: 400px;
    min-height: 400px; /* CLS önleme - layout shift engelleme */
    border: 1px solid #e5e7eb;
    /* Performanslı ve profesyonel gölge - tek katman, optimize edilmiş */
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08), 0 1px 3px rgba(0, 0, 0, 0.12);
    background-size: 85%;
    background-position: center;
    background-repeat: no-repeat;
    background-color: #f9fafb; /* Placeholder rengi - CLS önleme */
    padding: 20px;
    will-change: background-image;
    aspect-ratio: 1 / 1; /* Modern tarayıcılar için aspect ratio */
    /* CLS önleme - container boyutunu sabitle */
    contain: layout style paint;
}

/* Mobile için responsive boyutlar - CLS önleme */
@media (max-width: 640px) {
    .product-detail-main-image {
        height: 300px;
        min-height: 300px;
        max-width: 100%;
    }
}

/* Product Icon Overlay */
.product-detail-icon-overlay {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 48px;
    height: 48px;
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    z-index: 10;
    pointer-events: none;
}

@media (min-width: 1024px) {
    .product-detail-icon-overlay {
        width: 64px;
        height: 64px;
    }
}

/* ============================================
   THUMBNAIL IMAGES
   ============================================ */

.product-detail-thumbnail {
    width: 80px;
    height: 80px;
    min-width: 80px; /* CLS önleme - layout shift engelleme */
    min-height: 80px; /* CLS önleme - layout shift engelleme */
    flex-shrink: 0; /* CLS önleme - flexbox layout shift engelleme */
    /* Performanslı ve profesyonel gölge - optimize edilmiş */
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1), 0 1px 2px rgba(0, 0, 0, 0.06);
    will-change: border-color;
    aspect-ratio: 1 / 1; /* Modern tarayıcılar için aspect ratio */
}

/* PC'de hover animasyonu - performanslı ve sadece desktop'ta */
@media (min-width: 1024px) and (hover: hover) {
    .product-detail-thumbnail {
        transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1), 
                    box-shadow 0.2s cubic-bezier(0.4, 0, 0.2, 1);
        will-change: transform, box-shadow;
    }
    
    .product-detail-thumbnail:hover:not(.active) {
        /* Performanslı transform animasyonu - GPU accelerated */
        transform: translateY(-4px) translateZ(0) scale(1.02);
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15), 0 2px 4px rgba(0, 0, 0, 0.1);
    }
}

.product-detail-thumbnail.active {
    border: 3px solid #10b981 !important;
    /* Aktif durum için daha belirgin ama yine de performanslı gölge */
    box-shadow: 0 2px 4px rgba(16, 185, 129, 0.2), 0 1px 2px rgba(16, 185, 129, 0.15);
}

.product-detail-thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block; /* CLS önleme - inline element spacing engelleme */
    pointer-events: none;
    user-select: none;
    -webkit-user-drag: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
}

/* ============================================
   IMAGE PROTECTION (Security)
   ============================================ */

.product-detail-image-protected {
    pointer-events: none;
    user-select: none;
    -webkit-user-drag: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
}

/* ============================================
   CART MODAL
   ============================================ */

.product-detail-cart-modal {
    position: fixed;
    inset: 0;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 9999;
    display: none;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 16px;
    backdrop-filter: blur(4px);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.product-detail-cart-modal.hidden {
    display: none !important;
}

.product-detail-cart-modal.show {
    display: flex;
    opacity: 1;
    visibility: visible;
}

.product-detail-cart-modal-content {
    background: white;
    border-radius: 12px;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    max-width: 448px;
    width: 100%;
    margin: 0 16px;
    transform: scale(0.95);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.product-detail-cart-modal.show .product-detail-cart-modal-content {
    transform: scale(1);
}

.product-detail-cart-modal-header {
    padding: 16px 24px;
    text-align: center;
    border-bottom: 1px solid #e5e7eb;
}

@media (min-width: 640px) {
    .product-detail-cart-modal-header {
        padding: 24px;
    }
}

.product-detail-cart-modal-icon {
    width: 48px;
    height: 48px;
    background-color: #d1fae5;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 12px;
}

@media (min-width: 640px) {
    .product-detail-cart-modal-icon {
        width: 64px;
        height: 64px;
        margin-bottom: 16px;
    }
}

.product-detail-cart-modal-icon svg {
    width: 24px;
    height: 24px;
    color: #10b981;
}

@media (min-width: 640px) {
    .product-detail-cart-modal-icon svg {
        width: 32px;
        height: 32px;
    }
}

.product-detail-cart-modal-title {
    font-size: 14px;
    font-weight: 700;
    color: #111827;
    margin-bottom: 8px;
}

@media (min-width: 640px) {
    .product-detail-cart-modal-title {
        font-size: 20px;
    }
}

.product-detail-cart-modal-message {
    font-size: 12px;
    color: #4b5563;
}

@media (min-width: 640px) {
    .product-detail-cart-modal-message {
        font-size: 16px;
    }
}

/* Stock Warning */
.product-detail-stock-warning {
    margin-top: 12px;
    padding: 8px 12px;
    background-color: #fef3c7;
    border: 1px solid #fde68a;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.product-detail-stock-warning.hidden {
    display: none;
}

@media (min-width: 640px) {
    .product-detail-stock-warning {
        padding: 12px;
    }
}

.product-detail-stock-warning svg {
    width: 16px;
    height: 16px;
    color: #d97706;
    flex-shrink: 0;
}

@media (min-width: 640px) {
    .product-detail-stock-warning svg {
        width: 20px;
        height: 20px;
    }
}

.product-detail-stock-warning-text {
    font-size: 11px;
    color: #92400e;
    font-weight: 500;
}

@media (min-width: 640px) {
    .product-detail-stock-warning-text {
        font-size: 14px;
    }
}

.product-detail-cart-modal-footer {
    padding: 16px 24px;
}

@media (min-width: 640px) {
    .product-detail-cart-modal-footer {
        padding: 24px;
    }
}

.product-detail-cart-modal-buttons {
    display: flex;
    gap: 8px;
}

@media (min-width: 640px) {
    .product-detail-cart-modal-buttons {
        gap: 12px;
    }
}

.product-detail-cart-modal-button {
    flex: 1;
    padding: 8px 12px;
    border-radius: 8px;
    font-weight: 600;
    font-size: 12px;
    transition: all 0.2s ease;
    border: none;
    cursor: pointer;
}

@media (min-width: 640px) {
    .product-detail-cart-modal-button {
        padding: 12px 16px;
        font-size: 16px;
    }
}

.product-detail-cart-modal-button-primary {
    background-color: #9333ea;
    color: white;
}

.product-detail-cart-modal-button-primary:hover {
    background-color: #7e22ce;
}

.product-detail-cart-modal-button-primary:focus-visible {
    outline: 2px solid #9333ea;
    outline-offset: 2px;
}

.product-detail-cart-modal-button-secondary {
    background-color: #e5e7eb;
    color: #374151;
}

.product-detail-cart-modal-button-secondary:hover {
    background-color: #d1d5db;
}

.product-detail-cart-modal-button-secondary:focus-visible {
    outline: 2px solid #6b7280;
    outline-offset: 2px;
}

.product-detail-cart-modal-countdown {
    font-size: 11px;
    color: #6b7280;
    text-align: center;
    margin-top: 12px;
}

@media (min-width: 640px) {
    .product-detail-cart-modal-countdown {
        font-size: 12px;
    }
}

/* ============================================
   PERFORMANCE OPTIMIZATIONS
   ============================================ */

/* GPU Acceleration - Sadece gerektiğinde */
.product-detail-main-image {
    transform: translateZ(0);
    backface-visibility: hidden;
}

.product-detail-cart-modal-content {
    transform: translateZ(0);
    backface-visibility: hidden;
    perspective: 1000px;
}

/* Thumbnail GPU acceleration - hover için optimize edilmiş */
@media (min-width: 1024px) and (hover: hover) {
    .product-detail-thumbnail {
        /* Compositing layer için - performans optimizasyonu */
        backface-visibility: hidden;
        isolation: isolate;
    }
}

/* Reduce repaints */
.product-detail-thumbnail img,
.product-detail-image-protected {
    contain: layout style paint;
}

/* ============================================
   QUANTITY INPUT (Readonly - Sadece Butonlarla Kontrol)
   ============================================ */

.product-detail-quantity-input {
    /* Readonly input görünümü - performanslı */
    background-color: #f9fafb;
    cursor: default;
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
}

.product-detail-quantity-input:focus {
    outline: none;
    border-color: #d1d5db;
    box-shadow: none;
}

/* ============================================
   ACCESSIBILITY
   ============================================ */

.product-detail-cart-modal-button:focus-visible,
.product-detail-thumbnail:focus-visible {
    outline: 2px solid #9333ea;
    outline-offset: 2px;
}

/* Screen reader only */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

/* ============================================
   SECURITY - XSS PROTECTION
   ============================================ */

.product-detail-main-image,
.product-detail-thumbnail,
.product-detail-cart-modal-content {
    word-wrap: break-word;
    overflow-wrap: break-word;
}

/* Prevent content injection */
.product-detail-cart-modal-content * {
    max-width: 100%;
}

/* ============================================
   RESPONSIVE UTILITIES
   ============================================ */

@media (prefers-reduced-motion: reduce) {
    .toast,
    .product-detail-cart-modal,
    .product-detail-cart-modal-content,
    .product-detail-thumbnail {
        transition: none;
        animation: none;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .product-detail-thumbnail.active {
        border-width: 4px;
    }
    
    .product-detail-cart-modal-button {
        border: 2px solid currentColor;
    }
}

/* ============================================
   LOADING STATES
   ============================================ */

.product-detail-main-image[data-bg-image]:not([style*="background-image"]) {
    background-color: #f3f4f6;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24'%3E%3Cpath fill='%239ca3af' d='M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm-2 15l-5-5 1.41-1.41L10 14.17l7.59-7.59L19 8l-9 9z'/%3E%3C/svg%3E");
    background-size: 40px;
    background-position: center;
    background-repeat: no-repeat;
}

/* ============================================
   PRINT STYLES
   ============================================ */

@media print {
    .product-detail-cart-modal,
    .toast {
        display: none !important;
    }
    
    .product-detail-main-image {
        break-inside: avoid;
    }
}

