@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;700&display=swap');

:root {
    /* Default Colors */
    --vibe-primary: #4F46E5; /* Indigo */
    --vibe-primary-dark: #4338CA;
    --vibe-slider-bg: #FFFFFF;
    --vibe-form-text-color: #374151; /* --vibe-gray-700 */
    --vibe-input-bg: #FFFFFF;
    --vibe-input-border: #D1D5DB; /* --vibe-gray-300 */
    
    /* Static Colors */
    --vibe-gray-100: #f3f4f6;
    --vibe-gray-900: #111827;
    --vibe-success: #10B981; /* Emerald */
    --vibe-danger: #EF4444; /* Red */
    --vibe-radius: 0.5rem; /* 8px */
    --vibe-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

#vibe-checkout-container {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background: var(--vibe-slider-bg); /* Use dynamic var */
    direction: rtl;
    color: var(--vibe-form-text-color); /* Use dynamic var */
}

.vibe-form-title {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    font-size: 1.25rem; /* 20px */
    font-weight: 700;
    color: var(--vibe-gray-900); /* Title is darker, keep static */
    margin: 0 0 1.5rem 0;
    text-align: center;
}
.vibe-form-title svg {
    width: 24px;
    height: 24px;
    color: var(--vibe-primary);
}

#vibe-checkout-form {
    display: flex;
    flex-direction: column;
    gap: 1rem; /* 16px */
}

.vibe-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.vibe-form-group {
    display: flex;
    flex-direction: column;
    gap: 0.25rem; /* 4px */
}

.vibe-form-group label {
    font-size: 0.875rem; /* 14px */
    font-weight: 500;
    color: var(--vibe-form-text-color); /* Use dynamic var */
    text-align: right;
}

.vibe-form-group label .required {
    color: var(--vibe-danger);
    margin-right: 2px;
}

.vibe-input,
.vibe-quantity-input {
    width: 100%;
    padding: 0.75rem; /* 12px */
    font-size: 1rem; /* 16px */
    border: 1px solid var(--vibe-input-border); /* Use dynamic var */
    border-radius: 0.375rem; /* 6px */
    background-color: var(--vibe-input-bg); /* Use dynamic var */
    color: var(--vibe-form-text-color); /* Use dynamic var */
    transition: border-color 0.2s, box-shadow 0.2s;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    text-align: right;
}

/* Force phone number input to be LTR */
#vibe_billing_phone {
    direction: ltr;
    text-align: left;
}

.vibe-input:focus {
    outline: none;
    border-color: var(--vibe-primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.2);
}

.vibe-input:disabled {
    background-color: var(--vibe-gray-100);
    cursor: not-allowed;
}

/* Variations */
.vibe-variation-radios {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}
.vibe-variation-label {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--vibe-form-text-color); /* Use dynamic var */
    text-align: right;
}
.vibe-radio-group {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    justify-content: flex-start;
}
.vibe-radio-item {
    position: relative;
}
.vibe-radio-input {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}
.vibe-radio-label {
    display: inline-block;
    padding: 0.5rem 1rem;
    border: 2px solid var(--vibe-input-border); /* Use dynamic var */
    border-radius: 9999px;
    cursor: pointer;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--vibe-form-text-color); /* Use dynamic var */
    transition: all 0.2s ease;
}
.vibe-radio-input:checked + .vibe-radio-label {
    background-color: var(--vibe-primary);
    border-color: var(--vibe-primary);
    color: #fff; /* Keep white for contrast */
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.2);
}
.vibe-radio-input:focus + .vibe-radio-label {
    border-color: var(--vibe-primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.2);
}


