/**
 * Checkout Page Styles
 */

.checkout-page {
    padding-bottom: 2rem;
}

.checkout {
    max-width: 800px;
    margin: 0 auto;
}

/* Empty Cart State */
.checkout__empty-state {
    background: var(--color-white);
    border: 1px solid var(--color-line-3);
    padding: 4rem 2rem;
    text-align: center;
    margin-top: 2rem;
}

.checkout__empty-state-content {
    max-width: 400px;
    margin: 0 auto;
}

.checkout__empty-state h2 {
    font-family: "Maax Bold";
    font-weight: 400;
    margin-bottom: 1rem;
}

.checkout__empty-state p {
    line-height: 1.6;
}

.checkout__empty-state .button {
    min-width: 150px;
}

/* Auth Section */
.checkout__section {
    background: var(--color-white);
    border: 1px solid #e0e0e0;
    border-radius: 0;
    padding: 2rem;
    margin-bottom: 2rem;
}

.checkout__section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.checkout__section h2 {
    margin-top: 0;
    margin-bottom: 1rem;
    font-size: 1.3rem;
}

.checkout__section-header h2 {
    margin-bottom: 0;
}

.checkout__section-description {
    color: #666;
    margin-bottom: 1.5rem;
}

.checkout__section--payment {
    transition: opacity 0.2s ease, border-color 0.2s ease, background-color 0.2s ease;
}

.checkout__section--payment.checkout__section--locked {
    border-color: var(--color-line-2);
    background-color: var(--color-background-2);
}

.checkout__payment-lock-message {
    margin-bottom: 1.5rem;
    color: var(--color-text-2);
}

.checkout__payment-lock-message.is-ready {
    color: var(--color-green);
    font-family: "Maax Medium";
    font-weight: 400;
}

.checkout__payment-option-content.is-locked,
.checkout__section--payment.checkout__section--locked #stripe-submit-section {
    opacity: 0.5;
    pointer-events: none;
}

.checkout__section--payment.checkout__section--locked .checkout__payment-option-header {
    cursor: not-allowed;
}

.checkout__section--payment.checkout__section--locked .checkout__payment-option-title,
.checkout__section--payment.checkout__section--locked .checkout__payment-help-text {
    color: var(--color-text-2);
}

#checkout-submit-btn:disabled,
#checkout-submit-btn[disabled] {
    background: var(--color-gray-light);
    color: var(--color-gray-mid) !important;
    cursor: not-allowed;
    pointer-events: none;
}

/* Required Section Indicators */
.checkout__required-legend {
    font-size: 0.9rem;
    color: var(--color-text-2);
    margin-bottom: 1.5rem;
    padding-left: 0.5rem;
}

.required-asterisk {
    color: var(--color-red);
    font-family: "Maax Medium";
    font-weight: 400;
    margin-left: 0.25rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 0.9rem;
    line-height: 1;
    opacity: 1;
    transform: scale(1);
    transition: opacity 0.3s ease, transform 0.3s ease;
}

/* Required sections with colored left borders */
.checkout__section--required {
    border-left: 4px solid var(--color-yellow);
    transition: border-color 0.3s ease;
    position: relative;
}

/* Section states */
.checkout__section--required[data-section-state="incomplete"] {
    border-left-color: var(--color-yellow);
}

.checkout__section--required[data-section-state="complete"] {
    border-left-color: var(--color-green);
}

.checkout__section--required[data-section-state="error"] {
    border-left-color: var(--color-red);
}

/* Checkmark indicator */
.section-checkmark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 0.9rem;
    margin-left: -0.9rem;
    color: var(--color-green);
    font-family: "Maax Bold";
    font-weight: 400;
    font-size: 1rem;
    line-height: 1;
    vertical-align: middle;
    transform: scale(1.2);
    opacity: 0;
    transition: opacity 0.3s ease, transform 0.3s ease;
}

/* Hide asterisk and show checkmark when complete */
.checkout__section--required[data-section-state="complete"] .required-asterisk {
    opacity: 0;
    transform: scale(0);
}

.checkout__section--required[data-section-state="complete"] .section-checkmark {
    display: inline-block !important;
    opacity: 1;
    transform: scale(1.2);
}

