/**
 * Dynamic Box Capacity Controls CSS
 * 
 * This file contains all the styling for the dynamic box quantity controls
 * that allow users to add/remove empty boxes within defined limits.
 * 
 * @package Custom Product Boxes
 * @version 1.0.0
 */

/* ========================================
   QUANTITY CONTROLS STYLING
   ======================================== */

.wcpb-box-quantity-controls {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    margin: 12px 0;
    gap: 10px;
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    padding: 10px 14px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

/* Max Boxes Message */
.wcpb-max-boxes-message {
    text-align: center;
    margin-bottom: 8px;
}

.wcpb-max-boxes-text {
    font-size: 10px;
    color: #6c757d;
    font-weight: 500;
    background: #e9ecef;
    padding: 6px 12px;
    border-radius: 20px;
    display: inline-block;
}

/* Quantity Controls Wrapper */
.wcpb-quantity-controls-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
}

/* Count Input Field (converted from span) */
.wcpb-box-count {
    width: 35px;
    height: 24px;
    border: 1px solid #dee2e6;
    background: #ffffff;
    border-radius: 3px;
    font-size: 11px;
    font-weight: 600;
    color: #495057;
    text-align: center;
    padding: 1px 2px;
    transition: all 0.2s ease;
}

.wcpb-box-count:focus {
    outline: none;
    border-color: #007cba;
    box-shadow: 0 0 0 2px rgba(0, 124, 186, 0.2);
}

.wcpb-box-count::-webkit-outer-spin-button,
.wcpb-box-count::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.wcpb-box-count[type=number] {
    -moz-appearance: textfield;
}

/* Button Styling */
.wcpb-box-minus,
.wcpb-box-plus {
    width: 24px;
    height: 24px;
    border: 1px solid #dee2e6;
    background: #ffffff;
    border-radius: 3px;
    font-size: 12px;
    font-weight: 600;
    color: #495057;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    user-select: none;
}

.wcpb-box-minus:hover,
.wcpb-box-plus:hover {
    background-color: #e9ecef;
    border-color: #adb5bd;
    transform: scale(1.05);
}

.wcpb-box-minus:active,
.wcpb-box-plus:active {
    transform: scale(0.95);
}

/* ========================================
   HOVER EFFECTS FOR DYNAMIC BOXES
   ======================================== */

/* Card Layout - Empty Box Hover Effects */
body.cpb-card-layout .cpb-product-box-wrap .cpb-empty-box {
    transition: all 0.3s ease-in-out;
    cursor: pointer;
}

body.cpb-card-layout .cpb-product-box-wrap .cpb-empty-box:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

body.cpb-card-layout .cpb-product-box-wrap .cpb-empty-box:hover .cpb-empty-box-inner {
    border-color: #007cba;
    background-color: #f8f9ff;
}

body.cpb-card-layout .cpb-product-box-wrap .cpb-empty-box:hover .cpb-image {
    background-color: #e3f2fd;
    border: 1px solid #bbdefb;
}

body.cpb-card-layout .cpb-product-box-wrap .cpb-empty-box:hover .cpb-title {
    background-color: #e3f2fd;
    border: 1px solid #bbdefb;
}

/* Modern Layout - Empty Box Hover Effects */
body.cpb-modern-layout .wcpb-gift-box-items .wcpb-gift-box-item {
    transition: all 0.3s ease-in-out;
    cursor: pointer;
}

body.cpb-modern-layout .wcpb-gift-box-items .wcpb-gift-box-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

body.cpb-modern-layout .wcpb-gift-box-items .wcpb-gift-box-item:hover .cpb-image {
    background-color: #e3f2fd;
    border: 1px solid #bbdefb;
}

body.cpb-modern-layout .wcpb-gift-box-items .wcpb-gift-box-item:hover .cpb-title {
    background-color: #e3f2fd;
    border: 1px solid #bbdefb;
}

/* ========================================
   HOVER EFFECTS FOR ADDON PRODUCT BOXES
   (ONLY FOR CARD LAYOUT - NOT MODERN)
   ======================================== */

/* Card Layout - Addon Product Box Hover Effects */
body.cpb-card-layout .cpb-products-wrap .cpb-product-inner {
    transition: all 0.3s ease-in-out;
    cursor: pointer;
}

