/**
 * Book Listing Form Styles
 */

.book-listings-manage {
    max-width: 1280px;
    margin: 0 auto;
    width:100%;
    overflow: hidden;
    box-sizing: border-box;
}

/* Header with inline button */
.listings-header-inline {
    margin-bottom: 2rem;
    margin-top: 1rem;
}

/* Create listing button */
.button-create-listing {
    background: var(--Color-Wave, #097ec1) !important;
    color: #fff !important;
    border: none;
    border-radius: 4px;
    padding: 0.75em 1.5em;
    font-size: 1em;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s, opacity 0.2s;
    white-space: nowrap;
    filter: none;
    -webkit-text-fill-color: #fff;
    margin-bottom: 0;
    width: 100%;
    max-width: 400px;
}

.button-create-listing:hover,
.button-create-listing:focus {
    background: #065a8e !important;
    color: #fff !important;
    -webkit-text-fill-color: #fff;
}

.button-create-listing:disabled {
    background: #dcdcde !important;
    color: #a7aaad !important;
    -webkit-text-fill-color: #a7aaad;
    cursor: not-allowed;
    opacity: 0.7;
}

.button-create-listing:disabled:hover {
    background: #dcdcde !important;
}

.button-create-listing * {
    color: #fff !important;
}

/* Limit reached message */
.listing-limit-reached-inline {
    background: #fff3cd;
    border: 1px solid #ffc107;
    border-radius: 6px;
    padding: 0.5rem 1rem;
    color: #856404;
    font-size: 0.9rem;
    font-weight: 500;
    margin-bottom: 1rem;
}

.listing-create-section {
    margin-top: 1.5rem;
}

.listing-limit-reached {
    background: #fff3cd;
    border: 1px solid #ffc107;
    border-radius: 8px;
    padding: 1rem;
    margin-bottom: 1rem;
}

.listing-limit-reached p {
    margin: 0;
    color: #856404;
}

/* Validation Error Summary (matches CF7 style) */
#form-validation-errors {
    background: #fff3cd;
    border: 1px solid #ffc107;
    border-radius: 4px;
    padding: 1rem;
    margin-bottom: 1rem;
    color: #856404;
    font-weight: 500;
}

/* Field Error Messages (matches CF7 style) */
.field-error {
    display: block;
    color: #b71c1c;
    font-size: 0.98em;
    margin-top: 0.2em;
    padding: 0.2em 0.6em;
}

.field-invalid {
    border-color: #b71c1c !important;
    background: #fff0f0 !important;
}

/* Listing Details Section (shown after book selection) */
#listing-details-fields {
    animation: slideDown 0.3s ease;
}

.listing-form {
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 1.5rem;
    margin-top: 1rem;
    animation: slideDown 0.3s ease;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.listing-form h3 {
    margin-top: 0;
    margin-bottom: 0;
    color: #333;
}

/* Form Header with Step Indicator */
.listing-form-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 2px solid #e0e0e0;
}

.step-indicator {
    font-size: 0.9rem;
    color: #666;
    background: #f5f5f5;
    padding: 0.4rem 0.8rem;
    border-radius: 4px;
    font-weight: 500;
}

.form-group {
    margin-bottom: 1.5rem;
    position: relative;
}

.form-group label {
    display: block;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: #333;
}

.form-group input[type="text"],
.form-group input[type="number"],
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 1rem;
    transition: border-color 0.3s ease;
    box-sizing: border-box;
}

#listing-price {
    max-width: 150px;
}

#listing-condition {
    max-width: 300px;
}

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

.form-help {
    font-size: 0.85rem;
    color: #666;
    margin: 0.5rem 0;
}

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

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

.book-search-result {
    padding: 0.75rem;
    cursor: pointer;
    border-bottom: 1px solid #eee;
    transition: background-color 0.2s ease;
}

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

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

.book-result-title {
    font-weight: 600;
    color: #333;
    margin-bottom: 0.25rem;
}

.book-result-code {
    font-size: 0.85rem;
    color: #2c5aa0;
    margin-bottom: 0.25rem;
}

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

