/**
 * YouTube-Style Comments CSS
 * Strictly scoped inside #comments to preserve theme and blog post design integrity.
 * SpendWisely Starter Theme
 */

/* ==========================================================================
   Page Layout & Container Width Compatibility
   ========================================================================== */
.container.no-sidebar .site-main,
.no-sidebar .site-main {
    display: block !important;
    width: 100% !important;
}

.no-sidebar .single-post-content {
    max-width: 800px;
    margin: 0 auto;
    width: 100%;
}

.single-post-content {
    min-width: 0;
    width: 100%;
    box-sizing: border-box;
}

/* ==========================================================================
   Base Scoped Layout
   ========================================================================== */
#comments.sw-yt-comments-area {
    /* Retains default .comments-area border and margin from style.css */
    font-family: inherit;
    color: inherit;
    box-sizing: border-box;
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
    overflow-wrap: break-word;
    word-break: break-word;
}

#comments .sw-yt-comments-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 1.3rem;
    margin-bottom: 25px;
    font-weight: 700;
}

#comments .sw-yt-total-count {
    color: inherit;
}

#comments .sw-yt-count-label {
    color: inherit;
}

/* ==========================================================================
   Avatar Styles
   ========================================================================== */
#comments .sw-yt-avatar {
    position: relative;
    border-radius: 50%;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    user-select: none;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

#comments .sw-yt-avatar-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
    display: block;
}

#comments .sw-yt-avatar-initial {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #ffffff;
    font-weight: 700;
    font-size: 0.95rem;
    text-transform: uppercase;
    line-height: 1;
}

#comments .sw-yt-avatar-guest {
    background: #64748b;
}

#comments .depth-2 .sw-yt-avatar .sw-yt-avatar-initial {
    font-size: 0.8rem;
}



/* ==========================================================================
   Comment Forms (Main & Inline)
   ========================================================================== */
#comments .sw-yt-form-wrapper {
    display: flex;
    gap: 16px;
    margin-bottom: 32px;
}

#comments .sw-yt-form-avatar-col {
    flex-shrink: 0;
    padding-top: 2px;
}

#comments .sw-yt-form-content-col {
    flex: 1;
    min-width: 0;
}

#comments .sw-yt-form {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* Returning User Notification Bar */
#comments .sw-yt-returning-user-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
    color: #475569;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    padding: 6px 12px;
    border-radius: 8px;
    width: fit-content;
    max-width: 100%;
    box-sizing: border-box;
    flex-wrap: wrap;
}

#comments .sw-yt-returning-text strong {
    color: #0f172a;
    font-weight: 600;
}

#comments .sw-yt-dot {
    color: #94a3b8;
}

#comments .sw-yt-switch-user-btn {
    background: none;
    border: none;
    color: #0073aa;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    padding: 0;
    text-decoration: underline;
    transition: color 0.15s ease;
}

#comments .sw-yt-switch-user-btn:hover {
    color: #005177;
}

/* Textarea with Animated Expanding Underline */
#comments .sw-yt-textarea-wrapper {
    position: relative;
    width: 100%;
}

#comments .sw-yt-textarea {
    width: 100%;
    min-height: 40px;
    max-height: 300px;
    padding: 8px 0;
    background: transparent;
    border: none;
    border-bottom: 1px solid #cbd5e1;
    border-radius: 0;
    font-family: inherit;
    font-size: 0.95rem;
    line-height: 1.5;
    color: inherit;
    resize: none;
    box-sizing: border-box;
    transition: min-height 0.2s ease, border-color 0.2s ease;
    outline: none;
}

#comments .sw-yt-textarea:focus {
    min-height: 64px;
    outline: none;
    border-bottom-color: transparent;
}

#comments .sw-yt-focus-line {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 2px;
    background-color: #0073aa;
    transform: scaleX(0);
    transform-origin: center;
    transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    pointer-events: none;
}

#comments .sw-yt-textarea:focus~.sw-yt-focus-line {
    transform: scaleX(1);
}

/* Guest Input Fields (Name, Email) */
#comments .sw-yt-user-fields {
    margin-top: 4px;
}

#comments .sw-yt-input-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

#comments .sw-yt-input-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

#comments .sw-yt-label {
    font-size: 0.82rem;
    font-weight: 600;
    color: #475569;
}

#comments .sw-yt-required {
    color: #ef4444;
}

#comments .sw-yt-optional {
    font-size: 0.75rem;
    color: #94a3b8;
    font-weight: 400;
    margin-left: 3px;
}

#comments .sw-yt-input {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    font-size: 0.9rem;
    color: inherit;
    background: #ffffff;
    outline: none;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
    box-sizing: border-box;
}

