/**
 * Floating Cart Widget - Styles
 * SocialBoost.asia
 * 
 * Features:
 * - Floating button with badge
 * - Cart panel (slide from right)
 * - Shake animation on add
 * - Responsive design
 */

/* ========== CSS Variables ========== */
:root {
    --fc-primary: #5d87ff;
    --fc-primary-dark: #4a6fd4;
    --fc-accent: #fa896b;
    --fc-success: #13deb9;
    --fc-danger: #fa896b;
    --fc-bg: #ffffff;
    --fc-bg-secondary: #f8fafc;
    --fc-text: #1e293b;
    --fc-text-muted: #64748b;
    --fc-border: #e2e8f0;
    --fc-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    --fc-shadow-sm: 0 4px 12px rgba(0, 0, 0, 0.1);
    --fc-radius: 16px;
    --fc-radius-sm: 10px;
    --fc-transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ========== Floating Button ========== */
.fc-floating-btn {
    position: fixed;
    bottom: 100px;
    right: 40px;
    /* ~1cm from edge */
    z-index: 9998;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 70px;
    height: 70px;
    background: linear-gradient(135deg, var(--fc-primary) 0%, var(--fc-primary-dark) 100%);
    border-radius: 50%;
    box-shadow: var(--fc-shadow), 0 0 0 4px rgba(93, 135, 255, 0.2);
    cursor: grab;
    user-select: none;
    touch-action: none;
    transition: transform var(--fc-transition), box-shadow var(--fc-transition);
}

.fc-floating-btn:hover {
    transform: scale(1.05);
    box-shadow: var(--fc-shadow), 0 0 0 6px rgba(93, 135, 255, 0.3);
}

.fc-floating-btn:active,
.fc-floating-btn.is-dragging {
    cursor: grabbing;
    transform: scale(0.95);
}

.fc-floating-btn .fc-icon {
    font-size: 28px;
    color: white;
    line-height: 1;
}

.fc-floating-btn .fc-label {
    font-size: 10px;
    color: rgba(255, 255, 255, 0.9);
    font-weight: 500;
    margin-top: 2px;
}

/* Badge */
.fc-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    min-width: 24px;
    height: 24px;
    padding: 0 6px;
    background: var(--fc-accent);
    color: white;
    font-size: 12px;
    font-weight: 700;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(250, 137, 107, 0.4);
    animation: fc-pulse 2s infinite;
}

.fc-badge.is-zero {
    display: none;
}

@keyframes fc-pulse {

    0%,
    100% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.1);
    }
}

/* Shake Animation */
@keyframes fc-shake {

    0%,
    100% {
        transform: translateX(0) rotate(0);
    }

    10% {
        transform: translateX(-3px) rotate(-5deg);
    }

    20% {
        transform: translateX(3px) rotate(5deg);
    }

    30% {
        transform: translateX(-3px) rotate(-3deg);
    }

    40% {
        transform: translateX(3px) rotate(3deg);
    }

    50% {
        transform: translateX(-2px) rotate(-2deg);
    }

    60% {
        transform: translateX(2px) rotate(2deg);
    }

    70% {
        transform: translateX(-1px) rotate(-1deg);
    }

    80% {
        transform: translateX(1px) rotate(1deg);
    }

    90% {
        transform: translateX(0) rotate(0);
    }
}

.fc-floating-btn.is-shaking {
    animation: fc-shake 0.8s ease-in-out;
}

/* Idle wobble animation */
@keyframes fc-wobble {

    0%,
    100% {
        transform: rotate(0deg);
    }

    25% {
        transform: rotate(2deg);
    }

    75% {
        transform: rotate(-2deg);
    }
}

.fc-floating-btn.is-idle {
    animation: fc-wobble 3s ease-in-out infinite;
}

/* ========== Cart Panel Overlay ========== */
.fc-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 9999;
    opacity: 0;
    visibility: hidden;
    transition: opacity var(--fc-transition), visibility var(--fc-transition);
    backdrop-filter: blur(4px);
}

.fc-overlay.is-open {
    opacity: 1;
    visibility: visible;
}

/* ========== Cart Panel ========== */
.fc-panel {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    max-width: 420px;
    background: var(--fc-bg);
    z-index: 10000;
    transform: translateX(100%);
    transition: transform var(--fc-transition);
    display: flex;
    flex-direction: column;
    box-shadow: -10px 0 40px rgba(0, 0, 0, 0.15);
}

.fc-panel.is-open {
    transform: translateX(0);
}

/* Panel Header */
.fc-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px;
    border-bottom: 1px solid var(--fc-border);
    background: var(--fc-bg);
}

.fc-panel-title {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 18px;
    font-weight: 700;
    color: var(--fc-text);
    margin: 0;
}

.fc-panel-title iconify-icon {
    color: var(--fc-primary);
    font-size: 24px;
}

