/**
 * Single Build Detail Page Styles
 *
 * Styling for the single build template including:
 * - Two-column layout (gallery + details)
 * - Photo gallery with thumbnails
 * - Build header and author info
 * - Components list
 * - Comments section
 *
 * @package PKB
 */

/* ================================================================
   PAGE CONTAINER
   ================================================================ */

.single-build {
    padding: clamp(1rem, 3vw, 2rem) 0 clamp(3rem, 6vw, 5rem);
    background-color: var(--bg-primary);
    min-height: 60vh;
}

.single-build .container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 clamp(1rem, 3vw, 2rem);
}

/* ================================================================
   BREADCRUMB
   ================================================================ */

.single-build .breadcrumb {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem;
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-bottom: clamp(1.5rem, 3vw, 2rem);
}

.single-build .breadcrumb__link {
    color: var(--text-secondary);
    text-decoration: none;
    transition: color 0.2s ease;
}

.single-build .breadcrumb__link:hover {
    color: var(--accent);
}

.single-build .breadcrumb__separator {
    color: var(--text-muted);
}

.single-build .breadcrumb__current {
    color: var(--text-primary);
    font-weight: 500;
}

/* ================================================================
   TWO-COLUMN LAYOUT
   ================================================================ */

.single-build__layout {
    display: grid;
    grid-template-columns: 1fr;
    gap: clamp(1.5rem, 4vw, 3rem);
}

@media (min-width: 768px) {
    .single-build__layout {
        grid-template-columns: 1fr 1fr;
    }
}

@media (min-width: 1024px) {
    .single-build__layout {
        grid-template-columns: 1.2fr 1fr;
    }
}

/* ================================================================
   GALLERY SECTION
   ================================================================ */

.single-build__gallery {
    display: flex;
    flex-direction: column;
    gap: clamp(0.75rem, 2vw, 1rem);
}

/* Main Image */
.gallery__main {
    position: relative;
    aspect-ratio: 16 / 10;
    border-radius: 12px;
    overflow: hidden;
    background-color: var(--bg-tertiary);
}

.gallery__main-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.gallery__main-image:hover {
    transform: scale(1.02);
}

/* Featured Badge */
.gallery__badge {
    position: absolute;
    top: 0.75rem;
    left: 0.75rem;
    padding: 0.375rem 0.875rem;
    font-size: 0.75rem;
    font-weight: 600;
    border-radius: 6px;
    z-index: 2;
}

.gallery__badge--featured {
    background-color: var(--accent);
    color: var(--bg-primary);
}

/* Thumbnails */
.gallery__thumbs {
    display: flex;
    gap: 0.5rem;
    overflow-x: auto;
    padding-bottom: 0.25rem;
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
}

.gallery__thumbs::-webkit-scrollbar {
    height: 4px;
}

.gallery__thumbs::-webkit-scrollbar-track {
    background: transparent;
}

.gallery__thumbs::-webkit-scrollbar-thumb {
    background-color: var(--border);
    border-radius: 2px;
}

.gallery__thumb {
    flex-shrink: 0;
    width: 72px;
    height: 48px;
    border-radius: 6px;
    overflow: hidden;
    background: none;
    border: 2px solid transparent;
    padding: 0;
    cursor: pointer;
    transition: all 0.2s ease;
    opacity: 0.7;
}

.gallery__thumb:hover {
    opacity: 1;
    border-color: var(--text-muted);
}

.gallery__thumb--active {
    opacity: 1;
    border-color: var(--accent);
}

.gallery__thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Placeholder */
.gallery__main--placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--bg-tertiary) 0%, var(--bg-secondary) 100%);
}

.gallery__placeholder-icons {
    display: flex;
    gap: 1.5rem;
    opacity: 0.3;
    color: var(--text-muted);
}

/* ================================================================
   DETAILS SECTION
   ================================================================ */

.single-build__details {
    display: flex;
    flex-direction: column;
    gap: clamp(1.25rem, 3vw, 1.75rem);
}

/* ================================================================
   BUILD HEADER
   ================================================================ */

.build-header {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

/* Title row with save button */
.build-header__top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
}

.build-header__title {
    font-size: clamp(1.5rem, 4vw, 2rem);
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
    line-height: 1.2;
    flex: 1;
}

/* Save button (heart icon) */
.build-header__save {
    flex-shrink: 0;
}

.build-save-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    padding: 0;
    border: 2px solid var(--border-color);
    border-radius: 50%;
    background-color: var(--bg-secondary);
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.2s ease;
}

.build-save-btn:hover:not(:disabled) {
    border-color: var(--error);
    color: var(--error);
    background-color: rgba(239, 68, 68, 0.1);
    transform: scale(1.05);
}

