/* 
 * Modern Chatbox Styles for Co-Pilot Assistant
 */

 html, body {
    width: 100%;
    height: 100%;
    margin: 0;
    padding: 0;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: #f8f9fa;
    overflow: hidden;
}

/* Sideload message */
.sideload-message {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100vh;
    padding: 20px;
    text-align: center;
    background: #f8f9fa;
}

/* Chat container */
.chat-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    background: #ffffff;
}

/* Chat header */
.chat-header {
    background: #0078d7;
    color: white;
    padding: 12px 16px;
    border-bottom: 1px solid #e1e5e9;
    flex-shrink: 0;
}

/* View information */
.view-info {
    background: #f8f9fa;
    border-bottom: 1px solid #e1e5e9;
    padding: 8px 16px;
    flex-shrink: 0;
}

.view-name {
    font-size: 14px;
    font-weight: 600;
    color: #323130;
    margin-bottom: 4px;
}

.custom-content {
    font-size: 12px;
    color: #605e5c;
    line-height: 1.4;
}

.custom-content p {
    margin: 0;
    padding: 0;
}

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

.chat-title {
    font-size: 18px;
    font-weight: 600;
    margin: 0;
    flex: 1;
}

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

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

.status-dot.online {
    background: #4caf50;
}

.status-dot.offline {
    background: #f44336;
    animation: none;
}

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

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

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

/* Message styles */
.message {
    display: flex;
    gap: 12px;
    max-width: 80%;
    animation: fadeIn 0.3s ease-in;
}

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

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

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

.system-message {
    align-self: flex-start;
    max-width: 95%;
}

.message-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    overflow: hidden;
    flex-shrink: 0;
}

.message-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.message-content {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.message-text {
    padding: 12px 16px;
    border-radius: 18px;
    font-size: 14px;
    line-height: 1.4;
    word-wrap: break-word;
}

.user-message .message-text {
    background: #0078d7;
    color: white;
    border-bottom-right-radius: 4px;
}

.bot-message .message-text {
    background: white;
    color: #323130;
    border: 1px solid #e1e5e9;
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.system-message .message-text {
    background: #f0f8ff;
    color: #1976d2;
    border: 1px solid #bbdefb;
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
    font-family: 'Courier New', monospace;
    font-size: 13px;
    line-height: 1.3;
}

.message-time {
    font-size: 11px;
    color: #605e5c;
    margin: 0 4px;
}

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

.system-message .message-avatar {
    background: #e3f2fd;
    border: 2px solid #bbdefb;
}

.system-message .message-avatar img {
    opacity: 0.8;
}

/* Chat input area */
.chat-input-container {
    background: white;
    border-top: 1px solid #e1e5e9;
    padding: 16px;
    flex-shrink: 0;
}

.input-wrapper {
    display: flex;
    gap: 8px;
    align-items: flex-end;
    background: #f8f9fa;
    border: 1px solid #e1e5e9;
    border-radius: 20px;
    padding: 8px 12px;
    transition: border-color 0.2s ease;
}

.input-wrapper:focus-within {
    border-color: #0078d7;
    box-shadow: 0 0 0 1px #0078d7;
}

.message-input {
    flex: 1;
    border: none;
    background: transparent;
    resize: none;
    font-size: 14px;
    font-family: inherit;
    line-height: 1.4;
    max-height: 120px;
    min-height: 20px;
    outline: none;
    padding: 4px 0;
}

.message-input::placeholder {
    color: #605e5c;
}

/* Send button */
.send-button {
    background: #0078d7;
    border: none;
    border-radius: 50%;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    color: white;
    flex-shrink: 0;
}

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

.send-button:active {
    background: #005a9e;
    transform: scale(0.95);
}

.send-button:disabled {
    background: #c8c6c4;
    cursor: not-allowed;
    transform: none;
}

.send-button svg {
    width: 16px;
    height: 16px;
}

.input-footer {
    margin-top: 8px;
    text-align: center;
}

.input-hint {
    font-size: 11px;
    color: #605e5c;
}

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

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

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

.chat-messages::-webkit-scrollbar-thumb:hover {
    background: #a19f9d;
}

/* Typing indicator */
.typing-dots {
    display: flex;
    gap: 4px;
    align-items: center;
    padding: 12px 16px !important;
}

.typing-dots span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #605e5c;
    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;
    }
}

/* Error message styles */
.error-message .message-text {
    background: #ffebee;
    color: #c62828;
    border: 1px solid #ffcdd2;
}

/* Streaming message styles */
.message-text.streaming {
    position: relative;
}

.message-text.streaming::after {
    content: '▋';
    animation: blink 1s infinite;
    color: #0078d7;
    margin-left: 2px;
}

@keyframes blink {
    0%, 50% { opacity: 1; }
    51%, 100% { opacity: 0; }
}