body.cpb-card-layout .cpb-products-wrap .cpb-product-inner:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

body.cpb-card-layout .cpb-products-wrap .cpb-product-inner:hover .cpb-product-image {
    border: 1px solid #007cba;
}

body.cpb-card-layout .cpb-products-wrap .cpb-product-inner:hover .cpb-product-info {
    background-color: #f8f9ff;
    border: 1px solid #bbdefb;
}

/* ========================================
   LAYOUT-SPECIFIC STYLING
   ======================================== */

/* Layout-specific styling */
body.cpb-card-layout .cpb-product-box-wrap .cpb-empty-box .cpb-image {
    width: 160px;
    min-height: 120px;
    background-color: #f9f9f9;
    border: 1px solid transparent;
    transition: all 0.3s ease-in-out;
}

body.cpb-card-layout .cpb-product-box-wrap .cpb-empty-box .cpb-title {
    min-height: 30px;
    background-color: #f9f9f9;
    border: 1px solid transparent;
    transition: all 0.3s ease-in-out;
}

/* Modern Layout (cpb_grid_layout) - wcpb-gift-box-item */
body.cpb-modern-layout .wcpb-gift-box-items .wcpb-gift-box-item {
    width: 160px;
    height: auto;
    margin: 15px;
}

body.cpb-modern-layout .wcpb-gift-box-items .wcpb-gift-box-item .cpb-image {
    border: 1px solid transparent;
    transition: all 0.3s ease-in-out;
}

body.cpb-modern-layout .wcpb-gift-box-items .wcpb-gift-box-item .cpb-title {
    border: 1px solid transparent;
    transition: all 0.3s ease-in-out;
}

