/* Item Box Styling */
.Case-Container,
.CPU-Container,
.CPU-Selection-Container,
.GPU-Container,
.RAM-Selection-Container,
.Storage-Container,
.CPU-Cooler-Container,
.PSU-Selection-Container,
.Motherboard-Container {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    justify-content: center;
    padding: 20px 0;
    overflow: hidden;
    max-height: 5500px; /* Increased to ensure all content fits */
    opacity: 1;
    transform: translateY(0);
    transition: max-height 0.6s cubic-bezier(0.33, 1, 0.68, 1), 
                opacity 0.4s ease-in-out, 
                transform 0.4s cubic-bezier(0.33, 1, 0.68, 1),
                padding 0.4s cubic-bezier(0.33, 1, 0.68, 1);
    will-change: max-height, opacity, transform; /* Optimize for animation */
    transform-origin: top center;
}

/* Add layout styles for two-column design */
.content-container {
    display: flex;
    width: 100%;
    margin-top: 20px;
}

.current-build {
    width: 30%;
    position: sticky;
    top: 20px;
    height: fit-content;
    background-color: #fff;
    padding: 15px;
    border-radius: 8px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
    margin: 0px 10px;
    align-self: flex-start;
}

.current-build h2 {
    margin-top: 0;
    border-bottom: 1px solid #ddd;
    padding-bottom: 10px;
    padding-top: 0;
}

.current-build ul {
    list-style-type: none;
    padding-left: 0;
    padding: 4px 7.5px;
    font-size: 16px;
    margin: 0;
}

.current-build li:nth-child(6) {
    font-size: 15px;
}

.collapsed {
    transform: rotate(-90deg);
}

.Item {
    background-color: #fff;
    border-radius: 8px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    padding: 30px 30px 40px;
    width: 280px;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
    cursor: pointer;
    border: 3px solid transparent;
}

.Item:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.2);
}

.Item.selected {
    border-color: #27ae60;
    background-color: rgba(52, 152, 219, 0.05);
}

.Item img {
    max-width: 100%;
    height: 180px;
    object-fit: contain;
    margin-top: 30px;
}

.Item h4 {
    margin: 15px 0;
    text-align: center;
}

/* Benchmark Score Styling */
.bench-score {
    color: #3a7bd5;
    font-weight: 600;
    position: absolute;
    bottom: 0px;
    font-size: 0.9em;
}

.Item p {
    color: #e74c3c;
    font-weight: bold;
    position: absolute;
    bottom: 6%;
    font-size: 17px;
    margin: 10px 0;
}

/* Selection indicator */
.Item::after {
    content: "Select";
    position: absolute;
    bottom: -15px;
    left: 50%;
    transform: translateX(-50%);
    background-color: #3498db;
    color: white;
    padding: 5px 15px;
    border-radius: 4px;
    font-size: 14px;
    opacity: 0;
    transition: opacity 0.3s ease, bottom 0.3s ease;
}

.Item:hover::after {
    opacity: 1;
    bottom: -10px;
}

.Item.selected::after {
    content: "Selected";
    background-color: #27ae60;
    opacity: 1;
    bottom: -10px;
}

/* Build Process Section */
.Build-Process {
    max-width: 1300px;
    margin: 30px auto;
    padding: 0 20px;
}

