/* Feedback Chat Widget Styles */
.feedback-chat-widget {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 9999;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

/* Main button */
.feedback-chat-button {
    background: #0d6efd;
    color: white;
    border: none;
    border-radius: 50px;
    padding: 12px 20px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(13, 110, 253, 0.3);
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 8px;
}

.feedback-chat-button:hover {
    background: #0b5ed7;
    box-shadow: 0 6px 20px rgba(13, 110, 253, 0.4);
    transform: translateY(-2px);
}

.feedback-chat-button i {
    font-size: 18px;
}

/* Chat window */
.feedback-chat-window {
    position: absolute;
    bottom: 70px;
    right: 0;
    width: 380px;
    height: 500px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 5px 40px rgba(0, 0, 0, 0.16);
    display: flex;
    flex-direction: column;
    opacity: 0;
    transform: scale(0.9) translateY(20px);
    pointer-events: none;
    transition: all 0.3s ease;
}

.feedback-chat-window.open {
    opacity: 1;
    transform: scale(1) translateY(0);
    pointer-events: all;
}

/* Header */
.feedback-chat-header {
    background: #0d6efd;
    color: white;
    padding: 16px 20px;
    border-radius: 12px 12px 0 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.feedback-chat-header h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    flex: 1;
}

.feedback-chat-status {
    font-size: 12px;
    margin-right: 12px;
    opacity: 0.8;
}

.feedback-chat-status.reconnecting {
    color: #ffc107;
}

.feedback-chat-status.disconnected {
    color: #dc3545;
}

.feedback-chat-close {
    background: none;
    border: none;
    color: white;
    font-size: 20px;
    cursor: pointer;
    padding: 0;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: background 0.2s;
}

.feedback-chat-close:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* Body */
.feedback-chat-body {
    flex: 1;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.feedback-chat-content {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
}

/* Menu */
.feedback-menu {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.feedback-menu-intro {
    margin: 0 0 8px 0;
    color: #495057;
    font-size: 14px;
}

.feedback-menu-item {
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    padding: 16px;
    display: flex;
    align-items: center;
    gap: 16px;
    cursor: pointer;
    transition: all 0.2s;
    text-align: left;
}

.feedback-menu-item:hover {
    background: #e9ecef;
    border-color: #dee2e6;
    transform: translateX(4px);
}

.feedback-menu-item i {
    font-size: 24px;
    color: #0d6efd;
    flex-shrink: 0;
}

.feedback-menu-item strong {
    display: block;
    color: #212529;
    font-weight: 600;
    font-size: 14px;
    margin-bottom: 2px;
}

.feedback-menu-item small {
    display: block;
    color: #6c757d;
    font-size: 12px;
}

/* Feedback form */
.feedback-form {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.feedback-back-btn {
    background: none;
    border: none;
    color: #6c757d;
    font-size: 14px;
    cursor: pointer;
    padding: 0;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 4px;
    transition: color 0.2s;
}

.feedback-back-btn:hover {
    color: #495057;
}

.feedback-form h4 {
    margin: 0 0 16px 0;
    font-size: 18px;
    font-weight: 600;
    color: #212529;
}

.feedback-textarea {
    flex: 1;
    width: 100%;
    padding: 12px;
    border: 1px solid #ced4da;
    border-radius: 6px;
    font-size: 14px;
    resize: none;
    font-family: inherit;
    transition: border-color 0.2s;
}

.feedback-textarea:focus {
    outline: none;
    border-color: #0d6efd;
    box-shadow: 0 0 0 0.2rem rgba(13, 110, 253, 0.25);
}

.feedback-form-footer {
    margin-top: 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.feedback-char-count {
    font-size: 12px;
    color: #6c757d;
}

.feedback-submit-btn {
    padding: 8px 20px;
    font-size: 14px;
    font-weight: 500;
}

/* Chat view */
.feedback-chat-view {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.feedback-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 12px 0;
}

.feedback-system-message {
    background: #f8f9fa;
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 12px;
    display: flex;
    gap: 12px;
}

.feedback-system-message i {
    font-size: 24px;
    color: #0d6efd;
    flex-shrink: 0;
}

.feedback-system-message p {
    margin: 0;
    font-size: 14px;
    color: #495057;
    line-height: 1.5;
}

/* Messages */
.feedback-message {
    margin-bottom: 12px;
    padding: 12px;
    border-radius: 8px;
    background: #f8f9fa;
}

.feedback-message-time {
    font-size: 11px;
    color: #6c757d;
    display: block;
    margin-bottom: 4px;
}

.feedback-message p {
    margin: 0;
    font-size: 14px;
    color: #212529;
}

/* Markdown formatting for chat messages */
.feedback-message .message-content {
    font-size: 14px;
    color: #212529;
    line-height: 1.5;
}

.feedback-message .message-content strong {
    font-weight: 600;
    color: #0d6efd;
}

.feedback-message .message-content code {
    background: #e9ecef;
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'Monaco', 'Consolas', 'Courier New', monospace;
    font-size: 13px;
    color: #e83e8c;
}

.feedback-message .message-content ul,
.feedback-message .message-content ol {
    margin: 8px 0;
    padding-left: 20px;
}

.feedback-message .message-content li {
    margin: 4px 0;
}

.feedback-message .message-content ul li {
    list-style-type: disc;
}

.feedback-message .message-content ol li {
    list-style-type: decimal;
}

/* System notifications */
.feedback-system-notification {
    position: absolute;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: white;
    padding: 12px 20px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    animation: slideDown 0.3s ease;
}

.feedback-system-notification.success {
    color: #198754;
    border: 1px solid #d1e7dd;
    background: #d1e7dd;
}

.feedback-system-notification.error {
    color: #dc3545;
    border: 1px solid #f8d7da;
    background: #f8d7da;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

/* Mobile responsiveness */
@media (max-width: 480px) {
    .feedback-chat-window {
        width: 100%;
        height: 100%;
        bottom: 0;
        right: 0;
        border-radius: 0;
        max-height: 100vh;
    }
    
    .feedback-chat-window.open {
        transform: none;
    }
    
    .feedback-chat-header {
        border-radius: 0;
    }
    
    .feedback-chat-button {
        bottom: 10px;
        right: 10px;
    }
}

/* Streaming message styles */
.assistant-message.streaming .message-content {
    position: relative;
}

.assistant-message.streaming .message-content::after {
    content: '▎';
    animation: blink 1s infinite;
    margin-left: 2px;
    color: #0d6efd;
}

@keyframes blink {
    0%, 50% { opacity: 1; }
    51%, 100% { opacity: 0; }
}

/* Typing indicator */
.typing-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 15px;
    margin: 5px 0;
    background: #f8f9fa;
    border-radius: 15px;
    font-size: 13px;
    color: #6c757d;
}

.typing-dots {
    display: flex;
    gap: 3px;
}

.typing-dots span {
    width: 6px;
    height: 6px;
    background: #6c757d;
    border-radius: 50%;
    animation: typing 1.4s infinite ease-in-out;
}

.typing-dots span:nth-child(1) { animation-delay: -0.32s; }
.typing-dots span:nth-child(2) { animation-delay: -0.16s; }

@keyframes typing {
    0%, 80%, 100% {
        transform: scale(0.8);
        opacity: 0.5;
    }
    40% {
        transform: scale(1);
        opacity: 1;
    }
}

/* Assistant message styling */
.assistant-message {
    background: #e3f2fd;
    border: 1px solid #bbdefb;
}

.assistant-message .message-header {
    color: #1976d2;
    font-weight: 600;
}

/* Hide on mobile if specified */
@media (max-width: 767px) {
    .feedback-chat-widget {
        display: none;
    }
}

/* Chat input area */
.feedback-chat-input {
    display: flex;
    gap: 8px;
    padding: 12px;
    border-top: 1px solid #e9ecef;
    background: #f8f9fa;
    border-radius: 0 0 12px 12px;
}

.feedback-chat-textarea {
    flex: 1;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    padding: 8px 12px;
    font-size: 14px;
    resize: none;
    font-family: inherit;
    line-height: 1.5;
    transition: border-color 0.15s ease;
}

.feedback-chat-textarea:focus {
    outline: none;
    border-color: #0d6efd;
}

.feedback-chat-send {
    background: #0d6efd;
    color: white;
    border: none;
    border-radius: 8px;
    padding: 8px 16px;
    cursor: pointer;
    transition: background 0.15s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.feedback-chat-send:hover:not(:disabled) {
    background: #0b5ed7;
}

.feedback-chat-send:disabled {
    background: #6c757d;
    cursor: not-allowed;
    opacity: 0.6;
}

.feedback-chat-send i {
    font-size: 16px;
}

/* User and assistant messages */
.feedback-message.user {
    background: #0d6efd;
    color: white;
    margin-left: 20%;
    margin-right: 12px;
}

.feedback-message.user .feedback-message-time {
    color: rgba(255, 255, 255, 0.8);
}

.feedback-message.user p {
    color: white;
}

.feedback-message.assistant {
    background: #f8f9fa;
    margin-right: 20%;
    margin-left: 12px;
}

.feedback-message.streaming .message-content::after {
    content: '▌';
    animation: blink 1s infinite;
}

/* Update typing indicator styles */
.feedback-typing-indicator {
    display: none;
    align-items: center;
    gap: 8px;
    padding: 12px;
    margin: 0 12px 12px 12px;
    background: #f8f9fa;
    border-radius: 8px;
    color: #6c757d;
    font-size: 14px;
}

.feedback-typing-indicator i {
    animation: blink 1.5s infinite;
}

/* Streaming message cursor animation */
@keyframes blink {
    0%, 50% { opacity: 1; }
    51%, 100% { opacity: 0; }
}