/**
 * Frontend Styles for WooCommerce Custom Blocks
 * 
 * @package WC_Custom_Blocks
 */

/* ==========================================================================
   CSS Variables for Easy Theming
   ========================================================================== */

:root {
    --wcb-spacing: 20px;
    --wcb-border-radius: 8px;
    --wcb-border-color: #e0e0e0;
    --wcb-bg-light: #f9f9f9;
    --wcb-text-color: #333;
    --wcb-heading-color: #1a1a1a;
    --wcb-transition: all 0.3s ease;
}

/* ==========================================================================
   Block Container
   ========================================================================== */

.wc-custom-blocks-container {
    margin: var(--wcb-spacing) 0;
    clear: both;
}

.wc-custom-block {
    margin-bottom: var(--wcb-spacing);
}

.wc-custom-block:last-child {
    margin-bottom: 0;
}

/* ==========================================================================
   Rich Text Block
   ========================================================================== */

.wc-custom-block-rich-text {
    padding: var(--wcb-spacing);
    background: var(--wcb-bg-light);
    border-radius: var(--wcb-border-radius);
    border: 1px solid var(--wcb-border-color);
}

.wc-custom-block-heading {
    margin: 0 0 15px 0;
    color: var(--wcb-heading-color);
    font-weight: 600;
    line-height: 1.3;
}

.wc-custom-block-content {
    color: var(--wcb-text-color);
    line-height: 1.6;
}

.wc-custom-block-content p:first-child {
    margin-top: 0;
}

.wc-custom-block-content p:last-child {
    margin-bottom: 0;
}

.wc-custom-block-content ul,
.wc-custom-block-content ol {
    margin: 15px 0;
    padding-left: 25px;
}

.wc-custom-block-content li {
    margin-bottom: 8px;
}

.wc-custom-block-content a {
    color: #2271b1;
    text-decoration: none;
    transition: var(--wcb-transition);
}

.wc-custom-block-content a:hover {
    text-decoration: underline;
    opacity: 0.8;
}

/* ==========================================================================
   Image with Link Block
   ========================================================================== */

.wc-custom-block-image-link {
    text-align: left;
    margin: var(--wcb-spacing) 0;
}

.wc-custom-block-image-link a {
    display: inline-block;
    transition: var(--wcb-transition);
}

.wc-custom-block-image-link a:hover {
    opacity: 0.85;
    transform: scale(1.02);
}

.wc-custom-block-image {
    max-width: 100%;
    height: auto;
    border-radius: var(--wcb-border-radius);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* ==========================================================================
   Image Gallery Block
   ========================================================================== */

.wc-custom-block-gallery {
    margin: var(--wcb-spacing) 0;
}

/* Grid Layout */
.wc-custom-block-gallery-grid {
    display: grid;
    gap: 15px;
}

.wc-custom-block-gallery-cols-1 {
    grid-template-columns: 1fr;
}

.wc-custom-block-gallery-cols-2 {
    grid-template-columns: repeat(2, 1fr);
}

.wc-custom-block-gallery-cols-3 {
    grid-template-columns: repeat(3, 1fr);
}

.wc-custom-block-gallery-cols-4 {
    grid-template-columns: repeat(4, 1fr);
}

.wc-custom-block-gallery-cols-5 {
    grid-template-columns: repeat(5, 1fr);
}

.wc-custom-block-gallery-cols-6 {
    grid-template-columns: repeat(6, 1fr);
}

/* Gallery Items */
.wc-custom-block-gallery-item {
    position: relative;
    overflow: hidden;
    border-radius: var(--wcb-border-radius);
    background: var(--wcb-bg-light);
}

.wc-custom-block-gallery-item a {
    display: block;
    transition: var(--wcb-transition);
}

.wc-custom-block-gallery-item a:hover {
    transform: scale(1.05);
}

.wc-custom-block-gallery-image {
    width: 100%;
    height: auto;
    display: block;
    transition: var(--wcb-transition);
}

.wc-custom-block-gallery-item:hover .wc-custom-block-gallery-image {
    opacity: 0.9;
}

/* Slider Layout */
.wc-custom-block-gallery-slider {
    display: flex;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    gap: 15px;
    padding: 10px 0;
    -webkit-overflow-scrolling: touch;
}

.wc-custom-block-gallery-slider .wc-custom-block-gallery-item {
    flex: 0 0 auto;
    width: 280px;
    scroll-snap-align: start;
}

.wc-custom-block-gallery-slider::-webkit-scrollbar {
    height: 8px;
}

.wc-custom-block-gallery-slider::-webkit-scrollbar-track {
    background: var(--wcb-bg-light);
    border-radius: 4px;
}

.wc-custom-block-gallery-slider::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 4px;
}

.wc-custom-block-gallery-slider::-webkit-scrollbar-thumb:hover {
    background: #999;
}

/* ==========================================================================
   Badge/Tag Block
   ========================================================================== */

