/**
 * ENHANCED CSS with Fixed Reactions & Rating
 * File: assets/css/advanced-comments.css
 */

/* Advanced Comments Container */
.bricks-advanced-comments {
    max-width: 100%;
    margin: 20px 0;
    font-family: inherit;
    position: relative;
}

/* Comments Header */
.comments-header {
    margin-bottom: 25px;
    border-bottom: 2px solid #f0f0f0;
    padding-bottom: 15px;
}

.comments-title {
    font-size: 24px;
    font-weight: 600;
    margin: 0;
    color: #333;
    display: flex;
    align-items: center;
    gap: 10px;
}

.comments-title::before {
    content: "💬";
    font-size: 20px;
}

/* Comments List */
.comments-list {
    margin-bottom: 40px;
}

.comment-item {
    display: flex;
    gap: 15px;
    margin-bottom: 25px;
    padding: 20px;
    background: #fafafa;
    border-radius: 12px;
    border: 1px solid #e5e5e5;
    transition: all 0.3s ease;
    position: relative;
}

.comment-item:hover {
    background: #f5f5f5;
    border-color: #d0d0d0;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}

.comment-item.comment-reply {
    background: #f0f8ff;
    border-left: 3px solid #007cba;
    margin-left: 0;
    margin-top: 15px;
}

/* Comment Avatar */
.comment-avatar {
    flex-shrink: 0;
    position: relative;
}

.comment-avatar img {
    border-radius: 50%;
    display: block;
    border: 2px solid #fff;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

/* Comment Content */
.comment-content-wrap {
    flex: 1;
    min-width: 0;
}

.comment-header {
    margin-bottom: 12px;
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    align-items: center;
}

.comment-author {
    font-size: 16px;
    font-weight: 600;
    color: #333;
    margin: 0;
}

.comment-author a {
    color: #007cba;
    text-decoration: none;
    transition: color 0.3s ease;
}

.comment-author a:hover {
    color: #005a87;
    text-decoration: underline;
}

.comment-date {
    font-size: 12px;
    color: #666;
    background: rgba(0,0,0,0.05);
    padding: 4px 8px;
    border-radius: 12px;
}

.comment-date time {
    font-style: normal;
}

/* FIXED: Rating Stars Display in Comments */
.comment-rating {
    display: flex;
    gap: 2px;
    margin: 0;
}

.comment-rating .star {
    color: #ddd;
    font-size: 14px;
    transition: color 0.2s ease;
}

.comment-rating .star.filled {
    color: #ffc107;
    text-shadow: 0 1px 2px rgba(0,0,0,0.1);
}

/* Comment Content */
.comment-content {
    font-size: 15px;
    line-height: 1.6;
    color: #555;
    margin-bottom: 15px;
    word-wrap: break-word;
}

.comment-content p {
    margin-bottom: 12px;
}

.comment-content p:last-child {
    margin-bottom: 0;
}

/* Comment Footer with Reactions */
.comment-footer {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 15px;
}

/* FIXED: Emoji Reactions - Now properly displayed */
.comment-reactions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    align-items: center;
}

.comment-reactions .reaction-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 6px 10px;
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 14px;
    position: relative;
    min-width: 36px;
    justify-content: center;
    text-decoration: none;
}

.comment-reactions .reaction-btn:hover {
    background: #f8f9fa;
    border-color: #007cba;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0,124,186,0.2);
}

.comment-reactions .reaction-btn.active {
    background: #007cba;
    border-color: #007cba;
    color: white;
    font-weight: 600;
}

.comment-reactions .reaction-btn .emoji {
    font-size: 16px;
    line-height: 1;
}

.comment-reactions .reaction-btn .count {
    font-size: 12px;
    font-weight: 600;
    min-width: 16px;
    text-align: center;
}

.comment-reactions .reaction-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

/* NEW: Form Reactions */
.form-reactions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    align-items: center;
    margin-top: 10px;
}

.form-reactions .reaction-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    background: #f8f9fa;
    border: 2px solid #e9ecef;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 18px;
    position: relative;
    text-decoration: none;
}

.form-reactions .reaction-btn:hover {
    background: #e9ecef;
    border-color: #007cba;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,124,186,0.2);
}

.form-reactions .reaction-btn.active {
    background: #007cba;
    border-color: #007cba;
    color: white;
    transform: scale(1.1);
    box-shadow: 0 4px 15px rgba(0,124,186,0.3);
}

