/**
 * SWAPTIQ Listing Form Styles
 *
 * @package SWAPTIQ
 */

/* Form Container Layout */
.swaptiq-listing-form-container {
    display: flex;
    gap: 30px;
    margin: 20px 0;
    background: #fff;
}

.swaptiq-form-main {
    flex: 1;
    max-width: 65%;
}

.swaptiq-form-preview {
    flex: 0 0 350px;
    position: sticky;
    top: 32px;
    height: fit-content;
    background: #f8f9fa;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.swaptiq-form-preview h3 {
    margin-top: 0;
    font-size: 16px;
    font-weight: 600;
    color: #333;
}

/* Form Sections */
.swaptiq-form-section {
    background: #fff;
    padding: 25px;
    border: 1px solid #ddd;
    border-radius: 4px;
    margin-bottom: 20px;
}

.swaptiq-form-section h2 {
    margin-top: 0;
    font-size: 18px;
    font-weight: 600;
    color: #23282d;
    border-bottom: 1px solid #eee;
    padding-bottom: 10px;
}

/* Form Fields */
.form-field {
    margin-bottom: 20px;
}

.form-field label {
    display: block;
    font-weight: 600;
    margin-bottom: 8px;
    color: #23282d;
}

.form-field .required {
    color: #dc3232;
}

.form-field input[type="text"],
.form-field input[type="number"],
.form-field select,
.form-field textarea {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
}

.form-field input[type="text"]:focus,
.form-field input[type="number"]:focus,
.form-field select:focus,
.form-field textarea:focus {
    border-color: #339966;
    outline: none;
    box-shadow: 0 0 0 1px #339966;
}

.form-field .description {
    font-size: 13px;
    font-style: italic;
    color: #666;
    margin-top: 5px;
}

/* Form Rows */
.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
    margin-bottom: 20px;
}

/* Image Upload Section */
.image-upload-section {
    margin: 20px 0;
    padding: 20px;
    border: 2px dashed #ddd;
    border-radius: 8px;
    background: #fafafa;
}

.image-upload-section label {
    font-weight: 600;
    color: #23282d;
    display: block;
    margin-bottom: 10px;
}

.image-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 15px;
    margin: 15px 0;
    min-height: 50px;
}

.image-container.sortable {
    cursor: move;
}

.image-preview {
    position: relative;
    border: 2px solid #ddd;
    border-radius: 4px;
    overflow: hidden;
    background: #fff;
    transition: transform 0.2s, box-shadow 0.2s;
}

.image-preview:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.image-preview img {
    width: 100%;
    height: 150px;
    object-fit: cover;
    display: block;
}

.image-preview .remove-image {
    position: absolute;
    top: 5px;
    right: 5px;
    background: rgba(220, 50, 50, 0.9);
    color: white;
    border: none;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 18px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.image-preview .remove-image:hover {
    background: #dc3232;
}

.upload-image-button {
    margin-top: 10px;
}

/* Sortable Dragging */
.ui-sortable-helper {
    opacity: 0.7;
    border: 2px dashed #339966;
}

.ui-sortable-placeholder {
    border: 2px dashed #ccc;
    background: #f0f0f0;
    visibility: visible !important;
}

/* Preview Card */
#listing-preview-card {
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    overflow: hidden;
    margin-bottom: 10px;
}

#listing-preview-card .listing-thumbnail {
    width: 100%;
    height: 200px;
    background: #f0f0f0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #999;
    font-size: 14px;
}

#listing-preview-card .listing-thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

#listing-preview-card .listing-content {
    padding: 15px;
}

#listing-preview-card .listing-type {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
    margin-bottom: 8px;
}

#listing-preview-card .listing-type.sell {
    background: #d4edda;
    color: #155724;
}

#listing-preview-card .listing-type.buy {
    background: #d1ecf1;
    color: #0c5460;
}

#listing-preview-card .listing-title {
    font-size: 16px;
    font-weight: 600;
    margin: 8px 0;
    color: #333;
}

#listing-preview-card .listing-meta {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-top: 1px solid #eee;
    border-bottom: 1px solid #eee;
    margin: 10px 0;
    font-size: 13px;
}

#listing-preview-card .listing-excerpt {
    color: #666;
    font-size: 13px;
    line-height: 1.5;
    margin: 10px 0;
}

#listing-preview-card .listing-location {
    color: #666;
    font-size: 12px;
    margin: 8px 0;
}

#listing-preview-card .price-negotiable {
    color: #28a745;
    font-weight: 500;
}