.build-save-btn--saved {
    border-color: var(--error);
    color: var(--error);
    background-color: rgba(239, 68, 68, 0.1);
}

.build-save-btn--saved:hover:not(:disabled) {
    background-color: rgba(239, 68, 68, 0.2);
}

.build-save-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.build-save-btn .animate-spin {
    animation: save-btn-spin 1s linear infinite;
}

@keyframes save-btn-spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.build-header__author {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.75rem;
}

/* Author Link */
.build-author {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    text-decoration: none;
    color: var(--text-secondary);
    transition: color 0.2s ease;
}

.build-author:hover {
    color: var(--accent);
}

.build-author__avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    object-fit: cover;
}

.build-author__name {
    font-size: 0.9375rem;
}

.build-author__name strong {
    color: var(--text-primary);
    font-weight: 600;
}

.build-author:hover .build-author__name strong {
    color: var(--accent);
}

/* Date */
.build-header__date {
    font-size: 0.875rem;
    color: var(--text-muted);
}

/* Actions (Owner Only) */
.build-header__actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

/* ================================================================
   BUILD DESCRIPTION
   ================================================================ */

.build-description {
    padding: clamp(1rem, 2vw, 1.25rem);
    background-color: var(--bg-secondary);
    border-radius: 8px;
    border: 1px solid var(--border);
}

.build-description p {
    margin: 0;
    font-size: 0.9375rem;
    color: var(--text-secondary);
    line-height: 1.7;
}

/* ================================================================
   BUILD PRICE
   ================================================================ */

.build-price {
    display: flex;
    align-items: baseline;
    gap: 0.75rem;
}

.build-price__label {
    font-size: 0.9375rem;
    color: var(--text-secondary);
}

.build-price__value {
    font-size: clamp(1.5rem, 4vw, 1.875rem);
    font-weight: 700;
    color: var(--accent);
}

/* ================================================================
   BUILD COMPONENTS
   ================================================================ */

.build-components {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

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

.components-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.component-row {
    display: grid;
    grid-template-columns: 100px 1fr auto;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem;
    background-color: var(--bg-secondary);
    border-radius: 6px;
    font-size: 0.9375rem;
}

.component-row__type {
    color: var(--text-muted);
    font-size: 0.8125rem;
    font-weight: 500;
}

.component-row__name {
    color: var(--text-primary);
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.component-row__price {
    color: var(--text-secondary);
    font-size: 0.875rem;
    text-align: right;
    white-space: nowrap;
}

/* ================================================================
   BUILD STATS
   ================================================================ */

.build-stats {
    display: flex;
    gap: 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
}

.build-stat {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    color: var(--text-muted);
}

.build-stat svg {
    flex-shrink: 0;
    opacity: 0.6;
}

/* ================================================================
   COMMENTS SECTION
   ================================================================ */

.comments-section {
    margin-top: clamp(2rem, 5vw, 3rem);
    padding-top: clamp(2rem, 5vw, 3rem);
    border-top: 1px solid var(--border);
}

.comments-section__title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: clamp(1.25rem, 3vw, 1.5rem);
    font-weight: 600;
    color: var(--text-primary);
    margin: 0 0 1.5rem;
}

.comments-section__count {
    color: var(--text-muted);
    font-weight: 400;
}

/* ================================================================
   COMMENT FORM
   ================================================================ */

.comment-form {
    margin-bottom: 2rem;
}

.comment-form__input-wrapper {
    display: flex;
    gap: 0.75rem;
    align-items: flex-start;
}

.comment-form__avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}

.comment-form__textarea {
    flex: 1;
    min-height: 100px;
    padding: 0.875rem;
    font-size: 0.9375rem;
    font-family: inherit;
    color: var(--text-primary);
    background-color: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 8px;
    resize: vertical;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.comment-form__textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(var(--accent-rgb), 0.1);
}

.comment-form__textarea::placeholder {
    color: var(--text-muted);
}

.comment-form__textarea:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.comment-form__actions {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 1rem;
    margin-top: 0.75rem;
    padding-left: 52px; /* Align with textarea (avatar 40px + gap 12px) */
}

.comment-form__counter {
    font-size: 0.8125rem;
    color: var(--text-muted);
}

/* Login Prompt */
.comment-form--login {
    padding: 1.5rem;
    background-color: var(--bg-secondary);
    border-radius: 8px;
    border: 1px solid var(--border);
    text-align: center;
}

.comment-form--login p {
    margin: 0;
    font-size: 0.9375rem;
    color: var(--text-secondary);
}

.comment-form--login a {
    color: var(--accent);
    font-weight: 600;
    text-decoration: none;
}

