/**
 * Ethnic_AiAssistant - Frontend Styles
 */

/* ============================================================
   Wrapper & Toggle Bar
   ============================================================ */
.ethnic-aiassistant-wrapper {
    margin-bottom: 20px;
    font-family: inherit;
}

.ethnic-ai-toggle-bar {
    display: flex;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    overflow: hidden;
    margin-bottom: 12px;
}

.ethnic-ai-tab-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 14px;
    background: #f5f5f5;
    border: none;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    color: #555;
    transition: background 0.2s, color 0.2s;
}

.ethnic-ai-tab-btn:first-child {
    border-right: 1px solid #e0e0e0;
}

.ethnic-ai-tab-btn.active {
    background: #1a1a2e;
    color: #fff;
}

.ethnic-ai-tab-btn .ai-icon {
    font-size: 14px;
    color: #f0c040;
}

.ethnic-ai-tab-btn.active .ai-icon {
    color: #f0c040;
}

/* ============================================================
   AI Panel
   ============================================================ */
.ethnic-ai-panel {
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    overflow: hidden;
    background: #fff;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}

/* ============================================================
   Chat History
   ============================================================ */
.ethnic-ai-chat-history {
    padding: 14px;
    max-height: 320px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 10px;
    background: #fafafa;
    scroll-behavior: smooth;
}

.ethnic-ai-chat-history::-webkit-scrollbar {
    width: 4px;
}
.ethnic-ai-chat-history::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 4px;
}

.ethnic-ai-message {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    animation: ethnic-msg-in 0.2s ease;
}

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

.msg-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: #1a1a2e;
    color: #f0c040;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    flex-shrink: 0;
    margin-top: 2px;
}

.user-message .msg-avatar {
    background: #e8f0fe;
    color: #333;
    order: 2;
}

.user-message {
    flex-direction: row-reverse;
}

.msg-bubble {
    max-width: calc(100% - 40px);
    padding: 8px 12px;
    border-radius: 12px;
    font-size: 13px;
    line-height: 1.5;
    word-break: break-word;
}

.assistant-message .msg-bubble {
    background: #fff;
    border: 1px solid #e8e8e8;
    border-bottom-left-radius: 3px;
    color: #333;
}

.user-message .msg-bubble {
    background: #1a1a2e;
    color: #fff;
    border-bottom-right-radius: 3px;
}

.error-message .msg-bubble {
    background: #fff4f4;
    border-color: #ffcdd2;
    color: #c62828;
}

/* Typing indicator */
.typing-indicator .msg-bubble {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 10px 14px;
}

.typing-indicator .msg-bubble span {
    display: inline-block;
    width: 6px;
    height: 6px;
    background: #aaa;
    border-radius: 50%;
    animation: typing-bounce 1.2s infinite;
}

.typing-indicator .msg-bubble span:nth-child(2) { animation-delay: 0.2s; }
.typing-indicator .msg-bubble span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typing-bounce {
    0%, 60%, 100% { transform: translateY(0); }
    30%            { transform: translateY(-5px); }
}

/* ============================================================
   Applied Filter Pills
   ============================================================ */
.ethnic-ai-applied-filters {
    padding: 10px 14px;
    border-top: 1px solid #f0f0f0;
    background: #fff;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
}

.applied-filters-label {
    font-size: 11px;
    color: #888;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    width: 100%;
}

.ethnic-ai-pill {
    display: inline-flex;
    align-items: center;
    background: #f0f4ff;
    border: 1px solid #c5d3f5;
    border-radius: 20px;
    padding: 3px 10px;
    font-size: 12px;
    color: #3a56b0;
}

.ethnic-ai-clear-btn {
    margin-left: auto;
    background: none;
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 3px 10px;
    font-size: 12px;
    color: #888;
    cursor: pointer;
    transition: all 0.2s;
}

.ethnic-ai-clear-btn:hover {
    background: #f5f5f5;
    color: #333;
}

/* ============================================================
   Input Area
   ============================================================ */
.ethnic-ai-input-area {
    padding: 12px 14px;
    border-top: 1px solid #f0f0f0;
    background: #fff;
}

.ethnic-ai-input-row {
    display: flex;
    gap: 6px;
    align-items: center;
}

.ethnic-ai-input {
    flex: 1;
    padding: 9px 12px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 13px;
    outline: none;
    transition: border-color 0.2s;
    background: #f9f9f9;
    color: #333;
}

.ethnic-ai-input:focus {
    border-color: #1a1a2e;
    background: #fff;
}

.ethnic-ai-send-btn,
.ethnic-ai-voice-btn {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.2s;
    flex-shrink: 0;
}

.ethnic-ai-send-btn {
    background: #1a1a2e;
    color: #fff;
}

.ethnic-ai-send-btn:hover {
    background: #2e2e50;
}

