/**
 * MH Shop Guide — Front-end Stylesheet
 */

/* ============================================
   CSS Custom Properties
   ============================================ */
:root {
    --mhsg-primary: #2563EB;
    --mhsg-secondary: #F59E0B;
    --mhsg-text: #1F2937;
    --mhsg-bg: #FFFFFF;
    --mhsg-border: #E5E7EB;
    --mhsg-radius: 12px;
    --mhsg-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --mhsg-shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

/* ============================================
   Search Bar
   ============================================ */
.mhsg-search-wrapper {
    position: relative;
    width: 100%;
    max-width: 600px;
    margin: 0 auto;
    z-index: 9999;
}

.mhsg-search-input-group {
    position: relative;
    display: flex;
    align-items: center;
}

.mhsg-search-icon {
    position: absolute;
    left: 12px;
    color: #9CA3AF;
    pointer-events: none;
}

.mhsg-search-input {
    width: 100%;
    padding: 10px 40px 10px 40px;
    border: 2px solid var(--mhsg-border);
    border-radius: var(--mhsg-radius);
    font-size: 15px;
    color: var(--mhsg-text);
    background: var(--mhsg-bg);
    transition: border-color 0.2s, box-shadow 0.2s;
    outline: none;
}

.mhsg-search-input:focus {
    border-color: var(--mhsg-primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.mhsg-search-clear {
    position: absolute;
    right: 8px;
    background: none;
    border: none;
    cursor: pointer;
    color: #9CA3AF;
    padding: 4px;
}

.mhsg-search-clear:hover {
    color: var(--mhsg-text);
}

/* ============================================
   Search Dropdown
   ============================================ */
.mhsg-search-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--mhsg-bg);
    border: 1px solid var(--mhsg-border);
    border-radius: var(--mhsg-radius);
    box-shadow: var(--mhsg-shadow-lg);
    z-index: 10000;
    margin-top: 4px;
    max-height: 80vh;
    overflow-y: auto;
}

/* ============================================
   Search Results — Product Items
   ============================================ */
.mhsg-product-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    text-decoration: none;
    color: var(--mhsg-text);
    border-bottom: 1px solid #f3f4f6;
    transition: background 0.12s;
}

.mhsg-product-item:last-child {
    border-bottom: none;
}

.mhsg-product-item:hover {
    background: #f8fafc;
    text-decoration: none;
    color: var(--mhsg-text);
}

.mhsg-product-img {
    flex-shrink: 0;
    width: 56px;
    height: 56px;
    border-radius: 8px;
    overflow: hidden;
    background: #f9fafb;
    display: flex;
    align-items: center;
    justify-content: center;
}

.mhsg-product-img img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.mhsg-product-noimg {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    background: #f3f4f6;
}

.mhsg-product-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.mhsg-product-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--mhsg-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.mhsg-product-brand {
    font-size: 12px;
    color: #9ca3af;
}

.mhsg-product-prices {
    display: flex;
    align-items: center;
    gap: 6px;
}

.mhsg-product-price {
    font-size: 14px;
    font-weight: 700;
    color: var(--mhsg-primary);
}

.mhsg-product-price-old {
    font-size: 12px;
    color: #9ca3af;
    text-decoration: line-through;
}

/* Loading & empty states */
.mhsg-search-loading,
.mhsg-search-empty {
    padding: 20px;
    text-align: center;
    color: #9ca3af;
    font-size: 14px;
}

/* See all results link */
.mhsg-search-all {
    display: block;
    padding: 12px;
    text-align: center;
    font-size: 13px;
    font-weight: 600;
    color: var(--mhsg-primary);
    text-decoration: none;
    border-top: 1px solid #f3f4f6;
    transition: background 0.12s;
}

.mhsg-search-all:hover {
    background: #eff6ff;
    text-decoration: none;
    color: var(--mhsg-primary);
}

/* ============================================
   Chat FAB (Floating Action Button)
   ============================================ */
.mhsg-chat-fab {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--mhsg-primary);
    color: white;
    border: none;
    cursor: pointer;
    box-shadow: var(--mhsg-shadow-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9998;
    transition: transform 0.2s, box-shadow 0.2s;
}

.mhsg-chat-fab:hover {
    transform: scale(1.05);
    box-shadow: 0 12px 20px -5px rgba(0, 0, 0, 0.2);
}

.mhsg-fab-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    background: var(--mhsg-secondary);
    color: white;
    font-size: 11px;
    font-weight: 700;
    min-width: 20px;
    height: 20px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
}

/* ============================================
   Chat Panel
   ============================================ */
.mhsg-chat-panel {
    position: fixed;
    bottom: 96px;
    right: 24px;
    width: 400px;
    max-height: 80vh;
    min-height: 400px;
    background: var(--mhsg-bg);
    border-radius: var(--mhsg-radius);
    box-shadow: var(--mhsg-shadow-lg);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.mhsg-chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    border-bottom: 1px solid var(--mhsg-border);
    background: var(--mhsg-primary);
    color: white;
}

