/* AI Side Panel Styles */
.ai-panel {
    position: fixed;
    top: 0;
    right: -400px; /* Hidden by default */
    width: 350px;
    height: 100vh;
    background-color: #1e1e1e;
    border-left: 1px solid #333;
    z-index: 1000;
    transition: right 0.3s ease-in-out;
    display: flex;
    flex-direction: column;
    box-shadow: -2px 0 10px rgba(0,0,0,0.5);
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

@media only screen and (max-width: 900px){
    .ai-panel{
        height: 93vh;
    }
}

.ai-panel.open {
    right: 0;
}

.ai-header {
    padding: 15px;
    background-color: #252526;
    border-bottom: 1px solid #333;
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: #fff;
}

.ai-title {
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 10px;
}

.ai-title i {
    color: #4cc9f0;
}

.ai-close-btn {
    background: none;
    border: none;
    color: #888;
    cursor: pointer;
    font-size: 1.2rem;
}

.ai-close-btn:hover {
    color: #fff;
}

.ai-controls {
    padding: 10px 15px;
    background-color: #2d2d2d;
    border-bottom: 1px solid #333;
}

.mode-switch {
    display: flex;
    background: #3c3c3c;
    border-radius: 5px;
    padding: 2px;
}

.mode-btn {
    flex: 1;
    background: none;
    border: none;
    color: #aaa;
    padding: 8px;
    cursor: pointer;
    font-size: 0.85rem;
    border-radius: 3px;
    transition: all 0.2s;
}

.mode-btn.active {
    background: #007acc;
    color: white;
}

.chat-area {
    flex: 1;
    padding: 15px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    height: 90vh;
    gap: 15px;
    position: relative; /* For login overlay positioning */
}

/* Login Overlay Styles */
.login-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(30, 30, 30, 0.95);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 10;
    text-align: center;
    padding: 20px;
}

.login-overlay h3 {
    color: #fff;
    margin-bottom: 15px;
}

.login-overlay p {
    color: #ccc;
    margin-bottom: 20px;
    font-size: 0.9rem;
}

.login-btn-overlay {
    background: linear-gradient(45deg, #6a11cb 0%, #2575fc 100%);
    color: white;
    padding: 10px 20px;
    text-decoration: none;
    border-radius: 5px;
    font-weight: bold;
    transition: transform 0.2s;
}

.login-btn-overlay:hover {
    transform: scale(1.05);
}

.message {
    max-width: 90%;
    padding: 10px;
    border-radius: 8px;
    font-size: 0.9rem;
    line-height: 1.4;
    word-wrap: break-word;
}

.message.user {
    align-self: flex-end;
    background-color: #264f78;
    color: white;
}

.message.ai {
    align-self: flex-start;
    background-color: #333;
    color: #ddd;
    border: 1px solid #444;
}

.input-area {
    padding: 15px;
    background-color: #252526;
    border-top: 1px solid #333;
    display: flex;
    gap: 10px;
}

.input-area.disabled {
    opacity: 0.5;
    pointer-events: none;
}

#aiPromptInput {
    flex: 1;
    background: #3c3c3c;
    border: 1px solid #555;
    color: white;
    padding: 10px;
    border-radius: 4px;
    resize: none;
    height: 40px;
}

#aiPromptInput:focus {
    outline: none;
    border-color: #007acc;
}

#sendAiBtn {
    background: #007acc;
    border: none;
    color: white;
    padding: 0 15px;
    border-radius: 4px;
    cursor: pointer;
}

#sendAiBtn:hover {
    background: #0062a3;
}

/* Typing Indicator */
.typing {
    color: #888;
    font-size: 0.8rem;
    font-style: italic;
    margin-left: 10px;
    display: none;
}

/* Apply Code Button */
.apply-code-btn {
    display: block;
    width: 100%;
    margin-top: 10px;
    padding: 8px;
    background: #28a745;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    text-align: center;
}

.apply-code-btn:hover {
    background: #218838;
}

/* Code block styles in chat */
.message.ai pre {
    background: #111;
    padding: 0;
    border-radius: 4px;
    overflow-x: auto;
    margin: 0;
}

/* New Code Block Styles */
.code-block {
    background: #1e1e1e;
    border: 1px solid #444;
    border-radius: 6px;
    margin: 10px 0;
    overflow: hidden;
}

.code-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #2d2d2d;
    padding: 5px 10px;
    border-bottom: 1px solid #444;
}

.lang-tag {
    color: #888;
    font-size: 0.75rem;
    font-weight: bold;
    text-transform: uppercase;
}

.copy-btn-chat {
    background: transparent;
    border: 1px solid #555;
    color: #ccc;
    border-radius: 4px;
    padding: 2px 8px;
    font-size: 0.75rem;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 5px;
}

.copy-btn-chat:hover {
    background: #444;
    color: white;
    border-color: #666;
}

.code-content {
    padding: 10px;
    margin: 0;
    color: #d4d4d4;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 0.85rem;
    overflow-x: auto;
}