/* Floating Chat Assistant Plugin Stylesheet */

:root {
    --assist-primary: #f27b21;       /* Theme Orange */
    --assist-primary-hover: #e06b12;
    --assist-bg-sidebar: #f9fafb;
    --assist-bg-chat: #ffffff;
    --assist-border: #e5e7eb;
    --assist-text-main: #1f2937;
    --assist-text-muted: #6b7280;
    --assist-text-light: #9ca3af;
    
    --assist-bubble-ai-bg: #f27b21;
    --assist-bubble-ai-text: #ffffff;
    --assist-bubble-user-bg: #f3f4f6;
    --assist-bubble-user-text: #f27b21; /* Orange text inside user bubble */
    
    --assist-btn-red: #ef4444;
    --assist-btn-red-bg: #fee2e2;
    --assist-shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.05);
    --assist-shadow-md: 0 10px 25px rgba(0, 0, 0, 0.08);
    --assist-shadow-lg: 0 20px 50px rgba(0, 0, 0, 0.15);
    --assist-shadow-glow: 0 8px 32px rgba(242, 123, 33, 0.3);
}

/* Floating Ball Trigger */
.assist-trigger-ball {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background-color: #ffffff;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    box-shadow: var(--assist-shadow-glow);
    cursor: pointer;
    z-index: 99999;
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275), box-shadow 0.3s ease, left 0.3s ease, top 0.3s ease, opacity 0.3s ease;
    border: 2px solid #ffffff;
}

.assist-trigger-ball:hover {
    transform: scale(1.1);
    box-shadow: 0 12px 40px rgba(242, 123, 33, 0.5);
}

.assist-trigger-ball:active {
    transform: scale(0.95);
}

/* Chat Panel Container */
.assist-panel {
    position: fixed;
    bottom: 110px;
    right: 30px;
    width: 960px;
    height: 620px;
    max-width: calc(100vw - 60px);
    max-height: calc(100vh - 150px);
    background: var(--assist-bg-chat);
    border-radius: 16px;
    box-shadow: var(--assist-shadow-lg);
    border: 1px solid rgba(0, 0, 0, 0.05);
    z-index: 99999;
    display: flex;
    overflow: hidden;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    
    /* Animation classes */
    opacity: 0;
    pointer-events: none;
    transform: translateY(20px) scale(0.95);
    transition: opacity 0.3s cubic-bezier(0.16, 1, 0.3, 1), 
                transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.assist-panel.assist-open {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0) scale(1);
}

/* Sidebar Styling */
.assist-sidebar {
    width: 250px;
    background: var(--assist-bg-sidebar);
    border-right: 1px solid var(--assist-border);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    padding: 20px 16px;
    box-sizing: border-box;
}

/* New Conversation Button */
.assist-new-btn {
    background: #ffffff;
    border: 1px solid var(--assist-border);
    border-radius: 8px;
    padding: 10px 16px;
    font-size: 14px;
    font-weight: 500;
    color: var(--assist-text-main);
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
    width: 100%;
    box-sizing: border-box;
}

.assist-new-btn:hover {
    background: #f3f4f6;
    border-color: #d1d5db;
}

.assist-new-btn svg {
    color: var(--assist-text-muted);
}

/* Recent Conversations List */
.assist-recent-section {
    margin-top: 24px;
    flex: 1;
    overflow-y: auto;
}

.assist-recent-title {
    font-size: 12px;
    font-weight: 600;
    color: var(--assist-text-muted);
    padding-left: 8px;
    margin-bottom: 12px;
}

.assist-recent-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.assist-recent-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    border-radius: 8px;
    font-size: 13px;
    color: #4b5563;
    cursor: pointer;
    position: relative;
    transition: all 0.2s ease;
}

.assist-recent-item:hover {
    background: rgba(0, 0, 0, 0.03);
}

.assist-recent-item.assist-active {
    background: #ffffff;
    box-shadow: var(--assist-shadow-sm);
    color: var(--assist-text-main);
    font-weight: 500;
}

.assist-item-title-wrapper {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    margin-right: 8px;
}

.assist-item-title-input {
    width: 90%;
    border: none;
    background: transparent;
    font-size: 13px;
    font-family: inherit;
    font-weight: inherit;
    color: inherit;
    outline: none;
    padding: 0;
    margin: 0;
}

.assist-item-more-btn {
    display: none;
    color: var(--assist-text-light);
    cursor: pointer;
    width: 20px;
    height: 20px;
    border-radius: 4px;
    align-items: center;
    justify-content: center;
    transition: background 0.2s, color 0.2s;
}

.assist-recent-item:hover .assist-item-more-btn,
.assist-recent-item.assist-active .assist-item-more-btn {
    display: flex;
}

.assist-item-more-btn:hover {
    background: #f3f4f6;
    color: var(--assist-text-main);
}

