/* ============================================
   BUILDER PAGE STYLES
   ============================================ */

.builder-page {
    padding: 24px 0 80px;
    background: var(--bg-primary);
}

@media (max-width: 768px) {
    .builder-page {
        padding: 16px 0 60px;
    }
}

/* Builder Header (Catalog Style) */
.builder-header {
    position: relative;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: clamp(1rem, 2vw, 1.5rem);
    padding-bottom: clamp(1rem, 2vw, 1.25rem);
    margin-bottom: clamp(1.25rem, 2.5vw, 1.5rem);
    border-bottom: 2px solid var(--accent);
}

.builder-header__content {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    flex: 1;
    min-width: 0;
}

.builder-header__title {
    font-size: clamp(1.625rem, 3vw + 0.25rem, 2.25rem);
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
    letter-spacing: -0.01em;
    line-height: 1.2;
}

.builder-header__subtitle {
    font-size: clamp(0.9375rem, 1.5vw + 0.25rem, 1.0625rem);
    color: var(--text-secondary);
    margin: 0;
    line-height: 1.6;
    max-width: 700px;
}

.builder-header__badge {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.375rem 0.875rem;
    background: var(--accent);
    color: #fff;
    font-size: 0.875rem;
    font-weight: 600;
    border-radius: 9999px;
    white-space: nowrap;
    flex-shrink: 0;
    box-shadow: 0 2px 8px rgba(var(--accent-rgb), 0.25);
}

/* Legacy subtitle (voor backwards compatibility) */
.builder-subtitle {
    color: var(--text-secondary);
    font-size: 1rem;
    margin: 0 0 clamp(1.25rem, 2.5vw, 1.5rem) 0;
}

/* Breadcrumb in builder */
.builder-page .breadcrumb {
    margin-bottom: clamp(1rem, 2vw, 1.25rem);
}

.builder-layout {
    display: grid;
    grid-template-columns: 1fr;
    gap: 2rem;
}

@media (min-width: 1024px) {
    .builder-layout {
        grid-template-columns: 1.4fr 1fr;
    }
}

/* Parts List - Clean container (catalog style) */
.parts-list {
    background: transparent;
    border: none;
    border-radius: 0;
    overflow: visible;
    box-shadow: none;
    position: relative;
}

/* Section Header (catalog style accent) */
.parts-list__section-header {
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-primary);
    padding-bottom: 0.5rem;
    margin-bottom: 1rem;
    border-bottom: 2px solid var(--accent);
    display: inline-block;
}

/* Title Row - Combined with buttons */
.parts-list__title-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 1rem;
}

.parts-list__title-left {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.parts-list__title-right {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    position: relative;
}

/* Ghost Button */
.btn--ghost {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid transparent;
    padding: 0.5rem 0.875rem;
    border-radius: 6px;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.btn--ghost:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.btn--sm {
    padding: 0.375rem 0.75rem;
    font-size: 0.8125rem;
}

.btn--xs {
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
}

/* Builds Dropdown - Base styles for desktop */
.builds-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    left: auto;
    bottom: auto;
    width: 320px;
    max-height: min(500px, 70vh);
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 10px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
    z-index: 10000;
    display: flex;
    flex-direction: column;
}

/* Parent needs relative positioning */
.parts-list__title-right {
    position: relative;
}

.builds-dropdown__header {
    padding: 0.875rem 1rem;
    border-bottom: 1px solid var(--border);
    font-weight: 600;
    color: var(--text-primary);
    font-size: 0.875rem;
    flex: 0 0 auto;
}

.builds-dropdown__list {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    overscroll-behavior: contain;
    scrollbar-width: thin;
    scrollbar-color: var(--border) var(--bg-tertiary);
    -webkit-overflow-scrolling: touch;
}

.builds-dropdown__list::-webkit-scrollbar {
    width: 6px;
}

.builds-dropdown__list::-webkit-scrollbar-track {
    background: transparent;
}

.builds-dropdown__list::-webkit-scrollbar-thumb {
    background-color: var(--border);
    border-radius: 3px;
}

.builds-dropdown__item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    cursor: pointer;
    transition: background 0.15s;
    border-bottom: 1px solid var(--border);
}

.builds-dropdown__item:last-child {
    border-bottom: none;
}

.builds-dropdown__item:hover {
    background: var(--bg-tertiary);
}

.builds-dropdown__item--active {
    background: rgba(var(--accent-rgb), 0.1);
}

.builds-dropdown__dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--border);
    flex-shrink: 0;
}

.builds-dropdown__dot--active {
    background: var(--accent);
}

.builds-dropdown__info {
    flex: 1;
    min-width: 0;
}

