﻿/* Listing Details Page Styles */

/* ===========================================
   MOBILE LAYOUT FIX
   Ensures content fits within viewport
   =========================================== */
@media (max-width: 768px) {
    /* Prevent horizontal scroll on entire page */
    html {
        overflow-x: hidden;
    }

    body {
        overflow-x: hidden;
        width: 100%;
    }

    /* Details page specific container fixes */
    .main-content {
        width: 100%;
        max-width: 100vw;
        overflow-x: hidden;
    }

    .main-content .container {
        padding-left: 12px !important;
        padding-right: 12px !important;
        max-width: 100%;
        width: 100%;
        box-sizing: border-box;
        overflow-x: hidden;
    }

    .listing-container {
        max-width: 100%;
        width: 100%;
        box-sizing: border-box;
    }

    .image-gallery {
        max-width: 100%;
        width: 100%;
        box-sizing: border-box;
    }

    .listing-info {
        max-width: 100%;
        width: 100%;
        box-sizing: border-box;
        overflow-x: hidden;
    }

    /* Ensure attribute values don't overflow */
    .attribute-row {
        max-width: 100%;
        overflow: hidden;
    }

    .attr-value {
        max-width: 60%;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    /* Action buttons fix */
    .action-buttons {
        max-width: 100%;
        flex-direction: column;
        gap: 8px;
    }

    .btn-contact,
    .btn-favorite {
        width: 100%;
        flex: none;
    }

    /* Seller info fix */
    .seller-info {
        max-width: 100%;
        overflow: hidden;
    }

    .seller-stats {
        font-size: 11px !important;
        word-break: break-word;
    }
}

/* Modal Animations and Utilities */
.spinner {
    width: 16px;
    height: 16px;
    border: 2px solid #f3f3f3;
    border-top: 2px solid #2ABDB5;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

    100% {
        transform: rotate(360deg);
    }
}

#contactSellerModal.show {
    display: flex;
    align-items: center;
    justify-content: center;
}

.notification {
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }

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

/* Contact Seller Modal Styles */
#contactSellerModal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}

#contactSellerModal .modal-content {
    background: white;
    border-radius: 20px;
    padding: 30px;
    max-width: 500px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
}

#contactSellerModal .modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 1px solid var(--border-light);
}

#contactSellerModal .modal-header h3 {
    margin: 0;
    color: var(--text-dark);
}

#contactSellerModal .modal-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: #718096;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
}

#contactSellerModal .modal-close:hover {
    color: var(--text-dark);
}

/* Form Styles for Contact Seller Modal */
#contactSellerModal .form-group {
    margin-bottom: 20px;
}

#contactSellerModal .form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: var(--text-dark);
}

#contactSellerModal .form-group input,
#contactSellerModal .form-group textarea {
    width: 100%;
    padding: 12px;
    border: 2px solid var(--border-light);
    border-radius: 10px;
    font-size: 14px;
    transition: border-color 0.3s;
    box-sizing: border-box;
}

#contactSellerModal .form-group input:focus,
#contactSellerModal .form-group textarea:focus {
    outline: none;
    border-color: var(--primary-teal);
}

#contactSellerModal .form-group textarea {
    height: 120px;
    resize: vertical;
}

#contactSellerModal .action-buttons {
    display: flex;
    gap: 15px;
    justify-content: center;
    margin-top: 20px;
}

.price-offer {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 10px;
    padding: 10px;
    background: white;
    border-radius: 10px;
}

    .price-offer input {
        flex: 1;
        margin: 0;
    }

/* Verification Step Styles */
#requestCodeStep,
#verifyCodeStep {
    text-align: center;
}

    #verifyCodeStep input[type="text"] {
        font-size: 18px;
        text-align: center;
        letter-spacing: 3px;
        font-weight: 600;
    }

/* Button Loading States */
.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* Responsive for Contact Seller Modal */
@media (max-width: 768px) {
    #contactSellerModal .modal-content {
        margin: 20px;
        width: calc(100% - 40px);
    }

    #contactSellerModal .action-buttons {
        flex-direction: column;
    }
}

/* Gallery Grid Styles */
.gallery-grid {
    display: grid;
    grid-template-columns: 1.5fr 1fr;
    gap: 4px;
    margin-bottom: 20px;
    border-radius: 12px;
    overflow: hidden;
}

.gallery-main {
    position: relative;
    cursor: pointer;
    overflow: hidden;
    background: #f8f9fa;
    border-radius: 8px 0 0 8px;
}

    .gallery-main img {
        width: 100%;
        height: 100%;
        object-fit: cover;
        display: block;
        transition: transform 0.3s ease;
    }

    .gallery-main:hover img {
        transform: scale(1.05);
    }

