body {
    margin: 0;
    font-family: 'Orbitron', sans-serif; /* Futuristic font */
    background-color: #0d0d1a;
    color: #e0e0f0;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background-image: url('background.png'); /* Sci-fi background */
    background-size: cover;
    background-position: center;
    overflow: hidden; /* Hide potential scrollbars from background image */
}

#app-container {
    display: flex;
    flex-direction: column;
    width: 90%;
    max-width: 1000px;
    height: 90vh;
    background: rgba(18, 18, 36, 0.7); /* Darker, slightly transparent background */
    border-radius: 20px;
    box-shadow: 0 0 50px rgba(0, 255, 255, 0.4); /* Cyan glow */
    border: 2px solid rgba(0, 255, 255, 0.6);
    backdrop-filter: blur(10px); /* Frosted glass effect */
    -webkit-backdrop-filter: blur(10px);
    overflow: hidden;
}

header {
    text-align: center;
    padding: 20px;
    border-bottom: 1px solid rgba(0, 255, 255, 0.3);
    background: rgba(25, 25, 50, 0.8);
    position: relative;
    z-index: 10;
}

#jbr-logo {
    width: 80px;
    height: 80px;
    margin-bottom: 10px;
    filter: drop-shadow(0 0 10px rgba(0, 255, 255, 0.8));
}

header h1 {
    margin: 0;
    font-size: 2.5em;
    color: #00ffff; /* Cyan color */
    text-shadow: 0 0 15px #00ffff;
}

header p {
    margin: 5px 0 0;
    font-size: 0.9em;
    color: #a0f0ff;
}

#chat-container {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    padding: 20px;
    position: relative;
}

#chat-display {
    flex-grow: 1;
    flex-basis: 0; /* Ensures chat-display correctly takes up available space for scrolling */
    overflow-y: auto;
    padding-right: 10px; /* Space for scrollbar */
    scroll-behavior: smooth;
    margin-bottom: 15px; /* Space above input area */
    padding-bottom: 160px; /* increased bottom padding to accommodate the lifted input area */
}

/* Custom scrollbar for webkit browsers */
#chat-display::-webkit-scrollbar {
    width: 8px;
}

#chat-display::-webkit-scrollbar-track {
    background: rgba(0, 255, 255, 0.1);
    border-radius: 10px;
}

#chat-display::-webkit-scrollbar-thumb {
    background-color: rgba(0, 255, 255, 0.5);
    border-radius: 10px;
    border: 1px solid rgba(0, 255, 255, 0.7);
}

.message {
    padding: 12px 18px;
    margin-bottom: 15px;
    border-radius: 20px;
    max-width: 80%;
    word-wrap: break-word;
    font-size: 0.95em;
    line-height: 1.6;
    animation: fadeIn 0.5s ease-out;
}

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

