/**
 * Port Market Floating Cart — Premium Styles
 * RTL-first design for Hebrew layout
 * Version: 1.1.0 — Dark luxury theme, repositioned, right-slide panel
 */

/* =========================================================
   CSS CUSTOM PROPERTIES
   ========================================================= */
:root {
    --pmfc-primary: #1b2a4a;
    --pmfc-primary-hover: #243558;
    --pmfc-primary-dark: #111d35;
    --pmfc-accent: #c9a84c;
    --pmfc-accent-hover: #dabb62;
    --pmfc-accent-soft: rgba(201, 168, 76, 0.12);
    --pmfc-danger: #e63946;
    --pmfc-danger-hover: #c5303c;
    --pmfc-bg: #ffffff;
    --pmfc-bg-subtle: #f5f5f8;
    --pmfc-bg-item-hover: #fafafa;
    --pmfc-border: #e4e4eb;
    --pmfc-border-light: #f0f0f4;
    --pmfc-text: #1b2a4a;
    --pmfc-text-secondary: #5e6a80;
    --pmfc-text-light: #8e96a6;
    --pmfc-shadow-sm: 0 2px 8px rgba(27, 42, 74, 0.06);
    --pmfc-shadow-md: 0 8px 32px rgba(27, 42, 74, 0.14);
    --pmfc-shadow-lg: 0 20px 60px rgba(27, 42, 74, 0.18);
    --pmfc-shadow-toggle: 0 4px 20px rgba(27, 42, 74, 0.35);
    --pmfc-radius: 14px;
    --pmfc-radius-sm: 10px;
    --pmfc-radius-xs: 6px;
    --pmfc-panel-width: 400px;
    --pmfc-z-index: 999990;
    --pmfc-transition: cubic-bezier(0.32, 0.72, 0, 1);
    --pmfc-font: "Heebo", "Assistant", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

/* =========================================================
   RESET — Prevent theme interference
   ========================================================= */
#pmfc-toggle,
#pmfc-panel,
#pmfc-overlay,
#pmfc-panel *,
#pmfc-toggle * {
    box-sizing: border-box;
    font-family: var(--pmfc-font);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* =========================================================
   OVERLAY
   ========================================================= */
.pmfc-overlay {
    position: fixed;
    inset: 0;
    background: rgba(17, 29, 53, 0.55);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    z-index: var(--pmfc-z-index);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.35s var(--pmfc-transition), visibility 0.35s var(--pmfc-transition);
}

.pmfc-overlay.pmfc-active {
    opacity: 1;
    visibility: visible;
}

/* =========================================================
   FLOATING TOGGLE BUTTON
   — Left side, positioned ABOVE the WhatsApp button
   ========================================================= */
.pmfc-toggle {
    position: fixed;
    bottom: 65vh;
    left: 20px;
    z-index: calc(var(--pmfc-z-index) + 2);
    width: 56px;
    height: 56px;
    border: none;
    border-radius: 50%;
    background: var(--pmfc-primary);
    color: #ffffff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--pmfc-shadow-toggle);
    transition: transform 0.25s var(--pmfc-transition),
                box-shadow 0.25s var(--pmfc-transition),
                background 0.2s ease;
    outline: none;
    padding: 0;
    margin: 0;
    line-height: 1;
}

.pmfc-toggle:hover {
    transform: scale(1.07);
    box-shadow: var(--pmfc-shadow-lg);
    background: var(--pmfc-primary-hover);
}

.pmfc-toggle:active {
    transform: scale(0.94);
}

.pmfc-cart-icon {
    width: 24px;
    height: 24px;
    pointer-events: none;
}

/* =========================================================
   BADGE
   ========================================================= */
.pmfc-badge {
    position: absolute;
    top: -3px;
    right: -3px;
    min-width: 20px;
    height: 20px;
    padding: 0 5px;
    border-radius: 10px;
    background: var(--pmfc-danger);
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    line-height: 20px;
    text-align: center;
    pointer-events: none;
    transition: transform 0.3s var(--pmfc-transition), opacity 0.2s ease;
    letter-spacing: -0.02em;
    box-shadow: 0 2px 6px rgba(230, 57, 70, 0.4);
}

.pmfc-badge.pmfc-hidden {
    transform: scale(0);
    opacity: 0;
}

.pmfc-badge.pmfc-pulse {
    animation: pmfc-pulse 0.4s var(--pmfc-transition);
}

@keyframes pmfc-pulse {
    0%   { transform: scale(1); }
    50%  { transform: scale(1.35); }
    100% { transform: scale(1); }
}

/* =========================================================
   SLIDE-OUT PANEL
   — Opens from the RIGHT side (RTL natural direction)
   ========================================================= */
.pmfc-panel {
    position: fixed;
    top: 0;
    right: 0;
    left: auto;
    width: var(--pmfc-panel-width);
    max-width: 100vw;
    height: 100%;
    z-index: calc(var(--pmfc-z-index) + 1);
    background: var(--pmfc-bg);
    box-shadow: -8px 0 40px rgba(17, 29, 53, 0.15);
    transform: translateX(100%);
    transition: transform 0.4s var(--pmfc-transition);
    overflow: hidden;
    direction: rtl;
}

.pmfc-panel.pmfc-active {
    transform: translateX(0);
}

.pmfc-panel.pmfc-swiping {
    transition: none;
}

.pmfc-panel-inner {
    display: flex;
    flex-direction: column;
    height: 100%;
}

/* =========================================================
   HEADER — Dark premium bar
   ========================================================= */
.pmfc-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 22px;
    background: var(--pmfc-primary);
    flex-shrink: 0;
}

