/**
 * StressTherapist Comments Widget Styles
 * Matches existing --st-* CSS variables from article templates
 *
 * @package StressTherapist\Comments
 * @version 1.0.0
 */

/* ============================================
   CSS Variables (fallbacks for standalone use)
   ============================================ */
.st-comments-section {
    --st-accent-red: #d63939;
    --st-accent-red-hover: #bf0606;
    --st-accent-red-light: rgba(214, 57, 57, 0.1);
    --st-text-primary: #333333;
    --st-text-secondary: #666666;
    --st-text-light: #999999;
    --st-bg-light: #F8F9FA;
    --st-bg-white: #FFFFFF;
    --st-border-light: #E0E0E0;
    --st-font-family: 'Lato', 'Open Sans', -apple-system, BlinkMacSystemFont, sans-serif;
}

/* ============================================
   Base Container
   ============================================ */
.st-comments-section {
    padding: 60px 0;
    max-width: 800px;
    margin: 0 auto;
    font-family: var(--st-font-family);
}

.st-comments-section .st-container {
    max-width: 100%;
}

.st-comments-title {
    font-size: 28px;
    font-weight: 700;
    margin-bottom: 24px;
    color: var(--st-text-primary);
    display: flex;
    align-items: center;
    gap: 8px;
}

.st-comment-count {
    font-size: 20px;
    font-weight: 400;
    color: var(--st-text-light);
}

/* ============================================
   Engagement Prompt
   ============================================ */
.st-comment-prompt {
    background: linear-gradient(135deg, var(--st-accent-red-light) 0%, rgba(214, 57, 57, 0.03) 100%);
    border-left: 4px solid var(--st-accent-red);
    padding: 16px 20px;
    margin-bottom: 24px;
    border-radius: 0 8px 8px 0;
}

.st-prompt-text {
    margin: 0;
    color: var(--st-text-primary);
    font-size: 16px;
    font-weight: 500;
}

/* ============================================
   Comment Form
   ============================================ */
.st-comment-form {
    background: var(--st-bg-light);
    padding: 24px;
    border-radius: 12px;
    margin-bottom: 32px;
}

.st-comment-form h3 {
    font-size: 18px;
    font-weight: 600;
    margin: 0 0 16px;
    color: var(--st-text-primary);
}

.st-form-row {
    margin-bottom: 12px;
}

.st-textarea-row {
    position: relative;
}

.st-comment-form input[type="text"],
.st-comment-form input[type="email"] {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid var(--st-border-light);
    border-radius: 8px;
    font-family: var(--st-font-family);
    font-size: 15px;
    background: var(--st-bg-white);
    transition: border-color 0.2s, box-shadow 0.2s;
    box-sizing: border-box;
}

.st-comment-form input:focus,
.st-comment-form textarea:focus {
    outline: none;
    border-color: var(--st-accent-red);
    box-shadow: 0 0 0 3px var(--st-accent-red-light);
}

.st-comment-form input::placeholder,
.st-comment-form textarea::placeholder {
    color: var(--st-text-light);
}

.st-comment-form textarea {
    width: 100%;
    padding: 14px;
    border: 1px solid var(--st-border-light);
    border-radius: 8px;
    font-family: var(--st-font-family);
    font-size: 15px;
    line-height: 1.5;
    resize: vertical;
    min-height: 120px;
    background: var(--st-bg-white);
    transition: border-color 0.2s, box-shadow 0.2s;
    box-sizing: border-box;
}

.st-char-count {
    position: absolute;
    bottom: 10px;
    right: 12px;
    font-size: 12px;
    color: var(--st-text-light);
    pointer-events: none;
}

.st-char-warning {
    color: #f59e0b !important;
}

.st-char-error {
    color: var(--st-accent-red) !important;
}

.st-notify-row {
    display: none;
    margin-top: 8px;
}

.st-checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    color: var(--st-text-secondary);
    cursor: pointer;
}

.st-checkbox-label input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--st-accent-red);
}

.st-form-actions {
    display: flex;
    gap: 12px;
    align-items: center;
    margin-top: 16px;
}

.st-btn-submit {
    padding: 12px 28px;
    background: var(--st-accent-red);
    color: white;
    border: none;
    border-radius: 6px;
    font-family: var(--st-font-family);
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s;
}

.st-btn-submit:hover:not(:disabled) {
    background: var(--st-accent-red-hover);
}

.st-btn-submit:active:not(:disabled) {
    transform: scale(0.98);
}

