/* 
 * Josjis Theme - Comments Component
 * @package Josjis
 * Social media style comment layout
 */

.josjis-comments-section {
    margin-top: 40px;
    border-top: 1px solid var(--color-border);
}

.josjis-comments-title {
    margin: 40px 0 24px;
    font-family: var(--typo-section-heading-font, inherit);
    font-size: var(--typo-section-heading-size-desktop, 20px);
    font-weight: var(--typo-section-heading-weight, 700);
    line-height: var(--typo-section-heading-lh, 1.2);
    color: var(--color-text);
    display: inline-block;
    position: relative;
}

/* ==========================================================================
   COMMENT LIST
   ========================================================================== */

.josjis-comment-list,
.josjis-comment-list .children {
    list-style: none;
    margin: 0;
    padding: 0;
}

.josjis-comment-list .children {
    margin-left: 56px; /* Indentation for threaded replies */
    margin-top: 16px;
    position: relative;
}

/* Sub-thread line guide */
.josjis-comment-list .children::before {
    content: '';
    position: absolute;
    left: -32px;
    top: 0;
    bottom: 0px;
    width: 2px;
    background-color: var(--color-border);
    border-radius: 2px;
}

/* Mobile indentation */
@media (max-width: 600px) {
    .josjis-comment-list .children {
        margin-left: 20px;
    }
    .josjis-comment-list .children::before {
        left: -12px;
    }
}

.josjis-comment {
    margin-bottom: 20px;
}

.josjis-comment-body {
    display: flex;
    gap: 16px;
    padding: 16px;
    background: var(--bg-card, #ffffff);
    border: 1px solid var(--color-border);
    border-radius: 12px;
    transition: background-color 0.2s ease, border-color 0.2s ease;
}

.josjis-comment-body:hover {
    border-color: rgba(var(--color-primary-rgb, 0, 115, 170), 0.3);
}

/* Reply style slightly different background */
.is-reply > .josjis-comment-body {
    background: transparent;
    border: none;
    padding: 12px 0 0 0;
}
.is-reply > .josjis-comment-body:hover {
    border-color: transparent;
}


/* Avatar */
.josjis-comment-avatar {
    flex-shrink: 0;
}

.josjis-avatar-img {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    object-fit: cover;
    background: var(--bg-secondary);
    display: block;
}

.is-reply .josjis-avatar-img {
    width: 36px;
    height: 36px;
}


/* Content Area */
.josjis-comment-content {
    flex-grow: 1;
    min-width: 0; /* text truncation wrapping */
}

/* Header */
.josjis-comment-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 12px;
    margin-bottom: 6px;
}

.josjis-comment-author {
    font-weight: 600;
    font-size: 15px;
    color: var(--text-primary);
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.josjis-comment-author a {
    color: inherit;
    text-decoration: none;
}
.josjis-comment-author a:hover {
    color: var(--color-primary);
    text-decoration: underline;
}

.josjis-author-badge {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    background: var(--color-primary);
    color: #fff;
    padding: 2px 6px;
    border-radius: 4px;
    line-height: 1;
}

.josjis-comment-date a {
    font-size: 13px;
    color: var(--text-tertiary, #6b7280);
    text-decoration: none;
}
.josjis-comment-date a:hover {
    text-decoration: underline;
}

/* Moderation */
.josjis-comment-moderation {
    font-size: 13px;
    color: #d97706; /* warning color */
    background: #fef3c7;
    padding: 6px 10px;
    border-radius: 6px;
    margin-bottom: 10px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

/* Text payload */
.josjis-comment-text {
    font-size: 15px;
    line-height: 1.6;
    color: var(--text-secondary, #4b5563);
    margin-bottom: 12px;
    word-break: break-word;
}
.josjis-comment-text p {
    margin-top: 0;
    margin-bottom: 10px;
}
.josjis-comment-text p:last-child {
    margin-bottom: 0;
}

/* Actions */
.josjis-comment-actions {
    display: flex;
    gap: 16px;
    align-items: center;
}

.josjis-comment-actions a {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-tertiary, #6b7280);
    text-decoration: none;
    transition: color 0.2s;
    background: transparent;
    border: none;
    padding: 0;
    cursor: pointer;
}

.josjis-comment-actions a:hover {
    color: var(--color-primary);
}


/* Pagination */
.josjis-comment-pagination {
    margin-top: 30px;
    display: flex;
    justify-content: center;
    gap: 8px;
}
.josjis-comment-pagination .page-numbers {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    height: 36px;
    padding: 0 10px;
    border-radius: 6px;
    background: var(--bg-card);
    border: 1px solid var(--color-border);
    color: var(--text-primary);
    font-weight: 600;
    font-size: 14px;
    text-decoration: none;
    transition: all 0.2s;
}
.josjis-comment-pagination .page-numbers:hover {
    border-color: var(--color-primary);
    color: var(--color-primary);
}
.josjis-comment-pagination .page-numbers.current {
    background: var(--color-primary);
    color: #fff;
    border-color: var(--color-primary);
}

.josjis-comments-closed {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 20px;
    background: var(--bg-secondary);
    border-radius: 8px;
    color: var(--text-secondary);
    font-weight: 500;
    margin-top: 20px;
    text-align: center;
}


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

.josjis-comment-form-wrapper {
    margin-top: 40px;
    background: var(--bg-card);
    border: 1px solid var(--color-border);
    border-radius: 12px;
    padding: 24px;
}

.josjis-comment-form-wrapper #reply-title {
    font-size: 18px;
    font-weight: 700;
    margin: 0 0 20px 0;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 10px;
}

.josjis-comment-form-wrapper #cancel-comment-reply-link {
    align-items: center;
    gap: 4px;
    font-size: 13px;
    font-weight: 600;
    color: #dc2626; /* red */
    background: rgba(220, 38, 38, 0.1);
    border: none;
    padding: 6px 12px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
}
/* Force flex only when WP is NOT hiding it */
.josjis-comment-form-wrapper #cancel-comment-reply-link:not([style*="display: none"]):not([style*="display:none"]) {
    display: inline-flex !important;
}

.josjis-comment-form-wrapper #cancel-comment-reply-link:hover {
    background: #dc2626;
    color: #fff;
}

