/**
 * WP Checkout Frontend Styles - Consolidated
 * All frontend styles including checkout, shortcodes, product display, cart functionality
 * 
 * @package WP_Checkout
 * @since 1.0.0
 */

/* ========================================
   PRODUCT PAGE STYLES
   ======================================== */

/* Related Products Section */
.wp-checkout-related-products {
    margin-top: 60px;
    padding: 40px 0;
    border-top: 1px solid #e9ecef;
}

.wp-checkout-related-products h2 {
    font-size: 1.8rem;
    font-weight: 600;
    color: #2c3e50;
    text-align: center;
    margin-bottom: 40px;
}

.related-products-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 30px;
    max-width: 1200px;
    margin: 0 auto;
}

/* Override products.css styles for Related Products */
.related-products-grid .wp-checkout-product-item {
    background: #fff;
    border: 1px solid #e9ecef;
    border-radius: 12px;
    padding: 0;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
    overflow: hidden;
}

.related-products-grid .wp-checkout-product-item:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 25px rgba(0,0,0,0.1);
    border-color: #2c5aa0;
}

.related-products-grid .product-image {
    width: 100%;
    height: 200px;
    overflow: hidden;
    background: #f8f9fa;
    position: relative;
}

.related-products-grid .product-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.related-products-grid .wp-checkout-product-item:hover .product-image img {
    transform: scale(1.05);
}

.related-products-grid .product-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f8f9fa;
    color: #666;
}

.related-products-grid .placeholder-icon {
    font-size: 48px;
    opacity: 0.5;
}

.related-products-grid .product-content {
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.related-products-grid .product-title {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 600;
    color: #2c3e50;
    line-height: 1.4;
}

.related-products-grid .product-title a {
    color: #2c3e50;
    text-decoration: none;
    transition: color 0.3s ease;
}

.related-products-grid .product-title a:hover {
    color: #2c5aa0;
}

.related-products-grid .product-description {
    margin: 0;
    font-size: 14px;
    color: #666;
    line-height: 1.5;
    flex: 1;
}

.related-products-grid .product-price {
    margin: 10px 0;
}

.related-products-grid .price-amount {
    font-size: 1.2rem;
    font-weight: 700;
    color: #2c5aa0;
}

.related-products-grid .product-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: auto;
}

.related-products-grid .wp-checkout-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 16px;
    font-size: 14px;
    font-weight: 500;
    text-decoration: none;
    border-radius: 6px;
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: center;
    min-height: 40px;
}

.related-products-grid .wp-checkout-btn-primary {
    background: #2c5aa0;
    color: white;
}

.related-products-grid .wp-checkout-btn-primary:hover {
    background: #1e3d6f;
    transform: translateY(-1px);
}

.related-products-grid .wp-checkout-btn-secondary {
    background: transparent;
    color: #2c5aa0;
    border: 1px solid #2c5aa0;
}

.related-products-grid .wp-checkout-btn-secondary:hover {
    background: #2c5aa0;
    color: white;
}

