/* ========================================
   AI CFO Assistant Chatbot Styles
   ======================================== */

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

/* ========================================
   Floating Toggle Button (Collapsed State)
   ======================================== */

.chatbot-toggle {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    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 16px rgba(0, 0, 0, 0.2);
}

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

.chatbot-icon {
    width: 28px;
    height: 28px;
    color: white;
}

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

/* ========================================
   Chat Window (Expanded State)
   ======================================== */

.chatbot-window {
    width: 380px;
    height: 550px;
    background: white;
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: slideUp 0.3s ease-out;
}

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

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

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

.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 svg {
    width: 24px;
    height: 24px;
}

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

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

.status-indicator {
    width: 8px;
    height: 8px;
    background: #10b981;
    border-radius: 50%;
    display: inline-block;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

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

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

.chatbot-close svg {
    width: 18px;
    height: 18px;
}

/* ========================================
   Messages Area
   ======================================== */

.chatbot-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    background: #f9fafb;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

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

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

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

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

/* Message Bubbles */
.chat-message {
    display: flex;
    flex-direction: column;
    max-width: 80%;
    animation: fadeIn 0.3s ease-out;
}

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

.bot-message {
    align-self: flex-start;
}

.user-message {
    align-self: flex-end;
}

.message-content {
    padding: 12px 16px;
    border-radius: 12px;
    line-height: 1.5;
    font-size: 14px;
}

.bot-message .message-content {
    background: white;
    border: 1px solid #e5e7eb;
    border-bottom-left-radius: 4px;
}

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

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

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

/* Bot message lists */
.message-content .bot-list {
    margin: 8px 0 12px 0;
    padding-left: 8px;
    list-style: none;
}

.message-content .bot-list li {
    position: relative;
    padding-left: 20px;
    margin-bottom: 8px;
    line-height: 1.5;
}

.message-content .bot-list li:last-child {
    margin-bottom: 0;
}

.message-content .bot-list li::before {
    content: "";
    position: absolute;
    left: 0;
    top: 8px;
    width: 6px;
    height: 6px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 50%;
}

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

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

/* ========================================
   Input Area
   ======================================== */

.chatbot-input-wrapper {
    border-top: 1px solid #e5e7eb;
    background: white;
}

.chatbot-input-container {
    display: flex;
    align-items: flex-end;
    padding: 12px;
    gap: 8px;
}

.chatbot-input {
    flex: 1;
    border: 1px solid #e5e7eb;
    border-radius: 20px;
    padding: 10px 16px;
    font-size: 14px;
    resize: none;
    max-height: 100px;
    font-family: inherit;
    transition: border-color 0.2s;
}

.chatbot-input:focus {
    outline: none;
    border-color: #667eea;
}

.chatbot-input::placeholder {
    color: #9ca3af;
}

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

.chatbot-send:hover:not(:disabled) {
    transform: scale(1.05);
    box-shadow: 0 4px 8px rgba(102, 126, 234, 0.3);
}

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

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

.chatbot-send svg {
    width: 20px;
    height: 20px;
    color: white;
}

/* Suggestions */
.chatbot-suggestions {
    padding: 8px 12px 12px 12px;
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    overflow-x: auto;
}

.suggestion-chip {
    background: #f3f4f6;
    border: 1px solid #e5e7eb;
    border-radius: 16px;
    padding: 6px 12px;
    font-size: 12px;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.2s;
}

.suggestion-chip:hover {
    background: #e5e7eb;
    border-color: #667eea;
}

/* ========================================
   Loading Indicator
   ======================================== */

.chatbot-loading {
    padding: 8px 16px;
    background: #f9fafb;
}

.typing-indicator {
    display: flex;
    gap: 4px;
    align-items: center;
    padding: 12px 16px;
    background: white;
    border-radius: 12px;
    border: 1px solid #e5e7eb;
    width: fit-content;
}

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

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

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

/* ========================================
   Responsive Design
   ======================================== */

@media (max-width: 480px) {
    .chatbot-window {
        width: calc(100vw - 40px);
        height: calc(100vh - 100px);
        max-height: 600px;
    }

    .chatbot-toggle {
        width: 56px;
        height: 56px;
    }

    .chatbot-icon {
        width: 24px;
        height: 24px;
    }
}

/* ========================================
   Error State
   ======================================== */

.error-message .message-content {
    background: #fee2e2;
    border: 1px solid #fecaca;
    color: #991b1b;
}

/* ========================================
   Created Items Badges (Entities/Business Lines)
   ======================================== */

.created-items-badge {
    max-width: 100%;
}

.created-items-container {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
    border-radius: 8px;
    font-size: 13px;
}

.created-items-label {
    font-weight: 600;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 12px;
    white-space: nowrap;
}

.created-items-label.badge-primary {
    background: #3b82f6;
    color: white;
}

.created-items-label.badge-info {
    background: #06b6d4;
    color: white;
}

.created-items-list {
    color: #166534;
    font-weight: 500;
}

/* ========================================
   Milestone Indicators
   ======================================== */

.milestone-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    transition: opacity 0.3s, transform 0.2s;
    cursor: default;
    min-width: 50px;
}

.milestone-item:hover {
    transform: scale(1.1);
}

.milestone-icon {
    display: block;
    font-size: 1rem;
    line-height: 1;
}

.milestone-label {
    display: block;
    font-size: 0.65rem;
    margin-top: 2px;
    white-space: nowrap;
}

/* ========================================
   Utility Classes
   ======================================== */

.hidden {
    display: none !important;
}

.fade-out {
    animation: fadeOut 0.3s ease-out forwards;
}

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