/* AI Chat Widget Styles */

/* ============================================
   FLOATING BUTTON (Minimized State)
   ============================================ */

.chat-widget-button {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 60px;
    height: 60px;
    background: linear-gradient(135deg, #3b82f6 0%, #06b6d4 100%);
    border-radius: 50%;
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.4);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9998;
    transition: all 0.3s ease;
    border: none;
}

.chat-widget-button:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(59, 130, 246, 0.6);
}

.chat-widget-button:active {
    transform: scale(0.95);
}

.chat-widget-button-icon {
    font-size: 28px;
    color: white;
}

/* Notification badge */
.chat-widget-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #ef4444;
    color: white;
    border-radius: 12px;
    padding: 2px 8px;
    font-size: 12px;
    font-weight: bold;
    min-width: 20px;
    text-align: center;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

/* Pulse animation for new messages */
@keyframes pulse {
    0% {
        box-shadow: 0 4px 12px rgba(59, 130, 246, 0.4);
    }
    50% {
        box-shadow: 0 4px 20px rgba(59, 130, 246, 0.8);
    }
    100% {
        box-shadow: 0 4px 12px rgba(59, 130, 246, 0.4);
    }
}

.chat-widget-button.has-notification {
    animation: pulse 2s infinite;
}

/* ============================================
   CHAT WINDOW (Expanded State)
   ============================================ */

.chat-widget-window {
    position: fixed;
    bottom: 90px;
    right: 20px;
    width: 450px;  /* Increased from 400px */
    height: 650px;  /* Increased from 600px */
    background: white;
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
    display: none;
    flex-direction: column;
    z-index: 9999;
    overflow: hidden;
    transition: width 0.3s ease, height 0.3s ease;
}

.chat-widget-window.show {
    display: flex;
}

/* Large size mode - expands to the LEFT to stay on screen */
.chat-widget-window.size-large {
    width: 650px;
    height: 800px;
    max-height: calc(100vh - 100px);
    /* Note: dragging will override right/left positioning */
}

/* Header */
.chat-widget-header {
    background: linear-gradient(135deg, #3b82f6 0%, #06b6d4 100%);
    color: white;
    padding: 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: move;
    user-select: none;
}

.chat-widget-title {
    font-size: 17px;  /* Increased from 16px */
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
}

.chat-widget-controls {
    display: flex;
    gap: 8px;
}

.chat-widget-control-btn {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    width: 28px;
    height: 28px;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    transition: background 0.2s;
}

.chat-widget-control-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* Messages area */
.chat-widget-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    background: #f9fafb;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.chat-widget-messages::-webkit-scrollbar {
    width: 8px;
}

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

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

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

/* Welcome message */
.chat-widget-welcome {
    text-align: center;
    padding: 40px 20px;
    color: #64748b;
}

.chat-widget-welcome-icon {
    font-size: 48px;
    margin-bottom: 16px;
}

.chat-widget-welcome h3 {
    font-size: 20px;  /* Increased from 18px */
    font-weight: 600;
    color: #1e293b;
    margin-bottom: 8px;
}

.chat-widget-welcome p {
    font-size: 15px;  /* Increased from 14px */
    line-height: 1.6;
}

/* Message bubbles */
.chat-message {
    display: flex;
    flex-direction: column;
    max-width: 85%;
    animation: slideIn 0.3s ease;
}

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

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

.chat-message-row {
    display: flex;
    gap: 8px;
}

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

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

.chat-message.user .chat-message-avatar {
    background: #667eea;
    color: white;
}

.chat-message.assistant .chat-message-avatar {
    background: #eff6ff;
    color: #3b82f6;
}

.chat-message-content {
    background: white;
    padding: 12px 16px;
    border-radius: 12px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
    font-size: 15px;  /* Increased from 14px */
    line-height: 1.6;  /* Increased from 1.5 */
    color: #1e293b;
}

.chat-message.user .chat-message-content {
    background: #3b82f6;
    color: white;
}

.chat-message.assistant .chat-message-content {
    background: white;
    border: 1px solid #e2e8f0;
}

