/*
 * Public-facing CSS for WP Digital Marketplace plugin.
 * Modern, Responsive, and Conflict-Resistant Design.
 *
 * @package WP_Digital_Marketplace
 */

/* --- Base & General Styles --- */
/* Global box-sizing for all plugin elements to prevent layout issues */
.wpdm-product-card,
.wpdm-grid-wrapper,
.wpdm-slider-wrapper,
.wpdm-single-product-page-wrapper,
.wpdm-single-product-shortcode-wrapper,
.wpdm-archive-page-wrapper,
.wpdm-product-card *,
.wpdm-grid-wrapper *,
.wpdm-slider-wrapper *,
.wpdm-single-product-page-wrapper *,
.wpdm-single-product-shortcode-wrapper *,
.wpdm-archive-page-wrapper * {
    box-sizing: border-box;
}

.wpdm-section-title {
    text-align: center;
    margin: 60px 0 40px; /* More vertical spacing */
    font-size: 2.6em; /* Slightly larger */
    color: #333;
    position: relative;
    padding-bottom: 20px;
    font-weight: 700;
}

.wpdm-section-title::after {
    content: '';
    position: absolute;
    left: 50%;
    bottom: 0;
    transform: translateX(-50%);
    width: 90px; /* Slightly wider */
    height: 5px; /* Thicker accent line */
    background-color: #007bff; /* Modern blue accent */
    border-radius: 3px;
}

.wpdm-no-products-message {
    text-align: center;
    padding: 30px;
    background-color: #f8f9fa;
    border: 1px dashed #e0e0e0;
    border-radius: 12px; /* More rounded corners */
    color: #666;
    font-size: 1.1em;
    margin: 40px auto; /* More vertical spacing */
    max-width: 800px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05); /* Subtle shadow */
}

/* --- Product Card Styles (Used in Grid, Slider) --- */
.wpdm-product-card {
    display: flex;
    flex-direction: column;
    background-color: #fff;
    border-radius: 18px; /* More rounded */
    overflow: hidden;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.08); /* Enhanced shadow */
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    height: 100%; /* Important for grid alignment */
    text-align: center; /* Center content */
}

.wpdm-product-card:hover {
    transform: translateY(-10px); /* More pronounced lift */
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.15);
}

.wpdm-card-link {
    text-decoration: none;
    color: inherit;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 25px 20px 15px; /* Increased padding */
    flex-grow: 1;
}

.wpdm-card-thumbnail {
    width: 100%;
    height: 180px;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 20px; /* More margin */
    border-radius: 12px; /* Rounded image container */
    background-color: #f1f3f5; /* Light grey background for image */
    flex-shrink: 0; /* Prevent image container from shrinking */
}

.wpdm-card-thumbnail img {
    max-width: 90%; /* Smaller max-width for internal image */
    max-height: 90%; /* Smaller max-height for internal image */
    width: auto;
    height: auto;
    object-fit: contain;
    transition: transform 0.4s ease; /* Slower transition */
}

.wpdm-product-card:hover .wpdm-card-thumbnail img {
    transform: scale(1.08); /* More pronounced zoom */
}

.wpdm-card-content {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    width: 100%;
    align-items: center; /* Center content */
}

.wpdm-card-title {
    font-size: 1.4em; /* Slightly larger title */
    font-weight: 700;
    color: #333;
    margin: 0 0 12px; /* Adjusted margin */
    line-height: 1.4;
    min-height: 2.8em;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-align: center; /* Ensure title is centered */
}

.wpdm-card-link:hover .wpdm-card-title {
    color: #007bff; /* Modern blue accent on hover */
}

.wpdm-card-price-group {
    display: flex;
    align-items: baseline; /* Align prices nicely */
    justify-content: center; /* Center prices */
    flex-wrap: wrap;
    padding: 0 5px 15px; /* Increased bottom padding */
    font-size: 1.3em; /* Slightly larger price font */
    font-weight: 800;
    color: #28a745; /* Green for price */
    margin-top: auto;
}

.wpdm-card-original-price {
    text-decoration: line-through;
    color: #999;
    font-size: 0.75em; /* Slightly larger original price */
    margin-right: 10px;
    font-weight: 500;
}

.wpdm-card-discount-price {
    color: #dc3545; /* Red for discount */
    margin-right: 5px;
}

.wpdm-card-price {
    color: #28a745; /* Green for regular price */
}

