/**
 * Azarias Books - Hardened Sell Cart & Checkout Styles
 */

/* --- Elite Security: Honeypot Trap --- */
.hp-field-container {
    position: absolute;
    left: -9999px;
    top: -9999px;
    height: 1px;
    width: 1px;
    overflow: hidden;
    pointer-events: none;
}

/* Header Area - RESTORED VISIBILITY */
.cart-header {
    background-color: var(--az-navy);
    color: var(--az-cream-tint); /* Restore cream text for secondary lines */
    padding: 4rem 0 2rem;
    margin-bottom: 3rem;
    border-bottom: 5px solid var(--az-bronze);
}

.cart-header h1 {
    /* FIX: Explicitly set to Bronze to stand out against Navy background */
    color: var(--az-bronze) !important; 
    text-shadow: 0 2px 4px rgba(0,0,0,0.2);
    font-family: 'Merriweather', serif;
}

.cart-header p {
    color: var(--az-cream-tint) !important;
    opacity: 0.85;
}

/* --- FIX: STICKY SIDEBAR BEHAVIOR --- */
/* Ensures the sidebar is contained and doesn't overlap the footer */
.cart-main-row {
    min-height: 800px; 
    align-items: flex-start;
}

.cart-summary-card {
    background: white;
    border: 1px solid rgba(0,0,0,0.1);
    border-radius: 8px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.05);
    position: sticky;
    top: 120px; 
    margin-bottom: 2rem;
    z-index: 5;
}

.cart-item-row {
    background: white;
    border: 1px solid #eee;
    border-radius: 8px;
    margin-bottom: 1rem;
    padding: 1.5rem;
    transition: all 0.2s ease;
    animation: cartFadeIn 0.4s ease-out;
}

.cart-item-row.is-over-limit {
    border: 2px solid #dc3545;
    background-color: #fff8f8;
}

/* Keep cart metadata and state text readable across all rendering engines. */
.cart-item-row .text-muted {
    color: #4b5563 !important;
}

.cart-item-row .text-success {
    color: #146c43 !important;
}

/* Book Covers */
.book-cover-thumb {
    width: 60px;
    height: 90px;
    object-fit: cover;
    border-radius: 4px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

.book-cover-thumb.bg-secondary {
    background-color: #343a40 !important;
    color: #ffffff !important;
}

/* --- Action Buttons --- */
.btn-update-qty {
    font-size: 0.75rem;
    text-decoration: underline;
    color: #4b5563;
    background: none;
    border: none;
    padding: 0;
    margin-top: 5px;
    cursor: pointer;
    font-weight: 600;
}

.btn-update-qty:hover {
    color: var(--az-navy);
}

.btn-remove-item {
    color: #dc3545;
    background: none;
    border: none;
    font-size: 1.2rem;
    transition: 0.2s;
    cursor: pointer;
    padding: 5px;
}

.btn-remove-item:hover {
    transform: scale(1.15);
    color: #a71d2a;
}

/* Inputs & Validation */
.qty-input {
    width: 65px;
    text-align: center;
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 5px;
    font-weight: 600;
    color: var(--az-navy);
}

.qty-input.invalid-qty {
    border-color: #dc3545;
    color: #dc3545;
    background-color: #ffe6e6;
    outline: none;
}

.qty-limit-text {
    font-size: 0.7rem;
    color: #dc3545;
    margin-top: 4px;
    font-weight: 500;
}

.form-control.is-invalid {
    border-color: #dc3545 !important;
    background-color: #fff8f8 !important;
}

.validation-error {
    color: #dc3545;
    font-size: 0.8rem;
    margin-top: 4px;
    display: none;
    font-weight: 600;
}

/* Global Error Box */
.general-error-box {
    background-color: #ffe6e6;
    color: #b02a37;
    border: 1px solid #f1aeb5;
    padding: 12px;
    border-radius: 6px;
    margin-bottom: 1.5rem;
    font-size: 0.9rem;
    text-align: left;
}

/*
 * Keep the cart entrance motion without animating opacity.
 * Axe can scan during the WebKit transition; opacity blending would temporarily
 * reduce otherwise-compliant foreground/background contrast below WCAG 2 AA.
 */
@keyframes cartFadeIn {
    from { transform: translateY(10px); }
    to { transform: translateY(0); }
}

.checkout-step-title {
    font-family: 'Merriweather', serif;
    color: var(--az-navy);
    border-bottom: 2px solid var(--az-bronze);
    padding-bottom: 10px;
    margin-bottom: 20px;
    margin-top: 2rem;
}

/* --- Browser E2E / WCAG contrast hardening --- */
/* Keep sell-cart controls readable even while WebKit is resolving transient UI layers. */
.btn-search-submit,
.nav-cart-link,
#submitBtn {
    background-color: #051b2c !important;
    border-color: #051b2c !important;
    color: #ffffff !important;
    opacity: 1 !important;
}

.isbn-sidebar-input {
    background-color: #163247 !important;
    border-color: #9fb3c8 !important;
    color: #ffffff !important;
    opacity: 1 !important;
}

.isbn-sidebar-input::placeholder {
    color: #ffffff !important;
    opacity: 1 !important;
}

.isbn-sidebar-btn,
.isbn-sidebar-btn:hover,
.isbn-sidebar-btn:focus-visible {
    background-color: #ffffff !important;
    border: 2px solid #ffffff !important;
    color: #051b2c !important;
    opacity: 1 !important;
}

.site-footer .btn-outline-light,
.footer-modal-link {
    color: #ffffff !important;
    opacity: 1 !important;
}

.site-footer .btn-outline-light {
    border-color: #ffffff !important;
}

/* --- RESPONSIVE ADJUSTMENTS --- */
@media (max-width: 991px) {
    .cart-summary-card {
        position: static; 
        margin-top: 2rem;
    }
    .cart-main-row {
        min-height: auto;
    }
}

@media (max-width: 575.98px) {
    .cart-item-row {
        flex-wrap: wrap;
        align-items: flex-start !important;
        gap: 1rem;
        padding: 1rem;
        scroll-margin-top: 11rem;
    }

    .cart-item-row > .me-3 {
        margin-right: 0 !important;
    }

    .cart-item-row > .flex-grow-1 {
        min-width: 0;
        flex: 1 1 calc(100% - 5.5rem);
    }

    .cart-item-row > .text-end {
        min-width: 0 !important;
        margin-left: 0 !important;
        flex: 1 1 auto;
    }

    .cart-item-row > .ms-4 {
        margin-left: auto !important;
        flex: 0 0 auto;
    }

    .cart-item-row .qty-input,
    .cart-item-row .btn-update-qty,
    .cart-item-row .btn-remove-item {
        scroll-margin-top: 11rem;
    }
}
