/**
 * Shared VideoHub360 Comment UI Styles
 *
 * Base comment form, action menu, reply, and responsive layout styles shared by
 * native WordPress comments and Activity Feed/community comment surfaces.
 *
 * @package Videohub360_Theme
 * @since 1.0.0
 */

/* Comment form at bottom of post */
.vh360-comment-form {
    display: flex;
    gap: 0.75rem;
    align-items: flex-start;
    margin-top: 1rem;
    padding: 12px 16px;
    border-top: 1px solid var(--border-1);
}

.vh360-comment-avatar {
    flex-shrink: 0;
}

.vh360-comment-avatar img {
    width: 32px;
    height: 32px;
    border-radius: 50%;
}

/* Main comment input wrapper (contains textarea + send button) */
.vh360-comment-input-wrapper {
    position: relative;
    flex: 1;
    display: flex;
    align-items: flex-start;
}

.vh360-comment-textarea {
    width: 100%;
    min-height: 40px;
    max-height: 150px;
    padding: 8px 50px 8px 12px; /* Right padding for send button */
    border: 1px solid var(--border-1);
    border-radius: 20px;
    font-family: inherit;
    font-size: 14px;
    line-height: 1.5;
    resize: none;
    overflow-y: auto;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    background: var(--surface-3);
}

.vh360-comment-textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(24, 119, 242, 0.1);
    background: var(--surface-1);
}

/* Comment send button - positioned inside textarea */
.vh360-comment-send-btn {
    position: absolute;
    right: 4px;
    top: 50%;
    transform: translateY(-50%);
    width: 32px;
    height: 32px;
    padding: 0;
    border: none;
    border-radius: 50%;
    background: var(--primary-color);
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s ease;
}

.vh360-comment-send-btn:hover:not(:disabled) {
    background: #166fe5;
}

.vh360-comment-send-btn:disabled {
    background: var(--border-1);
    cursor: not-allowed;
    opacity: 0.5;
}

.vh360-comment-send-btn.vh360-btn-active {
    background: var(--primary-color);
    opacity: 1;
}

.vh360-comment-send-btn.vh360-btn-loading .vh360-btn-text {
    display: none;
}

.vh360-comment-send-btn.vh360-btn-loading .vh360-btn-spinner {
    display: block !important;
}

.vh360-comment-send-icon {
    width: 16px;
    height: 16px;
    fill: currentColor;
}

/* Loading spinner in send button */
.vh360-btn-spinner {
    display: none;
    width: 16px;
    height: 16px;
    border: 2px solid #fff;
    border-top-color: transparent;
    border-radius: 50%;
    animation: vh360-spin 0.6s linear infinite;
}


/* Shared comment form mobile adjustments */
@media (max-width: 768px) {
    .vh360-comment-textarea {
        font-size: 16px; /* Prevent iOS zoom on focus */
        padding-right: 44px; /* Adjust for send button */
    }

    .vh360-comment-send-btn {
        width: 36px;
        height: 36px;
        right: 4px;
    }

    .vh360-comment-form {
        padding: 10px 12px;
    }
}

/* Remove old Post button styles */
.vh360-post-comment-btn,
.vh360-comment-submit {
    display: none !important;
}

/* ========================================
   VH360 Comments v2 - Mobile-First Grid Layout (PR #10)
   Facebook-Style Two-Column Structure
   ======================================== */

/* Comment Item Container */
.vh360-comment-item {
    margin-bottom: 12px;
}

/* Comment Row - Two Column Layout */
.vh360-comment-row {
    display: grid;
    grid-template-columns: 40px 1fr; /* Fixed avatar + flexible content */
    column-gap: 10px;
    align-items: start;
}

/* Left Column - Avatar */
.vh360-comment-avatar {
    width: 40px;
    height: 40px;
    flex-shrink: 0;
}

.vh360-comment-avatar img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
}

/* Right Column - Content */
.vh360-comment-main {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0; /* Allow flex shrinking */
    width: 100%;
}

/* Header Row (OUTSIDE bubble) - Name + Kebab */
.vh360-comment-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding-left: 12px; /* Align with bubble text */
    min-height: 20px;
}