.wpdm-card-price.wpdm-price-contact {
    font-size: 1em; /* Larger for contact */
    color: #555;
    font-weight: 600;
}

.wpdm-card-buy-btn {
    display: block;
    width: calc(100% - 40px);
    margin: 0 20px 20px;
    padding: 12px 18px; /* Slightly more padding for button */
    background-color: #0088cc; /* Telegram blue */
    color: #fff;
    text-align: center;
    text-decoration: none;
    border-radius: 12px; /* More rounded */
    font-weight: bold;
    font-size: 1em; /* Standard font size for button */
    transition: background-color 0.3s ease, transform 0.2s ease, box-shadow 0.2s ease;
    margin-top: auto;
    box-shadow: 0 4px 12px rgba(0, 136, 204, 0.3); /* Subtle shadow for button */
}

.wpdm-card-buy-btn:hover {
    background-color: #007bb6;
    color: #fff;
    transform: translateY(-3px); /* More pronounced lift */
    box-shadow: 0 6px 18px rgba(0, 136, 204, 0.4);
}

.wpdm-no-telegram-id {
    color: #dc3545;
    font-size: 0.9em;
    text-align: center;
    padding: 0 20px 20px;
}

/* --- Grid Layouts (for Category and Archive Pages) --- */
.wpdm-grid-wrapper {
    margin: 60px auto;
}

.wpdm-grid-container {
    display: grid;
    gap: 35px; /* Increased gap */
    padding: 0;
}

.wpdm-grid-cols-2 {
    grid-template-columns: repeat(auto-fit, minmax(380px, 1fr)); /* Adjusted min-width */
}
.wpdm-grid-cols-3 {
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); /* Adjusted min-width */
}
.wpdm-grid-cols-4 {
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); /* Adjusted min-width */
}

@media (max-width: 992px) {
    .wpdm-grid-cols-4 {
        grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    }
}

@media (max-width: 768px) {
    .wpdm-grid-cols-2,
    .wpdm-grid-cols-3,
    .wpdm-grid-cols-4 {
        grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); /* 2 columns on tablets */
    }
    .wpdm-section-title {
        font-size: 2.2em;
    }
}

@media (max-width: 576px) {
    .wpdm-grid-cols-2,
    .wpdm-grid-cols-3,
    .wpdm-grid-cols-4 {
        grid-template-columns: 1fr; /* Single column on mobile */
    }
    .wpdm-product-card {
        margin-left: auto;
        margin-right: auto;
        max-width: 350px; /* Constrain single card on mobile */
    }
}

/* --- Product Slider Styles --- */
.wpdm-slider-wrapper {
    margin: 60px auto;
}

.wpdm-slider-container {
    position: relative;
    padding: 30px; /* Increased padding */
    background-color: #fdfdfd;
    border-radius: 20px; /* More rounded */
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.08); /* Refined shadow */
    overflow: hidden;
}

.wpdm-slider-track {
    display: flex;
    overflow-x: scroll;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 25px; /* More space for scrollbar */
    margin-bottom: -25px;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.wpdm-slider-track::-webkit-scrollbar {
    display: none;
}

.wpdm-slider-track .wpdm-product-card {
    flex: 0 0 auto;
    width: 340px; /* Slightly wider fixed width for slider cards */
    margin-left: 30px; /* Increased spacing between cards */
}
.wpdm-slider-track .wpdm-product-card:first-child {
    margin-left: 0;
}

.wpdm-slider-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background-color: rgba(0, 0, 0, 0.4); /* More subtle background */
    color: #fff;
    border: none;
    padding: 12px; /* Smaller clickable area, more discreet */
    cursor: pointer;
    border-radius: 50%;
    font-size: 1.5em; /* Smaller icons */
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.8;
    transition: background-color 0.3s ease, opacity 0.3s ease, transform 0.2s ease;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1); /* Lighter shadow */
}

.wpdm-slider-btn:hover {
    background-color: rgba(0, 0, 0, 0.6);
    opacity: 1;
    transform: translateY(-50%) scale(1.1); /* Subtle hover effect */
}

.wpdm-slider-prev {
    left: 20px; /* Adjusted position */
}

.wpdm-slider-next {
    right: 20px; /* Adjusted position */
}

.wpdm-slider-btn .dashicons {
    font-size: 1em;
    line-height: 1;
    vertical-align: middle;
}

/* Adjust dashicon direction for RTL */
.rtl .wpdm-slider-prev .dashicons-arrow-right-alt2 {
    transform: rotate(180deg);
}
.rtl .wpdm-slider-next .dashicons-arrow-left-alt2 {
    transform: rotate(180deg);
}