.book-inactive-indicator {
    display: inline-flex;
    align-items: center;
    gap: 0.3em;
    font-size: 0.85em;
    font-weight: 600;
    color: #856404;
    background: linear-gradient(135deg, #fff3cd 0%, #ffeaa7 100%);
    border: 1px solid #ffc107;
    border-radius: 4px;
    padding: 0.2em 0.6em;
    margin-left: 0.5em;
    font-style: normal;
    cursor: help;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    transition: all 0.2s ease;
}

.book-inactive-indicator:hover {
    background: linear-gradient(135deg, #ffeaa7 0%, #fdcb6e 100%);
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.15);
}

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

.selected-book {
    margin-top: 0.5rem;
    padding: 0.75rem;
    background: #e8f4f8;
    border: 1px solid #2c5aa0;
    border-radius: 4px;
    display: none;
}

.selected-book.active {
    display: block;
}

.selected-book strong {
    color: #2c5aa0;
}

.button-link {
    background: none;
    border: none;
    color: #2c5aa0;
    text-decoration: underline;
    cursor: pointer;
    padding: 0;
    margin-left: 0.5rem;
    font-size: 0.9em;
}

.button-link:hover {
    color: #1a3a6b;
}

/* Image Upload - Slot System */
.image-slots {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
    margin-bottom: 0.5rem;
}

.image-slot {
    position: relative;
    aspect-ratio: 1;
    border: 2px dashed #ccc;
    border-radius: 8px;
    overflow: hidden;
    cursor: pointer;
    transition: all 0.2s;
    background: #f9f9f9;
}

.image-slot:hover {
    border-color: #2c5aa0;
    background: #f0f0f0;
}

.image-slot.has-image {
    border: 2px solid #2c5aa0;
    cursor: default;
    background: #fff;
}

.image-slot.has-image:hover {
    border-color: #1a3a6b;
}

.slot-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    font-size: 2.5rem;
    color: #ccc;
}

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

.image-slot-remove {
    position: absolute;
    top: 4px;
    right: 4px;
    background: rgba(255, 0, 0, 0.8);
    color: #fff;
    border: none;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1.2rem;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    opacity: 0;
    transition: opacity 0.2s, background 0.2s;
}

.image-slot:hover .image-slot-remove {
    opacity: 1;
}

.image-slot-remove:hover {
    background: rgba(200, 0, 0, 1);
}

.catalog-badge {
    position: absolute;
    bottom: 5px;
    left: 5px;
    background: rgba(44, 90, 160, 0.9);
    color: #fff;
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 0.75rem;
    font-weight: 600;
}

/* Form Actions */
.form-actions {
    display: flex;
    gap: 0.75rem;
    margin-top: 1.5rem;
}

.form-actions .button {
    border: none;
    border-radius: 4px;
    padding: 0.7em 1.75em;
    font-size: 1em;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
    background: #e0e0e0;
    color: #333;
}

.form-actions .button:hover,
.form-actions .button:focus {
    background: #d0d0d0;
}

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

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

/* Messages */
.form-messages {
    margin-top: 1rem;
    padding: 0.75rem;
    border-radius: 4px;
    display: none;
}

.form-messages.success {
    display: block;
    background: #d4edda;
    border: 1px solid #c3e6cb;
    color: #155724;
}

.form-messages.error {
    display: block;
    background: #f8d7da;
    border: 1px solid #f5c6cb;
    color: #721c24;
}

.upload-error {
    margin-top: 1rem;
    padding: 1rem;
    background: #fee;
    border: 2px solid #c00;
    color: #c00;
    border-radius: 4px;
    font-weight: 500;
    line-height: 1.5;
}

.upload-error strong {
    display: block;
    margin-bottom: 0.25rem;
}

.upload-helper-text {
    margin: 0.5rem 0 0 0;
    font-size: 0.9rem;
    color: #666;
    line-height: 1.4;
}

/* My Listings Section */
.my-listings-section {
    margin-top: 1rem;
}

.my-listings-section > h3 {
    display: none; /* Title is now in .listings-header */
}

/* Responsive */
@media (max-width: 768px) {
    .listings-header h3 {
        font-size: 1.5rem;
    }
    
    .button-create-listing,
    .listing-limit-reached-inline {
        width: 100%;
        text-align: center;
        justify-content: center;
    }
    
    .listing-form {
        padding: 1rem;
    }
    
    .listing-form-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }
    
    .form-actions {
        flex-direction: column;
    }
    
    .form-actions .button {
        width: 100%;
    }
    
    .image-slots {
        gap: 0.75rem;
    }
}