.josjis-comment-form {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.josjis-comment-textarea-wrap textarea {
    width: 100%;
    background: var(--bg-secondary);
    border: 1px solid var(--color-border);
    border-radius: 8px;
    padding: 16px;
    font-family: inherit;
    font-size: 15px;
    color: var(--text-primary);
    resize: vertical;
    min-height: 120px;
    transition: border-color 0.2s, box-shadow 0.2s;
}
.josjis-comment-textarea-wrap textarea:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(var(--color-primary-rgb, 0, 115, 170), 0.15);
}

.josjis-comment-fields-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
}

.josjis-field-wrap {
    position: relative;
    display: flex;
    align-items: center;
}

.josjis-field-icon {
    position: absolute;
    left: 14px;
    color: var(--text-tertiary);
    display: flex;
    align-items: center;
    pointer-events: none;
}

.josjis-field-wrap input {
    width: 100%;
    background: var(--bg-secondary);
    border: 1px solid var(--color-border);
    border-radius: 8px;
    padding: 12px 14px 12px 40px;
    font-family: inherit;
    font-size: 15px;
    color: var(--text-primary);
    transition: border-color 0.2s, box-shadow 0.2s;
}

.josjis-field-wrap input:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(var(--color-primary-rgb, 0, 115, 170), 0.15);
}

.josjis-field-cookies {
    display: flex;
    align-items: flex-start;
    gap: 10px;
}
.josjis-field-cookies input[type="checkbox"] {
    margin-top: 3px;
    width: 16px;
    height: 16px;
    accent-color: var(--color-primary);
}
.josjis-field-cookies label {
    font-size: 14px;
    color: var(--text-secondary);
    line-height: 1.5;
    cursor: pointer;
}

.form-submit {
    margin: 0;
}

.josjis-submit-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: var(--color-primary);
    color: #fff;
    padding: 14px 24px;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s, background-color 0.2s;
}
.josjis-submit-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 15px rgba(var(--color-primary-rgb, 0, 115, 170), 0.3);
}
.josjis-submit-btn:active {
    transform: translateY(0);
}

/* ==========================================================================
   DARK MODE ADAPTATIONS
   ========================================================================== */
[data-theme="dark"] .josjis-comment-moderation {
    background: rgba(217, 119, 6, 0.2);
    color: #fbbf24;
}

[data-theme="dark"] .josjis-comment-form-wrapper #cancel-comment-reply-link {
    background: rgba(248, 113, 113, 0.15);
    color: #f87171;
}
[data-theme="dark"] .josjis-comment-form-wrapper #cancel-comment-reply-link:hover {
    background: #ef4444;
    color: #fff;
}