.st-btn-submit:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.st-btn-cancel {
    display: none;
    padding: 10px 20px;
    background: transparent;
    border: 1px solid var(--st-border-light);
    border-radius: 6px;
    font-family: var(--st-font-family);
    font-size: 14px;
    color: var(--st-text-secondary);
    cursor: pointer;
    transition: border-color 0.2s, color 0.2s;
}

.st-btn-cancel:hover {
    border-color: var(--st-text-secondary);
    color: var(--st-text-primary);
}

.st-form-message {
    margin-top: 12px;
    padding: 10px 14px;
    border-radius: 6px;
    font-size: 14px;
    display: none;
}

.st-form-message:not(:empty) {
    display: block;
}

.st-form-message.st-success {
    background: rgba(34, 197, 94, 0.1);
    color: #16a34a;
    border: 1px solid rgba(34, 197, 94, 0.2);
}

.st-form-message.st-error {
    background: var(--st-accent-red-light);
    color: #c62828;
    border: 1px solid rgba(214, 57, 57, 0.2);
}

/* ============================================
   Comments List
   ============================================ */
.st-comments-list {
    min-height: 100px;
}

.st-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 40px 20px;
    color: var(--st-text-light);
    font-size: 15px;
}

.st-loading-spinner {
    width: 20px;
    height: 20px;
    border: 2px solid var(--st-border-light);
    border-top-color: var(--st-accent-red);
    border-radius: 50%;
    animation: st-spin 0.8s linear infinite;
}

@keyframes st-spin {
    to { transform: rotate(360deg); }
}

.st-no-comments,
.st-error {
    text-align: center;
    padding: 40px 20px;
    color: var(--st-text-light);
    font-size: 15px;
}

.st-error p {
    margin: 0 0 12px;
}

.st-btn-retry {
    padding: 8px 20px;
    background: var(--st-accent-red);
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    cursor: pointer;
}

/* ============================================
   Individual Comment
   ============================================ */
.st-comment {
    display: flex;
    gap: 12px;
    padding: 16px 0;
    border-bottom: 1px solid var(--st-border-light);
    transition: background 0.3s;
}

.st-comment:last-child {
    border-bottom: none;
}

.st-comment.st-highlight {
    background: rgba(214, 57, 57, 0.06);
    margin-left: -12px !important;
    margin-right: -12px;
    padding-left: 12px;
    padding-right: 12px;
    border-radius: 8px;
    border-bottom-color: transparent;
}

.st-comment-pinned {
    background: linear-gradient(135deg, rgba(214, 57, 57, 0.06) 0%, transparent 100%);
    margin-left: -12px !important;
    margin-right: -12px;
    padding: 16px 12px;
    border-radius: 8px;
    border: 1px solid rgba(214, 57, 57, 0.15);
    border-bottom: 1px solid rgba(214, 57, 57, 0.15) !important;
}

.st-comment-avatar {
    width: 40px;
    height: 40px;
    min-width: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 700;
    font-size: 14px;
    text-transform: uppercase;
}

.st-comment-body {
    flex: 1;
    min-width: 0;
}

.st-comment-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
    flex-wrap: wrap;
}

.st-comment-author {
    font-weight: 600;
    color: var(--st-text-primary);
    font-size: 15px;
}

