/* AI Chat Button and Interface Styles */

/* Floating Chat Button */
.ai-chat-button {
    position: fixed;
    bottom: 24px;
    right: 24px;
    background: linear-gradient(135deg, #29e775 0%, #1fb85e 100%);
    color: white;
    border: none;
    border-radius: 30px;
    padding: 16px 24px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
    box-shadow: 0 4px 20px rgba(41, 231, 117, 0.3);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 998;
    animation: slideInUp 0.5s ease-out;
}

.ai-chat-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 30px rgba(41, 231, 117, 0.4);
}

.ai-chat-button:active {
    transform: translateY(0);
}

.ai-chat-button svg {
    width: 24px;
    height: 24px;
    animation: pulse 2s infinite;
}

/* Chat Container */
.ai-chat-container {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: all 0.3s ease;
}

.ai-chat-container.active {
    background: rgba(0, 0, 0, 0.5);
    opacity: 1;
    pointer-events: all;
}

/* Chat Window */
.ai-chat-window {
    width: 100%;
    height: 100%;
    max-width: 900px;
    max-height: 90dvh;
    background: #ffffff;
    border-radius: 20px;
    display: flex;
    flex-direction: column;
    transform: scale(0.9) translateY(20px);
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.1);
    overflow: hidden;
    position: relative;
}

.ai-chat-container.active .ai-chat-window {
    transform: scale(1) translateY(0);
    opacity: 1;
}

