/* Chatbot Container */
.chatbot-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 9999;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* Chatbot Body */
.chatbot-body {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* Chatbot Toggle Button */
.chatbot-toggle {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, #f57c00 0%, #e65100 100%);
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(245, 124, 0, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    position: relative;
}

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

.chatbot-toggle i {
    color: white;
    font-size: 24px;
    transition: transform 0.3s ease;
}

.chatbot-toggle:hover i {
    transform: rotate(10deg);
}

/* Chatbot Badge */
.chatbot-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #e53935;
    color: white;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    font-size: 12px;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.1);
    }
}

/* Chatbot Window */
.chatbot-window {
    position: absolute;
    bottom: 80px;
    right: 0;
    width: 380px;
    height: calc(100vh - 120px);
    max-height: 600px;
    background: white;
    border-radius: 20px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    display: none;
    flex-direction: column;
    overflow: hidden;
    animation: slideUp 0.3s ease;
}

/* Tablet Styles — icon stays bottom-right, window centered in viewport */
@media (max-width: 768px) {
    .chatbot-container {
        right: 20px;
        bottom: 20px;
        left: auto;
        transform: none;
    }

    .chatbot-window {
        position: fixed;
        bottom: 100px;
        left: 50%;
        right: auto;
        transform: translateX(-50%);
        width: calc(100vw - 40px);
        max-width: 420px;
        height: calc(100vh - 140px);
        max-height: 700px;
        border-radius: 20px;
    }

    .chatbot-sidebar.active {
        width: 240px;
    }
}

/* Mobile Styles — icon stays bottom-right, window fills screen */
@media (max-width: 480px) {
    .chatbot-container {
        right: 16px;
        bottom: 16px;
        left: auto;
        transform: none;
    }

    .chatbot-window {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        width: 100%;
        height: 100%;
        max-height: none;
        max-width: none;
        border-radius: 0;
        transform: none;
    }

    .chatbot-sidebar.active {
        position: absolute;
        left: 0;
        top: 0;
        bottom: 0;
        width: 100%;
        z-index: 10;
        background: white;
    }

    .chatbot-sidebar.active .chatbot-sidebar-header {
        background: #f8f9fa;
    }
}

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

/* On tablet, the window uses translateX(-50%) for centering — override animation to preserve that */
@media (min-width: 481px) and (max-width: 768px) {
    @keyframes slideUp {
        from {
            opacity: 0;
            transform: translateX(-50%) translateY(20px);
        }
        to {
            opacity: 1;
            transform: translateX(-50%) translateY(0);
        }
    }
}

.chatbot-window.active {
    display: flex;
}

/* Chatbot Header */
.chatbot-header {
    background: linear-gradient(135deg, #f57c00 0%, #e65100 100%);
    color: white;
    padding: 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.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;
}

.chatbot-avatar i {
    font-size: 20px;
}

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

.chatbot-title p {
    margin: 2px 0 0 0;
    font-size: 12px;
    opacity: 0.9;
}

.chatbot-close {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease;
}

.chatbot-close:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* Chatbot Header Actions */
.chatbot-header-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

.chatbot-new-chat,
.chatbot-sidebar-toggle {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease;
}

.chatbot-new-chat:hover,
.chatbot-sidebar-toggle:hover,
.chatbot-support-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* Chatbot Support Badge */
.chatbot-support-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #e53935;
    color: white;
    border-radius: 50%;
    min-width: 18px;
    height: 18px;
    font-size: 11px;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
    line-height: 1;
    animation: pulse 2s infinite;
}

/* Chatbot Sidebar */
.chatbot-sidebar {
    width: 0;
    background: #f8f9fa;
    border-right: 1px solid #e0e0e0;
    overflow-y: auto;
    transition: width 0.3s ease;
    display: flex;
    flex-direction: column;
}

.chatbot-sidebar.active {
    width: 280px;
}

.chatbot-sidebar-header {
    padding: 15px;
    border-bottom: 1px solid #e0e0e0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: white;
}

.chatbot-sidebar-header h4 {
    margin: 0;
    font-size: 14px;
    font-weight: 600;
    color: #333;
}

.chatbot-sidebar-close {
    background: none;
    border: none;
    color: #666;
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    transition: background 0.2s ease;
}

.chatbot-sidebar-close:hover {
    background: #e0e0e0;
}

.chatbot-conversations {
    flex: 1;
    padding: 10px;
    overflow-y: auto;
}

.no-conversations {
    text-align: center;
    color: #999;
    font-size: 13px;
    padding: 20px 10px;
}

.chatbot-conversation-item {
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 12px;
    margin-bottom: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
}