/* More Dropdown Menu */
.assist-item-dropdown {
    position: absolute;
    top: 35px;
    right: 8px;
    width: 110px;
    background: #ffffff;
    border: 1px solid var(--assist-border);
    border-radius: 8px;
    box-shadow: var(--assist-shadow-md);
    z-index: 10;
    display: none;
    flex-direction: column;
    padding: 4px;
}

.assist-item-dropdown.assist-show {
    display: flex;
}

.assist-dropdown-option {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    font-size: 12px;
    color: #4b5563;
    border: none;
    background: transparent;
    text-align: left;
    cursor: pointer;
    border-radius: 6px;
    width: 100%;
    box-sizing: border-box;
}

.assist-dropdown-option:hover {
    background: #f3f4f6;
    color: var(--assist-text-main);
}

.assist-dropdown-option.assist-delete-option:hover {
    background: #fee2e2;
    color: #dc2626;
}

/* Sidebar Footer */
.assist-sidebar-footer {
    margin-top: auto;
    border-top: 1px solid var(--assist-border);
    padding-top: 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.assist-footer-company {
    display: flex;
    align-items: center;
    gap: 8px;
}

.assist-company-logo {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background-color: var(--assist-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #ffffff;
}

.assist-company-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--assist-text-main);
}

.assist-settings-btn {
    color: var(--assist-text-light);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s, transform 0.3s ease;
}

.assist-settings-btn:hover {
    color: var(--assist-text-main);
    transform: rotate(45deg);
}

/* Main Chat Section */
.assist-chat-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--assist-bg-chat);
}

/* Chat Header */
.assist-header {
    height: 60px;
    border-bottom: 1px solid var(--assist-border);
    padding: 0 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-sizing: border-box;
}

.assist-header-left {
    display: flex;
    align-items: center;
    gap: 4px;
}

.assist-status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.assist-status-dot.green-active {
    background: #10b981;
}

.assist-status-dot.green-light {
    background: #a7f3d0;
}

.assist-header-label {
    font-size: 13px;
    color: var(--assist-text-muted);
    margin-left: 4px;
    font-weight: 500;
}

.assist-header-title {
    font-size: 16px;
    font-weight: 500;
    color: var(--assist-text-main);
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
}

.assist-header-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.assist-service-phone {
    font-size: 12px;
    color: var(--assist-text-muted);
}

/* Window Controls */
.assist-win-controls {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-left: 8px;
}

.assist-win-btn {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--assist-text-muted);
    cursor: pointer;
    border-radius: 4px;
    transition: all 0.2s;
}

.assist-win-btn:hover {
    background: #f3f4f6;
    color: var(--assist-text-main);
}

.assist-win-btn.win-close:hover {
    background: #ef4444;
    color: #ffffff;
}

/* Chat Message Area */
.assist-chat-body {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 24px;
    box-sizing: border-box;
}

/* Scrollbar styles */
.assist-chat-body::-webkit-scrollbar,
.assist-recent-section::-webkit-scrollbar {
    width: 6px;
}

.assist-chat-body::-webkit-scrollbar-track,
.assist-recent-section::-webkit-scrollbar-track {
    background: transparent;
}

.assist-chat-body::-webkit-scrollbar-thumb,
.assist-recent-section::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 10px;
}

.assist-chat-body::-webkit-scrollbar-thumb:hover,
.assist-recent-section::-webkit-scrollbar-thumb:hover {
    background: #9ca3af;
}

/* Messages */
.assist-msg {
    display: flex;
    flex-direction: column;
    max-width: 80%;
    animation: assistFadeIn 0.3s ease forwards;
}

@keyframes assistFadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.assist-msg.assist-ai {
    align-self: flex-start;
}

.assist-msg.assist-user {
    align-self: flex-end;
    align-items: flex-end;
}

.assist-msg-sender {
    font-size: 12px;
    margin-bottom: 6px;
    display: flex;
    align-items: center;
    gap: 4px;
    font-weight: 500;
}

.assist-ai .assist-msg-sender {
    color: var(--assist-primary);
}

.assist-user .assist-msg-sender {
    color: var(--assist-text-muted);
}

.assist-msg-bubble {
    padding: 12px 18px;
    border-radius: 12px;
    font-size: 14px;
    line-height: 1.6;
    word-break: break-word;
    box-sizing: border-box;
}

.assist-ai .assist-msg-bubble {
    background: var(--assist-bubble-ai-bg);
    color: var(--assist-bubble-ai-text);
    border-top-left-radius: 2px;
}

.assist-user .assist-msg-bubble {
    background: var(--assist-bubble-user-bg);
    color: var(--assist-bubble-user-text); /* Orange text in user bubble */
    border-top-right-radius: 2px;
}

/* Typing Indicator */
.assist-typing-indicator {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 4px 6px;
}

