/* ========================================
   APTIA CHATBOT - PROFESSIONAL STYLING
   55% Chat History | 20% Prompt | 25% Suggestions
   ======================================== */

/* ========== ROOT VARIABLES ========== */
:root {
    --aptia-green: #00D084;
    --aptia-green-dark: #00B070;
    --aptia-green-light: #00F094;
    --slate-gray: #708090;
    --dark-slate: #2f4f4f;
    --crimson: #dc143c;
    --crimson-dark: #b91c3c;
    --light-gray: #f8f9fa;
    --border-gray: #e9ecef;
    --text-gray: #495057;
    --white: #ffffff;
    --shadow-soft: 0 2px 8px rgba(0, 0, 0, 0.08);
    --shadow-medium: 0 4px 16px rgba(0, 0, 0, 0.12);
    --shadow-strong: 0 8px 32px rgba(0, 0, 0, 0.16);
}

/* ========== CHATBOT CONTAINER ========== */
.ask-3173-chatbot {
    position: fixed;
    bottom: 20px;
    left: 20px;
    z-index: 9999;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

/* ========== TOGGLE BUTTON (AVATAR) ========== */
.chatbot-toggle {
    width: 70px;
    height: 70px;
    background: linear-gradient(135deg, var(--aptia-green), var(--aptia-green-dark));
    border: none;
    cursor: move;
    box-shadow: 0 4px 20px rgba(0, 208, 132, 0.4);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
    z-index: 10000;
    clip-path: polygon(30% 0%, 70% 0%, 100% 30%, 100% 70%, 70% 100%, 30% 100%, 0% 70%, 0% 30%);
}

.chatbot-toggle:hover {
    transform: scale(1.1) rotate(5deg);
    box-shadow: 0 6px 30px rgba(0, 208, 132, 0.6);
}

.chatbot-toggle::before {
    content: '';
    position: absolute;
    inset: -2px;
    background: linear-gradient(45deg, var(--aptia-green), var(--aptia-green-light), var(--aptia-green));
    clip-path: polygon(30% 0%, 70% 0%, 100% 30%, 100% 70%, 70% 100%, 30% 100%, 0% 70%, 0% 30%);
    z-index: -1;
    animation: aptiaGlow 2s ease-in-out infinite alternate;
}

@keyframes aptiaGlow {
    0% { opacity: 0.7; }
    100% { opacity: 1; }
}

.chatbot-avatar {
    width: 50px;
    height: 50px;
    background-image: url('../images/aptia/aptia-logo-new.png');
    background-size: contain;
    background-position: center;
    background-repeat: no-repeat;
    border-radius: 8px;
    margin: 10px;
    flex-shrink: 0;
    border: 2px solid var(--aptia-green);
    box-shadow: 0 2px 8px rgba(0, 208, 132, 0.2);
}

/* ========== CHATBOT WINDOW ========== */
.chatbot-container {
    position: fixed;
    bottom: 100px;
    left: 20px;
    width: 450px;
    height: 600px;
    background: var(--white);
    border-radius: 16px;
    box-shadow: var(--shadow-strong), 0 0 0 1px rgba(0, 0, 0, 0.05);
    display: none;
    flex-direction: column;
    overflow: hidden;
    z-index: 9998;
    border: 2px solid var(--aptia-green);
    resize: both;
    min-width: 350px;
    min-height: 450px;
    max-width: 90vw;
    max-height: 90vh;
}

.chatbot-container.open {
    display: flex;
}

/* Draggable cursor when hovering header */
.chatbot-container.dragging {
    user-select: none;
    transition: none !important;
}

/* ========== HEADER ========== */
.chatbot-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: linear-gradient(135deg, #1a3a4a 0%, #2d5a6b 100%);
    border-bottom: 2px solid var(--aptia-green);
    flex-shrink: 0;
    cursor: move;
}

.chatbot-title {
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--white);
    font-weight: 600;
    font-size: 15px;
}

.chatbot-title .chatbot-avatar {
    width: 36px;
    height: 36px;
    margin: 0;
    border-color: var(--white);
}

