/* Digital Human Service Public CSS */

/* Container positioning */
#digital-human-container {
    position: fixed;
    z-index: 9999;
    pointer-events: none;
}

/* Position classes */
.digital-human-position-bottom-left {
    bottom: 20px;
    left: 20px;
}

.digital-human-position-bottom-right {
    bottom: 20px;
    right: 20px;
}

.digital-human-position-top-left {
    top: 20px;
    left: 20px;
}

.digital-human-position-top-right {
    top: 20px;
    right: 20px;
}

/* Digital human */
#digital-human {
    pointer-events: auto;
    cursor: pointer;
    display: inline-block;
    vertical-align: bottom;
}

#human-video {
    width: 100%;
    height: auto;
    display: block;
    background: transparent;
}

/* Initial bubble */
.digital-human-bubble {
    position: absolute;
    left: 100%;
    bottom: 10%;
    margin-left: 15px;
    background: white;
    border-radius: 20px;
    padding: 15px 20px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    width: 280px;
    max-width: 80vw;
    display: none;
    pointer-events: none;
    animation: bubbleSlideIn 0.3s ease-out;
    border: 1px solid #e8f4ff;
    box-sizing: border-box;
    overflow: hidden;
}

@keyframes bubbleSlideIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.digital-human-bubble::before {
    content: '';
    position: absolute;
    right: 100%;
    bottom: 25px;
    border-width: 10px;
    border-style: solid;
    border-color: transparent white transparent transparent;
    filter: drop-shadow(-2px 2px 4px rgba(0, 0, 0, 0.08));
}

#bubble-text {
    font-size: 14px;
    line-height: 1.5;
    color: #333;
    width: 100%;
    max-width: 100%;
    word-wrap: break-word;
    white-space: normal;
    display: block;
    vertical-align: top;
    overflow: hidden;
    text-align: left;
    writing-mode: horizontal-tb;
    text-orientation: mixed;
    direction: ltr;
    box-sizing: border-box;
}

/* Chat window */
.digital-human-chat {
    position: absolute;
    left: 100%;
    bottom: 0;
    margin-left: 15px;
    width: 380px;
    height: 520px;
    background: white;
    border-radius: 20px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
    display: none;
    flex-direction: column;
    pointer-events: auto;
    border: 1px solid #e8f4ff;
    animation: chatSlideIn 0.3s ease-out;
    overflow: hidden;
}

@keyframes chatSlideIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Chat header */
.chat-header {
    background: linear-gradient(135deg, #0B5AA8 0%, #1a73e8 100%);
    color: white;
    padding: 18px 20px;
    border-radius: 20px 20px 0 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 10px rgba(11, 90, 168, 0.2);
}

.chat-header h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    letter-spacing: 0.5px;
}

.chat-minimize, .chat-close {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    font-size: 18px;
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.3s ease;
    margin-left: 8px;
    backdrop-filter: blur(10px);
}

.chat-minimize:hover, .chat-close:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.1);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.chat-close {
    font-size: 22px;
    font-weight: 300;
}

/* Chat messages */
.chat-messages {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    background: linear-gradient(180deg, #f8fafc 0%, #e0f2fe 100%);
    scroll-behavior: smooth;
}

/* Custom scrollbar */
.chat-messages::-webkit-scrollbar {
    width: 6px;
}

.chat-messages::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.05);
    border-radius: 3px;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: rgba(11, 90, 168, 0.3);
    border-radius: 3px;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
    background: rgba(11, 90, 168, 0.5);
}

/* Message styles */
.message {
    margin-bottom: 20px;
    display: flex;
    align-items: flex-end;
    animation: messageSlideIn 0.2s ease-out;
}

@keyframes messageSlideIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.message.user {
    justify-content: flex-end;
}

.message.ai {
    justify-content: flex-start;
}

.message-content {
    max-width: 75%;
    padding: 12px 18px;
    border-radius: 22px;
    font-size: 15px;
    line-height: 1.5;
    word-wrap: break-word;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
    position: relative;
}

.message.user .message-content {
    background: linear-gradient(135deg, #0B5AA8 0%, #1a73e8 100%);
    color: white;
    border-bottom-right-radius: 8px;
    box-shadow: 0 4px 15px rgba(11, 90, 168, 0.3);
}

.message.ai .message-content {
    background: white;
    color: #333;
    border-bottom-left-radius: 8px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    border: 1px solid #e8f4ff;
}

/* Typing indicator */
.message.typing .message-content {
    background: white;
    padding: 12px 18px;
}

.typing-indicator {
    display: flex;
    align-items: center;
}

.typing-indicator span {
    width: 8px;
    height: 8px;
    margin: 0 3px;
    background: #0B5AA8;
    border-radius: 50%;
    animation: typingBounce 1.4s infinite ease-in-out;
}

.typing-indicator span:nth-child(1) {
    animation-delay: -0.32s;
}

.typing-indicator span:nth-child(2) {
    animation-delay: -0.16s;
}

@keyframes typingBounce {
    0%, 80%, 100% {
        transform: scale(0);
        opacity: 0.5;
    }
    40% {
        transform: scale(1);
        opacity: 1;
    }
}

/* Chat input */
.chat-input-container {
    display: flex;
    padding: 20px;
    background: white;
    border-top: 1px solid #e8f4ff;
    border-radius: 0 0 20px 20px;
    gap: 12px;
}

.chat-input {
    flex: 1;
    padding: 14px 20px;
    border: 2px solid #e8f4ff;
    border-radius: 28px;
    font-size: 15px;
    outline: none;
    transition: all 0.3s ease;
    background: #f8fafc;
    resize: none;
    max-height: 120px;
    font-family: inherit;
}

.chat-input:focus {
    border-color: #0B5AA8;
    background: white;
    box-shadow: 0 0 0 3px rgba(11, 90, 168, 0.1);
}

.chat-send {
    padding: 14px 28px;
    background: linear-gradient(135deg, #0B5AA8 0%, #1a73e8 100%);
    color: white;
    border: none;
    border-radius: 28px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(11, 90, 168, 0.3);
    white-space: nowrap;
}

.chat-send:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(11, 90, 168, 0.4);
}

.chat-send:active:not(:disabled) {
    transform: translateY(0);
}

.chat-send:disabled {
    background: #e0e0e0;
    color: #9e9e9e;
    box-shadow: none;
    cursor: not-allowed;
}

/* Minimized chat */
.digital-human-chat.minimized {
    height: auto;
    width: auto;
    padding: 0;
    animation: none;
}

.digital-human-chat.minimized .chat-header {
    border-radius: 20px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
}

.digital-human-chat.minimized .chat-messages,
.digital-human-chat.minimized .chat-input-container {
    display: none;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .digital-human-chat {
        width: 300px;
        height: 400px;
    }
    
    .digital-human-position-bottom-left,
    .digital-human-position-bottom-right {
        bottom: 10px;
    }
    
    .digital-human-position-top-left,
    .digital-human-position-top-right {
        top: 10px;
    }
}
