
:root {
    /* Light Theme - Futuristic */
    --bg-primary: #f0f4f8; /* Very light blue-gray */
    --bg-secondary: #ffffff;
    --bg-tertiary: #e2e8f0; /* Subtle contrast */
    --text-primary: #1a202c;
    --text-secondary: #4a5568;
    --accent-main: #007bff; /* Bright blue */
    --accent-hover: #0056b3;
    --accent-glow: rgba(0, 123, 255, 0.4); /* Blue glow */
    --border-color: rgba(100, 149, 237, 0.3); /* Muted cornflower blue */
    --glass-bg: rgba(255, 255, 255, 0.6);
    --glass-border: rgba(200, 220, 240, 0.6);
    --shadow-color: rgba(0, 0, 0, 0.15);
    --input-focus-border: var(--accent-main);
    --heading-font: 'Poppins', sans-serif;
    --body-font: 'Inter', sans-serif;
}

html.dark {
    /* Dark Theme - Futuristic */
    --bg-primary: #0a0e14; /* Deep dark blue-gray */
    --bg-secondary: #1a1f26;
    --bg-tertiary: #2d3748; /* Darker contrast */
    --text-primary: #e2e8f0;
    --text-secondary: #a0aec0;
    --accent-main: #00c4ff; /* Luminous cyan */
    --accent-hover: #0099e6;
    --accent-glow: rgba(0, 196, 255, 0.4); /* Cyan glow */
    --border-color: rgba(0, 196, 255, 0.3);
    --glass-bg: rgba(26, 31, 38, 0.6);
    --glass-border: rgba(50, 60, 70, 0.6);
    --shadow-color: rgba(0, 0, 0, 0.5);
    --input-focus-border: var(--accent-main);
}

body {
    background: var(--bg-primary);
    font-family: var(--body-font);
    color: var(--text-primary);
    line-height: 1.6;
    transition: background-color 0.5s ease, color 0.5s ease;
    overflow-x: hidden; /* Prevent horizontal scroll from subtle animations */
}

/* Subtle background animation */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle at top left, var(--accent-glow) 0%, transparent 20%),
                radial-gradient(circle at bottom right, var(--accent-glow) 0%, transparent 20%);
    opacity: 0.1;
    pointer-events: none;
    z-index: -1;
    animation: backgroundGlow 20s infinite alternate;
}

@keyframes backgroundGlow {
    0% { transform: scale(1) translate(0, 0); opacity: 0.1; }
    50% { transform: scale(1.1) translate(10px, 10px); opacity: 0.15; }
    100% { transform: scale(1) translate(0, 0); opacity: 0.1; }
}


h1, h2, h3, h4, h5, h6 {
    font-family: var(--heading-font);
    color: var(--text-primary);
    margin-bottom: 0.75rem;
    line-height: 1.2;
}

.font-poppins {
    font-family: 'Poppins', sans-serif;
}

.font-inter {
    font-family: 'Inter', sans-serif;
}

.glass-card {
    background: var(--glass-bg);
    backdrop-filter: blur(30px);
    -webkit-backdrop-filter: blur(20px);
    border-radius: 1.5rem; /* Even more rounded, sleek */
    border: 1px solid var(--glass-border);
    box-shadow: 0 8px 30px rgba(var(--shadow-color), 0.3); /* Deeper, more diffused shadow */
    padding: 1.5rem;
    transition: all 0.3s ease-in-out;
}

.glass-card:hover {
    box-shadow: 0 12px 40px var(--shadow-color), 0 0 15px var(--accent-glow);
    transform: translateY(-3px) scale(1.01); /* Subtle lift and scale */
}

/* Sidebar and Main Content Layout */
.app-container {
    display: flex;
    min-height: 100vh;
    padding: 1.5rem; /* Overall padding for the app */
    gap: 1.5rem;
}

aside {
    flex-shrink: 0;
    backdrop-filter: blur(30px);
    -webkit-backdrop-filter: blur(20px);
    border-radius: 1.5rem;
    border: 1px solid var(--glass-border);
    box-shadow: 0 8px 30px var(--shadow-color);
    padding: 1.5rem;
    position: sticky;
    top: 1.5rem; /* Stick to top with padding */
    height: calc(100vh - 3rem); /* Full height minus padding */
    display: flex;
    flex-direction: column;
}

aside ul {
    list-style: none;
    padding: 0;
    margin: 0;
    flex-grow: 1; /* Allow navigation to take available space */
}

aside ul li {
    margin-bottom: 0.75rem;
}

