/* PSIRS Chatbot Styles */
.psirs-chatbot {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 9999;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
}

/* Chatbot Toggle Button */
.chatbot-toggle {
    width: 60px;
    height: 60px;
    background: linear-gradient(135deg, #00aa55 0%, #008844 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0, 170, 85, 0.4);
    transition: all 0.3s ease;
    position: relative;
    color: white;
    font-size: 24px;
}

.chatbot-toggle:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(0, 170, 85, 0.6);
}

.chatbot-toggle.active {
    background: linear-gradient(135deg, #008844 0%, #006633 100%);
}

.chatbot-badge {
    position: absolute;
    top: -8px;
    right: -8px;
    background: #ff4444;
    color: white;
    font-size: 10px;
    padding: 4px 8px;
    border-radius: 12px;
    font-weight: 600;
    white-space: nowrap;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

/* Chatbot Window */
.chatbot-window {
    position: absolute;
    bottom: 80px;
    right: 0;
    width: 380px;
    height: 600px;
    max-width: calc(100vw - 40px);
    max-height: calc(100vh - 100px);
    background: white;
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
    display: flex;
    flex-direction: column;
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px) scale(0.95);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
    box-sizing: border-box;
}

.chatbot-window.open {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

/* Chatbot Header */
.chatbot-header {
    background: linear-gradient(135deg, #00aa55 0%, #008844 100%);
    color: white;
    padding: 16px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.chatbot-header-content {
    display: flex;
    align-items: center;
    gap: 12px;
}

.chatbot-avatar {
    width: 40px;
    height: 40px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    overflow: hidden;
    flex-shrink: 0;
}

.chatbot-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
}

.chatbot-title h4 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
}

.chatbot-status {
    font-size: 12px;
    opacity: 0.9;
    display: flex;
    align-items: center;
    gap: 4px;
}

.chatbot-status::before {
    content: '';
    width: 8px;
    height: 8px;
    background: #4ade80;
    border-radius: 50%;
    display: inline-block;
}

.chatbot-close {
    background: none;
    border: none;
    color: white;
    font-size: 20px;
    cursor: pointer;
    padding: 4px;
    opacity: 0.8;
    transition: opacity 0.2s;
}

.chatbot-close:hover {
    opacity: 1;
}

/* Chatbot Messages Area */
.chatbot-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: #f8f9fa;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

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

.chatbot-messages::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.chatbot-messages::-webkit-scrollbar-thumb {
    background: #00aa55;
    border-radius: 3px;
}

.chatbot-messages::-webkit-scrollbar-thumb:hover {
    background: #008844;
}

/* Welcome Message */
.chatbot-welcome {
    text-align: center;
    padding: 20px;
    color: #666;
}

.welcome-icon {
    font-size: 48px;
    color: #00aa55;
    margin-bottom: 16px;
}

.chatbot-welcome h5 {
    color: #333;
    margin: 0 0 12px 0;
    font-size: 18px;
}

.chatbot-welcome p {
    margin: 8px 0;
    font-size: 14px;
}

.chatbot-welcome ul {
    text-align: left;
    display: inline-block;
    margin: 12px 0;
    padding-left: 20px;
}

.chatbot-welcome li {
    margin: 6px 0;
    font-size: 14px;
}

/* Chat Messages */
.chatbot-message {
    display: flex;
    gap: 12px;
    animation: messageSlideIn 0.3s ease;
}

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

.user-message {
    flex-direction: row-reverse;
}

.message-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 16px;
    overflow: hidden;
}

.message-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
}

