/**
 * Browse Book Listings Styles
 */

.book-listings-browse {
    max-width: 1280px;
    margin: 0 auto;
}

/* Filters */
.listings-filters {
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 1.5rem;
    margin-bottom: 2rem;
}

.filters-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.filter-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    align-items: end;
}

.filter-group {
    display: flex;
    flex-direction: column;
    position: relative;
}

.filter-group label {
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: #333;
    font-size: 0.9rem;
}

.filter-group input,
.filter-group select {
    padding: 0.75rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 1rem;
    transition: border-color 0.3s ease;
}

.filter-group input:focus,
.filter-group select:focus {
    outline: none;
    border-color: #2c5aa0;
}

.filter-actions {
    display: flex;
    gap: 0.5rem;
    align-items: flex-end;
    justify-content: flex-end;
}

.filter-actions .button {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 4px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
    text-decoration: none;
    display: inline-block;
    white-space: nowrap;
    box-sizing: border-box;
}

.filter-actions .button-reset {
    background: var(--Color-Wave, #097ec1);
    color: #fff;
}

.filter-actions .button-reset:hover,
.filter-actions .button-reset:focus {
    background: #065a8e;
}

/* Results */
.listings-results {
    margin-top: 2rem;
}

/* Modal Styles */
.modal {
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.modal-content {
    background-color: #fff;
    padding: 2rem;
    border-radius: 8px;
    max-width: 500px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
    animation: slideUp 0.3s ease;
}

@keyframes slideUp {
    from {
        transform: translateY(20px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.modal-close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--wp--preset--color--contrast, #000);
    padding: 0;
    outline-offset: 2px;
}

.modal-close svg {
    display: block;
    pointer-events: none;
}

.modal-content h3 {
    margin-top: 0;
    margin-bottom: 1rem;
    color: #333;
}

.modal-seller-name {
    font-weight: 600;
    color: #2c5aa0;
    margin-bottom: 1rem;
}

.modal-content textarea {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 1rem;
    font-family: inherit;
    resize: vertical;
    box-sizing: border-box;
}

.modal-content textarea:focus {
    outline: none;
    border-color: #2c5aa0;
}

.char-count {
    display: block;
    text-align: right;
    font-size: 0.85rem;
    color: #666;
    margin-top: 0.25rem;
}

.modal-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 1.5rem;
}

.modal-actions .button {
    flex: 1;
    padding: 0.75rem 1.5rem;
    cursor: pointer;
    text-align: center;
}

.form-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 1.5rem;
}

.form-actions .button {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 4px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    text-align: center;
    text-decoration: none;
    display: inline-block;
    transition: background 0.2s, color 0.2s;
}

.form-actions .button-primary {
    background: var(--Color-Wave, #097ec1);
    color: #fff;
}

.form-actions .button-primary:hover,
.form-actions .button-primary:focus {
    background: #065a8e;
}

.form-actions .modal-close-btn {
    background: #f0f0f0;
    color: #333;
}

.form-actions .modal-close-btn:hover,
.form-actions .modal-close-btn:focus {
    background: #e0e0e0;
}

/* Delete Confirmation Modal */
#delete-confirm-modal .modal-content {
    max-width: 400px;
}

/* Price Slider */
.filter-price-slider {
    grid-column: 1 / -2;
}

.price-slider-wrapper {
    position: relative;
    padding: 0 9px;
}

.price-slider {
    height: 6px;
    background: #e0e0e0;
    border-radius: 3px;
    position: relative;
    margin: 1rem 0 0.5rem;
    cursor: pointer;
}

.price-slider-track {
    height: 100%;
    background: var(--Color-Wave, #097ec1);
    border-radius: 3px;
    position: absolute;
}

.price-slider-thumb {
    width: 18px;
    height: 18px;
    background: #fff;
    border: 2px solid var(--Color-Wave, #097ec1);
    border-radius: 50%;
    position: absolute;
    top: 50%;
    transform: translate(-50%, -50%);
    cursor: grab;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.price-slider-thumb:active {
    cursor: grabbing;
}

.price-slider-values {
    display: flex;
    justify-content: space-between;
    font-size: 0.9rem;
    color: #666;
    font-weight: 600;
}

/* Book Search Results (smart search) */
.book-search-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: #fff;
    border: 1px solid #ddd;
    border-top: none;
    border-radius: 0 0 4px 4px;
    max-height: 400px;
    overflow-y: auto;
    z-index: 1000;
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
    display: none;
}

.book-search-results.active {
    display: block;
}

.book-search-result {
    padding: 0.75rem;
    cursor: pointer;
    border-bottom: 1px solid #f0f0f0;
    transition: background 0.15s;
}

.book-search-result:last-child {
    border-bottom: none;
}

.book-search-result:hover {
    background: #f5f5f5;
}

.book-result-title {
    font-weight: 600;
    color: #333;
    margin-bottom: 0.25rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.book-result-code {
    font-size: 0.85rem;
    color: var(--Color-Wave, #097ec1);
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.book-result-author {
    font-size: 0.85rem;
    color: #888;
    font-style: italic;
}

.book-inactive-indicator {
    font-size: 0.75rem;
    font-weight: 600;
    color: #856404;
    background: linear-gradient(135deg, #fff3cd 0%, #ffeaa7 100%);
    border: 1px solid #ffc107;
    border-radius: 3px;
    padding: 0.2em 0.5em;
    display: inline-flex;
    align-items: center;
    gap: 0.25em;
}

.book-inactive-indicator .info-icon {
    font-style: normal;
}

/* Pagination */
.listings-pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1.5rem;
    margin-top: 2rem;
    padding: 1rem;
}

.listings-pagination .pagination-prev,
.listings-pagination .pagination-next {
    padding: 0.6rem 1.2rem;
    background: var(--Color-Wave, #097ec1);
    color: #fff !important;
    border-radius: 4px;
    text-decoration: none;
    font-weight: 600;
    transition: background 0.2s;
}

.listings-pagination .pagination-prev:hover,
.listings-pagination .pagination-next:hover {
    background: #086ba8;
}

.pagination-info {
    font-weight: 600;
    color: #555;
}

/* Listing Mode Toggle (Achat | Vente) */
.listing-mode-toggle {
    display: flex;
    align-items: center;
    padding-bottom: 1rem;
}

.listing-mode-btn {
    padding: 0.75rem 1.5rem;
    border: 2px solid var(--Color-Wave, #097ec1);
    background: transparent;
    color: var(--Color-Wave, #097ec1);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
    white-space: nowrap;
}

.listing-mode-btn:first-of-type {
    border-radius: 4px 0 0 4px;
    border-right: none;
}

.listing-mode-btn:last-of-type {
    border-radius: 0 4px 4px 0;
}

.listing-mode-btn:hover {
    background: #e6f3fb;
}

.listing-mode-btn.is-active {
    background: var(--Color-Wave, #097ec1);
    color: #fff;
}

.listing-mode-btn.is-active:hover {
    background: #065a8e;
}

.listing-mode-separator {
    display: none;
}

/* Responsive */
@media (max-width: 768px) {
    .listings-filters {
        padding: 1rem;
    }
    
    .filter-row {
        grid-template-columns: 1fr;
    }
    
    .filter-price-slider {
        grid-column: 1;
    }
    
    /* Larger touch targets for mobile */
    .price-slider-wrapper {
        padding: 0 14px;
    }
    
    .price-slider-thumb {
        width: 28px;
        height: 28px;
        border-width: 3px;
    }
    
    .price-slider {
        height: 8px;
        margin: 1.5rem 0 0.75rem;
    }
    
    .filter-actions {
        flex-direction: column;
    }
    
    .filter-actions .button {
        width: 100%;
        padding: 0.6rem 1rem;
        font-size: 0.95rem;
    }
}

/* Contact Seller Modal - Desktop centered, Mobile takeover */
#contact-seller-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 100000;
    align-items: center;
    justify-content: center;
}

#contact-seller-modal .modal-content {
    background: var(--wp--preset--color--base, #fff);
    border-radius: 8px;
    padding: 2rem;
    max-width: 500px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    animation: modalFadeIn 0.2s ease-out forwards;
}

#contact-seller-modal .modal-close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--wp--preset--color--contrast, #000);
    padding: 0.5rem;
    margin: 0;
    width: auto;
    height: auto;
    font-size: inherit;
    font-weight: normal;
    border-radius: 4px;
    outline-offset: 2px;
    transition: background 0.2s;
}

#contact-seller-modal .modal-close:hover {
    background: var(--wp--preset--color--accent-5, #f0f0f0);
}

#contact-seller-modal .modal-close svg {
    display: block;
    pointer-events: none;
    width: 24px;
    height: 24px;
}

#contact-seller-modal .modal-content h3 {
    margin-top: 0;
    margin-bottom: 1.5rem;
    padding-right: 2rem;
}

#contact-seller-modal .contact-instructions {
    font-size: 0.9em;
    color: var(--wp--preset--color--contrast-2, #666);
    margin-top: 0;
    margin-bottom: 1.25rem;
}

#contact-seller-modal .form-group label {
    display: block;
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--wp--preset--color--contrast, #333);
    margin-bottom: 0.5rem;
}

@keyframes modalFadeIn {
    from {
        opacity: 0;
        transform: scale(0.95);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* Mobile: Full-page takeover matching notification style */
@media (max-width: 899px) {
    #contact-seller-modal {
        background: none;
        animation: none;
    }
    
    #contact-seller-modal .modal-content {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        width: 100%;
        height: 100vh;
        max-width: 100vw;
        max-height: none;
        margin: 0;
        padding: max(2.5rem, clamp(1rem, var(--wp--style--root--padding-top), 20rem)) clamp(1rem, var(--wp--style--root--padding-right), 20rem) clamp(1rem, var(--wp--style--root--padding-bottom), 20rem) clamp(1rem, var(--wp--style--root--padding-left), 20rem);
        background: var(--wp--preset--color--base, #fff);
        border: none;
        border-radius: 0;
        box-shadow: none;
        overflow-y: auto;
        box-sizing: border-box;
        animation: overlaySlideUp 0.1s ease-out forwards;
    }
    
    #contact-seller-modal .modal-close {
        display: block;
        position: static;
        background: none;
        border: none;
        cursor: pointer;
        color: var(--wp--preset--color--contrast, #000);
        padding: 0;
        margin-bottom: 1rem;
        width: auto;
        height: auto;
        outline-offset: 2px;
    }
    
    .admin-bar #contact-seller-modal .modal-close {
        margin-top: 46px;
    }
    
    #contact-seller-modal .modal-close:hover {
        background: none;
    }
    
    #contact-seller-modal .modal-content h3 {
        font-size: 1.4rem;
        font-weight: 700;
        margin-top: 1.25rem;
        margin-bottom: 0.5rem;
        color: var(--wp--preset--color--contrast, #000);
    }
    
    #contact-seller-modal .contact-instructions {
        margin-bottom: 1.5rem;
    }

    #contact-seller-modal .modal-content textarea {
        border-color: var(--wp--preset--color--accent-6, #ddd);
    }
    
    #contact-seller-modal .form-actions {
        flex-direction: column;
    }
    
    #contact-seller-modal .form-actions .button {
        width: 100%;
    }
    
    @keyframes overlaySlideUp {
        from {
            opacity: 0;
            transform: translateY(0.5em);
        }
        to {
            opacity: 1;
            transform: translateY(0);
        }
    }
}