.chatbot-conversation-item:hover {
    border-color: #f57c00;
    box-shadow: 0 2px 8px rgba(245, 124, 0, 0.1);
}

.chatbot-conversation-item.active {
    border-color: #f57c00;
    background: #fff8f0;
}

.conversation-title {
    font-size: 13px;
    font-weight: 500;
    color: #333;
    margin-bottom: 6px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.conversation-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 11px;
    color: #999;
}

.conversation-delete {
    position: absolute;
    top: 8px;
    right: 8px;
    background: none;
    border: none;
    color: #999;
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    opacity: 0;
    transition: all 0.2s ease;
}

.chatbot-conversation-item:hover .conversation-delete {
    opacity: 1;
}

.conversation-delete:hover {
    color: #e53935;
    background: rgba(229, 57, 53, 0.1);
}

/* Chatbot Messages */
.chatbot-messages {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    background: #f8f9fa;
    min-width: 0; /* Prevent flex overflow */
}

.chatbot-message {
    margin-bottom: 15px;
    display: flex;
    flex-direction: column;
    animation: fadeIn 0.3s ease;
}

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

.chatbot-message.user {
    align-items: flex-end;
}

.chatbot-message.bot {
    align-items: flex-start;
}

.chatbot-message-content {
    max-width: 80%;
    padding: 12px 16px;
    border-radius: 18px;
    font-size: 14px;
    line-height: 1.4;
    word-wrap: break-word;
}

.chatbot-message.user .chatbot-message-content {
    background: linear-gradient(135deg, #f57c00 0%, #e65100 100%);
    color: white;
    border-bottom-right-radius: 4px;
}

.chatbot-message.bot .chatbot-message-content {
    background: white;
    color: #333;
    border-bottom-left-radius: 4px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
}

.chatbot-message-time {
    font-size: 11px;
    color: #999;
    margin-top: 4px;
}

.chatbot-message.user .chatbot-message-time {
    margin-right: 5px;
}

.chatbot-message.bot .chatbot-message-time {
    margin-left: 5px;
}

/* Caregiver Recommendations */
.chatbot-recommendations {
    margin-top: 10px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.chatbot-recommendation {
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 12px;
    padding: 12px;
    transition: all 0.2s ease;
}

.chatbot-recommendation:hover {
    border-color: #f57c00;
    box-shadow: 0 2px 8px rgba(245, 124, 0, 0.1);
}

.chatbot-recommendation-name {
    font-weight: 600;
    color: #333;
    margin-bottom: 4px;
}

.chatbot-recommendation-details {
    font-size: 12px;
    color: #666;
    margin-bottom: 8px;
}

.chatbot-recommendation-skills {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

.chatbot-recommendation-skill {
    background: #e8f5e9;
    color: #2e7d32;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 11px;
}

.chatbot-recommendation-match {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 8px;
}

.chatbot-recommendation-match-bar {
    flex: 1;
    height: 4px;
    background: #e0e0e0;
    border-radius: 2px;
    overflow: hidden;
}

.chatbot-recommendation-match-fill {
    height: 100%;
    background: linear-gradient(90deg, #4caf50, #8bc34a);
    border-radius: 2px;
}

.chatbot-recommendation-match-text {
    font-size: 11px;
    color: #666;
    font-weight: 500;
}

/* Chatbot Input */
.chatbot-input-container {
    padding: 15px 20px;
    background: white;
    border-top: 1px solid #e0e0e0;
    display: flex;
    gap: 10px;
    align-items: center;
}

.chatbot-input {
    flex: 1;
    padding: 12px 16px;
    border: 1px solid #e0e0e0;
    border-radius: 25px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s ease;
}

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

.chatbot-send {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, #f57c00 0%, #e65100 100%);
    border: none;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.chatbot-send:hover {
    transform: scale(1.05);
}

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

/* Typing Indicator */
.chatbot-typing {
    display: flex;
    gap: 4px;
    padding: 12px 16px;
    background: white;
    border-radius: 18px;
    border-bottom-left-radius: 4px;
    width: fit-content;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
}

.chatbot-typing-dot {
    width: 8px;
    height: 8px;
    background: #999;
    border-radius: 50%;
    animation: typing 1.4s infinite;
}

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

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

@keyframes typing {
    0%, 60%, 100% {
        transform: translateY(0);
    }
    30% {
        transform: translateY(-4px);
    }
}

/* Quick Actions */
.chatbot-quick-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 10px;
}

.chatbot-quick-action {
    background: white;
    border: 1px solid #e0e0e0;
    padding: 8px 12px;
    border-radius: 20px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.chatbot-quick-action:hover {
    background: #f57c00;
    color: white;
    border-color: #f57c00;
}

/* Responsive — mobile rules handled in the main mobile block above */