/**
 * ESP Cart Drawer Styles
 *
 * Industrial Parts Cart - Updated Design
 * Slide-out cart drawer with warm cream aesthetic, card-based items, and yellow accents
 */

/* ==========================================================================
   CSS VARIABLES
   ========================================================================== */

:root {
    --cart-bg: #FFFDF7;
    --cart-yellow: #EAB308;
    --cart-yellow-hover: #D9A506;
    --cart-yellow-light: #FFF8E6;
    --cart-yellow-border: #FCEEB5;
    --cart-yellow-text: #B48405;
    --cart-yellow-text-hover: #8F6A04;
}

/* ==========================================================================
   DRAWER CONTAINER
   ========================================================================== */

.esp-cart-drawer {
    position: fixed;
    inset: 0;
    z-index: 100000; /* Above chat widget (99999) */
    pointer-events: none;
    /* Explicit font-family to prevent inheritance from pages with CSS resets */
    font-family: 'MuseoSans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif !important;
}

/* WordPress Admin Bar offset - 32px desktop, 46px mobile */
.admin-bar .esp-cart-drawer {
    top: 32px;
}

@media screen and (max-width: 782px) {
    .admin-bar .esp-cart-drawer {
        top: 46px;
    }
}

.esp-cart-drawer--open {
    pointer-events: auto;
}

/* ==========================================================================
   BACKDROP
   ========================================================================== */

.esp-cart-drawer__backdrop {
    position: absolute;
    inset: 0;
    background-color: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
    opacity: 0;
    transition: opacity 300ms ease;
}

.esp-cart-drawer--open .esp-cart-drawer__backdrop {
    opacity: 1;
}

/* ==========================================================================
   DRAWER PANEL
   ========================================================================== */

.esp-cart-drawer__panel {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    max-width: 460px;
    background-color: var(--cart-bg);
    box-shadow: -4px 0 20px rgba(0, 0, 0, 0.15);
    display: flex;
    flex-direction: column;
    transform: translateX(100%);
    transition: transform 300ms ease-out;
    /* Explicit font-family for all panel content */
    font-family: 'MuseoSans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif !important;
}

.esp-cart-drawer--open .esp-cart-drawer__panel {
    transform: translateX(0);
}

/* ==========================================================================
   HEADER
   ========================================================================== */

.esp-cart-drawer__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid #f3f4f6;
    background-color: var(--cart-bg);
    flex-shrink: 0;
}

.esp-cart-drawer__title {
    font-family: 'MuseoSans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif !important;
    font-size: 1.25rem !important;
    font-weight: 700 !important;
    color: #111827 !important;
    margin: 0 !important;
}

.esp-cart-drawer__close {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: 2.5rem !important;
    height: 2.5rem !important;
    margin-right: -0.5rem !important;
    padding: 0 !important;
    background: transparent !important;
    border: none !important;
    border-radius: 9999px !important;
    color: #9ca3af !important;
    cursor: pointer !important;
    transition: background-color 0.15s ease, color 0.15s ease !important;
    box-shadow: none !important;
    outline: none !important;
}

.esp-cart-drawer__close:hover {
    background-color: #f3f4f6 !important;
    color: #4b5563 !important;
}

.esp-cart-drawer__close svg {
    width: 1.5rem !important;
    height: 1.5rem !important;
}

/* ==========================================================================
   CONTENT AREA
   ========================================================================== */

.esp-cart-drawer__content {
    flex: 1;
    overflow-y: auto;
    overscroll-behavior-y: contain;
    padding: 1rem;
    background-color: var(--cart-bg);
}

/* Hide scrollbar but allow scrolling */
.esp-cart-drawer__content::-webkit-scrollbar {
    width: 0;
    display: none;
}

.esp-cart-drawer__content {
    -ms-overflow-style: none;
    scrollbar-width: none;
}

/* Empty State */
.esp-cart-drawer__empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    padding: 3rem 1.5rem;
    text-align: center;
    color: #9ca3af;
}

.esp-cart-drawer__empty-icon {
    width: 4rem;
    height: 4rem;
    padding: 1rem;
    margin-bottom: 1rem;
    background: #f3f4f6;
    border-radius: 9999px;
    color: #9ca3af;
}

.esp-cart-drawer__empty-text {
    font-size: 1.125rem;
    font-weight: 500;
    margin: 0 0 1rem;
    color: #9ca3af;
}

.esp-cart-drawer__empty-link {
    color: var(--cart-yellow);
    font-weight: 500;
    text-decoration: none;
    cursor: pointer;
}

