/**
 * TD Rewards - Frontend Styles
 *
 * @package TD_Rewards
 * @version 1.0.0
 */

/* ==========================================================================
   Checkout Layout - Payment Info below Your Order
   ========================================================================== */

/* Make form a flex column */
form.woocommerce-checkout,
form.checkout.wd-checkout-form {
    display: flex !important;
    flex-direction: column !important;
}

/* Your Order section - show first */
form.woocommerce-checkout .checkout-order-review,
form.woocommerce-checkout #order_review_heading,
form.woocommerce-checkout > .checkout-order-review {
    order: 1 !important;
}

/* Payment Information (billing/shipping) - show after */
form.woocommerce-checkout .customer-details,
form.woocommerce-checkout #customer_details,
form.woocommerce-checkout > .customer-details {
    order: 2 !important;
}

/* ==========================================================================
   My Account Dashboard
   ========================================================================== */

.td-rewards-dashboard {
    max-width: 800px;
    min-height: 60vh;
    padding-bottom: 3rem;
}

/* Ensure WooCommerce account content has proper height */
.woocommerce-account .woocommerce-MyAccount-content:has(.td-rewards-dashboard) {
    min-height: auto;
    overflow: visible;
}

/* Points Summary */
.td-rewards-summary {
    background: linear-gradient(135deg, #1a1a1a 0%, #333 100%);
    color: #fff;
    padding: 2rem;
    border-radius: 8px;
    margin-bottom: 1.5rem;
    text-align: center;
}

.td-rewards-balance-label {
    display: block;
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    opacity: 0.8;
    margin-bottom: 0.5rem;
}

.td-rewards-balance-value {
    display: block;
    font-size: 3rem;
    font-weight: 700;
    line-height: 1;
    margin-bottom: 0.5rem;
}

.td-rewards-balance-worth {
    display: block;
    font-size: 1rem;
    opacity: 0.9;
}

.td-rewards-expiring {
    margin-top: 1rem;
    padding: 0.75rem;
    background: rgba(255, 193, 7, 0.2);
    border-radius: 4px;
    font-size: 0.875rem;
}

.td-rewards-expiring .dashicons {
    color: #ffc107;
    vertical-align: middle;
    margin-right: 0.25rem;
}

/* Stats */
.td-rewards-stats {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.td-rewards-stat {
    background: #f8f8f8;
    padding: 1.5rem;
    border-radius: 8px;
    text-align: center;
}

.td-rewards-stat-value {
    display: block;
    font-size: 1.5rem;
    font-weight: 700;
    color: #1a1a1a;
}

.td-rewards-stat-label {
    display: block;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #666;
    margin-top: 0.25rem;
}

/* Info Box */
.td-rewards-info {
    background: #f8f8f8;
    padding: 1.5rem;
    border-radius: 8px;
    margin-bottom: 1.5rem;
}

.td-rewards-info h3 {
    margin: 0 0 1rem;
    font-size: 1rem;
}

.td-rewards-info ul {
    margin: 0;
    padding: 0;
    list-style: none;
}

.td-rewards-info li {
    padding: 0.5rem 0;
    border-bottom: 1px solid #eee;
    font-size: 0.875rem;
}

.td-rewards-info li:last-child {
    border-bottom: none;
}

/* Transaction History */
.td-rewards-history h3 {
    margin: 0 0 1rem;
    font-size: 1rem;
}

.td-rewards-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

.td-rewards-table th,
.td-rewards-table td {
    padding: 0.75rem;
    text-align: left;
    border-bottom: 1px solid #eee;
}

.td-rewards-table th {
    background: #f8f8f8;
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.td-rewards-table .positive {
    color: #28a745;
    font-weight: 600;
}

.td-rewards-table .negative {
    color: #dc3545;
    font-weight: 600;
}

.td-rewards-no-history {
    color: #666;
    font-style: italic;
}

/* Clearfix for proper layout */
.td-rewards-dashboard::after {
    content: "";
    display: table;
    clear: both;
}

.td-rewards-history {
    margin-bottom: 2rem;
}

/* ==========================================================================
   Cart Suggestion
   ========================================================================== */

.td-rewards-suggestion {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
    padding: 1rem;
    border-radius: 8px;
    margin-bottom: 1rem;
}

.td-rewards-suggestion-icon {
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    background: #f59e0b;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.td-rewards-suggestion-icon .dashicons {
    color: #fff;
    font-size: 20px;
    width: 20px;
    height: 20px;
}

.td-rewards-suggestion-text {
    margin: 0;
    font-size: 0.875rem;
    color: #78350f;
}

.td-rewards-login-prompt {
    background: #f8f8f8;
    padding: 1rem;
    border-radius: 8px;
    margin-bottom: 1rem;
    font-size: 0.875rem;
}

.td-rewards-login-prompt a {
    font-weight: 600;
}

/* Points to Earn Row */
.td-rewards-earn-row th,
.td-rewards-earn-row td {
    padding-top: 0.5rem;
}

.td-rewards-points-badge {
    display: inline-block;
    background: #28a745;
    color: #fff;
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-size: 0.875rem;
    font-weight: 600;
}

/* Mini Cart */
.td-rewards-mini-cart {
    background: #f8f8f8;
    padding: 0.75rem;
    border-radius: 4px;
    margin-bottom: 0.75rem;
    font-size: 0.75rem;
    text-align: center;
}

/* ==========================================================================
   Checkout Redemption
   ========================================================================== */

.td-rewards-checkout {
    background: linear-gradient(135deg, #1a1a1a 0%, #333 100%);
    color: #fff !important;
    padding: 1.25rem;
    border-radius: 8px;
    margin-bottom: 1.5rem;
    position: relative;
    transition: opacity 0.2s;
}

/* Loading state */
.td-rewards-checkout.td-rewards-loading {
    opacity: 0.7;
    pointer-events: none;
}

.td-rewards-checkout.td-rewards-loading::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 24px;
    height: 24px;
    margin: -12px 0 0 -12px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-top-color: #ffc107;
    border-radius: 50%;
    animation: td-rewards-spin 0.8s linear infinite;
}

@keyframes td-rewards-spin {
    to { transform: rotate(360deg); }
}

/* Force all text white inside checkout box */
.td-rewards-checkout,
.td-rewards-checkout p,
.td-rewards-checkout span,
.td-rewards-checkout label,
.td-rewards-checkout strong,
.td-rewards-checkout div {
    color: #fff !important;
}

.td-rewards-checkout a {
    color: #ffc107 !important;
}

/* Locked State for Guests */
.td-rewards-locked {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.td-rewards-locked__icon {
    width: 48px;
    height: 48px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #ffc107;
    flex-shrink: 0;
}

.td-rewards-locked__content {
    flex: 1;
    min-width: 200px;
}

.td-rewards-locked__content strong {
    display: block;
    font-size: 1rem;
    margin-bottom: 0.25rem;
}

.td-rewards-locked__content p {
    margin: 0;
    font-size: 0.8rem;
    opacity: 0.8;
}

.td-rewards-locked__btn {
    background: #ffc107 !important;
    color: #1a1a1a !important;
    border: none !important;
    padding: 0.75rem 1.25rem !important;
    font-weight: 600 !important;
    font-size: 0.8rem !important;
    border-radius: 4px !important;
    cursor: pointer;
    transition: all 0.2s;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.td-rewards-locked__btn:hover {
    background: #ffca2c !important;
}

@media (max-width: 600px) {
    .td-rewards-locked {
        flex-direction: column;
        text-align: center;
    }

    .td-rewards-locked__btn {
        width: 100%;
    }
}

/* Header with Balance and Redeem Button */
.td-rewards-checkout-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
}

.td-rewards-checkout-balance {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.td-rewards-checkout-icon {
    width: 40px;
    height: 40px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #ffc107;
}

.td-rewards-checkout-balance-info {
    display: flex;
    flex-direction: column;
}

.td-rewards-checkout-balance-label {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    opacity: 0.8;
}

.td-rewards-checkout-balance-value {
    font-size: 1.125rem;
    font-weight: 700;
}

.td-rewards-checkout-balance-value small {
    font-weight: 400;
    opacity: 0.8;
    margin-left: 0.25rem;
}

.td-rewards-redeem-btn {
    background: #ffc107 !important;
    color: #1a1a1a !important;
    border: none !important;
    padding: 0.75rem 1.25rem !important;
    font-weight: 600 !important;
    font-size: 0.875rem !important;
    border-radius: 4px !important;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
    display: inline-block !important;
    visibility: visible !important;
    opacity: 1 !important;
}

.td-rewards-redeem-btn:hover {
    background: #ffca2c !important;
    transform: translateY(-1px);
}

/* Make sure button text is dark */
.td-rewards-redeem-btn,
.td-rewards-apply-btn,
.td-rewards-locked__btn {
    color: #1a1a1a !important;
    background: #ffc107 !important;
}

/* Checkout Options */
.td-rewards-checkout-options {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.td-rewards-checkout-limit {
    margin: 0 0 0.75rem;
    font-size: 0.8rem;
    opacity: 0.9;
}

.td-rewards-checkout-limit strong,
.td-rewards-checkout-limit strong .woocommerce-Price-amount,
.td-rewards-checkout-limit strong .woocommerce-Price-currencySymbol {
    color: #ffc107 !important;
}

.td-rewards-custom-toggle {
    background: rgba(255, 255, 255, 0.1) !important;
    border: 1px solid rgba(255, 255, 255, 0.3) !important;
    color: #fff !important;
    font-size: 0.8rem;
    cursor: pointer;
    padding: 0.5rem 1rem !important;
    border-radius: 4px;
    display: inline-block;
}

.td-rewards-custom-toggle:hover {
    background: rgba(255, 255, 255, 0.2) !important;
    color: #fff !important;
}

.td-rewards-custom-form {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

/* Applied State */
.td-rewards-applied {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #28a745;
    padding: 1rem;
    border-radius: 4px;
    margin-top: 1rem;
    gap: 1rem;
}

.td-rewards-applied-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.td-rewards-applied-check {
    width: 24px;
    height: 24px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.875rem;
}

.td-rewards-applied-discount {
    display: block;
    font-size: 0.8rem;
    opacity: 0.9;
}

.td-rewards-remove-btn {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: #fff;
    padding: 0.5rem 1rem;
    font-size: 0.75rem;
    cursor: pointer;
    border-radius: 4px;
    transition: background 0.2s;
}

.td-rewards-remove-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* Insufficient Points */
.td-rewards-insufficient {
    margin: 0.5rem 0 0;
    padding: 0;
    font-size: 0.8rem;
    opacity: 0.8;
}

/* Points to Earn Info */
.td-rewards-earn-info {
    margin-top: 1rem;
    padding: 1rem;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    text-align: center;
}

.td-rewards-earning {
    margin: 0;
    font-size: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.td-rewards-earn-badge {
    display: inline-block;
    background: #28a745;
    color: #fff;
    padding: 0.35rem 0.75rem;
    border-radius: 20px;
    font-size: 1rem;
    font-weight: 700;
}

/* Form */
.td-rewards-form {
    display: flex;
    gap: 0.75rem;
    align-items: flex-end;
    flex-wrap: wrap;
}

.td-rewards-input-group {
    flex: 1;
    min-width: 150px;
}

.td-rewards-input-group label {
    display: block;
    font-size: 0.7rem;
    font-weight: 600;
    margin-bottom: 0.35rem;
    opacity: 0.8;
}

.td-rewards-input-group input {
    width: 100%;
    padding: 0.75rem !important;
    border: 2px solid rgba(255, 255, 255, 0.5) !important;
    border-radius: 4px;
    font-size: 1rem !important;
    background: rgba(255, 255, 255, 0.15) !important;
    color: #fff !important;
    -webkit-appearance: none;
    -moz-appearance: textfield;
}

.td-rewards-input-group input::placeholder {
    color: rgba(255, 255, 255, 0.5) !important;
}

.td-rewards-input-group input:focus {
    outline: none !important;
    border-color: #ffc107 !important;
    background: rgba(255, 255, 255, 0.2) !important;
}

.td-rewards-value {
    display: block;
    font-size: 0.7rem;
    color: #ffc107;
    margin-top: 0.25rem;
}

.td-rewards-apply-btn {
    white-space: nowrap;
    background: #ffc107 !important;
    color: #1a1a1a !important;
    border: none !important;
    padding: 0.5rem 1.5rem !important;
    font-weight: 600 !important;
    border-radius: 4px !important;
    cursor: pointer;
    display: inline-block !important;
    visibility: visible !important;
}

.td-rewards-apply-btn:hover {
    background: #ffca2c !important;
    color: #1a1a1a !important;
}

/* Quick Select */
.td-rewards-quick-select {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.75rem;
    flex-wrap: wrap;
}

.td-rewards-quick-btn {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #fff;
    padding: 0.35rem 0.75rem;
    border-radius: 4px;
    font-size: 0.7rem;
    cursor: pointer;
    transition: all 0.2s;
}

.td-rewards-quick-btn:hover {
    border-color: #ffc107;
    background: #ffc107;
    color: #1a1a1a;
}

/* Message */
.td-rewards-message {
    margin-top: 1rem;
    padding: 0.75rem;
    border-radius: 4px;
    font-size: 0.875rem;
}

.td-rewards-message.success {
    background: rgba(40, 167, 69, 0.3);
    color: #fff;
}

.td-rewards-message.error {
    background: rgba(220, 53, 69, 0.3);
    color: #fff;
}

/* ==========================================================================
   Responsive
   ========================================================================== */

@media (max-width: 600px) {
    .td-rewards-balance-value {
        font-size: 2.5rem;
    }

    .td-rewards-stats {
        grid-template-columns: 1fr;
    }

    .td-rewards-form {
        flex-direction: column;
    }

    .td-rewards-input-group {
        width: 100%;
    }

    .td-rewards-apply-btn {
        width: 100%;
    }

    .td-rewards-table {
        font-size: 0.75rem;
    }

    .td-rewards-table th,
    .td-rewards-table td {
        padding: 0.5rem;
    }

    /* Checkout responsive */
    .td-rewards-checkout-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .td-rewards-redeem-btn {
        width: 100%;
        text-align: center;
        margin-top: 0.75rem;
    }

    .td-rewards-applied {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
    }

    .td-rewards-remove-btn {
        width: 100%;
        text-align: center;
    }
}
