/* =============================================
   G5Shop Sidebar Cart - Shopify Style
   ============================================= */

/* Sidebar Cart Container */
.g5shop__sidebar-cart {
    --g5-off-canvas-width: 420px;
    --g5-sidebar-bg: #fff;
    --g5-sidebar-border: #e5e5e5;
    --g5-primary-color: #222;
    --g5-accent-color: #f04336;
    --g5-success-color: #28a745;
    --g5-text-color: #333;
    --g5-text-muted: #6c757d;
    gap: 0;
    position: fixed;
    top: 0;
    right: 0;
    width: var(--g5-off-canvas-width);
    height: 100%;
    z-index: 99999;
    transform: translateX(100%);
    transition: transform 0.3s ease;
}

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

/* Overlay */
.g5shop__sidebar-cart-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 99998;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.g5shop__sidebar-cart-overlay.is-visible {
    opacity: 1;
    visibility: visible;
}

/* Body when cart is open */
body.g5shop__sidebar-cart-open {
    overflow: hidden;
}

.g5shop__sidebar-cart .g5shop__sidebar-cart-inner {
    display: flex;
    flex-direction: column;
    height: 100%;
    background: var(--g5-sidebar-bg);
}

/* Header */
.g5shop__sidebar-cart .g5core-off-canvas-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 25px;
    border-bottom: 1px solid var(--g5-sidebar-border);
    background: var(--g5-sidebar-bg);
    flex-shrink: 0;
}

.g5shop__sidebar-cart .g5core-off-canvas-header-inner {
    display: flex;
    align-items: center;
    gap: 10px;
}

.g5shop__sidebar-cart .g5core-off-canvas-title {
    font-size: 18px;
    font-weight: 600;
    margin: 0;
    color: var(--g5-primary-color);
}

.g5shop__cart-count-wrap {
    display: flex;
    align-items: center;
    gap: 5px;
    color: var(--g5-text-muted);
    font-size: 14px;
}

.g5shop__cart-count {
    font-weight: 600;
}

.g5shop__sidebar-cart .off-canvas-close {
    display: flex;
    align-items: center;
    gap: 8px;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--g5-text-muted);
    padding: 5px;
    transition: color 0.3s;
}

.g5shop__sidebar-cart .off-canvas-close:hover {
    color: var(--g5-primary-color);
}

.g5shop__sidebar-cart .off-canvas-close svg {
    fill: currentColor;
}

.g5shop__sidebar-cart .off-canvas-close span {
    font-size: 14px;
}

/* Body */
.g5shop__sidebar-cart .g5core-off-canvas-body {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 0;
}

