:root {
    /* Visma Colors - Main */
    --primary-color: #42BFB0; /* Green/Health */
    --secondary-color: #FF6E26; /* Orange/Education */
    --accent-color: #9966E5; /* Purple/Welfare */
    
    /* Visma Colors - Calmer Versions */
    --primary-light: #42BFB0; /* Green light */
    --secondary-light: #FF6E26; /* Orange light */
    --accent-light: #9966E5; /* Purple light */
    
    /* Core UI Colors */
    --background-color: #f5f7fa;
    --text-color: #333;
    --light-gray: #e0e0e0;
    --medium-gray: #999;
    --dark-gray: #666;
    --success-color: #28a745;
    --error-color: #dc3545;
    --user-message-bg: #E0F5F2; /* Light green for user messages */
    --bot-message-bg: #ffffff;
    --component-bg: #ffffff;
    --font-family: 'DM Sans', sans-serif;
}

[x-cloak] { display: none !important; }

[data-theme='dark'] {
    /* Visma Colors - Brighter for dark mode */
    --primary-color: #B185FF; /* Brighter purple for dark mode */
    --secondary-color: #FF8F4F; /* Brighter orange for dark mode */
    --accent-color: #4FD7C7; /* Brighter green for dark mode */
    
    /* Core UI Colors for dark mode */
    --background-color: #1a1a1a;
    --text-color: #e0e0e0;
    --light-gray: #333333;
    --medium-gray: #666666;
    --dark-gray: #999999;
    --user-message-bg: #372a52; /* Darker purple for user messages in dark mode */
    --bot-message-bg: #2a2a2a;
    --component-bg: #2a2a2a;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

::selection {
    background-color: var(--primary-color);
    color: white;
}

body {
    font-family: var(--font-family);
    background-color: var(--background-color);
    color: var(--text-color);
    line-height: 1.6;
    height: 100vh;
}

.container {
    width: 100%; /* Take full browser width */
    padding: 20px 40px; /* Add some padding on the sides */
    max-width: none; /* Remove the max-width constraint */
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header Styles */
header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16.5px 0; /* Increased by 10% from 15px */
    border-bottom: 1px solid var(--light-gray);
    margin-bottom: 20px;
}

.logo {
    display: flex;
    align-items: center;
}

.logo img {
    height: 44px; /* Increased by 10% from 40px */
    margin-right: 15px;
}

.logo h1 {
    font-size: 24px;
    font-weight: 600;
    color: var(--primary-color);
}

.actions {
    display: flex;
    gap: 10px;
    align-items: center;
}

/* Authentication UI Styles */
.user-info {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 5px 10px;
    background-color: var(--component-bg);
    border-radius: 20px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    margin-right: 10px;
}

.user-avatar {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    object-fit: cover;
}

.user-info span {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-color);
    max-width: 150px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.logout-button {
    color: var(--error-color);
    text-decoration: none;
    font-size: 13px;
    padding: 3px 8px;
    border-radius: 4px;
    transition: background-color 0.2s;
}

.logout-button:hover {
    background-color: rgba(220, 53, 69, 0.1);
}

.login-button {
    display: flex;
    align-items: center;
    gap: 8px;
    background-color: #4285F4;
    color: white;
    border: none;
    border-radius: 4px;
    padding: 8px 15px;
    font-size: 14px;
    cursor: pointer;
    text-decoration: none;
    transition: background-color 0.3s;
    margin-right: 10px;
}

.login-button:hover {
    background-color: #3367D6;
}

#theme-toggle,
#new-chat-button {
    background-color: var(--primary-color);
    color: white;
    border: none;
    border-radius: 6px;
    padding: 8px 15px;
    font-size: 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.3s ease;
}

#theme-toggle {
    padding: 8px;
}

#theme-toggle:hover,
#new-chat-button:hover {
    background-color: var(--secondary-color);
    transform: scale(1.05);
}

#new-chat-button:hover {
    background-color: var(--secondary-color);
}

/* Main Layout */
main {
    display: flex;
    flex-grow: 1;
    gap: 20px;
    height: calc(100vh - 150px);
}

/* Sidebar Styles */
.sidebar {
    width: 340px;
    flex-shrink: 0; /* Prevent shrinking */
    background-color: var(--component-bg);
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    padding: 20px;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

@media (max-width: 1400px) {
    .sidebar {
        width: 350px; /* Slightly narrower on medium screens */
    }
}

@media (max-width: 1200px) {
    .sidebar {
        width: 300px; /* Even narrower on smaller screens */
    }
}

.index-selector-container {
    margin-bottom: 20px;
}

#index-selector {
    width: 100%;
    padding: 10px;
    border: 1px solid var(--light-gray);
    border-radius: 6px;
    font-size: 14px;
    background-color: var(--component-bg);
    color: var(--text-color);
}

