/**
 * Review System Styles - External File
 * Customizable via CSS variables
 */

:root {
    /* Customizable Colors */
    --review-primary: var(--primary-color, #007bff);
    --review-star: var(--star-color, #ffa500);
    --review-bg: var(--background-color, #f8f9fa);
    --review-text: var(--text-color, #333);
    --review-border: var(--border-color, #ddd);
    --review-font: var(--font-family, 'Arial, sans-serif');
}

/* Review System Container */
.review-system {
    margin: 20px 0;
    font-family: var(--review-font);
    color: var(--review-text);
}

.review-container {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
    align-items: flex-start;
}

/* FIXED: Rating sidebar with fixed height */
.rating-sidebar {
    flex: 0 0 200px;
    background: var(--review-bg);
    padding: 20px;
    border-radius: 8px;
    min-width: 180px;
    border: 1px solid var(--review-border);
    /* Fixed height to prevent expansion with review count */
    height: 220px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.reviews-content {
    flex: 1;
    min-width: 200px;
}

/* Rating Display */
.average-rating {
    text-align: center;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.rating-number {
    font-size: 2em;
    font-weight: bold;
    color: var(--review-text);
}

.stars {
    font-size: 1.5em;
    color: var(--review-star);
    margin: 5px 0;
    line-height: 1;
}

.total-reviews {
    color: #666;
    font-size: 0.9em;
}

/* Write Review Button */
.write-review-btn {
    background: var(--review-primary);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 5px;
    cursor: pointer;
    width: 100%;
    transition: all 0.2s ease;
    margin-top: 15px;
    flex-shrink: 0;
}

.write-review-btn:hover {
    filter: brightness(0.9);
}

/* Review Items */
.review-item {
    border-bottom: 1px solid var(--review-border);
    padding: 15px 0;
}

.reviewer-name {
    font-weight: bold;
    color: var(--review-text);
}

.review-rating {
    color: var(--review-star);
    margin: 5px 0;
    font-size: 1.2em;
}

.review-text {
    line-height: 1.5;
    margin-top: 8px;
    color: #666;
}

/* FIXED: Review Images with proper display */
.review-images {
    margin: 10px 0;
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.review-image {
    width: 80px;
    height: 80px;
    object-fit: cover;
    border-radius: 4px;
    cursor: pointer;
    border: 1px solid var(--review-border);
    transition: transform 0.2s ease;
}

.review-image:hover {
    transform: scale(1.05);
}

.review-image-error {
    width: 80px;
    height: 80px;
    background: #f8f9fa;
    border: 1px solid var(--review-border);
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #666;
    font-size: 12px;
    text-align: center;
}

/* Admin Response */
.admin-response {
    margin-top: 10px;
    padding: 10px;
    background: #f8f9fa;
    border-left: 3px solid var(--review-primary);
    border-radius: 0 4px 4px 0;
}

.admin-response-label {
    font-weight: bold;
    color: var(--review-primary);
    margin-bottom: 5px;
    font-size: 0.9em;
}

/* Modal Styles */
.review-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 99999;
}

.modal-content {
    background: white;
    margin: 20px auto;
    padding: 20px;
    border-radius: 8px;
    width: 90%;
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
}

.close {
    float: right;
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: #888;
}

/* Form Styles */
.form-group {
    margin-bottom: 15px;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: bold;
    color: var(--review-text);
}

.form-input {
    width: 100%;
    padding: 8px;
    border: 1px solid var(--review-border);
    border-radius: 4px;
    box-sizing: border-box;
}

.form-input:focus {
    border-color: var(--review-primary);
    outline: none;
    box-shadow: 0 0 0 2px rgba(0,123,255,0.25);
}

.form-textarea {
    height: 100px;
    resize: vertical;
}

/* Star Rating */
.star-rating-container {
    margin: 10px 0;
}

.star-input {
    font-size: 24px;
    color: #ddd;
    cursor: pointer;
    margin-right: 5px;
    display: inline-block;
    width: 30px;
    height: 30px;
    text-align: center;
    line-height: 30px;
    transition: color 0.2s;
}

.star-input:hover,
.star-input.active {
    color: var(--review-star);
}

/* IMPROVED: File Upload with better visual feedback */
.file-upload-area {
    border: 2px dashed var(--review-border);
    border-radius: 8px;
    padding: 20px;
    text-align: center;
    cursor: pointer;
    margin: 10px 0;
    transition: border-color 0.2s;
    background: #fafafa;
}

.file-upload-area:hover {
    border-color: var(--review-primary);
    background: #f0f8ff;
}

.file-upload-area.dragover {
    border-color: var(--review-primary);
    background: #e3f2fd;
}

.file-upload-input {
    display: none;
}

/* IMPROVED: File Preview with better styling */
.file-preview {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 10px;
}

.file-preview-item {
    position: relative;
    display: inline-block;
    background: white;
    border: 1px solid var(--review-border);
    border-radius: 4px;
    padding: 5px;
}

.file-preview-image {
    width: 80px;
    height: 80px;
    object-fit: cover;
    border-radius: 4px;
    display: block;
}

.file-preview-name {
    font-size: 10px;
    color: #666;
    margin-top: 2px;
    text-align: center;
    max-width: 80px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.file-remove-btn {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #dc3545;
    color: white;
    border: none;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    font-size: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.file-remove-btn:hover {
    background: #c82333;
}

.file-upload-status {
    margin-top: 5px;
    font-size: 12px;
    color: #666;
}

/* Submit Button */
.submit-btn {
    background: #28a745;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.2s;
}

.submit-btn:hover {
    background: #218838;
}

.submit-btn:disabled {
    background: #6c757d;
    cursor: not-allowed;
}

/* IMPROVED: Thank You Message - Centered */
.thank-you-message {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: #d4edda;
    color: #155724;
    padding: 20px 30px;
    border-radius: 8px;
    border: 1px solid #c3e6cb;
    z-index: 100000;
    box-shadow: 0 8px 24px rgba(0,0,0,0.3);
    max-width: 400px;
    text-align: center;
    cursor: pointer;
    animation: fadeInScale 0.3s ease-out;
}

@keyframes fadeInScale {
    from {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.8);
    }
    to {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }
}

.thank-you-message:hover {
    background: #c3e6cb;
}

.thank-you-message h4 {
    margin: 0 0 10px 0;
    font-size: 18px;
}

.thank-you-message p {
    margin: 0 0 10px 0;
    font-size: 14px;
}

.thank-you-message small {
    font-size: 12px;
    color: #0a5d20;
    display: block;
    margin-top: 5px;
}

/* Image Modal */
.image-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.8);
    z-index: 100001;
    cursor: pointer;
}

.image-modal img {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    max-width: 90%;
    max-height: 90%;
    border-radius: 8px;
}

.image-modal-close {
    position: absolute;
    top: 20px;
    right: 30px;
    color: white;
    font-size: 40px;
    font-weight: bold;
    cursor: pointer;
}

/* Responsive Design */
@media (max-width: 768px) {
    .review-container {
        flex-direction: column;
    }
    
    .rating-sidebar {
        height: auto;
        min-height: 180px;
    }
    
    .thank-you-message {
        margin: 20px;
        max-width: calc(100% - 40px);
    }
    
    .modal-content {
        margin: 10px;
        width: auto;
    }
}

/* =================================================================
   CSS CONFLICT FIXES - Added to resolve modal layout issues
   These overrides fix conflicts with website-specific stylesheets
   ================================================================= */

/* Modal isolation - Prevent inheritance of conflicting styles */
.review-modal {
    /* Reset any inherited styles that might cause conflicts */
    font-family: var(--review-font) !important;
    font-size: 14px !important;
    line-height: 1.4 !important;
    text-align: left !important;
}

.review-modal *,
.review-modal *:before,
.review-modal *:after {
    /* Prevent inheritance of conflicting positioning/layout styles */
    box-sizing: border-box !important;
}

/* Fix close button positioning */
.review-modal .close {
    float: right !important;
    position: relative !important;
    z-index: 1 !important;
    margin: 0 !important;
    padding: 0 !important;
    width: auto !important;
    height: auto !important;
    line-height: 1 !important;
    background: none !important;
    border: none !important;
    display: inline-block !important;
}

/* Fix form layout - prevent float inheritance */
.review-modal .form-group {
    display: block !important;
    clear: both !important;
    float: none !important;
    width: auto !important;
    margin-bottom: 15px !important;
    position: static !important;
}

/* Fix star rating alignment */
.review-modal .star-rating-container {
    display: inline-block !important;
    vertical-align: middle !important;
    white-space: nowrap !important;
    margin: 10px 0 !important;
    float: none !important;
    width: auto !important;
    clear: none !important;
}

/* Override input styles that might conflict */
.review-modal .star-input {
    font-size: 24px !important;
    width: 30px !important;
    height: 30px !important;
    border: none !important;
    background: transparent !important;
    padding: 0 !important;
    margin: 0 5px 0 0 !important;
    box-sizing: border-box !important;
    vertical-align: middle !important;
    display: inline-block !important;
    float: none !important;
    position: static !important;
}

/* Fix form label positioning */
.review-modal .form-group label {
    display: block !important;
    margin-bottom: 5px !important;
    font-weight: bold !important;
    color: var(--review-text) !important;
    float: none !important;
    width: auto !important;
    position: static !important;
    text-align: left !important;
}

/* For inline label-input pairs (like rating) */
.review-modal .form-group.inline-group {
    display: flex !important;
    align-items: center !important;
    flex-wrap: nowrap !important;
    gap: 15px !important;
}

.review-modal .form-group.inline-group label {
    margin-bottom: 0 !important;
    flex-shrink: 0 !important;
    min-width: 60px !important;
}

/* Fix modal content positioning */
.review-modal .modal-content {
    position: relative !important;
    display: block !important;
    float: none !important;
    clear: both !important;
}

/* Fix input field styling */
.review-modal .form-input,
.review-modal .form-textarea {
    display: block !important;
    width: 100% !important;
    float: none !important;
    clear: both !important;
    position: static !important;
    font-family: inherit !important;
    font-size: 14px !important;
}

/* Fix button styling */
.review-modal .submit-btn,
.review-modal .write-review-btn {
    display: inline-block !important;
    float: none !important;
    position: static !important;
    font-family: inherit !important;
    text-align: center !important;
    vertical-align: middle !important;
}

/* Fix file upload area */
.review-modal .file-upload-area {
    display: block !important;
    float: none !important;
    clear: both !important;
    position: static !important;
    width: 100% !important;
    text-align: center !important;
}

/* Fix file preview layout */
.review-modal .file-preview {
    display: flex !important;
    float: none !important;
    clear: both !important;
    position: static !important;
    width: 100% !important;
}

/* Responsive fixes for mobile */
@media (max-width: 768px) {
    .review-modal .modal-content {
        margin: 10px !important;
        width: auto !important;
        max-width: none !important;
    }
    
    .review-modal .form-group.inline-group {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 5px !important;
    }
    
    .review-modal .star-rating-container {
        display: block !important;
        margin-top: 5px !important;
    }
}