/* Free Shipping Progress */
.g5shop__shipping-progress-wrap {
    padding: 15px 25px;
    background: linear-gradient(135deg, #f8fff8 0%, #e8f5e9 100%);
    border-bottom: 1px solid var(--g5-sidebar-border);
}

.g5shop__shipping-progress {
    margin-bottom: 10px;
}

.g5shop__progress-bar {
    height: 24px;
    background: #e0e0e0;
    border-radius: 12px;
    overflow: visible;
    position: relative;
}

.g5shop__progress-meter {
    height: 100%;
    background: linear-gradient(90deg, var(--g5-accent-color) 0%, var(--g5-success-color) 100%);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    min-width: 50px;
    transition: width 0.5s ease;
}

.g5shop__progress-text {
    color: #fff;
    font-size: 11px;
    font-weight: 600;
    text-shadow: 0 1px 2px rgba(0,0,0,0.2);
}

.g5shop__progress-truck {
    position: absolute;
    right: -12px;
    top: 50%;
    transform: translateY(-50%);
    background: var(--g5-success-color);
    border-radius: 50%;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
    opacity: 0;
    transition: opacity 0.3s;
}

.g5shop__progress-truck.active {
    opacity: 1;
}

.g5shop__shipping-message {
    font-size: 13px;
    color: var(--g5-text-color);
    text-align: center;
}

.g5shop__free-shipping-success {
    color: var(--g5-success-color);
    font-weight: 600;
}

/* Cart Items */
.g5shop__sidebar-cart .g5shop__mini-cart {
    padding: 0;
}

.g5shop__sidebar-cart .widget_shopping_cart_content {
    position: static;
    opacity: 1;
    visibility: visible;
    width: 100%;
    box-shadow: none;
    margin: 0;
    padding: 0;
}

.g5shop__sidebar-cart ul.woocommerce-mini-cart {
    max-height: none;
    padding: 15px 25px;
    margin: 0;
    list-style: none;
}

.g5shop__sidebar-cart .woocommerce-mini-cart-item {
    display: grid;
    grid-template-columns: auto 1fr auto;
    grid-template-rows: auto auto;
    gap: 10px 15px;
    padding: 15px 0;
    border-bottom: 1px solid var(--g5-sidebar-border);
    position: relative;
    align-items: start;
}

.g5shop__sidebar-cart .woocommerce-mini-cart-item:last-child {
    border-bottom: none;
}

/* Remove Button */
.g5shop__sidebar-cart .woocommerce-mini-cart-item .remove {
    grid-column: 3;
    grid-row: 1;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    color: var(--g5-text-muted);
    background: #f5f5f5;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.3s;
    text-decoration: none;
    line-height: 1;
}

.g5shop__sidebar-cart .woocommerce-mini-cart-item .remove:hover {
    color: #fff;
    background: var(--g5-accent-color);
}

/* Product Link (contains image + name) */
.g5shop__sidebar-cart .woocommerce-mini-cart-item > a:not(.remove) {
    grid-column: 1 / 3;
    grid-row: 1;
    display: flex;
    align-items: flex-start;
    gap: 15px;
    font-size: 14px;
    font-weight: 500;
    color: var(--g5-text-color);
    text-decoration: none;
    line-height: 1.5;
}

.g5shop__sidebar-cart .woocommerce-mini-cart-item > a:not(.remove):hover {
    color: var(--g5-accent-color);
}

/* Product Image */
.g5shop__sidebar-cart .woocommerce-mini-cart-item > a:not(.remove) img {
    width: 80px;
    height: 80px;
    object-fit: cover;
    border-radius: 8px;
    border: 1px solid var(--g5-sidebar-border);
    flex-shrink: 0;
}

/* Quantity */
.g5shop__sidebar-cart .woocommerce-mini-cart-item .quantity {
    grid-column: 1 / 4;
    grid-row: 2;
    font-size: 13px;
    color: var(--g5-text-muted);
    padding-left: 95px;
}

.g5shop__sidebar-cart .woocommerce-mini-cart-item .remove:hover {
    color: var(--g5-accent-color);
}

/* Quantity Controls */
.g5shop__sidebar-cart .quantity {
    display: flex;
    align-items: center;
    gap: 5px;
    margin-top: 10px;
}

.g5shop__sidebar-cart .quantity .qty-btn {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f5f5f5;
    border: 1px solid var(--g5-sidebar-border);
    border-radius: 4px;
    cursor: pointer;
    font-size: 16px;
    transition: all 0.2s;
}

.g5shop__sidebar-cart .quantity .qty-btn:hover {
    background: var(--g5-primary-color);
    color: #fff;
}

.g5shop__sidebar-cart .quantity input.qty {
    width: 40px;
    height: 28px;
    text-align: center;
    border: 1px solid var(--g5-sidebar-border);
    border-radius: 4px;
    font-size: 14px;
}

/* Mini Cart Totals - Hide default */
.g5shop__sidebar-cart .woocommerce-mini-cart__total,
.g5shop__sidebar-cart .woocommerce-mini-cart__buttons {
    display: none;
}

/* Footer */
.g5shop__sidebar-cart .g5core-off-canvas-footer {
    padding: 20px 25px;
    background: var(--g5-sidebar-bg);
    border-top: 1px solid var(--g5-sidebar-border);
    flex-shrink: 0;
}

.g5shop__cart-totals {
    margin-bottom: 15px;
}

.g5shop__cart-subtotal,
.g5shop__cart-total {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.g5shop__totals-label {
    font-size: 14px;
    color: var(--g5-text-muted);
}

.g5shop__totals-value {
    font-size: 14px;
    font-weight: 600;
    color: var(--g5-primary-color);
}

.g5shop__cart-total .g5shop__totals-label,
.g5shop__cart-total .g5shop__totals-value {
    font-size: 16px;
}

.g5shop__cart-tax-note {
    font-size: 12px;
    color: var(--g5-text-muted);
    margin: 10px 0 0;
}

.g5shop__cart-buttons {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.g5shop__btn-checkout,
.g5shop__btn-view-cart {
    display: block;
    width: 100%;
    padding: 14px 20px;
    font-size: 14px;
    font-weight: 600;
    text-align: center;
    text-decoration: none;
    border-radius: 6px;
    transition: all 0.3s;
}

.g5shop__btn-checkout {
    background: var(--g5-primary-color);
    color: #fff;
    border: none;
}

.g5shop__btn-checkout:hover {
    background: var(--g5-accent-color);
    color: #fff;
}

.g5shop__btn-view-cart {
    background: #fff;
    color: var(--g5-primary-color);
    border: 2px solid var(--g5-primary-color);
}

.g5shop__btn-view-cart:hover {
    background: var(--g5-primary-color);
    color: #fff;
}

/* Empty Cart Message */
.g5shop__sidebar-cart .woocommerce-mini-cart__empty-message {
    display: none;
}

.g5shop__sidebar-cart .g5shop__empty-cart-icon {
    width: 200px;
    margin: 40px auto 20px;
    display: block;
}

.g5shop__sidebar-cart .g5shop__empty-cart-messages {
    text-align: center;
    padding: 20px 25px;
}

/* =============================================
   RTL Support - Arabic
   ============================================= */
[dir="rtl"] .g5shop__sidebar-cart,
.rtl .g5shop__sidebar-cart {
    right: auto;
    left: 0;
    transform: translateX(-100%);
    direction: rtl;
}

[dir="rtl"] .g5shop__sidebar-cart.is-open,
.rtl .g5shop__sidebar-cart.is-open {
    transform: translateX(0);
}

/* RTL Header */
[dir="rtl"] .g5shop__sidebar-cart .g5core-off-canvas-header,
.rtl .g5shop__sidebar-cart .g5core-off-canvas-header {
    flex-direction: row-reverse;
}

[dir="rtl"] .g5shop__sidebar-cart .g5core-off-canvas-header-inner,
.rtl .g5shop__sidebar-cart .g5core-off-canvas-header-inner {
    flex-direction: row-reverse;
}

[dir="rtl"] .g5shop__sidebar-cart .off-canvas-close,
.rtl .g5shop__sidebar-cart .off-canvas-close {
    flex-direction: row-reverse;
}

/* RTL Progress Bar */
[dir="rtl"] .g5shop__progress-bar,
.rtl .g5shop__progress-bar {
    direction: ltr;
}

[dir="rtl"] .g5shop__progress-meter,
.rtl .g5shop__progress-meter {
    margin-left: auto;
    margin-right: 0;
}

[dir="rtl"] .g5shop__progress-truck,
.rtl .g5shop__progress-truck {
    right: auto;
    left: -12px;
}

/* RTL Shipping Message */
[dir="rtl"] .g5shop__shipping-message,
.rtl .g5shop__shipping-message {
    direction: rtl;
    text-align: center;
}

/* RTL Mini Cart Items */
[dir="rtl"] .g5shop__sidebar-cart .woocommerce-mini-cart-item,
.rtl .g5shop__sidebar-cart .woocommerce-mini-cart-item {
    grid-template-columns: auto 1fr auto;
    direction: rtl;
}

[dir="rtl"] .g5shop__sidebar-cart .woocommerce-mini-cart-item .remove,
.rtl .g5shop__sidebar-cart .woocommerce-mini-cart-item .remove {
    grid-column: 1;
    grid-row: 1;
}

[dir="rtl"] .g5shop__sidebar-cart .woocommerce-mini-cart-item > a:not(.remove),
.rtl .g5shop__sidebar-cart .woocommerce-mini-cart-item > a:not(.remove) {
    grid-column: 2 / 4;
    flex-direction: row-reverse;
    text-align: right;
}

[dir="rtl"] .g5shop__sidebar-cart .woocommerce-mini-cart-item .quantity,
.rtl .g5shop__sidebar-cart .woocommerce-mini-cart-item .quantity {
    text-align: right;
    padding-left: 0;
    padding-right: 95px;
    direction: rtl;
}

/* RTL Footer Totals */
[dir="rtl"] .g5shop__cart-subtotal,
[dir="rtl"] .g5shop__cart-total,
.rtl .g5shop__cart-subtotal,
.rtl .g5shop__cart-total {
    flex-direction: row-reverse;
}

[dir="rtl"] .g5shop__cart-tax-note,
.rtl .g5shop__cart-tax-note {
    text-align: right;
}

/* RTL Empty Cart */
[dir="rtl"] .g5shop__sidebar-cart .g5shop__empty-cart-messages,
.rtl .g5shop__sidebar-cart .g5shop__empty-cart-messages {
    text-align: center;
    direction: rtl;
}

/* Responsive */
@media (max-width: 480px) {
    .g5shop__sidebar-cart {
        --g5-off-canvas-width: 100%;
    }
    
    [dir="rtl"] .g5shop__sidebar-cart,
    .rtl .g5shop__sidebar-cart {
        transform: translateX(-100%);
    }
}
