/**
 * SmartComments WP — Frontend Stylesheet
 * Dùng CSS Variables để bám theo màu theme WordPress.
 */

/* ── CSS Variables & Reset ──────────────────────────────────────────────── */
.sc-section {
    --sc-radius:      10px;
    --sc-radius-sm:   6px;
    --sc-avatar-size: 40px;
    --sc-gap:         16px;
    --sc-transition:  0.2s ease;

    font-family: inherit;
    color: inherit;
    max-width: 800px;
    margin: 2rem auto;
    padding: 0 1rem;
}

/* ── Header ─────────────────────────────────────────────────────────────── */
.sc-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 2px solid var(--wp--preset--color--light-grey, #e5e7eb);
}

.sc-title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1.25rem;
    font-weight: 700;
    margin: 0;
    color: inherit;
}

.sc-icon {
    width: 22px;
    height: 22px;
    opacity: 0.7;
}

/* ── Form Wrapper ────────────────────────────────────────────────────────── */
.sc-form-wrap {
    display: flex;
    gap: var(--sc-gap);
    margin-bottom: 2rem;
}

.sc-form {
    flex: 1;
    min-width: 0;
}

/* ── Avatar ──────────────────────────────────────────────────────────────── */
.sc-avatar-wrap {
    flex-shrink: 0;
}

.sc-avatar {
    width: var(--sc-avatar-size);
    height: var(--sc-avatar-size);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1rem;
    color: #fff;
    overflow: hidden;
    position: relative;
    background-image: var(--sc-gravatar-url);
    background-size: cover;
    background-position: center;
    user-select: none;
    flex-shrink: 0;
}

.sc-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    position: absolute;
    inset: 0;
    border-radius: 50%;
}

/* ── Guest Fields ────────────────────────────────────────────────────────── */
.sc-field-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
}

@media (max-width: 480px) {
    .sc-field-row { grid-template-columns: 1fr; }
}

.sc-field-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.sc-label {
    font-size: 0.78rem;
    font-weight: 600;
    color: #6b7280;
    letter-spacing: 0.01em;
}

.sc-input {
    padding: 0.55rem 0.75rem;
    border: 1.5px solid #d1d5db;
    border-radius: var(--sc-radius-sm);
    font-size: 0.9rem;
    font-family: inherit;
    background: #fff;
    color: inherit;
    transition: border-color var(--sc-transition), box-shadow var(--sc-transition);
    outline: none;
    width: 100%;
    box-sizing: border-box;
}