.pmfc-title {
    font-size: 18px;
    font-weight: 700;
    color: #ffffff;
    margin: 0;
    padding: 0;
    letter-spacing: 0.01em;
    line-height: 1.3;
}

.pmfc-close {
    width: 34px;
    height: 34px;
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.08);
    color: rgba(255, 255, 255, 0.7);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

.pmfc-close:hover {
    background: rgba(255, 255, 255, 0.15);
    color: #ffffff;
    border-color: rgba(255, 255, 255, 0.25);
}

.pmfc-close svg {
    width: 16px;
    height: 16px;
    pointer-events: none;
}

/* =========================================================
   ITEMS CONTAINER
   ========================================================= */
.pmfc-items {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 0;
    background: var(--pmfc-bg);
    scrollbar-width: thin;
    scrollbar-color: var(--pmfc-border) transparent;
    overscroll-behavior: contain;
}

.pmfc-items::-webkit-scrollbar {
    width: 3px;
}

.pmfc-items::-webkit-scrollbar-track {
    background: transparent;
}

.pmfc-items::-webkit-scrollbar-thumb {
    background: var(--pmfc-border);
    border-radius: 2px;
}

/* =========================================================
   LOADING SPINNER
   ========================================================= */
.pmfc-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 60px 0;
}

.pmfc-spinner {
    width: 28px;
    height: 28px;
    border: 2.5px solid var(--pmfc-border);
    border-top-color: var(--pmfc-accent);
    border-radius: 50%;
    animation: pmfc-spin 0.7s linear infinite;
}

@keyframes pmfc-spin {
    to { transform: rotate(360deg); }
}

/* =========================================================
   EMPTY STATE
   ========================================================= */
.pmfc-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 80px 32px;
    text-align: center;
}

.pmfc-empty-icon {
    width: 56px;
    height: 56px;
    color: var(--pmfc-text-light);
    margin-bottom: 18px;
    opacity: 0.35;
}

.pmfc-empty-text {
    font-size: 15px;
    color: var(--pmfc-text-secondary);
    margin: 0;
    line-height: 1.5;
}

/* =========================================================
   CART ITEM
   ========================================================= */
.pmfc-item {
    display: flex;
    gap: 14px;
    padding: 16px 22px;
    border-bottom: 1px solid var(--pmfc-border-light);
    position: relative;
    transition: background 0.2s ease, opacity 0.3s ease;
}