/* Quantity */
.vibe-quantity-wrapper {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}
.vibe-quantity-wrapper label {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--vibe-form-text-color); /* Use dynamic var */
    text-align: right;
}
.vibe-quantity {
    display: flex;
    align-items: center;
    justify-content: flex-start;
}
.vibe-qty-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border: 1px solid var(--vibe-input-border); /* Use dynamic var */
    background-color: var(--vibe-input-bg); /* Use dynamic var */
    font-size: 1.5rem;
    font-weight: 400;
    color: var(--vibe-form-text-color); /* Use dynamic var */
    cursor: pointer;
    transition: background-color 0.2s;
}
.vibe-qty-btn:hover {
    background-color: var(--vibe-gray-100);
}
/* RTL adjustment: decrease on the right */
.vibe-qty-btn[data-action="decrease"] {
    border-radius: 0 0.375rem 0.375rem 0;
}
/* RTL adjustment: increase on the left */
.vibe-qty-btn[data-action="increase"] {
    border-radius: 0.375rem 0 0 0.375rem;
}
.vibe-qty-input {
    width: 60px;
    height: 44px;
    text-align: center;
    font-size: 1rem;
    font-weight: 700;
    border: 1px solid var(--vibe-input-border); /* Use dynamic var */
    border-left: none;
    border-right: none;
    border-radius: 0;
    padding: 0 0.5rem;
    -moz-appearance: textfield;
}
.vibe-qty-input::-webkit-outer-spin-button,
.vibe-qty-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

/* Shipping */
.vibe-shipping-methods {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    border: 1px solid var(--vibe-input-border); /* Use dynamic var */
    background-color: var(--vibe-gray-100); /* Keep light gray for contrast */
    padding: 1rem;
    border-radius: var(--vibe-radius);
}
.vibe-shipping-methods label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1rem;
    cursor: pointer;
    text-align: right;
    color: var(--vibe-form-text-color); /* Use dynamic var */
}
.vibe-shipping-methods input[type="radio"] {
    width: 1rem;
    height: 1rem;
    accent-color: var(--vibe-primary);
}

/* Summary */
.vibe-order-summary {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    padding: 1rem 0;
    border-top: 1px solid var(--vibe-input-border); /* Use dynamic var */
    margin-top: 1rem;
}
.vibe-summary-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 1rem;
    color: var(--vibe-form-text-color); /* Use dynamic var */
}
.vibe-summary-row.total {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--vibe-form-text-color); /* Use dynamic var */
}
.vibe-summary-row .woocommerce-Price-amount {
    font-weight: 700;
}
.vibe-summary-row.total .woocommerce-Price-amount {
    color: var(--vibe-primary);
}
/* RTL support for price formatting */
.vibe-summary-row span bdi {
    display: inline-block;
}


/* Submit Button */
.vibe-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    padding: 0.875rem 1.5rem; /* 14px 24px */
    font-size: 1.125rem; /* 18px */
    font-weight: 700;
    color: #fff; /* Handled by dynamic style */
    background: linear-gradient(135deg, var(--vibe-primary) 0%, var(--vibe-primary-dark) 100%);
    border: none;
    border-radius: 0.375rem;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(79, 70, 229, 0.3);
}
.vibe-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(79, 70, 229, 0.4);
}
.vibe-btn:active {
    transform: translateY(0);
}
.vibe-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* --- NEW: Secondary "Add to Cart" Button Style --- */
.vibe-btn.vibe-btn-secondary {
    background: var(--vibe-input-bg); /* Use dynamic var */
    border: 2px solid var(--vibe-primary);
    color: var(--vibe-primary);
    box-shadow: none;
    font-size: 1rem; /* Make it slightly smaller */
}
.vibe-btn.vibe-btn-secondary:hover {
    background: #fcfcff;
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(79, 70, 229, 0.1);
}
.vibe-btn.vibe-btn-secondary:active {
    transform: translateY(0);
}
/* Loader for secondary button */
.vibe-btn.vibe-btn-secondary .vibe-btn-loader {
    border-top-color: var(--vibe-primary);
    border-left-color: var(--vibe-primary);
    border-right-color: var(--vibe-primary);
}

/* --- NEW: Button Wrapper --- */
.vibe-submit-wrapper {
    display: flex;
    flex-direction: column; /* Stack buttons */
    gap: 0.75rem; /* Space between buttons */
}


/* Loader for button */
.vibe-btn-loader {
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-top-color: #fff; /* Handled by dynamic style */
    border-radius: 50%;
    animation: vibe-spin 1s linear infinite;
}
@keyframes vibe-spin {
    to { transform: rotate(360deg); }
}

