/* ==========================================================================
   CodePaks Slide-Over Cart Drawer (Silicon Valley Pure Light Style)
   ========================================================================== */

/* 1. Transparent Outside Click Interceptor (No Dark Mask) */
.codepaks-drawer-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: transparent; /* Strictly transparent, background retains 100% brightness */
    z-index: 99998;
    display: none;
    cursor: default;
    pointer-events: auto;
}

.codepaks-drawer-overlay.is-active {
    display: block;
}

/* 2. Drawer Core Frame */
.codepaks-cart-drawer {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    max-width: 420px; /* Big-tech desktop standard width */
    height: 100vh;
    background-color: #ffffff;
    border-left: 1px solid rgba(226, 232, 240, 0.9); /* Slate-200 boundary line */
    box-shadow: -12px 0 35px -4px rgba(15, 23, 42, 0.08), -4px 0 12px -2px rgba(15, 23, 42, 0.04);
    z-index: 99999;
    transform: translateX(100%); /* Off-canvas initially */
    transition: transform 0.36s cubic-bezier(0.16, 1, 0.3, 1); /* Apple/Linear standard curve */
    will-change: transform;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, Helvetica, Arial, sans-serif;
    box-sizing: border-box;
}

.codepaks-cart-drawer.is-open {
    transform: translateX(0);
}

.codepaks-cart-drawer-inner {
    display: flex;
    flex-direction: column;
    height: 100%;
    position: relative;
    background: #ffffff;
}

/* 3. Drawer Header */
.codepaks-drawer-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid #f1f5f9;
    background: #ffffff;
}

.codepaks-drawer-title-group {
    display: flex;
    align-items: center;
    gap: 10px;
}

.codepaks-drawer-icon {
    color: #0f172a;
}

.codepaks-drawer-title {
    font-size: 14px;
    font-weight: 700;
    letter-spacing: 0.06em;
    color: #0f172a;
    text-transform: uppercase;
}

.codepaks-cart-count-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    background-color: #f5f3ff;
    color: #7c3aed;
    font-size: 11px;
    font-weight: 700;
    border-radius: 9999px;
    border: 1px solid #ede9fe;
}

.codepaks-drawer-close {
    background-color: #f1f5f9; 
    border: 1px solid #e2e8f0;
    color: #475569;           
    cursor: pointer;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.codepaks-drawer-close:hover {
    color: #0f172a;            
    background-color: #e2e8f0; 
    border-color: #cbd5e1;
    transform: scale(1.05);
}

/* 4. Cart Content & Items List */
.codepaks-cart-drawer-content {
    display: flex;
    flex-direction: column;
    flex: 1;
    overflow: hidden;
}

.codepaks-cart-items-scroll {
    flex: 1;
    overflow-y: auto;
    padding: 16px 24px;
}

/* Slim scrollbar */
.codepaks-cart-items-scroll::-webkit-scrollbar {
    width: 4px;
}
.codepaks-cart-items-scroll::-webkit-scrollbar-track {
    background: transparent;
}
.codepaks-cart-items-scroll::-webkit-scrollbar-thumb {
    background: #e2e8f0;
    border-radius: 4px;
}

.codepaks-cart-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 0;
    border-bottom: 1px solid #f8fafc;
    transition: opacity 0.25s ease, transform 0.25s ease;
}

.codepaks-cart-item.is-removing {
    opacity: 0;
    transform: translateX(16px);
}

.codepaks-item-thumb {
    width: 52px;
    height: 52px;
    border-radius: 10px;
    overflow: hidden;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    flex-shrink: 0;
}

.codepaks-item-thumb-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.codepaks-item-info {
    flex: 1;
    min-width: 0;
}

.codepaks-item-title {
    font-size: 13px;
    font-weight: 600;
    color: #1e293b;
    text-decoration: none;
    line-height: 1.35;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    transition: color 0.15s ease;
}

.codepaks-item-title:hover {
    color: #7c3aed;
}

.codepaks-item-meta {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 5px;
}

.codepaks-item-price {
    font-size: 13px;
    font-weight: 700;
    color: #0f172a;
}

.codepaks-item-dot {
    color: #cbd5e1;
    font-size: 12px;
}