.gallery-thumbnails {
    display: grid;
    grid-template-columns: 1fr;
    grid-template-rows: 1fr 1fr;
    gap: 4px;
}

.gallery-thumb {
    position: relative;
    cursor: pointer;
    overflow: hidden;
    background: #f8f9fa;
}

/* First thumbnail - top right corner rounded */
.gallery-thumb:first-child {
    border-radius: 0 8px 0 0;
}

/* Last thumbnail - bottom right corner rounded */
.gallery-thumb:last-child {
    border-radius: 0 0 8px 0;
}

    .gallery-thumb img {
        width: 100%;
        height: 100%;
        object-fit: cover;
        display: block;
        transition: transform 0.3s ease;
    }

    .gallery-thumb:hover img {
        transform: scale(1.05);
    }

.gallery-thumb-overlay {
    position: relative;
}

    .gallery-thumb-overlay::before {
        content: '';
        position: absolute;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.6);
        z-index: 1;
        border-radius: 8px;
    }

.thumb-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2;
}

.overlay-text {
    color: white;
    font-size: 28px;
    font-weight: 700;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

/* Single image layout */
.gallery-grid:has(.gallery-main):not(:has(.gallery-thumbnails)) {
    grid-template-columns: 1fr;
}

    .gallery-grid:has(.gallery-main):not(:has(.gallery-thumbnails)) .gallery-main {
        max-height: 600px;
    }

/* Responsive Gallery - Mobile */
@media (max-width: 768px) {
    .gallery-grid {
        display: grid;
        grid-template-columns: 1.5fr 1fr;
        gap: 3px;
        margin-bottom: 16px;
    }

    .gallery-main {
        border-radius: 8px 0 0 8px;
    }

    .gallery-thumbnails {
        display: grid;
        grid-template-columns: 1fr;
        grid-template-rows: 1fr 1fr;
        gap: 3px;
    }

    .gallery-thumb {
        border-radius: 0;
    }

    .gallery-thumb:first-child {
        border-radius: 0 8px 0 0;
    }

    .gallery-thumb:last-child {
        border-radius: 0 0 8px 0;
    }

    .overlay-text {
        font-size: 16px;
    }

    /* With 2 images total (1 main + 1 thumbnail) - balanced 50/50 split */
    .gallery-grid:has(.gallery-thumbnails > .gallery-thumb:only-child) {
        grid-template-columns: 1fr 1fr;
        gap: 3px;
    }

    .gallery-grid:has(.gallery-thumbnails > .gallery-thumb:only-child) .gallery-main {
        border-radius: 8px 0 0 8px;
    }

    .gallery-grid:has(.gallery-thumbnails > .gallery-thumb:only-child) .gallery-thumbnails {
        grid-template-rows: 1fr;
    }

    .gallery-grid:has(.gallery-thumbnails > .gallery-thumb:only-child) .gallery-thumb {
        height: 100%;
        border-radius: 0 8px 8px 0;
    }
}

/* Image Modal Styles */
#imageModal {
    background: rgba(0, 0, 0, 0.95) !important;
}

#imageModal .modal-close {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 2001;
    background: rgba(255, 255, 255, 0.1);
    color: white;
    font-size: 24px;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.3);
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    cursor: pointer;
}

    #imageModal .modal-close:hover {
        background: rgba(255, 255, 255, 0.2);
        transform: rotate(90deg);
    }

.image-modal-content {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    touch-action: pan-y pinch-zoom;
    user-select: none;
    -webkit-user-select: none;
}

.image-modal-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    overflow: hidden;
}

.image-carousel {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    position: relative;
}

.carousel-image {
    position: absolute;
    max-width: 90vw;
    max-height: 90vh;
    object-fit: contain;
    border-radius: 8px;
    box-shadow: 0 10px 50px rgba(0, 0, 0, 0.5);
    transition: transform 0.3s ease, opacity 0.3s ease;
}

.carousel-current {
    transform: translateX(0);
    opacity: 1;
}

.carousel-prev {
    transform: translateX(-100vw);
    opacity: 1;
}

.carousel-next {
    transform: translateX(100vw);
    opacity: 1;
}

.image-nav-btn {
    position: fixed;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255, 255, 255, 0.1);
    color: white;
    border: 2px solid rgba(255, 255, 255, 0.3);
    width: 50px;
    height: 50px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 24px;
    transition: all 0.3s ease;
    z-index: 2001;
}

    .image-nav-btn:hover {
        background: rgba(255, 255, 255, 0.2);
        transform: translateY(-50%) scale(1.1);
    }

.image-nav-prev {
    left: 20px;
}

