/* ==========================================================================
   Happy School AI Chatbot Stylesheet
   Designed for modern UI/UX, responsive on all devices & high aesthetic appeal
   ========================================================================== */

.hsc-chatbot-wrapper {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 999999;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    line-height: 1.5;
}

/* Floating Trigger Button */
.hsc-chatbot-btn {
    position: relative;
    width: 62px;
    height: 62px;
    border-radius: 50%;
    background: linear-gradient(135deg, #1e40af 0%, #2563eb 50%, #3b82f6 100%);
    color: #ffffff;
    border: none;
    cursor: pointer;
    box-shadow: 0 10px 25px -3px rgba(30, 64, 175, 0.45), 0 4px 10px -2px rgba(30, 64, 175, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    outline: none;
    user-select: none;
}

.hsc-chatbot-btn:hover {
    transform: scale(1.08) translateY(-2px);
    box-shadow: 0 15px 30px -4px rgba(30, 64, 175, 0.55), 0 6px 12px -2px rgba(30, 64, 175, 0.4);
}

.hsc-chatbot-btn:active {
    transform: scale(0.95);
}

/* Pulsing Wave Ring */
.hsc-chatbot-btn-pulse {
    position: absolute;
    inset: -6px;
    border-radius: 50%;
    border: 2px solid rgba(59, 130, 246, 0.6);
    animation: hsc-chat-pulse 2.2s infinite cubic-bezier(0.24, 0, 0.38, 1);
    pointer-events: none;
}

@keyframes hsc-chat-pulse {
    0% {
        transform: scale(0.9);
        opacity: 0.8;
    }
    50% {
        transform: scale(1.25);
        opacity: 0.2;
    }
    100% {
        transform: scale(1.4);
        opacity: 0;
    }
}

/* Badge AI */
.hsc-chatbot-badge {
    position: absolute;
    top: -3px;
    right: -3px;
    background: linear-gradient(135deg, #ff6b00 0%, #ea580c 100%);
    color: #ffffff;
    font-size: 10px;
    font-weight: 800;
    padding: 2px 6px;
    border-radius: 12px;
    letter-spacing: 0.5px;
    border: 2px solid #ffffff;
    box-shadow: 0 2px 6px rgba(234, 88, 12, 0.4);
}

/* Chat Dialog Window - Mở rộng full chiều cao từ đỉnh tới đáy trên PC, đè lên nút open */
.hsc-chatbot-window {
    position: fixed;
    top: 20px;
    bottom: 20px;
    right: 24px;
    width: 440px;
    max-width: calc(100vw - 36px);
    height: calc(100vh - 40px);
    max-height: calc(100vh - 40px);
    background: #ffffff;
    border-radius: 20px;
    box-shadow: 0 20px 45px -6px rgba(15, 23, 42, 0.25), 0 10px 20px -3px rgba(15, 23, 42, 0.15);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid rgba(226, 232, 240, 0.85);
    transform-origin: bottom right;
    animation: hsc-chat-popup 0.35s cubic-bezier(0.16, 1, 0.3, 1) forwards;
    z-index: 9999999;
}

@keyframes hsc-chat-popup {
    0% {
        opacity: 0;
        transform: scale(0.92) translateY(20px);
    }
    100% {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

/* Chat Header */
.hsc-chat-header {
    background: linear-gradient(135deg, #1e40af 0%, #1d4ed8 60%, #2563eb 100%);
    color: #ffffff;
    padding: 16px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 2px 8px rgba(30, 64, 175, 0.15);
    flex-shrink: 0;
}

.hsc-chat-header-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.hsc-chat-avatar {
    position: relative;
    width: 42px;
    height: 42px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.18);
    backdrop-filter: blur(4px);
    border: 1px solid rgba(255, 255, 255, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
}

.hsc-chat-status-dot {
    position: absolute;
    bottom: -2px;
    right: -2px;
    width: 10px;
    height: 10px;
    background: #10b981;
    border: 2px solid #1e40af;
    border-radius: 50%;
}

.hsc-chat-title {
    font-size: 15.5px;
    font-weight: 700;
    letter-spacing: -0.2px;
}

.hsc-chat-subtitle {
    font-size: 12px;
    opacity: 0.88;
    margin-top: 1px;
}

.hsc-chat-header-actions {
    display: flex;
    align-items: center;
    gap: 6px;
}

.hsc-chat-btn-icon {
    background: rgba(255, 255, 255, 0.15);
    border: none;
    color: #ffffff;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.hsc-chat-btn-icon:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.05);
}

/* Chat Messages Scroll Container - Tận dụng tối đa chiều cao */
.hsc-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 18px 18px 20px 18px;
    background: #f8fafc;
    display: flex;
    flex-direction: column;
    gap: 15px;
    scroll-behavior: smooth;
}

.hsc-chat-messages::-webkit-scrollbar {
    width: 6px;
}

.hsc-chat-messages::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 10px;
}

/* Message Rows & Bubbles */
.hsc-msg-row {
    display: flex;
    gap: 10px;
    align-items: flex-start;
}

.hsc-msg-row.user {
    justify-content: flex-end;
}

.hsc-msg-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: #eff6ff;
    color: #1e40af;
    border: 1px solid #bfdbfe;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 15px;
    flex-shrink: 0;
    margin-top: 4px;
}

.hsc-msg-bubble {
    max-width: 88%;
    padding: 13px 16px;
    font-size: 13.5px;
    line-height: 1.62;
    word-break: break-word;
}

.hsc-msg-row.bot .hsc-msg-bubble {
    background: #ffffff;
    color: #1e293b;
    border-radius: 4px 18px 18px 18px;
    border: 1px solid #e2e8f0;
    box-shadow: 0 2px 8px rgba(15, 23, 42, 0.05);
}

.hsc-msg-row.user .hsc-msg-bubble {
    background: linear-gradient(135deg, #1e40af 0%, #2563eb 100%);
    color: #ffffff;
    border-radius: 18px 18px 4px 18px;
    box-shadow: 0 3px 8px rgba(30, 64, 175, 0.25);
}

.hsc-msg-bubble p {
    margin: 0 0 8px 0;
}

.hsc-msg-bubble p:last-child {
    margin-bottom: 0;
}

.hsc-msg-bubble ul, .hsc-msg-bubble ol {
    margin: 6px 0 8px 18px;
    padding: 0;
}

.hsc-msg-bubble li {
    margin-bottom: 4px;
}

.hsc-msg-bubble strong {
    font-weight: 700;
    color: inherit;
}

/* Gợi ý nhanh nằm trực tiếp trong block tin nhắn (In-message Prompts) */
.hsc-chat-prompts-block {
    margin-top: 14px;
    padding-top: 12px;
    border-top: 1px dashed #cbd5e1;
    display: flex;
    flex-direction: column;
    gap: 7px;
}

.hsc-prompts-title {
    font-size: 11.5px;
    font-weight: 700;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    margin-bottom: 3px;
    display: flex;
    align-items: center;
    gap: 4px;
}

.hsc-prompts-chips {
    display: flex;
    flex-direction: column;
    gap: 7px;
}

.hsc-quick-chip {
    background: #f8fafc;
    border: 1px solid #cbd5e1;
    color: #1e40af;
    font-size: 12.5px;
    font-weight: 500;
    padding: 8px 12px;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    text-align: left;
    display: flex;
    align-items: center;
    justify-content: space-between;
    user-select: none;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
}

.hsc-quick-chip::after {
    content: "→";
    font-size: 13px;
    font-weight: 700;
    opacity: 0.5;
    transition: transform 0.2s ease, opacity 0.2s ease;
}

.hsc-quick-chip:hover {
    background: #eff6ff;
    color: #1d4ed8;
    border-color: #93c5fd;
    transform: translateX(4px);
    box-shadow: 0 2px 6px rgba(37, 99, 235, 0.12);
}

.hsc-quick-chip:hover::after {
    transform: translateX(3px);
    opacity: 1;
}

/* Rich Course / Page Links Inside Bot Replies */
.hsc-chat-link {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    margin: 5px 2px;
    padding: 6px 12px;
    background: #eff6ff;
    color: #1d4ed8 !important;
    border: 1px solid #bfdbfe;
    border-radius: 8px;
    font-weight: 600;
    font-size: 13px;
    text-decoration: none !important;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 1px 2px rgba(30, 64, 175, 0.08);
}

.hsc-chat-link::after {
    content: "↗";
    font-size: 12px;
    font-weight: 700;
    opacity: 0.8;
}

.hsc-chat-link:hover {
    background: #2563eb;
    color: #ffffff !important;
    border-color: #2563eb;
    transform: translateY(-1.5px);
    box-shadow: 0 4px 10px rgba(37, 99, 235, 0.25);
}

/* Typing Indicator Animation */
.hsc-typing-bubble {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 12px 16px;
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 4px 16px 16px 16px;
    width: fit-content;
}

.hsc-typing-dot {
    width: 7px;
    height: 7px;
    background: #3b82f6;
    border-radius: 50%;
    animation: hsc-dot-bounce 1.4s infinite ease-in-out both;
}

.hsc-typing-dot:nth-child(1) { animation-delay: -0.32s; }
.hsc-typing-dot:nth-child(2) { animation-delay: -0.16s; }

@keyframes hsc-dot-bounce {
    0%, 80%, 100% {
        transform: scale(0);
        opacity: 0.4;
    }
    40% {
        transform: scale(1);
        opacity: 1;
    }
}

/* Input Bar */
.hsc-chat-input-container {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    background: #ffffff;
    border-top: 1px solid #e2e8f0;
    flex-shrink: 0;
}

.hsc-chat-input {
    flex: 1;
    border: 1px solid #cbd5e1;
    border-radius: 12px;
    padding: 10px 14px;
    font-size: 13.5px;
    font-family: inherit;
    outline: none;
    resize: none;
    max-height: 90px;
    line-height: 1.4;
    color: #0f172a;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.hsc-chat-input:focus {
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.hsc-chat-send-btn {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    background: linear-gradient(135deg, #1e40af 0%, #2563eb 100%);
    color: #ffffff;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
    flex-shrink: 0;
}

.hsc-chat-send-btn:hover {
    transform: scale(1.06);
    background: #1d4ed8;
}

.hsc-chat-send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* Footer note */
.hsc-chat-footer-note {
    font-size: 11px;
    text-align: center;
    color: #94a3b8;
    padding: 4px 10px 8px 10px;
    background: #ffffff;
    flex-shrink: 0;
}

/* Mobile Responsive Optimization - Toàn màn hình trên điện thoại */
@media (max-width: 480px) {
    .hsc-chatbot-wrapper {
        bottom: 16px;
        right: 16px;
    }

    .hsc-chatbot-btn {
        width: 56px;
        height: 56px;
    }

    .hsc-chatbot-window {
        position: fixed;
        top: 0;
        bottom: 0;
        right: 0;
        left: 0;
        width: 100vw;
        max-width: 100vw;
        height: 100vh;
        max-height: 100vh;
        border-radius: 0;
        border: none;
        z-index: 9999999;
    }

    .hsc-msg-bubble {
        max-width: 90%;
    }
}