#listing-preview-card .price {
    color: #333;
    font-weight: 700;
    font-size: 14px;
}

/* WP Editor Override */
#wp-swaptiq_description-wrap {
    margin-top: 0;
}

#wp-swaptiq_description-editor-tools {
    background: #f0f0f0;
    border: 1px solid #ddd;
    border-bottom: none;
}

/* Responsive */
@media (max-width: 1200px) {
    .swaptiq-listing-form-container {
        flex-direction: column;
    }

    .swaptiq-form-main {
        max-width: 100%;
    }

    .swaptiq-form-preview {
        position: relative;
        top: 0;
        flex: 1;
    }
}

@media (max-width: 768px) {
    .form-row {
        grid-template-columns: 1fr;
    }

    .image-container {
        grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    }
}

/* Loading State */
.swaptiq-loading {
    opacity: 0.6;
    pointer-events: none;
}

.swaptiq-loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 30px;
    height: 30px;
    margin: -15px 0 0 -15px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #339966;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* Error Messages */
.swaptiq-error-message {
    background: #f8d7da;
    color: #721c24;
    padding: 10px 15px;
    border: 1px solid #f5c6cb;
    border-radius: 4px;
    margin: 10px 0;
}

.swaptiq-success-message {
    background: #d4edda;
    color: #155724;
    padding: 10px 15px;
    border: 1px solid #c3e6cb;
    border-radius: 4px;
    margin: 10px 0;
}

/* Frontend Form Extensions */
.swaptiq-frontend-form-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
    background: #fff;
}

.swaptiq-form-header {
    margin-bottom: 30px;
    border-bottom: 2px solid #eee;
    padding-bottom: 15px;
}

.swaptiq-form-layout {
    display: flex;
    gap: 40px;
}

.swaptiq-form-main-column {
    flex: 1;
}

.swaptiq-preview-column {
    flex: 0 0 350px;
}

.sticky-preview {
    position: sticky;
    top: 20px;
}

.form-section {
    margin-bottom: 35px;
    padding: 20px;
    background: #fdfdfd;
    border: 1px solid #f0f0f0;
    border-radius: 8px;
}

.form-section h3 {
    margin-top: 0;
    font-size: 1.2rem;
    color: #333;
    border-bottom: 1px solid #eee;
    padding-bottom: 10px;
    margin-bottom: 20px;
}

.swaptiq-dropzone {
    border: 3px dashed #ccc;
    border-radius: 12px;
    padding: 40px 20px;
    text-align: center;
    background: #fafafa;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-bottom: 20px;
}

.swaptiq-dropzone:hover {
    border-color: #339966;
    background: #f0f7ff;
}

.swaptiq-dropzone.dragover {
    background: #eef6ff;
    border-color: #339966;
}

.dropzone-prompt {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    pointer-events: none;
}

.dropzone-prompt .upload-icon {
    font-size: 40px;
    display: block;
    margin-bottom: 10px;
}

.dropzone-prompt p {
    margin: 0;
    font-size: 16px;
    color: #666;
}

.swaptiq-previews-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 15px;
    margin-top: 20px;
}

.image-preview {
    position: relative;
    border-radius: 8px;
    overflow: hidden;
    aspect-ratio: 1/1;
    border: 1px solid #ddd;
    background: #eee;
}

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

.image-preview .image-label {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(0,0,0,0.6);
    color: #fff;
    font-size: 10px;
    text-align: center;
    padding: 2px 0;
}

.image-preview.loading {
    display: flex;
    align-items: center;
    justify-content: center;
}

.spinner {
    width: 30px;
    height: 30px;
    border: 3px solid #ddd;
    border-top-color: #339966;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.price-input-wrapper {
    display: flex;
    align-items: center;
    border: 1px solid #ddd;
    border-radius: 4px;
    overflow: hidden;
}

.price-input-wrapper .currency-symbol {
    padding: 0 12px;
    background: #eee;
    color: #666;
    border-right: 1px solid #ddd;
}

.price-input-wrapper input {
    border: none !important;
    box-shadow: none !important;
}

.upload-instructions {
    background: #fff8e1;
    padding: 10px 15px;
    border-left: 4px solid #ffc107;
    margin-bottom: 20px;
    font-size: 13px;
    color: #5d4037;
}

@media (max-width: 991px) {
    .swaptiq-form-layout {
        flex-direction: column;
    }
    
    .swaptiq-preview-column {
        flex: none;
    }
}