.form-reactions .reaction-btn .emoji {
    font-size: 20px;
    line-height: 1;
}

/* Reaction Tooltips */
.reaction-tooltip {
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%) translateY(-5px);
    background: #333;
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease, transform 0.2s ease;
    z-index: 1000;
}

.reaction-tooltip.visible {
    opacity: 1;
    transform: translateX(-50%) translateY(-8px);
}

.reaction-tooltip::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 4px solid transparent;
    border-top-color: #333;
}

/* Reaction Feedback */
.reaction-feedback {
    position: absolute;
    top: -30px;
    left: 50%;
    transform: translateX(-50%);
    background: #28a745;
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 11px;
    white-space: nowrap;
    z-index: 1001;
    animation: reactionFeedback 1.5s ease-in-out;
}

@keyframes reactionFeedback {
    0% { opacity: 0; transform: translateX(-50%) translateY(5px); }
    20%, 80% { opacity: 1; transform: translateX(-50%) translateY(0); }
    100% { opacity: 0; transform: translateX(-50%) translateY(-5px); }
}

/* Comment Actions */
.comment-actions {
    display: flex;
    gap: 10px;
    align-items: center;
}

.comment-reply-link {
    background: none;
    border: none;
    color: #007cba;
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.comment-reply-link:hover {
    background: #f0f8ff;
    color: #005a87;
}

/* Nested Replies */
.comment-replies {
    margin-top: 15px;
    margin-left: 40px;
    padding-left: 15px;
    border-left: 2px solid #e0e8ff;
    position: relative;
}

.comment-replies::before {
    content: '';
    position: absolute;
    left: -2px;
    top: 0;
    bottom: 0;
    width: 2px;
    background: linear-gradient(to bottom, #007cba, transparent);
}

.comment-replies .comment-item {
    background: #f8fbff;
    border-color: #e0e8ff;
    margin-bottom: 15px;
}

.comment-replies-toggle {
    margin: 15px 0;
    margin-left: 60px;
}

.load-replies-btn {
    background: none;
    border: 1px solid #007cba;
    color: #007cba;
    padding: 8px 15px;
    border-radius: 20px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.load-replies-btn:hover {
    background: #007cba;
    color: white;
}

.load-replies-btn .toggle-icon {
    transition: transform 0.3s ease;
    font-size: 12px;
}

.load-replies-btn .loading-spinner {
    animation: spin 1s linear infinite;
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* No Comments */
.no-comments {
    text-align: center;
    padding: 60px 20px;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border-radius: 12px;
    margin-bottom: 30px;
    border: 2px dashed #dee2e6;
}

.no-comments::before {
    content: "📝";
    font-size: 48px;
    display: block;
    margin-bottom: 15px;
}

.no-comments p {
    margin: 0;
    color: #6c757d;
    font-size: 16px;
    font-style: italic;
}

/* Comment Form */
.comment-form-container {
    background: #fff;
    padding: 30px;
    border-radius: 12px;
    border: 1px solid #e0e0e0;
    box-shadow: 0 4px 20px rgba(0,0,0,0.08);
    position: relative;
}

.comment-form-container.reply-form {
    margin-top: 15px;
    border-color: #007cba;
    border-width: 2px;
    box-shadow: 0 4px 20px rgba(0,124,186,0.15);
}

.comment-form-container.reply-form::before {
    content: "💬 Reply";
    position: absolute;
    top: -12px;
    left: 20px;
    background: #007cba;
    color: white;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
}

.comment-form-title {
    font-size: 22px;
    font-weight: 600;
    margin-bottom: 20px;
    color: #333;
    display: flex;
    align-items: center;
    gap: 10px;
}

.comment-form-title::before {
    content: "✍️";
    font-size: 20px;
}

/* Form Messages */
.comment-form-messages {
    margin-bottom: 20px;
    padding: 15px 20px;
    border-radius: 8px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 10px;
}

.comment-form-messages.success {
    background: linear-gradient(135deg, #d4edda 0%, #c3e6cb 100%);
    color: #155724;
    border: 1px solid #c3e6cb;
}

.comment-form-messages.success::before {
    content: "✅";
    font-size: 16px;
}

.comment-form-messages.error {
    background: linear-gradient(135deg, #f8d7da 0%, #f5c6cb 100%);
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.comment-form-messages.error::before {
    content: "⚠️";
    font-size: 16px;
}

/* Form Layout */
.comment-form-advanced {
    display: grid;
    gap: 20px;
}

.comment-form-advanced.loading {
    pointer-events: none;
    opacity: 0.8;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
}

.form-group {
    display: flex;
    flex-direction: column;
    position: relative;
}

.form-group.honeypot {
    position: absolute;
    left: -9999px;
    opacity: 0;
}

.form-group label {
    margin-bottom: 8px;
    font-weight: 600;
    color: #333;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 5px;
}

.form-group .required {
    color: #e74c3c;
    font-weight: 700;
}

/* Form Inputs */
.form-group input,
.form-group textarea {
    padding: 12px 15px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 15px;
    font-family: inherit;
    transition: all 0.3s ease;
    background: #fff;
    resize: vertical;
}

.form-group input:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #007cba;
    box-shadow: 0 0 0 3px rgba(0, 124, 186, 0.1);
    transform: translateY(-1px);
}

.form-group textarea {
    min-height: 120px;
    line-height: 1.6;
}

.form-group input:invalid,
.form-group textarea:invalid {
    border-color: #e74c3c;
}

/* FIXED: Rating Input in Form */
.rating-group {
    margin: 10px 0;
}

.rating-group label {
    margin-bottom: 10px;
    font-weight: 600;
    color: #333;
}

.rating-stars {
    display: flex;
    gap: 4px;
    align-items: center;
}

.rating-stars input[type="radio"] {
    display: none;
}

.rating-stars .star-label {
    font-size: 32px;
    color: #ddd;
    cursor: pointer;
    transition: all 0.2s ease;
    user-select: none;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    margin: 0;
}

.rating-stars .star-label:hover,
.rating-stars .star-label.hover {
    color: #ffc107;
    transform: scale(1.1);
    background: rgba(255, 193, 7, 0.1);
    text-shadow: 0 2px 4px rgba(255, 193, 7, 0.3);
}

.rating-stars .star-label.selected {
    color: #ffc107;
    text-shadow: 0 2px 4px rgba(255, 193, 7, 0.5);
    transform: scale(1.05);
}

.rating-stars input[type="radio"]:checked + .star-label {
    color: #ffc107;
    text-shadow: 0 2px 4px rgba(255, 193, 7, 0.5);
}

/* Reaction Group in Form */
.reaction-group {
    margin: 15px 0;
}

.reaction-group label {
    margin-bottom: 10px;
    font-weight: 600;
    color: #333;
}

/* hCaptcha */
.hcaptcha-group {
    display: flex;
    justify-content: center;
    padding: 10px 0;
}

/* Form Actions */
.form-actions {
    display: flex;
    gap: 15px;
    align-items: center;
    margin-top: 10px;
}

.comment-submit-btn,
.comment-cancel-btn {
    padding: 14px 28px;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-width: 140px;
    position: relative;
    overflow: hidden;
}

.comment-submit-btn {
    background: linear-gradient(135deg, #007cba 0%, #005a87 100%);
    color: white;
    box-shadow: 0 4px 15px rgba(0, 124, 186, 0.3);
}

.comment-submit-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
    transition: left 0.6s ease;
}

.comment-submit-btn:hover:not(:disabled) {
    background: linear-gradient(135deg, #005a87 0%, #004066 100%);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 124, 186, 0.4);
}

.comment-submit-btn:hover:not(:disabled)::before {
    left: 100%;
}

.comment-submit-btn:disabled {
    background: #6c757d;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.comment-cancel-btn {
    background: linear-gradient(135deg, #6c757d 0%, #495057 100%);
    color: white;
}

.comment-cancel-btn:hover {
    background: linear-gradient(135deg, #495057 0%, #343a40 100%);
    transform: translateY(-1px);
}

/* Loading States */
.submit-loading,
.submit-text {
    display: flex;
    align-items: center;
    gap: 8px;
}

.submit-loading::before {
    content: '';
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255,255,255,0.3);
    border-top: 2px solid white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

/* Login Required */
.comment-form-login-required {
    text-align: center;
    padding: 40px 30px;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border-radius: 12px;
    border: 2px dashed #dee2e6;
}

.comment-form-login-required::before {
    content: "🔐";
    font-size: 48px;
    display: block;
    margin-bottom: 15px;
}

.comment-form-login-required h4 {
    margin-bottom: 15px;
    color: #495057;
    font-size: 20px;
}

.comment-form-login-required p {
    margin-bottom: 20px;
    color: #6c757d;
    font-size: 16px;
}

.login-link {
    display: inline-block;
    padding: 12px 24px;
    background: linear-gradient(135deg, #007cba 0%, #005a87 100%);
    color: white;
    text-decoration: none;
    border-radius: 8px;
    font-weight: 600;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(0, 124, 186, 0.3);
}

.login-link:hover {
    background: linear-gradient(135deg, #005a87 0%, #004066 100%);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 124, 186, 0.4);
}

/* Error States */
.bricks-advanced-comments-error,
.bricks-advanced-comments-disabled {
    padding: 30px;
    text-align: center;
    background: linear-gradient(135deg, #f8d7da 0%, #f5c6cb 100%);
    color: #721c24;
    border: 2px dashed #f5c6cb;
    border-radius: 12px;
    margin: 20px 0;
}

.bricks-advanced-comments-error::before,
.bricks-advanced-comments-disabled::before {
    content: "⚠️";
    font-size: 48px;
    display: block;
    margin-bottom: 15px;
}

/* Responsive Design */
@media (max-width: 768px) {
    .comment-item {
        flex-direction: column;
        gap: 15px;
        padding: 15px;
    }
    
    .comment-avatar {
        align-self: flex-start;
    }
    
    .comment-avatar img {
        width: 50px;
        height: 50px;
    }
    
    .comment-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }
    
    .comment-reactions,
    .form-reactions {
        justify-content: flex-start;
    }
    
    .comment-replies {
        margin-left: 0;
        padding-left: 15px;
    }
    
    .comment-replies-toggle {
        margin-left: 15px;
    }
    
    .comment-form-container {
        padding: 20px;
    }
    
    .form-row {
        grid-template-columns: 1fr;
    }
    
    .form-actions {
        flex-direction: column;
        align-items: stretch;
    }
    
    .comment-submit-btn,
    .comment-cancel-btn {
        width: 100%;
    }
    
    .rating-stars .star-label {
        font-size: 28px;
        width: 36px;
        height: 36px;
    }
    
    .form-reactions .reaction-btn {
        width: 40px;
        height: 40px;
        font-size: 16px;
    }
}

@media (max-width: 480px) {
    .bricks-advanced-comments {
        margin: 10px 0;
    }
    
    .comments-title {
        font-size: 20px;
    }
    
    .comment-form-container {
        padding: 15px;
        margin: 0 -5px;
    }
    
    .comment-form-title {
        font-size: 18px;
    }
    
    .comment-item {
        margin: 0 -5px 20px;
        border-radius: 8px;
    }
    
    .comment-reactions .reaction-btn {
        padding: 4px 8px;
        font-size: 13px;
        min-width: 32px;
    }
    
    .comment-reactions .reaction-btn .emoji {
        font-size: 14px;
    }
    
    .rating-stars {
        gap: 2px;
    }
    
    .rating-stars .star-label {
        font-size: 24px;
        width: 32px;
        height: 32px;
    }
    
    .form-reactions .reaction-btn {
        width: 36px;
        height: 36px;
    }
    
    .form-reactions .reaction-btn .emoji {
        font-size: 18px;
    }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    .bricks-advanced-comments {
        color: #e0e0e0;
    }
    
    .comment-item {
        background: #2a2a2a;
        border-color: #404040;
        color: #e0e0e0;
    }
    
    .comment-item:hover {
        background: #333;
        border-color: #555;
    }
    
    .comment-form-container {
        background: #2a2a2a;
        border-color: #404040;
        color: #e0e0e0;
    }
    
    .form-group input,
    .form-group textarea {
        background: #333;
        border-color: #555;
        color: #e0e0e0;
    }
    
    .comment-reactions .reaction-btn,
    .form-reactions .reaction-btn {
        background: #333;
        border-color: #555;
        color: #e0e0e0;
    }
    
    .comment-reactions .reaction-btn:hover,
    .form-reactions .reaction-btn:hover {
        background: #404040;
    }
}

/* Print styles */
@media print {
    .comment-form-container,
    .comment-reactions,
    .form-reactions,
    .comment-actions,
    .comment-replies-toggle {
        display: none;
    }
    
    .comment-item {
        break-inside: avoid;
        box-shadow: none;
        border: 1px solid #ccc;
    }
}