.codepaks-badge-license {
    display: inline-block;
    font-size: 10px;
    font-weight: 600;
    color: #059669;
    background: #ecfdf5;
    padding: 1px 6px;
    border-radius: 4px;
    border: 1px solid #d1fae5;
}

.codepaks-item-remove {
    background-color: #f8fafc;
    border: 1px solid #f1f5f9;
    color: #64748b;           
    cursor: pointer;
    width: 30px;
    height: 30px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.codepaks-item-remove:hover {
    color: #ef4444;           
    background-color: #fef2f2;
    border-color: #fee2e2;
    transform: scale(1.08);
}

/* 5. Sticky Footer */
.codepaks-drawer-footer {
    padding: 20px 24px 24px 24px;
    border-top: 1px solid #f1f5f9;
    background: #ffffff;
    box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.02);
}

.codepaks-subtotal-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.codepaks-subtotal-label {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.05em;
    color: #64748b;
    text-transform: uppercase;
}

.codepaks-subtotal-amount {
    font-size: 18px;
    font-weight: 800;
    color: #0f172a;
}

.codepaks-btn-checkout {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 13px 18px;
    border-radius: 12px;
    background: linear-gradient(135deg, #2436e4 0%, #5b32e8 100%);
    color: #ffffff;
    font-size: 14px;
    font-weight: 700;
    text-decoration: none;
    box-shadow: 0 4px 14px rgba(36, 54, 228, 0.28);
    transition: all 0.2s ease;
    box-sizing: border-box;
}
.codepaks-btn-checkout:hover {
    filter: brightness(1.1);
    transform: translateY(-1px);
    box-shadow: 0 6px 18px rgba(36, 54, 228, 0.35);
}

.codepaks-btn-checkout:hover {
    box-shadow: 0 6px 20px rgba(124, 58, 237, 0.38);
    transform: translateY(-1px);
    color: #ffffff;
}

.codepaks-btn-checkout:active {
    transform: translateY(0);
}

/* Secondary Link */
.codepaks-btn-continue {
    display: block;
    width: 100%;
    margin-top: 12px;
    background: transparent;
    border: none;
    font-size: 12px;
    font-weight: 500;
    color: #64748b;
    text-align: center;
    cursor: pointer;
    transition: color 0.15s ease;
}

.codepaks-btn-continue:hover {
    color: #0f172a;
    text-decoration: underline;
}

/* 6. Empty State */
.codepaks-cart-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 60px 24px;
    flex: 1;
}

.codepaks-cart-empty-icon {
    width: 68px;
    height: 68px;
    border-radius: 50%;
    background: #f8fafc;
    border: 1px dashed #cbd5e1;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 16px;
}

.codepaks-cart-empty-text {
    font-size: 15px;
    font-weight: 700;
    color: #0f172a;
    margin: 0 0 6px 0;
}

.codepaks-cart-empty-sub {
    font-size: 12px;
    color: #64748b;
    margin: 0 0 20px 0;
    line-height: 1.5;
    max-width: 240px;
}

.codepaks-btn-start-browsing {
    padding: 9px 20px;
    border-radius: 8px;
    background: #0f172a;
    color: #ffffff;
    font-size: 12px;
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: background-color 0.15s ease;
}

.codepaks-btn-start-browsing:hover {
    background: #1e293b;
}

/* 7. Mobile Viewport Optimization (< 640px) */
@media (max-width: 640px) {
    .codepaks-cart-drawer {
        max-width: 100%; /* Full screen on phones for maximum comfort */
    }
    .codepaks-drawer-header {
        padding: 16px 20px;
    }
    .codepaks-cart-items-scroll {
        padding: 12px 20px;
    }
    .codepaks-drawer-footer {
        padding: 16px 20px 24px 20px;
    }
}

/* Fix: Suppress WooCommerce legacy injected "View cart" text link */
.added_to_cart.wc-forward {
    display: none !important;
}

/* Fix: Empty cart button nowrap fix */
.codepaks-btn-start-browsing {
    white-space: nowrap !important;
    min-width: 140px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* 彻底隐藏 WooCommerce 默认追加的 View cart 链接 */
.added_to_cart.wc-forward {
    display: none !important;
}


