/**
 * Compose Your Pack - Pack Builder Styles
 *
 * @package ComposeYourPack
 */

/* CSS Variables for easy customization */
:root {
    --cyp-primary-color: #7A1F07;
    --cyp-primary-hover: #5a1705;
    --cyp-secondary-color: #7A1F07;
    --cyp-accent-color: #7A1F07;
    --cyp-success-color: #28a745;
    --cyp-warning-color: #ffc107;
    --cyp-danger-color: #dc3545;
    --cyp-text-color: #333333;
    --cyp-text-light: #666666;
    --cyp-border-color: #e0e0e0;
    --cyp-background: #ffffff;
    --cyp-background-light: #f8f9fa;
    --cyp-slot-bg: #F3EDEB;
    --cyp-slot-border: #7A1F07;
    --cyp-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    --cyp-shadow-lg: 0 4px 20px rgba(0, 0, 0, 0.15);
    --cyp-radius: 12px;
    --cyp-radius-sm: 8px;
    --cyp-transition: all 0.3s ease;
}

/* Reset & Base */
.cyp-pack-builder {
    font-family: Urbanist , BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    max-width: 1000px !important;
    width: 100% !important;
    margin: 0 auto;
    padding: 20px;
    background: var(--cyp-background);
    color: var(--cyp-text-color);
}

.cyp-pack-builder * {
    box-sizing: border-box;
}

/* Main Layout - Side by Side on Desktop */
.cyp-main-layout {
    display: flex !important;
    flex-direction: row !important;
    gap: 30px;
    align-items: flex-start;
}

/* Left Section - Slots */
.cyp-left-section {
    flex: 0 0 auto;
    width: 320px;
}

