/* Chat Widget Styles */
.chat-widget {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 1000;
}

.chat-toggle {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(45deg, #1f4cca, #309bff);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    color: white;
    box-shadow: 0 4px 20px rgba(0,0,0,0.3);
    transition: all 0.3s ease;
}

.chat-toggle:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 25px rgba(0,0,0,0.4);
}

.chat-container {
    position: absolute;
    bottom: 80px;
    right: 0;
    width: 400px;
    height: 600px;
    background: white;
    border-radius: 20px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
    display: none;
    flex-direction: column;
    overflow: hidden;
    min-width: 350px;
    min-height: 400px;
    max-width: 800px;
    max-height: 80vh;
    transition: all 0.3s;
    z-index: 2001;
}

.chat-container.active {
    display: flex;
    animation: slideUp 0.3s ease;
}

/* Fullscreen mode */
.chat-container.fullscreen {
    position: fixed !important;
    top: 80px; /* Height of navbar (adjust if your navbar is taller) */
    left: 0;
    right: 0;
    width: 100vw !important;
    height: calc(100vh - 80px) !important;
    min-width: 0;
    min-height: 0;
    max-width: 100vw;
    max-height: calc(100vh - 80px);
    border-radius: 0;
    z-index: 3000;
}

.chat-header {
    background: linear-gradient(45deg, #667eea, #764ba2);
    color: white;
    padding: 15px 20px;
    text-align: center;
    font-weight: bold;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: move;
    position: relative;
}

.chat-actions {
    display: flex;
    gap: 10px;
    align-items: center;
}

.chat-close, .chat-expand {
    background: none;
    border: none;
    color: #fff;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0 6px;
    transition: color 0.2s;
}
.chat-close:hover { color: #d00; }
.chat-expand:hover { color: #0af; }

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.message {
    max-width: 80%;
    padding: 12px 16px;
    border-radius: 18px;
    word-wrap: break-word;
    animation: fadeIn 0.3s ease;
}

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

.message.user {
    background: linear-gradient(45deg, #667eea, #764ba2);
    color: white;
    align-self: flex-end;
    margin-left: auto;
}

.message.ai {
    background: #f1f3f4;
    color: #333;
    align-self: flex-start;
}

.message.ai h1, .message.ai h2, .message.ai h3 {
    margin: 10px 0 5px 0;
    color: #667eea;
}

.message.ai p {
    margin: 5px 0;
    line-height: 1.5;
}

.message.ai ul, .message.ai ol {
    margin: 10px 0;
    padding-left: 20px;
}

.message.ai li {
    margin: 5px 0;
}

.message.ai code {
    background: #e8e8e8;
    padding: 2px 4px;
    border-radius: 4px;
    font-family: 'Courier New', monospace;
}

.message.ai pre {
    background: #f5f5f5;
    padding: 10px;
    border-radius: 8px;
    margin: 10px 0;
    overflow-x: auto;
}

.message.ai blockquote {
    border-left: 4px solid #667eea;
    margin: 10px 0;
    padding: 10px 15px;
    background: #f9f9f9;
}

.chat-input-container {
    padding: 20px;
    border-top: 1px solid #eee;
    display: flex;
    gap: 10px;
}

.chat-input {
    flex: 1;
    padding: 12px 16px;
    border: 1px solid #ddd;
    border-radius: 25px;
    outline: none;
    font-size: 14px;
}

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

.send-btn {
    padding: 12px 20px;
    background: linear-gradient(45deg, #667eea, #764ba2);
    color: white;
    border: none;
    border-radius: 25px;
    cursor: pointer;
    font-weight: bold;
    transition: all 0.3s ease;
}

.send-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
}

.send-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.typing-indicator {
    display: none;
    padding: 12px 16px;
    background: #f1f3f4;
    border-radius: 18px;
    align-self: flex-start;
    max-width: 80%;
}

.typing-dots {
    display: inline-flex;
    gap: 4px;
}

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

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

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

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

.api-key-prompt {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}

.api-key-modal {
    background: white;
    padding: 30px;
    border-radius: 20px;
    max-width: 400px;
    width: 90%;
    text-align: center;
}

.api-key-modal h3 {
    margin-bottom: 20px;
    color: #333;
}

.api-key-modal input {
    width: 100%;
    padding: 12px;
    border: 1px solid #ddd;
    border-radius: 10px;
    margin-bottom: 20px;
    font-size: 14px;
}

.api-key-modal button {
    padding: 12px 30px;
    background: linear-gradient(45deg, #667eea, #764ba2);
    color: white;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    font-weight: bold;
}

.loading-indicator {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(255, 255, 255, 0.9);
    padding: 20px;
    border-radius: 10px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.1);
    display: none;
    z-index: 3000;
}

@media (max-width: 768px) {
    .chat-container {
        width: 99vw;
        max-width: 80vw;
        height: 80vh;
        max-height: calc(80vh - 80px);
        border-radius: 0;
    }
    .chat-container.fullscreen {
        top: 56px;
        width: 100vw !important;
        height: calc(100vh - 56px) !important;
        border-radius: 0;
    }
}

/* =====================
    Chat AI - Dark Mode
===================== */
body.dark-mode .chat-container {
    background: #1a1a2e;
    color: #e2e8f0;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6);
}

body.dark-mode .chat-header {
    background: linear-gradient(45deg, #8b5cf6, #ec4899);
    color: white;
}

body.dark-mode .chat-toggle {
    background: linear-gradient(45deg, #8b5cf6, #ec4899);
    color: white;
}

body.dark-mode .chat-container .message.user {
    background: linear-gradient(45deg, #8b5cf6, #ec4899);
    color: white;
}

body.dark-mode .chat-container .message.ai {
    background: #2a2a40;
    color: #e2e8f0;
}

body.dark-mode .chat-container .message.ai h1,
body.dark-mode .chat-container .message.ai h2,
body.dark-mode .chat-container .message.ai h3 {
    color: #8b5cf6;
}

body.dark-mode .chat-container .message.ai code {
    background: #383859;
    color: #e2e8f0;
}

body.dark-mode .chat-container .message.ai pre {
    background: #2f2f4f;
    color: #e2e8f0;
}

body.dark-mode .chat-container .message.ai blockquote {
    background: #26263f;
    border-left: 4px solid #8b5cf6;
    color: #d1d5db;
}

body.dark-mode .chat-input-container {
    border-top: 1px solid #333;
    background: #1a1a2e;
}

body.dark-mode .chat-input {
    background: #2a2a40;
    color: #e2e8f0;
    border-color: #444;
}

body.dark-mode .chat-input:focus {
    border-color: #8b5cf6;
}

body.dark-mode .send-btn {
    background: linear-gradient(45deg, #8b5cf6, #ec4899);
}

body.dark-mode .typing-indicator {
    background: #2a2a40;
    color: #ccc;
}

body.dark-mode .typing-dots span {
    background: #aaa;
}

body.dark-mode .api-key-modal {
    background: #1a1a2e;
    color: #e2e8f0;
}

body.dark-mode .api-key-modal input {
    background: #2a2a40;
    color: #e2e8f0;
    border-color: #444;
}

body.dark-mode .api-key-modal button {
    background: linear-gradient(45deg, #8b5cf6, #ec4899);
}

body.dark-mode .loading-indicator {
    background: rgba(26, 26, 46, 0.95);
    color: #e2e8f0;
}
