/* ==========================================================================
   Karizflow Pro Cart - Off-Canvas Left Mini Cart & Invoice Styles
   ========================================================================== */

/* 1. دکمه تریگر مینی‌کارت (همراه با مبلغ کل و تعداد) */
.kf-mini-cart-wrapper {
    display: inline-block;
    position: relative;
    vertical-align: middle;
}

.kf-cart-trigger-btn {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 12px;
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.04);
    transition: all 0.25s ease;
    padding: 6px 14px 6px 8px;
    color: #1e293b;
    text-align: right;
    outline: none;
}

.kf-cart-trigger-btn:hover {
    border-color: #3b82f6;
    color: #2563eb;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.12);
    transform: translateY(-1px);
}

.kf-trigger-icon-wrap {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background: #f8fafc;
    border-radius: 10px;
    color: inherit;
}

.kf-cart-icon {
    width: 20px;
    height: 20px;
}

.kf-cart-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #ef4444;
    color: #ffffff;
    font-size: 11px;
    font-weight: 700;
    min-width: 18px;
    height: 18px;
    border-radius: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
    border: 2px solid #ffffff;
    box-shadow: 0 2px 4px rgba(0,0,0,0.15);
    font-family: inherit;
}

.kf-trigger-text-wrap {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    line-height: 1.2;
}

.kf-trigger-title {
    font-size: 11px;
    color: #64748b;
    font-weight: 500;
}

.kf-trigger-total {
    font-size: 13px;
    font-weight: 700;
    color: #0f172a;
    margin-top: 2px;
}

.kf-trigger-total .woocommerce-Price-amount {
    color: inherit;
}

/* 2. پرده پس‌زمینه (Overlay) */
.kf-offcanvas-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(4px);
    z-index: 999998;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.kf-offcanvas-overlay.is-active {
    opacity: 1;
    visibility: visible;
}

/* 3. پنل آف‌کانواس از چپ (Left Off-Canvas) */
.kf-offcanvas-panel {
    position: fixed;
    top: 0;
    left: 0; /* موقعیت سمت چپ */
    width: 400px;
    max-width: 88vw;
    height: 100vh;
    height: 100dvh;
    background: #ffffff;
    box-shadow: 10px 0 35px rgba(0, 0, 0, 0.15);
    z-index: 999999;
    transform: translateX(-100%); /* مخفی در خارج از صفحه چپ */
    transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1);
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
}

.kf-offcanvas-panel.is-active {
    transform: translateX(0); /* باز شدن به داخل */
}

/* هدر آف‌کانواس */
.kf-offcanvas-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid #f1f5f9;
    background: #f8fafc;
}

.kf-offcanvas-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 15px;
    font-weight: 700;
    color: #1e293b;
}

.kf-header-icon {
    width: 20px;
    height: 20px;
    color: #2563eb;
}

.kf-close-btn {
    background: transparent;
    border: none;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: #64748b;
    transition: all 0.2s;
    padding: 0;
}

.kf-close-btn svg {
    width: 18px;
    height: 18px;
}

.kf-close-btn:hover {
    background: #e2e8f0;
    color: #0f172a;
}

/* بدنه آف‌کانواس */
.kf-offcanvas-body {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 16px;
    -webkit-overflow-scrolling: touch;
}

/* لیست محصولات در مینی‌کارت */
.kf-mini-cart-items-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.kf-mini-cart-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 0;
    border-bottom: 1px dashed #e2e8f0;
    position: relative;
}

.kf-item-thumb img {
    width: 60px;
    height: 60px;
    object-fit: cover;
    border-radius: 8px;
    border: 1px solid #f1f5f9;
    display: block;
}

.kf-item-info {
    flex: 1;
    min-width: 0;
}

.kf-item-title {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: #1e293b;
    text-decoration: none;
    line-height: 1.4;
    margin-bottom: 6px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.kf-item-title:hover {
    color: #2563eb;
}

.kf-item-meta {
    font-size: 12px;
    color: #64748b;
    display: flex;
    align-items: center;
    gap: 4px;
}

.kf-item-qty {
    font-weight: 700;
    color: #0f172a;
}

.kf-item-unit {
    background: #f1f5f9;
    padding: 1px 6px;
    border-radius: 4px;
    font-size: 11px;
    color: #475569;
}

.kf-item-price {
    font-weight: 700;
    color: #2563eb;
}

.kf-item-remove a.remove {
    display: flex !important;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border-radius: 50% !important;
    color: #ef4444 !important;
    background: #fee2e2;
    text-decoration: none;
    font-size: 16px;
    line-height: 1;
    transition: all 0.2s;
}

.kf-item-remove a.remove:hover {
    background: #ef4444;
    color: #ffffff !important;
}

/* فوتر مینی‌کارت */
.kf-offcanvas-footer {
    padding: 16px;
    border-top: 1px solid #f1f5f9;
    background: #f8fafc;
}

.kf-summary-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
    font-size: 13px;
    color: #475569;
}

.kf-total-row {
    font-size: 15px;
    font-weight: 700;
    color: #0f172a;
    border-top: 1px dashed #cbd5e1;
    padding-top: 10px;
    margin-top: 10px;
}

.kf-highlight {
    color: #2563eb;
}

.kf-mini-cart-actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 14px;
}

.kf-btn-checkout {
    display: block;
    background: #2563eb;
    color: #ffffff !important;
    text-align: center;
    padding: 12px;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 700;
    text-decoration: none;
    box-shadow: 0 4px 10px rgba(37, 99, 235, 0.25);
    transition: all 0.2s;
}