.st-pinned-badge {
    background: var(--st-accent-red);
    color: white;
    font-size: 10px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.st-comment-time {
    font-size: 13px;
    color: var(--st-text-light);
    text-decoration: none;
    transition: color 0.2s;
}

.st-comment-time:hover {
    color: var(--st-accent-red);
}

.st-comment-content {
    color: var(--st-text-secondary);
    line-height: 1.6;
    font-size: 15px;
}

.st-comment-content p {
    margin: 0 0 8px;
}

.st-comment-content p:last-child {
    margin-bottom: 0;
}

.st-comment-actions {
    display: flex;
    gap: 8px;
    margin-top: 10px;
}

.st-btn-like,
.st-btn-reply,
.st-btn-link {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 5px 10px;
    background: none;
    border: none;
    color: var(--st-text-light);
    font-family: var(--st-font-family);
    font-size: 13px;
    border-radius: 4px;
    cursor: pointer;
    text-decoration: none;
    transition: color 0.2s, background 0.2s;
}

.st-btn-like:hover,
.st-btn-reply:hover,
.st-btn-link:hover {
    color: var(--st-accent-red);
    background: var(--st-accent-red-light);
}

.st-btn-like.st-liked {
    color: var(--st-accent-red);
}

.st-btn-like:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.st-like-count {
    min-width: 12px;
    text-align: left;
}

.st-icon-heart,
.st-icon-link {
    flex-shrink: 0;
}

/* ============================================
   Pagination
   ============================================ */
.st-pagination {
    margin-top: 24px;
    text-align: center;
}

.st-pagination-inner {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.st-page-btn {
    padding: 8px 12px;
    min-width: 36px;
    border: 1px solid var(--st-border-light);
    background: var(--st-bg-white);
    color: var(--st-text-secondary);
    font-family: var(--st-font-family);
    font-size: 14px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
}

.st-page-btn:hover {
    border-color: var(--st-accent-red);
    color: var(--st-accent-red);
}

.st-page-btn.st-page-active {
    background: var(--st-accent-red);
    border-color: var(--st-accent-red);
    color: white;
}

.st-page-ellipsis {
    padding: 0 8px;
    color: var(--st-text-light);
}

.st-page-prev,
.st-page-next {
    padding: 8px 14px;
}

/* ============================================
   Toast Notification
   ============================================ */
.st-toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: var(--st-text-primary);
    color: white;
    padding: 12px 24px;
    border-radius: 8px;
    font-family: var(--st-font-family);
    font-size: 14px;
    font-weight: 500;
    opacity: 0;
    transition: transform 0.3s ease, opacity 0.3s ease;
    z-index: 10000;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.st-toast-show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

/* ============================================
   Responsive Design
   ============================================ */
@media (max-width: 768px) {
    .st-comments-section {
        padding: 40px 16px;
    }

    .st-comments-title {
        font-size: 24px;
    }

    .st-comment-form {
        padding: 20px 16px;
    }

    .st-comment {
        gap: 10px;
    }

    .st-comment-avatar {
        width: 36px;
        height: 36px;
        min-width: 36px;
        font-size: 12px;
    }

    .st-comment-author {
        font-size: 14px;
    }

    .st-comment-content {
        font-size: 14px;
    }

    .st-comment-actions {
        flex-wrap: wrap;
        gap: 4px;
    }

    .st-btn-like,
    .st-btn-reply,
    .st-btn-link {
        padding: 4px 8px;
        font-size: 12px;
    }

    .st-form-actions {
        flex-direction: column;
        align-items: stretch;
    }

    .st-btn-submit,
    .st-btn-cancel {
        width: 100%;
        text-align: center;
    }

    .st-page-btn {
        padding: 6px 10px;
        min-width: 32px;
        font-size: 13px;
    }
}

@media (max-width: 480px) {
    .st-comments-section {
        padding: 32px 12px;
    }

    .st-comment-prompt {
        padding: 12px 16px;
    }

    .st-prompt-text {
        font-size: 14px;
    }

    .st-pagination-inner {
        flex-wrap: wrap;
        justify-content: center;
    }
}

/* ============================================
   Print Styles
   ============================================ */
@media print {
    .st-comment-form,
    .st-comment-actions,
    .st-pagination,
    .st-comment-prompt {
        display: none !important;
    }

    .st-comment {
        break-inside: avoid;
        page-break-inside: avoid;
    }
}

/* ============================================
   Reply Modal
   ============================================ */
.st-reply-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10000;
}

.st-reply-modal.st-modal-open {
    display: flex;
    align-items: center;
    justify-content: center;
}

.st-reply-modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    animation: st-fade-in 0.2s ease;
}

.st-reply-modal-content {
    position: relative;
    z-index: 1;
    width: 90%;
    max-width: 550px;
    max-height: 90vh;
    overflow-y: auto;
    animation: st-slide-up 0.3s ease;
}

