/* Builder CSS - Premium Redesign */

:root {
    --builder-bg-gradient: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    --card-hover-transform: translateY(-5px);
    --transition-speed: 0.3s;
    --glass-bg: rgba(255, 255, 255, 0.7);
    --glass-border: 1px solid rgba(255, 255, 255, 0.5);
    --glass-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.1);
}

[data-theme="dark"] {
    --builder-bg-gradient: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    --glass-bg: rgba(30, 30, 46, 0.7);
    --glass-border: 1px solid rgba(255, 255, 255, 0.1);
}

body {
    background: var(--bg-color);
    /* Fallback */
}

/* Main Layout */
.builder-container {
    max-width: 1400px;
    margin: 40px auto;
    padding: 0 40px;
    min-height: 80vh;
}

.builder-header {
    text-align: center;
    margin-bottom: 50px;
}

.builder-title {
    font-size: 2.5em;
    font-weight: 800;
    margin-bottom: 10px;
    background: var(--primary-gradient);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.builder-subtitle {
    font-size: 1.1em;
    opacity: 0.7;
    max-width: 600px;
    margin: 0 auto;
}

/* Status Bar (Redesigned) */
.status-bar-container {
    display: flex;
    justify-content: center;
    gap: 30px;
    margin-bottom: 40px;
    flex-wrap: wrap;
}

.status-pill {
    background: var(--card-bg);
    padding: 10px 25px;
    border-radius: 50px;
    box-shadow: var(--shadow-light);
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 600;
    border: 1px solid var(--border-color);
}

.status-pill i {
    color: var(--primary-color);
}

.status-pill.success i {
    color: #10b981;
}

.status-pill.warning i {
    color: #f59e0b;
}

.status-pill.error {
    background: #fef2f2;
    border-color: #ef4444;
}

.status-pill.error i {
    color: #ef4444;
}

/* Component Grid */
.component-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 30px;
    margin-bottom: 60px;
}

/* Component Card */
.component-card {
    background: var(--card-bg);
    border-radius: 20px;
    padding: 25px;
    position: relative;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-light);
    transition: all var(--transition-speed) ease;
    display: flex;
    flex-direction: column;
    min-height: 320px;
    overflow: hidden;
}

.component-card:hover {
    transform: var(--card-hover-transform);
    box-shadow: var(--shadow-medium);
    border-color: var(--primary-color);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.component-type {
    font-size: 0.9em;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-color);
    opacity: 0.6;
    font-weight: 700;
}

.card-icon {
    font-size: 1.2em;
    color: var(--primary-color);
    opacity: 0.8;
}

/* Empty State */
.component-card.empty {
    border-style: dashed;
    border-width: 2px;
    background: transparent;
}

.empty-state-content {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    gap: 15px;
    color: var(--text-color);
    opacity: 0.5;
}

.add-component-btn {
    margin-top: auto;
    width: 100%;
    padding: 12px;
    border-radius: 12px;
    border: none;
    background: var(--tag-bg);
    color: var(--text-color);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
}

.add-component-btn:hover {
    background: var(--primary-color);
    color: white;
}

/* Filled State */
.component-card.filled {
    border-style: solid;
}

.product-preview {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    margin-bottom: 20px;
}

.product-img {
    width: 120px;
    height: 120px;
    object-fit: contain;
    margin-bottom: 15px;
    transition: transform 0.3s;
}

.component-card:hover .product-img {
    transform: scale(1.1);
}