.wc-custom-block-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    transition: var(--wcb-transition);
    vertical-align: middle;
    line-height: 1;
}

/* Badge Sizes */
.wc-custom-block-badge-small {
    padding: 6px 12px;
    font-size: 11px;
}

.wc-custom-block-badge-medium {
    padding: 10px 18px;
    font-size: 13px;
}

.wc-custom-block-badge-large {
    padding: 14px 24px;
    font-size: 16px;
}

/* Badge Styles */
.wc-custom-block-badge-rounded {
    border-radius: 6px;
}

.wc-custom-block-badge-pill {
    border-radius: 50px;
}

.wc-custom-block-badge-square {
    border-radius: 0;
}

/* Badge Icons */
.wc-custom-block-badge-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.wc-custom-block-badge-icon svg {
    width: 16px;
    height: 16px;
    fill: currentColor;
}

.wc-custom-block-badge-small .wc-custom-block-badge-icon svg {
    width: 12px;
    height: 12px;
}

.wc-custom-block-badge-large .wc-custom-block-badge-icon svg {
    width: 20px;
    height: 20px;
}

/* Badge Hover Effect */
.wc-custom-block-badge:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

/* ==========================================================================
   Position-Specific Styling
   ========================================================================== */

/* Before Title */
.wc-custom-blocks-position-before_title {
    margin-bottom: 15px;
}

/* After Title */
.wc-custom-blocks-position-after_title {
    margin-top: 10px;
    margin-bottom: 15px;
}

/* Before/After Price */
.wc-custom-blocks-position-before_price,
.wc-custom-blocks-position-after_price {
    margin: 15px 0;
}

/* Before/After Add to Cart */
.wc-custom-blocks-position-before_add_to_cart,
.wc-custom-blocks-position-after_add_to_cart {
    margin: 20px 0;
}

/* Custom Tab */
.wc-custom-blocks-position-custom_tab .wc-custom-block {
    padding: 20px 0;
}

/* ==========================================================================
   Responsive Design
   ========================================================================== */

@media (max-width: 768px) {
    :root {
        --wcb-spacing: 15px;
        --wcb-border-radius: 6px;
    }
    
    /* Adjust grid columns on mobile */
    .wc-custom-block-gallery-cols-4,
    .wc-custom-block-gallery-cols-5,
    .wc-custom-block-gallery-cols-6 {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .wc-custom-block-gallery-cols-3 {
        grid-template-columns: repeat(2, 1fr);
    }
    
    /* Reduce badge sizes */
    .wc-custom-block-badge-large {
        padding: 12px 20px;
        font-size: 14px;
    }
    
    .wc-custom-block-badge-medium {
        padding: 8px 14px;
        font-size: 12px;
    }
    
    /* Slider adjustments */
    .wc-custom-block-gallery-slider .wc-custom-block-gallery-item {
        width: 220px;
    }
}

@media (max-width: 480px) {
    /* Single column on very small screens */
    .wc-custom-block-gallery-cols-2,
    .wc-custom-block-gallery-cols-3,
    .wc-custom-block-gallery-cols-4,
    .wc-custom-block-gallery-cols-5,
    .wc-custom-block-gallery-cols-6 {
        grid-template-columns: 1fr;
    }
    
    /* Smaller slider items */
    .wc-custom-block-gallery-slider .wc-custom-block-gallery-item {
        width: 180px;
    }
}

/* ==========================================================================
   Accessibility
   ========================================================================== */

.wc-custom-block-image img,
.wc-custom-block-gallery-image {
    image-rendering: -webkit-optimize-contrast;
    image-rendering: crisp-edges;
}

/* Focus states */
.wc-custom-block-image-link a:focus,
.wc-custom-block-gallery-item a:focus {
    outline: 2px solid #2271b1;
    outline-offset: 2px;
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    
    .wc-custom-block-badge:hover {
        transform: none;
    }
    
    .wc-custom-block-image-link a:hover,
    .wc-custom-block-gallery-item a:hover {
        transform: none;
    }
}

/* ==========================================================================
   Print Styles
   ========================================================================== */

@media print {
    .wc-custom-block-badge {
        border: 1px solid #000;
        color: #000 !important;
        background: #fff !important;
    }
    
    .wc-custom-block-rich-text {
        border: 1px solid #000;
        background: #fff;
    }
}

/* ==========================================================================
   Animation Classes (Optional)
   ========================================================================== */

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.wc-custom-block-animate {
    animation: fadeInUp 0.6s ease-out;
}

/* ==========================================================================
   Dark Mode Support (Optional)
   ========================================================================== */

@media (prefers-color-scheme: dark) {
    :root {
        --wcb-border-color: #444;
        --wcb-bg-light: #2a2a2a;
        --wcb-text-color: #e0e0e0;
        --wcb-heading-color: #fff;
    }
    
    .wc-custom-block-image,
    .wc-custom-block-gallery-image {
        opacity: 0.9;
    }
    
    .wc-custom-block-content a {
        color: #6ea8fe;
    }
}