#comments .sw-yt-input:focus {
    border-color: #0073aa;
    box-shadow: 0 0 0 3px rgba(0, 115, 170, 0.15);
}

/* Action Buttons */
#comments .sw-yt-form-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 6px;
}

#comments .sw-yt-form-feedback {
    margin-right: auto;
    font-size: 0.85rem;
    font-weight: 500;
    padding: 6px 12px;
    border-radius: 6px;
    display: none !important;
}

#comments .sw-yt-form-feedback.is-error {
    background: #fef2f2;
    color: #b91c1c;
    border: 1px solid #fecaca;
}

#comments .sw-yt-form-feedback.is-success {
    background: #f0fdf4;
    color: #15803d;
    border: 1px solid #bbf7d0;
}

#comments .sw-yt-btn-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

#comments .sw-yt-btn {
    border: none;
    border-radius: 18px;
    padding: 8px 18px;
    font-size: 0.88rem;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.15s ease, opacity 0.15s ease, color 0.15s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1.2;
}

#comments .sw-yt-btn-cancel {
    background: transparent;
    color: #475569;
}

#comments .sw-yt-btn-cancel:hover {
    background: #f1f5f9;
    color: #0f172a;
}

#comments .sw-yt-btn-submit {
    background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
    padding: 12px 30px;
        border: 1px solid #e2e8f0;
    border-radius: 100px;
    color: #ffffff;
}

#comments .sw-yt-btn-submit:hover:not(:disabled) {
    background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
}

#comments .sw-yt-btn-submit:disabled {
    background: #cbd5e1;
    color: #ffffff;
    cursor: not-allowed;
    opacity: 0.7;
}

/* ==========================================================================
   Comments List & Items
   ========================================================================== */
#comments .sw-yt-comments-list {
    display: flex;
    flex-direction: column;
    gap: 24px;
    margin-top: 10px;
}

#comments .sw-yt-comment-item {
    display: flex;
    flex-direction: column;
    position: relative;
    transition: background-color 0.3s ease;
}

#comments .sw-yt-comment-item.is-highlighted {
    animation: swYtPulseHighlight 2.5s ease-out;
}

@keyframes swYtPulseHighlight {
    0% {
        background-color: rgba(0, 115, 170, 0.15);
        border-radius: 8px;
    }

    100% {
        background-color: transparent;
    }
}

#comments .sw-yt-comment-body {
    display: flex;
    gap: 14px;
}

#comments .sw-yt-comment-avatar-col {
    flex-shrink: 0;
    padding-top: 2px;
}

#comments .sw-yt-comment-content-col {
    flex: 1;
    min-width: 0;
}

#comments .sw-yt-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
    line-height: 1.2;
}

#comments .sw-yt-author-name {
    font-size: 0.88rem;
    font-weight: 600;
    color: inherit;
}

.sw-yt-badge-author,
#comments .sw-yt-badge-author {
    display: inline-flex !important;
    align-items: center !important;
    background: #065fd4 !important;
    /* YouTube Verified Blue */
    color: #ffffff !important;
    font-size: 0.70rem !important;
    font-weight: 700 !important;
    padding: 2px 8px !important;
    border-radius: 12px !important;
    text-transform: uppercase !important;
    letter-spacing: 0.4px !important;
    line-height: 1.2 !important;
    vertical-align: middle !important;
    margin-left: 6px !important;
    box-shadow: 0 1px 3px rgba(6, 95, 212, 0.3) !important;
    white-space: nowrap !important;
}

#comments .sw-yt-time {
    font-size: 0.78rem;
    color: #888888;
}

#comments .sw-yt-text {
    font-size: 0.92rem;
    line-height: 1.55;
    color: inherit;
    word-break: break-word;
}

#comments .sw-yt-text p {
    margin: 0 0 6px;
}

#comments .sw-yt-text p:last-child {
    margin-bottom: 0;
}

/* Action Bar (Like & Reply) */
#comments .sw-yt-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 8px;
}

#comments .sw-yt-btn-action {
    background: transparent;
    border: none;
    color: inherit;
    font-size: 0.82rem;
    font-weight: 600;
    border-radius: 16px;
    padding: 6px 10px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: background-color 0.15s ease, color 0.15s ease;
    user-select: none;
}

#comments .sw-yt-btn-action:hover {
    background-color: #f1f5f9;
}

/* Like Button Specifics */
#comments .sw-yt-btn-like {
    padding: 5px 8px;
}

#comments .sw-yt-icon-like {
    transition: transform 0.15s ease, fill 0.15s ease, stroke 0.15s ease;
}

#comments .sw-yt-btn-like:hover .sw-yt-icon-like {
    transform: scale(1.1);
}

#comments .sw-yt-btn-like.is-liked {
    color: #0073aa;
}