.esp-cart-drawer__empty-link:hover {
    text-decoration: underline;
}

/* Loading State */
.esp-cart-drawer__loading {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    padding: 0;
}

.esp-cart-drawer__skeleton {
    display: flex;
    gap: 1rem;
    padding: 0.75rem;
    background: #fff;
    border-radius: 0.75rem;
    border: 1px solid #e5e7eb;
}

.esp-cart-drawer__skeleton-img {
    width: 6rem;
    height: 6rem;
    background: linear-gradient(90deg, #e5e7eb 25%, #f3f4f6 50%, #e5e7eb 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: 0.5rem;
    flex-shrink: 0;
}

.esp-cart-drawer__skeleton-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.esp-cart-drawer__skeleton-line {
    height: 1rem;
    background: linear-gradient(90deg, #e5e7eb 25%, #f3f4f6 50%, #e5e7eb 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: 0.25rem;
}

.esp-cart-drawer__skeleton-line--short {
    width: 60%;
}

.esp-cart-drawer__skeleton-line--medium {
    width: 80%;
}

@keyframes shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* ==========================================================================
   CART ITEMS - Card-Based Design
   ========================================================================== */

.esp-cart-drawer__items {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.esp-cart-drawer__item {
    display: flex;
    gap: 1rem;
    padding: 0.75rem;
    background: #fff;
    border-radius: 0.75rem;
    border: 1px solid #e5e7eb;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
    transition: box-shadow 0.15s ease;
}

.esp-cart-drawer__item:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

/* Item Image */
.esp-cart-drawer__item-image {
    position: relative;
    width: 6rem;
    height: 6rem;
    flex-shrink: 0;
    background: #fff;
    border-radius: 0.5rem;
    border: 1px solid #e5e7eb;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem;
}

.esp-cart-drawer__item-image a {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
}

.esp-cart-drawer__item-image img {
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    object-fit: contain;
}

/* Item Info */
.esp-cart-drawer__item-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 0.25rem 0;
}

.esp-cart-drawer__item-details {
    display: flex;
    flex-direction: column;
    gap: 0.125rem;
}

.esp-cart-drawer__item-name {
    font-family: 'MuseoSans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif !important;
    font-size: 0.9375rem;
    font-weight: 700;
    color: #111827;
    margin: 0;
    line-height: 1.3;
}

.esp-cart-drawer__item-name a {
    color: inherit;
    text-decoration: none;
}

.esp-cart-drawer__item-name a:hover {
    color: var(--cart-yellow-text);
}

.esp-cart-drawer__item-sku {
    font-size: 0.75rem;
    font-weight: 500;
    color: #6b7280;
    margin: 0;
}

.esp-cart-drawer__item-unit-price {
    font-size: 0.875rem;
    font-weight: 400;
    color: #6b7280;
    margin: 0.375rem 0 0;
}

/* Item Variations/Options */
.esp-cart-drawer__item-options {
    margin-top: 0.5rem;
    padding-top: 0.5rem;
    border-top: 1px dashed #e5e7eb;
}

.esp-cart-drawer__item-option {
    font-size: 0.8125rem;
    color: #6b7280;
    margin: 0.125rem 0;
}

.esp-cart-drawer__item-option strong {
    color: #4b5563;
    font-weight: 500;
}

/* Item Actions Row */
.esp-cart-drawer__item-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 0.75rem;
}

.esp-cart-drawer__item-controls {
    display: flex;
    align-items: center;
    gap: 1rem;
}

/* Quantity Control Pill */
.esp-cart-drawer__qty-pill {
    display: flex !important;
    align-items: center !important;
    background: var(--cart-yellow-light) !important;
    border-radius: 9999px !important;
    padding: 0.125rem 0.25rem !important;
    border: 1px solid var(--cart-yellow-border) !important;
}

.esp-cart-drawer__qty-btn {
    width: 1.5rem !important;
    height: 1.5rem !important;
    padding: 0 !important;
    background: transparent !important;
    border: none !important;
    border-radius: 9999px !important;
    color: var(--cart-yellow-text) !important;
    font-size: 0.875rem !important;
    font-weight: 700 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    cursor: pointer !important;
    transition: background-color 0.15s ease !important;
    box-shadow: none !important;
    outline: none !important;
    -webkit-appearance: none !important;
    -moz-appearance: none !important;
    appearance: none !important;
}

.esp-cart-drawer__qty-btn:hover {
    background: var(--cart-yellow-border) !important;
}

.esp-cart-drawer__qty-btn:disabled {
    opacity: 0.4 !important;
    cursor: not-allowed !important;
}

.esp-cart-drawer__qty-btn svg {
    width: 0.75rem !important;
    height: 0.75rem !important;
    stroke-width: 3 !important;
}

.esp-cart-drawer__qty-count {
    min-width: 1.25rem !important;
    text-align: center !important;
    font-size: 0.875rem !important;
    font-weight: 700 !important;
    color: #111827 !important;
}

/* Remove Button */
.esp-cart-drawer__remove-btn {
    display: flex !important;
    align-items: center !important;
    gap: 0.25rem !important;
    padding: 0 !important;
    background: transparent !important;
    border: none !important;
    color: var(--cart-yellow-text) !important;
    font-family: 'MuseoSans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif !important;
    font-size: 0.8125rem !important;
    font-weight: 500 !important;
    cursor: pointer !important;
    transition: color 0.15s ease !important;
    box-shadow: none !important;
    outline: none !important;
    -webkit-appearance: none !important;
    -moz-appearance: none !important;
    appearance: none !important;
    text-decoration: none !important;
}

.esp-cart-drawer__remove-btn:hover {
    color: var(--cart-yellow-text-hover) !important;
}

.esp-cart-drawer__remove-btn:hover svg {
    transform: scale(1.1) !important;
}

.esp-cart-drawer__remove-btn svg {
    width: 0.875rem !important;
    height: 0.875rem !important;
    transition: transform 0.15s ease !important;
}

.esp-cart-drawer__remove-btn:disabled {
    opacity: 0.5 !important;
    cursor: not-allowed !important;
}

/* Item Line Total */
.esp-cart-drawer__item-total {
    font-size: 1rem;
    font-weight: 700;
    color: #111827;
}

/* Removing state */
.esp-cart-drawer__item--removing {
    opacity: 0.5;
    pointer-events: none;
}

/* Updating state - pulse animation on qty count */
.esp-cart-drawer__qty-pill:has(.esp-cart-drawer__qty-btn:disabled) .esp-cart-drawer__qty-count {
    animation: qty-pulse 0.8s ease-in-out infinite;
}

@keyframes qty-pulse {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.1); opacity: 0.7; }
}

