/**
 * Advanced WooCommerce Floating Minicart Stylesheet
 * Architecture Optimization & Modern Component Styling Engine
 */

 :root {
    /* Color Palette Configurations */
    --awfm-brand-primary: #000000;
    --awfm-brand-secondary: #f1f5f9;
    --awfm-brand-accent: #f43f5e;
    --awfm-text-main: #0f172a;
    --awfm-text-muted: #64748b;
    --awfm-bg-surface: #ffffff;
    --awfm-border-color: #e2e8f0;
    
    /* Box Radius & Spacing Architecture */
    --awfm-radius-panel: 16px;
    --awfm-radius-item: 12px;
    --awfm-radius-badge: 9999px;
    
    /* Animation & Shadow Structural Tokens */
    --awfm-shadow-elevation: 0 20px 40px -15px rgba(15, 23, 42, 0.15), 0 0 0 1px rgba(15, 23, 42, 0.05);
    --awfm-curve-standard: cubic-bezier(0.25, 1, 0.5, 1);
    --awfm-transition-speed: 380ms;
    --awfm-font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

/* ==========================================================================
   1. Base Core Containers & Component Layouts
   ========================================================================== */

.awfm-cart-container {
    font-family: var(--awfm-font-family);
    box-sizing: border-box;
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 340px;
    background-color: var(--awfm-bg-surface);
    border-radius: var(--awfm-radius-panel);
    box-shadow: var(--awfm-shadow-elevation);
    z-index: 999999;
    overflow: visible;
    transition: transform var(--awfm-transition-speed) var(--awfm-curve-standard), 
                opacity var(--awfm-transition-speed) linear;
    will-change: transform;
}

/* Ensure child-element inheritance resets cleanly */
.awfm-cart-container *,
.awfm-cart-container *::before,
.awfm-cart-container *::after {
    box-sizing: inherit;
    margin: 0;
    padding: 0;
}

.awfm-cart-inner {
    position: relative;
    width: 100%;
    display: flex;
    flex-direction: column;
}

/* ==========================================================================
   2. Floating Toggle Button Control Interfaces
   ========================================================================== */

.awfm-cart-trigger {
    position: absolute;
    top: 0;
    left: -76px; /* Positions the handle clear of panel shadows */
    width: 56px;
    height: 56px;
    background-color: var(--awfm-brand-primary);
    border-radius: var(--awfm-radius-badge);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.2s var(--awfm-curve-standard);
}

.awfm-cart-trigger:hover {
    transform: translateY(-2px) scale(1.04);
}

.awfm-trigger-icon-frame {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
}

.awfm-trigger-icon-frame img {
    width: 24px;
    height: 24px;
    object-fit: contain;
    filter: brightness(0) invert(1); /* Inverts dark basket icon to white safely */
}

/* Interactive Realtime Counter Notification Badge */
.awfm-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background-color: var(--awfm-brand-accent);
    color: #ffffff;
    font-size: 11px;
    font-weight: 700;
    min-width: 20px;
    height: 20px;
    padding: 0 5px;
    border-radius: var(--awfm-radius-badge);
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid var(--awfm-bg-surface);
    box-shadow: 0 3px 8px rgba(244, 63, 94, 0.3);
}

.awfm-badge[aria-hidden="true"],
.awfm-badge:empty {
    display: none;
}

/* ==========================================================================
   3. Header Summary Status Interface Panels
   ========================================================================== */

.awfm-cart-header {
    padding: 20px 20px 14px 20px;
    border-bottom: 1px solid var(--awfm-border-color);
}

.awfm-header-status-text {
    font-size: 14px;
    font-weight: 600;
    color: var(--awfm-text-main);
    text-align: center;
    letter-spacing: -0.01em;
}

/* ==========================================================================
   4. Core Scroller Loop List Elements (CSS Grid System)
   ========================================================================== */

.awfm-cart-items-list {
    list-style: none !important;
    max-height: 310px;
    overflow-y: auto;
    padding: 16px !important;
    background-color: rgba(248, 250, 252, 0.5);
    scrollbar-width: thin;
    scrollbar-color: var(--awfm-border-color) transparent;
}

