/* ========================================
   Custom Comment Form Styles v2.0
   มีระบบ Reply + Admin Highlight
   วาง CSS นี้ใน style.css ของ theme หรือใน Customizer
   ======================================== */

/* Comments Section Container */
#comments-section {
    max-width: 100%;
    margin: 0px auto;
    padding: 0;
}

.commentx h3 {
    color: #FFF !important;
} 

.comment-form-title {
    color: #000 !important;
}

.custom-comment-form-wrapper h3 {
    color: #000 !important;
}

/* ========================================
   COMMENT FORM STYLES
   ======================================== */

.custom-comment-form-wrapper {
    background: #ffffff;
    border-radius: 12px;
    padding: 30px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
    margin-bottom: 40px;
    border: 1px solid #e8e8e8;
}

.comment-form-title {
    font-size: 24px;
    font-weight: 700;
    color: #2c3e50;
    margin: 0 0 25px 0;
    padding-bottom: 15px;
    border-bottom: 3px solid #3498db;
}

/* Reply Form Title */
.reply-form-title {
    font-size: 18px;
    font-weight: 600;
    color: #3498db;
    margin: 0 0 20px 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.reply-form-title svg {
    color: #3498db;
}

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

.comment-form-field label {
    display: block;
    font-weight: 600;
    color: #34495e;
    margin-bottom: 8px;
    font-size: 14px;
}

.comment-form-field .required {
    color: #e74c3c;
    font-weight: bold;
}

.comment-form-field input[type="text"],
.comment-form-field input[type="email"],
.comment-form-field input[type="number"],
.comment-form-field textarea {
    width: 100%;
    padding: 12px 15px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 15px;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Sarabun', sans-serif;
    transition: all 0.3s ease;
    background: #fafafa;
    color: #000 !important;
}

.comment-form-field input:focus,
.comment-form-field textarea:focus {
    outline: none;
    border-color: #3498db;
    background: #ffffff;
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1);
}

.comment-form-field textarea {
    resize: vertical;
    min-height: 120px;
    line-height: 1.6;
}

.form-hint {
    display: block;
    margin-top: 6px;
    color: #7f8c8d;
    font-size: 13px;
    font-style: italic;
}

/* Logged In Message */
.logged-in-as {
    background: #f0f8ff;
    padding: 15px;
    border-radius: 8px;
    border-left: 4px solid #3498db;
    margin-bottom: 20px;
    font-size: 14px;
    color: #2c3e50;
}

.logged-in-as strong {
    color: #3498db;
    font-weight: 600;
}

.logged-in-as a {
    color: #e74c3c;
    text-decoration: none;
    margin-left: 10px;
    font-weight: 500;
}

.logged-in-as a:hover {
    text-decoration: underline;
}

/* Math CAPTCHA Styles */
.captcha-field {
    background: #fff9e6;
    padding: 20px;
    border-radius: 8px;
    border: 2px solid #f39c12;
}

.math-captcha {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-top: 10px;
}

.math-question {
    background: #ffffff;
    padding: 12px 20px;
    border-radius: 6px;
    font-size: 20px;
    font-weight: 700;
    color: #2c3e50;
    border: 2px solid #f39c12;
    min-width: 120px;
    text-align: center;
    box-shadow: 0 2px 8px rgba(243, 156, 18, 0.2);
}

.math-captcha input[type="number"] {
    width: 150px;
    padding: 12px;
    text-align: center;
    font-size: 18px;
    font-weight: 600;
    border: 2px solid #f39c12;
}

/* Submit Button */
.comment-form-submit {
    margin-top: 25px;
    display: flex;
    gap: 10px;
    align-items: center;
}