.image-nav-next {
    right: 20px;
}

.image-counter {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    color: white;
    background: rgba(0, 0, 0, 0.6);
    padding: 10px 20px;
    border-radius: 25px;
    font-size: 14px;
    font-weight: 600;
    z-index: 2001;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

/* Responsive Image Modal */
@media (max-width: 768px) {
    .image-modal-wrapper img {
        max-width: 95vw;
        max-height: 85vh;
    }

    .image-nav-btn {
        width: 40px;
        height: 40px;
        font-size: 20px;
    }

    .image-nav-prev {
        left: 10px;
    }

    .image-nav-next {
        right: 10px;
    }

    .image-counter {
        bottom: 20px;
        font-size: 12px;
        padding: 8px 16px;
    }

    #imageModal .modal-close {
        top: 10px;
        right: auto;
        left: 10px;
        width: 40px;
        height: 40px;
        font-size: 20px;
    }
}

/* ===========================================
   VINTED-STYLE LISTING INFO
   =========================================== */

/* Listing Info Container */
.listing-info {
    background: white;
    border-radius: 12px;
    padding: 16px;
    border: 1px solid #E5E7EB;
}

/* Title */
.listing-info .listing-title {
    font-size: 18px;
    font-weight: 600;
    margin: 0 0 4px 0;
    color: #1F2937;
    line-height: 1.3;
}

/* Subtitle: Size · Condition · Brand */
.listing-subtitle {
    font-size: 14px;
    color: #6B7280;
    margin-bottom: 12px;
}

.listing-subtitle .brand-link {
    color: #2ABDB5;
    text-decoration: none;
}

.listing-subtitle .brand-link:hover {
    text-decoration: underline;
}

/* Price */
.listing-info .listing-price {
    font-size: 24px;
    font-weight: 700;
    color: #2ABDB5;
    margin-bottom: 4px;
}

.price-negotiable {
    color: #2ABDB5;
    font-size: 13px;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 6px;
}

/* Attributes List */
.listing-attributes {
    border-top: 1px solid #E5E7EB;
    padding-top: 12px;
    margin-bottom: 16px;
}

.attribute-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid #F3F4F6;
}

.attribute-row:last-child {
    border-bottom: none;
}

.attr-label {
    font-size: 14px;
    color: #6B7280;
    font-weight: 400;
}

.attr-value {
    font-size: 14px;
    color: #1F2937;
    font-weight: 500;
    text-align: right;
}

.attr-value .brand-link {
    color: #2ABDB5;
    text-decoration: none;
    font-weight: 500;
}

.attr-value .brand-link:hover {
    text-decoration: underline;
}

.attr-value i {
    font-size: 12px;
    margin-right: 2px;
}

/* Description */
.description-section {
    border-top: 1px solid #E5E7EB;
    padding-top: 12px;
    margin-bottom: 16px;
}

.description-text {
    font-size: 14px;
    color: #4B5563;
    line-height: 1.6;
}

/* Action Buttons */
.action-buttons {
    display: flex;
    gap: 10px;
    margin-bottom: 16px;
}

.btn-contact {
    flex: 1;
    background: white;
    color: #2ABDB5;
    border: 1px solid #2ABDB5;
    padding: 12px 16px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn-contact:hover {
    background: #2ABDB5;
    color: white;
}

.btn-favorite {
    flex: 1;
    background: white;
    border: 1px solid #E5E7EB;
    color: #6B7280;
    padding: 12px 16px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn-favorite:hover {
    border-color: #2ABDB5;
    color: #2ABDB5;
}

.btn-favorite.favorited {
    border-color: #2ABDB5;
    color: #1F2937;
    background: #F0FDFA;
}

.btn-favorite.favorited i {
    color: #EF4444;
}

/* Seller Info */
.seller-info {
    background: #F9FAFB;
    border-radius: 10px;
    padding: 14px;
    border: 1px solid #E5E7EB;
}

.seller-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}

.seller-avatar {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, #2ABDB5, #1E9E97);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 16px;
}

.seller-details h3 {
    font-size: 14px;
    font-weight: 600;
    color: #1F2937;
    margin: 0 0 2px 0;
}

.seller-stats {
    font-size: 12px;
    color: #6B7280;
}

.seller-stats i {
    color: #FBBF24;
}

/* Safety Notice */
.safety-notice {
    background: #FFFBEB;
    border: 1px solid #FDE68A;
    border-radius: 10px;
    padding: 14px;
    margin: 20px 0;
}

.safety-notice h4 {
    font-size: 14px;
    color: #92400E;
    margin: 0 0 6px 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.safety-notice p {
    font-size: 13px;
    color: #78350F;
    margin: 0;
    line-height: 1.5;
}

/* Related Listings */
.related-section {
    margin-top: 24px;
}

.related-section .section-title {
    font-size: 16px;
    font-weight: 600;
    color: #1F2937;
    margin-bottom: 12px;
}

/* Related listings uses same listing-card format as Browse */
.related-listings-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 12px;
}

@media (max-width: 1024px) {
    .related-listings-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 768px) {
    .related-listings-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
    }
}