.assist-typing-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #ffffff;
    opacity: 0.6;
    animation: assistTypingAnim 1.4s infinite ease-in-out;
}

.assist-typing-dot:nth-child(1) { animation-delay: 0s; }
.assist-typing-dot:nth-child(2) { animation-delay: 0.2s; }
.assist-typing-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes assistTypingAnim {
    0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
    40% { transform: scale(1); opacity: 1; }
}

/* Quick Actions Section */
.assist-quick-actions {
    display: flex;
    gap: 8px;
    padding: 8px 24px;
    justify-content: center;
    flex-wrap: wrap;
    background: var(--assist-bg-chat);
}

.assist-btn-action {
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 1px solid transparent;
    outline: none;
    box-sizing: border-box;
}

/* Specific Quick Action Styles */
.btn-shelter {
    background: var(--assist-primary);
    border-color: var(--assist-primary);
    color: #ffffff;
}

.btn-shelter:hover {
    background: var(--assist-primary-hover);
    border-color: var(--assist-primary-hover);
}

.btn-safe {
    background: #ffffff;
    border-color: var(--assist-btn-red);
    color: var(--assist-btn-red);
}

.btn-safe:hover {
    background: var(--assist-btn-red-bg);
}

.btn-guide, .btn-emergency {
    background: #ffffff;
    border-color: #d1d5db;
    color: #374151;
}

.btn-guide:hover, .btn-emergency:hover {
    background: #f9fafb;
    border-color: #9ca3af;
}

/* Input Area Container */
.assist-input-bar {
    padding: 16px 24px 24px 24px;
    display: flex;
    align-items: center;
    background: var(--assist-bg-chat);
    box-sizing: border-box;
}

.assist-input-container {
    flex: 1;
    display: flex;
    align-items: center;
    background: #f3f4f6;
    border: 1px solid var(--assist-border);
    border-radius: 24px;
    padding: 6px 16px;
    transition: border-color 0.2s, box-shadow 0.2s;
    box-sizing: border-box;
}

.assist-input-container:focus-within {
    border-color: var(--assist-primary);
    box-shadow: 0 0 0 3px rgba(242, 123, 33, 0.15);
}

.assist-input {
    flex: 1;
    border: none;
    background: transparent;
    outline: none;
    padding: 6px 0;
    font-size: 14px;
    color: var(--assist-text-main);
    box-sizing: border-box;
}

.assist-input::placeholder {
    color: var(--assist-text-light);
}

.assist-mic-btn {
    color: var(--assist-text-muted);
    cursor: pointer;
    padding: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s;
}

.assist-mic-btn:hover {
    color: var(--assist-text-main);
}

.assist-mic-btn.recording {
    color: var(--assist-btn-red);
    animation: assistPulse 1.5s infinite;
}

@keyframes assistPulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.15); }
    100% { transform: scale(1); }
}

.assist-send-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--assist-primary);
    color: #ffffff;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-left: 10px;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.assist-send-btn:hover {
    background: var(--assist-primary-hover);
    transform: scale(1.05);
}

.assist-send-btn:active {
    transform: scale(0.95);
}

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

/* Settings Modal */
.assist-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(4px);
    z-index: 100000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.assist-modal-overlay.assist-modal-open {
    opacity: 1;
    pointer-events: auto;
}

.assist-modal-card {
    background: #ffffff;
    border-radius: 12px;
    width: 400px;
    max-width: 90%;
    padding: 24px;
    box-shadow: var(--assist-shadow-lg);
    transform: scale(0.9);
    transition: transform 0.3s ease;
    font-family: inherit;
}

.assist-modal-overlay.assist-modal-open .assist-modal-card {
    transform: scale(1);
}

.assist-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
}

.assist-modal-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--assist-text-main);
}

.assist-modal-close {
    cursor: pointer;
    color: var(--assist-text-light);
    display: flex;
    align-items: center;
}

.assist-modal-close:hover {
    color: var(--assist-text-main);
}

.assist-modal-body {
    font-size: 14px;
    color: var(--assist-text-main);
    line-height: 1.6;
}

.assist-settings-item {
    margin-bottom: 16px;
}

.assist-settings-item label {
    display: block;
    font-weight: 500;
    margin-bottom: 6px;
    font-size: 13px;
    color: var(--assist-text-muted);
}

.assist-settings-item input,
.assist-settings-item select {
    width: 100%;
    padding: 10px;
    border: 1px solid var(--assist-border);
    border-radius: 6px;
    font-size: 13px;
    outline: none;
    box-sizing: border-box;
}

.assist-settings-item input:focus,
.assist-settings-item select:focus {
    border-color: var(--assist-primary);
}

.assist-settings-desc {
    font-size: 11px;
    color: var(--assist-text-light);
    margin-top: 4px;
}

