/* ========================================
   CART & CHECKOUT STYLING
   Professional, modern cart experience
   ======================================== */

/* ========================================
   CART ITEM CARD STYLING
   ======================================== */
[data-cart-id] {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
}

[data-cart-id]:hover {
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.08);
    transform: translateY(-2px);
}

[data-cart-id]::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    height: 100%;
    width: 3px;
    background: linear-gradient(180deg, var(--brand-color, #0097A7), transparent);
    opacity: 0;
    transition: opacity 0.3s ease;
    border-radius: 12px 0 0 12px;
}

[data-cart-id]:hover::before {
    opacity: 1;
}

/* ========================================
   QUANTITY ADJUSTMENT BUTTONS
   Smooth hover and active states
   ======================================== */
.qty-btn, [onclick*="updateQty"], [onclick*="guestQtyChange"] {
    transition: all 0.2s ease;
    position: relative;
    overflow: hidden;
}

.qty-btn:hover,
[onclick*="updateQty"]:hover,
[onclick*="guestQtyChange"]:hover {
    background-color: var(--brand-color, #0097A7) !important;
    color: white !important;
    transform: scale(1.05);
}

.qty-btn:active,
[onclick*="updateQty"]:active,
[onclick*="guestQtyChange"]:active {
    transform: scale(0.95);
}

/* Quantity display smooth transition */
.qty {
    transition: all 0.2s ease;
    display: inline-block;
}

/* ========================================
   PRICE DISPLAY ANIMATION
   Smooth price updates
   ======================================== */
[data-total-price],
#cart-total,
#guest-total,
#review-total,
#summary-total {
    transition: color 0.3s ease, transform 0.2s ease;
}

/* Price highlight animation when updated */
@keyframes priceUpdate {
    0% {
        color: var(--brand-color, #0097A7);
        transform: scale(1);
    }
    50% {
        color: #16a34a;
        transform: scale(1.1);
    }
    100% {
        color: var(--brand-color, #0097A7);
        transform: scale(1);
    }
}

.price-updating {
    animation: priceUpdate 0.6s ease;
}

/* ========================================
   REMOVE BUTTON STYLING
   Delete action with confirmation feedback
   ======================================== */
.remove-btn, [onclick*="confirmRemove"] {
    transition: all 0.2s ease;
    position: relative;
}

.remove-btn:hover,
[onclick*="confirmRemove"]:hover {
    background-color: rgba(239, 68, 68, 0.1) !important;
    color: #dc2626 !important;
    transform: scale(1.15);
}

/* ========================================
   CHECKBOX STYLING & SELECTION
   Better visual feedback for item selection
   ======================================== */
.cart-check {
    cursor: pointer;
    transition: all 0.2s ease;
    accent-color: var(--brand-color, #0097A7);
}

[data-cart-id].ring-2,
[data-cart-id].ring-brand {
    box-shadow: inset 0 0 0 2px var(--brand-color, #0097A7),
                0 12px 24px rgba(0, 155, 167, 0.12);
}

/* ========================================
   PRICE BREAKDOWN GRID
   Professional 4-column layout
   ======================================== */
.grid-cols-4 {
    animation: slideIn 0.4s ease-out;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Grid column animations */
.grid-cols-4 > div {
    transition: all 0.2s ease;
}

.grid-cols-4 > div:hover {
    transform: translateY(-2px);
}

/* ========================================
   SPECIAL INSTRUCTIONS BOX
   Prominent display with animation
   ======================================== */
.bg-amber-50,
.bg-gradient-to-r[from-amber-50] {
    animation: fadeInScale 0.4s ease-out 0.1s both;
}

@keyframes fadeInScale {
    from {
        opacity: 0;
        transform: scale(0.95);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* Instruction box icons bounce on hover */
.bg-amber-50 i,
.bg-gradient-to-r[from-amber-50] i {
    transition: transform 0.2s ease;
}

.bg-amber-50:hover i,
.bg-gradient-to-r[from-amber-50]:hover i {
    animation: bounce 0.6s ease;
}

@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-4px); }
}

/* ========================================
   ORDER SUMMARY STYLING
   Professional pricing summary box
   ======================================== */
#cart-subtotal,
#cart-total,
#guest-subtotal,
#guest-total,
#review-subtotal,
#review-total,
#summary-subtotal,
#summary-total {
    font-variant-numeric: tabular-nums;
    transition: all 0.3s ease;
}

/* Summary card hover effects */
.pk-card:has(#summary-total) {
    transition: all 0.3s ease;
    position: sticky;
    top: 100px;
}

.pk-card:has(#summary-total):hover {
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.12);
    transform: translateY(-4px);
}

/* ========================================
   BUTTON ANIMATIONS
   Add to cart and Buy buttons
   ======================================== */
button[type="button"][onclick*="addToCart"],
button[type="button"][onclick*="proceedCheckout"],
button[type="submit"] {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

button[type="button"][onclick*="addToCart"]:hover,
button[type="button"][onclick*="proceedCheckout"]:hover,
button[type="submit"]:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 24px rgba(0, 155, 167, 0.3);
}

button[type="button"][onclick*="addToCart"]:active,
button[type="button"][onclick*="proceedCheckout"]:active,
button[type="submit"]:active {
    transform: translateY(0);
}

/* Ripple effect on button click */
@keyframes ripple {
    from {
        transform: scale(0);
        opacity: 1;
    }
    to {
        transform: scale(4);
        opacity: 0;
    }
}

button::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 1px;
    height: 1px;
    background: rgba(255, 255, 255, 0.5);
    border-radius: 100%;
    transform: scale(0);
}

button:active::after {
    animation: ripple 0.6s ease-out;
}

/* ========================================
   MODAL & DIALOG ANIMATIONS
   Smooth fade-in transitions
   ======================================== */
#address-modal {
    transition: opacity 0.3s ease, background-color 0.3s ease;
}

#address-modal:not(.hidden) {
    animation: fadeIn 0.3s ease-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

/* ========================================
   MOBILE OPTIMIZATION
   Touch-friendly and responsive
   ======================================== */
@media (max-width: 640px) {
    [data-cart-id] {
        border-radius: 0.75rem;
        margin-bottom: 0.5rem;
    }

    [data-cart-id]:hover {
        transform: translateY(-1px);
    }

    /* Larger tap targets on mobile */
    .qty-btn,
    [onclick*="updateQty"],
    [onclick*="guestQtyChange"],
    .remove-btn,
    [onclick*="confirmRemove"] {
        min-height: 44px;
        min-width: 44px;
        padding: 0.75rem !important;
    }

    /* Stack price grid on very small screens */
    .grid-cols-4 {
        gap: 0.5rem;
    }

    .grid-cols-4 > div {
        padding: 0.75rem 0.5rem;
    }

    /* Optimize summary card on mobile */
    .pk-card:has(#summary-total) {
        position: relative;
        top: auto;
        margin-bottom: 1rem;
    }
}

/* ========================================
   LOADING & TRANSITION STATES
   Better UX during async operations
   ======================================== */
@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

.loading {
    animation: pulse 1.5s ease-in-out infinite;
}

/* ========================================
   CART SHAKE ANIMATION
   Visual feedback when item is added
   ======================================== */
@keyframes cartShake {
    0%, 100% { transform: translateX(0) rotate(0deg); }
    15% { transform: translateX(-10px) rotate(-2deg); }
    30% { transform: translateX(10px) rotate(2deg); }
    45% { transform: translateX(-8px) rotate(-1deg); }
    60% { transform: translateX(8px) rotate(1deg); }
    75% { transform: translateX(-4px); }
    90% { transform: translateX(4px); }
}

.cart-shake {
    animation: cartShake 0.5s ease-in-out;
}

/* ========================================
   LOADING SPINNER
   Indicates async operations in progress
   ======================================== */
@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(0, 151, 167, 0.3);
    border-top-color: #0097A7;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 4px;
    vertical-align: middle;
}