.comment-form--login a:hover {
    text-decoration: underline;
}

/* ================================================================
   COMMENTS LIST
   ================================================================ */

.comments-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

/* ================================================================
   SINGLE COMMENT
   ================================================================ */

.comment {
    display: flex;
    gap: 0.75rem;
    padding: 1rem;
    background-color: var(--bg-secondary);
    border-radius: 8px;
    border: 1px solid var(--border);
}

.comment--new {
    border-color: var(--accent);
    animation: comment-highlight 2s ease-out;
}

@keyframes comment-highlight {
    0% {
        background-color: rgba(var(--accent-rgb), 0.1);
    }
    100% {
        background-color: var(--bg-secondary);
    }
}

.comment__avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}

.comment__content {
    flex: 1;
    min-width: 0;
}

.comment__header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.comment__author {
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--text-primary);
    text-decoration: none;
    transition: color 0.2s ease;
}

.comment__author:hover {
    color: var(--accent);
}

.comment__date {
    font-size: 0.8125rem;
    color: var(--text-muted);
}

.comment__delete {
    margin-left: auto;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    padding: 0;
    background: transparent;
    border: none;
    border-radius: 4px;
    color: var(--text-muted);
    cursor: pointer;
    opacity: 0.5;
    transition: all 0.2s ease;
}

.comment__delete:hover {
    opacity: 1;
    color: var(--error);
    background-color: rgba(var(--error-rgb), 0.1);
}

.comment__text {
    margin: 0;
    font-size: 0.9375rem;
    color: var(--text-secondary);
    line-height: 1.6;
    word-wrap: break-word;
}

/* ================================================================
   COMMENTS EMPTY STATE
   ================================================================ */

.comments-empty {
    text-align: center;
    padding: 2rem 1rem;
    color: var(--text-secondary);
    background-color: var(--bg-secondary);
    border-radius: 8px;
    border: 1px dashed var(--border);
}

.comments-empty p {
    margin: 0;
    font-size: 0.9375rem;
}

/* ================================================================
   COMMENTS LOADING STATE
   ================================================================ */

.comments-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    padding: 2rem;
    color: var(--text-secondary);
}

.comments-loading .spinner {
    width: 28px;
    height: 28px;
    border: 3px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* ================================================================
   BUTTON STYLES (Local overrides)
   ================================================================ */

.single-build .btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.625rem 1.25rem;
    font-size: 0.9375rem;
    font-weight: 500;
    text-decoration: none;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.single-build .btn--small {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
}

.single-build .btn--primary {
    background-color: var(--accent);
    color: var(--bg-primary);
}

.single-build .btn--primary:hover:not(:disabled) {
    background-color: var(--accent-hover);
}

.single-build .btn--secondary {
    background-color: var(--bg-secondary);
    color: var(--text-primary);
    border: 1px solid var(--border);
}

.single-build .btn--secondary:hover:not(:disabled) {
    background-color: var(--bg-tertiary);
    border-color: var(--accent);
}

.single-build .btn--danger {
    background-color: transparent;
    color: var(--error);
    border: 1px solid var(--error);
}

.single-build .btn--danger:hover:not(:disabled) {
    background-color: rgba(var(--error-rgb), 0.1);
}

.single-build .btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* ================================================================
   RESPONSIVE ADJUSTMENTS
   ================================================================ */

@media (max-width: 767px) {
    /* Stack layout on mobile */
    .single-build__layout {
        grid-template-columns: 1fr;
    }

    /* Component rows compact */
    .component-row {
        grid-template-columns: 80px 1fr auto;
        padding: 0.625rem;
        font-size: 0.875rem;
    }

    .component-row__type {
        font-size: 0.75rem;
    }

    /* Comment form actions */
    .comment-form__actions {
        padding-left: 0;
    }

    /* Author actions stack */
    .build-header__actions {
        width: 100%;
    }

    .build-header__actions .btn {
        flex: 1;
    }
}

@media (max-width: 480px) {
    /* Smaller thumbnails */
    .gallery__thumb {
        width: 60px;
        height: 40px;
    }

    /* Component rows compact */
    .component-row {
        grid-template-columns: 1fr auto;
        gap: 0.5rem;
    }

    .component-row__type {
        grid-column: 1 / -1;
        margin-bottom: -0.25rem;
    }

    /* Stats stack */
    .build-stats {
        flex-direction: column;
        gap: 0.75rem;
    }

    /* Comment compact */
    .comment {
        padding: 0.875rem;
    }

    .comment__avatar {
        width: 32px;
        height: 32px;
    }

    .comment-form__avatar {
        width: 32px;
        height: 32px;
    }
}