aside ul li a {
    display: flex;
    align-items: center;
    padding: 0.75rem 1rem;
    border-radius: 1rem;
    color: var(--text-secondary);
    text-decoration: none;
    transition: all 0.3s ease-in-out;
    font-weight: 500;
}

aside ul li a svg {
    margin-right: 0.75rem;
    width: 20px;
    height: 20px;
    fill: currentColor; /* Use current text color for icons */
}

aside ul li a:hover, aside ul li a.active {
    background-color: var(--accent-main);
    color: var(--bg-primary); /* Text color changes for contrast */
    box-shadow: 0 0 15px var(--accent-glow);
    transform: translateY(-3px) scale(1.02); /* More pronounced lift and slight scale */
}
}

main {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

/* Redefine form styles from forms.py to avoid specificity issues */
.glass-card form .w-full.bg-gray-800,
.glass-card form .w-full.bg-white {
    background-color: var(--bg-secondary) !important;
    border-color: var(--border-color) !important;
    color: var(--text-primary) !important;
    border-radius: 0.75rem;
    padding: 0.75rem 1rem;
    transition: all 0.3s ease;
}

.glass-card form .w-full.bg-gray-800:focus,
.glass-card form .w-full.bg-white:focus {
    border-color: var(--input-focus-border) !important;
    box-shadow: 0 0 0 3px var(--accent-glow);
    outline: none;
}

/* Intent Badge Styles */
.intent-badge {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    margin-left: 8px;
    display: inline-block;
}

.intent-neutral { background-color: var(--text-secondary); }
.intent-safe { background-color: #34D399; /* Green */ }
.intent-caution { background-color: #FBBF24; /* Yellow */ }
.intent-warning { background-color: #EF4444; /* Red */ }

/* General Button Styles */
.btn-primary {
    background-color: var(--accent-main);
    color: var(--bg-primary); /* Contrast with button color */
    border: none;
    border-radius: 1rem;
    padding: 0.85rem 1.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease-in-out, transform 0.2s ease;
    box-shadow: 0 5px 15px rgba(var(--accent-main), 0.3);
}

.btn-primary:hover {
    background-color: var(--accent-hover);
    box-shadow: 0 8px 20px rgba(var(--accent-main), 0.4), 0 0 15px var(--accent-glow);
    transform: translateY(-3px) scale(1.02); /* More pronounced lift and slight scale */
}

.form-control {
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    border-radius: 0.75rem;
    padding: 0.75rem 1rem;
    transition: all 0.3s ease, transform 0.2s ease;
}

.form-control::placeholder {
    color: var(--text-secondary);
    opacity: 0.7;
}

.form-control:focus {
    border-color: var(--input-focus-border);
    box-shadow: 0 0 0 4px var(--accent-glow);
    outline: none;
    transform: translateY(-1px) scale(1.005);
}

.card {
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 1rem;
    padding: 1.5rem;
    box-shadow: 0 4px 15px var(--shadow-color);
}

/* AI Chat Styles */
.chat-container {
    width: 100%; /* Take full width of its parent (main) */
    margin: 0; /* Remove auto margin, controlled by main layout */
    display: flex;
    flex-direction: column;
    height: 100%; /* Take full height of its parent (main) */
    border-radius: 1.5rem;
    overflow: hidden;
    background: var(--glass-bg); /* Use glass-bg for chat container too */
    backdrop-filter: blur(30px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    box-shadow: 0 8px 30px var(--shadow-color);
}

.chat-header {
    padding: 1.2rem 1.5rem;
    border-bottom: 1px solid var(--glass-border);
    text-align: center;
    background-color: var(--glass-bg); /* Match container background */
    font-weight: 600;
    font-size: 1.1rem;
    color: var(--text-primary);
}

.chat-box {
    flex-grow: 1;
    padding: 1.5rem;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    background-color: var(--bg-secondary); /* Chat background distinct from glass-bg */
    scroll-behavior: smooth;
}

.chat-message {
    display: flex;
    flex-direction: column;
    max-width: 75%; /* Slightly less wide */
    animation: fadeIn 0.5s ease-out;
    transition: transform 0.2s ease-in-out, box-shadow 0.2s ease-in-out;
}

.chat-message:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);

.message-content {
    padding: 1rem 1.25rem;
    border-radius: 1.25rem; /* More rounded */
    line-height: 1.6;
    word-wrap: break-word;
    white-space: pre-wrap; /* Preserve whitespace and line breaks */
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
}

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

/* User Message */
.user-message {
    align-self: flex-end;
    align-items: flex-end;
}

.user-message .message-content {
    background-color: var(--accent-main);
    color: var(--bg-primary); /* Text contrasts with accent */
    border-bottom-right-radius: 0.5rem; /* Softer edge */
}

/* AI Message */
.ai-message {
    align-self: flex-start;
    align-items: flex-start;
}

.ai-message .message-content {
    background: var(--bg-tertiary); /* Lighter/Darker shade for AI */
    border: 1px solid var(--glass-border);
    color: var(--text-primary);
    border-bottom-left-radius: 0.5rem; /* Softer edge */
}

.ai-message.error-message .message-content {
    background-color: #ef4444; /* Red for errors */
    color: #fee2e2;
}

/* Typing Indicator */
.typing-indicator {
    padding: 0.5rem 1rem;
    display: flex;
    align-items: center;
}

.typing-indicator span {
    height: 10px; /* Slightly larger */
    width: 10px;
    margin: 0 3px; /* More spacing */
    background-color: var(--text-secondary);
    border-radius: 50%;
    display: inline-block;
    animation: bounce 1.4s infinite ease-in-out both;
}

.typing-indicator span:nth-child(1) { animation-delay: -0.32s; }
.typing-indicator span:nth-child(2) { animation-delay: -0.16s; }

@keyframes bounce {
    0%, 80%, 100% { transform: scale(0); }
    40% { transform: scale(1.0); }
}

/* Chat Input */
.chat-input-area {
    padding: 1.5rem;
    border-top: 1px solid var(--glass-border);
    background-color: var(--glass-bg);
    display: flex; /* Use flex for layout */
    align-items: center;
    gap: 0.75rem;
}

.chat-input {
    background: var(--bg-secondary); /* Input background */
    border: 1px solid var(--border-color);
    border-radius: 2rem; /* Fully rounded pill shape */
    color: var(--text-primary);
    padding: 0.9rem 1.5rem;
    flex-grow: 1;
    outline: none;
    transition: all 0.3s ease, transform 0.2s ease;
    font-size: 1rem;
}

.chat-input:focus {
    border-color: var(--input-focus-border);
    box-shadow: 0 0 0 4px var(--accent-glow);
    outline: none;
    transform: translateY(-1px) scale(1.005);
}

.send-button {
    background: var(--accent-main);
    border: none;
    border-radius: 50%;
    width: 52px; /* Slightly larger button */
    height: 52px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--bg-primary); /* Icon color */
    cursor: pointer;
    transition: all 0.3s ease-in-out;
    box-shadow: 0 4px 12px rgba(var(--accent-main), 0.3);
}

.send-button:hover {
    background: var(--accent-hover);
    box-shadow: 0 6px 16px rgba(var(--accent-main), 0.4), 0 0 10px var(--accent-glow);
    transform: translateY(-1px) scale(1.03);
}

/* Code Block Styles */
.code-block-wrapper {
    margin-top: 1rem;
    border-radius: 0.75rem;
    overflow: hidden;
    border: 1px solid var(--glass-border);
    box-shadow: 0 4px 15px var(--shadow-color);
}
.code-block-header {
    background: var(--bg-tertiary);
    padding: 0.75rem 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.9rem;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--glass-border);
}
.copy-code-btn {
    background: var(--accent-main);
    color: var(--bg-primary);
    border: none;
    padding: 0.35rem 0.7rem;
    border-radius: 0.5rem;
    cursor: pointer;
    font-size: 0.8rem;
    transition: all 0.3s ease;
}
.copy-code-btn:hover {
    background: var(--accent-hover);
    transform: translateY(-1px);
}
pre {
    margin: 0;
    padding: 1.2rem;
    background: var(--bg-secondary);
    color: var(--text-primary);
    overflow-x: auto;
    font-size: 0.9rem;
}
code {
    font-family: 'Fira Code', 'Courier New', monospace;
    font-size: 0.9rem;
}

/* Utility for Flexbox Layout */
.flex-1 { flex: 1; }
.relative { position: relative; }
.z-10 { z-index: 10; }

/* Responsive adjustments */
@media (max-width: 1024px) {
    .app-container {
        flex-direction: column;
        padding: 1rem;
        gap: 1rem;
    }

    aside {
        width: 100%;
        height: auto;
        position: relative;
        top: 0;
    }

    .chat-container {
        max-width: 100%;
        height: 70vh; /* Adjust height for smaller screens */
    }
}