/* Single Product Cart Manager Styles */

/* Floating Cart Icon */
.spcm-floating-cart {
    position: fixed;
    z-index: 999999;
    cursor: pointer;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease-in-out;
    background-color: var(--spcm-icon-bg, #0073aa);
    color: var(--spcm-icon-color, #ffffff);
    width: 50px;
    height: 50px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
}

/* Editor-specific styles */
.elementor-editor-active .spcm-floating-cart {
    position: relative !important;
    margin: 20px !important;
    transform: none !important;
    opacity: 1 !important;
    visibility: visible !important;
    pointer-events: auto !important;
    z-index: 1 !important;
    width: 50px !important;
    height: 50px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
}

.elementor-editor-active .spcm-floating-cart.spcm-cart-hidden {
    display: flex !important;
    opacity: 1 !important;
    visibility: visible !important;
    transform: none !important;
    pointer-events: auto !important;
}

.elementor-editor-active .spcm-floating-cart[style*="position: fixed"] {
    position: relative !important;
}

.elementor-editor-active .spcm-floating-cart i {
    font-size: inherit !important;
    line-height: 1 !important;
    margin: 0 !important;
}

.elementor-editor-active .spcm-floating-cart .spcm-cart-count {
    position: absolute !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
}

/* Remove position classes in editor */
.elementor-editor-active .spcm-position-top-right,
.elementor-editor-active .spcm-position-top-left,
.elementor-editor-active .spcm-position-bottom-right,
.elementor-editor-active .spcm-position-bottom-left {
    top: auto !important;
    right: auto !important;
    bottom: auto !important;
    left: auto !important;
}

/* Ensure animations work in editor */
.elementor-editor-active .spcm-animation-bounce,
.elementor-editor-active .spcm-animation-pulse,
.elementor-editor-active .spcm-animation-shake,
.elementor-editor-active .spcm-animation-wiggle,
.elementor-editor-active .spcm-animation-tada {
    animation-play-state: running !important;
}

/* Position Classes - Only apply when not in editor */
body:not(.elementor-editor-active) .spcm-position-bottom-right {
    bottom: 20px;
    right: 60px;
}

body:not(.elementor-editor-active) .spcm-position-bottom-left {
    bottom: 20px;
    left: 60px;
}

body:not(.elementor-editor-active) .spcm-position-top-right {
    top: 20px;
    right: 60px;
}

body:not(.elementor-editor-active) .spcm-position-top-left {
    top: 20px;
    left: 60px;
}

.spcm-floating-cart.spcm-cart-visible {
    opacity: 1;
    visibility: visible;
    transform: scale(1);
}

.spcm-floating-cart.spcm-cart-hidden {
    opacity: 0;
    visibility: hidden;
    transform: scale(0.8);
    pointer-events: none;
}

/* Hide cart when empty, but not in editor */
.elementor-editor-active .spcm-cart-hidden {
    display: flex !important;
}

/* Show cart when has items */
.spcm-cart-visible {
    display: flex;
}

.spcm-floating-cart:hover {
    background-color: var(--spcm-icon-hover-bg, #005a87);
    color: var(--spcm-icon-hover-color, #ffffff);
}

/* Animation Classes */
.spcm-animation-bounce {
    animation: spcm-bounce 1s infinite;
}

.spcm-animation-pulse {
    animation: spcm-pulse 1s infinite;
}

.spcm-animation-shake {
    animation: spcm-shake 1s infinite;
}

.spcm-animation-wiggle {
    animation: spcm-wiggle 1s infinite;
}

.spcm-animation-tada {
    animation: spcm-tada 1s infinite;
}

/* Cart Count Styles */
.spcm-cart-count {
    position: absolute;
    top: -8px;
    right: -8px;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    border-radius: 10px;
    background-color: var(--spcm-count-bg, #ff0000);
    color: var(--spcm-count-color, #ffffff);
    font-size: 12px;
    font-weight: bold;
    line-height: 1;
    text-align: center;
    border: 2px solid white;
}

/* Count Position Classes */
.spcm-count-top-right .spcm-cart-count {
    top: -8px;
    right: -8px;
}

.spcm-count-top-left .spcm-cart-count {
    top: -8px;
    left: -8px;
}

.spcm-count-bottom-right .spcm-cart-count {
    bottom: -8px;
    right: -8px;
}

.spcm-count-bottom-left .spcm-cart-count {
    bottom: -8px;
    left: -8px;
}

/* Animation Keyframes */
@keyframes spcm-bounce {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-10px);
    }
}

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

@keyframes spcm-shake {
    0%, 100% {
        transform: translateX(0);
    }
    25% {
        transform: translateX(-5px);
    }
    75% {
        transform: translateX(5px);
    }
}

@keyframes spcm-wiggle {
    0%, 100% {
        transform: rotate(0);
    }
    25% {
        transform: rotate(-5deg);
    }
    75% {
        transform: rotate(5deg);
    }
}

@keyframes spcm-tada {
    0% {
        transform: scale(1);
    }
    10%, 20% {
        transform: scale(0.9) rotate(-3deg);
    }
    30%, 50%, 70%, 90% {
        transform: scale(1.1) rotate(3deg);
    }
    40%, 60%, 80% {
        transform: scale(1.1) rotate(-3deg);
    }
    100% {
        transform: scale(1) rotate(0);
    }
}

/* Responsive Styles */
@media (max-width: 767px) {
    .spcm-floating-cart {
        transform: scale(0.9);
    }
    
    .spcm-position-bottom-right,
    .spcm-position-bottom-left {
        bottom: 10px;
    }
    
    .spcm-position-top-right,
    .spcm-position-top-left {
        top: 10px;
    }
}

/* Product Button Styles */
.spcm-product-button {
    background-color: #0073aa;
    color: white;
    border: none;
    padding: 12px 24px;
    font-size: 16px;
    font-weight: 600;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    position: relative;
    overflow: hidden;
    display: inline-block;
    text-decoration: none;
    line-height: 1;
}

.spcm-product-button:hover {
    background-color: #005a87;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
    color: white;
    text-decoration: none;
}

.spcm-product-button:active {
    transform: translateY(0);
}

.spcm-product-button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.spcm-product-button.added {
    background-color: #28a745;
}

.spcm-product-button.added:hover {
    background-color: #218838;
}

/* Loading animation */
.spcm-product-button.loading {
    color: transparent;
}

.spcm-product-button.loading::after {
    content: '';
    position: absolute;
    width: 16px;
    height: 16px;
    top: 50%;
    left: 50%;
    margin-left: -8px;
    margin-top: -8px;
    border-radius: 50%;
    border: 2px solid transparent;
    border-top-color: #ffffff;
    animation: spcm-spin 1s ease infinite;
}

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

/* Product info styles for Elementor widget */
.spcm-product-info {
    margin-bottom: 15px;
    text-align: center;
}

.spcm-product-info h3 {
    margin: 0 0 5px 0;
    font-size: 1.2em;
    color: #333;
}

.spcm-product-info .price {
    font-size: 1.1em;
    font-weight: bold;
    color: #0073aa;
}

/* Message styles */
.spcm-message {
    position: fixed;
    z-index: 9999999;
    max-width: 300px;
    padding: 15px 20px;
    margin: 10px;
    border-radius: 4px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    opacity: 0;
    transform: translateY(-20px);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    pointer-events: none;
    border-left-width: 4px;
    border-left-style: solid;
    font-size: 14px;
    line-height: 1.4;
    font-weight: 500;
}

/* Position Classes for Messages */
.spcm-position-top-right {
    top: 20px;
    right: 20px;
    transform: translateX(100%);
}

.spcm-position-top-left {
    top: 20px;
    left: 20px;
    transform: translateX(-100%);
}

.spcm-position-bottom-right {
    bottom: 20px;
    right: 20px;
    transform: translateX(100%);
}

.spcm-position-bottom-left {
    bottom: 20px;
    left: 20px;
    transform: translateX(-100%);
}

.spcm-message-visible {
    opacity: 1;
    transform: translateX(0) translateY(0);
}

/* Success Message */
.spcm-message-success {
    background-color: var(--spcm-success-bg, #28a745);
    color: var(--spcm-success-color, #ffffff);
    border-left-color: var(--spcm-success-border, #218838);
}

/* Error Message */
.spcm-message-error {
    background-color: var(--spcm-error-bg, #dc3545);
    color: var(--spcm-error-color, #ffffff);
    border-left-color: var(--spcm-error-border, #bd2130);
}

/* Responsive Message Styles */
@media (max-width: 767px) {
    .spcm-message {
        max-width: calc(100% - 40px);
        margin: 10px;
        font-size: 13px;
        padding: 12px 16px;
    }
    
    .spcm-position-top-right,
    .spcm-position-top-left {
        top: 10px;
    }
    
    .spcm-position-bottom-right,
    .spcm-position-bottom-left {
        bottom: 10px;
    }
}

/* Elementor button alignment */
.elementor-widget-spcm_single_product_button .elementor-button-wrapper {
    display: flex;
    flex-direction: column;
}

.elementor-widget-spcm_single_product_button .spcm-product-button {
    width: 100%;
    box-sizing: border-box;
    justify-self: stretch;
}

/* Elementor alignment classes */
.elementor-align-left .elementor-button-wrapper {
    align-items: flex-start;
}

.elementor-align-center .elementor-button-wrapper {
    align-items: center;
}

.elementor-align-right .elementor-button-wrapper {
    align-items: flex-end;
}

.elementor-align-justify .spcm-product-button {
    width: 100%;
}

/* Elementor button sizes */
.elementor-size-xs .spcm-product-button {
    padding: 8px 16px;
    font-size: 12px;
}

.elementor-size-sm .spcm-product-button {
    padding: 10px 20px;
    font-size: 14px;
}

.elementor-size-md .spcm-product-button {
    padding: 12px 24px;
    font-size: 16px;
}

.elementor-size-lg .spcm-product-button {
    padding: 15px 30px;
    font-size: 18px;
}

.elementor-size-xl .spcm-product-button {
    padding: 18px 36px;
    font-size: 20px;
}

/* Access page styles */
.spcm-access-page {
    max-width: 800px;
    margin: 0 auto;
    padding: 40px 20px;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.spcm-access-header {
    text-align: center;
    margin-bottom: 40px;
}

.spcm-access-header h1 {
    color: #0073aa;
    font-size: 2.5em;
    margin-bottom: 10px;
}

.spcm-access-content {
    background: #f9f9f9;
    padding: 30px;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.spcm-access-details {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-top: 30px;
}

.spcm-detail-box {
    background: white;
    padding: 20px;
    border-radius: 6px;
    border-left: 4px solid #0073aa;
}

.spcm-detail-box h3 {
    margin-top: 0;
    color: #0073aa;
}

.spcm-detail-box p {
    margin-bottom: 0;
    font-family: monospace;
    background: #f5f5f5;
    padding: 8px;
    border-radius: 4px;
    word-break: break-all;
}

/* Admin styles */
.spcm-admin-notice {
    background: #fff;
    border-left: 4px solid #0073aa;
    padding: 12px;
    margin: 20px 0;
}

.spcm-admin-notice.error {
    border-left-color: #dc3232;
}

.spcm-admin-notice.success {
    border-left-color: #46b450;
}

/* WooCommerce compatibility */
.woocommerce .spcm-product-button {
    margin-bottom: 10px;
}

/* Focus styles for accessibility */
.spcm-floating-cart:focus,
.spcm-product-button:focus {
    outline: 2px solid #0073aa;
    outline-offset: 2px;
}

/* Print styles */
@media print {
    .spcm-floating-cart {
        display: none;
    }
}