/* --- Floating "Buy Now" Button --- */
.vibe-floating-container {
    position: fixed;
    bottom: 20px;
    left: 15px;
    right: 15px;
    z-index: 998; /* Below slider */
}
#vibe-open-checkout-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem; 
    width: 100%;
    max-width: 450px; /* Match slider width */
    margin: 0 auto;
    animation: vibe-pulse 2s infinite;
}
#vibe-open-checkout-btn svg {
    order: 1; /* RTL: icon on the right */
}

@keyframes vibe-pulse {
    0% {
        box-shadow: 0 4px 15px rgba(79, 70, 229, 0.3);
    }
    70% {
        box-shadow: 0 8px 30px rgba(79, 70, 229, 0.5);
    }
    100% {
        box-shadow: 0 4px 15px rgba(79, 70, 229, 0.3);
    }
}


/* --- Slider Checkout Styles --- */

/* Overlay */
#vibe-checkout-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}
#vibe-checkout-overlay.vibe-active {
    opacity: 1;
    visibility: visible;
}

/* Slider */
#vibe-checkout-slider {
    position: fixed;
    top: 0;
    left: 0; /* Changed from right to left */
    width: 100%;
    max-width: 450px; /* Slider width */
    height: 100%;
    background: var(--vibe-slider-bg); /* Use dynamic var */
    z-index: 1001;
    transform: translateX(-100%); /* Changed from 100% to -100% */
    transition: transform 0.3s ease-in-out;
    display: flex;
    flex-direction: column;
    box-shadow: 5px 0 15px rgba(0,0,0,0.1); /* Changed from -5px */
    direction: rtl; /* Ensure slider content is RTL */
}
#vibe-checkout-slider.vibe-active {
    transform: translateX(0);
}

/* Slider Header */
#vibe-slider-header {
    display: grid; 
    grid-template-columns: 1fr 2fr 1fr; /* 3-col layout: [close] [logo/title] [empty] */
    align-items: center;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--vibe-input-border); /* Use dynamic var */
    flex-shrink: 0;
}

/* Branding wrapper for logo/title */
.vibe-header-branding {
    grid-column: 2 / 3; /* Place in the center column */
    text-align: center;
}
.vibe-header-branding .custom-logo {
    max-height: 40px; /* "small" */
    width: auto;
    object-fit: contain;
    display: inline-block; /* Center it */
    vertical-align: middle;
}
.vibe-header-branding .vibe-slider-sitetitle {
     font-size: 1.1rem;
    font-weight: 700;
    color: var(--vibe-form-text-color); /* Use dynamic var */
}

#vibe-slider-header h3 {
   display: none; /* Hide the "Complete Your Order" text, logo replaces it */
}

#vibe-close-btn {
    grid-column: 1 / 2; /* Place in the first column */
    justify-self: start; /* Align to the start (left for RTL) */
    font-size: 2rem;
    font-weight: 300;
    color: var(--vibe-form-text-color); /* Use dynamic var */
    background: none;
    border: none;
    cursor: pointer;
    padding: 0 0.5rem;
    line-height: 1;
    order: -1; 
}
#vibe-close-btn:hover {
    color: var(--vibe-gray-900);
}

/* Slider Content (scrolling area) */
#vibe-slider-content {
    overflow-y: auto;
    flex-grow: 1;
    padding: 1.5rem; 
}

/* The title inside the form is now redundant */
#vibe-checkout-container .vibe-form-title {
    display: none;
}

/* Responsive */
@media (max-width: 640px) {
    /* State/City grid remains 1fr 1fr */

    .vibe-form-title {
        font-size: 1.125rem;
    }
    
    .vibe-btn {
        font-size: 1rem;
    }
    
    #vibe-checkout-slider {
        max-width: 100%; /* Full width on mobile */
    }
    #vibe-slider-content {
        padding: 1rem;
    }

    .vibe-floating-container {
        bottom: 65px; /* Default 20px + 45px lift */
    }

    /* On mobile, make buttons side-by-side */
    .vibe-submit-wrapper {
        flex-direction: row;
        gap: 0.5rem;
    }
    .vibe-btn.vibe-btn-secondary {
        font-size: 0.875rem; /* Make text smaller to fit */
        padding: 0.75rem 0.5rem; /* Adjust padding */
        flex-shrink: 1; /* Allow to shrink */
    }
    #vibe-submit-btn {
        flex-grow: 1; /* Allow main button to grow */
    }
}