/* --- Single Product Page Styles --- */
.wpdm-single-product-page-wrapper,
.wpdm-single-product-shortcode-wrapper {
    padding: 60px 15px; /* More vertical padding */
    display: flex; /* Use flex to center the container */
    justify-content: center;
}

.wpdm-single-product-container { /* New wrapper for the single product layout */
    max-width: 1100px; /* Max width for the entire product block */
    width: 100%;
    margin: 0 auto;
    background-color: #fff;
    border-radius: 25px; /* More rounded */
    box-shadow: 0 15px 50px rgba(0, 0, 0, 0.1); /* Deeper shadow */
    overflow: hidden;
    padding: 50px; /* Generous padding */
}

.wpdm-single-product-layout {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    gap: 50px; /* Increased gap between columns */
    padding: 0;
}

.wpdm-single-image-col {
    flex: 1 1 45%; /* Adjusted flex basis */
    max-width: 45%;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 350px; /* Ensure minimum height */
}

.wpdm-product-image-wrap {
    margin: 0;
    padding: 0;
    width: 100%;
    max-width: 550px; /* Limit image size for better presentation */
    background-color: #f1f3f5;
    border-radius: 18px; /* Rounded image container */
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.1); /* Subtle shadow */
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 350px; /* Ensure a minimum height for placeholder */
}

.wpdm-single-product-image {
    max-width: 90%; /* Internal image slightly smaller than container */
    height: auto;
    display: block;
    transition: transform 0.4s ease;
}

.wpdm-product-image-wrap:hover .wpdm-single-product-image {
    transform: scale(1.05);
}

.wpdm-single-details-col {
    flex: 1 1 50%; /* Adjusted flex basis */
    max-width: 50%;
    padding: 0;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
}

.wpdm-single-product-title {
    font-size: 3.2em; /* Larger title */
    font-weight: 800;
    color: #222;
    margin-top: 0;
    margin-bottom: 25px; /* More margin */
    line-height: 1.2;
}

.wpdm-single-product-price-group {
    display: flex;
    align-items: baseline;
    flex-wrap: wrap;
    margin-bottom: 30px; /* More margin */
    font-size: 2.2em; /* Larger price font */
    font-weight: 800;
}

.wpdm-single-original-price {
    text-decoration: line-through;
    color: #999;
    font-size: 0.65em; /* Slightly larger original price */
    margin-right: 20px; /* More margin */
    font-weight: 500;
}

.wpdm-single-discount-price {
    color: #dc3545; /* Prominent red for discount */
    margin-right: 10px;
}

.wpdm-single-price {
    color: #28a745; /* Prominent green for regular price */
}

.wpdm-single-price.wpdm-price-contact {
    font-size: 1em; /* Larger for contact */
    color: #555;
    font-weight: 600;
}

.wpdm-single-buy-btn {
    display: inline-block;
    background-color: #0088cc; /* Telegram blue */
    color: #fff;
    padding: 18px 45px; /* Larger padding for a more prominent button */
    border-radius: 15px; /* More rounded */
    text-decoration: none;
    font-size: 1.4em; /* Larger font size */
    font-weight: bold;
    transition: background-color 0.3s ease, transform 0.2s ease, box-shadow 0.2s ease;
    text-align: center;
    margin-bottom: 35px; /* More margin */
    max-width: 380px; /* Increased max width */
    box-shadow: 0 6px 20px rgba(0, 136, 204, 0.45); /* Stronger shadow for pop effect */
}

.wpdm-single-buy-btn:hover {
    background-color: #007bb6;
    color: #fff;
    transform: translateY(-5px); /* More pronounced lift */
    box-shadow: 0 8px 25px rgba(0, 136, 204, 0.6);
}

.wpdm-single-product-description-wrap {
    margin-top: 20px;
    position: relative;
    padding-bottom: 40px; /* Space for the button */
}

.wpdm-single-product-description-content {
    font-size: 1.15em; /* Slightly larger font size */
    line-height: 1.9; /* Improved line height for readability */
    color: #444;
    transition: max-height 0.3s ease-out; /* Smooth transition for expand/collapse */
}

.wpdm-single-product-description-wrap.is-collapsed .wpdm-single-product-description-content {
    overflow: hidden;
    /* max-height is set by JS */
}