#comments .sw-yt-btn-like.is-liked .sw-yt-icon-like {
    fill: #0073aa;
    stroke: #0073aa;
}

#comments .sw-yt-like-count {
    font-size: 0.78rem;
    font-weight: 600;
    min-width: 8px;
}

/* Inline Reply Form Container */
#comments .sw-yt-reply-form-slot {
    margin-top: 12px;
}

#comments .sw-yt-reply-form-slot .sw-yt-form-wrapper {
    margin-bottom: 8px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    padding: 12px;
    border-radius: 10px;
}

/* ==========================================================================
   Nested Child Replies (Depth 2)
   ========================================================================== */
#comments .sw-yt-replies-wrap {
    margin-left: 54px;
    margin-top: 6px;
    max-width: calc(100% - 54px);
    box-sizing: border-box;
}

#comments .sw-yt-toggle-replies {
    background: transparent;
    border: none;
    color: #0073aa;
    font-size: 0.85rem;
    font-weight: 700;
    border-radius: 18px;
    padding: 6px 12px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: background-color 0.15s ease, color 0.15s ease;
    user-select: none;
    margin-bottom: 6px;
}

#comments .sw-yt-toggle-replies:hover {
    background-color: #eff6ff;
}

#comments .sw-yt-chevron {
    transition: transform 0.2s ease;
}

#comments .sw-yt-toggle-replies[aria-expanded="true"] .sw-yt-chevron {
    transform: rotate(180deg);
}

#comments .sw-yt-replies-list {
    display: flex;
    flex-direction: column;
    gap: 14px;
    margin-top: 10px;
    padding-left: 16px;
    border-left: 2px solid #cbd5e1;
    position: relative;
}

#comments .sw-yt-comment-item.depth-2 {
    margin-bottom: 6px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-left: 3px solid #2563eb;
    border-radius: 10px;
    padding: 12px 14px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
    position: relative;
}

#comments .sw-yt-comment-item.depth-2::before {
    content: "";
    position: absolute;
    top: 20px;
    left: -19px;
    width: 16px;
    height: 2px;
    background: #cbd5e1;
}

#comments .sw-yt-reply-context {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: #eff6ff;
    border: 1px solid #dbeafe;
    border-radius: 14px;
    padding: 2px 10px;
    margin-bottom: 8px;
    font-size: 0.8rem;
    color: #1e40af;
    line-height: 1.2;
}

#comments .sw-yt-reply-context-icon {
    color: #2563eb;
    stroke-width: 2.5;
}

#comments .sw-yt-reply-context-author {
    font-weight: 700;
    color: #1d4ed8;
}

#comments .sw-yt-comment-item.depth-2 .sw-yt-comment-body {
    gap: 12px;
}

#comments .sw-yt-comment-item.depth-2 .sw-yt-author-name {
    font-size: 0.88rem;
    font-weight: 700;
}

#comments .sw-yt-comment-item.depth-2 .sw-yt-text {
    font-size: 0.9rem;
    color: #334155;
}

#comments .sw-yt-btn-like.is-liked {
    color: #2563eb !important;
    background: #eff6ff !important;
}

#comments .sw-yt-btn-like.is-liked .sw-yt-icon-like {
    fill: #2563eb !important;
    stroke: #2563eb !important;
}

/* ==========================================================================
   Empty & Closed States
   ========================================================================== */
#comments .sw-yt-empty-state {
    text-align: center;
    padding: 30px 20px;
    color: #888888;
    background: #fbfbfb;
    border: 1px dashed #dddddd;
    border-radius: 8px;
    margin-top: 12px;
}

#comments .sw-yt-empty-icon {
    color: #aaaaaa;
    margin-bottom: 8px;
}

#comments .sw-yt-empty-lead {
    font-size: 1rem;
    font-weight: 700;
    color: inherit;
    margin: 0 0 4px;
}

#comments .sw-yt-empty-sub {
    font-size: 0.85rem;
    margin: 0;
}

#comments .sw-yt-comments-closed {
    text-align: center;
    padding: 15px;
    color: #888;
    font-style: italic;
    background: #fbfbfb;
    border-radius: 4px;
    margin-bottom: 24px;
}

/* ==========================================================================
   Mobile Responsive Adjustments
   ========================================================================== */
@media (max-width: 640px) {
    #comments .sw-yt-form-wrapper {
        gap: 10px;
    }

    #comments .sw-yt-input-row {
        grid-template-columns: 1fr;
    }

    #comments .sw-yt-replies-wrap {
        margin-left: 20px;
        max-width: calc(100% - 20px);
    }

    #comments .sw-yt-avatar {
        width: 32px !important;
        height: 32px !important;
    }

    #comments .sw-yt-avatar-initial {
        font-size: 0.8rem;
    }
}