/* Message feedback buttons */
.chat-message-feedback {
    display: flex;
    gap: 8px;
    margin-top: 8px;
    padding-left: 40px;
}

.feedback-btn {
    background: white;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    padding: 6px 14px;
    font-size: 20px;
    cursor: pointer;
    transition: all 0.2s ease;
    opacity: 0.7;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.feedback-btn:hover:not(:disabled) {
    opacity: 1;
    border-color: #3b82f6;
    transform: scale(1.15);
    box-shadow: 0 2px 6px rgba(59, 130, 246, 0.2);
}

.feedback-btn:disabled {
    cursor: not-allowed;
    opacity: 0.3;
}

.feedback-btn.feedback-selected {
    opacity: 1;
    background: #eff6ff;
    border-color: #3b82f6;
    box-shadow: 0 2px 6px rgba(59, 130, 246, 0.3);
}

/* Feedback followup */
.feedback-followup {
    background: #fef3c7 !important;
    border-left: 4px solid #f59e0b !important;
}

.feedback-options {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.feedback-options label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 14px;
}

.feedback-options input[type="checkbox"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
}

.feedback-detail-input {
    width: 100%;
    padding: 8px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-family: inherit;
    font-size: 14px;
    resize: vertical;
}

.feedback-retry-btn,
.feedback-skip-btn {
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.feedback-retry-btn {
    background: #667eea;
    color: white;
    border: none;
}

.feedback-retry-btn:hover {
    background: #5568d3;
    transform: translateY(-1px);
}

.feedback-skip-btn {
    background: white;
    color: #6b7280;
    border: 1px solid #d1d5db;
    margin-left: 8px;
}

.feedback-skip-btn:hover {
    background: #f3f4f6;
}

/* Typing indicator */
.chat-typing-indicator {
    display: none;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    background: white;
    border-radius: 12px;
    max-width: 80px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.chat-typing-indicator.show {
    display: flex;
}

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

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

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

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

/* Input area */
.chat-widget-input {
    padding: 16px;
    border-top: 1px solid #e2e8f0;
    background: white;
}

.chat-input-form {
    display: flex;
    gap: 8px;
}

.chat-input-textarea {
    flex: 1;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 10px 12px;
    font-size: 15px;  /* Increased from 14px */
    font-family: inherit;
    resize: none;
    max-height: 100px;
    overflow-y: auto;
    transition: border-color 0.2s;
}

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

.chat-input-textarea::placeholder {
    color: #94a3b8;
}

.chat-send-btn {
    background: #667eea;
    border: none;
    color: white;
    width: 40px;
    height: 40px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    transition: background 0.2s;
    flex-shrink: 0;
}

.chat-send-btn:hover:not(:disabled) {
    background: #5568d3;
}

.chat-send-btn:disabled {
    background: #cbd5e1;
    cursor: not-allowed;
}

/* Connection status */
.chat-status-indicator {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: #64748b;
    padding: 8px 16px;
    background: #f1f5f9;
    border-top: 1px solid #e2e8f0;
}

.chat-status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #10b981;
}

.chat-status-dot.disconnected {
    background: #ef4444;
}

.chat-status-dot.connecting {
    background: #f59e0b;
    animation: pulse 1s infinite;
}

/* ============================================
   RESPONSIVE DESIGN
   ============================================ */

@media (max-width: 768px) {
    .chat-widget-window {
        right: 10px;
        bottom: 80px;
        width: calc(100vw - 20px);
        max-width: 450px;  /* Updated */
        height: 550px;  /* Updated */
    }
    
    .chat-widget-window.size-large {
        max-width: calc(100vw - 20px);
        height: calc(100vh - 100px);
    }
    
    .chat-widget-button {
        right: 10px;
        bottom: 10px;
    }
}

/* ============================================
   ENLARGED MODE (Future Enhancement)
   ============================================ */

.chat-widget-window.enlarged {
    width: 600px;
    height: 800px;
}

/* ============================================
   UTILITY CLASSES
   ============================================ */

.hidden {
    display: none !important;
}

.fade-in {
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}
