/**
 * Free Gifts Custom Styles for Cos/blank Theme
 * Optimized for COS design system
 */

/* Main wrapper for free gifts - matches COS container styling */
.cos-free-gifts-wrapper,
.mpfreegifts-btn-cart {
    margin: 24px 0;
    padding: 24px;
    background-color: #fff;
    border: 1px solid #e5e5e5;
    border-radius: 0;
    box-shadow: none;
    font-family: inherit;
}

/* Add gift button styling - matches COS button design */
.mpfreegifts-add-gift-btn {
    text-align: center;
    margin-bottom: 24px;
}

.mpfreegifts-btn {
    background-color: #080808;
    border: 1px solid #080808;
    color: #fff;
    padding: 16px 32px;
    font-size: 14px;
    font-weight: 400;
    border-radius: 0;
    cursor: pointer;
    transition: all 0.2s ease;
    text-transform: uppercase;
    letter-spacing: 1px;
    min-width: 200px;
    font-family: inherit;
}

.mpfreegifts-btn:hover {
    background-color: #333;
    border-color: #333;
    color: #fff;
}

.mpfreegifts-btn:focus {
    outline: 2px solid #080808;
    outline-offset: 2px;
}

/* Modal styling - COS design system */
.mpfreegifts-modal {
    background: #fff;
    padding: 32px;
    border-radius: 0;
    max-width: 1200px;
    margin: 0 auto;
    border: 1px solid #e5e5e5;
    font-family: inherit;
}