.message.user {
    background: linear-gradient(135deg, #2a2a5a, #4a4a8a); /* Dark blue to lighter blue */
    align-self: flex-end;
    margin-left: auto;
    border-bottom-right-radius: 5px;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
}

.message.ai {
    background: linear-gradient(135deg, #1a3a3a, #2a5a5a); /* Dark teal to lighter teal */
    align-self: flex-start;
    margin-right: auto;
    border-bottom-left-radius: 5px;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(0, 255, 255, 0.3);
    position: relative;
    overflow: hidden;
}

.message.ai::before {
    content: '';
    position: absolute;
    top: -1px;
    left: -1px;
    right: -1px;
    bottom: -1px;
    background: linear-gradient(45deg, rgba(0,255,255,0.2) 0%, rgba(0,255,255,0) 50%, rgba(0,255,255,0.2) 100%);
    z-index: -1;
    border-radius: inherit;
    opacity: 0.3;
}

.message.ai.welcome {
    border: 2px solid #00ffff;
    box-shadow: 0 0 20px rgba(0, 255, 255, 0.7);
    animation: pulseGlow 1.5s infinite alternate;
}

@keyframes pulseGlow {
    from { box-shadow: 0 0 10px rgba(0, 255, 255, 0.5); }
    to { box-shadow: 0 0 30px rgba(0, 255, 255, 1); }
}

.message p {
    margin: 0;
}

/* Code container and pre block styles for light theme */
.code-container {
    position: relative;
    margin-top: 10px;
    border-radius: 8px;
    overflow: hidden;
    /* Adjusted shadow and border for light theme */
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    border: 1px solid #e0e0e0; /* Very light gray border */
}

.message pre {
    margin: 0;
    padding: 15px;
    background-color: #f7f7f7; /* Light background for code */
    border-radius: 0 0 8px 8px;
    overflow-x: auto;
    font-family: 'Roboto Mono', monospace;
    font-size: 0.85em;
    line-height: 1.4;
    color: #333333; /* Dark text for code */
}

/* Custom Highlight.js Light Theme for JBR GPT */
/* This theme aims for clear readability with a light background and distinct, bright syntax colors. */
.hljs {
    display: block;
    overflow-x: auto;
    /* padding should be handled by .message pre */
    background: transparent !important; /* Use pre background */
    color: #333333 !important; /* Default text color for code */
}

/* Comments and quotes - subtle, readable gray */
.hljs-comment,
.hljs-quote {
    color: #6A737D !important; /* Slightly darker grey for comments */
}

/* Keywords, operators, preprocessor directives, boolean literals - strong, distinct red */
.hljs-keyword,
.hljs-selector-tag,
.hljs-doctag,
.hljs-name,
.hljs-meta-keyword,
.hljs-operator {
    color: #D73A49 !important; /* Vibrant red for keywords and operators */
}

/* Functions, methods, class names, titles - prominent purple */
.hljs-function,
.hljs-title,
.hljs-section,
.hljs-attr { /* HTML attributes */
    color: #6F42C1 !important; /* Deep purple for functions and titles */
}

/* Strings, regular expressions, symbols, additions - vibrant green */
.hljs-string,
.hljs-regexp,
.hljs-symbol,
.hljs-bullet,
.hljs-addition {
    color: #22863A !important; /* Darker, distinct green for strings */
}

/* Numbers, built-in types, constants, literals - clear blue */
.hljs-number,
.hljs-built_in,
.hljs-literal,
.hljs-type,
.hljs-params { /* Function parameters */
    color: #0366D6 !important; /* Bright blue for numbers and built-ins */
}

/* Variables, properties, tags, template variables - a distinct dark pink */
.hljs-variable,
.hljs-template-variable,
.hljs-tag,
.hljs-selector-id,
.hljs-selector-class,
.hljs-selector-attr,
.hljs-selector-pseudo {
    color: #E31B54 !important; /* Vibrant pink for variables and tags */
}

/* Important, bold, emphasis */
.hljs-strong {
    font-weight: bold !important;
}
.hljs-emphasis {
    font-style: italic !important;
}

/* Deletion */
.hljs-deletion {
    color: #B31010 !important; /* Strong red for deletions */
}

/* Meta information (e.g., #include, @media) */
.hljs-meta {
    color: #24292E !important; /* Very dark text for meta info */
}

/* Other less common elements - ensure they have a default color */
.hljs-link {
    color: #0366D6 !important; /* Blue for links */
}

/* New styles for the code header and language label */
.code-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: #e9e9e9; /* Slightly darker light background for the header */
    padding: 8px 15px;
    border-bottom: 1px solid #d0d0d0; /* Lighter border */
    border-top-left-radius: 8px;
    border-top-right-radius: 8px;
}

.code-language-label {
    color: #555555; /* Darker text for readability on light background */
    font-family: 'Orbitron', sans-serif;
    font-size: 0.85em;
    letter-spacing: 1px;
    flex-grow: 1;
    text-align: left;
}

.copy-button {
    position: static;
    background-color: #cccccc; /* Neutral gray button */
    color: #333333; /* Dark text */
    border: none;
    border-radius: 5px;
    padding: 5px 10px;
    cursor: pointer;
    font-size: 0.75em;
    font-family: 'Orbitron', sans-serif;
    transition: background-color 0.3s ease, transform 0.2s ease;
    opacity: 1; /* Make it fully opaque */
    margin-left: 10px;
    box-shadow: none; /* Remove glowing shadow */
}

.copy-button:hover {
    background-color: #bbbbbb;
    transform: scale(1.05);
    opacity: 1;
}

.image-output {
    margin-top: 10px;
    text-align: center;
}

.image-output img {
    max-width: 90%;
    height: auto;
    border-radius: 10px;
    box-shadow: 0 0 20px rgba(0, 255, 255, 0.5);
    border: 2px solid rgba(0, 255, 255, 0.7);
    object-fit: contain;
}

/* Typing Indicator Styles */
.typing-indicator {
    display: flex;
    justify-content: flex-start;
    align-items: center;
    background: linear-gradient(135deg, #1a3a3a, #2a5a5a);
    padding: 12px 18px;
    border-radius: 20px;
    max-width: 100px; /* Keep it concise */
    margin-right: auto;
    border-bottom-left-radius: 5px;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(0, 255, 255, 0.3);
    margin-bottom: 15px;
}

.typing-indicator .dot {
    width: 10px;
    height: 10px;
    background-color: #00ffff; /* Cyan dots */
    border-radius: 50%;
    margin: 0 3px;
    animation: bounce 1.4s infinite ease-in-out;
}

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

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

@keyframes bounce {
    0%, 80%, 100% {
        transform: translateY(0);
    }
    40% {
        transform: translateY(-8px);
    }
}

#input-area {
    display: flex;
    padding-top: 15px;
    border-top: 1px solid rgba(0, 255, 255, 0.3);
    background: rgba(25, 25, 50, 0.8);
    position: absolute;
    bottom: 40px; /* lifted slightly higher for better visibility */
    left: 20px;
    width: calc(100% - 40px);
    z-index: 10;
}

#user-input {
    flex-grow: 1;
    padding: 15px;
    border: 2px solid rgba(0, 255, 255, 0.6);
    border-radius: 10px;
    background-color: rgba(20, 20, 40, 0.9);
    color: #e0e0f0;
    font-size: 1em;
    resize: none;
    outline: none;
    box-shadow: 0 0 15px rgba(0, 255, 255, 0.3);
    font-family: 'Roboto Mono', monospace;
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

#user-input:focus {
    border-color: #00ffff;
    box-shadow: 0 0 20px rgba(0, 255, 255, 0.6);
}