/* Modern Webkit Scrollbar Controls */
.awfm-cart-items-list::-webkit-scrollbar {
    width: 5px;
}
.awfm-cart-items-list::-webkit-scrollbar-track {
    background: transparent;
}
.awfm-cart-items-list::-webkit-scrollbar-thumb {
    background: var(--awfm-border-color);
    border-radius: 10px;
}

.awfm-cart-item {
    display: grid !important;
    grid-template-columns: 56px 1fr auto;
    gap: 14px;
    align-items: center;
    background: var(--awfm-bg-surface);
    padding: 12px !important;
    margin-bottom: 12px !important;
    border-radius: var(--awfm-radius-item);
    border: 1px solid var(--awfm-border-color);
    box-shadow: 0 2px 6px rgba(15, 23, 42, 0.02);
    position: relative;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.awfm-cart-item:last-child {
    margin-bottom: 0 !important;
}

.awfm-cart-item:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(15, 23, 42, 0.05);
}

/* Thumbnail Box Components Frame */
.awfm-item-media-box {
    width: 56px;
    height: 56px;
    border-radius: calc(var(--awfm-radius-item) - 4px);
    overflow: hidden;
    background-color: var(--awfm-brand-secondary);
    border: 1px solid rgba(15, 23, 42, 0.05);
}

.awfm-item-image-link {
    display: block;
    width: 100%;
    height: 100%;
}

.awfm-item-image-link img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 0.3s var(--awfm-curve-standard);
}

.awfm-cart-item:hover .awfm-item-image-link img {
    transform: scale(1.06);
}

