/**
 * ================================================================================
 * CO-READIT - AI Smart Replies CSS
 * ================================================================================
 * 
 * Inline smart reply chips styling - appears in comment input area
 * Modified from Komico modal to inline/collapsible design
 * 
 * @author      Edu Brazeal
 * @version     1.0.0
 * ================================================================================
 */

/* ===== Smart Replies Container ===== */
.ai-smart-replies {
    display: none;
    flex-wrap: wrap;
    gap: 8px;
    padding: 12px 0;
    animation: fadeInSlide 0.3s ease-out;
}

.ai-smart-replies.show {
    display: flex;
}

@keyframes fadeInSlide {
    from {
        opacity: 0;
        transform: translateY(-5px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ===== Header with Toggle ===== */
.ai-smart-replies__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    margin-bottom: 8px;
}

.ai-smart-replies__title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.ai-smart-replies__title-icon {
    width: 16px;
    height: 16px;
    color: var(--primary-color);
}

.ai-smart-replies__close {
    width: 24px;
    height: 24px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: all 0.2s ease;
    padding: 0;
}

.ai-smart-replies__close:hover {
    background: var(--hover-bg);
    color: var(--text-primary);
}

.ai-smart-replies__close svg {
    width: 14px;
    height: 14px;
}

/* ===== Chips Container ===== */
.ai-smart-replies__chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    width: 100%;
}

/* ===== Individual Chip ===== */
.ai-smart-reply-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    font-size: 13px;
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ai-smart-reply-chip:hover {
    background: var(--primary-color);
    border-color: var(--primary-color);
    color: #ffffff;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(59, 130, 246, 0.25);
}

.ai-smart-reply-chip:active {
    transform: translateY(0);
}

/* Chip icon */
.ai-smart-reply-chip__icon {
    width: 14px;
    height: 14px;
    flex-shrink: 0;
    opacity: 0.7;
}

.ai-smart-reply-chip:hover .ai-smart-reply-chip__icon {
    opacity: 1;
}

/* ===== Loading State ===== */
.ai-smart-replies--loading .ai-smart-replies__chips {
    display: flex;
    gap: 8px;
}

/* Skeleton chips for loading */
.ai-smart-reply-chip--skeleton {
    height: 36px;
    background: linear-gradient(
        90deg, 
        var(--bg-secondary) 25%, 
        var(--border-color) 50%, 
        var(--bg-secondary) 75%
    );
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border: 1px solid var(--border-color);
    border-radius: 20px;
    cursor: default;
}

.ai-smart-reply-chip--skeleton:nth-child(1) {
    width: 90px;
}

.ai-smart-reply-chip--skeleton:nth-child(2) {
    width: 120px;
}

.ai-smart-reply-chip--skeleton:nth-child(3) {
    width: 100px;
}

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

/* ===== Trigger Button (appears next to comment input) ===== */
.ai-smart-replies-trigger {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: transparent;
    border: 1px solid var(--border-color);
    border-radius: 16px;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s ease;
}

.ai-smart-replies-trigger:hover {
    background: var(--primary-color);
    border-color: var(--primary-color);
    color: #ffffff;
}

.ai-smart-replies-trigger:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.ai-smart-replies-trigger:disabled:hover {
    background: transparent;
    border-color: var(--border-color);
    color: var(--text-secondary);
}

.ai-smart-replies-trigger__icon {
    width: 14px;
    height: 14px;
}

.ai-smart-replies-trigger--loading .ai-smart-replies-trigger__icon {
    animation: spin 1s linear infinite;
}

@keyframes spin {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

/* ===== Error State ===== */
.ai-smart-replies--error {
    padding: 12px;
    text-align: center;
}

.ai-smart-replies__error {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    color: var(--error-color);
    font-size: 13px;
}

.ai-smart-replies__error-icon {
    width: 24px;
    height: 24px;
}

.ai-smart-replies__retry {
    padding: 6px 12px;
    background: var(--error-color);
    border: none;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 500;
    color: #ffffff;
    cursor: pointer;
    transition: all 0.2s ease;
    margin-top: 4px;
}

.ai-smart-replies__retry:hover {
    filter: brightness(1.1);
}

/* ===== Responsive Design ===== */
@media (max-width: 768px) {
    .ai-smart-reply-chip {
        padding: 6px 12px;
        font-size: 12px;
    }
    
    .ai-smart-replies__title {
        font-size: 11px;
    }
    
    .ai-smart-replies-trigger {
        padding: 5px 10px;
        font-size: 11px;
    }
    
    /* Mobile: Make suggestions take full width below buttons */
    .comment-form-actions,
    .comment-reply-actions {
        flex-wrap: wrap;
    }
    
    .comment-form-actions .ai-smart-replies,
    .comment-reply-actions .ai-smart-replies {
        order: 10; /* Push to end/bottom */
        width: 100%;
        flex-basis: 100%;
        margin-top: 12px;
        padding-top: 12px;
        border-top: 1px solid var(--border-color);
    }
}

/* ===== Dark Mode Support ===== */
[data-theme="dark"] .ai-smart-reply-chip {
    background: var(--bg-secondary);
    border-color: rgba(255, 255, 255, 0.1);
}

[data-theme="dark"] .ai-smart-reply-chip:hover {
    background: var(--primary-color);
    border-color: var(--primary-color);
}

[data-theme="dark"] .ai-smart-reply-chip--skeleton {
    background: linear-gradient(
        90deg, 
        rgba(255, 255, 255, 0.05) 25%, 
        rgba(255, 255, 255, 0.1) 50%, 
        rgba(255, 255, 255, 0.05) 75%
    );
    background-size: 200% 100%;
    border-color: rgba(255, 255, 255, 0.05);
}

[data-theme="dark"] .ai-smart-replies-trigger {
    border-color: rgba(255, 255, 255, 0.1);
}

[data-theme="dark"] .ai-smart-replies-trigger:hover {
    border-color: var(--primary-color);
}