.wpdm-read-more-btn {
    position: absolute;
    bottom: 0;
    left: 0; /* Align left for RTL */
    background: none;
    border: none;
    color: #007bff; /* Accent color for link */
    cursor: pointer;
    font-size: 1em;
    font-weight: 600;
    padding: 5px 0;
    transition: color 0.2s ease;
}

.wpdm-read-more-btn:hover {
    color: #0056b3;
}

/* RTL adjustments for button position */
.rtl .wpdm-read-more-btn {
    left: auto;
    right: 0;
}


@media (max-width: 992px) {
    .wpdm-single-product-container {
        padding: 40px;
        border-radius: 20px;
    }
    .wpdm-single-product-layout {
        flex-direction: column;
        gap: 30px;
    }
    .wpdm-single-image-col,
    .wpdm-single-details-col {
        flex: 1 1 100%;
        max-width: 100%;
        padding: 0;
        min-height: auto; /* Allow image to adjust height */
    }
    .wpdm-single-product-title {
        font-size: 2.5em;
        text-align: center;
    }
    .wpdm-single-product-price-group {
        justify-content: center;
        font-size: 1.8em;
    }
    .wpdm-single-buy-btn {
        margin-left: auto;
        margin-right: auto;
        font-size: 1.2em;
        padding: 15px 30px;
        max-width: 320px;
    }
    .wpdm-single-product-description-content {
        font-size: 1.05em;
        line-height: 1.8;
    }
}

@media (max-width: 576px) {
    .wpdm-single-product-page-wrapper,
    .wpdm-single-product-shortcode-wrapper {
        padding: 30px 10px;
    }
    .wpdm-single-product-container {
        padding: 25px;
        border-radius: 15px;
        box-shadow: 0 8px 30px rgba(0, 0, 0, 0.08);
    }
    .wpdm-single-product-layout {
        gap: 20px;
    }
    .wpdm-product-image-wrap {
        min-height: 250px;
        border-radius: 12px;
    }
    .wpdm-single-product-title {
        font-size: 2em;
        margin-bottom: 15px;
    }
    .wpdm-single-product-price-group {
        font-size: 1.5em;
        margin-bottom: 20px;
    }
    .wpdm-single-buy-btn {
        font-size: 1em;
        padding: 12px 25px;
        max-width: 280px;
        margin-bottom: 25px;
    }
    .wpdm-single-product-description-content {
        font-size: 0.95em;
        line-height: 1.7;
    }
    .wpdm-read-more-btn {
        font-size: 0.9em;
    }
}


/* --- Archive Page Specific Styles --- */
.wpdm-archive-page-wrapper {
    padding: 60px 15px;
}

.wpdm-archive-header {
    text-align: center;
    margin-bottom: 60px;
    padding: 40px;
    background-color: #fff;
    border-radius: 20px;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.08);
}

.wpdm-archive-title {
    font-size: 3.5em; /* Larger title */
    color: #333;
    margin-top: 0;
    margin-bottom: 25px;
    font-weight: 800;
}

.wpdm-taxonomy-description {
    max-width: 800px;
    margin: 0 auto;
    font-size: 1.2em; /* Slightly larger */
    color: #555;
    line-height: 1.9;
}

/* --- Pagination Styles --- */
.wpdm-archive-page-wrapper .pagination {
    margin-top: 60px; /* More margin */
    text-align: center;
    padding: 0 15px;
}
.wpdm-archive-page-wrapper .page-numbers {
    display: inline-block;
    padding: 14px 20px; /* Larger padding */
    margin: 0 10px; /* More margin */
    border: 1px solid #e0e0e0; /* Lighter border */
    border-radius: 12px; /* More rounded */
    text-decoration: none;
    color: #007bff; /* Accent color */
    font-weight: 600;
    transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease, transform 0.2s ease;
}
.wpdm-archive-page-wrapper .page-numbers.current {
    background-color: #007bff;
    color: #fff;
    border-color: #007bff;
}
.wpdm-archive-page-wrapper .page-numbers:hover:not(.current) {
    background-color: #e9f5ff; /* Lighter hover background */
    border-color: #a3d9ff; /* Lighter hover border */
    color: #0056b3;
    transform: translateY(-3px);
}

.wpdm-archive-page-wrapper .page-numbers.dots {
    border: none;
    background: none;
    cursor: default;
    color: #999;
}
.wpdm-archive-page-wrapper .page-numbers.dots:hover {
    background: none;
    color: #999;
    transform: none;
}