/* Legacy Enhanced - Desktop Styles */
/* Matches the horizontal card design from legacy popup */


/* Global Modal Dropdown Styles - Desktop */
.wcas-global-modal.wcas-modal-desktop {
    overflow: visible !important;
    min-width: 700px !important;
    max-width: 800px !important;
    width: 90vw !important;
}

/* Global Modal Dropdown Styles - Mobile */
.wcas-global-modal.wcas-modal-mobile {
    overflow: visible !important;
    min-width: 300px !important;
    max-width: 95vw !important;
    width: 95vw !important;
}

.wcas-dropdown-selected::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 4px;
    background: var(--pack-category-color, #666666);
    border-radius: 0 2px 2px 0;
}

.wcas-dropdown-option.selected::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 4px;
    background: var(--pack-category-color, #666666);
    border-radius: 0 2px 2px 0;
    opacity: 0.8;
}

.wcas-product-info::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 4px;
    background: var(--pack-category-color, #666666);
    border-radius: 2px 0 0 2px;
}

/* ADD MORE ITEMS section - matches legacy background */
.wcas-add-more-section {
    background-color: #f8f9fa !important;
    padding: 0px !important;
    margin: 0 !important;
    border-radius: 0 !important;
}

.wcas-section-title {
    font-size: 18px !important;
    font-weight: 600 !important;
    color: #495057 !important;
    margin: 0 0 15px 0 !important;
    text-align: left !important;
    text-transform: uppercase !important;
    letter-spacing: 0.5px !important;
}

/* Responsive layout switching for separated concerns */
.wcas-desktop-layout {
    display: block;
}

.wcas-mobile-layout {
    display: none;
}

@media (max-width: 768px) {
    .wcas-desktop-layout {
        display: none;
    }
    
    .wcas-mobile-layout {
        display: block;
    }
}

/* Legacy container compatibility */
.wcas-desktop-container {
    display: block;
}

.wcas-mobile-container {
    display: none;
}

@media (max-width: 768px) {
    .wcas-desktop-container {
        display: none;
    }
    
    .wcas-mobile-container {
        display: block;
    }
    
    /* Mobile grid layout with auto-fit responsive columns */
    .wcas-legacy-container,
    .wcas-desktop-container,
    .wcas-products-grid,
    .wcas-current-items-grid {
        display: grid;
        grid-template-columns: 1fr; /* Single column on mobile */
        gap: 12px;
        margin-bottom: 20px;
        padding: 0; /* Removed extra padding on mobile */
    }
    
    .wcas-legacy-card {
        height: auto !important;
        min-height: 140px !important;
        max-width: 100%;
        margin: 0px auto !important;
        width: calc(100% - 40px) !important;
        padding: 0px !important;
    }
    
    /* Mobile layout specific adjustments */
    .wcas-mobile-layout {
        width: 100%;
    }
    
    .wcas-layout-mobile .wcas-mobile-summary {
        min-height: 100px;
    }
}

/* Products grid styles - desktop and mobile */
.wcas-products-grid,
.wcas-current-items-grid,
.wcas-add-more-grid,
.wcas-legacy-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(450px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

/* Ensure desktop retains proper padding */
@media (min-width: 768px) {
    .wcas-products-grid,
    .wcas-current-items-grid,
    .wcas-add-more-grid,
    .wcas-legacy-grid {
        padding: 0; /* No extra padding on desktop either */
    }
}

/* Mobile subscription container adjustments */
@media (max-width: 767px) {
    .wcas-subscription-add-more {
        padding: 0 !important;
        margin: -15px !important;
    }
    
    /* Adjust grid for mobile */
    .wcas-products-grid,
    .wcas-current-items-grid,
    .wcas-add-more-grid,
    .wcas-legacy-grid {
        grid-template-columns: 1fr; /* Single column for narrow mobile screens */
        gap: 12px;
    }
    
    /* Fix mobile card heights for consistent grid appearance */
    .wcas-legacy-mobile {
        min-height: 140px !important;
        height: auto !important;
        display: flex !important;
        flex-direction: column !important;
    }
    
    .wcas-mobile-summary {
        flex: 1 !important;
        display: flex !important;
        flex-direction: column !important;
        min-height: 140px !important;
    }
    
    .wcas-mobile-header {
        flex: 1 !important;
        min-height: 90px !important;
        display: flex !important;
    }
    
    .wcas-mobile-buttons,
    .wcas-mobile-existing-controls {
        flex-shrink: 0 !important;
        min-height: 50px !important;
    }
}

/* Main container for legacy cards - exact Bootstrap grid layout */
.wcas-legacy-container,
.wcas-desktop-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
    max-width: 100%;
    padding: 15px;
}