/* Chat Header */
.ai-chat-header {
    background: linear-gradient(135deg, #29e775 0%, #1fb85e 100%);
    color: white;
    padding: 20px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

.ai-chat-header-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

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

.ai-status {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 14px;
    opacity: 0.9;
}

.status-dot {
    width: 8px;
    height: 8px;
    background: #4ade80;
    border-radius: 50%;
    animation: pulse 2s infinite;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.back-to-history {
    color: white;
    background: rgba(255, 255, 255, 0.2);
    border: none;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border-radius: 8px;
    transition: all 0.2s ease;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
}

.back-to-history:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: translateY(-1px);
}

.back-to-history svg {
    width: 16px;
    height: 16px;
}

.close-chat {
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    padding: 8px;
    border-radius: 8px;
    transition: background 0.2s;
}

.close-chat:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* Chat Messages Area */
.ai-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    background: #f9fafb;
}

/* Message Styles */
.message {
    max-width: 70%;
    animation: fadeInUp 0.3s ease-out;
}

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

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

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

.message-bubble {
    padding: 12px 18px;
    border-radius: 18px;
    font-size: 15px;
    line-height: 1.5;
    word-wrap: break-word;
}

.message.user .message-bubble {
    background: #29e775;
    color: white;
    border-bottom-right-radius: 4px;
}

.message.ai .message-bubble {
    background: white;
    color: #1f2937;
    border-bottom-left-radius: 4px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.message.assistant .message-bubble {
    background: white;
    color: #1f2937;
    border-bottom-left-radius: 4px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

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

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

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

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

/* Suggestions */
.suggestions-container {
    padding: 16px 24px;
    background: white;
    border-top: 1px solid #e5e7eb;
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    max-height: 100px;
    overflow-y: auto;
}

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

.suggestion-chip:hover {
    background: #29e775;
    color: white;
    border-color: #29e775;
    transform: translateY(-1px);
}

/* Chat Input */
.ai-chat-input-container {
    padding: 20px 24px;
    background: white;
    border-top: 1px solid #e5e7eb;
    display: flex;
    gap: 12px;
    align-items: center;
}

.ai-chat-input {
    flex: 1;
    border: 2px solid #e5e7eb;
    border-radius: 25px;
    padding: 12px 20px;
    font-size: 15px;
    outline: none;
    transition: border-color 0.2s;
    resize: none;
    max-height: 120px;
    line-height: 1.5;
}

.ai-chat-input:focus {
    border-color: #29e775;
}

.send-button {
    background: #29e775;
    color: white;
    border: none;
    border-radius: 50%;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    flex-shrink: 0;
}

.send-button:hover {
    background: #1fb85e;
    transform: scale(1.05);
}

.send-button:disabled {
    background: #9ca3af;
    cursor: not-allowed;
    transform: scale(1);
}

/* Animations */
@keyframes slideInUp {
    from {
        transform: translateY(100px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

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

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

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

/* Mobile Responsive */
@media (max-width: 768px) {
    .ai-chat-button {
        bottom: 16px;
        right: 16px;
        padding: 14px 20px;
        font-size: 14px;
    }
    
    .ai-chat-window {
        max-width: 100%;
        max-height: 100%;
        height: 100%;
        border-radius: 0;
    }
    
    .back-to-history {
        padding: 6px 8px;
        font-size: 12px;
    }
    
    .back-to-history span {
        display: none;
    }
    
    .back-to-history svg {
        width: 18px;
        height: 18px;
    }
    
    .message {
        max-width: 85%;
    }
    
    .suggestions-container {
        padding: 12px 16px;
        gap: 6px;
    }
    
    .suggestion-chip {
        font-size: 13px;
        padding: 6px 12px;
    }
    
    .header-buttons {
        flex-direction: column;
        gap: 8px;
        width: 100%;
    }
    
    .new-chat-btn,
    .logout-btn {
        width: 100%;
        justify-content: center;
    }
    
    .history-header {
        flex-direction: column;
        gap: 12px;
        align-items: stretch;
    }
    
    .logout-btn span {
        display: inline;
    }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    .ai-chat-window {
        background: #1f2937;
    }
    
    .ai-chat-messages {
        background: #111827;
    }
    
    .message.ai .message-bubble {
        background: #374151;
        color: #f9fafb;
    }
    
    .message.assistant .message-bubble {
        background: #374151;
        color: #f9fafb;
    }
    
    .typing-indicator {
        background: #374151;
    }
    
    .suggestions-container {
        background: #1f2937;
        border-color: #374151;
    }
    
    .suggestion-chip {
        background: #374151;
        border-color: #4b5563;
        color: #e5e7eb;
    }
    
    .ai-chat-input-container {
        background: #1f2937;
        border-color: #374151;
    }
    
    .ai-chat-input {
        background: #111827;
        border-color: #374151;
        color: #f9fafb;
    }
}

/* Scrollbar styling */
.ai-chat-messages::-webkit-scrollbar {
    width: 6px;
}

.ai-chat-messages::-webkit-scrollbar-track {
    background: transparent;
}

.ai-chat-messages::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 3px;
}

.ai-chat-messages::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* Authentication Screen */
.chat-auth-screen {
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 400px;
    padding: 40px;
    text-align: center;
}

.chat-auth-screen.active {
    display: flex;
}

.chat-auth-screen h2 {
    font-size: 24px;
    font-weight: 600;
    color: #1f2937;
    margin-bottom: 12px;
}

.chat-auth-screen p {
    font-size: 16px;
    color: #6b7280;
    margin-bottom: 32px;
    max-width: 400px;
}

.auth-form {
    width: 100%;
    max-width: 360px;
}

.auth-form-group {
    margin-bottom: 16px;
}

.auth-form-group label {
    display: block;
    font-size: 14px;
    font-weight: 500;
    color: #374151;
    margin-bottom: 8px;
    text-align: left;
}

.auth-form-input {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid #e5e7eb;
    border-radius: 12px;
    font-size: 15px;
    outline: none;
    transition: border-color 0.2s;
}

.auth-form-input:focus {
    border-color: #29e775;
}

.auth-form-input.error {
    border-color: #ef4444;
}

.auth-error-message {
    font-size: 13px;
    color: #ef4444;
    margin-top: 4px;
    text-align: left;
    display: none;
}

.auth-form-input.error ~ .auth-error-message {
    display: block;
}

.auth-submit-btn {
    width: 100%;
    padding: 14px 24px;
    background: linear-gradient(135deg, #29e775 0%, #1fb85e 100%);
    color: white;
    border: none;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    margin-top: 24px;
}

.auth-submit-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 20px rgba(41, 231, 117, 0.3);
}

.auth-submit-btn:disabled {
    background: #9ca3af;
    cursor: not-allowed;
    transform: none;
}

.auth-privacy-note {
    font-size: 12px;
    color: #9ca3af;
    margin-top: 16px;
}

.auth-privacy-note a {
    color: #29e775;
    text-decoration: none;
}

.auth-privacy-note a:hover {
    text-decoration: underline;
}

/* Conversation History */
.conversation-history {
    display: none;
    flex-direction: column;
    height: 100%;
}

.conversation-history.active {
    display: flex;
}

.history-header {
    padding: 20px 24px;
    background: #f9fafb;
    border-bottom: 1px solid #e5e7eb;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.history-header h3 {
    font-size: 18px;
    font-weight: 600;
    color: #1f2937;
}

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

.new-chat-btn {
    padding: 8px 16px;
    background: #29e775;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.new-chat-btn:hover {
    background: #1fb85e;
}

.logout-btn {
    padding: 8px 16px;
    background: transparent;
    color: #6b7280;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 6px;
}

.logout-btn:hover {
    background: #f3f4f6;
    color: #ef4444;
    border-color: #ef4444;
}

.logout-btn svg {
    width: 16px;
    height: 16px;
}

.history-list {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.history-item {
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 16px;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.history-item:hover {
    border-color: #29e775;
    box-shadow: 0 4px 12px rgba(41, 231, 117, 0.15);
    transform: translateY(-1px);
}

.history-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.history-item-date {
    font-size: 13px;
    color: #6b7280;
    font-weight: 500;
}

.history-item-messages {
    font-size: 12px;
    color: #29e775;
    background: rgba(41, 231, 117, 0.1);
    padding: 2px 8px;
    border-radius: 12px;
    font-weight: 500;
}

.history-item-preview {
    font-size: 14px;
    color: #4b5563;
    line-height: 1.5;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
}

.empty-history {
    text-align: center;
    padding: 60px 20px;
}

.empty-history-icon {
    font-size: 48px;
    margin-bottom: 16px;
    opacity: 0.3;
}

.empty-history p {
    font-size: 16px;
    color: #9ca3af;
}

/* User info badge */
.user-info-badge {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 20px;
    background: linear-gradient(135deg, rgba(41, 231, 117, 0.1) 0%, rgba(31, 184, 94, 0.1) 100%);
    border-radius: 12px;
    margin: 16px;
    margin-bottom: 20px;
    border: 1px solid rgba(41, 231, 117, 0.2);
}

.user-info-badge svg {
    width: 20px;
    height: 20px;
    color: #1fb85e;
    flex-shrink: 0;
}

.user-details {
    display: flex;
    flex-direction: column;
    gap: 2px;
    text-align: left;
}

.user-name {
    font-size: 14px;
    font-weight: 600;
    color: #1f2937;
}

.user-company {
    font-size: 13px;
    color: #6b7280;
}

.user-email {
    font-size: 12px;
    color: #9ca3af;
}

/* Loading state */
.chat-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 200px;
}

.chat-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid #e5e7eb;
    border-top-color: #29e775;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Transitions between screens */
.chat-screen {
    display: none;
    animation: fadeIn 0.3s ease-out;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: white;
    z-index: 1;
}

.chat-screen.active {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    z-index: 10;
}

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

/* Responsive adjustments for auth screen */
@media (max-width: 768px) {
    .chat-auth-screen {
        padding: 24px;
    }
    
    .chat-auth-screen h2 {
        font-size: 20px;
    }
    
    .chat-auth-screen p {
        font-size: 14px;
    }
}

/* Dark mode for new elements */
@media (prefers-color-scheme: dark) {
    .chat-auth-screen h2 {
        color: #f9fafb;
    }
    
    .chat-auth-screen p {
        color: #9ca3af;
    }
    
    .auth-form-group label {
        color: #e5e7eb;
    }
    
    .auth-form-input {
        background: #374151;
        border-color: #4b5563;
        color: #f9fafb;
    }
    
    .auth-form-input:focus {
        border-color: #29e775;
    }
    
    .history-header {
        background: #1f2937;
        border-color: #374151;
    }
    
    .history-header h3 {
        color: #f9fafb;
    }
    
    .history-list {
        background: #111827;
    }
    
    .history-item {
        background: #1f2937;
        border-color: #374151;
    }
    
    .history-item:hover {
        border-color: #29e775;
    }
    
    .history-item-preview {
        color: #e5e7eb;
    }
    
    .user-info-badge {
        background: linear-gradient(135deg, rgba(41, 231, 117, 0.05) 0%, rgba(31, 184, 94, 0.05) 100%);
        border-color: rgba(41, 231, 117, 0.1);
    }
    
    .user-info-badge svg {
        color: #29e775;
    }
    
    .user-name {
        color: #f9fafb;
    }
    
    .user-company {
        color: #d1d5db;
    }
    
    .user-email {
        color: #9ca3af;
    }
    
    .history-item-date {
        color: #d1d5db;
    }
    
    .history-item-messages {
        background: rgba(41, 231, 117, 0.15);
        color: #4ade80;
    }
    
    .logout-btn {
        color: #d1d5db;
        border-color: #374151;
    }
    
    .logout-btn:hover {
        background: rgba(239, 68, 68, 0.1);
        color: #ef4444;
        border-color: #ef4444;
    }
    
    .header-buttons {
        gap: 12px;
    }
}

/* Scrollbar styling for history list */
.history-list::-webkit-scrollbar {
    width: 6px;
}

.history-list::-webkit-scrollbar-track {
    background: transparent;
}

.history-list::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 3px;
}

.history-list::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* Dark mode for chat screens */
@media (prefers-color-scheme: dark) {
    .chat-screen {
        background: #1f2937;
    }
} 