.related-item {
    background: white;
    border: 1px solid #E5E7EB;
    border-radius: 10px;
    overflow: hidden;
    text-decoration: none;
    transition: all 0.2s;
}

.related-item:hover {
    border-color: #2ABDB5;
}

.related-image {
    width: 100%;
    aspect-ratio: 1;
    object-fit: cover;
}

.related-content {
    padding: 10px;
}

.related-title {
    font-size: 13px;
    color: #1F2937;
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.related-price {
    font-size: 14px;
    font-weight: 600;
    color: #2ABDB5;
}

/* ===========================================
   MOBILE RESPONSIVE - LISTING INFO
   =========================================== */
@media (max-width: 768px) {
    .listing-info {
        padding: 14px;
        border-radius: 0;
        border-left: none;
        border-right: none;
        /* Removed negative margins that caused overflow */
        margin: 0;
        width: 100%;
    }

    .listing-info .listing-title {
        font-size: 16px;
    }

    .listing-subtitle {
        font-size: 13px;
    }

    .listing-info .listing-price {
        font-size: 22px;
    }

    .attribute-row {
        padding: 8px 0;
    }

    .attr-label,
    .attr-value {
        font-size: 13px;
    }

    .action-buttons {
        flex-direction: column;
        gap: 8px;
    }

    .btn-contact,
    .btn-favorite {
        width: 100%;
        padding: 12px 16px;
        font-size: 14px;
    }

    .seller-info {
        padding: 12px;
    }

    .seller-avatar {
        width: 36px;
        height: 36px;
        font-size: 14px;
    }

    .related-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
    }

    .related-content {
        padding: 8px;
    }

    .related-title {
        font-size: 12px;
    }

    .related-price {
        font-size: 13px;
    }
}

/* ===========================================
   SOLD LISTING STYLES
   =========================================== */

.image-gallery {
    position: relative;
}

.sold-banner {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    pointer-events: none;
    border-radius: 12px;
}

.sold-badge {
    background: #DC2626;
    color: white;
    font-size: 28px;
    font-weight: 700;
    padding: 12px 32px;
    border-radius: 8px;
    text-transform: uppercase;
    letter-spacing: 2px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.sold-notice {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 16px 24px;
    background: #FEF2F2;
    border: 1px solid #FECACA;
    border-radius: 10px;
    color: #DC2626;
    font-size: 15px;
    font-weight: 500;
    width: 100%;
}

.sold-notice i {
    font-size: 18px;
}

@media (max-width: 768px) {
    .sold-badge {
        font-size: 22px;
        padding: 10px 24px;
    }

    .sold-notice {
        padding: 12px 16px;
        font-size: 14px;
    }
}

/* Pending moderation notice */
.pending-moderation-notice {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: #FEF3C7;
    border: 1px solid #FCD34D;
    border-radius: 10px;
    margin-bottom: 16px;
    grid-column: 1 / -1; /* Span full width in grid */
}

.pending-moderation-notice i {
    font-size: 24px;
    color: #D97706;
    flex-shrink: 0;
    margin-top: 2px;
}

.pending-moderation-notice strong {
    color: #92400E;
    font-size: 15px;
}

.pending-moderation-notice p {
    color: #92400E;
    font-size: 14px;
    margin: 0;
    line-height: 1.4;
}

.pending-moderation-notice div {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 6px;
}

/* Rejected notice */
.rejected-notice {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: #FEF2F2;
    border: 1px solid #FECACA;
    border-radius: 10px;
    margin-bottom: 16px;
    grid-column: 1 / -1; /* Span full width in grid */
}

.rejected-notice i {
    font-size: 24px;
    color: #DC2626;
    flex-shrink: 0;
    margin-top: 2px;
}

.rejected-notice strong {
    color: #991B1B;
    font-size: 15px;
}

.rejected-notice p {
    color: #991B1B;
    font-size: 14px;
    margin: 0;
    line-height: 1.4;
}

.rejected-notice div {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 6px;
}

@media (max-width: 768px) {
    .pending-moderation-notice,
    .rejected-notice {
        padding: 12px 16px;
    }

    .pending-moderation-notice i,
    .rejected-notice i {
        font-size: 20px;
    }
}