/* Product badges for related products */
.related-products-grid .product-badge {
    position: absolute;
    top: 10px;
    right: 10px;
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.related-products-grid .free-badge {
    background: #28a745;
    color: #fff;
}

.related-products-grid .subscription-badge {
    background: #007cba;
    color: #fff;
}

/* Single Product Container */
.wp-checkout-single-product {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
    background: #fff;
}

/* Breadcrumb Navigation */
.wp-checkout-breadcrumb {
    margin-bottom: 30px;
    padding: 10px 0;
    font-size: 0.9rem;
    color: #666;
}

.wp-checkout-breadcrumb a {
    color: #2c5aa0;
    text-decoration: none;
}

.wp-checkout-breadcrumb a:hover {
    text-decoration: underline;
}

.wp-checkout-breadcrumb .separator {
    margin: 0 8px;
    color: #ccc;
}

.wp-checkout-breadcrumb .current {
    color: #333;
    font-weight: 500;
}

.wp-checkout-container {
    display: flex;
    flex-wrap: wrap;
    gap: 30px;
    align-items: flex-start;
}

.wp-checkout-product-wrapper {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 40px;
    width: 100%;
}

/* Product Gallery */
.wp-checkout-product-gallery {
    position: relative;
}

.product-main-image {
    position: relative;
    overflow: hidden;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.wp-checkout-product-gallery img {
    width: 100%;
    height: auto;
    border-radius: 8px;
    transition: transform 0.3s ease;
}

.product-main-image:hover img {
    transform: scale(1.05);
}

.image-zoom-overlay {
    position: absolute;
    top: 15px;
    right: 15px;
    background: rgba(0,0,0,0.7);
    color: white;
    padding: 8px 12px;
    border-radius: 20px;
    font-size: 0.9rem;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.product-main-image:hover .image-zoom-overlay {
    opacity: 1;
}

.product-gallery-thumbnails {
    display: flex;
    gap: 10px;
    margin-top: 15px;
}

.gallery-thumbnail {
    width: 80px;
    height: 80px;
    object-fit: cover;
    border-radius: 6px;
    cursor: pointer;
    opacity: 0.7;
    transition: opacity 0.3s ease;
}

.gallery-thumbnail:hover,
.gallery-thumbnail.active {
    opacity: 1;
}

/* Product Info */
.wp-checkout-product-info {
    padding: 20px 0;
}

.wp-checkout-product-title {
    font-size: 2.5rem;
    font-weight: 700;
    color: #333;
    margin-bottom: 15px;
    line-height: 1.2;
}

.wp-checkout-product-price {
    font-size: 2rem;
    font-weight: 600;
    color: #2c5aa0;
    margin-bottom: 20px;
}

.wp-checkout-product-description {
    font-size: 1.1rem;
    line-height: 1.6;
    color: #666;
    margin-bottom: 25px;
}

/* Product Actions */
.wp-checkout-product-actions {
    display: flex;
    gap: 15px;
    margin-top: 30px;
}

.wp-checkout-btn {
    padding: 15px 30px;
    border: none;
    border-radius: 6px;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 150px;
}

.wp-checkout-btn-primary {
    background: #2c5aa0;
    color: white;
}

.wp-checkout-btn-primary:hover {
    background: #1e3f73;
    transform: translateY(-2px);
}

.wp-checkout-btn-secondary {
    background: #28a745;
    color: white;
}

.wp-checkout-btn-secondary:hover {
    background: #1e7e34;
    transform: translateY(-2px);
}

/* Stock Status */
.wp-checkout-stock-status {
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 0.9rem;
    font-weight: 600;
    margin-bottom: 20px;
    display: inline-block;
}

.wp-checkout-stock-status.in-stock {
    background: #d4edda;
    color: #155724;
}

.wp-checkout-stock-status.out-of-stock {
    background: #f8d7da;
    color: #721c24;
}

/* Product Meta */
.wp-checkout-product-meta {
    margin-top: 25px;
    padding-top: 20px;
    border-top: 1px solid #eee;
}

.wp-checkout-product-meta > div {
    margin-bottom: 10px;
    font-size: 0.95rem;
}

.wp-checkout-product-meta .meta-label {
    font-weight: 600;
    color: #333;
    margin-right: 8px;
}

.wp-checkout-product-meta .meta-value {
    color: #666;
}

.wp-checkout-product-meta .meta-value a {
    color: #2c5aa0;
    text-decoration: none;
}

.wp-checkout-product-meta .meta-value a:hover {
    text-decoration: underline;
}

/* Responsive Design */
@media (max-width: 768px) {
    .wp-checkout-product-wrapper {
        grid-template-columns: 1fr;
        gap: 20px;
    }
    
    .wp-checkout-product-title {
        font-size: 2rem;
    }
    
    .wp-checkout-product-price {
        font-size: 1.5rem;
    }
    
    .wp-checkout-product-actions {
        flex-direction: column;
    }
    
    .wp-checkout-btn {
        width: 100%;
    }
}

/* ========================================
   CHECKOUT STYLES
   ======================================== */

/* Main Checkout Container */
#wp-checkout-embedded-checkout {
    max-width: 600px;
    margin: 0 auto;
    padding: 20px;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

#wp-checkout-embedded-checkout h3 {
    margin: 0 0 20px 0;
    color: #333;
    font-size: 24px;
    text-align: center;
}

/* Payment Methods Selection */
.wp-checkout-payment-methods {
    margin-bottom: 30px;
    padding: 20px;
    background: #f9f9f9;
    border-radius: 6px;
}

.wp-checkout-payment-methods h4 {
    margin: 0 0 15px 0;
    color: #333;
    font-size: 18px;
}

.wp-checkout-payment-method {
    display: flex;
    align-items: center;
    margin-bottom: 10px;
    padding: 10px;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.wp-checkout-payment-method:hover {
    border-color: #007cba;
    background: #f0f8ff;
}

.wp-checkout-payment-method input[type="radio"] {
    margin-right: 10px;
}

.wp-checkout-payment-method-label {
    font-weight: 500;
    color: #333;
}

/* Form Layout */
.wp-checkout-form-row {
    margin-bottom: 20px;
}

.wp-checkout-form-group {
    margin-bottom: 15px;
}

.wp-checkout-form-group-half {
    display: inline-block;
    width: 48%;
    margin-right: 2%;
}

.wp-checkout-form-group-half:last-child {
    margin-right: 0;
}

/* Form Fields */
.wp-checkout-form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: 500;
    color: #333;
}

.wp-checkout-form-group input[type="text"],
.wp-checkout-form-group input[type="email"],
.wp-checkout-form-group input[type="tel"] {
    width: 100%;
    padding: 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 16px;
    transition: border-color 0.2s ease;
}

.wp-checkout-form-group input:focus {
    outline: none;
    border-color: #007cba;
    box-shadow: 0 0 0 2px rgba(0, 122, 186, 0.2);
}

/* Submit Button */
.wp-checkout-pay-button {
    width: 100%;
    padding: 15px 20px;
    background: #007cba;
    color: #fff;
    border: none;
    border-radius: 6px;
    font-size: 18px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.wp-checkout-pay-button:hover:not(:disabled) {
    background: #005a87;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 124, 186, 0.3);
}

.wp-checkout-pay-button:disabled {
    background: #ccc;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* Notices */
.wp-checkout-errors,
.wp-checkout-success {
    margin-bottom: 20px;
    padding: 15px;
    border-radius: 4px;
}

.wp-checkout-errors {
    background: #f8d7da;
    border: 1px solid #f5c6cb;
    color: #721c24;
}

.wp-checkout-success {
    background: #d4edda;
    border: 1px solid #c3e6cb;
    color: #155724;
}

/* ========================================
   FRONTEND PRODUCT STYLES
   ======================================== */

.wp-checkout-product-single {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.wp-checkout-product-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 40px;
    align-items: start;
}

/* Product Media Gallery */
.wp-checkout-product-media {
    position: sticky;
    top: 20px;
}

.product-gallery .main-image {
    margin-bottom: 15px;
    border-radius: 8px;
    overflow: hidden;
    background: #f8f9fa;
    text-align: center;
}

.product-main-image {
    width: 100%;
    height: auto;
    max-height: 500px;
    object-fit: cover;
}

.gallery-thumbnails {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.gallery-thumb {
    cursor: pointer;
    border: 2px solid transparent;
    border-radius: 4px;
    overflow: hidden;
    transition: border-color 0.3s ease;
}

.gallery-thumb:hover,
.gallery-thumb.active {
    border-color: #0073aa;
}

.product-placeholder {
    background: #f8f9fa;
    border: 2px dashed #ddd;
    border-radius: 8px;
    padding: 60px 20px;
    text-align: center;
    color: #666;
}

.placeholder-icon {
    font-size: 48px;
    margin-bottom: 15px;
}

/* Product Details */
.wp-checkout-product-details {
    padding: 0 20px;
}

.product-title {
    font-size: 2.5em;
    font-weight: 700;
    margin: 0 0 20px 0;
    color: #333;
    line-height: 1.2;
}

/* Product Pricing */
.product-pricing {
    margin-bottom: 30px;
}

.price {
    font-size: 2em;
    font-weight: 700;
    color: #0073aa;
}

.free-price {
    color: #28a745;
}

.pay-what-you-want {
    display: block;
    font-size: 0.9em;
    color: #666;
    margin-top: 5px;
}

.subscription-plans {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.subscription-plan {
    padding: 15px;
    border: 1px solid #ddd;
    border-radius: 8px;
    background: #f8f9fa;
}

.plan-name {
    font-weight: 600;
    display: block;
    margin-bottom: 5px;
}

.plan-price {
    font-size: 1.2em;
    font-weight: 700;
    color: #0073aa;
    display: block;
}

.trial-info {
    font-size: 0.9em;
    color: #28a745;
    display: block;
    margin-top: 5px;
}

/* Product Description */
.product-description {
    margin-bottom: 30px;
    line-height: 1.6;
    color: #555;
}

.product-description h1,
.product-description h2,
.product-description h3,
.product-description h4,
.product-description h5,
.product-description h6 {
    margin-top: 25px;
    margin-bottom: 15px;
    color: #333;
}

.product-description p {
    margin-bottom: 15px;
}

.product-description ul,
.product-description ol {
    margin-bottom: 15px;
    padding-left: 25px;
}

/* Purchase Section */
.product-purchase {
    margin-bottom: 30px;
}

.wp-checkout-btn {
    display: inline-block;
    padding: 15px 30px;
    font-size: 16px;
    font-weight: 600;
    text-align: center;
    text-decoration: none;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.3s ease;
    min-width: 200px;
}

.wp-checkout-btn-primary {
    background: #0073aa;
    color: white;
}

.wp-checkout-btn-primary:hover {
    background: #005a87;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 115, 170, 0.3);
}

/* ========================================
   SHORTCODE STYLES
   ======================================== */

/* Product Display */
.wp-checkout-product {
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 20px;
    margin: 20px 0;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.wp-checkout-product-image {
    width: 100%;
    max-width: 300px;
    height: auto;
    border-radius: 4px;
    margin-bottom: 15px;
}

.wp-checkout-product-title {
    font-size: 24px;
    font-weight: 600;
    margin: 0 0 10px 0;
    color: #333;
}

.wp-checkout-product-description {
    color: #666;
    line-height: 1.6;
    margin-bottom: 15px;
}

.wp-checkout-product-price {
    font-size: 28px;
    font-weight: 700;
    color: #2271b1;
    margin-bottom: 20px;
}

.wp-checkout-add-to-cart {
    background: #2271b1;
    color: #fff;
    border: none;
    padding: 12px 24px;
    border-radius: 4px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.3s ease;
}

.wp-checkout-add-to-cart:hover {
    background: #135e96;
}

.wp-checkout-add-to-cart:disabled {
    background: #ccc;
    cursor: not-allowed;
}

/* Products Grid */
.wp-checkout-products-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
    margin: 20px 0;
}

.wp-checkout-products-grid .wp-checkout-product {
    margin: 0;
    text-align: center;
}

.wp-checkout-products-grid .wp-checkout-product-image {
    max-width: 200px;
}

.wp-checkout-products-grid .wp-checkout-product-title {
    font-size: 18px;
}

.wp-checkout-products-grid .wp-checkout-product-price {
    font-size: 20px;
}

/* Cart Styles */
.wp-checkout-cart {
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 20px;
    margin: 20px 0;
}

.wp-checkout-cart-item {
    display: flex;
    align-items: center;
    padding: 15px 0;
    border-bottom: 1px solid #eee;
}

.wp-checkout-cart-item:last-child {
    border-bottom: none;
}

.wp-checkout-cart-item-image {
    width: 60px;
    height: 60px;
    object-fit: cover;
    border-radius: 4px;
    margin-right: 15px;
}

.wp-checkout-cart-item-details {
    flex: 1;
}

.wp-checkout-cart-item-name {
    font-weight: 600;
    margin: 0 0 5px 0;
}

.wp-checkout-cart-item-price {
    color: #666;
    font-size: 14px;
}

.wp-checkout-cart-item-quantity {
    display: flex;
    align-items: center;
    margin: 0 15px;
}

.wp-checkout-quantity-input {
    width: 60px;
    text-align: center;
    padding: 5px;
    border: 1px solid #ddd;
    border-radius: 4px;
}

.wp-checkout-cart-item-remove {
    background: #d63638;
    color: #fff;
    border: none;
    padding: 5px 10px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
}

.wp-checkout-cart-item-remove:hover {
    background: #b32d2e;
}

.wp-checkout-cart-total {
    text-align: right;
    margin-top: 20px;
    padding-top: 20px;
    border-top: 2px solid #2271b1;
}

.wp-checkout-cart-total-label {
    font-size: 18px;
    font-weight: 600;
}

.wp-checkout-cart-total-amount {
    font-size: 24px;
    font-weight: 700;
    color: #2271b1;
}

/* Loading States */
.wp-checkout-loading {
    position: relative;
    opacity: 0.6;
    pointer-events: none;
}

.wp-checkout-loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid #f3f3f3;
    border-top: 2px solid #2271b1;
    border-radius: 50%;
    animation: wp-checkout-spin 1s linear infinite;
}

@keyframes wp-checkout-spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Messages */
.wp-checkout-message {
    padding: 15px;
    border-radius: 4px;
    margin: 15px 0;
    font-weight: 600;
}

.wp-checkout-message.success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.wp-checkout-message.error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.wp-checkout-message.warning {
    background: #fff3cd;
    color: #856404;
    border: 1px solid #ffeaa7;
}

/* ========================================
   RESPONSIVE DESIGN
   ======================================== */

@media (max-width: 768px) {
    #wp-checkout-embedded-checkout {
        margin: 10px;
        padding: 15px;
    }
    
    .wp-checkout-form-group-half {
        display: block;
        width: 100%;
        margin-right: 0;
        margin-bottom: 15px;
    }
    
    .wp-checkout-payment-method {
        padding: 8px;
    }
    
    .wp-checkout-pay-button {
        padding: 12px 15px;
        font-size: 16px;
    }
    
    .wp-checkout-product-container {
        grid-template-columns: 1fr;
        gap: 20px;
    }
    
    .wp-checkout-product-details {
        padding: 0;
    }
    
    .product-title {
        font-size: 2em;
    }
    
    .price {
        font-size: 1.5em;
    }
    
    .wp-checkout-btn {
        width: 100%;
        padding: 12px 20px;
    }
    
    .wp-checkout-products-grid {
        grid-template-columns: 1fr;
    }
    
    .wp-checkout-form-row {
        flex-direction: column;
    }
    
    .wp-checkout-cart-item {
        flex-direction: column;
        align-items: flex-start;
        text-align: left;
    }
    
    .wp-checkout-cart-item-image {
        margin-bottom: 10px;
    }
    
    .wp-checkout-cart-item-quantity {
        margin: 10px 0;
    }
}

@media (max-width: 480px) {
    .wp-checkout-product-single {
        padding: 15px;
    }
    
    .product-title {
        font-size: 1.8em;
    }
    
    .gallery-thumbnails {
        justify-content: center;
    }
}

/* Focus states for accessibility */
.wp-checkout-btn:focus,
.custom-price-input:focus,
.subscription-option input[type="radio"]:focus + .plan-label {
    outline: 2px solid #0073aa;
    outline-offset: 2px;
}

/* High Contrast Mode Support */
@media (prefers-contrast: high) {
    .wp-checkout-payment-method {
        border-width: 2px;
    }
    
    .wp-checkout-pay-button {
        border: 2px solid #000;
    }
}

/* Reduced Motion Support */
@media (prefers-reduced-motion: reduce) {
    .wp-checkout-payment-method,
    .wp-checkout-pay-button {
        transition: none;
    }
    
    .wp-checkout-pay-button:hover:not(:disabled) {
        transform: none;
    }
}