.submit-comment-btn {
    background: linear-gradient(135deg, #3498db 0%, #2980b9 100%);
    color: #ffffff;
    border: none;
    padding: 14px 32px;
    font-size: 16px;
    font-weight: 600;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    box-shadow: 0 4px 12px rgba(52, 152, 219, 0.3);
}

.submit-comment-btn:hover {
    background: linear-gradient(135deg, #2980b9 0%, #21618c 100%);
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(52, 152, 219, 0.4);
}

.submit-comment-btn:active {
    transform: translateY(0);
}

.submit-comment-btn svg {
    transition: transform 0.3s ease;
}

.submit-comment-btn:hover svg {
    transform: translateX(3px);
}

/* Cancel Reply Button */
.cancel-reply-btn {
    background: #95a5a6;
    color: #ffffff;
    border: none;
    padding: 14px 24px;
    font-size: 16px;
    font-weight: 600;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.cancel-reply-btn:hover {
    background: #7f8c8d;
}

/* Success Messages */
.comment-success-message {
    display: flex;
    align-items: flex-start;
    gap: 15px;
    padding: 20px;
    border-radius: 10px;
    margin-bottom: 25px;
    animation: slideDown 0.4s ease-out;
}

.comment-success-message.approved {
    background: linear-gradient(135deg, #d4edda 0%, #c3e6cb 100%);
    border: 2px solid #28a745;
    color: #155724;
}

.comment-success-message.pending {
    background: linear-gradient(135deg, #fff3cd 0%, #ffeaa7 100%);
    border: 2px solid #ffc107;
    color: #856404;
}

.comment-success-message svg {
    flex-shrink: 0;
    margin-top: 2px;
}

.comment-success-message .message-content strong {
    display: block;
    font-size: 16px;
    margin-bottom: 5px;
}

.comment-success-message .message-content p {
    margin: 0;
    font-size: 14px;
}

/* ========================================
   COMMENTS LIST STYLES
   ======================================== */

.comments-list-wrapper {
    margin-bottom: 15px;
}

.comments-title {
    font-size: 22px;
    font-weight: 700;
    color: #2c3e50;
    margin-bottom: 25px;
    padding-bottom: 12px;
    border-bottom: 2px solid #ecf0f1;
}

.no-comments {
    text-align: center;
    padding: 40px 20px;
    background: #f8f9fa;
    border-radius: 8px;
    color: #7f8c8d;
    font-size: 15px;
    font-style: italic;
}

.comments-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.comment-item {
    display: flex;
    gap: 15px;
    padding: 20px;
    background: #ffffff;
    border-radius: 10px;
    margin-bottom: 5px;
    border: 1px solid #e8e8e8;
    transition: all 0.3s ease;
}

.comment-item:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    border-color: #3498db;
}

/* ========================================
   ADMIN COMMENT STYLES (ไฮไลท์พิเศษ)
   ======================================== */

.comment-item.admin-comment,
.comment-reply.admin-comment {
    background: linear-gradient(135deg, #fff8e1 0%, #ffecb3 100%);
    border: 2px solid #ffa726;
    box-shadow: 0 4px 15px rgba(255, 167, 38, 0.15);
}

.comment-item.admin-comment:hover,
.comment-reply.admin-comment:hover {
    border-color: #ff9800;
    box-shadow: 0 6px 20px rgba(255, 152, 0, 0.25);
}

/* Admin Badge */
.admin-badge {
    position: absolute;
    bottom: -5px;
    right: -5px;
    background: linear-gradient(135deg, #ff9800 0%, #f57c00 100%);
    color: #ffffff;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid #ffffff;
    box-shadow: 0 2px 8px rgba(255, 152, 0, 0.4);
}

/* Admin Label */
.admin-label {
    background: linear-gradient(135deg, #ff9800 0%, #f57c00 100%);
    color: #ffffff;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-left: 8px;
    box-shadow: 0 2px 6px rgba(255, 152, 0, 0.3);
}

/* Avatar Container */
.comment-avatar {
    flex-shrink: 0;
    position: relative;
}

.comment-avatar img {
    border-radius: 50%;
    border: 3px solid #ecf0f1;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Admin Avatar มีกรอบทอง */
.admin-comment .comment-avatar img {
    border-color: #ffa726;
    box-shadow: 0 3px 10px rgba(255, 167, 38, 0.3);
}

.comment-avatar img:hover {
    transform: scale(1.15) rotate(5deg);
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.3);
}

.comment-content-wrap {
    flex-grow: 1;
}

.comment-meta {
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.comment-author {
    font-weight: 700;
    color: #2c3e50;
    font-size: 15px;
    display: flex;
    align-items: center;
}

.comment-date {
    color: #95a5a6;
    font-size: 13px;
}

.comment-date::before {
    content: "•";
    margin-right: 8px;
}

.comment-text {
    color: #34495e;
    line-height: 1.7;
    font-size: 15px;
}

.comment-text p {
    margin: 0 0 10px 0;
}

.comment-text p:last-child {
    margin-bottom: 0;
}

/* ========================================
   REPLY BUTTON & FORM STYLES
   ======================================== */

.comment-actions {
    margin-top: 15px;
    padding-top: 12px;
    border-top: 1px solid #ecf0f1;
}

.reply-btn {
    background: transparent;
    color: #3498db;
    border: 2px solid #3498db;
    padding: 8px 16px;
    font-size: 14px;
    font-weight: 600;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.reply-btn:hover {
    background: #3498db;
    color: #ffffff;
    transform: translateY(-2px);
    box-shadow: 0 4px 10px rgba(52, 152, 219, 0.3);
}

.reply-btn svg {
    transition: transform 0.3s ease;
}

.reply-btn:hover svg {
    transform: translateX(-3px);
}

/* Reply Form Container */
.reply-form-container {
    margin-top: 20px;
    animation: slideDown 0.3s ease-out;
}

.reply-form-container .custom-comment-form-wrapper {
    background: #f8f9fa;
    border: 2px dashed #3498db;
    padding: 20px;
    margin: 0;
}

/* ========================================
   REPLIES LIST (ซ้อนใต้ Comment หลัก)
   ======================================== */

.comment-replies {
    list-style: none;
    padding: 0;
    margin: 20px 0 0 0;
}

.comment-reply {
    display: flex;
    gap: 12px;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 8px;
    margin-bottom: 10px;
    border: 1px solid #e0e0e0;
    margin-left: 20px;
    transition: all 0.3s ease;
}

.comment-reply:hover {
    background: #ffffff;
    border-color: #3498db;
    box-shadow: 0 2px 8px rgba(52, 152, 219, 0.1);
}

.comment-reply .comment-avatar img {
    width: 40px;
    height: 40px;
    border-width: 2px;
}

.comment-reply .comment-author {
    font-size: 14px;
}

.comment-reply .comment-date {
    font-size: 12px;
}

.comment-reply .comment-text {
    font-size: 14px;
}

/* Reply ของ Admin */
.comment-reply.admin-comment {
    margin-left: 20px;
    background: linear-gradient(135deg, #fff8e1 0%, #ffecb3 100%);
}

/* ========================================
   ANIMATIONS
   ======================================== */

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

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes avatarPop {
    0% {
        transform: scale(0);
        opacity: 0;
    }
    50% {
        transform: scale(1.1);
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

.comment-item,
.comment-reply {
    animation: slideIn 0.4s ease-out;
}

.comment-avatar img {
    animation: avatarPop 0.5s ease-out;
}

/* ========================================
   RESPONSIVE DESIGN
   ======================================== */

@media screen and (max-width: 768px) {
    .custom-comment-form-wrapper {
        padding: 20px;
    }
    
    .comment-form-title {
        font-size: 20px;
    }
    
    .math-captcha {
        flex-direction: column;
        align-items: stretch;
    }
    
    .math-question {
        text-align: center;
    }
    
    .math-captcha input[type="number"] {
        width: 100%;
    }
    
    .comment-form-submit {
        flex-direction: column;
    }
    
    .submit-comment-btn,
    .cancel-reply-btn {
        width: 100%;
        justify-content: center;
    }
    
    .comment-item,
    .comment-reply {
        flex-direction: column;
    }
    
    .comment-avatar {
        align-self: flex-start;
    }
    
    .comment-reply {
        margin-left: 10px;
    }
    
    .admin-badge {
        width: 20px;
        height: 20px;
    }
    
    .admin-badge svg {
        width: 12px;
        height: 12px;
    }
}

@media screen and (max-width: 480px) {
    #comments-section {
        padding: 0;
    }
    
    .custom-comment-form-wrapper {
        padding: 15px;
    }
    
    .comment-form-field input,
    .comment-form-field textarea {
        font-size: 16px; /* ป้องกัน zoom บน iOS */
    }
    
    .comment-reply {
        margin-left: 0;
        padding-left: 10px;
        border-left: 3px solid #3498db;
    }
}

/* ========================================
   CLOSED COMMENTS
   ======================================== */

.comments-closed {
    text-align: center;
    padding: 30px;
    background: #fff3cd;
    border: 2px solid #ffc107;
    border-radius: 8px;
    color: #856404;
    font-weight: 600;
}

/* ========================================
   DARK MODE SUPPORT (Optional)
   ======================================== */

@media (prefers-color-scheme: dark) {
    .custom-comment-form-wrapper,
    .comment-item {
        background: #2c3e50;
        border-color: #34495e;
    }
    
    .comment-form-title,
    .comments-title,
    .comment-author {
        color: #ecf0f1;
    }
    
    .comment-form-field input,
    .comment-form-field textarea {
        background: #34495e;
        border-color: #4a5f7f;
        color: #ecf0f1;
    }
    
    .comment-text {
        color: #bdc3c7;
    }
    
    .comment-date {
        color: #7f8c8d;
    }
    
    .comment-reply {
        background: #34495e;
        border-color: #4a5f7f;
    }
    
    .comment-item.admin-comment,
    .comment-reply.admin-comment {
        background: linear-gradient(135deg, #3d3121 0%, #4a3e28 100%);
        border-color: #ffa726;
    }
}