/* ==========================================================================
   FOOTER
   ========================================================================== */

.esp-cart-drawer__footer {
    background: var(--cart-bg);
    padding: 1.5rem;
    padding-top: 0.5rem;
    border-top: none;
    flex-shrink: 0;
    padding-bottom: 2rem;
}

.esp-cart-drawer__totals {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    padding-top: 0.5rem;
    margin-bottom: 1rem;
}

.esp-cart-drawer__total-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.esp-cart-drawer__total-label {
    font-size: 1rem;
    font-weight: 400;
    color: #4b5563;
}

.esp-cart-drawer__total-value {
    font-size: 1.25rem;
    font-weight: 700;
    color: #111827;
}

.esp-cart-drawer__total-value--small {
    font-size: 1rem;
    font-weight: 500;
    color: #111827;
}

/* Legacy subtotal support */
.esp-cart-drawer__subtotal {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
}

.esp-cart-drawer__subtotal-label {
    font-size: 1rem;
    font-weight: 400;
    color: #4b5563;
}

.esp-cart-drawer__subtotal-value {
    font-size: 1.25rem;
    font-weight: 700;
    color: #111827;
}

/* Checkout Button */
.esp-cart-drawer__checkout {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 0.5rem !important;
    width: 100% !important;
    padding: 0.875rem 1.5rem !important;
    background: var(--cart-yellow) !important;
    color: #fff !important;
    font-family: 'MuseoSans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif !important;
    font-size: 1.125rem !important;
    font-weight: 700 !important;
    text-decoration: none !important;
    border: none !important;
    border-radius: 9999px !important;
    cursor: pointer !important;
    box-shadow: 0 4px 14px rgba(234, 179, 8, 0.4) !important;
    transition: background-color 0.15s ease, box-shadow 0.15s ease, transform 0.1s ease !important;
    -webkit-appearance: none !important;
    -moz-appearance: none !important;
    appearance: none !important;
    outline: none !important;
}

.esp-cart-drawer__checkout:hover {
    background: var(--cart-yellow-hover) !important;
    box-shadow: 0 6px 20px rgba(234, 179, 8, 0.5) !important;
    color: #fff !important;
}

.esp-cart-drawer__checkout:active {
    transform: scale(0.99) !important;
}

.esp-cart-drawer__checkout svg {
    width: 1.25rem !important;
    height: 1.25rem !important;
    display: none !important; /* Hide icon for cleaner look */
}

