/**
 * Post-Purchase Add-ons — Frontend Styles.
 *
 * @package WCPPA
 */

/* Addon Section */
.wcppa-addon-section {
    margin: 2em 0;
    padding: 1.5em;
    background: #f8f9fa;
    border: 1px solid #e2e4e7;
    border-radius: 4px;
}

.wcppa-addon-section h2 {
    margin-top: 0;
    font-size: 1.2em;
}

.wcppa-open-browser {
    display: inline-block;
    padding: 10px 24px;
    font-size: 1em;
    cursor: pointer;
}

/* Modal Overlay */
.wcppa-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 999999;
    display: flex;
    align-items: center;
    justify-content: center;
}

.wcppa-modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
}

/* Modal Container */
.wcppa-modal-container {
    position: relative;
    width: 90%;
    max-width: 900px;
    max-height: 90vh;
    background: #fff;
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.wcppa-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 24px;
    border-bottom: 1px solid #e2e4e7;
}

.wcppa-modal-header h2 {
    margin: 0;
    font-size: 1.3em;
}

.wcppa-modal-close {
    background: none;
    border: none;
    font-size: 28px;
    cursor: pointer;
    color: #666;
    padding: 0 4px;
    line-height: 1;
}

.wcppa-modal-close:hover {
    color: #333;
}

.wcppa-modal-body {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
}

.wcppa-modal-footer {
    padding: 12px 24px;
    border-top: 1px solid #e2e4e7;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* Search Bar */
.wcppa-search-bar {
    display: flex;
    gap: 12px;
    margin-bottom: 20px;
}

.wcppa-search-input {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
}

.wcppa-category-filter {
    min-width: 180px;
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
}

/* Product Grid */
.wcppa-products-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 16px;
    min-height: 200px;
}

.wcppa-product-card {
    border: 1px solid #e2e4e7;
    border-radius: 6px;
    padding: 12px;
    text-align: center;
    display: flex;
    flex-direction: column;
    transition: box-shadow 0.2s;
}

.wcppa-product-card:hover {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.wcppa-product-image img {
    width: 100%;
    height: 150px;
    object-fit: contain;
    margin-bottom: 8px;
}

.wcppa-product-info {
    flex: 1;
}

.wcppa-product-name {
    font-size: 0.9em;
    margin: 0 0 4px;
    line-height: 1.3;
}

.wcppa-product-price {
    font-size: 0.95em;
    color: #333;
    font-weight: 600;
    margin-bottom: 8px;
}

.wcppa-add-product {
    margin-top: auto;
    width: 100%;
}

/* Pagination */
.wcppa-pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 12px;
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid #eee;
}

.wcppa-page-info {
    font-size: 0.9em;
    color: #666;
}

/* Loading */
.wcppa-loading {
    text-align: center;
    padding: 40px;
    color: #666;
}

.wcppa-loading .spinner {
    float: none;
    display: inline-block;
    vertical-align: middle;
    margin-right: 8px;
}

.wcppa-no-products {
    text-align: center;
    color: #666;
    padding: 40px;
    grid-column: 1 / -1;
}

/* Mini Cart */
.wcppa-mini-cart {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 0.95em;
}

.wcppa-cart-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #7f54b3;
    color: #fff;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    font-size: 0.85em;
    font-weight: 600;
}

/* Cart Table */
.wcppa-cart-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 20px;
}

.wcppa-cart-table th,
.wcppa-cart-table td {
    padding: 10px 12px;
    border-bottom: 1px solid #eee;
    text-align: left;
}

.wcppa-cart-table th {
    font-weight: 600;
    font-size: 0.9em;
    color: #666;
}

.wcppa-item-qty {
    width: 60px;
    padding: 4px 8px;
    text-align: center;
}

.wcppa-remove-item {
    background: none;
    border: none;
    color: #cc0000;
    font-size: 18px;
    cursor: pointer;
    padding: 2px 8px;
}

.wcppa-remove-item:hover {
    color: #ff0000;
}

.wcppa-cart-actions {
    display: flex;
    justify-content: space-between;
    gap: 12px;
}

.wcppa-cart-empty {
    text-align: center;
    padding: 30px;
    color: #666;
}

/* Payment Step */
.wcppa-payment-summary {
    margin-bottom: 20px;
    padding: 12px 16px;
    background: #f8f9fa;
    border-radius: 4px;
}

.wcppa-payment-summary strong {
    font-size: 1.2em;
}

.wcppa-saved-methods-list {
    margin-bottom: 16px;
}

.wcppa-payment-method-option {
    display: block;
    padding: 10px 12px;
    margin-bottom: 4px;
    border: 1px solid #e2e4e7;
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.15s;
}

.wcppa-payment-method-option:hover {
    background: #f8f9fa;
}

.wcppa-payment-method-option input[type="radio"] {
    margin-right: 8px;
}

.wcppa-payment-divider {
    text-align: center;
    margin: 20px 0;
    position: relative;
}

.wcppa-payment-divider span {
    background: #fff;
    padding: 0 12px;
    color: #999;
    position: relative;
    z-index: 1;
}

.wcppa-payment-divider::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    border-top: 1px solid #e2e4e7;
}

.wcppa-payment-loading {
    text-align: center;
    padding: 20px;
}

.wcppa-payment-loading .spinner {
    float: none;
    display: inline-block;
    vertical-align: middle;
}

.wcppa-payment-error .wcppa-error-message {
    color: #cc0000;
    background: #fff0f0;
    padding: 10px 16px;
    border-radius: 4px;
    border: 1px solid #ffcccc;
}