.spinner-sm {
    width: 12px;
    height: 12px;
    border-width: 1.5px;
}

.spinner-lg {
    width: 24px;
    height: 24px;
    border-width: 3px;
}

/* ========================================
   FOCUS & ACCESSIBILITY
   Enhanced keyboard navigation
   ======================================== */
button:focus-visible,
input:focus-visible,
select:focus-visible,
[role="button"]:focus-visible {
    outline: 3px solid var(--brand-color, #0097A7);
    outline-offset: 2px;
    border-radius: 4px;
}

/* ========================================
   EMPTY & ERROR STATES
   Professional feedback for empty/error scenarios
   ======================================== */

/* Empty State Card */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 4rem 2rem;
    text-align: center;
    border: 2px dashed #e5e7eb;
    border-radius: 12px;
    background: #fafafa;
    animation: fadeIn 0.3s ease-out;
}

.empty-state i,
.empty-state .icon {
    font-size: 3rem;
    margin-bottom: 1rem;
    opacity: 0.6;
}

.empty-state h3 {
    font-size: 1.125rem;
    font-weight: 600;
    color: #1f2937;
    margin-bottom: 0.5rem;
}

.empty-state p {
    color: #6b7280;
    margin-bottom: 1.5rem;
    font-size: 0.95rem;
}

.empty-state a,
.empty-state button {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    background-color: #0097A7;
    color: white;
    border-radius: 8px;
    text-decoration: none;
    transition: all 0.2s ease;
    border: none;
    cursor: pointer;
    font-size: 0.95rem;
    font-weight: 500;
}

.empty-state-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    background-color: #0097A7;
    color: white;
    border-radius: 8px;
    text-decoration: none;
    transition: all 0.2s ease;
    border: none;
    cursor: pointer;
    font-size: 0.95rem;
    font-weight: 500;
}

.empty-state-btn:hover {
    opacity: 0.9;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 151, 167, 0.3);
}

.empty-state-btn:active {
    transform: translateY(0);
}

/* Error State Card */
.error-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem 2rem;
    text-align: center;
    border-left: 4px solid #ef4444;
    border-radius: 8px;
    background: #fef2f2;
    animation: fadeIn 0.3s ease-out;
}