/* ==========================================================================
   TOAST NOTIFICATION
   ========================================================================== */

.esp-toast {
    position: fixed;
    top: 1rem;
    left: 50%;
    transform: translateX(-50%) translateY(-100%);
    z-index: 100001; /* Above cart drawer */
    max-width: calc(100% - 2rem);
    width: auto;
    min-width: 20rem;
    padding: 1rem 1.25rem;
    background: #10b981;
    color: #fff;
    border-radius: 0.5rem;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.2);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    opacity: 0;
    transition: transform 0.3s ease, opacity 0.3s ease;
    font-family: 'MuseoSans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif !important;
}

.esp-toast--visible {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

.esp-toast__icon {
    flex-shrink: 0;
    width: 1.5rem;
    height: 1.5rem;
}

.esp-toast__content {
    flex: 1;
    font-size: 0.9375rem;
    line-height: 1.4;
}

.esp-toast__content a {
    color: #fff;
    text-decoration: underline;
    font-weight: 600;
}

.esp-toast__content a:hover {
    text-decoration: none;
}

.esp-toast__close {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 1.75rem;
    height: 1.75rem;
    padding: 0;
    background: rgba(255, 255, 255, 0.2);
    border: none;
    border-radius: 0.25rem;
    color: #fff;
    cursor: pointer;
    transition: background-color 0.15s ease;
}

.esp-toast__close:hover {
    background: rgba(255, 255, 255, 0.3);
}

.esp-toast__close svg {
    width: 1rem;
    height: 1rem;
}

/* Error toast variant */
.esp-toast--error {
    background: #ef4444;
}

/* ==========================================================================
   BODY SCROLL LOCK
   ========================================================================== */

body.esp-cart-drawer-open {
    overflow: hidden;
}

/* ==========================================================================
   RESPONSIVE - Mobile First (Designer: w-full sm:w-[460px])
   ========================================================================== */

/* Mobile: Full width panel */
@media (max-width: 639px) {
    .esp-cart-drawer__panel {
        max-width: 100%;
    }

    .esp-cart-drawer__header {
        padding: 1rem;
    }

    .esp-cart-drawer__content {
        padding: 0.75rem;
    }

    .esp-cart-drawer__footer {
        padding: 1rem;
        padding-bottom: 1.5rem;
    }

    .esp-cart-drawer__item {
        padding: 0.625rem;
        gap: 0.75rem;
    }

    .esp-cart-drawer__item-image {
        width: 5rem;
        height: 5rem;
        padding: 0.375rem;
    }

    .esp-cart-drawer__skeleton-img {
        width: 5rem;
        height: 5rem;
    }

    .esp-cart-drawer__item-name {
        font-size: 0.875rem;
    }

    .esp-cart-drawer__item-unit-price {
        font-size: 0.8125rem;
    }

    /* Stack actions vertically on very small screens */
    .esp-cart-drawer__item-actions {
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    .esp-cart-drawer__item-total {
        width: 100%;
        text-align: right;
        margin-top: 0.25rem;
    }

    /* Slightly larger touch targets on mobile */
    .esp-cart-drawer__qty-btn {
        width: 1.75rem !important;
        height: 1.75rem !important;
    }

    .esp-cart-drawer__qty-count {
        min-width: 1.5rem !important;
        font-size: 0.9375rem !important;
    }

    .esp-cart-drawer__remove-btn {
        font-size: 0.875rem !important;
    }

    .esp-cart-drawer__remove-btn svg {
        width: 1rem !important;
        height: 1rem !important;
    }

    /* Toast notification */
    .esp-toast {
        left: 1rem;
        right: 1rem;
        transform: translateX(0) translateY(-100%);
        width: auto;
        min-width: 0;
    }

    .esp-toast--visible {
        transform: translateX(0) translateY(0);
    }

    /* Checkout button - slightly smaller on mobile */
    .esp-cart-drawer__checkout {
        font-size: 1rem !important;
        padding: 0.75rem 1.25rem !important;
    }
}

/* Very small screens (< 375px) - extra adjustments */
@media (max-width: 374px) {
    .esp-cart-drawer__item {
        padding: 0.5rem;
        gap: 0.5rem;
    }

    .esp-cart-drawer__item-image {
        width: 4rem;
        height: 4rem;
    }

    .esp-cart-drawer__item-controls {
        gap: 0.5rem;
    }

    .esp-cart-drawer__qty-pill {
        padding: 0.0625rem 0.125rem !important;
    }
}