/* Default layout styling (fallback) */
body.cpb-default-layout .wcpb-box-quantity-controls {
    /* Basic styling that works for any layout */
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 15px 0;
    gap: 8px;
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    padding: 8px 12px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

/* ========================================
   ANIMATION CLASSES FOR DYNAMIC BOXES
   ======================================== */

/* Enhanced animation for newly added boxes */
.cpb-empty-box.newly-added {
    opacity: 0;
    transform: scale(0.8);
    animation: fadeInScale 0.5s ease-out forwards;
}

/* Ensure newly added boxes are always visible after animation */
.cpb-empty-box:not(.newly-added):not(.removing) {
    opacity: 1;
    transform: scale(1);
    visibility: visible;
}

.cpb-empty-box.removing {
    opacity: 1;
    transform: scale(1);
    animation: fadeOutScale 0.3s ease-in forwards;
}

/* Force visibility for any boxes that might be stuck */
.cpb-empty-box {
    transition: opacity 0.3s ease, transform 0.3s ease, visibility 0.3s ease;
}

/* Emergency visibility override */
.cpb-empty-box[style*="opacity: 1"] {
    opacity: 1;
    transform: scale(1);
    visibility: visible;
}

/* Enhanced animation for grid layout boxes */
.wcpb-gift-box-item.newly-added {
    opacity: 0;
    transform: scale(0.8);
    animation: fadeInScale 0.5s ease-out forwards;
}

/* Ensure grid layout boxes are always visible after animation */
.wcpb-gift-box-item:not(.newly-added):not(.removing) {
    opacity: 1;
    transform: scale(1);
    visibility: visible;
}

.wcpb-gift-box-item.removing {
    opacity: 1;
    transform: scale(1);
    animation: fadeOutScale 0.3s ease-in forwards;
}

/* Force visibility for any grid layout boxes that might be stuck */
.wcpb-gift-box-item {
    transition: opacity 0.3s ease, transform 0.3s ease, visibility 0.3s ease;
}

/* Emergency visibility override for grid layout */
.wcpb-gift-box-item[style*="opacity: 1"] {
    opacity: 1;
    transform: scale(1);
    visibility: visible;
}

/* ========================================
   ANIMATION KEYFRAMES
   ======================================== */

/* Enhanced fadeInScale animation with longer duration */
@keyframes fadeInScale {
    0% {
        opacity: 0;
        transform: scale(0.8);
    }
    50% {
        opacity: 0.7;
        transform: scale(0.9);
    }
    100% {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes fadeOutScale {
    to {
        opacity: 0;
        transform: scale(0.8);
    }
}

/* ========================================
   ENHANCED BUTTON STATES & USER FEEDBACK
   ======================================== */

/* Enhanced disabled button states with visual feedback */
.wcpb-box-minus.disabled,
.wcpb-box-plus.disabled {
    opacity: 0.4;
    cursor: not-allowed;
    background-color: #f8f9fa;
    color: #6c757d;
    border-color: #dee2e6;
    position: relative;
}

.wcpb-box-minus.disabled::after,
.wcpb-box-plus.disabled::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(108, 117, 125, 0.1);
    border-radius: 6px;
    pointer-events: none;
}

/* Safe removal info styling */
.wcpb-safe-removal-info {
    background: #e3f2fd;
    border: 1px solid #2196f3;
    border-radius: 6px;
    padding: 8px 12px;
    margin: 8px 0;
    font-size: 14px;
    color: #1976d2;
    display: none;
    transition: all 0.3s ease;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.wcpb-safe-removal-info.wcpb-info-visible {
    display: block;
    animation: slideIn 0.3s ease;
}

.wcpb-safe-removal-text {
    font-weight: 500;
}

.wcpb-safe-count {
    font-weight: 700;
    color: #1565c0;
}

.wcpb-safe-removal-close {
    background: none;
    border: none;
    color: #1976d2;
    font-size: 18px;
    cursor: pointer;
    padding: 0;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background-color 0.2s ease;
    margin-left: 8px;
}

.wcpb-safe-removal-close:hover {
    background-color: rgba(25, 118, 210, 0.1);
}

/* User feedback messages */
.wcpb-user-feedback {
    background: #fff3cd;
    border: 1px solid #ffc107;
    border-radius: 6px;
    padding: 10px 14px;
    margin: 8px 0;
    font-size: 13px;
    color: #856404;
    display: flex;
    justify-content: space-between;
    align-items: center;
    animation: slideIn 0.3s ease;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    position: relative;
    z-index: 1000;
    max-width: 100%;
    word-wrap: break-word;
}

.wcpb-user-feedback.wcpb-feedback-warning {
    background: #fff3cd;
    border-color: #ffc107;
    color: #856404;
    font-weight: 500;
}

.wcpb-user-feedback.wcpb-feedback-success {
    background: #d4edda;
    border-color: #28a745;
    color: #155724;
    font-weight: 500;
}

.wcpb-user-feedback.wcpb-feedback-error {
    background: #f8d7da;
    border-color: #dc3545;
    color: #721c24;
    font-weight: 500;
}

.wcpb-user-feedback.wcpb-feedback-info {
    background: #e3f2fd;
    border-color: #2196f3;
    color: #1976d2;
    font-weight: 500;
}

.wcpb-feedback-message {
    flex: 1;
    margin-right: 12px;
    font-size: 13px;
    line-height: 1.3;
    font-weight: 500;
}

.wcpb-feedback-close {
    background: none;
    border: none;
    color: inherit;
    font-size: 16px;
    cursor: pointer;
    padding: 0;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.wcpb-feedback-close:hover {
    background-color: rgba(0,0,0,0.1);
}

/* Fade out animation */
.wcpb-user-feedback.fade-out {
    opacity: 0;
    transform: translateY(-10px);
    transition: all 0.3s ease;
}

/* Responsive design for notifications */
@media (max-width: 768px) {
    .wcpb-user-feedback {
        font-size: 12px;
        padding: 8px 12px;
        margin: 6px 0;
    }
    
    .wcpb-feedback-message {
        font-size: 12px;
        margin-right: 10px;
    }
    
    .wcpb-feedback-close {
        font-size: 14px;
        width: 18px;
        height: 18px;
    }
}

/* Slide in animation */
@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ========================================
   RESPONSIVE HOVER EFFECTS
   ======================================== */

/* Mobile hover effects - reduce intensity on touch devices */
@media (max-width: 768px) {
    /* Reduce hover effects on mobile for better performance */
    body.cpb-card-layout .cpb-product-box-wrap .cpb-empty-box:hover,
    body.cpb-modern-layout .wcpb-gift-box-items .wcpb-gift-box-item:hover,
    body.cpb-card-layout .cpb-products-wrap .cpb-product-inner:hover {
        transform: translateY(-1px);
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    }
    
    /* Reduce transition duration on mobile */
    body.cpb-card-layout .cpb-product-box-wrap .cpb-empty-box,
    body.cpb-modern-layout .wcpb-gift-box-items .wcpb-gift-box-item,
    body.cpb-card-layout .cpb-products-wrap .cpb-product-inner {
        transition: all 0.2s ease-in-out;
    }
}

/* ========================================
   ACCESSIBILITY AND FOCUS STATES
   ======================================== */

/* Focus states for keyboard navigation */
body.cpb-card-layout .cpb-product-box-wrap .cpb-empty-box:focus,
body.cpb-modern-layout .wcpb-gift-box-items .wcpb-gift-box-item:focus,
body.cpb-card-layout .cpb-products-wrap .cpb-product-inner:focus {
    outline: 2px solid #007cba;
    outline-offset: 2px;
}

/* ========================================
   MODERN LAYOUT EDITABLE COUNT STYLING
   ======================================== */

/* Editable count span styling */
.wcpb-box-count.editable-count {
    cursor: text;
    padding: 2px 4px;
    border: 1px solid #ddd;
    border-radius: 3px;
    min-width: 30px;
    text-align: center;
    background: #fff;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.wcpb-box-count.editable-count:hover {
    border-color: #007cba;
}

.wcpb-box-count.editable-count:focus {
    outline: none;
    border-color: #007cba;
    box-shadow: 0 0 0 2px rgba(0, 124, 186, 0.2);
}

/* User feedback styling improvements */
.wcpb-user-feedback {
    display: block !important;
    position: relative !important;
    width: 100% !important;
    max-width: 100% !important;
    margin: 10px 0 !important;
    padding: 12px 16px !important;
    padding-right: 50px !important;
    background-color: #e3f2fd !important;
    border: 1px solid #2196f3 !important;
    border-radius: 8px !important;
    color: #1976d2 !important;
    font-size: 14px !important;
    font-weight: 500 !important;
    line-height: 1.4 !important;
    box-shadow: 0 2px 4px rgba(33, 150, 243, 0.1) !important;
    z-index: 1000 !important;
    opacity: 1 !important;
    visibility: visible !important;
}

.wcpb-user-feedback .wcpb-feedback-message {
    display: inline-block !important;
    margin-right: 10px !important;
    color: #1976d2 !important;
    font-weight: 500 !important;
}

.wcpb-user-feedback .wcpb-feedback-close {
    position: absolute !important;
    right: 12px !important;
    top: 50% !important;
    transform: translateY(-50%) !important;
    background: none !important;
    border: none !important;
    font-size: 18px !important;
    font-weight: bold !important;
    color: #2196f3 !important;
    cursor: pointer !important;
    padding: 0 !important;
    margin: 0 !important;
    line-height: 1 !important;
    width: 24px !important;
    height: 24px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    border-radius: 50% !important;
    transition: background-color 0.2s ease !important;
}

.wcpb-user-feedback .wcpb-feedback-close:hover {
    background-color: rgba(33, 150, 243, 0.1) !important;
}

.wcpb-user-feedback.fade-out {
    opacity: 0 !important;
    transform: translateY(-10px) !important;
    transition: opacity 0.3s ease, transform 0.3s ease !important;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    body.cpb-card-layout .cpb-product-box-wrap .cpb-empty-box:hover,
    body.cpb-modern-layout .wcpb-gift-box-items .wcpb-gift-box-item:hover,
    body.cpb-card-layout .cpb-products-wrap .cpb-product-inner:hover {
        border: 2px solid #000000;
        background-color: #ffffff;
    }
}

/* ========================================
   OVERRIDE ANY INLINE STYLES
   ======================================== */

/* Override any inline styles that might be added to images */
.wcpb-gift-box-item img {
    width: auto;
    height: auto;
    cursor: default;
}

/* Ensure hover effects work with existing CPB styles */
.cpb-empty-box-inner {
    transition: all 0.3s ease-in-out;
}

.cpb-product-inner {
    transition: all 0.3s ease-in-out;
}