.ethnic-ai-send-btn:disabled {
    background: #ccc;
    cursor: not-allowed;
}

.ethnic-ai-voice-btn {
    background: #f0f4ff;
    color: #3a56b0;
    border: 1px solid #c5d3f5;
}

.ethnic-ai-voice-btn:hover {
    background: #e0e9ff;
}

.ethnic-ai-voice-btn.listening {
    background: #ff5252;
    color: #fff;
    border-color: #ff5252;
    animation: pulse 1s infinite;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50%       { transform: scale(1.08); }
}

/* ============================================================
   Suggestion Chips
   ============================================================ */
.ethnic-ai-suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 8px;
}

.suggestion-chip {
    display: inline-block;
    background: #f5f5f5;
    border: 1px solid #e0e0e0;
    border-radius: 20px;
    padding: 3px 10px;
    font-size: 11px;
    color: #555;
    cursor: pointer;
    transition: all 0.2s;
}

.suggestion-chip:hover {
    background: #1a1a2e;
    border-color: #1a1a2e;
    color: #fff;
}

/* ============================================================
   AI Product Grid
   ============================================================ */
.ethnic-ai-product-grid {
    margin-top: 0;
}

/* ============================================================
   Toolbar
   ============================================================ */
.ethnic-ai-toolbar {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
    padding: 12px 0;
    border-bottom: 1px solid #eee;
    margin-bottom: 16px;
}

.ethnic-ai-toolbar-info {
    font-size: 13px;
    color: #666;
    flex: 1;
}

.ethnic-ai-toolbar-sort,
.ethnic-ai-toolbar-limit {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: #555;
}

.ethnic-ai-select {
    padding: 5px 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 13px;
    background: #fff;
    cursor: pointer;
}

/* ============================================================
   Product Items
   ============================================================ */
.ai-products-grid .product-items {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
    gap: 16px;
    list-style: none;
    margin: 0;
    padding: 0;
}

.ethnic-ai-product-item .product-item-info {
    border: 1px solid #eee;
    border-radius: 8px;
    overflow: hidden;
    transition: box-shadow 0.2s, transform 0.2s;
    background: #fff;
}

.ethnic-ai-product-item .product-item-info:hover {
    box-shadow: 0 4px 16px rgba(0,0,0,0.1);
    transform: translateY(-2px);
}

.ethnic-ai-product-item .product-item-photo {
    display: block;
    overflow: hidden;
    background: #f8f8f8;
}

.ethnic-ai-product-item .product-item-photo img {
    width: 100%;
    aspect-ratio: 1 / 1;
    object-fit: cover;
    transition: transform 0.3s;
}

.ethnic-ai-product-item .product-item-photo:hover img {
    transform: scale(1.04);
}

.ethnic-ai-product-item .product-item-details {
    padding: 10px 10px 12px;
}

.ethnic-ai-product-item .product-item-name {
    font-size: 13px;
    font-weight: 500;
    margin-bottom: 6px;
    line-height: 1.4;
}

.ethnic-ai-product-item .product-item-name a {
    color: #333;
    text-decoration: none;
}

.ethnic-ai-product-item .product-item-name a:hover {
    color: #1a1a2e;
}

.price-box {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.ethnic-ai-price {
    font-size: 14px;
    font-weight: 700;
    color: #1a1a2e;
}

.ethnic-ai-price-old {
    font-size: 12px;
    color: #aaa;
    text-decoration: line-through;
}

/* ============================================================
   Loading Spinner
   ============================================================ */
.ethnic-ai-loading {
    text-align: center;
    padding: 40px 20px;
    color: #888;
    font-size: 14px;
}

.ethnic-ai-spinner {
    width: 36px;
    height: 36px;
    border: 3px solid #e0e0e0;
    border-top-color: #1a1a2e;
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
    margin: 0 auto 12px;
}

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

/* ============================================================
   No Results
   ============================================================ */
.ethnic-ai-no-results {
    text-align: center;
    padding: 40px 20px;
    color: #888;
    font-size: 14px;
}

/* ============================================================
   Pagination
   ============================================================ */
.ethnic-ai-pages {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 6px;
    padding: 20px 0;
}

.ethnic-ai-page-btn {
    min-width: 36px;
    height: 36px;
    padding: 0 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    background: #fff;
    color: #555;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
}

.ethnic-ai-page-btn:hover {
    border-color: #1a1a2e;
    color: #1a1a2e;
}

.ethnic-ai-page-btn.active {
    background: #1a1a2e;
    border-color: #1a1a2e;
    color: #fff;
    font-weight: 600;
}

/* ============================================================
   Filters Panel
   ============================================================ */
.ethnic-filters-panel .block-title {
    margin-bottom: 12px;
}

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 768px) {
    .ethnic-ai-chat-history {
        max-height: 220px;
    }

    .ai-products-grid .product-items {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }

    .ethnic-ai-toolbar {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }
}