/* Confirmation Step */
.wcppa-confirmation {
    text-align: center;
    padding: 20px;
}

.wcppa-confirmation-icon {
    font-size: 48px;
    color: #4caf50;
    margin-bottom: 12px;
}

.wcppa-confirmation h3 {
    font-size: 1.4em;
    margin-bottom: 8px;
}

.wcppa-confirmation-details {
    margin: 20px 0;
    padding: 16px;
    background: #f8f9fa;
    border-radius: 4px;
    display: inline-block;
}

.wcppa-confirmation-details p {
    margin: 4px 0;
}

.wcppa-confirmation-actions {
    margin-top: 20px;
    display: flex;
    gap: 12px;
    justify-content: center;
}

/* Variation Modal */
.wcppa-variation-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1000000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.wcppa-variation-modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.4);
}

.wcppa-variation-modal-container {
    position: relative;
    width: 90%;
    max-width: 500px;
    max-height: 70vh;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    display: flex;
    flex-direction: column;
}

.wcppa-variation-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 20px;
    border-bottom: 1px solid #e2e4e7;
}

.wcppa-variation-modal-header h3 {
    margin: 0;
    font-size: 1.1em;
}

.wcppa-variation-modal-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: #666;
}

.wcppa-variation-modal-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px 20px;
}

.wcppa-variation-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid #f0f0f0;
}

.wcppa-variation-item:last-child {
    border-bottom: none;
}

.wcppa-variation-info {
    flex: 1;
}

.wcppa-variation-label {
    display: block;
    font-weight: 500;
}

.wcppa-variation-price {
    display: block;
    font-size: 0.9em;
    color: #666;
}

/* Addon Orders Table */
.wcppa-addon-orders-table {
    margin: 1em 0 2em;
}

.wcppa-parent-link {
    margin: 1.5em 0;
    padding: 12px 16px;
    background: #f0f7ff;
    border: 1px solid #c6ddf7;
    border-radius: 4px;
}

/* Pay-for-order notice */
.wcppa-pay-order-notice {
    margin-bottom: 20px;
}

/* Vibes-child theme integration — injected order buttons */
.wcppa-theme-addon-wrap {
    padding: 13px;
    border-top: 1px solid #cbcbcb;
    text-align: center;
}

.wcppa-theme-addon-btn.btn.btn-primary {
    width: 100%;
    max-width: 320px;
    padding: 10px 24px;
    font-size: 14px;
    cursor: pointer;
}

@media (min-width: 768px) {
    .wcppa-theme-addon-wrap {
        text-align: start;
    }
    .wcppa-theme-addon-btn.btn.btn-primary {
        width: auto;
        font-size: 16px;
        border-radius: 10px;
        font-weight: 500;
        padding-block: 8px;
    }
}

/* Frontend Payment Summary (view-order page) */
.wcppa-frontend-payment-summary {
    margin: 1.5em 0;
    padding: 1.5em;
    background: #f8f9fa;
    border: 1px solid #e2e4e7;
    border-radius: 4px;
}

.wcppa-frontend-payment-summary h3 {
    margin-top: 0;
    font-size: 1.1em;
}

.wcppa-payment-summary-table {
    margin-bottom: 1em;
}

.wcppa-remaining-row td {
    border-top: 2px solid #ddd;
}

.wcppa-pay-remaining-btn {
    display: inline-block;
    padding: 10px 24px;
    font-size: 1em;
    cursor: pointer;
    margin-top: 0.5em;
}

.wcppa-pay-remaining-btn:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}

.wcppa-pay-status {
    display: inline-block;
    margin-inline-start: 12px;
    font-size: 0.9em;
    vertical-align: middle;
}

.wcppa-pay-success {
    color: #4caf50;
}

.wcppa-pay-error {
    color: #cc0000;
}

.wcppa-fully-paid-notice {
    color: #4caf50;
    padding: 8px 16px;
    background: #f0faf0;
    border: 1px solid #c8e6c8;
    border-radius: 4px;
    margin-top: 1em;
}

.wcppa-no-stored-method-notice {
    color: #856404;
    background: #fff3cd;
    border: 1px solid #ffc107;
    border-radius: 4px;
    padding: 8px 16px;
    margin-top: 1em;
}

/* Vibes-child theme: "Pay Remaining" button in order blocks */
.wcppa-theme-pay-wrap {
    padding: 8px 13px;
    border-top: 1px solid #cbcbcb;
    text-align: center;
}

.wcppa-theme-pay-btn.btn.btn-primary {
    width: 100%;
    max-width: 320px;
    padding: 10px 24px;
    font-size: 14px;
    cursor: pointer;
}

@media (min-width: 768px) {
    .wcppa-theme-pay-wrap {
        text-align: start;
    }
    .wcppa-theme-pay-btn.btn.btn-primary {
        width: auto;
        font-size: 16px;
        border-radius: 10px;
        font-weight: 500;
        padding-block: 8px;
    }
}

/* Responsive */
@media (max-width: 600px) {
    .wcppa-modal-container {
        width: 100%;
        height: 100%;
        max-height: 100%;
        border-radius: 0;
    }

    .wcppa-products-grid {
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
        gap: 10px;
    }

    .wcppa-search-bar {
        flex-direction: column;
    }

    .wcppa-category-filter {
        min-width: auto;
    }

    .wcppa-cart-actions {
        flex-direction: column;
    }
}