.pmfc-item:last-child {
    border-bottom: none;
}

.pmfc-item:hover {
    background: var(--pmfc-bg-item-hover);
}

.pmfc-item.pmfc-removing {
    opacity: 0.35;
    pointer-events: none;
}

/* Thumbnail */
.pmfc-item-img {
    width: 68px;
    height: 68px;
    border-radius: var(--pmfc-radius-sm);
    overflow: hidden;
    flex-shrink: 0;
    background: var(--pmfc-bg-subtle);
    border: 1px solid var(--pmfc-border-light);
}

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

.pmfc-item-img a {
    display: block;
    width: 100%;
    height: 100%;
    text-decoration: none;
}

/* Item Details */
.pmfc-item-details {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.pmfc-item-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--pmfc-text);
    text-decoration: none;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    margin: 0;
    padding: 0;
    transition: color 0.15s ease;
}

.pmfc-item-name:hover {
    color: var(--pmfc-accent);
}

.pmfc-item-variation {
    font-size: 12px;
    color: var(--pmfc-text-light);
    line-height: 1.3;
    margin: 0;
}

.pmfc-item-bottom {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-top: auto;
}

.pmfc-item-price {
    font-size: 14px;
    font-weight: 700;
    color: var(--pmfc-primary);
    white-space: nowrap;
    letter-spacing: -0.01em;
}

/* Quantity Controls */
.pmfc-qty-wrap {
    display: flex;
    align-items: center;
    gap: 0;
    border: 1px solid var(--pmfc-border);
    border-radius: var(--pmfc-radius-xs);
    overflow: hidden;
    height: 30px;
    background: var(--pmfc-bg);
}

.pmfc-qty-btn {
    width: 28px;
    height: 30px;
    border: none;
    background: var(--pmfc-bg-subtle);
    color: var(--pmfc-text);
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    transition: background 0.15s ease, color 0.15s ease;
    line-height: 1;
}

.pmfc-qty-btn:hover {
    background: var(--pmfc-primary);
    color: #ffffff;
}

.pmfc-qty-btn:disabled {
    opacity: 0.25;
    cursor: not-allowed;
    background: var(--pmfc-bg-subtle);
    color: var(--pmfc-text);
}

.pmfc-qty-val {
    width: 30px;
    text-align: center;
    font-size: 13px;
    font-weight: 600;
    color: var(--pmfc-text);
    border: none;
    border-left: 1px solid var(--pmfc-border);
    border-right: 1px solid var(--pmfc-border);
    background: transparent;
    height: 30px;
    padding: 0;
    margin: 0;
    -moz-appearance: textfield;
    appearance: textfield;
}

.pmfc-qty-val::-webkit-inner-spin-button,
.pmfc-qty-val::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

/* Remove Button */
.pmfc-item-remove {
    position: absolute;
    top: 12px;
    left: 16px;
    width: 26px;
    height: 26px;
    border: none;
    border-radius: 50%;
    background: transparent;
    color: var(--pmfc-text-light);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    opacity: 0;
    transition: opacity 0.15s ease, background 0.15s ease, color 0.15s ease;
}

.pmfc-item:hover .pmfc-item-remove {
    opacity: 1;
}

.pmfc-item-remove:hover {
    background: rgba(230, 57, 70, 0.1);
    color: var(--pmfc-danger);
}

.pmfc-item-remove svg {
    width: 13px;
    height: 13px;
    pointer-events: none;
}

/* =========================================================
   FOOTER
   ========================================================= */