#send-button {
    background-color: #00ffff;
    color: #0d0d1a;
    border: none;
    border-radius: 10px;
    padding: 10px 20px;
    margin-left: 15px;
    cursor: pointer;
    font-size: 1.1em;
    font-weight: bold;
    font-family: 'Orbitron', sans-serif;
    transition: background-color 0.3s ease, transform 0.2s ease, box-shadow 0.3s ease;
    box-shadow: 0 0 15px rgba(0, 255, 255, 0.4);
}

#send-button:hover {
    background-color: #33ffff;
    transform: translateY(-2px);
    box-shadow: 0 0 25px rgba(0, 255, 255, 0.8);
}

#send-button:active {
    transform: translateY(0);
    box-shadow: 0 0 10px rgba(0, 255, 255, 0.6);
}

/* Media queries for responsiveness */
@media (max-width: 768px) {
    #app-container {
        width: 95%;
        height: 95vh;
        border-radius: 15px;
        box-shadow: 0 0 30px rgba(0, 255, 255, 0.3);
    }

    header h1 {
        font-size: 2em;
    }

    #jbr-logo {
        width: 60px;
        height: 60px;
    }

    .message {
        padding: 10px 15px;
        font-size: 0.9em;
    }

    .message pre {
        padding: 10px;
        font-size: 0.8em;
    }

    #user-input {
        padding: 12px;
        font-size: 0.9em;
    }

    #send-button {
        padding: 8px 15px;
        font-size: 1em;
    }
}

@media (max-width: 480px) {
    #app-container {
        width: 100%;
        height: 100vh;
        border-radius: 0;
        box-shadow: none;
        border: none;
    }

    header {
        padding: 15px;
    }

    header h1 {
        font-size: 1.8em;
    }

    #jbr-logo {
        width: 50px;
        height: 50px;
    }

    #chat-container {
        padding: 15px;
    }

    .message {
        max-width: 90%;
    }

    .copy-button {
        padding: 3px 6px;
        font-size: 0.7em;
    }

    #input-area {
        flex-direction: column;
        align-items: stretch;
        padding: 10px;
    }

    #user-input {
        margin-bottom: 10px;
        margin-left: 0;
    }

    #send-button {
        margin-left: 0;
        width: 100%;
    }
}