.chat-history {
    flex-grow: 1;
    overflow-y: auto;
}

.chat-history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    padding-bottom: 5px;
    border-bottom: 1px solid var(--light-gray);
}

.chat-history-header h3 {
    font-size: 16px;
    color: var(--dark-gray);
    margin: 0;
}

#chat-history-list {
    list-style: none;
}

.chat-history-item {
    padding: 10px;
    border-radius: 6px;
    margin-bottom: 8px;
    cursor: pointer;
    transition: background-color 0.2s;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.chat-history-item .thread-title {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-history-item .delete-thread {
    opacity: 0;
    margin-left: 8px;
    color: var(--medium-gray);
    transition: opacity 0.2s;
    font-size: 12px;
}

.chat-history-item:hover .delete-thread {
    opacity: 1;
}

.subtle-button {
    background: none;
    border: none;
    color: var(--medium-gray);
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    transition: all 0.2s;
}

.subtle-button:hover {
    color: var(--error-color);
    background-color: rgba(220, 53, 69, 0.1);
}

.chat-history-item:hover {
    background-color: var(--background-color);
}

.chat-history-item.active {
    background-color: var(--primary-color);
    color: white;
}

/* Chat Container Styles */
.chat-container {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    background-color: var(--component-bg);
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    overflow: hidden;
}

.chat-messages {
    flex-grow: 1;
    padding: 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.welcome-message {
    text-align: center;
    margin: 40px 0;
    color: var(--dark-gray);
}

.auth-buttons {
    margin-top: 20px;
}

.welcome-login-button {
    display: inline-block;
    background-color: var(--primary-color);
    color: white;
    padding: 12px 24px;
    border-radius: 6px;
    text-decoration: none;
    font-weight: 500;
    margin-top: 15px;
    transition: background-color 0.3s, transform 0.2s;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.welcome-login-button:hover {
    background-color: var(--secondary-color);
    text-decoration: none;
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

.welcome-message h2 {
    font-size: 24px;
    margin-bottom: 10px;
    color: var(--primary-color);
}

.message {
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 15px;
    line-height: 1.5;
    max-width: 80%;
    position: relative;
    transition: transform 0.2s ease, opacity 0.3s ease;
}

.message .message-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 10px;
    padding-top: 8px;
    border-top: 1px solid rgba(0, 0, 0, 0.05);
}

body.dark-mode .message .message-footer {
    border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.message .message-actions {
    display: flex;
    gap: 8px;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.message:hover .message-actions {
    opacity: 1;
}

.message-action-button {
    background: none;
    border: none;
    color: var(--medium-gray);
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.message-action-button:hover {
    background-color: rgba(0, 0, 0, 0.1);
    color: var(--primary-color);
}

.message-action-button.active {
    color: var(--primary-color);
}

.copy-tooltip {
    position: absolute;
    background-color: var(--dark-gray);
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    top: -24px;
    right: 0;
    opacity: 0;
    transition: opacity 0.2s ease;
    pointer-events: none;
}

.copy-tooltip.visible {
    opacity: 1;
}

.user-message {
    background-color: var(--user-message-bg);
    align-self: flex-end;
    border-bottom-right-radius: 0;
}

.bot-message {
    background-color: var(--bot-message-bg);
    align-self: flex-start;
    border-bottom-left-radius: 0;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.message-content {
    word-wrap: break-word;
}

.message-time {
    font-size: 12px;
    color: var(--medium-gray);
}

.sources-list {
    margin-top: 10px;
    font-size: 13px;
    color: var(--dark-gray);
    border-top: 1px solid var(--light-gray);
    padding-top: 8px;
    border-left: 3px solid var(--primary-color);
    padding-left: 12px;
    margin-left: 5px;
}

.sources-list h4 {
    margin-bottom: 5px;
}

.sources-list ul {
    list-style: none;
    padding-left: 5px;
}

.sources-list li {
    margin-bottom: 10px;
    display: flex;
    align-items: flex-start;
    gap: 10px;
}

.source-item {
    display: flex;
    flex-direction: row;
    align-items: flex-start;
    gap: 10px;
    padding: 15px;
    background-color: var(--component-bg);
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    margin-bottom: 15px;
    transition: transform 0.2s, box-shadow 0.2s;
}

.source-image-container {
    width: 120px;
    height: 80px;
    border-radius: 4px;
    overflow: hidden;
    flex-shrink: 0;
    background-color: var(--light-gray);
}

.source-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.source-text {
    flex-grow: 1;
}

.sources-list a {
    color: var(--primary-color);
    text-decoration: none;
}

.sources-list a:hover {
    text-decoration: underline;
}

/* Web Search Results Formatting */
.web-search-results {
    margin-top: 5px;
    line-height: 1.6;
}

/* Enhanced Web Source Styling */
.source-item[data-source-type="web"] {
    border-left: 3px solid var(--accent-color);
    padding-left: 8px;
    background-color: rgba(255, 102, 0, 0.05);
    border-radius: 4px;
}

.source-badge {
    display: inline-block;
    background-color: var(--accent-color);
    color: white;
    font-size: 10px;
    padding: 2px 5px;
    border-radius: 3px;
    margin-left: 5px;
}

.numbered-point {
    margin: 16px 0 6px 0;
    line-height: 1.5;
    display: flex;
    align-items: baseline;
}

.point-number {
    font-weight: bold;
    color: var(--primary-color);
    margin-right: 6px;
    flex-shrink: 0;
}

.point-title {
    font-weight: bold;
}

.news-paragraph {
    margin: 0 0 12px 0;
    padding-left: 24px;
    line-height: 1.6;
}

.point-separator {
    height: 12px;
}

.web-search-results a {
    color: var(--primary-color);
    text-decoration: none;
    border-bottom: 1px solid transparent;
    transition: border-color 0.2s ease;
}

/* Follow-up suggestions styling */
.follow-up-suggestions {
    margin-top: 15px;
    padding-top: 10px;
    border-top: 1px solid var(--light-gray);
}

.follow-up-suggestions h4 {
    font-size: 14px;
    margin-bottom: 8px;
    color: var(--dark-gray);
    font-weight: 500;
}

.follow-up-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 6px;
}

.follow-up-button {
    padding: 8px 15px;
    background-color: var(--component-bg);
    border: 1px solid var(--light-gray);
    border-radius: 18px;
    font-size: 13px;
    color: var(--text-color);
    margin-right: 10px;
    margin-bottom: 10px;
    cursor: pointer;
    transition: background-color 0.2s, transform 0.2s;
}

.follow-up-button:hover {
    background-color: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(66, 191, 176, 0.3);
}

/* Keyword suggestions styling */
.keyword-suggestions {
    margin-top: 12px;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}

.keyword-label {
    font-size: 13px;
    color: var(--dark-gray);
    font-weight: 500;
}

.keyword-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.keyword-chip {
    background-color: var(--background-color);
    border: 1px solid var(--light-gray);
    border-radius: 14px;
    padding: 3px 10px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    color: var(--dark-gray);
}

.keyword-chip:hover {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
    color: white;
}

/* Norwegian text formatting styles */
.web-search-results em {
    font-style: italic;
    color: inherit;
}

.web-search-results strong em {
    font-weight: bold;
    font-style: italic;
}

.web-search-results strong {
    font-weight: bold;
    color: inherit;
}

.web-search-results a:hover {
    border-bottom-color: var(--primary-color);
}

.point-title a {
    font-weight: bold;
}

/* Chat Input Styles */
.chat-input-container {
    display: flex;
    flex-wrap: wrap;
    padding: 15px;
    border-top: 1px solid var(--light-gray);
    background-color: var(--component-bg);
}

.search-options {
    width: 100%;
    display: flex;
    justify-content: flex-end;
    margin-bottom: 8px;
}

.toggle-container {
    display: inline-flex;
    align-items: center;
    cursor: pointer;
    user-select: none;
}

.toggle-slider {
    position: relative;
    display: inline-block;
    width: 40px;
    height: 20px;
    background-color: #f7f7f7;
    border-radius: 20px;
    margin: 0 10px;
    transition: all 0.3s;
    box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.1);
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 16px;
    width: 16px;
    left: 2px;
    bottom: 2px;
    background-color: white;
    border-radius: 50%;
    transition: all 0.3s;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

input:checked + .toggle-slider {
    background-color: var(--accent-color);
}

input:checked + .toggle-slider:before {
    transform: translateX(20px);
}

.toggle-label {
    font-size: 14px;
    color: var(--text-color);
}

#chat-input {
    flex-grow: 1;
    padding: 12px 15px;
    border: 1px solid var(--light-gray);
    border-radius: 6px;
    font-size: 15px;
    resize: none;
    max-height: 120px;
    overflow-y: auto;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

#chat-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(0, 102, 204, 0.2);
}

#send-button {
    background-color: var(--primary-color);
    color: white;
    border: none;
    border-radius: 6px;
    width: 45px;
    margin-left: 10px;
    cursor: pointer;
    transition: background-color 0.3s, transform 0.2s;
    display: flex;
    box-shadow: 0 2px 4px rgba(66, 191, 176, 0.3);
    align-items: center;
    justify-content: center;
}

#send-button:hover {
    background-color: #37a697;
    transform: translateY(-1px);
}

/* Loading Indicator */
.loading {
    padding: 20px;
    display: flex;
    justify-content: center;
}

.typing-indicator {
    display: flex;
    align-items: center;
}

.typing-indicator span {
    height: 8px;
    width: 8px;
    margin: 0 2px;
    background-color: var(--medium-gray);
    border-radius: 50%;
    display: inline-block;
    animation: bounce 1.5s infinite ease-in-out;
}

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

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

@keyframes bounce {
    0%, 60%, 100% { transform: translateY(0); }
    30% { transform: translateY(-5px); }
}

/* Footer Styles */
/* File Upload Styles */
.icon-button {
    background: none;
    border: none;
    padding: 8px;
    cursor: pointer;
    color: var(--text-color);
    border-radius: 50%;
    transition: background-color 0.2s;
}

.icon-button:hover {
    background-color: var(--background-color);
}



/* Tooltip Styles */
.simple-tooltip {
    position: absolute;
    background-color: var(--dark-gray);
    color: white;
    padding: 8px 10px;
    border-radius: 4px;
    font-size: 12px;
    max-width: 250px;
    text-align: center;
    z-index: 9999;
    pointer-events: none; /* So tooltip doesn't interfere with mouse events */
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
    animation: fadeIn 0.2s ease-out;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Modal Styles */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal.hidden {
    display: none;
}

.modal-content {
    background-color: var(--component-bg);
    border-radius: 8px;
    width: 90%;
    max-width: 500px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.modal-header {
    padding: 20px;
    border-bottom: 1px solid var(--light-gray);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    margin: 0;
    color: var(--text-color);
}

.close-modal {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--text-color);
    padding: 0;
    line-height: 1;
}

.modal-body {
    padding: 20px;
}

.upload-area {
    border: 2px dashed var(--light-gray);
    border-radius: 8px;
    padding: 40px 20px;
    text-align: center;
    cursor: pointer;
    transition: border-color 0.2s;
}

.upload-area:hover {
    border-color: var(--primary-color);
}

.upload-area i {
    font-size: 48px;
    color: var(--primary-color);
    margin-bottom: 16px;
}

.supported-formats {
    font-size: 13px;
    color: var(--medium-gray);
    margin-top: 6px;
    margin-bottom: 6px;
    font-style: italic;
}

.upload-button {
    display: inline-block;
    background-color: var(--primary-color);
    color: white;
    padding: 8px 16px;
    border-radius: 4px;
    cursor: pointer;
    margin-top: 12px;
    transition: background-color 0.2s;
}

.upload-button:hover {
    background-color: var(--secondary-color);
}

.upload-preview {
    margin-top: 20px;
    padding: 12px;
    background-color: var(--background-color);
    border-radius: 4px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.upload-preview.hidden {
    display: none;
}

.file-info {
    display: flex;
    align-items: center;
    gap: 8px;
}

.file-info i {
    color: var(--primary-color);
}

.upload-status {
    margin-top: 20px;
}

.upload-status.hidden {
    display: none;
}

.progress-bar {
    height: 4px;
    background-color: var(--light-gray);
    border-radius: 2px;
    overflow: hidden;
    margin-bottom: 8px;
}

.progress {
    height: 100%;
    background-color: var(--primary-color);
    width: 0;
    transition: width 0.3s ease;
}

.modal-footer {
    padding: 20px;
    border-top: 1px solid var(--light-gray);
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

.primary-button {
    background-color: var(--primary-color);
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.2s;
}

.primary-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.primary-button:not(:disabled):hover {
    background-color: var(--secondary-color);
}

.secondary-button {
    background-color: transparent;
    color: var(--text-color);
    border: 1px solid var(--light-gray);
    padding: 8px 16px;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.2s;
}

.secondary-button:hover {
    background-color: var(--background-color);
}

footer {
    margin-top: 20px;
    text-align: center;
    padding: 15px 0;
    border-top: 1px solid var(--light-gray);
    color: var(--medium-gray);
    font-size: 14px;
}

/* Utility Classes */
.hidden {
    display: none !important;
}

/* Responsive Styles */
@media (max-width: 992px) {
    main {
        flex-direction: column;
        height: auto;
    }
    
    .sidebar {
        width: 100%;
        margin-bottom: 20px;
        max-height: 200px;
    }
    
    .chat-container {
        height: 500px;
    }
}

@media (max-width: 768px) {
    .container {
        padding: 10px;
    }
    
    .logo img {
        height: 33px; /* Increased by 10% from 30px */
    }
    
    .logo h1 {
        font-size: 20px;
    }
    
    .message {
        max-width: 90%;
    }
}