/* Comment Bubble (text ONLY) */
.vh360-comment-bubble {
    background: var(--surface-3);
    border-radius: 16px;
    padding: 7px 14px;
    width: fit-content;
    max-width: 480px;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.vh360-comment-author {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-1, #050505);
    line-height: 1.2;
}

/* Kebab menu wrapper in comment header */
.vh360-comment-actions-menu-wrapper {
    position: relative;
    margin-left: auto;
    flex-shrink: 0;
}

.vh360-kebab-toggle {
    background: none;
    border: none;
    padding: 4px;
    cursor: pointer;
    color: var(--text-2, #65676b);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    transition: background-color 0.2s ease;
}

.vh360-kebab-toggle:hover {
    background-color: rgba(0, 0, 0, 0.05);
}

.vh360-kebab-dot {
    width: 3px;
    height: 3px;
    background-color: var(--text-2, #65676b);
    border-radius: 50%;
}

/* Actions menu dropdown */
.vh360-actions-menu {
    position: absolute;
    top: 100%;
    right: 0;
    background: var(--surface-1);
    border-radius: 8px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.15);
    min-width: 120px;
    z-index: 1000;
    margin-top: 4px;
    overflow: hidden;
    display: none;
}

.vh360-actions-menu.vh360-actions-menu--open {
    display: block;
}

.vh360-actions-menu-item {
    display: block;
    width: 100%;
    padding: 10px 16px;
    text-align: left;
    border: none;
    background: none;
    color: var(--text-1, #050505);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.vh360-actions-menu-item:hover {
    background-color: var(--surface-3);
}

.vh360-actions-menu-item.vh360-comment-delete-btn {
    color: var(--error-color);
}

.vh360-actions-menu-item.vh360-comment-delete-btn:hover {
    background-color: var(--error-bg-color, #fee);
}

/* Comment Text */
.vh360-comment-text {
    font-size: 15px;
    line-height: 1.3333;
    color: var(--text-1, #050505);
    word-break: break-word;
}

/* Actions Row (UNDER bubble) */
.vh360-comment-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    padding-left: 12px; /* Align with bubble content */
    font-size: 12px;
    color: var(--text-2, #65676b);
}

.vh360-comment-time {
    font-weight: 600;
    white-space: nowrap;
}

.vh360-action-separator {
    color: var(--border-1, #ccc);
    user-select: none;
}

.vh360-action-like,
.vh360-action-reply {
    background: none;
    border: none;
    padding: 0;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-2, #65676b);
    cursor: pointer;
    white-space: nowrap;
}

.vh360-action-like:hover,
.vh360-action-reply:hover {
    text-decoration: underline;
}

.vh360-action-like.vh360-liked {
    color: var(--primary-color);
}

.vh360-like-count {
    font-size: 11px;
    color: var(--text-2, #65676b);
}

/* Replies Container */
.vh360-comment-replies {
    margin-top: 8px;
    margin-left: 16px; /* Mobile indent - small */
    padding-left: 12px;
    border-left: 2px solid var(--border-1);
}

/* Toggle Replies Button */
.vh360-toggle-replies {
    background: none;
    border: none;
    padding: 4px 0;
    margin-bottom: 8px;
    margin-left: 50px; /* Align with comment text (40px avatar + 10px gap) */
    font-size: 13px;
    font-weight: 600;
    color: var(--text-2, #65676b);
    cursor: pointer;
}

.vh360-toggle-replies:hover {
    text-decoration: underline;
}

/* Reply Items */
.vh360-comment-reply .vh360-comment-avatar {
    width: 32px; /* Slightly smaller for replies */
    height: 32px;
}

.vh360-comment-reply .vh360-comment-row {
    grid-template-columns: 32px 1fr;
}

/* Desktop Adjustments */
@media (min-width: 769px) {
    .vh360-comment-row {
        grid-template-columns: 48px 1fr; /* Larger avatar on desktop */
        column-gap: 12px;
    }
    
    .vh360-comment-avatar {
        width: 48px;
        height: 48px;
    }
    
    .vh360-comment-bubble {
        max-width: 480px; /* Constrain bubble width on desktop */
    }
    
    .vh360-comment-replies {
        margin-left: 24px; /* Larger indent on desktop */
        padding-left: 16px;
    }
    
    .vh360-toggle-replies {
        margin-left: 60px; /* Adjust for larger avatar */
    }
    
    .vh360-comment-reply .vh360-comment-avatar {
        width: 40px;
        height: 40px;
    }
    
    .vh360-comment-reply .vh360-comment-row {
        grid-template-columns: 40px 1fr;
    }
}

/* Mobile Optimizations */
@media (max-width: 480px) {
    .vh360-comment-row {
        column-gap: 8px;
    }
    
    .vh360-comment-bubble {
        padding: 8px 16px;
        border-radius: 16px;
    }
    
    .vh360-comment-header {
        padding-left: 8px;
    }
    
    .vh360-comment-actions {
        padding-left: 8px;
        gap: 6px;
        font-size: 12px;
    }
    
    .vh360-comment-replies {
        margin-left: 12px; /* Reduced on very small screens */
        padding-left: 8px;
    }
}

/* Ensure no horizontal scroll */
.vh360-comment-item,
.vh360-comment-row,
.vh360-comment-main,
.vh360-comment-bubble {
    max-width: 100%;
    overflow: hidden;
}

/* Override Legacy Styles */
.vh360-comment {
    padding-left: 0 !important;
    position: static !important;
}

.vh360-comment-avatar {
    position: static !important;
}

.vh360-comment-actions {
    position: static !important;
    margin-left: 0 !important;
}

/* Hidden state classes */
.vh360-actions-menu--hidden {
    display: none;
}

.vh360-replies-list--hidden {
    display: none;
}