.pmfc-footer {
    flex-shrink: 0;
    padding: 18px 22px 22px;
    border-top: 1px solid var(--pmfc-border);
    background: var(--pmfc-bg);
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.pmfc-footer.pmfc-hidden {
    display: none;
}

.pmfc-subtotal {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-bottom: 14px;
    border-bottom: 1px solid var(--pmfc-border-light);
}

.pmfc-subtotal-label {
    font-size: 14px;
    color: var(--pmfc-text-secondary);
    font-weight: 500;
}

.pmfc-subtotal-value {
    font-size: 19px;
    font-weight: 800;
    color: var(--pmfc-primary);
    letter-spacing: -0.02em;
}

/* Buttons */
.pmfc-btn {
    display: block;
    width: 100%;
    padding: 13px 20px;
    border: none;
    border-radius: var(--pmfc-radius-sm);
    font-size: 15px;
    font-weight: 600;
    text-align: center;
    text-decoration: none;
    cursor: pointer;
    transition: background 0.2s ease,
                transform 0.12s ease,
                box-shadow 0.2s ease,
                color 0.2s ease;
    letter-spacing: 0.01em;
    line-height: 1;
}

.pmfc-btn:active {
    transform: scale(0.98);
}

.pmfc-btn-primary {
    background: var(--pmfc-primary);
    color: #ffffff;
    box-shadow: 0 4px 14px rgba(27, 42, 74, 0.2);
}

.pmfc-btn-primary:hover {
    background: var(--pmfc-primary-hover);
    box-shadow: 0 6px 20px rgba(27, 42, 74, 0.28);
    color: #ffffff;
}

.pmfc-btn-secondary {
    background: transparent;
    color: var(--pmfc-primary);
    border: 1.5px solid var(--pmfc-border);
}

.pmfc-btn-secondary:hover {
    background: var(--pmfc-bg-subtle);
    border-color: var(--pmfc-primary);
    color: var(--pmfc-primary);
}

/* =========================================================
   UTILITY
   ========================================================= */
.pmfc-hidden {
    display: none !important;
}

/* =========================================================
   MOBILE RESPONSIVE
   ========================================================= */
@media screen and (max-width: 480px) {
    :root {
        --pmfc-panel-width: 100vw;
    }

    .pmfc-toggle {
        bottom: 65vh;
        left: 14px;
        width: 50px;
        height: 50px;
    }

    .pmfc-cart-icon {
        width: 22px;
        height: 22px;
    }

    .pmfc-badge {
        min-width: 18px;
        height: 18px;
        line-height: 18px;
        font-size: 10px;
        padding: 0 4px;
        top: -2px;
        right: -2px;
    }

    .pmfc-header {
        padding: 14px 18px;
    }

    .pmfc-title {
        font-size: 16px;
    }

    .pmfc-item {
        padding: 14px 18px;
    }

    .pmfc-item-img {
        width: 60px;
        height: 60px;
    }

    .pmfc-footer {
        padding: 14px 18px 18px;
        padding-bottom: max(18px, env(safe-area-inset-bottom, 18px));
    }

    .pmfc-item-remove {
        opacity: 1;
    }
}

@media screen and (min-width: 481px) and (max-width: 768px) {
    :root {
        --pmfc-panel-width: 380px;
    }

    .pmfc-toggle {
        bottom: 65vh;
        left: 18px;
    }
}

/* =========================================================
   BODY SCROLL LOCK WHEN PANEL IS OPEN
   ========================================================= */
body.pmfc-panel-open .pmfc-toggle {
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
}

body.pmfc-panel-open {
    overflow: hidden;
}

/* =========================================================
   LTR OVERRIDE — Fallback if site direction is LTR
   ========================================================= */
[dir="ltr"] .pmfc-panel {
    right: auto;
    left: 0;
    transform: translateX(-100%);
}

[dir="ltr"] .pmfc-panel.pmfc-active {
    transform: translateX(0);
}

[dir="ltr"] .pmfc-toggle {
    left: auto;
    right: 20px;
}

[dir="ltr"] .pmfc-item-remove {
    left: auto;
    right: 16px;
}

/* =========================================================
   PRINT — Hide floating cart
   ========================================================= */
@media print {
    .pmfc-toggle,
    .pmfc-panel,
    .pmfc-overlay {
        display: none !important;
    }
}