.user-message .message-avatar {
    background: linear-gradient(135deg, #00aa55 0%, #008844 100%);
    color: white;
}

.assistant-message .message-avatar {
    background: #e5e7eb;
    color: #6b7280;
}

.message-content {
    flex: 1;
    max-width: 75%;
    min-width: 0; /* Prevents flex item from overflowing */
    overflow-wrap: break-word;
    word-wrap: break-word;
}

.user-message .message-content {
    text-align: right;
}

.message-text {
    padding: 12px 16px;
    border-radius: 18px;
    font-size: 14px;
    line-height: 1.5;
    word-wrap: break-word;
    overflow-wrap: break-word;
    word-break: break-word;
    hyphens: auto;
}

.user-message .message-text {
    background: linear-gradient(135deg, #00aa55 0%, #008844 100%);
    color: white;
    border-bottom-right-radius: 4px;
}

.assistant-message .message-text {
    background: white;
    color: #333;
    border: 1px solid #e5e7eb;
    border-bottom-left-radius: 4px;
}

.message-time {
    font-size: 11px;
    color: #9ca3af;
    margin-top: 4px;
    padding: 0 4px;
}

/* Typing Indicator */
.typing-indicator .message-content {
    padding: 12px 16px;
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 18px;
    border-bottom-left-radius: 4px;
}

.typing-dots {
    display: flex;
    gap: 4px;
    align-items: center;
}

.typing-dots span {
    width: 8px;
    height: 8px;
    background: #9ca3af;
    border-radius: 50%;
    animation: typing 1.4s infinite;
}

.typing-dots span:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-dots span:nth-child(3) {
    animation-delay: 0.4s;
}

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

/* Input Area */
.chatbot-input-area {
    border-top: 1px solid #e5e7eb;
    background: white;
    padding: 16px;
}

.chatbot-form {
    display: flex;
    gap: 8px;
    margin-bottom: 8px;
}

.chatbot-input {
    flex: 1;
    padding: 12px 16px;
    border: 1px solid #e5e7eb;
    border-radius: 24px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
    min-width: 0; /* Prevents flex item from overflowing */
    box-sizing: border-box;
}

.chatbot-input:focus {
    border-color: #00aa55;
}

.chatbot-send {
    width: 44px;
    height: 44px;
    background: linear-gradient(135deg, #00aa55 0%, #008844 100%);
    border: none;
    border-radius: 50%;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    font-size: 18px;
}

.chatbot-send:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(0, 170, 85, 0.4);
}

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

.chatbot-clear {
    width: 100%;
    padding: 8px;
    background: none;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    color: #6b7280;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.chatbot-clear:hover {
    background: #f3f4f6;
    border-color: #d1d5db;
    color: #374151;
}

/* Responsive Design */
@media (max-width: 768px) {
    .psirs-chatbot {
        bottom: 15px;
        right: 15px;
        left: 15px;
    }

    .chatbot-window {
        width: 100%;
        max-width: 100%;
        height: calc(100vh - 80px);
        max-height: calc(100vh - 80px);
        right: 0;
        left: 0;
        bottom: 75px;
        border-radius: 12px;
    }

    .chatbot-toggle {
        width: 56px;
        height: 56px;
        font-size: 20px;
        right: 0;
        bottom: 0;
    }

    .chatbot-header {
        padding: 12px 16px;
    }

    .chatbot-avatar {
        width: 32px;
        height: 32px;
        font-size: 16px;
    }

    .chatbot-title h4 {
        font-size: 14px;
    }

    .chatbot-status {
        font-size: 10px;
    }

    .chatbot-messages {
        padding: 12px 16px;
        gap: 12px;
    }

    .message-content {
        max-width: 85%;
    }

    .message-text {
        padding: 10px 14px;
        font-size: 13px;
    }

    .message-avatar {
        width: 32px;
        height: 32px;
        font-size: 14px;
    }

    .chatbot-input-area {
        padding: 12px;
    }

    .chatbot-form {
        gap: 6px;
        margin-bottom: 6px;
    }

    .chatbot-input {
        padding: 10px 14px;
        font-size: 14px;
    }

    .chatbot-send {
        width: 40px;
        height: 40px;
        font-size: 16px;
        flex-shrink: 0;
    }

    .chatbot-clear {
        padding: 6px;
        font-size: 11px;
    }

    .chatbot-welcome {
        padding: 16px 12px;
    }

    .welcome-icon {
        font-size: 36px;
        margin-bottom: 12px;
    }

    .chatbot-welcome h5 {
        font-size: 16px;
    }

    .chatbot-welcome p,
    .chatbot-welcome li {
        font-size: 13px;
    }
}

/* Extra small devices */
@media (max-width: 480px) {
    .psirs-chatbot {
        bottom: 10px;
        right: 10px;
        left: 10px;
    }

    .chatbot-window {
        height: calc(100vh - 70px);
        max-height: calc(100vh - 70px);
        bottom: 65px;
        border-radius: 10px;
    }

    .chatbot-toggle {
        width: 50px;
        height: 50px;
        font-size: 18px;
    }

    .message-content {
        max-width: 90%;
    }

    .message-text {
        padding: 8px 12px;
        font-size: 12px;
    }

    .chatbot-header {
        padding: 10px 12px;
    }

    .chatbot-messages {
        padding: 10px 12px;
    }
}

/* Link Styling in Messages */
.message-text a {
    color: #00aa55;
    text-decoration: underline;
}

.message-text a:hover {
    color: #008844;
}

/* Streaming Message Styles */
.streaming-message .streaming-text {
    position: relative;
}

.streaming-message .streaming-text::after {
    content: '▋';
    color: #00aa55;
    animation: blink 1s infinite;
    margin-left: 2px;
}

@keyframes blink {
    0%, 50% {
        opacity: 1;
    }
    51%, 100% {
        opacity: 0;
    }
}

/* Smooth text appearance */
.streaming-text {
    word-wrap: break-word;
    overflow-wrap: break-word;
    word-break: break-word;
    white-space: pre-wrap;
    max-width: 100%;
    box-sizing: border-box;
}

