/* WC Recurring Purchases - Frontend Styles */

/* Product Page Recurring Options */
.wc-rp-recurring-options {
    margin: 20px 0;
    padding: 20px;
    border: 1px solid #ddd;
    border-radius: 5px;
    background: #f9f9f9;
}

.wc-rp-recurring-options h4 {
    margin: 0 0 15px 0;
    color: #333;
}

.wc-rp-recurring-toggle {
    margin-bottom: 15px;
}

.wc-rp-recurring-toggle label {
    font-weight: bold;
    cursor: pointer;
}

#wc-rp-frequency-section {
    margin-bottom: 15px;
}

#wc-rp-frequency-section label {
    display: block;
    margin-bottom: 5px;
    font-weight: bold;
}

#wc_rp_frequency {
    width: 100%;
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 3px;
}

.wc-rp-price-display {
    margin: 10px 0;
}

.wc-rp-price-display .original-price {
    display: block;
    color: #666;
    font-size: 14px;
}

.wc-rp-price-display .recurring-price {
    display: block;
    font-size: 16px;
    font-weight: bold;
    color: #0073aa;
}

.wc-rp-price-display .discounted-price {
    color: #46b450;
}

.wc-rp-price-display .discount-percentage {
    color: #46b450;
    font-weight: bold;
    margin-left: 5px;
}

.wc-rp-description {
    font-style: italic;
    color: #666;
    margin: 10px 0 0 0;
}

/* Messages */
.wc-rp-message {
    padding: 10px;
    margin: 10px 0;
    border-radius: 3px;
    border-left: 4px solid;
}

.wc-rp-message--success {
    background: #d4edda;
    border-color: #46b450;
    color: #155724;
}

.wc-rp-message--info {
    background: #cce7ff;
    border-color: #0073aa;
    color: #004085;
}

.wc-rp-message--error {
    background: #f8d7da;
    border-color: #dc3545;
    color: #721c24;
}

/* Cart Page Recurring Order Summary */
.wc-rp-order-summary {
    margin: 30px 0;
    padding: 25px;
    background: #f8f9fa;
    border: 2px solid #e9ecef;
    border-radius: 8px;
    border-left: 5px solid #0073aa;
}

.wc-rp-order-summary h3 {
    margin: 0 0 20px 0;
    color: #0073aa;
    font-size: 22px;
    border-bottom: 2px solid #e9ecef;
    padding-bottom: 10px;
}

.wc-rp-summary-content {
    display: flex;
    flex-direction: column;
    gap: 25px;
}

.wc-rp-recurring-items h4 {
    margin: 0 0 15px 0;
    color: #333;
    font-size: 18px;
}

.wc-rp-recurring-item {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 15px;
    background: white;
    border: 1px solid #e9ecef;
    border-radius: 5px;
    margin-bottom: 10px;
}

.wc-rp-recurring-item .item-details {
    flex: 1;
}

.wc-rp-recurring-item .item-name {
    display: block;
    font-weight: bold;
    color: #333;
    margin-bottom: 5px;
}

.wc-rp-recurring-item .item-frequency {
    display: block;
    color: #0073aa;
    font-size: 14px;
    margin-bottom: 3px;
}

.wc-rp-recurring-item .item-discount {
    display: block;
    color: #46b450;
    font-size: 14px;
    font-weight: bold;
}

.wc-rp-recurring-item .item-pricing {
    text-align: right;
}

.wc-rp-recurring-item .item-quantity {
    display: block;
    color: #666;
    font-size: 14px;
    margin-bottom: 5px;
}

.wc-rp-recurring-item .item-total {
    display: block;
    font-weight: bold;
    font-size: 16px;
    color: #333;
}

.wc-rp-cost-breakdown {
    background: white;
    border: 1px solid #e9ecef;
    border-radius: 5px;
    padding: 20px;
}

.wc-rp-cost-breakdown .cost-line {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid #f0f0f1;
}

.wc-rp-cost-breakdown .cost-line:last-child {
    border-bottom: none;
}

.wc-rp-cost-breakdown .cost-line.total {
    border-top: 2px solid #e9ecef;
    margin-top: 10px;
    padding-top: 15px;
    font-size: 18px;
}

.wc-rp-cost-breakdown .cost-label {
    color: #333;
}

.wc-rp-cost-breakdown .cost-value {
    color: #0073aa;
    font-weight: bold;
}

.wc-rp-recurring-info {
    background: #e7f3ff;
    border: 1px solid #b8daff;
    border-radius: 5px;
    padding: 20px;
}

.wc-rp-recurring-info .info-text {
    margin: 0 0 15px 0;
    color: #004085;
}

.wc-rp-recurring-info .info-list {
    margin: 0;
    padding-left: 20px;
    color: #004085;
}

.wc-rp-recurring-info .info-list li {
    margin-bottom: 8px;
    line-height: 1.5;
}

.wc-rp-cart-recurring-info {
    color: #0073aa;
    font-weight: bold;
}