.Build-Process h2 {
    color: #2c3e50;
    border-bottom: 2px solid #3498db;
    padding-bottom: 10px;
    margin: 30px 0 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.Build-Process h2 span {
    color: #3498db;
    cursor: pointer;
    transition: transform 0.3s ease;
    display: inline-block;
}

.Build-Process h2 span.collapsed {
    transform: rotate(-90deg);
}

/* GPU Filter Styles */
.gpu-filter-section, .Storage-Filter-Section {
    width: fit-content;
    min-width: 23%;
    height: fit-content;
    padding: 15px 5px 15px 15px;
    margin-top: 19px;
    background-color: #fff;
    border-radius: 8px;
    margin-bottom: 20px;
    margin-left: 5%;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.gpu-filter-section h4, .Storage-Filter-Section h4 {
    margin-top: 0;
    padding-bottom: 5px;
    margin-bottom: 5px;
    border-bottom: 1px solid #ddd;
}

.gpu-filter-checkboxes, .Storage-Filter-Checkboxes {
    display: flex;
    flex-direction: column;
    padding: 0px;
    gap: 8px;
}

.gpu-filter-checkboxes label, .Storage-Filter-Checkboxes label {
    display: flex;
    cursor: pointer;
    padding: 5px 10px;
    background: #e9e9e9;
    border-radius: 4px;
    transition: background-color 0.2s;
    width: fit-content;
}

.gpu-filter-checkboxes label:hover, .Storage-Filter-Checkboxes label:hover {
    background: #d9d9d9;
}

.gpu-filter-checkboxes input, .Storage-Filter-Checkboxes input {
    margin-right: 6px;
}

/* Vertical Progress Dots */
.build-progress-container {
    position: relative;
    display: flex;
}

.build-progress-container ul {
    flex: 1;
}

.build-progress-container ul li {
    min-height: 24px;
    margin-bottom: 22px;
    display: flex;
    align-items: center;
}

.build-progress-list li p {
    margin: 0;
}

/* Adjust for the image at the top */
.build-progress-container ul div:first-child {
    margin-bottom: 30px;
}

/* Integrated Progress Dots with list items*/
.build-progress-list {
    position: relative;
    list-style: none;
    padding-left: 0;
}

.build-progress-list li {
    position: relative;
    display: flex;
    align-items: center;
    margin-bottom: 20px;
    margin-left: -4px;
    min-height: 24px;
}

.price-summary p {
    margin: 0;
    font-weight: bold;
    color: #333;
}

.progress-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background-color: #e0e0e0;
    border: 2px solid #ccc;
    margin-right: 20px;
    flex-shrink: 0;
    z-index: 2;
    position: relative;
}

.progress-dot.active {
    background-color: #3a7bd5;
    border-color: #2a68c2;
}

.progress-dot.completed {
    background-color: #00d2ff;
    border-color: #00a8cc;
}

/* Fix for the vertical connecting lines */
.progress-line {
    display: none; /* Hide individual progress lines */
}

/* Use a single continuous line behind the dots */
.build-progress-list::before {
    content: "";
    position: absolute;
    left: 9px; /* Center the line on dots */
    top: 16px; /* Start below the first dot */
    bottom: 20px; /* End before the total price row */
    width: 2px;
    background-color: #e0e0e0;
    z-index: 1;
}

/* Style for active connection line */
.build-progress-list.progress-started::before {
    background: linear-gradient(to bottom, 
        #00d2ff 0%, 
        #00d2ff var(--progress-height, 0%), 
        #e0e0e0 100%);
}

/* Special styling for when PSU is selected - no gray line after the last dot */
.build-progress-list.psu-selected::before {
    background: linear-gradient(to bottom, 
        #00d2ff 0%, 
        #00d2ff 70%);
    bottom: 40px; /* Ensure it ends at the bottom of the list */
}

.item-content {
    flex-grow: 1;
    display: flex;
    align-items: center;
}

/* Style for Total Price item which doesn't need a dot */
#Total-Price .item-content {
    margin-left: 33px; /* Equal to dot width + margins to align with other content */
}

/* Animation styles for containers */
.container-closed {
    max-height: 0 !important;
    opacity: 0;
    transform: translateY(-10px);
    padding: 0 !important;
    margin: 0 !important;
    pointer-events: none; /* Prevent interaction while closed */
    transition: max-height 0.5s cubic-bezier(0.33, 1, 0.68, 1), 
                opacity 0.3s ease-in-out,
                transform 0.4s cubic-bezier(0.33, 1, 0.68, 1),
                padding 0.3s ease-in-out, 
                margin 0.3s ease-in-out;
}

/* Special handling for containers with filters */
.GPU-Selection-Container,
.Storage-Selection-Container {
    max-height: 10000px; /* Much larger max-height for these complex containers */
    transition: max-height 0.8s cubic-bezier(0.33, 1, 0.68, 1), 
                opacity 0.5s ease-in-out,
                transform 0.5s cubic-bezier(0.33, 1, 0.68, 1);
}

/* Improved animation timing for filter sections */
.gpu-filter-section, 
.Storage-Filter-Section {
    opacity: 1;
    transform: translateY(0);
    transition: opacity 0.3s ease-in-out, transform 0.4s ease-in-out;
}

.container-closed .gpu-filter-section,
.container-closed .Storage-Filter-Section {
    opacity: 0;
    transform: translateY(-20px);
}

/* Improved animation for filtered item containers */
.GPU-Container,
.Storage-Container {
    transition: opacity 0.4s ease-in-out 0.1s; /* Slight delay to stagger animation */
}

.container-closed .GPU-Container,
.container-closed .Storage-Container {
    opacity: 0;
}

/* Special handling for CPU containers */
.CPU-Selection-Container {
    opacity: 1;
    transition: max-height 0.5s cubic-bezier(0.33, 1, 0.68, 1),
                opacity 0.3s ease-in-out,
                transform 0.3s cubic-bezier(0.33, 1, 0.68, 1);
    max-height: 1500px; /* Set appropriate max-height */
    transform: translateY(0);
}

.container-closed.CPU-Selection-Container {
    max-height: 0 !important;
    opacity: 0;
    transform: translateY(-10px);
    pointer-events: none;
}

/* Improve CPU container transition when selected */
#CPU-Selection-Container {
    transform-origin: top center;
    will-change: transform, opacity, max-height;
    transition: max-height 0.7s cubic-bezier(0.33, 1, 0.68, 1), 
                opacity 0.5s ease-in-out,
                transform 0.5s cubic-bezier(0.33, 1, 0.68, 1);
}

/* Buy Button Styling */
.buy-now-button {
    display: block;
    width: 100%;
    padding: 15px;
    margin-top: 20px;
    background-color: #27ae60;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 18px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.buy-now-button:hover:not(:disabled) {
    background-color: #219653;
    transform: translateY(-2px);
    box-shadow: 0 6px 8px rgba(0, 0, 0, 0.15);
}

.buy-now-button:active:not(:disabled) {
    transform: translateY(0);
    box-shadow: 0 3px 5px rgba(0, 0, 0, 0.1);
}

.buy-now-button:disabled {
    background-color: #95a5a6;
    cursor: not-allowed;
    opacity: 0.7;
}

.loading {
    text-align: center;
    padding: 20px;
    color: #666;
    font-style: italic;
}

.error {
    text-align: center;
    padding: 20px;
    color: #e74c3c;
    font-weight: bold;
}

.no-items {
    text-align: center;
    padding: 20px;
    color: #666;
}

.preowned-badge {
    position: absolute;
    top: 10px;
    right: 10px;
    background-color: #3498db;
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: bold;
}

/* Responsive adjustments */
@media (max-width: 768px) {

    .Case-Container,
    .CPU-Container {
        gap: 15px;
    }

    .Item {
        width: calc(50% - 15px);
        padding: 15px;
    }

    .content-container {
        flex-direction: column;
    }

    .current-build,
    .Build-Process {
        width: 100%;
    }

    .current-build {
        position: relative;
        margin-bottom: 20px;
    }
}

@media (max-width: 480px) {
    .Item {
        width: 100%;
    }
}