.builds-dropdown__title {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.builds-dropdown__date {
    display: block;
    font-size: 0.75rem;
    color: var(--text-muted);
}

.builds-dropdown__price {
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--accent);
    font-family: 'Monaco', 'Consolas', monospace;
}

.builds-dropdown__delete {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0.25rem;
    border-radius: 4px;
    opacity: 0;
    transition: all 0.15s;
}

.builds-dropdown__item:hover .builds-dropdown__delete {
    opacity: 1;
}

.builds-dropdown__delete:hover {
    background: var(--error-bg);
    color: var(--error);
}

.builds-dropdown__footer {
    padding: 0.75rem 1rem;
    border-top: 1px solid var(--border);
    background: var(--bg-tertiary);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
    flex: 0 0 auto;
}

.builds-dropdown__footer-left {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.builds-dropdown__count {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.builds-dropdown__login {
    font-size: 0.75rem;
    color: var(--accent);
    text-decoration: none;
}

.builds-dropdown__login:hover {
    text-decoration: underline;
}

.builds-dropdown__clear-all {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.375rem 0.625rem;
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--error);
    background: transparent;
    border: 1px solid var(--error);
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.15s;
}

.builds-dropdown__clear-all:hover {
    background: var(--error);
    color: white;
}

.builds-dropdown__clear-all svg {
    flex-shrink: 0;
}

/* Parts List Header (catalog toolbar style) */
.parts-list__header {
    padding: 0;
    margin-bottom: 0.5rem;
    border-bottom: none;
}

/* Build Title Row */
.parts-list__title-row {
    margin-bottom: 0.5rem;
}

.parts-list__title-group {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.parts-list__title-display {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
}

.parts-list__title-display:hover .parts-list__title-edit-icon {
    opacity: 1;
}

.parts-list__title-text {
    font-size: clamp(1.125rem, 2.5vw + 0.2rem, 1.25rem);
    font-weight: 600;
    color: var(--text-primary);
}

.parts-list__title-edit-icon {
    color: var(--text-muted);
    opacity: 0.5;
    transition: opacity 0.15s;
}

.parts-list__title-input {
    background: var(--bg-tertiary);
    border: 1px solid var(--accent);
    border-radius: 4px;
    color: var(--text-primary);
    font-size: 1.25rem;
    font-weight: 600;
    padding: 0.25rem 0.5rem;
    outline: none;
    min-width: 200px;
}

.parts-list__meta-divider {
    color: var(--text-muted);
    font-size: 0.875rem;
}

.parts-list__author,
.parts-list__date {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.parts-list__author svg,
.parts-list__date svg {
    color: var(--text-muted);
}

/* Build title - left aligned, clean */
.parts-list__title {
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-size: clamp(1.125rem, 2.5vw + 0.2rem, 1.375rem);
    font-weight: 600;
    padding: 0;
    margin: 0;
    text-align: left;
    transition: color 0.15s;
}

.parts-list__title-btn:hover .parts-list__title {
    color: var(--accent);
}

/* Share Toolbar */
.parts-list__share-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.75rem;
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
}

.share-toolbar__left,
.share-toolbar__right {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.share-toolbar__label {
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
}

/* Toast Notification */
.toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-left: 3px solid var(--accent);
    padding: 0.875rem 1.25rem;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
    z-index: 1000;
    font-size: 0.875rem;
    color: var(--text-primary);
}

/* Toast animations */
.toast-enter {
    transition: all 0.2s ease-out;
}

.toast-enter-start {
    opacity: 0;
    transform: translateY(10px);
}

.toast-enter-end {
    opacity: 1;
    transform: translateY(0);
}

.toast-leave {
    transition: all 0.2s ease-in;
}

.toast-leave-start {
    opacity: 1;
    transform: translateY(0);
}

.toast-leave-end {
    opacity: 0;
    transform: translateY(10px);
}

/* Alpine cloak */
[x-cloak] {
    display: none !important;
}

/* Alpine transition utilities */
.transition {
    transition-property: all;
    transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
}

.ease-out {
    transition-timing-function: cubic-bezier(0, 0, 0.2, 1);
}

.ease-in {
    transition-timing-function: cubic-bezier(0.4, 0, 1, 1);
}

.duration-200 {
    transition-duration: 200ms;
}

.duration-150 {
    transition-duration: 150ms;
}

.opacity-0 {
    opacity: 0;
}

.opacity-100 {
    opacity: 1;
}

.scale-90 {
    transform: scale(0.9);
}

.scale-100 {
    transform: scale(1);
}

/* =============================================================================
   SSR FALLBACK SECTION
   Shown when JavaScript is disabled, hidden when Alpine.js loads
   ============================================================================= */

.builder-intro {
    max-width: 1200px;
    margin: 0 auto;
    padding: clamp(1.5rem, 3vw, 2rem);
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 12px;
}

.builder-intro__lead {
    font-size: clamp(1rem, 1.5vw + 0.5rem, 1.125rem);
    color: var(--text-secondary);
    line-height: 1.6;
    margin: 0 0 clamp(1.5rem, 3vw, 2rem) 0;
}

/* Example Builds Grid */
.builder-examples {
    display: grid;
    grid-template-columns: 1fr;
    gap: clamp(1rem, 2vw, 1.5rem);
}

@media (min-width: 768px) {
    .builder-examples {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (min-width: 1024px) {
    .builder-examples {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* Individual Build Card */
.builder-example {
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: clamp(1rem, 2vw, 1.5rem);
}

.builder-example__title {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0 0 0.5rem 0;
}

.builder-example__desc {
    font-size: 0.875rem;
    color: var(--text-muted);
    margin: 0 0 1rem 0;
    line-height: 1.5;
}

/* Parts Table */
.builder-example__parts {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

.builder-example__parts td {
    padding: 0.5rem 0;
    vertical-align: top;
}

.builder-example__type {
    width: 30%;
    color: var(--text-muted);
    font-weight: 500;
}

.builder-example__name {
    color: var(--text-primary);
}

.builder-example__name a {
    color: var(--accent);
    text-decoration: none;
    transition: text-decoration 0.15s;
}

.builder-example__name a:hover {
    text-decoration: underline;
}

.builder-example__price {
    text-align: right;
    font-weight: 500;
    white-space: nowrap;
    color: var(--text-primary);
}

/* Total Row */
.builder-example__parts tfoot td {
    border-top: 1px solid var(--border);
    padding-top: 0.75rem;
    font-weight: 600;
}

.builder-example__parts tfoot .builder-example__type {
    color: var(--text-primary);
}

.builder-example__parts tfoot .builder-example__price {
    color: var(--accent);
}

/* Component Categories Grid */
.builder-categories {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: clamp(0.75rem, 2vw, 1rem);
    margin-top: 1.5rem;
}

@media (min-width: 768px) {
    .builder-categories {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (min-width: 1024px) {
    .builder-categories {
        grid-template-columns: repeat(4, 1fr);
    }
}

/* Category Link Card */
.builder-categories__link {
    display: flex;
    flex-direction: column;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1rem;
    text-decoration: none;
    transition: border-color 0.15s, background-color 0.15s;
}

.builder-categories__link:hover {
    border-color: var(--accent);
    background: var(--bg-hover);
}

.builder-categories__label {
    font-weight: 500;
    color: var(--text-primary);
}

.builder-categories__desc {
    font-size: 0.8125rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
    line-height: 1.4;
}

/* JavaScript Notice */
.builder-notice {
    background: var(--bg-tertiary);
    border-radius: 8px;
    padding: 1rem 1.25rem;
    margin-top: 1.5rem;
    color: var(--text-secondary);
    font-size: 0.875rem;
    line-height: 1.5;
}

/* ================================================================
   RESPONSIVE - BUILDS DROPDOWN
   ================================================================ */

/* Backdrop for builds dropdown */
.builds-dropdown-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 9999;
}

@media (max-width: 768px) {
    .builds-dropdown-backdrop {
        background: rgba(0, 0, 0, 0.6);
        backdrop-filter: blur(2px);
    }

    .builds-dropdown {
        position: fixed !important;
        top: auto !important;
        bottom: 0 !important;
        left: 0 !important;
        right: 0 !important;
        width: 100% !important;
        max-width: 100%;
        max-height: 80vh;
        border-radius: 16px 16px 0 0;
        box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.5);
    }

    .builds-dropdown__header {
        text-align: center;
        padding: 1rem;
        padding-top: 1.5rem;
        border-bottom: 1px solid var(--border);
        position: relative;
    }

    /* Add drag handle indicator */
    .builds-dropdown__header::before {
        content: '';
        position: absolute;
        top: 8px;
        left: 50%;
        transform: translateX(-50%);
        width: 36px;
        height: 4px;
        background: var(--border);
        border-radius: 2px;
    }

    .builds-dropdown__list {
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    .builds-dropdown__item {
        padding: 1rem;
    }

    .builds-dropdown__footer {
        padding: 1rem;
        padding-bottom: calc(1rem + env(safe-area-inset-bottom, 0px));
    }

    .builds-dropdown__footer-left {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.25rem;
    }
}