.chatbot-close {
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: var(--white);
    font-size: 24px;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.chatbot-close:hover {
    background: rgba(220, 20, 60, 0.8);
    transform: scale(1.1);
}

/* ========== CHAT HISTORY SECTION (55%) ========== */
.chatbot-messages {
    flex: 0 0 55%;
    overflow-y: auto;
    padding: 16px;
    background: linear-gradient(180deg, #f8fffe 0%, #f0f9f7 100%);
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* ========== MESSAGE STYLING ========== */
.message {
    display: flex;
    margin-bottom: 4px;
    animation: messageSlide 0.3s ease-out;
}

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

.message.user {
    justify-content: flex-end;
}

.message.bot {
    justify-content: flex-start;
}

.message-content {
    max-width: 85%;
    padding: 12px 16px;
    border-radius: 16px;
    font-size: 14px;
    line-height: 1.5;
    word-wrap: break-word;
    box-shadow: var(--shadow-soft);
}

.message.user .message-content {
    background: linear-gradient(135deg, var(--aptia-green), var(--aptia-green-dark));
    color: var(--white);
    border-bottom-right-radius: 4px;
}

.message.bot .message-content {
    background: var(--white);
    color: var(--text-gray);
    border: 1px solid var(--border-gray);
    border-bottom-left-radius: 4px;
}

.message-content p {
    margin: 0 0 8px 0;
}

.message-content p:last-child {
    margin-bottom: 0;
}

.message-content ul,
.message-content ol {
    margin: 8px 0;
    padding-left: 20px;
}

.message-content li {
    margin-bottom: 4px;
}

.message-content code {
    background: rgba(0, 208, 132, 0.1);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'Monaco', 'Menlo', monospace;
    font-size: 13px;
}

.message-content pre {
    background: #1a3a4a;
    color: #f8f9fa;
    padding: 12px;
    border-radius: 8px;
    overflow-x: auto;
    margin: 8px 0;
}

.message-content a {
    color: var(--aptia-green-dark);
    text-decoration: underline;
}

.message-content a:hover {
    color: var(--aptia-green);
}

/* ========== INPUT SECTION (20%) ========== */
.chatbot-input-area {
    flex: 0 0 20%;
    padding: 16px;
    background: var(--white);
    border-top: 2px solid var(--aptia-green);
    display: flex;
    flex-direction: column;
    gap: 10px;
    box-shadow: 0 -4px 12px rgba(0, 208, 132, 0.1);
    flex-shrink: 0;
}

.chatbot-input-row {
    display: flex;
    gap: 10px;
    align-items: center;
}

.chatbot-input {
    flex: 1;
    border: 2px solid var(--aptia-green);
    border-radius: 24px;
    padding: 12px 18px;
    font-size: 14px;
    outline: none;
    transition: all 0.2s ease;
    font-family: inherit;
    resize: none;
    min-height: 44px;
}

.chatbot-input:focus {
    border-color: var(--aptia-green-dark);
    box-shadow: 0 0 0 4px rgba(0, 208, 132, 0.15);
}

.chatbot-input::placeholder {
    color: #adb5bd;
}

.voice-button,
.send-button {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--white);
    transition: all 0.2s ease;
    flex-shrink: 0;
    font-size: 18px;
}

.voice-button {
    background: linear-gradient(135deg, var(--slate-gray), var(--dark-slate));
}

.voice-button:hover {
    background: linear-gradient(135deg, var(--dark-slate), #1a3a3a);
    transform: scale(1.1);
    box-shadow: var(--shadow-medium);
}

.voice-button.recording {
    background: linear-gradient(135deg, var(--crimson), var(--crimson-dark));
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.15); box-shadow: 0 0 20px rgba(220, 20, 60, 0.4); }
}

.send-button {
    background: linear-gradient(135deg, var(--aptia-green), var(--aptia-green-dark));
    font-weight: 700;
}

.send-button:hover {
    background: linear-gradient(135deg, var(--aptia-green-dark), #008060);
    transform: scale(1.1);
    box-shadow: 0 4px 16px rgba(0, 208, 132, 0.4);
}

.send-button:active,
.voice-button:active {
    transform: scale(0.95);
}

/* ========== SUGGESTED QUESTIONS SECTION (25%) ========== */
.suggested-questions {
    flex: 0 0 25%;
    padding: 12px 16px;
    background: linear-gradient(180deg, #f0f9f7 0%, #e8f5f2 100%);
    border-top: 1px solid var(--border-gray);
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.suggested-questions-title {
    font-size: 12px;
    font-weight: 600;
    color: var(--slate-gray);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.suggested-questions-title::before {
    content: '💡';
    font-size: 14px;
}

.suggested-question-btn {
    background: var(--white);
    border: 1px solid var(--border-gray);
    border-radius: 10px;
    padding: 10px 14px;
    font-size: 13px;
    color: var(--text-gray);
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    text-align: left;
    line-height: 1.4;
    font-weight: 500;
    box-shadow: var(--shadow-soft);
}

.suggested-question-btn:hover {
    background: linear-gradient(135deg, var(--aptia-green), var(--aptia-green-dark));
    border-color: var(--aptia-green-dark);
    color: var(--white);
    transform: translateY(-2px);
    box-shadow: var(--shadow-medium);
}

.suggested-question-btn:active {
    transform: translateY(0);
    box-shadow: var(--shadow-soft);
}

/* ========== SCROLLBAR STYLING ========== */
.chatbot-messages::-webkit-scrollbar,
.suggested-questions::-webkit-scrollbar {
    width: 6px;
}

.chatbot-messages::-webkit-scrollbar-track,
.suggested-questions::-webkit-scrollbar-track {
    background: transparent;
}

.chatbot-messages::-webkit-scrollbar-thumb,
.suggested-questions::-webkit-scrollbar-thumb {
    background: var(--aptia-green);
    border-radius: 10px;
}

.chatbot-messages::-webkit-scrollbar-thumb:hover,
.suggested-questions::-webkit-scrollbar-thumb:hover {
    background: var(--aptia-green-dark);
}

/* ========== TYPING INDICATOR ========== */
.typing-indicator {
    display: flex;
    gap: 4px;
    padding: 12px 16px;
    background: var(--white);
    border-radius: 16px;
    border: 1px solid var(--border-gray);
    width: fit-content;
    box-shadow: var(--shadow-soft);
}

.typing-indicator span {
    width: 8px;
    height: 8px;
    background: var(--aptia-green);
    border-radius: 50%;
    animation: typingBounce 1.4s infinite ease-in-out;
}

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

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

/* ========== SPEAK BUTTON ========== */
.speak-btn,
.inline-speak {
    background: none;
    border: none;
    font-size: 16px;
    cursor: pointer;
    margin-left: 8px;
    padding: 4px 8px;
    border-radius: 6px;
    transition: all 0.2s ease;
    color: var(--slate-gray);
    opacity: 0.7;
}

.speak-btn:hover,
.inline-speak:hover {
    background-color: rgba(0, 208, 132, 0.1);
    color: var(--aptia-green-dark);
    opacity: 1;
    transform: scale(1.15);
}

/* ========== MOBILE RESPONSIVE ========== */
@media (max-width: 768px) {
    .chatbot-container {
        width: calc(100vw - 30px);
        height: calc(100vh - 120px);
        left: 15px !important;
        bottom: 90px !important;
        max-height: 90vh;
    }
    
    .ask-3173-chatbot {
        bottom: 15px;
        left: 15px;
    }
    
    .chatbot-toggle {
        width: 60px;
        height: 60px;
    }
    
    .chatbot-avatar {
        width: 40px;
        height: 40px;
        margin: 10px;
    }
    
    .chatbot-messages {
        flex: 0 0 50%;
    }
    
    .chatbot-input-area {
        flex: 0 0 22%;
    }
    
    .suggested-questions {
        flex: 0 0 28%;
    }
    
    .message-content {
        max-width: 85%;
        font-size: 13px;
    }
}

/* Fix close button clickability */
.chatbot-close {
}

.chatbot-header {
    user-select: none;
}

/* Fix close button clickability */
.chatbot-close {
    z-index: 10001;
    pointer-events: auto;
    cursor: pointer;
    position: relative;
}