/* Cart Item Recurring Information */
.wc-rp-cart-recurring-info {
    display: inline-block;
    background: linear-gradient(135deg, #0073aa 0%, #005a87 100%);
    color: white !important;
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    margin-left: 8px;
    text-transform: uppercase;
    box-shadow: 0 2px 4px rgba(0,115,170,0.3);
    vertical-align: middle;
}

.wc-rp-cart-recurring-info::before {
    content: "🔄 ";
    font-size: 10px;
    margin-right: 3px;
}

/* Badge ricorrente per nome prodotto */
.woocommerce-cart-form .cart_item .product-name {
    position: relative;
}

.woocommerce-cart-form .cart_item:has(.wc-rp-cart-recurring-info) .product-name::after {
    content: "RICORRENTE";
    position: absolute;
    top: -8px;
    right: -8px;
    background: #00a32a;
    color: white;
    font-size: 9px;
    font-weight: bold;
    padding: 2px 6px;
    border-radius: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    box-shadow: 0 2px 4px rgba(0,163,42,0.3);
    z-index: 1;
}

/* Hover effect per prodotti ricorrenti */
.woocommerce-cart-form .cart_item:has(.wc-rp-cart-recurring-info) {
    background: linear-gradient(135deg, #f8f9ff 0%, #e7f3ff 100%);
    border-left: 4px solid #0073aa;
    transition: all 0.3s ease;
}

.woocommerce-cart-form .cart_item:has(.wc-rp-cart-recurring-info):hover {
    box-shadow: 0 2px 8px rgba(0,115,170,0.2);
    transform: translateX(2px);
}

/* Account Subscriptions Page */
.wc-rp-subscriptions-wrapper {
    margin: 20px 0;
}

.wc-rp-subscriptions-table-wrapper {
    overflow-x: auto;
    margin: 20px 0;
}

.wc-rp-subscriptions-table {
    width: 100%;
    border-collapse: collapse;
}

.wc-rp-subscriptions-table th,
.wc-rp-subscriptions-table td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid #e1e1e1;
}

.wc-rp-subscriptions-table th {
    background: #f8f9fa;
    font-weight: bold;
}

.status-badge {
    padding: 4px 8px;
    border-radius: 3px;
    font-size: 11px;
    font-weight: bold;
    text-transform: uppercase;
    display: inline-block;
}

.status-active {
    background: #46b450;
    color: white;
}

.status-pending {
    background: #ffb900;
    color: white;
}

.status-paused {
    background: #666;
    color: white;
}

.status-cancelled,
.status-user_cancelled,
.status-admin_cancelled {
    background: #dc3232;
    color: white;
}

.status-error {
    background: #dc3232;
    color: white;
}

.frequency-badge {
    padding: 3px 6px;
    background: #e9ecef;
    border-radius: 3px;
    font-size: 11px;
    color: #495057;
}

.subscription-meta,
.product-meta {
    margin-top: 5px;
}

.subscription-meta small,
.product-meta small {
    color: #6c757d;
}

.subscription-actions-wrapper .button {
    margin-right: 5px;
    margin-bottom: 5px;
    padding: 6px 12px;
    font-size: 12px;
}

.subscription-actions-wrapper .subscription-pause {
    background: #ffc107;
    border-color: #ffc107;
    color: #212529;
}

.subscription-actions-wrapper .subscription-resume {
    background: #28a745;
    border-color: #28a745;
    color: white;
}

.subscription-actions-wrapper .subscription-cancel {
    background: #dc3545;
    border-color: #dc3545;
    color: white;
}

.wc-rp-subscription-info {
    margin-top: 30px;
    padding: 20px;
    background: #f8f9fa;
    border-radius: 5px;
    border: 1px solid #e9ecef;
}

.wc-rp-subscription-info h3 {
    margin-top: 0;
    color: #495057;
}

.wc-rp-subscription-info ul {
    margin: 15px 0;
    padding-left: 20px;
}

.wc-rp-subscription-info li {
    margin-bottom: 8px;
    color: #6c757d;
}

.wc-rp-frequency-group {
    margin-bottom: 20px;
}

.wc-rp-frequency-group h4 {
    margin: 0 0 12px 0;
    color: #0073aa;
    font-size: 16px;
    border-bottom: 1px solid #e9ecef;
    padding-bottom: 8px;
}

/* Responsive Design */
@media (max-width: 768px) {
    .wc-rp-recurring-options {
        margin: 15px 0;
        padding: 15px;
    }
    
    .wc-rp-order-summary {
        margin: 20px 0;
        padding: 15px;
    }
    
    .wc-rp-order-summary h3 {
        font-size: 18px;
    }
    
    .wc-rp-recurring-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }
    
    .wc-rp-recurring-item .item-pricing {
        text-align: left;
        width: 100%;
    }
    
    .wc-rp-cost-breakdown {
        padding: 15px;
    }
    
    .wc-rp-cost-breakdown .cost-line {
        flex-direction: column;
        align-items: flex-start;
        gap: 5px;
    }
    
    .wc-rp-cost-breakdown .cost-line.total {
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
    }
    
    .wc-rp-recurring-info {
        padding: 15px;
    }
    
    .wc-rp-subscriptions-table thead {
        display: none;
    }
    
    .wc-rp-subscriptions-table,
    .wc-rp-subscriptions-table tbody,
    .wc-rp-subscriptions-table tr,
    .wc-rp-subscriptions-table td {
        display: block;
        width: 100%;
    }
    
    .wc-rp-subscriptions-table tr {
        border: 1px solid #e1e1e1;
        margin-bottom: 15px;
        padding: 10px;
        border-radius: 5px;
    }
    
    .wc-rp-subscriptions-table td {
        border: none;
        border-bottom: 1px solid #f0f0f1;
        text-align: right;
        padding: 8px 0;
        position: relative;
        padding-left: 50%;
    }
    
    .wc-rp-subscriptions-table td:before {
        content: attr(data-title) ": ";
        position: absolute;
        left: 0;
        width: 45%;
        padding-right: 10px;
        white-space: nowrap;
        font-weight: bold;
        text-align: left;
    }
    
    .subscription-actions-wrapper {
        text-align: left;
    }
}

/* Loading states */
.wc-rp-loading {
    position: relative;
}

.wc-rp-loading:after {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.8);
    display: block;
}

/* Animations */
.wc-rp-message {
    animation: slideDown 0.3s ease-out;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}