.mhsg-chat-title {
    font-weight: 600;
    font-size: 15px;
}

.mhsg-chat-header-actions {
    display: flex;
    gap: 4px;
}

.mhsg-chat-btn {
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.8);
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
}

.mhsg-chat-btn:hover {
    color: white;
    background: rgba(255, 255, 255, 0.1);
}

.mhsg-chat-handle {
    display: none;
}

/* ============================================
   Chat Messages
   ============================================ */
.mhsg-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.mhsg-chat-msg {
    display: flex;
    max-width: 85%;
}

.mhsg-chat-msg-user {
    align-self: flex-end;
}

.mhsg-chat-msg-bot {
    align-self: flex-start;
}

.mhsg-chat-msg-content {
    padding: 10px 14px;
    border-radius: 16px;
    font-size: 14px;
    line-height: 1.5;
    word-break: break-word;
}

.mhsg-chat-msg-user .mhsg-chat-msg-content {
    background: var(--mhsg-primary);
    color: white;
    border-bottom-right-radius: 4px;
}

.mhsg-chat-msg-bot .mhsg-chat-msg-content {
    background: #f3f4f6;
    color: var(--mhsg-text);
    border-bottom-left-radius: 4px;
}

/* Typing indicator */
.mhsg-chat-typing {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 12px 18px;
}

.mhsg-chat-typing span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #9ca3af;
    animation: mhsg-typing 1.2s infinite ease-in-out;
}

.mhsg-chat-typing span:nth-child(2) {
    animation-delay: 0.15s;
}

.mhsg-chat-typing span:nth-child(3) {
    animation-delay: 0.3s;
}

@keyframes mhsg-typing {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
    30% { transform: translateY(-6px); opacity: 1; }
}

/* ============================================
   Chat Product Cards
   ============================================ */
.mhsg-chat-products {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 4px 0;
    max-width: 90%;
}

.mhsg-chat-product-card {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    background: #fff;
    border: 1px solid var(--mhsg-border);
    border-radius: 10px;
    text-decoration: none;
    color: var(--mhsg-text);
    transition: border-color 0.15s, box-shadow 0.15s;
}

.mhsg-chat-product-card:hover {
    border-color: var(--mhsg-primary);
    box-shadow: 0 2px 8px rgba(37, 99, 235, 0.1);
    text-decoration: none;
    color: var(--mhsg-text);
}

.mhsg-chat-product-card img {
    width: 44px;
    height: 44px;
    border-radius: 6px;
    object-fit: cover;
    flex-shrink: 0;
}

.mhsg-chat-product-noimg {
    width: 44px;
    height: 44px;
    border-radius: 6px;
    background: #f3f4f6;
    flex-shrink: 0;
}

.mhsg-chat-product-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.mhsg-chat-product-name {
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.mhsg-chat-product-price {
    font-size: 13px;
    font-weight: 700;
    color: var(--mhsg-primary);
}

/* ============================================
   Chat Input Area
   ============================================ */
.mhsg-chat-input-area {
    border-top: 1px solid var(--mhsg-border);
    padding: 12px;
}

.mhsg-chat-input-group {
    display: flex;
    align-items: flex-end;
    gap: 8px;
}

.mhsg-chat-input {
    flex: 1;
    padding: 8px 12px;
    border: 2px solid var(--mhsg-border);
    border-radius: var(--mhsg-radius);
    resize: none;
    font-size: 14px;
    font-family: inherit;
    color: var(--mhsg-text);
    outline: none;
    max-height: 120px;
}

.mhsg-chat-input:focus {
    border-color: var(--mhsg-primary);
}

.mhsg-chat-send {
    background: var(--mhsg-primary);
    color: white;
    border: none;
    border-radius: 50%;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
    transition: opacity 0.2s;
}

.mhsg-chat-send:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.mhsg-chat-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.3);
    z-index: 9997;
}

/* ============================================
   Mobile (Bottom-Sheet)
   ============================================ */
@media (max-width: 768px) {
    .mhsg-chat-panel {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        width: 100%;
        max-height: 90vh;
        border-radius: var(--mhsg-radius) var(--mhsg-radius) 0 0;
    }

    .mhsg-chat-handle {
        display: block;
        width: 32px;
        height: 4px;
        background: rgba(255, 255, 255, 0.4);
        border-radius: 2px;
        position: absolute;
        top: 6px;
        left: 50%;
        transform: translateX(-50%);
    }

    .mhsg-chat-fab {
        bottom: 16px;
        right: 16px;
    }

    .mhsg-search-dropdown {
        border-radius: 0 0 var(--mhsg-radius) var(--mhsg-radius);
    }

    .mhsg-product-img {
        width: 48px;
        height: 48px;
    }
}