/* Checkout Items */
.checkout__items-list {
    margin-bottom: 1.5rem;
}

.checkout__item {
    display: grid;
    grid-template-columns: 60px 1fr auto;
    gap: 1rem;
    padding: 1rem 0;
    border-bottom: 1px solid #f5f5f5;
}

.checkout__item:last-child {
    border-bottom: none;
}

.checkout__item-image {
    width: 60px;
    height: 90px;
    object-fit: cover;
}

.checkout__item-title {
    font-family: "Maax Medium";
    font-weight: 400;
    margin-bottom: 0.25rem;
}

.checkout__item-meta {
    font-size: 0.9rem;
    color: #666;
}

.checkout__item-total {
    font-family: "Maax Medium";
    font-weight: 400;
    text-align: right;
}

.checkout__subtotal {
    display: flex;
    justify-content: space-between;
    padding-top: 1rem;
    border-top: 2px solid #e0e0e0;
}

/* Form Styles */
.checkout__form-group {
    margin-bottom: 1.5rem;
}

.checkout__form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-family: "Maax Medium";
    font-weight: 400;
}

.checkout__form-group input,
.checkout__form-group select {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--color-gray-mid);
    border-radius: 0;
    font-size: 1rem;
}

.checkout__form-group input:focus,
.checkout__form-group select:focus {
    outline: none;
    border-color: var(--color-black);
}

.checkout__form-group input.error,
.checkout__form-group select.error {
    border-color: var(--color-red, #d32f2f);
}

.checkout__form-group input.success,
.checkout__form-group select.success {
    border-color: var(--color-green, #14bfa1);
}

.checkout__form-group input.warning,
.checkout__form-group select.warning {
    border-color: var(--color-orange, #ff9f37);
}

.checkout__form-group .field-error {
    color: var(--color-red, #d32f2f);
    font-size: 0.875rem;
    margin-top: 0.25rem;
    display: block;
}

.checkout__form-group .field-success {
    color: var(--color-green, #14bfa1);
    font-size: 0.875rem;
    margin-top: 0.25rem;
    display: block;
}

.checkout__form-group .field-warning {
    color: var(--color-orange, #ff9f37);
    font-size: 0.875rem;
    margin-top: 0.25rem;
    display: block;
}

.checkout__form-group .field-loading {
    color: var(--color-gray-dark, #757575);
    font-size: 0.875rem;
    margin-top: 0.25rem;
    display: block;
}

.checkout__form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

/* Promo Code */
.checkout__promo-input {
    display: flex;
    gap: 0.5rem;
}

.checkout__promo-input input {
    flex: 1;
}

/* Message Boxes (Tax and Promo) */
.checkout__message {
    margin-top: 1rem;
    padding: 0.5rem;
    border-radius: 0;
    font-size: 0.9rem;
    display: none;
}

.checkout__message.success {
    margin-top: 1rem;
    background: #e8f5e9;
    color: #2e7d32;
    border: 1px solid #a5d6a7;
}

.checkout__message.error {
    background: #ffebee;
    color: #c62828;
    border: 1px solid #ef9a9a;
}

/* Order Total */
.checkout__total-breakdown {
    background: #f5f5f5;
    padding: 1.5rem;
    border-radius: 0;
}

.checkout__total-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.75rem;
}

.checkout__total-row--total {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 2px solid var(--color-gray-mid);
    font-size: 1.2rem;
}

/* Express Checkout (Apple Pay / Google Pay) */
.checkout__express {
    margin-bottom: 0;
}

#payment-request-button {
    margin-bottom: 1rem;
}

.checkout__express-divider {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin: 1.5rem 0 0;
    color: var(--color-text-2);
    font-size: 0.875rem;
    text-transform: uppercase;
    font-family: "Maax Medium";
    font-weight: 400;
}

.checkout__express-divider::before,
.checkout__express-divider::after {
    content: '';
    flex: 1;
    border-top: 1px solid var(--color-line);
}

/* Payment Method Selection */
.checkout__payment-option {
    border: 2px solid var(--color-line-3);
    margin-bottom: 1rem;
    border-radius: 0;
    transition: all 0.2s ease;
}

.checkout__payment-option:last-child {
    margin-bottom: 0;
}

.checkout__payment-option-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1.25rem 1.5rem;
    cursor: pointer;
    transition: background-color 0.2s ease;
    margin: 0;
}

.checkout__payment-option-header:hover {
    background-color: var(--color-background-2);
}

.checkout__payment-option-header input[type="radio"] {
    margin: 0;
    width: 20px;
    height: 20px;
    cursor: pointer;
    flex-shrink: 0;
}

.checkout__payment-option-title {
    font-family: "Maax Medium";
    font-weight: 400;
    font-size: 1.1rem;
    flex-grow: 1;
}

.checkout__payment-option-icons {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-shrink: 0;
}

.checkout__payment-option-icons img {
    height: 24px;
    width: auto;
}

/* Selected state */
.checkout__payment-option:has(input[type="radio"]:checked) {
    border-color: var(--color-black);
    background-color: var(--color-white);
}

.checkout__payment-option:has(input[type="radio"]:checked) .checkout__payment-option-header {
    background-color: var(--color-background-2);
}

/* Payment content area */
.checkout__payment-option-content {
    padding: 1.5rem;
    display: none;
}

.checkout__payment-option:has(input[type="radio"]:checked) .checkout__payment-option-content {
    display: block;
}

#checkout-form:has(input[name="payment_method"][value="paypal"]:checked) #stripe-submit-section {
    display: none;
}

#checkout-form:has(input[name="payment_method"][value="stripe"]:checked) #stripe-submit-section {
    display: block;
}

.checkout__payment-help-text {
    color: var(--color-text-2);
    font-size: 0.9rem;
    margin-bottom: 1rem;
    line-height: 1.5;
}

/* Stripe Payment Element */
#stripe-payment-element {
    padding: 0.75rem;
    border: 1px solid var(--color-line-3);
    border-radius: 4px;
    background: var(--color-white);
}

/* PayPal Button Container */
#paypal-button-container {
    min-height: 150px;
    position: relative;
}

