/* === Gradient Animated Outer Background for AI Assistant === */
body {
    min-height: 100vh;
    min-width: 100vw;
    margin: 0;
    padding: 0;
    background: linear-gradient(120deg, #ff9800, #e53935, #4e5254, #ff9800, #e53935, #232526);
    background-size: 300% 300%;
    animation: ai-gradient-move 10s ease-in-out infinite;
}

/* Animated gradient keyframes */
@keyframes ai-gradient-move {
  0% { background-position: 0% 50%; }
  25% { background-position: 50% 100%; }
  50% { background-position: 100% 50%; }
  75% { background-position: 50% 0%; }
  100% { background-position: 0% 50%; }
}

/* Subtle glass effect overlay */
body::before {
    content: '';
    position: fixed;
    z-index: 0;
    inset: 0;
    pointer-events: none;
    backdrop-filter: blur(0.5px) saturate(1.05);
    -webkit-backdrop-filter: blur(0.5px) saturate(1.05);
}

/* Header and Navigation Bar */
.header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 60px;
    background: #fff;
    z-index: 1000;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

/* User Info Bar */
.user-info-bar {
    position: fixed;
    top: 60px;
    left: 0;
    right: 0;
    background: #1e1e1e;
    color: #fff;
    padding: 10px 20px;
    z-index: 999;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.navbar {
    z-index: 1000;
    display: flex;
    height: 60px;
    width: 100%;
    background-color: rgb(246, 246, 246);
    align-items: center;
    position: fixed;
    opacity: .9;
    top: 0;
    left: 0;
}

.navlogo {
    height: 45px;
    width: 90px;
    margin-left: 30px;
}
.navlogo img {
    height: 45px;
    width: 90px;
}
.navtext ol {
    display: flex;
    gap: 40px;
    margin-left: 25px;
    font-family: cursive;
    color: rgb(75, 84, 81);
    font-weight: bold;
}
.navtext .hov-home a:hover,
.navtext .hov-courses:hover,
.navtext .hov-roadmap:hover,
.navtext .hov-compiler:hover,
.navtext .hov-competitive:hover,
.navtext .hov-aiassiatant:hover,
.navtext .hov-profile:hover {
    color: orange;
    transition: color .3s ease;
}
.navtext ol li { list-style: none; }
.navtext ol li a {
    text-decoration: none;
    color: black;
}
.navtext ol li a:hover {
    color: orange;
    transition: color .3s ease;
}

/* Responsive adjustments for navbar */
@media (max-width: 1100px) {
    .navtext ol { gap: 20px; margin-left: 10px; }
    .login { margin-left: 40px; }
    .navlogo { margin-left: 10px; }
}
@media (max-width: 900px) {
    .navbar {
        flex-wrap: wrap;
        height: auto;
        min-height: 60px;
        padding-bottom: 5px;
    }
    .navtext ol {
        flex-wrap: wrap;
        gap: 14px;
        font-size: 15px;
    }
    .login, .singup {
        margin-left: 8px;
        margin-top: 5px;
    }
}
@media (max-width: 700px) {
    .navbar {
        flex-direction: column;
        align-items: flex-start;
        padding: 10px 0;
        height: auto;
    }
    .navlogo {
        margin: 0 0 5px 10px;
    }
    .navtext ol {
        flex-wrap: wrap;
        gap: 10px;
        font-size: 13px;
        margin-left: 10px;
    }
    .login, .singup {
        margin-left: 0;
        margin-top: 5px;
    }
}

/* Main Container - Adjusted for fixed header and info bar */
.ai-container {
    width: 100%;
    max-width: 1200px;
    margin: 120px auto 20px;
    height: calc(100vh - 180px);
    padding: 0 20px;
    position: relative;
    display: flex;
    justify-content: center;
    align-items: stretch;
    animation: fadeInUpBig 1s cubic-bezier(0.23, 1, 0.32, 1);
    box-shadow: 0 8px 32px 8px #1a1a1a15;
    background: linear-gradient(120deg, #ff9800, #e53935, #595e61, #ff9800, #ff5451, #303334, #ff9800, #e53935);
    background-size: 300% 300%;
    animation: ai-gradient-move 10s ease-in-out infinite;
    border-radius: 18px;
    z-index: 2;
}

@media (max-width: 1200px) {
    .ai-container {
        max-width: 100vw;
        padding: 0 7vw;
    }
}
@media (max-width: 900px) {
    .ai-container {
        max-width: 100vw;
        margin: 110px auto 16px;
        height: calc(100vh - 140px);
        padding: 0 2vw;
    }
}
@media (max-width: 600px) {
    .ai-container {
        max-width: 100vw;
        margin: 100px auto 10px;
        height: calc(100vh - 120px);
        padding: 0 5px;
        border-radius: 10px;
    }
}
@media (max-width: 400px) {
    .ai-container {
        margin: 80px auto 5px;
        height: calc(100vh - 80px);
        padding: 0 2px;
        border-radius: 5px;
    }
}

/* Chat Interface */
.chat-interface {
    background: #ffffff;
    border-radius: 18px;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.13);
    height: 100%;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: box-shadow 0.3s, border-radius 0.3s;
    animation: popIn 0.95s cubic-bezier(0.23, 1, 0.32, 1);
}
@media (max-width: 600px) {
    .chat-interface { border-radius: 9px; }
}
@media (max-width: 400px) {
    .chat-interface { border-radius: 5px; }
}

/* Chat History */
.chat-history {
    flex: 1;
    overflow-y: auto;
    padding: 20px 24px;
    background: linear-gradient(135deg, #f8f9fa 70%, #e0f7ff 100%);
    animation: fadeIn 1.2s;
    scroll-behavior: smooth;
    transition: background 0.25s;
}
@media (max-width: 900px) {
    .chat-history { padding: 14px 10px; }
}
@media (max-width: 600px) {
    .chat-history { padding: 8px 2px; }
}

/* Message Styles */
.message {
    margin-bottom: 22px;
    animation: messageFadeIn 0.5s;
    will-change: transform, opacity;
    transition: box-shadow 0.18s;
    position: relative;
}
.message-content {
    display: flex;
    gap: 12px;
    max-width: 88%;
    box-shadow: 0 2px 12px rgba(0, 180, 255, 0.04);
    transition: box-shadow 0.18s;
    animation: bubblePopIn 0.5s;
}
.ai-message .message-content {
    margin-right: auto;
    animation: slideLeftIn 0.45s;
}
.user-message .message-content {
    margin-left: auto;
    flex-direction: row-reverse;
    animation: slideRightIn 0.45s;
}
.message-avatar {
    width: 44px;
    height: 44px;
    background: linear-gradient(135deg, #007bff 60%, #00e3ff 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    flex-shrink: 0;
    font-size: 1.45em;
    box-shadow: 0 2px 7px #00e3ff22;
    animation: avatarPop 0.6s;
}
.user-message .message-avatar {
    background: linear-gradient(135deg, #28a745 60%, #a6ffcb 100%);
    box-shadow: 0 2px 7px #28a74522;
}
.message-text {
    background: #fff;
    padding: 14px 20px;
    border-radius: 16px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.07);
    line-height: 1.6;
    word-wrap: break-word;
    font-size: 1.03em;
    border: 1.5px solid #f2f7fa;
    letter-spacing: 0.01em;
    animation: textPop 0.75s;
    position: relative;
    z-index: 1;
}
.ai-message .message-text {
    background: linear-gradient(120deg, #f0f7ff 80%, #d3eaff 100%);
    border: 1.5px solid #e0f0fa;
}
.user-message .message-text {
    background: linear-gradient(120deg, #e7f5e9 80%, #faffef 100%);
    border: 1.5px solid #e2fae4;
}
@media (max-width: 900px) {
    .message-content { max-width: 98%; gap: 8px; }
    .message-avatar { width: 38px; height: 38px; font-size: 1.13em; }
    .message-text { padding: 9px 12px; font-size: 1em; border-radius: 11px; }
}
@media (max-width: 600px) {
    .message-content { max-width: 99%; gap: 4px; }
    .message-avatar { width: 32px; height: 32px; font-size: 1em; }
    .message-text { padding: 7px 7px; font-size: 0.98em; border-radius: 7px; }
}

/* Input Area */
.input-area {
    padding: 20px 24px 16px 24px;
    background: #ffffffcc;
    border-top: 1px solid #eaeaea;
    animation: fadeInUp 0.8s;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.input-wrapper {
    display: flex;
    gap: 10px;
    margin-bottom: 10px;
    align-items: center;
}
#userInput {
    flex: 1;
    padding: 14px 12px;
    border: 1.5px solid #dde9ef;
    border-radius: 13px;
    resize: none;
    font-size: 17px;
    line-height: 1.5;
    max-height: 150px;
    transition: all 0.35s cubic-bezier(0.23, 1, 0.32, 1);
    font-family: inherit;
    outline: none;
    background: #f9fbfc;
    box-shadow: 0 2px 8px #bce2ff0d;
}
#userInput:focus {
    border-color: #007bff;
    box-shadow: 0 0 0 3px rgba(0,123,255,0.18);
    outline: none;
    background: #f2faff;
}
#sendButton {
    padding: 13px 22px;
    background: linear-gradient(90deg, #007bff 60%, #00e3ff 100%);
    color: white;
    border: none;
    border-radius: 11px;
    cursor: pointer;
    transition: background 0.3s, transform 0.12s;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 19px;
    box-shadow: 0 2px 7px #00e3ff22;
    animation: popIn 0.25s;
}
#sendButton:hover {
    background: linear-gradient(90deg, #0056b3 60%, #00aaff 100%);
    transform: scale(1.06);
}
.input-tools {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    justify-content: flex-start;
    animation: fadeIn 1.2s;
}
.tool-button {
    padding: 10px;
    background: transparent;
    border: 1.5px solid #ddd;
    border-radius: 8px;
    cursor: pointer;
    color: #666;
    transition: all 0.26s;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    box-shadow: 0 2px 7px #00e3ff0b;
}
.tool-button:hover {
    background: linear-gradient(90deg, #f8f9fa 60%, #e7f9ff 100%);
    color: #007bff;
    border-color: #007bff;
    transform: scale(1.11) rotate(-2deg);
}
@media (max-width: 900px) {
    .input-area { padding: 10px 4px 10px 4px; gap: 6px; }
    #sendButton { padding: 10px 14px; font-size: 17px; border-radius: 8px; }
    .tool-button { padding: 7px; font-size: 16px; border-radius: 6px; }
    #userInput { font-size: 15px; padding: 8px 7px; border-radius: 9px; }
}
@media (max-width: 600px) {
    .input-area { padding: 6px 2px 6px 2px; }
    .input-wrapper { gap: 6px; }
    .input-tools { gap: 6px; }
    .tool-button { padding: 5px; font-size: 14px; border-radius: 5px; }
}

/* Loading Overlay */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255,255,255,0.9);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 1001;
    animation: popIn 0.5s;
}
.spinner {
    text-align: center;
    color: #007bff;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    font-size: 1.3em;
    animation: spinIn 1.1s;
}
.spinner i {
    font-size: 32px;
    animation: rotate360 1.2s linear infinite;
}
@media (max-width: 900px) {
    .spinner { font-size: 1em; }
    .spinner i { font-size: 23px; }
}

/* Animations */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(50px);}
    to { opacity: 1; transform: translateY(0);}
}
@keyframes fadeInUpBig {
    from { opacity: 0; transform: translateY(120px);}
    to { opacity: 1; transform: translateY(0);}
}
@keyframes popIn {
    from { transform: scale(0.95); opacity: 0;}
    to { transform: scale(1); opacity: 1;}
}
@keyframes messageFadeIn {
    from { opacity: 0; transform: translateY(20px);}
    to { opacity: 1; transform: translateY(0);}
}
@keyframes slideLeftIn {
    from { opacity: 0; transform: translateX(-30px);}
    to { opacity: 1; transform: translateX(0);}
}
@keyframes slideRightIn {
    from { opacity: 0; transform: translateX(40px);}
    to { opacity: 1; transform: translateX(0);}
}
@keyframes bubblePopIn {
    0% { transform: scale(0.95);}
    80% { transform: scale(1.03);}
    100% { transform: scale(1);}
}
@keyframes textPop {
    0% { opacity: 0; transform: scale(0.95);}
    80% { opacity: 1; transform: scale(1.04);}
    100% { opacity: 1; transform: scale(1);}
}
@keyframes avatarPop {
    0% { opacity: 0; transform: scale(0.7);}
    70% { opacity: 1; transform: scale(1.08);}
    100% {opacity: 1; transform: scale(1);}
}
@keyframes spinIn {
    from { opacity: 0; transform: rotate(-40deg);}
    to { opacity: 1; transform: rotate(0);}
}
@keyframes rotate360 {
    from { transform: rotate(0deg);}
    to { transform: rotate(360deg);}
}
@keyframes timeUpdate {
    0% { transform: scale(1);}
    50% { transform: scale(1.05);}
    100% { transform: scale(1);}
}

.time-updated {
    animation: timeUpdate 0.3s ease-out;
}

/* Responsive Design for Chat History and Scrollbar */
@media (max-width: 768px) {
    .user-info-bar {
        flex-direction: column;
        padding: 8px 15px;
        gap: 8px;
    }
    .ai-container {
        margin-top: 140px;
        padding: 10px;
        height: calc(100vh - 200px);
    }
    .message-content { max-width: 99%; }
    .input-tools { justify-content: center; }
}
@media (max-width: 480px) {
    .ai-container { padding: 2px; }
    .chat-history { padding: 2px; }
    .message-avatar { width: 28px; height: 28px; font-size: 12px; }
    .message-text { padding: 7px 7px; font-size: 13px; }
    #userInput { font-size: 13px; padding: 6px; }
    .tool-button { padding: 4px; font-size: 13px; }
}

/* Scrollbar Styling */
.chat-history::-webkit-scrollbar { width: 8px; }
.chat-history::-webkit-scrollbar-track { background: #f1f1f1; border-radius: 4px; }
.chat-history::-webkit-scrollbar-thumb { background: #888; border-radius: 4px; }
.chat-history::-webkit-scrollbar-thumb:hover { background: #707070; }