.st-reply-modal-content .st-comment-form {
    margin: 0;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.st-reply-modal-content .st-comment-form h3 {
    display: flex;
    align-items: center;
    gap: 6px;
}

.st-reply-modal-content .st-reply-to-name {
    color: var(--st-accent-red);
    font-weight: 700;
}

.st-reply-modal-content .st-btn-cancel-modal {
    padding: 10px 20px;
    background: transparent;
    border: 1px solid var(--st-border-light);
    border-radius: 6px;
    font-family: var(--st-font-family);
    font-size: 14px;
    color: var(--st-text-secondary);
    cursor: pointer;
    transition: border-color 0.2s, color 0.2s;
}

.st-reply-modal-content .st-btn-cancel-modal:hover {
    border-color: var(--st-text-secondary);
    color: var(--st-text-primary);
}

@keyframes st-fade-in {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes st-slide-up {
    from {
        opacity: 0;
        transform: translateY(30px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Mobile adjustments for modal */
@media (max-width: 768px) {
    .st-reply-modal-content {
        width: 95%;
        max-height: 85vh;
    }

    .st-reply-modal-content .st-comment-form {
        padding: 20px 16px;
    }
}

/* ============================================
   Formatting toolbar (bold / italic / underline / emoji)
   ============================================ */
.st-format-toolbar {
    position: relative;
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 6px 8px;
    background: var(--st-bg-white);
    border: 1px solid var(--st-border-light);
    border-bottom: none;
    border-radius: 8px 8px 0 0;
}

/* Snug the textarea up under the toolbar */
.st-format-toolbar + textarea {
    border-top-left-radius: 0 !important;
    border-top-right-radius: 0 !important;
    margin-top: 0;
}

.st-comment-form .st-format-toolbar .st-fmt-btn {
    margin: 0;
    min-width: 32px;
    height: 32px;
    padding: 0 8px;
    border: 1px solid transparent;
    border-radius: 6px;
    background: transparent;
    color: var(--st-text-primary);
    font-family: var(--st-font-family);
    font-size: 15px;
    line-height: 1;
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease;
}

.st-comment-form .st-format-toolbar .st-fmt-btn:hover {
    background: var(--st-bg-light);
    border-color: var(--st-border-light);
}

.st-comment-form .st-format-toolbar .st-fmt-btn:active {
    background: var(--st-accent-red-light);
}

.st-toolbar-divider {
    width: 1px;
    height: 20px;
    margin: 0 4px;
    background: var(--st-border-light);
}

.st-emoji-panel {
    position: absolute;
    top: calc(100% + 4px);
    left: 8px;
    z-index: 50;
    display: grid;
    grid-template-columns: repeat(10, 1fr);
    gap: 2px;
    max-width: 340px;
    padding: 8px;
    background: var(--st-bg-white);
    border: 1px solid var(--st-border-light);
    border-radius: 8px;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.12);
}

.st-emoji-panel[hidden] {
    display: none;
}

.st-comment-form .st-emoji-panel .st-emoji-btn {
    margin: 0;
    width: 30px;
    height: 30px;
    padding: 0;
    border: none;
    border-radius: 6px;
    background: transparent;
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
    transition: background 0.15s ease;
}

.st-comment-form .st-emoji-panel .st-emoji-btn:hover {
    background: var(--st-bg-light);
}

/* ============================================
   Nested replies — clearly threaded under their parent
   ============================================ */
.st-comment-reply {
    border-left: 3px solid rgba(214, 57, 57, 0.35);
    background: var(--st-bg-light);
    border-radius: 0 10px 10px 0;
    padding-left: 14px;
    padding-right: 12px;
    margin-top: 4px;
    margin-bottom: 8px;
    border-bottom: none;
}

.st-comment-reply .st-comment-avatar {
    width: 30px;
    height: 30px;
    min-width: 30px;
    font-size: 12px;
}

.st-reply-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 9px;
    border-radius: 10px;
    background: var(--st-accent-red-light);
    color: var(--st-text-secondary);
    font-size: 12px;
    line-height: 1.6;
    white-space: nowrap;
}

@media (max-width: 768px) {
    .st-reply-badge {
        white-space: normal;
    }
}

/* Inline formatting inside rendered comments */
.st-comment-content strong {
    font-weight: 700;
}

.st-comment-content em {
    font-style: italic;
}

.st-comment-content u {
    text-decoration: underline;
}

@media (max-width: 768px) {
    .st-emoji-panel {
        grid-template-columns: repeat(8, 1fr);
        left: 0;
        right: 0;
        max-width: none;
    }
}

/* ===== PCW free tools overrides (PCW look) ===== */
.st-comments-section.pcw-comments{
    --st-accent-red:#4ca154; --st-accent-red-hover:#45914c; --st-accent-red-light:rgba(76,161,84,.12);
    --st-text-primary:#111827; --st-text-secondary:#626b76; --st-text-light:#8a929b;
    --st-bg-light:#f5f7f3; --st-border-light:#dce1dc;
    --st-font-family:Inter,ui-sans-serif,system-ui,sans-serif;
    max-width:760px; margin:0; padding:20px 0 50px;
}
.pcw-comments .st-comments-title{font-size:30px;line-height:1.2;letter-spacing:-.9px}
.pcw-comments .st-comment-prompt{display:none}
.pcw-comments .pcw-review-note{font-size:13px;color:#626b76;margin:-4px 0 14px}
.pcw-comments .st-btn-submit{border-radius:6px;font-weight:600}
.pcw-comments .st-btn-reply,.pcw-comments .st-reply-modal{display:none!important}