.sc-input:focus {
    border-color: #6366f1;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

/* ── Textarea ────────────────────────────────────────────────────────────── */
.sc-textarea-group {
    position: relative;
}

.sc-textarea {
    width: 100%;
    padding: 0.75rem;
    border: 1.5px solid #d1d5db;
    border-radius: var(--sc-radius);
    font-size: 0.9rem;
    font-family: inherit;
    resize: vertical;
    min-height: 100px;
    background: #fff;
    color: inherit;
    transition: border-color var(--sc-transition), box-shadow var(--sc-transition);
    outline: none;
    box-sizing: border-box;
    line-height: 1.6;
}

.sc-textarea:focus {
    border-color: #6366f1;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

.sc-textarea-footer {
    display: flex;
    justify-content: flex-end;
    padding: 4px 2px 0;
}

.sc-char-count {
    font-size: 0.72rem;
    color: #9ca3af;
}

.sc-char-count.sc-char-warning { color: #f59e0b; }
.sc-char-count.sc-char-danger  { color: #ef4444; }

/* ── Form Footer ─────────────────────────────────────────────────────────── */
.sc-form-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 0.75rem;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.sc-security-badge {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 0.72rem;
    color: #9ca3af;
}

.sc-security-badge svg {
    width: 13px;
    height: 13px;
    stroke: #10b981;
}

.sc-submit-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 0.55rem 1.1rem;
    background: #6366f1;
    color: #fff;
    border: none;
    border-radius: var(--sc-radius-sm);
    font-size: 0.88rem;
    font-weight: 600;
    cursor: pointer;
    transition: background var(--sc-transition), opacity var(--sc-transition), transform var(--sc-transition);
    font-family: inherit;
}

.sc-submit-btn:hover:not(:disabled) {
    background: #4f46e5;
    transform: translateY(-1px);
}

.sc-submit-btn:disabled {
    opacity: 0.55;
    cursor: not-allowed;
    transform: none;
}

.sc-submit-btn svg {
    width: 14px;
    height: 14px;
}

.sc-logged-in-as {
    font-size: 0.82rem;
    color: #6b7280;
    margin: 0 0 0.5rem;
}

/* ── Form Messages ───────────────────────────────────────────────────────── */
.sc-form-message {
    margin-top: 0.5rem;
    padding: 0.5rem 0.75rem;
    border-radius: var(--sc-radius-sm);
    font-size: 0.85rem;
    display: none;
}

.sc-form-message.sc-error {
    display: block;
    background: #fef2f2;
    color: #dc2626;
    border: 1px solid #fecaca;
}

.sc-form-message.sc-success {
    display: block;
    background: #f0fdf4;
    color: #16a34a;
    border: 1px solid #bbf7d0;
}

/* ── Reply Form (inline) ─────────────────────────────────────────────────── */
.sc-reply-form-wrap {
    margin-top: 0.75rem;
}

.sc-reply-header {
    font-size: 0.8rem;
    color: #6b7280;
    margin-bottom: 0.5rem;
}

.sc-reply-header strong { color: #6366f1; }

.sc-reply-cancel {
    background: none;
    border: none;
    color: #9ca3af;
    cursor: pointer;
    font-size: 0.8rem;
    padding: 0;
    margin-left: 0.5rem;
    font-family: inherit;
}

.sc-reply-cancel:hover { color: #ef4444; }

/* ── Comment List ────────────────────────────────────────────────────────── */
.sc-comment-list {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

/* ── Single Comment ──────────────────────────────────────────────────────── */
.sc-comment {
    display: flex;
    gap: var(--sc-gap);
    animation: sc-fade-in 0.3s ease;
}

@keyframes sc-fade-in {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
}

.sc-comment-body {
    flex: 1;
    min-width: 0;
    background: #ffffff !important;
    border: 1px solid #e2e8f0 !important;
    border-radius: var(--sc-radius);
    padding: 1rem 1.15rem;
    position: relative;
    box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.05);
}

/* Arrow pointing to avatar */
.sc-comment-body::before {
    content: '';
    position: absolute;
    left: -7px;
    top: 14px;
    width: 12px;
    height: 12px;
    background: #ffffff !important;
    border-left: 1px solid #e2e8f0 !important;
    border-bottom: 1px solid #e2e8f0 !important;
    transform: rotate(45deg);
}

/* ── Meta (author, badge, time) ──────────────────────────────────────────── */
.sc-meta {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.sc-author {
    font-weight: 700;
    font-size: 0.95rem;
    color: #0f172a !important;
}

.sc-badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.02em;
}

.sc-badge--author {
    background: #ede9fe;
    color: #6d28d9;
}

.sc-time {
    font-size: 0.8rem;
    color: #64748b !important;
    margin-left: auto;
}

/* ── Comment Content ─────────────────────────────────────────────────────── */
.sc-content,
.sc-content * {
    color: #1e293b !important;
}

.sc-content {
    font-size: 0.95rem;
    line-height: 1.7;
    word-break: break-word;
}

.sc-content p {
    color: #1e293b !important;
    margin: 0 0 0.5rem;
}

.sc-content p:last-child { margin-bottom: 0; }

.sc-pending-notice {
    font-size: 0.8rem;
    color: #92400e;
    background: #fef3c7;
    border-radius: var(--sc-radius-sm);
    padding: 6px 10px;
    margin: 0.5rem 0 0;
    border: 1px solid #fde68a;
}


/* ── Actions (Like, Reply) ───────────────────────────────────────────────── */
.sc-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-top: 0.65rem;
    padding-top: 0.65rem;
    border-top: 1px solid #e5e7eb;
}

.sc-like-btn,
.sc-reply-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 0.8rem;
    font-family: inherit;
    color: #9ca3af;
    padding: 3px 6px;
    border-radius: var(--sc-radius-sm);
    transition: color var(--sc-transition), background var(--sc-transition);
}

.sc-like-btn:hover,
.sc-reply-btn:hover {
    color: #6366f1;
    background: #ede9fe;
}

.sc-like-btn svg,
.sc-reply-btn svg {
    width: 14px;
    height: 14px;
}

.sc-like-btn.sc-liked {
    color: #ef4444;
}

.sc-like-btn.sc-liked svg {
    fill: #ef4444;
    stroke: #ef4444;
}

.sc-like-btn.sc-anim {
    animation: sc-pop 0.3s ease;
}

@keyframes sc-pop {
    0%   { transform: scale(1); }
    50%  { transform: scale(1.35); }
    100% { transform: scale(1); }
}

.sc-reply-count { color: #9ca3af; }

/* ── Replies (cấp 2) ─────────────────────────────────────────────────────── */
.sc-replies {
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
    margin-top: 0.85rem;
    padding-top: 0.85rem;
    border-top: 1px dashed #e5e7eb;
}

/* Reply comments dùng avatar nhỏ hơn */
.sc-replies .sc-comment { gap: 10px; }
.sc-replies .sc-avatar { width: 30px; height: 30px; font-size: 0.75rem; }
.sc-replies .sc-comment-body { padding: 0.7rem 0.85rem; }

/* ── Empty State ─────────────────────────────────────────────────────────── */
.sc-empty {
    text-align: center;
    padding: 2.5rem 1rem;
    color: #9ca3af;
}

.sc-empty svg {
    width: 48px;
    height: 48px;
    margin: 0 auto 0.75rem;
    display: block;
    opacity: 0.4;
}

.sc-empty p {
    font-size: 0.9rem;
    margin: 0;
}

/* ── Load More Button ────────────────────────────────────────────────────── */
.sc-load-more-wrap {
    text-align: center;
    margin-top: 1.5rem;
}

.sc-load-more-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 0.6rem 1.4rem;
    border: 1.5px solid #d1d5db;
    border-radius: 999px;
    background: #fff;
    color: #374151;
    font-size: 0.875rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: all var(--sc-transition);
}

.sc-load-more-btn:hover:not(:disabled) {
    border-color: #6366f1;
    color: #6366f1;
    background: #ede9fe;
}

.sc-load-more-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.sc-no-more {
    text-align: center;
    font-size: 0.8rem;
    color: #9ca3af;
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid #e5e7eb;
}

/* ── Skeleton Loader ─────────────────────────────────────────────────────── */
.sc-skeleton-avatar {
    background: linear-gradient(90deg, #e5e7eb 25%, #f3f4f6 50%, #e5e7eb 75%);
    background-size: 200% 100%;
    animation: sc-shimmer 1.4s infinite;
}

.sc-skeleton-line {
    height: 12px;
    border-radius: 6px;
    margin-bottom: 8px;
    background: linear-gradient(90deg, #e5e7eb 25%, #f3f4f6 50%, #e5e7eb 75%);
    background-size: 200% 100%;
    animation: sc-shimmer 1.4s infinite;
}

.sc-skeleton-item .sc-comment-body {
    background: #f9fafb;
}

@keyframes sc-shimmer {
    0%   { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* ── Sentinel ────────────────────────────────────────────────────────────── */
#sc-sentinel {
    height: 1px;
    visibility: hidden;
}

/* ── Reply Logged In Info ────────────────────────────────────────────────── */
.sc-reply-logged-in {
    font-size: 0.82rem;
    color: #475569;
    margin-bottom: 0.65rem;
    padding: 4px 10px;
    background: #f1f5f9;
    border-radius: var(--sc-radius-sm);
    display: inline-block;
    border: 1px solid #e2e8f0;
}

.sc-reply-logged-in strong {
    color: #4f46e5;
}

/* ── Guest Info Popup Modal ──────────────────────────────────────────────── */
.sc-modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.65);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 999999;
    padding: 1rem;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.25s ease, visibility 0.25s ease;
}

.sc-modal-backdrop.sc-modal--active {
    opacity: 1;
    visibility: visible;
}

.sc-modal-card {
    background: #ffffff;
    width: 100%;
    max-width: 440px;
    border-radius: 16px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25), 0 0 0 1px rgba(0, 0, 0, 0.05);
    overflow: hidden;
    animation: sc-modal-slide 0.25s ease;
}

@keyframes sc-modal-slide {
    from { transform: scale(0.94) translateY(10px); opacity: 0; }
    to   { transform: scale(1) translateY(0); opacity: 1; }
}

.sc-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    background: #f8fafc;
    border-bottom: 1px solid #e2e8f0;
}

.sc-modal-title {
    font-size: 1.05rem;
    font-weight: 700;
    color: #0f172a;
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0;
}

.sc-modal-close {
    background: none;
    border: none;
    font-size: 1.25rem;
    line-height: 1;
    color: #94a3b8;
    cursor: pointer;
    padding: 4px;
    border-radius: 6px;
    transition: color 0.15s, background 0.15s;
}

.sc-modal-close:hover {
    color: #ef4444;
    background: #fee2e2;
}

.sc-modal-body {
    padding: 20px;
}

.sc-modal-desc {
    font-size: 0.85rem;
    color: #475569;
    margin: 0 0 16px;
    line-height: 1.5;
}

.sc-modal-group {
    margin-bottom: 14px;
}

.sc-modal-group:last-child {
    margin-bottom: 0;
}

.sc-modal-label {
    display: block;
    font-size: 0.82rem;
    font-weight: 600;
    color: #334155;
    margin-bottom: 5px;
}

.sc-modal-input {
    width: 100%;
    padding: 9px 12px;
    border: 1.5px solid #cbd5e1;
    border-radius: 8px;
    font-size: 0.92rem;
    font-family: inherit;
    box-sizing: border-box;
    transition: border-color 0.2s, box-shadow 0.2s;
    outline: none;
    background: #ffffff;
    color: #0f172a;
}

.sc-modal-input:focus {
    border-color: #6366f1;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.18);
}

.sc-modal-remember {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 14px;
    font-size: 0.8rem;
    color: #64748b;
    cursor: pointer;
}

.sc-modal-remember input[type="checkbox"] {
    accent-color: #6366f1;
    cursor: pointer;
}

.sc-modal-error {
    font-size: 0.8rem;
    color: #dc2626;
    background: #fef2f2;
    border: 1px solid #fecaca;
    padding: 6px 10px;
    border-radius: 6px;
    margin-bottom: 12px;
    display: none;
}

.sc-modal-footer {
    padding: 12px 20px 16px;
    background: #f8fafc;
    border-top: 1px solid #e2e8f0;
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

.sc-modal-btn-cancel {
    padding: 8px 16px;
    background: #ffffff;
    border: 1.5px solid #cbd5e1;
    border-radius: 8px;
    font-size: 0.88rem;
    font-weight: 600;
    color: #475569;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
}

.sc-modal-btn-cancel:hover {
    background: #f1f5f9;
    color: #0f172a;
}

.sc-modal-btn-submit {
    padding: 8px 18px;
    background: #6366f1;
    border: none;
    border-radius: 8px;
    font-size: 0.88rem;
    font-weight: 600;
    color: #ffffff;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-family: inherit;
}

.sc-modal-btn-submit:hover {
    background: #4f46e5;
    transform: translateY(-1px);
    box-shadow: 0 4px 6px -1px rgba(99, 102, 241, 0.25);
}


/* ── Fullscreen / Form Loading Overlay ────────────────────────────────────── */
.sc-form-wrap {
    position: relative;
}

.sc-overlay {
    position: absolute;
    inset: -10px;
    background: rgba(255, 255, 255, 0.82);
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    border-radius: calc(var(--sc-radius) + 4px);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.25s ease, visibility 0.25s ease;
    cursor: wait;
    user-select: none;
}

.sc-overlay.sc-overlay--visible {
    opacity: 1;
    visibility: visible;
}

.sc-overlay-inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    background: #ffffff;
    padding: 18px 24px;
    border-radius: var(--sc-radius);
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
    border: 1px solid #e5e7eb;
    text-align: center;
    max-width: 90%;
    animation: sc-scale-up 0.25s ease;
}

@keyframes sc-scale-up {
    from { transform: scale(0.92); opacity: 0; }
    to   { transform: scale(1); opacity: 1; }
}

.sc-spinner {
    width: 32px;
    height: 32px;
    border: 3px solid #e0e7ff;
    border-top-color: #6366f1;
    border-radius: 50%;
    animation: sc-spin 0.8s linear infinite;
}

@keyframes sc-spin {
    to { transform: rotate(360deg); }
}

.sc-overlay-text {
    font-size: 0.88rem;
    font-weight: 600;
    color: #374151;
    letter-spacing: 0.01em;
}

.sc-overlay-subtext {
    font-size: 0.75rem;
    color: #9ca3af;
}

/* Button loading state */
.sc-submit-btn.sc-btn--loading {
    position: relative;
    pointer-events: none;
    opacity: 0.85;
}

.sc-btn-spinner {
    display: inline-block;
    width: 14px;
    height: 14px;
    border: 2px solid rgba(255, 255, 255, 0.4);
    border-top-color: #ffffff;
    border-radius: 50%;
    animation: sc-spin 0.7s linear infinite;
    vertical-align: middle;
}

/* Dark mode for overlay */
@media (prefers-color-scheme: dark) {
    .sc-overlay {
        background: rgba(17, 24, 39, 0.85);
    }
    .sc-overlay-inner {
        background: #1f2937;
        border-color: #374151;
        box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.5);
    }
    .sc-overlay-text {
        color: #f3f4f6;
    }
    .sc-overlay-subtext {
        color: #9ca3af;
    }
    .sc-spinner {
        border-color: #374151;
        border-top-color: #818cf8;
    }
}