.product-name {
    font-size: 1.1em;
    font-weight: 700;
    margin-bottom: 5px;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.product-price {
    font-size: 1.2em;
    color: var(--primary-color);
    font-weight: 600;
}

.card-actions {
    display: flex;
    gap: 10px;
    margin-top: auto;
}

.action-btn {
    flex: 1;
    padding: 10px;
    border-radius: 10px;
    border: 1px solid var(--border-color);
    background: transparent;
    cursor: pointer;
    transition: all 0.2s;
    font-weight: 600;
    color: var(--text-color);
}

.action-btn.edit:hover {
    background: var(--tag-bg);
    border-color: var(--text-color);
}

.action-btn.remove {
    color: #ef4444;
    border-color: rgba(239, 68, 68, 0.2);
}

.action-btn.remove:hover {
    background: #fef2f2;
    border-color: #ef4444;
}

/* Summary Footer */
.builder-footer {
    position: sticky;
    bottom: 20px;
    background: var(--header-bg);
    border-radius: 16px;
    padding: 20px 40px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
    border: 1px solid var(--border-color);
    z-index: 100;
    backdrop-filter: blur(10px);
}

.total-price-display {
    text-align: right;
}

.total-label {
    font-size: 0.9em;
    opacity: 0.7;
    margin-bottom: 5px;
    display: block;
}

.total-amount {
    font-size: 2em;
    font-weight: 800;
    background: var(--primary-gradient);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.buy-now-btn {
    background: var(--primary-gradient);
    color: white;
    border: none;
    padding: 15px 40px;
    border-radius: 12px;
    font-size: 1.1em;
    font-weight: 700;
    cursor: pointer;
    box-shadow: var(--shadow-medium);
    transition: all 0.3s;
}

.buy-now-btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-strong);
}

/* Selection Overlay (Slide Up) */
#part-selection-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 2000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s;
    backdrop-filter: blur(5px);
    display: flex;
    justify-content: center;
    align-items: center;
}

#part-selection-overlay.active {
    opacity: 1;
    visibility: visible;
}

.selection-modal {
    width: 90%;
    max-width: 1000px;
    max-height: 85vh;
    background: var(--card-bg);
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform: translateY(50px);
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    border: 1px solid var(--border-color);
}

#part-selection-overlay.active .selection-modal {
    transform: translateY(0);
}

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

.modal-title {
    font-size: 1.5em;
    font-weight: 700;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.2em;
    cursor: pointer;
    color: var(--text-color);
    padding: 10px;
    border-radius: 50%;
    transition: background 0.2s;
}

.modal-close:hover {
    background: var(--tag-bg);
}

.modal-body {
    flex-grow: 1;
    overflow-y: auto;
    padding: 30px;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 20px;
    background: var(--bg-color);
}

/* Selection Item Card */
.selection-item {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 15px;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    transition: all 0.2s;
    cursor: pointer;
}

.selection-item:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-medium);
    border-color: var(--primary-color);
}

.selection-item img {
    width: 100px;
    height: 100px;
    object-fit: contain;
    margin-bottom: 10px;
}

.selection-item h4 {
    font-size: 0.95em;
    margin-bottom: 5px;
    line-height: 1.3;
}

.selection-item .price {
    color: var(--primary-color);
    font-weight: 700;
    margin-top: auto;
    padding-top: 10px;
}

/* Compatibility UI */
.selection-item.incompatible-part {
    opacity: 0.6;
    cursor: not-allowed;
    filter: grayscale(0.5);
    border-color: #fee2e2;
}

.part-badge {
    position: absolute;
    top: 10px;
    right: 10px;
    font-size: 0.65em;
    padding: 4px 8px;
    border-radius: 4px;
    font-weight: 800;
    text-transform: uppercase;
}

.part-badge.comp-ok {
    background: #ecfdf5;
    color: #059669;
}

.part-badge.comp-err {
    background: #fef2f2;
    color: #ef4444;
}

.comp-reason {
    font-size: 0.75em;
    color: #ef4444;
    font-weight: 600;
    margin-top: 5px;
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.component-card {
    animation: fadeIn 0.5s ease backwards;
}

.component-card:nth-child(1) {
    animation-delay: 0.1s;
}

.component-card:nth-child(2) {
    animation-delay: 0.15s;
}

.component-card:nth-child(3) {
    animation-delay: 0.2s;
}

.component-card:nth-child(4) {
    animation-delay: 0.25s;
}

.component-card:nth-child(5) {
    animation-delay: 0.3s;
}

.component-card:nth-child(6) {
    animation-delay: 0.35s;
}