/* Product Meta / Information Block Panels */
.awfm-item-details-box {
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.awfm-item-title-link {
    text-decoration: none;
    color: var(--awfm-text-main);
    margin-bottom: 4px;
    display: inline-block;
}

.awfm-item-name {
    font-size: 13px;
    font-weight: 600;
    line-height: 1.4;
    color: var(--awfm-text-main);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    transition: color 0.15s ease;
}

.awfm-item-title-link:hover .awfm-item-name {
    color: var(--awfm-text-muted);
}

/* Pricing Calculations Segments */
.awfm-item-meta-pricing {
    display: flex;
    align-items: center;
    font-size: 12px;
    color: var(--awfm-text-muted);
}

.awfm-item-quantity-row {
    font-size: 12px;
    color: var(--awfm-text-muted);
}

.awfm-qty-multiplier {
    font-weight: 700;
    color: var(--awfm-text-main);
    background-color: var(--awfm-brand-secondary);
    padding: 1px 6px;
    border-radius: 4px;
    margin-right: 2px;
}

/* Variations Attributes (WooCommerce Core standard Output Lists) */
.awfm-item-details-box dl.variation {
    display: flex;
    flex-wrap: wrap;
    gap: 4px 8px;
    margin-top: 6px;
    font-size: 11px;
    color: var(--awfm-text-muted);
    border-top: 1px dashed var(--awfm-border-color);
    padding-top: 4px;
}

.awfm-item-details-box dl.variation dt {
    font-weight: 600;
}

.awfm-item-details-box dl.variation dd {
    margin: 0;
}

/* Action Operations Frame (Absolute Isolation Removal Cross) */
.awfm-item-actions-box {
    display: flex;
    align-items: center;
    justify-content: center;
    padding-left: 4px;
}

.awfm-item-remove-btn {
    width: 24px;
    height: 24px;
    border-radius: var(--awfm-radius-badge);
    background-color: transparent;
    color: var(--awfm-text-muted) !important;
    text-decoration: none !important;
    font-size: 18px !important;
    font-weight: 400;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    transition: all 0.15s ease;
    border: 1px solid transparent;
}

.awfm-item-remove-btn:hover {
    background-color: #fee2e2;
    color: var(--awfm-brand-accent) !important;
    border-color: #fca5a5;
}

/* Private Visibility Element Block Custom Configuration styling */
.awfm-item-private-wrapper {
    grid-column: 1 / -1;
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 12px;
    color: var(--awfm-text-muted);
    font-style: italic;
}

/* ==========================================================================
   5. Footer Calculation Blocks & Action Interfaces
   ========================================================================== */

.awfm-cart-footer {
    padding: 20px;
    border-top: 1px solid var(--awfm-border-color);
    background-color: var(--awfm-bg-surface);
    border-bottom-left-radius: var(--awfm-radius-panel);
    border-bottom-right-radius: var(--awfm-radius-panel);
}

.awfm-footer-subtotal-panel {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.awfm-subtotal-label {
    font-size: 13px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--awfm-text-muted);
}

.awfm-subtotal-value {
    font-size: 18px;
    font-weight: 700;
    color: var(--awfm-text-main);
    letter-spacing: -0.02em;
}

/* Buttons Core Flexbox Action Layout Grid */
.awfm-footer-buttons-action-grid {
    display: flex;
    gap: 10px;
    width: 100%;
}

.awfm-footer-buttons-action-grid .awfm-btn {
    flex: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    padding: 8px 16px;
    font-size: 13px;
    font-weight: 600;
    border-radius: var(--awfm-radius-item);
    text-decoration: none !important;
    text-transform: capitalize;
    transition: background-color 0.15s ease, transform 0.1s ease;
    text-align: center;
    cursor: pointer;
    border: none;
}

.awfm-btn:active {
    transform: scale(0.98);
}

/* Specialized Primary Styling Rules */
.awfm-btn--primary {
    background-color: var(--awfm-brand-primary) !important;
    color: #ffffff !important;
}

.awfm-btn--primary:hover {
    background-color: #1e293b !important;
}

/* Specialized Secondary Styling Rules */
.awfm-btn--secondary {
    background-color: var(--awfm-brand-secondary) !important;
    color: var(--awfm-text-main) !important;
    border: 1px solid var(--awfm-border-color) !important;
}

.awfm-btn--secondary:hover {
    background-color: #e2e8f0 !important;
}

.awfm-footer-buttons-action-grid--fullwidth .awfm-btn {
    flex: 0 0 100%;
    width: 100%;
}

/* ==========================================================================
   6. Empty States & Cross-Selling Recommendations Layout
   ========================================================================== */

.awfm-cart-empty-state {
    padding: 40px 20px;
    text-align: center;
}

.awfm-empty-message {
    font-size: 14px;
    color: var(--awfm-text-muted);
    font-weight: 500;
}

.awfm-cart-footer--empty-state {
    background-color: rgba(248, 250, 252, 0.4);
    border-top: 1px dashed var(--awfm-border-color);
}

.awfm-recommendations-section {
    margin-bottom: 20px;
}

.awfm-recommendations-title {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--awfm-text-muted);
    letter-spacing: 0.05em;
    margin-bottom: 12px;
    text-align: center;
}

/* Modern Flex-Grid for Cross-Sells (Fixes floats) */
.awfm-recommendations-grid {
    list-style: none !important;
    display: flex;
    justify-content: center;
    gap: 12px;
    width: 100%;
}

.awfm-recommendation-item {
    flex: 0 1 64px;
    width: 64px;
    height: 64px;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid var(--awfm-border-color);
    background: var(--awfm-bg-surface);
    transition: transform 0.2s var(--awfm-curve-standard), border-color 0.2s ease;
}

.awfm-recommendation-item:hover {
    transform: scale(1.08) translateY(-2px);
    border-color: var(--awfm-text-muted);
}

.awfm-rec-thumb-link {
    display: block;
    width: 100%;
    height: 100%;
}

.awfm-rec-thumb-link img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* ==========================================================================
   7. Media Queries & Desktop Responsive Fallbacks
   ========================================================================== */

@media only screen and (max-width: 480px) {
    .awfm-cart-container {
        bottom: 16px;
        right: 16px;
        width: calc(100vw - 32px);
        max-width: 340px;
    }
    
    .awfm-cart-trigger {
        left: auto;
        right: 0;
        top: -72px; /* Positions the icon vertically on smaller mobile displays */
    }
    
    .awfm-cart-items-list {
        max-height: 240px;
    }
}