#paypal-button-container:empty::after {
    content: 'Loading PayPal...';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: var(--color-text-2);
}

.checkout__payment-errors {
    color: #c62828;
    margin-top: 0.5rem;
    font-size: 0.9rem;
}

/* Terms Agreement */
.checkout__terms-agreement {
    margin-bottom: 0;
}

.checkout__terms-label {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    cursor: pointer;
    margin: 0;
}

.checkout__terms-label input[type="checkbox"] {
    margin-top: 0.25rem;
    width: 18px;
    height: 18px;
    cursor: pointer;
    flex-shrink: 0;
}

.checkout__terms-text {
    font-size: 0.9rem;
    line-height: 1.6;
    color: var(--color-text);
}

.checkout__terms-text a {
    color: var(--color-black);
    text-decoration: underline;
}

.checkout__terms-text a:hover {
    text-decoration: none;
}

/* Checkout Actions */
.checkout__actions {
    margin-top: 2rem;
}

.spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid var(--color-white);
    border-radius: 50%;
    border-top-color: transparent;
    animation: spinner 0.6s linear infinite;
    margin-left: 0.5rem;
}

@keyframes spinner {
    to { transform: rotate(360deg); }
}

/* Loading State */
.checkout__loading {
    text-align: center;
    padding: 3rem;
    color: #666;
}

/* Owned Items Styling */
.checkout__item--owned {
    opacity: 0.6;
    background: var(--color-background-2);
    position: relative;
}

.checkout__item--owned .checkout__item-title {
    color: var(--color-text-2);
}

.checkout__item--owned .checkout__item-total {
    color: var(--color-text-2);
}

.checkout__item-total--excluded {
    text-decoration: line-through;
    color: var(--color-text-2);
}

.checkout__item__owned-badge {
    display: inline-block;
    background: var(--color-green);
    color: var(--color-white);
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
    font-family: "Maax Medium";
    font-weight: 400;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Responsive */
@media (max-width: 768px) {
    .checkout__form-row {
        grid-template-columns: 1fr;
    }

    .checkout__item {
        grid-template-columns: 1fr;
    }

    .checkout__item-image {
        display: none;
    }
}