/* Responsive design */
@media (max-width: 320px) {
    .message {
        max-width: 90%;
    }
    
    .chat-title {
        font-size: 16px;
    }
    
    .message-text {
        padding: 10px 12px;
        font-size: 13px;
    }
}

/* Project Information Styles */
.project-info {
    background: #f8f9fa;
    border-bottom: 1px solid #e1e5e9;
    padding: 12px 16px;
    margin: 0;
    flex-shrink: 0;
}

.project-info-content {
    margin-bottom: 8px;
}

.project-info h4 {
    margin: 0 0 8px 0;
    font-size: 14px;
    font-weight: 600;
    color: #323130;
    display: flex;
    align-items: center;
    gap: 6px;
}

.project-stats {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 8px;
}

.stat {
    background: #e3f2fd;
    color: #1976d2;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 500;
    white-space: nowrap;
}

.progress-bar {
    position: relative;
    background: #e1e5e9;
    border-radius: 4px;
    height: 16px;
    margin: 4px 0;
    overflow: hidden;
}

.progress-fill {
    background: linear-gradient(90deg, #4caf50, #8bc34a);
    height: 100%;
    border-radius: 4px;
    transition: width 0.3s ease;
}

.progress-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 10px;
    font-weight: 600;
    color: #323130;
    text-shadow: 0 1px 2px rgba(255, 255, 255, 0.8);
}

.warning {
    background: #fff3cd;
    color: #856404;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 500;
    margin-top: 4px;
    border-left: 3px solid #ffc107;
}


/* Responsive adjustments for project info */
@media (max-width: 400px) {
    .project-stats {
        flex-direction: column;
        gap: 4px;
    }
    
    .stat {
        font-size: 10px;
        padding: 1px 4px;
    }
    
    .project-info h4 {
        font-size: 13px;
    }
}

/* Document Change Notification Styles */
.document-change-notification {
    background: linear-gradient(135deg, #0078d7, #106ebe);
    color: white;
    padding: 8px 16px;
    border-radius: 0;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    animation: slideDown 0.3s ease-out;
    position: relative;
    z-index: 1000;
}

.notification-content {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
}

.notification-icon {
    font-size: 14px;
}

.notification-text {
    flex: 1;
    font-weight: 500;
}


@keyframes slideDown {
    from {
        transform: translateY(-100%);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* Enhanced project info for active document */
.project-info.active-document {
    background: linear-gradient(135deg, #f8f9fa, #e9ecef);
    border-left: 4px solid #0078d7;
}

.project-info.active-document h4::before {
    content: "📄 ";
    margin-right: 4px;
}

.project-info.active-document .document-status {
    display: inline-block;
    background: #28a745;
    color: white;
    padding: 2px 6px;
    border-radius: 12px;
    font-size: 10px;
    font-weight: 600;
    margin-left: 8px;
    animation: pulse 2s infinite;
}

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

/* Download Button Styles */
.download-section {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid #e1e5e9;
}

.download-button-container {
    display: flex;
    justify-content: center;
}

.download-button {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: #0078d7;
    color: white;
    text-decoration: none;
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s ease;
    border: none;
    cursor: pointer;
}

.download-button:hover {
    background: #106ebe;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0, 120, 215, 0.3);
}

.download-button:active {
    transform: translateY(0);
    box-shadow: 0 1px 2px rgba(0, 120, 215, 0.3);
}

.download-button svg {
    width: 16px;
    height: 16px;
}

/* Token Usage Styles */
.token-usage-info {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid #e1e5e9;
}

.token-stats {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    justify-content: center;
    font-size: 12px;
}

.token-stat {
    background: #f8f9fa;
    color: #323130;
    padding: 4px 8px;
    border-radius: 4px;
    border: 1px solid #e1e5e9;
    white-space: nowrap;
}

.token-stat strong {
    color: #0078d7;
}

/* Enhanced Error Message Styles */
.error-message .message-text {
    background: #ffebee;
    color: #c62828;
    border: 1px solid #ffcdd2;
    border-left: 4px solid #f44336;
}

.error-message .message-text::before {
    content: "⚠️ ";
    margin-right: 4px;
}

/* Success Message Styles */
.success-message .message-text {
    background: #e8f5e8;
    color: #2e7d32;
    border: 1px solid #c8e6c9;
    border-left: 4px solid #4caf50;
}

.success-message .message-text::before {
    content: "✅ ";
    margin-right: 4px;
}

/* Info Message Styles */
.info-message .message-text {
    background: #e3f2fd;
    color: #1976d2;
    border: 1px solid #bbdefb;
    border-left: 4px solid #2196f3;
}

.info-message .message-text::before {
    content: "ℹ️ ";
    margin-right: 4px;
}

/* Responsive adjustments for new elements */
@media (max-width: 400px) {
    .token-stats {
        flex-direction: column;
        gap: 6px;
    }
    
    .token-stat {
        font-size: 11px;
        padding: 3px 6px;
    }
    
    .download-button {
        font-size: 13px;
        padding: 6px 12px;
    }
}