.fc-panel-count {
    font-size: 14px;
    font-weight: 400;
    color: var(--fc-text-muted);
}

.fc-close-btn {
    width: 36px;
    height: 36px;
    border: none;
    background: var(--fc-bg-secondary);
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--fc-text-muted);
    transition: all var(--fc-transition);
}

.fc-close-btn:hover {
    background: var(--fc-danger);
    color: white;
}

/* Panel Body - Scrollable Items */
.fc-panel-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    background: var(--fc-bg-secondary);
}

/* Empty State */
.fc-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    text-align: center;
}

.fc-empty iconify-icon {
    font-size: 64px;
    color: var(--fc-border);
    margin-bottom: 16px;
}

.fc-empty-text {
    font-size: 16px;
    color: var(--fc-text-muted);
    margin-bottom: 16px;
}

.fc-empty-btn {
    padding: 12px 24px;
    background: var(--fc-primary);
    color: white;
    border: none;
    border-radius: var(--fc-radius-sm);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--fc-transition);
}

.fc-empty-btn:hover {
    background: var(--fc-primary-dark);
    transform: translateY(-2px);
}

/* Cart Item */
.fc-item {
    background: var(--fc-bg);
    border-radius: var(--fc-radius-sm);
    padding: 12px;
    margin-bottom: 12px;
    display: flex;
    gap: 12px;
    box-shadow: var(--fc-shadow-sm);
    transition: all var(--fc-transition);
}

.fc-item:hover {
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.12);
}

.fc-item-img {
    width: 80px;
    height: 80px;
    border-radius: 8px;
    object-fit: cover;
    flex-shrink: 0;
    background: var(--fc-bg-secondary);
}

.fc-item-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.fc-item-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--fc-text);
    margin-bottom: 4px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    line-clamp: 2;
    overflow: hidden;
}

.fc-item-variant {
    font-size: 12px;
    color: var(--fc-text-muted);
    margin-bottom: 8px;
}

.fc-item-price {
    font-size: 15px;
    font-weight: 700;
    color: var(--fc-accent);
}

.fc-item-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: auto;
}

/* Quantity Controls */
.fc-qty-controls {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--fc-bg-secondary);
    border-radius: 8px;
    padding: 4px;
}

.fc-qty-btn {
    width: 28px;
    height: 28px;
    border: none;
    background: var(--fc-bg);
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--fc-text);
    font-size: 16px;
    font-weight: 600;
    transition: all var(--fc-transition);
}

.fc-qty-btn:hover {
    background: var(--fc-primary);
    color: white;
}

.fc-qty-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.fc-qty-value {
    min-width: 24px;
    text-align: center;
    font-size: 14px;
    font-weight: 600;
    color: var(--fc-text);
}

/* Remove Button */
.fc-remove-btn {
    width: 32px;
    height: 32px;
    border: none;
    background: transparent;
    color: var(--fc-text-muted);
    cursor: pointer;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--fc-transition);
}

.fc-remove-btn:hover {
    background: rgba(250, 137, 107, 0.1);
    color: var(--fc-danger);
}

/* Panel Footer - Summary & Checkout */
.fc-panel-footer {
    padding: 16px 20px;
    border-top: 1px solid var(--fc-border);
    background: var(--fc-bg);
}

.fc-summary {
    margin-bottom: 16px;
}

.fc-summary-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 0;
    font-size: 14px;
    color: var(--fc-text-muted);
}

.fc-summary-row.is-total {
    font-size: 18px;
    font-weight: 700;
    color: var(--fc-text);
    padding-top: 12px;
    margin-top: 8px;
    border-top: 2px dashed var(--fc-border);
}

.fc-summary-row.is-total .fc-summary-value {
    color: var(--fc-accent);
}

.fc-summary-row.is-discount .fc-summary-value {
    color: var(--fc-success);
}

/* Voucher Input */
.fc-voucher {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
}

.fc-voucher-input {
    flex: 1;
    padding: 10px 12px;
    border: 1px solid var(--fc-border);
    border-radius: 8px;
    font-size: 14px;
    outline: none;
    transition: border-color var(--fc-transition);
}

.fc-voucher-input:focus {
    border-color: var(--fc-primary);
}

.fc-voucher-btn {
    padding: 10px 16px;
    background: var(--fc-bg-secondary);
    border: 1px solid var(--fc-border);
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    color: var(--fc-text);
    cursor: pointer;
    transition: all var(--fc-transition);
}

.fc-voucher-btn:hover {
    background: var(--fc-primary);
    border-color: var(--fc-primary);
    color: white;
}

/* Checkout Button */
.fc-checkout-btn {
    width: 100%;
    padding: 16px;
    background: linear-gradient(135deg, var(--fc-primary) 0%, var(--fc-primary-dark) 100%);
    color: white;
    border: none;
    border-radius: var(--fc-radius-sm);
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    transition: all var(--fc-transition);
    box-shadow: 0 4px 15px rgba(93, 135, 255, 0.3);
}