.error-state.warning {
    border-left-color: #f97316;
    background: #fef3c7;
}

.error-state i {
    font-size: 2.5rem;
    margin-bottom: 1rem;
    color: #ef4444;
}

.error-state.warning i {
    color: #f97316;
}

.error-state h3 {
    font-size: 1.125rem;
    font-weight: 600;
    color: #991b1b;
    margin-bottom: 0.5rem;
}

.error-state.warning h3 {
    color: #92400e;
}

.error-state p {
    color: #7f1d1d;
    margin-bottom: 1.5rem;
    font-size: 0.95rem;
}

.error-state.warning p {
    color: #78350f;
}

.error-state button,
.error-state a {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    background-color: #dc2626;
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.2s ease;
    font-size: 0.95rem;
    font-weight: 500;
}

.error-state.warning button,
.error-state.warning a {
    background-color: #ea580c;
}

.error-state button:hover,
.error-state a:hover {
    opacity: 0.9;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(220, 38, 38, 0.3);
}

.error-state.warning button:hover,
.error-state.warning a:hover {
    box-shadow: 0 4px 12px rgba(234, 88, 12, 0.3);
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}
.field-error {
    display: flex;
    gap: 0.25rem;
    margin-top: 0.25rem;
    font-size: 0.75rem;
    color: #dc2626;
    animation: slideInDown 0.3s ease-out;
}

@keyframes slideInDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

input.border-red-500,
textarea.border-red-500,
select.border-red-500 {
    border-color: #ef4444;
    background-color: rgba(239, 68, 68, 0.02);
}

input.border-red-500:focus,
textarea.border-red-500:focus,
select.border-red-500:focus {
    border-color: #dc2626;
    box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.1);
}

/* Success state */
input.border-green-500,
textarea.border-green-500,
select.border-green-500 {
    border-color: #22c55e;
    background-color: rgba(34, 197, 94, 0.02);
}

input.border-green-500:focus,
textarea.border-green-500:focus,
select.border-green-500:focus {
    border-color: #16a34a;
    box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.1);
}

/* Error icon animation */
.field-error i {
    animation: shake 0.4s ease-in-out;
}

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

/* Screen reader only text */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }

    [data-cart-id]:hover {
        transform: none;
    }

    button:hover {
        transform: none;
    }
}

/* ========================================
   PRINT STYLES
   Optimize for printing orders
   ======================================== */
@media print {
    .remove-btn,
    [onclick*="updateQty"],
    [onclick*="guestQtyChange"],
    button[type="button"],
    button[type="submit"] {
        display: none;
    }

    [data-cart-id] {
        page-break-inside: avoid;
        box-shadow: none;
        border: 1px solid #ddd;
        margin-bottom: 1rem;
    }

    .pk-card {
        box-shadow: none;
        border: 1px solid #ddd;
    }
}

/* ========================================
   LOADING STATE ANIMATIONS
   For async operations and overlays
   ======================================== */
@keyframes fadeOut {
    from {
        opacity: 1;
    }
    to {
        opacity: 0;
    }
}

.animate-fadeOut {
    animation: fadeOut 0.3s ease-out forwards;
}

#loading-overlay {
    animation: fadeIn 0.3s ease-out;
}

#loading-bar {
    animation: pulse 2s ease-in-out infinite;
}

/* ========================================
   CHECKOUT STEP ANIMATIONS
   Smooth transitions between steps
   ======================================== */
@keyframes slideInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideOutUp {
    from {
        opacity: 1;
        transform: translateY(0);
    }
    to {
        opacity: 0;
        transform: translateY(-20px);
    }
}

.checkout-step {
    transition: all 0.3s ease-out;
}

.checkout-step:not(.hidden) {
    animation: slideInUp 0.4s ease-out;
}

.checkout-step.hidden {
    display: none;
}

/* Progress bar styling */
.checkout-progress {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    margin-bottom: 2rem;
}

.progress-dot {
    width: 2.5rem;
    height: 2.5rem;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.875rem;
    transition: all 0.3s ease;
    border: 2px solid #e5e7eb;
    color: #6b7280;
    background: white;
}

.progress-dot.completed {
    border-color: #0097A7;
    background: #0097A7;
    color: white;
    box-shadow: 0 0 0 4px rgba(0, 151, 167, 0.1);
}

.progress-dot.active {
    border-color: #0097A7;
    background: #e0f7fa;
    color: #0097A7;
    box-shadow: 0 0 0 4px rgba(0, 151, 167, 0.2);
    transform: scale(1.1);
}

.progress-line {
    flex: 1;
    height: 2px;
    background: #e5e7eb;
    transition: all 0.3s ease;
    margin: 0 0.25rem;
}

.progress-line.completed {
    background: #0097A7;
}

.progress-label {
    font-size: 0.75rem;
    font-weight: 500;
    text-align: center;
    color: #6b7280;
    margin-top: 0.5rem;
    transition: all 0.3s ease;
}

.progress-dot.active .progress-label,
.progress-dot.completed .progress-label {
    color: #0097A7;
}