.mpfreegifts-item-left {
    text-align: center;
    margin-bottom: 32px;
    font-size: 16px;
    color: #080808;
    font-weight: 400;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.mpfreegifts-item-left strong {
    color: #080808;
    font-size: 24px;
    font-weight: 600;
}

/* Rule title styling */
.rule-title {
    font-size: 18px;
    font-weight: 600;
    color: #080808;
    margin-bottom: 24px;
    text-align: center;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid #e5e5e5;
    padding-bottom: 16px;
}

/* Grid layout - Bootstrap compatible */
.row-mp {
    display: flex;
    flex-wrap: wrap;
    margin: 0 -12px;
}

.col-mp {
    padding: 0 12px;
    box-sizing: border-box;
}

.mp-lg-3 { flex: 0 0 25%; max-width: 25%; }
.mp-md-4 { flex: 0 0 33.333333%; max-width: 33.333333%; }
.mp-sm-6 { flex: 0 0 50%; max-width: 50%; }
.mp-xs-12 { flex: 0 0 100%; max-width: 100%; }

/* Gift container styling - COS card design */
.gift-container {
    margin-bottom: 24px;
    padding: 12px;
}

.gift-item {
    border: 1px solid #e5e5e5;
    border-radius: 0;
    padding: 24px 16px;
    text-align: center;
    background: #fff;
    transition: all 0.2s ease;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    font-family: inherit;
}

.gift-item:hover {
    border-color: #080808;
    box-shadow: 0 2px 8px rgba(8, 8, 8, 0.1);
}

/* Gift image styling */
.gift-image-container {
    margin-bottom: 16px;
    height: 200px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    background-color: #f8f8f8;
}

.mpfreegifts-gift-image {
    max-width: 100%;
    max-height: 100%;
    height: auto;
    width: auto;
    object-fit: contain;
}

/* Gift name styling */
.mpfreegifts-gift-name {
    font-weight: 400;
    margin-bottom: 16px;
    min-height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #080808;
    font-size: 14px;
    line-height: 1.4;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Price styling - COS format */
.mpfreegifts-gift-price {
    margin-bottom: 24px;
}

.mpfreegifts-gift-original-price {
    text-decoration: line-through;
    color: #999;
    font-size: 14px;
    margin-bottom: 8px;
}

.mpfreegifts-gift-final-price {
    color: #080808;
    font-weight: 600;
    font-size: 16px;
}

/* Gift action styling - COS button style */
.mpfreegifts-gift-action {
    margin-top: auto;
}

.mpfreegifts-gift-action button {
    background-color: #080808;
    border: 1px solid #080808;
    color: #fff;
    padding: 12px 24px;
    border-radius: 0;
    cursor: pointer;
    transition: all 0.2s ease;
    font-weight: 400;
    font-size: 14px;
    min-width: 100px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-family: inherit;
}

.mpfreegifts-gift-action button:hover {
    background-color: #333;
    border-color: #333;
    color: #fff;
}

.mpfreegifts-gift-action button:focus {
    outline: 2px solid #080808;
    outline-offset: 2px;
}

.mpfreegifts-action-remove {
    background-color: #fff !important;
    border-color: #080808 !important;
    color: #080808 !important;
}

.mpfreegifts-action-remove:hover {
    background-color: #080808 !important;
    border-color: #080808 !important;
    color: #fff !important;
}

/* Quantity input styling - COS form style */
.mpfreegifts-gift-qty {
    margin-bottom: 16px;
}

.mpfreegifts-gift-qty label {
    display: block;
    margin-bottom: 8px;
    font-weight: 400;
    color: #080808;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.mpfreegifts-gift-qty input {
    width: 80px;
    padding: 12px;
    border: 1px solid #e5e5e5;
    border-radius: 0;
    text-align: center;
    font-size: 14px;
    transition: border-color 0.2s ease;
    font-family: inherit;
}

.mpfreegifts-gift-qty input:focus {
    outline: none;
    border-color: #080808;
}

/* Validation messages */
.mp-validation-message-box {
    margin-top: 8px;
}

.mp-mage-error {
    color: #d32f2f;
    font-size: 12px;
    background-color: #fff;
    padding: 8px;
    border: 1px solid #d32f2f;
    border-radius: 0;
}

/* List layout styling */
.mpfreegifts-rule-list .table-wrapper {
    overflow-x: auto;
    border: 1px solid #e5e5e5;
}

.mpfreegifts-rule-list table {
    width: 100%;
    border-collapse: collapse;
    background: #fff;
}

.mpfreegifts-rule-list .table-caption {
    background-color: #080808;
    color: #fff;
    padding: 16px;
    font-weight: 600;
    font-size: 16px;
    text-align: center;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.mpfreegifts-rule-list th {
    background-color: #f8f8f8;
    padding: 16px;
    font-weight: 600;
    color: #080808;
    border-bottom: 1px solid #e5e5e5;
    text-align: left;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-size: 12px;
}

.mpfreegifts-rule-list td {
    padding: 16px;
    border-bottom: 1px solid #e5e5e5;
    vertical-align: middle;
}

.mpfreegifts-rule-list .col.image {
    width: 120px;
    text-align: center;
}

.mpfreegifts-rule-list .mpfreegifts-gift-image {
    width: 100px;
    height: 100px;
    object-fit: contain;
}

/* Slider layout styling */
.mpfreegifts-rule-slider {
    overflow: hidden;
}

.mpfreegifts-rule-slider .item {
    padding: 12px;
}

/* Responsive design - Mobile first approach */
@media (max-width: 1024px) {
    .mp-lg-3 {
        flex: 0 0 33.333333%;
        max-width: 33.333333%;
    }

    .mpfreegifts-modal {
        padding: 24px;
    }
}

@media (max-width: 768px) {
    .mp-lg-3,
    .mp-md-4 {
        flex: 0 0 50%;
        max-width: 50%;
    }

    .cos-free-gifts-wrapper,
    .mpfreegifts-btn-cart {
        margin: 16px 0;
        padding: 16px;
    }

    .mpfreegifts-modal {
        padding: 16px;
    }

    .gift-image-container {
        height: 150px;
    }

    .mpfreegifts-gift-name {
        min-height: 40px;
        font-size: 12px;
    }

    .mpfreegifts-btn {
        padding: 14px 24px;
        font-size: 12px;
        min-width: 160px;
    }

    .rule-title {
        font-size: 16px;
        margin-bottom: 16px;
    }
}

@media (max-width: 480px) {
    .mp-lg-3,
    .mp-md-4,
    .mp-sm-6 {
        flex: 0 0 100%;
        max-width: 100%;
    }

    .cos-free-gifts-wrapper,
    .mpfreegifts-btn-cart {
        margin: 12px 0;
        padding: 12px;
    }

    .mpfreegifts-modal {
        padding: 12px;
    }

    .mpfreegifts-btn {
        padding: 12px 20px;
        font-size: 12px;
        width: 100%;
        min-width: auto;
    }

    .rule-title {
        font-size: 14px;
    }

    .mpfreegifts-item-left {
        font-size: 14px;
    }

    .mpfreegifts-item-left strong {
        font-size: 18px;
    }

    .gift-item {
        padding: 16px 12px;
    }

    .gift-image-container {
        height: 120px;
    }
}

/* Loading states */
.mpfreegifts-loading {
    position: relative;
    pointer-events: none;
    opacity: 0.6;
}

.mpfreegifts-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 #080808;
    border-radius: 50%;
    animation: mpfreegifts-spin 1s linear infinite;
}

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

/* Animation for gift items */
.gift-item {
    animation: mpfreegifts-fadeIn 0.3s ease-in-out;
}

@keyframes mpfreegifts-fadeIn {
    0% {
        opacity: 0;
        transform: translateY(10px);
    }
    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Success/Error states */
.mpfreegifts-success {
    background-color: #080808;
    color: white;
    padding: 16px;
    margin: 16px 0;
    text-align: center;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-size: 14px;
}

.mpfreegifts-error {
    background-color: #fff;
    color: #d32f2f;
    border: 1px solid #d32f2f;
    padding: 16px;
    margin: 16px 0;
    text-align: center;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-size: 14px;
}

/* Modal overlay improvements */
.modal-popup._show .mpfreegifts-modal {
    max-height: 80vh;
    overflow-y: auto;
}

/* Integration with COS cart layout */
.mycart-container .mpfreegifts-btn-cart {
    order: 3;
    margin-top: 24px;
}

/* Ensure proper spacing in COS layout */
.cart-items + .mpfreegifts-btn-cart {
    margin-top: 32px;
    border-top: 1px solid #e5e5e5;
    padding-top: 32px;
}

/* Style for empty states */
.mpfreegifts-empty {
    text-align: center;
    padding: 32px;
    color: #999;
    font-style: italic;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .gift-item {
        border-width: 2px;
    }

    .mpfreegifts-btn,
    .mpfreegifts-gift-action button {
        border-width: 2px;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    .gift-item,
    .mpfreegifts-btn,
    .mpfreegifts-gift-action button {
        transition: none;
    }

    .gift-item {
        animation: none;
    }

    .mpfreegifts-loading::after {
        animation: none;
    }
}

/* Print styles */
@media print {
    .mpfreegifts-btn-cart,
    .mpfreegifts-modal {
        display: none !important;
    }
}

/* Dark mode support (if COS implements it) */
@media (prefers-color-scheme: dark) {
    .cos-free-gifts-wrapper,
    .mpfreegifts-btn-cart,
    .mpfreegifts-modal,
    .gift-item {
        background-color: #1a1a1a;
        border-color: #333;
        color: #fff;
    }

    .gift-image-container {
        background-color: #2a2a2a;
    }

    .mpfreegifts-gift-name,
    .rule-title,
    .mpfreegifts-item-left {
        color: #fff;
    }

    .mpfreegifts-gift-final-price {
        color: #fff;
    }
}

/* Accessibility improvements */
.mpfreegifts-btn:focus-visible,
.mpfreegifts-gift-action button:focus-visible,
.mpfreegifts-gift-qty input:focus-visible {
    outline: 2px solid #080808;
    outline-offset: 2px;
}

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

/* Focus indicators for keyboard navigation */
.gift-item:focus-within {
    outline: 2px solid #080808;
    outline-offset: 2px;
}