.fc-checkout-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(93, 135, 255, 0.4);
}

.fc-checkout-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

/* Login Prompt */
.fc-login-prompt {
    text-align: center;
    padding: 16px;
    background: rgba(93, 135, 255, 0.1);
    border-radius: var(--fc-radius-sm);
    margin-bottom: 16px;
}

.fc-login-prompt p {
    font-size: 14px;
    color: var(--fc-text-muted);
    margin-bottom: 12px;
}

.fc-login-btn {
    padding: 10px 24px;
    background: var(--fc-primary);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--fc-transition);
}

.fc-login-btn:hover {
    background: var(--fc-primary-dark);
}

/* ========== Responsive ========== */
@media (max-width: 576px) {
    .fc-floating-btn {
        width: 60px;
        height: 60px;
        right: 20px;
        bottom: 80px;
    }

    .fc-floating-btn .fc-icon {
        font-size: 24px;
    }

    .fc-floating-btn .fc-label {
        display: none;
    }

    .fc-panel {
        max-width: 100%;
    }

    .fc-item-img {
        width: 70px;
        height: 70px;
    }
}

/* ========== Loading States ========== */
.fc-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px;
}

.fc-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--fc-border);
    border-top-color: var(--fc-primary);
    border-radius: 50%;
    animation: fc-spin 1s linear infinite;
}

@keyframes fc-spin {
    to {
        transform: rotate(360deg);
    }
}

/* Item removing animation */
.fc-item.is-removing {
    opacity: 0;
    transform: translateX(100%);
    max-height: 0;
    padding: 0;
    margin: 0;
    overflow: hidden;
}

/* ========== Toast Notifications ========== */
.fc-toast {
    position: fixed;
    bottom: 180px;
    right: 40px;
    padding: 12px 20px;
    background: var(--fc-text);
    color: white;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    box-shadow: var(--fc-shadow);
    z-index: 10001;
    transform: translateY(20px);
    opacity: 0;
    transition: all var(--fc-transition);
}

.fc-toast.is-visible {
    transform: translateY(0);
    opacity: 1;
}

.fc-toast.is-success {
    background: var(--fc-success);
}

.fc-toast.is-error {
    background: var(--fc-danger);
}

@media (max-width: 576px) {
    .fc-toast {
        left: 20px;
        right: 20px;
        bottom: 160px;
    }
}

/* ========== Promo Code UI ========== */
.fc-voucher {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 16px;
}

.fc-voucher.has-promo {
    gap: 0;
}

.fc-voucher-form {
    display: flex;
    gap: 8px;
}

/* Promo Success Card */
.fc-promo-success {
    background: linear-gradient(135deg, rgba(19, 222, 185, 0.1) 0%, rgba(93, 135, 255, 0.1) 100%);
    border: 1px solid var(--fc-success);
    border-radius: var(--fc-radius-sm);
    padding: 12px;
    animation: fc-promo-appear 0.3s ease;
}

@keyframes fc-promo-appear {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.fc-promo-header {
    display: flex;
    align-items: center;
    gap: 8px;
}

.fc-promo-header iconify-icon {
    font-size: 20px;
    color: var(--fc-success);
}

.fc-promo-code {
    font-weight: 700;
    font-size: 14px;
    color: var(--fc-text);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    flex: 1;
}

.fc-promo-remove {
    width: 24px;
    height: 24px;
    border: none;
    background: rgba(0, 0, 0, 0.1);
    border-radius: 50%;
    cursor: pointer;
    color: var(--fc-text-muted);
    font-size: 16px;
    line-height: 1;
    transition: all var(--fc-transition);
}

.fc-promo-remove:hover {
    background: var(--fc-danger);
    color: white;
}

.fc-promo-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 8px;
    font-size: 13px;
}

.fc-promo-type {
    color: var(--fc-text-muted);
}

.fc-promo-savings {
    color: var(--fc-success);
    font-weight: 600;
}

/* Promo Error */
.fc-promo-error {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    background: rgba(250, 137, 107, 0.1);
    border: 1px solid var(--fc-danger);
    border-radius: var(--fc-radius-sm);
    color: var(--fc-danger);
    font-size: 13px;
    animation: fc-shake 0.4s ease;
}

.fc-promo-error iconify-icon {
    font-size: 18px;
    flex-shrink: 0;
}

/* Bonus Row */
.fc-summary-row.is-bonus {
    color: var(--fc-primary);
}

.fc-summary-row.is-bonus .fc-summary-value {
    font-weight: 600;
    color: var(--fc-success);
}

/* Small Spinner for Button */
.fc-spinner-small {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid currentColor;
    border-top-color: transparent;
    border-radius: 50%;
    animation: fc-spin 0.8s linear infinite;
}

/* Voucher Button Loading State */
.fc-voucher-btn:disabled {
    opacity: 0.8;
    cursor: not-allowed;
}