/* Import Unbounded font from Google Fonts */
@import url('https://fonts.googleapis.com/css2?family=Unbounded:wght@300;400;500;600;700&display=swap');

/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Unbounded', monospace;
    background: #2a2a2a;
    min-height: 100vh;
    padding: 20px;
    overflow-x: hidden;
    color: #c77dff;
    position: relative;
}

/* CRT effect */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(rgba(18, 16, 16, 0) 50%, rgba(0, 0, 0, 0.15) 50%), 
                linear-gradient(90deg, rgba(255, 0, 0, 0.03), rgba(0, 255, 0, 0.01), rgba(0, 0, 255, 0.03));
    background-size: 100% 2px, 3px 100%;
    pointer-events: none;
    z-index: 2;
}

/* Grain texture overlay */
body::after {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 400 400' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noiseFilter'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noiseFilter)' opacity='0.1'/%3E%3C/svg%3E");
    pointer-events: none;
    z-index: 3;
}

/* Scan line animation */
@keyframes scan {
    0% { transform: translateY(-100%); }
    100% { transform: translateY(100%); }
}

.scan-line {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(to bottom, transparent, rgba(199, 125, 255, 0.03), transparent);
    height: 50%;
    animation: scan 8s linear infinite;
    pointer-events: none;
    z-index: 4;
}

/* Page container */
.page-container {
    width: 100%;
    max-width: 1000px;
    margin: 40px auto 0 auto; /* Increased top margin for more space */
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    position: relative;
}

/* Chat container */
.chat-container {
    background: #3a3a3a;
    border: 3px solid #9d4edd;
    border-radius: 0;
    box-shadow: 0 0 40px rgba(157, 78, 221, 0.4),
                inset 0 0 20px rgba(157, 78, 221, 0.1);
    width: 100%;
    height: 700px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
    z-index: 1;
    margin-bottom: 0;
    min-height: 700px;
}

/* Chat header */
.chat-header {
    background: #4a4a4a;
    color: #c77dff;
    padding: 15px 20px;
    display: flex;
    align-items: center;
    gap: 15px;
    border-bottom: 2px solid #9d4edd;
    text-transform: uppercase;
    letter-spacing: 2px;
}

.logo {
    width: 40px;
    height: 40px;
    border: 2px solid #c77dff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    color: #c77dff;
    position: relative;
    overflow: hidden;
    background: #5a5a5a;
}

.logo::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, #c77dff, transparent);
    animation: shimmer 3s infinite;
}

@keyframes shimmer {
    0% { left: -100%; }
    100% { left: 100%; }
}

.chat-header h1 {
    font-size: 1.2rem;
    font-weight: 600;
    text-shadow: 0 0 10px rgba(199, 125, 255, 0.6);
}

/* Chat messages area */
.chat-messages {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 15px;
    background: #454545;
    position: relative;
    z-index: 1;
}

/* Custom scrollbar */
.chat-messages::-webkit-scrollbar {
    width: 12px;
    background: #3a3a3a;
}

.chat-messages::-webkit-scrollbar-track {
    border: 1px solid #5a5a5a;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: #9d4edd;
    border: 1px solid #c77dff;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
    background: #c77dff;
    box-shadow: 0 0 10px #c77dff;
}

/* Message styles */
.message {
    display: flex;
    gap: 15px;
    max-width: 85%;
    animation: glitchIn 0.3s ease-out;
}

@keyframes glitchIn {
    0% {
        opacity: 0;
        transform: translateX(-10px);
        filter: blur(3px);
    }
    50% {
        opacity: 0.5;
        transform: translateX(5px);
    }
    100% {
        opacity: 1;
        transform: translateX(0);
        filter: blur(0);
    }
}

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

.message-avatar {
    width: 40px;
    height: 40px;
    border: 2px solid #9d4edd;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    color: #c77dff;
    background: #5a5a5a;
    text-shadow: 0 0 5px currentColor;
}

.message.user .message-avatar {
    border-color: #c77dff;
    color: #e0aaff;
    background: #6a6a6a;
}

.message-bubble {
    background: #5a5a5a;
    padding: 16px 20px;
    border: 1px solid #6a6a6a;
    position: relative;
    color: #f0f0f0;
    font-size: 14px;
    line-height: 1.6;
}

.message.user .message-bubble {
    background: #6a5a7a;
    border-color: #9d4edd;
    color: #f5e6ff;
}

/* Retro corner decorations */
.message-bubble::before,
.message-bubble::after {
    content: '';
    position: absolute;
    width: 8px;
    height: 8px;
    border: 1px solid #9d4edd;
}