.kf-btn-checkout:hover {
    background: #1d4ed8;
    transform: translateY(-1px);
}

.kf-btn-viewcart {
    display: block;
    background: #ffffff;
    color: #475569 !important;
    text-align: center;
    padding: 10px;
    border-radius: 10px;
    font-size: 13px;
    font-weight: 600;
    text-decoration: none;
    border: 1px solid #cbd5e1;
    transition: all 0.2s;
}

.kf-btn-viewcart:hover {
    background: #f1f5f9;
    color: #0f172a !important;
}

/* خالی بودن سبد */
.kf-mini-cart-empty {
    text-align: center;
    padding: 40px 10px;
    color: #94a3b8;
}

.kf-mini-cart-empty svg {
    width: 56px;
    height: 56px;
    margin-bottom: 12px;
    stroke: #cbd5e1;
}

.kf-btn-return-shop {
    display: inline-block;
    margin-top: 12px;
    padding: 8px 18px;
    background: #f1f5f9;
    color: #334155;
    border-radius: 8px;
    font-size: 13px;
    text-decoration: none;
    font-weight: 600;
}

/* استایل انتخابگر فاکتور */
.kf-invoice-selector-box {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    padding: 12px;
    margin: 12px 0;
}

.kf-selector-header {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: #334155;
    margin-bottom: 10px;
}

.kf-radio-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.kf-radio-label {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 8px 10px;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    cursor: pointer;
    background: #f8fafc;
    transition: all 0.2s;
}

.kf-radio-label.active {
    border-color: #2563eb;
    background: #eff6ff;
}

.kf-radio-label input[type="radio"] {
    margin-top: 3px;
    cursor: pointer;
}

.kf-invoice-selector-box .kf-radio-label{display:flex!important;flex-direction:row;align-items:flex-start;justify-content:flex-start;direction:rtl;text-align:right;width:100%;box-sizing:border-box}
.kf-invoice-selector-box .kf-radio-label input[type="radio"]{display:inline-block!important;width:16px!important;min-width:16px!important;max-width:16px!important;height:16px!important;min-height:16px!important;flex:0 0 16px;margin:3px 0 0!important;padding:0!important;float:none!important}
.kf-invoice-selector-box .kf-radio-text{flex:1;min-width:0;text-align:right!important;direction:rtl}

.kf-radio-text strong {
    display: block;
    font-size: 12px;
    color: #1e293b;
}

.kf-radio-text small {
    display: block;
    font-size: 11px;
    color: #64748b;
    margin-top: 2px;
}

.kf-selector-loading {
    margin-top: 8px;
    font-size: 12px;
    color: #2563eb;
    display: flex;
    align-items: center;
    gap: 6px;
}

.kf-spinner {
    width: 14px;
    height: 14px;
    border: 2px solid #93c5fd;
    border-top-color: #2563eb;
    border-radius: 50%;
    animation: kf-spin 0.7s linear infinite;
    display: inline-block;
}

@keyframes kf-spin {
    to { transform: rotate(360deg); }
}

/* برچسب واحد در جدول سبد خرید */
.kf-cart-unit-label {
    font-size: 12px;
    color: #64748b;
    background: #f1f5f9;
    padding: 2px 6px;
    border-radius: 4px;
    margin-right: 4px;
}

/* Scoped controls, keyboard focus and mobile safe areas. */
.kf-offcanvas-panel { visibility: hidden; }
.kf-offcanvas-panel.is-active { visibility: visible; }
.kf-offcanvas-body { min-height: 0; overscroll-behavior: contain; padding-bottom: max(16px, env(safe-area-inset-bottom)); }
.kf-offcanvas-panel *, .kf-invoice-selector-box * { box-sizing: border-box; }
.kf-quantity-control { display: inline-flex; align-items: center; gap: 6px; margin-top: 8px; direction: ltr; }
.kf-quantity-control button { width: 30px; height: 30px; padding: 0; border: 1px solid #cbd5e1; border-radius: 6px; background: #f8fafc; color: #0f172a; cursor: pointer; }
.kf-quantity-control .quantity { margin: 0; }
.kf-quantity-control input.qty { width: 64px; min-height: 30px; margin: 0; padding: 2px; text-align: center; border: 1px solid #cbd5e1; border-radius: 6px; }
.kf-is-busy .kf-remove-item { pointer-events: none; opacity: .5; }
.kf-quantity-control button:disabled, [data-kf-invoice-type]:disabled { opacity: .55; cursor: wait; }
.kf-cart-status:empty, .kf-invoice-status:empty { display: none; }
.kf-cart-status, .kf-invoice-status { color: #b91c1c; background: #fff1f2; padding: 10px; border-radius: 8px; font-size: 13px; }
.kf-totals-note { color: #64748b; font-size: 11px; line-height: 1.8; }
.kf-cart-trigger-btn:focus-visible, .kf-offcanvas-panel a:focus-visible, .kf-offcanvas-panel button:focus-visible, .kf-offcanvas-panel input:focus-visible { outline: 2px solid #2563eb; outline-offset: 3px; }
.kf-offcanvas-panel .variation { font-size: 11px; margin: 4px 0; }
@media (prefers-reduced-motion: reduce) {
    .kf-offcanvas-panel, .kf-offcanvas-overlay, .kf-cart-trigger-btn { transition: none; }
    .kf-spinner { animation: none; }
}
