/**
 * Responsive CSS for PhotoResk Q&A Plugin
 */

/* Mobile First Approach */

/* Base styles (Mobile) */
.photoresk-qa-container {
    width: 100%;
    max-width: 100%;
    padding: 0 15px;
}

.qa-form-container {
    width: 100%;
    padding: 15px;
}

.qa-question-item,
.qa-answer-item {
    padding: 15px;
    margin-bottom: 15px;
    border-radius: 8px;
    background: #fff;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.qa-question-meta,
.qa-answer-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    font-size: 12px;
    color: #666;
    margin-top: 10px;
}

.qa-voting-controls {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 10px;
    min-width: 60px;
}

.qa-vote-button {
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 50%;
    background: #f0f0f0;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    transition: all 0.3s ease;
}

.qa-vote-button:hover {
    background: #e0e0e0;
}

.qa-vote-button.voted {
    background: #0073aa;
    color: white;
}

.qa-vote-count {
    font-size: 16px;
    font-weight: bold;
    margin: 5px 0;
}

/* Image Gallery Responsive */
.qa-image-gallery {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 10px;
    margin: 15px 0;
}

.qa-image-item {
    position: relative;
    overflow: hidden;
    border-radius: 8px;
    aspect-ratio: 1;
}

.qa-image-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.qa-image-item:hover img {
    transform: scale(1.05);
}

/* Search and Filter */
.qa-search-container {
    position: relative;
    margin-bottom: 20px;
}

.qa-search-input {
    width: 100%;
    padding: 12px 15px;
    border: 2px solid #ddd;
    border-radius: 25px;
    font-size: 16px;
    background: #fff;
    transition: border-color 0.3s ease;
}

.qa-search-input:focus {
    outline: none;
    border-color: #0073aa;
}

.qa-search-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 1px solid #ddd;
    border-radius: 8px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    max-height: 400px;
    overflow-y: auto;
    z-index: 1000;
}

.qa-search-result-item {
    padding: 12px 15px;
    border-bottom: 1px solid #eee;
    cursor: pointer;
    transition: background-color 0.3s ease;
}

.qa-search-result-item:hover {
    background: #f8f9fa;
}

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

/* Reputation and Badges */
.qa-user-reputation {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 12px;
    color: #666;
}

.qa-reputation-points {
    font-weight: bold;
    color: #0073aa;
}

.qa-user-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    margin-top: 5px;
}

.qa-badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 6px;
    background: #f0f0f0;
    border-radius: 12px;
    font-size: 10px;
    color: #666;
}

.qa-badge.gold {
    background: #ffd700;
    color: #8b6914;
}

.qa-badge.silver {
    background: #c0c0c0;
    color: #666;
}

.qa-badge.bronze {
    background: #cd7f32;
    color: #fff;
}

/* Modals */
.qa-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.qa-modal-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
}

.qa-modal-content {
    position: relative;
    background: white;
    border-radius: 12px;
    max-width: 500px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
}

.qa-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border-bottom: 1px solid #eee;
}

.qa-modal-header h3 {
    margin: 0;
    font-size: 18px;
}

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

.qa-modal-body {
    padding: 20px;
}

.qa-modal-body .form-group {
    margin-bottom: 15px;
}

.qa-modal-body label {
    display: block;
    margin-bottom: 5px;
    font-weight: 500;
}

.qa-modal-body input,
.qa-modal-body select,
.qa-modal-body textarea {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 14px;
    transition: border-color 0.3s ease;
}

.qa-modal-body input:focus,
.qa-modal-body select:focus,
.qa-modal-body textarea:focus {
    outline: none;
    border-color: #0073aa;
}

.form-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 20px;
}

.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.3s ease;
}

.btn-primary {
    background: #0073aa;
    color: white;
}

.btn-primary:hover {
    background: #005177;
}

.btn-secondary {
    background: #6c757d;
    color: white;
}

.btn-secondary:hover {
    background: #5a6268;
}

/* Tablet Styles */
@media (min-width: 768px) {
    .photoresk-qa-container {
        padding: 0 30px;
    }
    
    .qa-form-container {
        padding: 30px;
    }
    
    .qa-question-item,
    .qa-answer-item {
        padding: 20px;
        margin-bottom: 20px;
    }
    
    .qa-image-gallery {
        grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
        gap: 15px;
    }
    
    .qa-search-input {
        font-size: 16px;
    }
    
    .qa-voting-controls {
        flex-direction: row;
        gap: 10px;
    }
    
    .qa-vote-button {
        width: 45px;
        height: 45px;
    }
    
    .qa-question-meta,
    .qa-answer-meta {
        font-size: 14px;
    }
    
    .qa-user-reputation {
        font-size: 14px;
    }
    
    .qa-badge {
        font-size: 12px;
        padding: 3px 8px;
    }
}