.message-bubble::before {
    top: -1px;
    left: -1px;
    border-right: 0;
    border-bottom: 0;
}

.message-bubble::after {
    bottom: -1px;
    right: -1px;
    border-left: 0;
    border-top: 0;
}

/* Welcome message */
.welcome-message {
    text-align: center;
    padding: 40px 20px;
    color: #c77dff;
    font-size: 1.1rem;
    line-height: 1.6;
    position: relative;
    z-index: 5;
}

.welcome-message h2 {
    color: #e0aaff;
    margin-bottom: 15px;
    font-weight: 600;
    text-shadow: 0 0 10px rgba(224, 170, 255, 0.6);
}

/* Source links styling */
.source-links {
    list-style: none;
    padding: 0;
    margin: 10px 0 15px 0;
}

.source-links li {
    margin: 6px 0;
}

.source-links a {
    color: #c77dff;
    text-decoration: none;
    padding: 6px 10px;
    background: rgba(157, 78, 221, 0.1);
    border: 1px solid rgba(157, 78, 221, 0.3);
    border-radius: 4px;
    display: inline-block;
    transition: all 0.3s ease;
    font-size: 0.8em;
    font-weight: 400;
}

.source-links a:hover {
    background: rgba(157, 78, 221, 0.2);
    border-color: rgba(157, 78, 221, 0.5);
    box-shadow: 0 0 10px rgba(157, 78, 221, 0.3);
    transform: translateY(-1px);
}

/* Disclaimer styling */
.welcome-message p:last-child {
    background: rgba(255, 165, 0, 0.1);
    border: 1px solid rgba(255, 165, 0, 0.3);
    border-radius: 4px;
    padding: 10px 12px;
    margin-top: 15px;
    font-size: 0.75em;
    color: #ffa500;
    line-height: 1.4;
    font-weight: 300;
    letter-spacing: 0.5px;
    box-shadow: inset 0 0 5px rgba(255, 165, 0, 0.1);
}

.welcome-message p:last-child a {
    color: #9d9d9d;
    text-decoration: underline;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    padding: 2px 4px;
    border-radius: 3px;
    background: rgba(157, 157, 157, 0.1);
    position: relative;
    z-index: 10;
}

.welcome-message p:last-child a:hover {
    color: #c0c0c0;
    text-shadow: 0 0 5px rgba(157, 157, 157, 0.5);
    background: rgba(157, 157, 157, 0.2);
    box-shadow: 0 0 8px rgba(157, 157, 157, 0.3);
}

/* Input area */
.chat-input-container {
    padding: 20px;
    background: #4a4a4a;
    border-top: 2px solid #9d4edd;
}

.chat-input-wrapper {
    display: flex;
    gap: 15px;
    align-items: center;
}

#messageInput {
    flex: 1;
    padding: 12px 16px;
    border: 1px solid #9d4edd;
    background: #3a3a3a;
    color: #f0f0f0;
    font-size: 14px;
    font-family: 'Unbounded', monospace;
    outline: none;
    transition: all 0.3s ease;
    resize: none;
    min-height: 24px;
    max-height: 200px;
}

#messageInput:focus {
    box-shadow: 0 0 20px rgba(157, 78, 221, 0.4),
                inset 0 0 10px rgba(157, 78, 221, 0.1);
    background: #454545;
}

#messageInput::placeholder {
    color: #999;
    text-transform: uppercase;
    font-size: 12px;
    letter-spacing: 1px;
}

/* Send button */
#sendButton {
    width: 50px;
    height: 50px;
    border: 2px solid #9d4edd;
    background: #5a5a5a;
    color: #c77dff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
    font-family: 'Unbounded', monospace;
    font-weight: 600;
}

#sendButton:hover:not(:disabled) {
    background: #9d4edd;
    color: #fff;
    box-shadow: 0 0 20px rgba(157, 78, 221, 0.6);
}

#sendButton:active {
    transform: scale(0.95);
}

#sendButton:disabled {
    background: #565869;
    cursor: not-allowed;
    opacity: 0.5;
}

/* Typing indicator */
.typing-indicator {
    display: flex;
    gap: 5px;
    padding: 15px;
    color: #c77dff;
    font-size: 0.9rem;
    font-weight: 300;
}

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

.typing-dot {
    width: 8px;
    height: 8px;
    background: #c77dff;
    border-radius: 50%;
    animation: pulse 1.5s infinite;
    box-shadow: 0 0 10px #c77dff;
}

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

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

@keyframes pulse {
    0%, 60%, 100% {
        opacity: 0.3;
        transform: scale(0.8);
    }
    30% {
        opacity: 1;
        transform: scale(1.2);
    }
}