/* Responsive CSS */
@media (max-width: 768px) {
    .assist-panel {
        width: 100%;
        height: 100%;
        max-width: 100%;
        max-height: 100%;
        bottom: 0;
        right: 0;
        border-radius: 0;
        border: none;
    }
    
    .assist-sidebar {
        position: absolute;
        left: -250px;
        top: 0;
        height: 100%;
        z-index: 1000;
        transition: left 0.3s ease;
        box-shadow: var(--assist-shadow-lg);
    }
    
    .assist-sidebar.assist-sidebar-open {
        left: 0;
    }
    
    .assist-header-title {
        position: static;
        transform: none;
    }
    
    .assist-menu-toggle {
        display: flex !important;
    }
}

.assist-menu-toggle {
    display: none;
    align-items: center;
    justify-content: center;
    color: var(--assist-text-muted);
    cursor: pointer;
    margin-right: 12px;
}

.assist-menu-toggle:hover {
    color: var(--assist-text-main);
}

/* Draggable & Snapping Styles */
.assist-trigger-ball.assist-dragging {
    transition: none !important;
    opacity: 0.9;
    cursor: grabbing;
}

/* Snapped Left State */
.assist-trigger-ball.assist-snapped-left {
    transform: translateX(-75%); /* Hides 75% of the ball to the left */
    opacity: 0.7;
}

.assist-trigger-ball.assist-snapped-left:hover {
    transform: translateX(0); /* Pops back out on hover */
    opacity: 1;
}

/* Snapped Right State */
.assist-trigger-ball.assist-snapped-right {
    transform: translateX(75%); /* Hides 75% of the ball to the right */
    opacity: 0.7;
}

.assist-trigger-ball.assist-snapped-right:hover {
    transform: translateX(0); /* Pops back out on hover */
    opacity: 1;
}

/* Dynamic Left Panel Alignment */
.assist-panel.assist-panel-left {
    right: auto !important;
    left: 30px !important;
}

/* WeChat Voice Input Styles */
.assist-voice-mode-toggle {
    color: var(--assist-text-muted);
    cursor: pointer;
    margin-right: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s, transform 0.1s;
    user-select: none;
}

.assist-voice-mode-toggle:hover {
    color: var(--assist-text-main);
}

.assist-voice-mode-toggle:active {
    transform: scale(0.9);
}

.assist-hold-to-speak-btn {
    flex: 1;
    background: #e5e7eb;
    border: 1px solid #d1d5db;
    border-radius: 18px;
    text-align: center;
    padding: 6px 0;
    font-size: 14px;
    font-weight: 600;
    color: #374151;
    cursor: pointer;
    user-select: none;
    transition: background-color 0.15s, border-color 0.15s, color 0.15s;
}

.assist-hold-to-speak-btn:active,
.assist-hold-to-speak-btn.assist-active {
    background: #d1d5db;
    border-color: #9ca3af;
    color: #111827;
}

/* WeChat Voice HUD Overlay */
.assist-voice-hud {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    width: 160px;
    height: 160px;
    background: rgba(0, 0, 0, 0.72);
    backdrop-filter: blur(8px);
    border-radius: 16px;
    color: #ffffff;
    display: none; /* Flex when visible */
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    pointer-events: none;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
    animation: hudFadeIn 0.15s ease-out;
}

@keyframes hudFadeIn {
    from { opacity: 0; transform: translate(-50%, -50%) scale(0.85); }
    to { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}

.assist-voice-hud-recording, .assist-voice-hud-cancel {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
}

.assist-voice-wave-container {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
}

.assist-hud-mic-icon {
    width: 32px;
    height: 32px;
    color: #ffffff;
}

.assist-voice-wave-bars {
    display: flex;
    align-items: flex-end;
    gap: 3px;
    height: 24px;
}

.wave-bar {
    width: 3px;
    background: #ffffff;
    border-radius: 2px;
    animation: waveBounce 0.8s infinite ease-in-out alternate;
}

.bar-1 { height: 8px; animation-delay: 0.1s; }
.bar-2 { height: 16px; animation-delay: 0.3s; }
.bar-3 { height: 20px; animation-delay: 0.0s; }
.bar-4 { height: 12px; animation-delay: 0.2s; }

@keyframes waveBounce {
    from { height: 4px; }
    to { height: 24px; }
}

.assist-voice-hud-text {
    font-size: 13px;
    font-weight: 500;
    margin: 0;
    color: rgba(255, 255, 255, 0.8);
    text-align: center;
}

.assist-voice-hud-text.cancel-text {
    color: #f87171;
}

.assist-hud-cancel-icon {
    width: 40px;
    height: 40px;
    color: #f87171;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(248, 113, 113, 0.15);
    border-radius: 50%;
    padding: 8px;
    box-sizing: border-box;
}