/* Desktop Styles */
@media (min-width: 1024px) {
    .photoresk-qa-container {
        max-width: 1200px;
        margin: 0 auto;
        padding: 0 40px;
    }
    
    .qa-content-wrapper {
        display: flex;
        gap: 30px;
    }
    
    .qa-main-content {
        flex: 1;
    }
    
    .qa-sidebar {
        width: 300px;
        flex-shrink: 0;
    }
    
    .qa-question-item,
    .qa-answer-item {
        padding: 25px;
        margin-bottom: 25px;
    }
    
    .qa-image-gallery {
        grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
        gap: 20px;
    }
    
    .qa-voting-controls {
        flex-direction: column;
        position: sticky;
        top: 20px;
    }
    
    .qa-vote-button {
        width: 50px;
        height: 50px;
        font-size: 20px;
    }
    
    .qa-vote-count {
        font-size: 18px;
    }
    
    .qa-modal-content {
        max-width: 600px;
    }
    
    .qa-search-container {
        position: relative;
        max-width: 600px;
    }
}

/* Large Desktop Styles */
@media (min-width: 1440px) {
    .photoresk-qa-container {
        max-width: 1400px;
        padding: 0 60px;
    }
    
    .qa-sidebar {
        width: 350px;
    }
    
    .qa-image-gallery {
        grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
        gap: 25px;
    }
}

/* Print Styles */
@media print {
    .qa-voting-controls,
    .qa-report-content,
    .qa-edit-buttons,
    .qa-admin-actions {
        display: none !important;
    }
    
    .qa-question-item,
    .qa-answer-item {
        box-shadow: none;
        border: 1px solid #ddd;
        break-inside: avoid;
    }
    
    .qa-image-gallery {
        grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    }
}

/* Accessibility Improvements */
@media (prefers-reduced-motion: reduce) {
    .qa-vote-button,
    .qa-image-item img,
    .qa-search-input,
    .qa-search-result-item,
    .btn {
        transition: none;
    }
}

/* High Contrast Mode */
@media (prefers-contrast: high) {
    .qa-question-item,
    .qa-answer-item {
        border: 2px solid #000;
    }
    
    .qa-vote-button {
        border: 2px solid #000;
    }
    
    .qa-search-input {
        border: 2px solid #000;
    }
}

/* Dark Mode Support */
@media (prefers-color-scheme: dark) {
    .qa-question-item,
    .qa-answer-item,
    .qa-modal-content,
    .qa-search-results {
        background: #2d2d2d;
        color: #fff;
    }
    
    .qa-vote-button {
        background: #4a4a4a;
        color: #fff;
    }
    
    .qa-search-input {
        background: #2d2d2d;
        border-color: #4a4a4a;
        color: #fff;
    }
    
    .qa-badge {
        background: #4a4a4a;
        color: #fff;
    }
}

/* Focus States for Keyboard Navigation */
.qa-vote-button:focus,
.qa-search-input:focus,
.btn:focus {
    outline: 2px solid #0073aa;
    outline-offset: 2px;
}

/* Loading States */
.qa-loading {
    position: relative;
    opacity: 0.6;
    pointer-events: none;
}

.qa-loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid #0073aa;
    border-radius: 50%;
    border-top-color: transparent;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Error States */
.qa-error {
    border-color: #dc3545 !important;
    background-color: #fff5f5;
}

.qa-error-message {
    color: #dc3545;
    font-size: 12px;
    margin-top: 5px;
}

/* Success States */
.qa-success {
    border-color: #28a745 !important;
    background-color: #f8fff8;
}

.qa-success-message {
    color: #28a745;
    font-size: 12px;
    margin-top: 5px;
}

/* Right-aligned Image Responsive Styles */
@media (max-width: 767px) {
    /* Mobile: Stack images below content */
    .qa-question-content-wrap {
        flex-direction: column;
        gap: 15px;
    }
    
    .qa-question-thumbnail-right {
        order: 1;
        width: 100%;
        height: auto;
        max-width: 200px;
        align-self: center;
    }
    
    .qa-question-content-container {
        flex-direction: column;
        gap: 20px;
    }
    
    .qa-question-images-right {
        width: 100%;
        max-width: none;
        order: 1;
    }
    
    .qa-question-images-right .qa-gallery-grid {
        grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
        gap: 15px;
    }
}

@media (min-width: 768px) and (max-width: 1023px) {
    /* Tablet: Maintain side-by-side but adjust proportions */
    .qa-question-images-right {
        width: 200px;
        max-width: 30%;
    }
}

@media (min-width: 1024px) {
    /* Desktop: Full layout with proper spacing */
    .qa-question-content-container {
        gap: 40px;
    }
    
    .qa-question-images-right {
        width: 300px;
        max-width: 40%;
    }
    
    .qa-question-images-right .qa-gallery-grid {
        gap: 15px;
    }
}