/* Error message */
.error-message {
    background: rgba(220, 53, 69, 0.1);
    border: 1px solid rgba(220, 53, 69, 0.3);
    color: #ff6b6b;
    padding: 15px 20px;
    border-radius: 10px;
    margin: 10px 0;
    font-size: 0.9rem;
    text-align: center;
}

/* Markdown styling */
.message-bubble p {
    margin-bottom: 12px;
}

.message-bubble p:last-child {
    margin-bottom: 0;
}

.message-bubble ul {
    margin: 12px 0;
    padding-left: 20px;
    list-style: none;
}

.message-bubble li {
    margin-bottom: 8px;
    position: relative;
    padding-left: 20px;
}

.message-bubble li::before {
    content: '>';
    position: absolute;
    left: 0;
    color: #c77dff;
    font-weight: bold;
}

.message-bubble strong {
    color: #e0aaff;
    text-shadow: 0 0 3px rgba(224, 170, 255, 0.5);
}

.message-bubble code {
    background: #3a3a3a;
    padding: 2px 6px;
    border: 1px solid #6a6a6a;
    color: #c77dff;
    font-family: inherit;
}

/* Main list styling */
.main-list {
    list-style: none;
    padding: 0;
    margin: 10px 0;
}

.main-list li {
    background: rgba(157, 78, 221, 0.1);
    border: 1px solid rgba(157, 78, 221, 0.2);
    border-radius: 8px;
    padding: 12px 15px;
    margin: 8px 0;
    backdrop-filter: blur(5px);
}

/* Sub list styling */
.sub-list {
    list-style: none;
    padding-left: 20px;
    margin: 8px 0;
}

.sub-list li {
    background: rgba(75, 0, 130, 0.1);
    border: 1px solid rgba(75, 0, 130, 0.2);
    border-radius: 6px;
    padding: 8px 12px;
    margin: 5px 0;
    font-size: 0.9rem;
    color: #c8b3d8;
}

/* Blinking cursor */
.blink {
    animation: blink 1s step-end infinite;
}

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

/* Mobile responsive */
@media (max-width: 768px) {
    .page-container {
        max-width: 100%;
        padding: 0;
        margin: 20px auto 0 auto; /* Reduced top margin for mobile */
    }
    
    .chat-container {
        height: 100vh;
        max-width: 100%;
        border-width: 0;
        border-radius: 0;
        margin-bottom: 0;
        overflow: hidden; /* Ensure overflow is hidden on mobile */
    }

    .message {
        max-width: 90%;
        padding: 16px;
    }
    
    .chat-input-container {
        padding: 16px;
    }
}

/* Tablet responsive */
@media (min-width: 769px) and (max-width: 1024px) {
    .page-container {
        max-width: 95%;
    }
}

/* Small mobile devices */
@media (max-width: 480px) {
    .page-container {
        max-width: 100%;
    }
}

/* Auto-resize textarea */
#messageInput {
    overflow: hidden;
}

/* Footer */
.footer {
    position: relative;
    z-index: 5;
    width: 100%;
    max-width: 1000px;
    margin: 20px auto 0 auto;
    padding: 15px 20px;
    text-align: center;
}

.footer-section {
    text-align: center;
    width: 100%;
}

.footer-section h4 {
    color: #9d9d9d;
    font-size: 0.9rem;
    font-weight: 400;
    margin: 0;
    text-align: center;
}

/* Footer link styling */
.footer-section h4 a {
    color: #9d9d9d;
    text-decoration: none;
    transition: all 0.3s ease;
}

.footer-section h4 a:hover {
    color: #c77dff;
    text-shadow: 0 0 5px rgba(199, 125, 255, 0.5);
}

/* Mobile responsive for footer */
@media (max-width: 768px) {
    .footer {
        margin-top: 15px;
        padding: 12px 15px;
    }

    .footer-section h4 {
        font-size: 0.85rem;
    }
}

/* Small mobile devices */
@media (max-width: 480px) {
    .footer {
        margin-top: 12px;
        padding: 10px 12px;
    }

    .footer-section h4 {
        font-size: 0.8rem;
    }
}

/* Bot response section styling */
.message-bubble .bot-section {
    font-weight: bold;
    color: #e0aaff; /* Light purple for better visibility */
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Specific styling for Direct Answer, Supporting Details, Context, and Further inquiries */
.message-bubble .direct-answer,
.message-bubble .supporting-details,
.message-bubble .context,
.message-bubble .further-inquiries {
    font-weight: bold;
    color: #e0aaff; /* Light purple for better visibility */
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}