/* Make single column on smaller desktop screens */
@media (max-width: 991px) {
    .wcas-legacy-container,
    .wcas-desktop-container {
        grid-template-columns: 1fr;
    }
}

/* Individual legacy card - exact match to legacy structure */
.wcas-legacy-card {
    position: relative;
    height: 200px;
    max-width: 500px;
    margin: 10px auto;
    box-shadow: none !important;
    border: none !important;
    border-radius: 0 !important;
    background: transparent !important;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

/* Remove hover transform effects */
.wcas-legacy-card:hover {
    /* No hover effects */
}

/* Card being edited */
.wcas-legacy-card.wcas-editing {
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

/* Existing items have subtle visual indicator */
.wcas-legacy-card.wcas-existing-item .wcas-legacy-summary {
    border-left: 3px solid #28a745 !important;
}

/* Legacy summary - with padding */
.wcas-legacy-summary {
    display: flex !important;
    background-color: #fff !important;
    border: 1px solid #d2d8e0 !important;
    border-radius: 0 !important;
    align-items: stretch;
    flex: 1;
    padding: 5px;
}

/* Thumbnail section - auto width, fixed height */
.wcas-legacy-thumbnail {
    padding: 10px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    background: #fff;
    height: 100px;
    width: auto;
}

.wcas-legacy-thumbnail img {
    width: auto !important;
    height: 90px !important;
    object-fit: contain !important;
    border-radius: 0 !important;
    display: block !important;
    /* transition: opacity 0.2s ease; */
}

/* Remove thumbnail hover effects */
.wcas-legacy-thumbnail:hover img {
    /* No hover effects */
}

/* Info section - middle area - more compact like legacy */
.wcas-legacy-info {
    flex: 1 !important;
    padding: 8px 12px !important;
    display: flex !important;
    flex-direction: column !important;
    justify-content: center !important;
    min-width: 0 !important; /* Allow text truncation */
}

.wcas-legacy-title {
    font-weight: 700 !important;
    margin-bottom: 3px !important;
    font-size: 16px !important;
    color: #7d7d7d !important;
    line-height: 1.2 !important;
    display: flex;
    align-items: center;
}

.wcas-edit-hint {
    font-size: 11px !important;
    color: #666 !important;
    font-weight: normal !important;
    margin-left: 8px !important;
    opacity: 0.7 !important;
    cursor: pointer;
}

.wcas-legacy-description {
    font-size: 14px !important;
    color: #7d7d7d !important;
    line-height: 1.3 !important;
    margin: 0 !important;
    display: -webkit-box !important;
    -webkit-line-clamp: 2 !important;
    -webkit-box-orient: vertical !important;
    overflow: hidden !important;
    flex: 1 !important;
}

.wcas-current-info {
    font-size: 11px !important;
    color: #28a745 !important;
    margin-top: 4px !important;
    font-weight: 500 !important;
}

/* Bottom buttons section - no padding, no min-height */
.wcas-legacy-buttons {
    display: flex !important;
    gap: 6px !important;
    justify-content: stretch !important;
    background: transparent !important;
    border-radius: 0 !important;
    align-items: stretch !important;
    border-top: none !important;
}

/* Legacy actions wrapper (for existing items) */
.wcas-legacy-actions-wrapper {
    padding: 8px !important;
    display: flex !important;
    gap: 6px !important;
    justify-content: center !important;
    background: #fff;
}

/* WCAS buttons - enhanced style for theme */
.wcas-btn {
    cursor: pointer !important;
    width: auto !important;
    flex: 1 !important;
    /* transition: all 0.2s ease !important; */
    color: #273376 !important;
    background-color: #fff !important;
    border: 1px solid #d2d8e0 !important;
    line-height: 14px !important;
    font-size: 16px !important;
    border-radius: 0 !important;
    display: flex !important;
    flex-direction: row !important;
    gap: 20px;
    justify-content: center !important;
    align-items: center !important;
    padding: 8px 12px !important;
    font-family: inherit;
    min-height: 36px !important;
    margin: 0 !important;
    pointer-events: auto !important;
}

.wcas-btn:hover {
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.wcas-btn:active {
    /* No transform effects */
}

/* One-time button - exact legacy colors */
.wcas-btn-onetime {
    color: #273376 !important;
    background-color: #fff !important;
    border: 1px solid #d2d8e0 !important;
}

.wcas-btn-onetime:hover {
    background-color: #f8f9fa !important;
    border-color: #6c757d !important;
    color: #495057 !important;
}

/* Subscribe button - same as one-time button */
.wcas-btn-subscribe {
    color: #273376 !important;
    background-color: #fff !important;
    border: 1px solid #d2d8e0 !important;
}

.wcas-btn-subscribe:hover {
    background-color: #f8f9fa !important;
    border-color: #6c757d !important;
    color: #495057 !important;
}

/* WCAS button text and price styling */
.wcas-btn-text {
    font-weight: 500 !important;
    font-size: 14px !important;
}

.wcas-btn-price {
    font-weight: 600 !important;
    font-size: 12px !important;
    color: #28a745 !important;
    margin-top: 0 !important;
}

/* Existing item controls */
.wcas-existing-controls {
    display: flex !important;
    gap: 4px !important;
    margin-top: 2px !important;
}

.wcas-btn-edit,
.wcas-btn-remove {
    flex: 1 !important;
    padding: 4px 8px !important;
    font-size: 11px !important;
    border-radius: 2px !important;
    cursor: pointer !important;
    /* transition: all 0.2s ease !important; */
    font-family: inherit;
}

.wcas-btn-edit {
    color: #007cba !important;
    background: #fff !important;
    border: 1px solid #007cba !important;
}

.wcas-btn-edit:hover {
    background: #007cba !important;
    color: #fff !important;
}

.wcas-btn-remove {
    color: #dc3545 !important;
    background: #fff !important;
    border: 1px solid #dc3545 !important;
}

.wcas-btn-remove:hover {
    background: #dc3545 !important;
    color: #fff !important;
}

/* Edit Panel - slides down below card */
.wcas-edit-panel {
    background: #f8f9fa !important;
    border: 1px solid #d2d8e0 !important;
    border-top: none !important;
    padding: 12px !important;
    border-radius: 0 0 4px 4px !important;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.05);
}

.wcas-edit-content {
    display: flex !important;
    gap: 16px !important;
    align-items: center !important;
}

.wcas-edit-variations,
.wcas-edit-frequency {
    display: flex;
    flex-direction: column;
}

.wcas-edit-variations label,
.wcas-edit-frequency label {
    font-size: 12px !important;
    font-weight: 600 !important;
    color: #555 !important;
    margin-bottom: 4px !important;
    display: block !important;
}

.wcas-variation-select,
.wcas-frequency-select {
    width: 100% !important;
    padding: 6px 8px !important;
    border: 1px solid #ddd !important;
    border-radius: 3px !important;
    font-size: 13px !important;
    background: #fff;
    font-family: inherit;
}


.wcas-edit-actions {
    display: flex !important;
    gap: 6px !important;
    margin-left: auto !important;
}

.wcas-btn-save,
.wcas-btn-cancel {
    padding: 6px 12px !important;
    border: none !important;
    border-radius: 3px !important;
    cursor: pointer !important;
    font-size: 12px !important;
    /* transition: all 0.2s ease !important; */
    font-family: inherit;
}

.wcas-btn-save {
    background: #28a745 !important;
    color: #fff !important;
}

.wcas-btn-save:hover {
    background: #218838 !important;
}

.wcas-btn-cancel {
    background: #6c757d !important;
    color: #fff !important;
}

.wcas-btn-cancel:hover {
    background: #5a6268 !important;
}

/* Loading states */
.wcas-legacy-card[data-loading="true"] {
    opacity: 0.7;
    pointer-events: none;
}

.wcas-legacy-card[data-loading="true"]::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid #f3f3f3;
    border-top: 2px solid #273376;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    z-index: 10;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Responsive adjustments for smaller screens */
@media (max-width: 768px) {
    .wcas-legacy-summary {
        height: auto !important;
        min-height: 100px !important;
    }
    
    .wcas-legacy-actions {
        width: 160px !important;
        min-width: 160px !important;
        padding: 6px !important;
    }
    
    .wcas-legacy-btn {
        font-size: 12px !important;
        padding: 6px 8px !important;
    }
    
    .wcas-edit-content {
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 12px !important;
    }
    
    .wcas-edit-actions {
        margin-left: 0 !important;
    }
}

/* Very small mobile screens */
@media (max-width: 480px) {
    .wcas-legacy-summary {
        flex-direction: column !important;
        height: auto !important;
    }
    
    .wcas-legacy-thumbnail {
        width: 100% !important;
        max-width: 100% !important;
        min-width: auto !important;
        padding: 8px !important;
        border-right: none !important;
        border-bottom: 1px solid #f0f0f0 !important;
    }
    
    .wcas-legacy-actions {
        width: 100% !important;
        min-width: auto !important;
        border-left: none !important;
        border-top: 1px solid #f0f0f0 !important;
        flex-direction: row !important;
        padding: 8px !important;
    }
    
    .wcas-legacy-btn {
        flex: 1 !important;
    }
    
    .wcas-existing-controls {
        width: 100% !important;
        margin-top: 4px !important;
    }
}

/* Modal Custom Dropdown Styles */
.wcas-modal-dropdown .wcas-dropdown-selected {
    display: flex !important;
    align-items: center !important;
    gap: 8px !important;
    cursor: pointer !important;
    /* transition: border-color 0.2s ease !important; */
}

.wcas-modal-dropdown .wcas-dropdown-selected:hover {
    border-color: #007cba !important;
}

.wcas-modal-dropdown .wcas-dropdown-selected:focus {
    outline: none !important;
    border-color: #007cba !important;
    box-shadow: 0 0 0 1px rgba(0, 124, 186, 0.25) !important;
}

.wcas-modal-dropdown .wcas-dropdown-options {
    position: absolute !important;
    top: 100% !important;
    left: 0 !important;
    right: 0 !important;
    background: #fff !important;
    border: 1px solid #ddd !important;
    border-top: none !important;
    border-radius: 0 0 4px 4px !important;
    max-height: 200px !important;
    overflow-y: auto !important;
    z-index: 10000 !important;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15) !important;
}

.wcas-modal-dropdown .wcas-dropdown-option {
    display: flex !important;
    align-items: center !important;
    gap: 8px !important;
    padding: 10px 12px !important;
    border-bottom: 1px solid #f0f0f0 !important;
    cursor: pointer !important;
    /* transition: background-color 0.2s ease !important; */
}

.wcas-modal-dropdown .wcas-dropdown-option:last-child {
    border-bottom: none !important;
}

.wcas-modal-dropdown .wcas-dropdown-option:hover {
    background-color: #f8f9fa !important;
}

.wcas-modal-dropdown .wcas-dropdown-option.wcas-option-selected {
    background-color: #e8f4fd !important;
    border-left: 3px solid #007cba !important;
}

.wcas-modal-dropdown .wcas-option-icon {
    flex-shrink: 0 !important;
}

.wcas-modal-dropdown .wcas-option-text {
    flex: 1 !important;
    font-size: 14px !important;
    color: #333 !important;
}

.wcas-modal-dropdown .wcas-option-price {
    font-size: 13px !important;
    font-weight: 600 !important;
    color: #273376 !important;
    flex-shrink: 0 !important;
}

.wcas-modal-dropdown .wcas-category-color-icon {
    width: 28px !important;
    height: 28px !important;
    flex-shrink: 0 !important;
}

/* Global Modal Styles */
.wcas-global-modal-backdrop {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999999;
}

.wcas-global-modal {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: white;
    border-radius: 8px;
    min-width: 400px;
    max-width: 500px;
    max-height: 95vh;
    z-index: 1000000;
}

.wcas-global-modal .wcas-modal-header {
    padding: 16px 20px;
    border-bottom: 1px solid #e0e0e0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #f8f9fa;
    border-radius: 8px 8px 0 0;
}

.wcas-global-modal .wcas-modal-title {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    color: #333;
}

.wcas-global-modal .wcas-modal-close {
    width: 2rem;
    height: 2rem;
    background-color: rgba(255, 255, 255, 0.95);
    color: #9ca3af;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1), 0 4px 6px rgba(0, 0, 0, 0.05);
    backdrop-filter: blur(8px);
    cursor: pointer;
    border: none;
    margin-left: 12px;
}

.wcas-global-modal .wcas-modal-body {
    padding: 20px;
    /* max-height: 600px; */
    /* overflow: visible; */
    /* min-height: 400px; */
}

.wcas-global-modal .wcas-modal-footer {
    padding: 16px 20px;
    border-top: 1px solid #e0e0e0;
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    background: #f8f9fa;
    border-radius: 0 0 8px 8px;
}

.wcas-global-modal .wcas-modal-cancel {
    padding: 8px 16px;
    background: #6c757d;
    color: #fff;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
}

.wcas-global-modal .wcas-modal-save {
    padding: 8px 16px;
    background: #28a745;
    color: #fff;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
}

/* Global Modal Custom Dropdown */
.wcas-global-modal .wcas-custom-dropdown {
    position: relative;
    width: 100%;
}

.wcas-global-modal .wcas-dropdown-selected {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    background: #fff;
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
}

.wcas-global-modal .wcas-dropdown-selected:hover {
    border-color: #007cba;
}

.wcas-global-modal .wcas-dropdown-options {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: #fff;
    border: 1px solid #ddd;
    border-top: none;
    border-radius: 0 0 4px 4px;
    max-height: 300px;
    overflow-y: auto;
    z-index: 1000;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.wcas-global-modal .wcas-dropdown-option {
    padding: 10px 12px;
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    border-bottom: 1px solid #f0f0f0;
}

.wcas-global-modal .wcas-dropdown-option:hover {
    background-color: #f8f9fa;
}

.wcas-global-modal .wcas-dropdown-option.selected {
    /* background-color: #e8f4fd; */
    /* border-left: 3px solid #007cba; */
}

/* Mobile Modal Responsive Styles */
@media (max-width: 768px) {
    .wcas-global-modal {
        top: 5%;
        left: 5%;
        right: 5%;
        /* bottom: 5%; */
        transform: none;
        width: auto !important;
        min-width: auto !important;
        max-width: none !important;
        /* height: 90%; */
        max-height: 90%;
        /* min-height: 90%; */
    }
    
    .wcas-global-modal.wcas-modal-mobile {
        /* Override desktop constraints for mobile */
        min-width: 300px !important;
        max-width: 95vw !important;
        width: auto !important;
    }
    
    .wcas-global-modal .wcas-modal-body {
        /* max-height: calc(90vh - 140px); */
        padding: 15px;
        min-height: 420px;
    }
    
    .wcas-global-modal .wcas-modal-header {
        padding: 12px 15px;
    }
    
    .wcas-global-modal .wcas-modal-footer {
        padding: 12px 15px;
        flex-direction: row;
        gap: 8px;
    }
    
    .wcas-global-modal .wcas-modal-cancel,
    .wcas-global-modal .wcas-modal-save {
        flex: 1;
        padding: 12px 16px;
        font-size: 14px;
    }
    
    .wcas-global-modal .wcas-modal-title {
        font-size: 14px;
        line-height: 1.3;
    }
    
    .wcas-global-modal .wcas-dropdown-options {
        max-height: 150px;
    }
    
    /* Touch-friendly interactions on mobile */
    .wcas-global-modal.wcas-modal-mobile .wcas-modal-close {
        width: 2.5rem;
        height: 2.5rem;
        font-size: 18px;
    }
    
    .wcas-global-modal.wcas-modal-mobile .wcas-custom-dropdown .wcas-dropdown-selected {
        min-height: 44px;
    }
    
    .wcas-global-modal.wcas-modal-mobile .wcas-dropdown-option {
        min-height: 44px;
        padding: 12px;
    }
}