/* Right Section - Info & Pricing */
.cyp-right-section {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* Header Section */
.cyp-header {
    text-align: left;
}

.cyp-subtitle {
    font-size: 1rem;
    color: var(--cyp-text-color);
    margin: 0 0 12px;
    line-height: 1.5;
}

.cyp-discount-message {
    color: #7A1F07 !important;
    padding: 0;
    font-size: 0.95rem;
    font-weight: 600;
    line-height: 1.4;
    background: none !important;
}

.cyp-message-complete {
    color: #28a745 !important;
    font-weight: 600;
}

/* Slots Container */
.cyp-slots-container {
    margin-bottom: 0;
}

.cyp-slots-grid {
    display: grid !important;
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 10px;
    padding: 0;
    background: transparent;
    border-radius: var(--cyp-radius);
}

/* Individual Slot */
.cyp-slot {
    position: relative;
    aspect-ratio: 1;
    background: #F3EDEB !important;
    border: 1px solid #7A1F07 !important;
    border-radius: 8px !important;
    cursor: pointer;
    transition: var(--cyp-transition);
    overflow: hidden;
    width: 100%;
    max-width: 150px;
    -webkit-border-radius: 8px !important;
    -moz-border-radius: 8px !important;
    -ms-border-radius: 8px !important;
    -o-border-radius: 8px !important;
}

.cyp-slot:hover {
    transform: translateY(-2px);
    box-shadow: var(--cyp-shadow);
}

.cyp-slot.cyp-slot-active {
    border-style: solid !important;
    border-color: #28a745 !important;
}

.cyp-slot-inner {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

/* Empty Slot State */
.cyp-slot-empty {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
}

.cyp-add-btn {
    width: 30px;
    height: 30px;
    border: 2px solid #7A1F07 !important;
    border-radius: 34px !important;
    background: #7A1F07 !important;
    color: #fff !important;
    font-size: 2rem;
    cursor: pointer;
    transition: var(--cyp-transition);
    display: flex;
    align-items: center;
    justify-content: center;
    -webkit-border-radius: 34px !important;
    -moz-border-radius: 34px !important;
    -ms-border-radius: 34px !important;
    -o-border-radius: 34px !important;
}

.cyp-add-btn:hover {
    transform: scale(1.1);
}

.cyp-plus-icon {
    line-height: 1;
    font-weight: 300;
}

/* Filled Slot State */
.cyp-slot-filled {
    position: relative;
    width: 100%;
    height: 100%;
    padding: 8px;
    background: white !important;
    overflow: hidden;
    border-radius: 8px !important;
}

.cyp-product-image {
    max-width: 100% !important;
    height: 70%;
    object-fit: cover;
    margin-left:14px;
    border-radius: var(--cyp-radius-sm);
}

.cyp-product-info {
    text-align: center;
    padding-top: 4px;
}

.cyp-product-name {
    display: block;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--cyp-text-color);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.cyp-product-price {
    display: block;
    font-size: 0.7rem;
    color: var(--cyp-primary-color);
    font-weight: 700;
}

.cyp-remove-btn {
    position: absolute !important;
    top: 5px;
    right: 5px;
    width: 20px;
    height: 20px;
    border: none;
    border-radius: 0;
    background: transparent !important;
    color: #333 !important;
    font-size: 1.1rem;
    font-weight: bold;
    cursor: pointer;
    transition: var(--cyp-transition);
    align-items: center;
    justify-content: center;
    opacity: 1 !important;
    visibility: visible !important;
    z-index: 10;
    line-height: 1;
    box-shadow: none;
    padding: 0;
}

.cyp-remove-btn:hover {
    background: transparent !important;
    color: #000 !important;
    transform: scale(1.2);
}

.cyp-change-btn {
    display: none;
}

.cyp-slot-number {
    position: absolute;
    bottom: -10px;
    right: -10px;
    width: 22px;
    height: 22px;
    background: #7A1F07 !important;
    color: white !important;
    font-size: 0.75rem;
    font-weight: 600;
    border-radius: 50% !important;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 5;
}

/* Pricing Section */
.cyp-pricing-section {
    background: var(--cyp-background-light);
    border-radius: var(--cyp-radius);
    padding: 16px 20px;
    margin-bottom: 16px;
    border-top: 1px solid var(--cyp-border-color);
    border-bottom: 1px solid var(--cyp-border-color);
}

.cyp-pricing-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
}

.cyp-pricing-row:not(:last-child) {
    border-bottom: none;
}

.cyp-pricing-label {
    font-size: 0.9rem;
    color: var(--cyp-text-light);
}

.cyp-pricing-value {
    font-size: 1rem;
    font-weight: 700;
    color: #333 !important;
}

.cyp-total .cyp-pricing-label {
    font-weight: 700;
    color: #7A1F07 !important;
    text-transform: uppercase;
    font-size: 0.85rem;
}

.cyp-total .cyp-pricing-value,
.cyp-total-value {
    font-size: 1.3rem;
    color: #7A1F07 !important;
}

.cyp-strikethrough {
    text-decoration: line-through;
    color: var(--cyp-text-light) !important;
    font-weight: 400;
}

.cyp-savings-amount {
    color: #28a745 !important;
}

/* Action Buttons */
.cyp-actions {
    display: flex;
    flex-direction: row;
    gap: 12px;
    margin-bottom: 0;
}

.cyp-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 20px;
    border: 2px solid transparent;
    border-radius: 8px !important;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--cyp-transition);
    flex: 1;
}

.cyp-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.cyp-btn-primary {
    background: linear-gradient(135deg, #8B6914, #B8860B) !important;
    color: white !important;
    border-color: #8B6914 !important;
}

.cyp-btn-primary:not(:disabled):hover {
    background: linear-gradient(135deg, #6B5210, #8B6914) !important;
    transform: translateY(-2px);
    box-shadow: var(--cyp-shadow);
}

.cyp-btn-secondary {
    background: white !important;
    color: #7A1F07 !important;
    border-color: #e0e0e0 !important;
}

.cyp-btn-secondary:not(:disabled):hover {
    background: #f8f9fa !important;
    transform: translateY(-2px);
    box-shadow: var(--cyp-shadow);
}

.cyp-btn-commander {
    background: linear-gradient(135deg, #7A1F07, #a52a0a) !important;
    color: white !important;
    border-color: #7A1F07 !important;
    width: 100%;
    padding: 14px 24px;
    font-size: 1rem;
}

.cyp-btn-commander:not(:disabled):hover {
    background: linear-gradient(135deg, #5a1705, #7A1F07) !important;
    transform: translateY(-2px);
    box-shadow: var(--cyp-shadow);
}

.cyp-btn-icon {
    font-size: 1.2rem;
}

/* Progress Indicator */
.cyp-progress {
    text-align: center;
    margin-top: 15px;
}

.cyp-progress-bar {
    height: 8px;
    background: #e0e0e0 !important;
    border-radius: 4px !important;
    overflow: hidden;
    margin-bottom: 8px;
}

.cyp-progress-fill {
    height: 100%;
    background-color: #7A1F07 !important;
    border-radius: 4px !important;
    transition: width 0.5s ease;
}

.cyp-progress-text {
    font-size: 0.875rem;
    color: #666 !important;
}

/* Modal Styles */
.cyp-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 999999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    pointer-events: none;
}
/*
.cyp-modal-overlay {
    position: fixed;
    top: var(--cyp-header-height, 150px);
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    pointer-events: auto;
}
*/

.cyp-modal-content {
    position: relative;
    width: 100%;
    max-width: 400px;
    max-height: 70vh;
    background: white;
    border-radius: var(--cyp-radius);
    box-shadow: var(--cyp-shadow-lg);
    display: flex;
    flex-direction: column;
    animation: cyp-modal-in 0.3s ease;
    pointer-events: auto;
    z-index: 1;
}

@keyframes cyp-modal-in {
    from {
        opacity: 0;
        transform: scale(0.95) translateY(20px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.cyp-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid var(--cyp-border-color);
}

.cyp-modal-title {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--cyp-text-color);
}

.cyp-modal-close {
    width: 36px;
    height: 36px;
    border: none;
    background: var(--cyp-background-light);
    color: var(--cyp-text-color);
    font-size: 1.5rem;
    border-radius: 50%;
    cursor: pointer;
    transition: var(--cyp-transition);
    display: flex;
    align-items: center;
    justify-content: center;
}

.cyp-modal-close:hover {
    background: var(--cyp-danger-color);
    color: white;
}

.cyp-modal-search {
    position: relative;
    padding: 12px 20px;
    border-bottom: 1px solid var(--cyp-border-color);
}

.cyp-modal-search input {
    width: 100%;
    padding: 10px 40px 10px 16px;
    border: 1px solid var(--cyp-border-color);
    border-radius: var(--cyp-radius-sm);
    font-size: 1rem;
    transition: var(--cyp-transition);
}

.cyp-modal-search input:focus {
    outline: none;
    border-color: var(--cyp-primary-color);
    box-shadow: 0 0 0 3px rgba(139, 69, 19, 0.1);
}

.cyp-search-icon {
    position: absolute;
    right: 32px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--cyp-text-light);
}

.cyp-modal-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px 20px;
}

/* Express Checkout Modal */
.cyp-express-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 9999999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    pointer-events: none;
}

.cyp-express-modal-overlay {
    position: fixed;
    top: var(--cyp-header-height, 150px);
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    pointer-events: auto;
}

.cyp-express-modal-content {
    position: relative;
    width: 100%;
    max-width: 500px;
    max-height: 80vh;
    background: white;
    border-radius: var(--cyp-radius);
    box-shadow: var(--cyp-shadow-lg);
    padding: 30px;
    overflow-y: auto;
    animation: cyp-modal-in 0.3s ease;
    pointer-events: auto;
    z-index: 1;
}

.cyp-express-modal-close {
    position: absolute;
    top: 15px;
    right: 15px;
    width: 36px;
    height: 36px;
    border: none;
    background: var(--cyp-background-light);
    color: var(--cyp-text-color);
    font-size: 1.5rem;
    border-radius: 50%;
    cursor: pointer;
    transition: var(--cyp-transition);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
}

.cyp-express-modal-close:hover {
    background: var(--cyp-danger-color);
    color: white;
}

/* Products List in Modal */
.cyp-products-grid {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.cyp-product-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--cyp-border-color);
    cursor: pointer;
    transition: var(--cyp-transition);
}

.cyp-product-card:last-child {
    border-bottom: none;
}

.cyp-product-card:hover {
    background: var(--cyp-background-light);
}

.cyp-product-card.cyp-selected {
    background: rgba(40, 167, 69, 0.1);
}

.cyp-product-card.cyp-disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

.cyp-product-card img {
    width: 50px;
    height: 50px;
    object-fit: cover;
    border-radius: var(--cyp-radius-sm);
    flex-shrink: 0;
}

.cyp-product-card-info {
    flex: 1;
    min-width: 0;
}

.cyp-product-card-name {
    display: block;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--cyp-text-color);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.cyp-product-card-price {
    font-size: 0.95rem;
    color: var(--cyp-primary-color);
    font-weight: 700;
    white-space: nowrap;
    margin-left: auto;
}

/* Loading State */
.cyp-products-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px;
    gap: 12px;
    color: var(--cyp-text-light);
}

.cyp-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--cyp-border-color);
    border-top-color: var(--cyp-primary-color);
    border-radius: 50%;
    animation: cyp-spin 1s linear infinite;
}

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

.cyp-no-products {
    text-align: center;
    padding: 40px;
    color: var(--cyp-text-light);
}

/* Toast Notification */
.cyp-toast {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--cyp-text-color);
    color: white;
    padding: 12px 24px;
    border-radius: var(--cyp-radius-sm);
    box-shadow: var(--cyp-shadow-lg);
    z-index: 9999999;
    animation: cyp-toast-in 0.3s ease;
}

.cyp-toast.cyp-toast-success {
    background: var(--cyp-success-color);
}

.cyp-toast.cyp-toast-error {
    background: var(--cyp-danger-color);
}

@keyframes cyp-toast-in {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

/* Responsive Design */
@media (max-width: 768px) {
    .cyp-main-layout {
        flex-direction: column !important;
        gap: 20px !important;
    }
    
    .cyp-left-section {
        width: 100% !important;
        max-width: 350px !important;
        margin: 0 auto !important;
    }
    
    .cyp-right-section {
        width: 100% !important;
    }
    
    .cyp-slots-grid {
        display: grid !important;
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 12px !important;
        max-width: 100% !important;
    }
    
    .cyp-slot {
        width: 100% !important;
        max-width: none !important;
        min-width: 0 !important;
        aspect-ratio: 1 !important;
    }
    
    .cyp-header {
        text-align: center !important;
    }
    
    .cyp-discount-message {
        text-align: center !important;
    }
}

@media (max-width: 480px) {
    .cyp-pack-builder {
        padding: 12px !important;
    }
    
    .cyp-left-section {
        max-width: 280px !important;
    }
    
    .cyp-subtitle {
        font-size: 0.85rem !important;
    }
    
    .cyp-discount-message {
        font-size: 0.8rem !important;
    }
    
    .cyp-slots-grid {
        display: grid !important;
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 8px !important;
        padding: 0 !important;
    }
    
    .cyp-slot {
        aspect-ratio: 1 !important;
    }
    
    .cyp-add-btn {
        width: 35px !important;
        height: 35px !important;
        font-size: 1.3rem !important;
    }
    
    .cyp-product-image {
        height: 60% !important;
    }
    
    .cyp-product-name {
        font-size: 0.65rem !important;
    }
    
    .cyp-product-price {
        font-size: 0.6rem !important;
    }
    
    .cyp-remove-btn {
        width: 18px !important;
        height: 18px !important;
        font-size: 0.9rem !important;
        top: 3px !important;
        right: 3px !important;
    }
    
    .cyp-slot-number {
        width: 18px !important;
        height: 18px !important;
        font-size: 0.65rem !important;
    }
    
    .cyp-pricing-section {
        padding: 12px !important;
    }
    
    .cyp-pricing-label {
        font-size: 0.8rem !important;
    }
    
    .cyp-pricing-value {
        font-size: 0.95rem !important;
    }
    
    .cyp-total .cyp-pricing-value,
    .cyp-total-value {
        font-size: 1.1rem !important;
    }
    
    .cyp-actions {
        flex-direction: column !important;
        gap: 10px !important;
    }
    
    .cyp-btn {
        width: 100% !important;
        padding: 12px 16px !important;
        flex: none !important;
    }
    
    .cyp-product-card img {
        width: 40px;
        height: 40px;
    }
}

/* Animation for slot filling */
.cyp-slot.cyp-filling {
    animation: cyp-pulse 0.5s ease;
}

@keyframes cyp-pulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.05);
    }
}

/* Accessibility */
.cyp-slot:focus,
.cyp-add-btn:focus,
.cyp-remove-btn:focus,
.cyp-btn:focus,
.cyp-product-card:focus {
    outline: 2px solid var(--cyp-primary-color);
    outline-offset: 2px;
}

/* RTL Support */
[dir="rtl"] .cyp-pack-builder {
    direction: rtl;
}

[dir="rtl"] .cyp-remove-btn {
    right: auto;
    left: 4px;
}

[dir="rtl"] .cyp-change-btn {
    left: auto;
    right: 4px;
}

[dir="rtl"] .cyp-slot-number {
    right: auto;
    left: 4px;
}