/* AgentCore MCP Chatbot Styles */

/* Font Definitions */
@font-face {
    font-family: 'Amazon Ember';
    src: url('/fonts/AmazonEmber_Th.ttf') format('truetype');
    font-weight: 100;
    font-style: normal;
}

@font-face {
    font-family: 'Amazon Ember Display';
    src: url('/fonts/AmazonEmberDisplay_Lt.ttf') format('truetype');
    font-weight: 300;
    font-style: normal;
}

@font-face {
    font-family: 'Amazon Ember Display';
    src: url('/fonts/AmazonEmberDisplay_Rg.ttf') format('truetype');
    font-weight: 400;
    font-style: normal;
}

@font-face {
    font-family: 'Amazon Ember Display';
    src: url('/fonts/AmazonEmberDisplay_Md.ttf') format('truetype');
    font-weight: 500;
    font-style: normal;
}

@font-face {
    font-family: 'Amazon Ember Display';
    src: url('/fonts/AmazonEmberDisplay_He.ttf') format('truetype');
    font-weight: 600;
    font-style: normal;
}

@font-face {
    font-family: 'Amazon Ember Display';
    src: url('/fonts/AmazonEmberDisplay_Bd.ttf') format('truetype');
    font-weight: 700;
    font-style: normal;
}

@font-face {
    font-family: 'Ember Modern Display';
    src: url('/fonts/EmberModernDisplayV1.1-Regular.otf') format('opentype');
    font-weight: 400;
    font-style: normal;
}

@font-face {
    font-family: 'Ember Modern Display';
    src: url('/fonts/EmberModernDisplayV1.1-Italic.otf') format('opentype');
    font-weight: 400;
    font-style: italic;
}

@font-face {
    font-family: 'Ember Modern Display';
    src: url('/fonts/EmberModernDisplayV1.1-Bold.otf') format('opentype');
    font-weight: 700;
    font-style: normal;
}

@font-face {
    font-family: 'Ember Modern Display';
    src: url('/fonts/EmberModernDisplayV1.1-BoldItalic.otf') format('opentype');
    font-weight: 700;
    font-style: italic;
}

/* ── Theme Variables ─────────────────────────────────────────────── */
:root {
    --bg-primary: #f5f5f5;
    --bg-secondary: #ffffff;
    --bg-header: #232f3e;
    --bg-tools-header: #ff9900;
    --text-primary: #232f3e;
    --text-secondary: #666;
    --text-inverse: #ffffff;
    --border-color: #ddd;
    --shadow: rgba(0, 0, 0, 0.1);
    --message-user-bg: #0073bb;
    --message-user-text: #ffffff;
    --message-assistant-bg: #e9ecef;
    --message-assistant-text: #232f3e;
    --tool-bg: #fff3cd;
    --tool-border: #ff9900;
    --tool-content-bg: #fff;
    --error-bg: #f8d7da;
    --error-text: #721c24;
    --error-border: #f5c6cb;
    --input-border: #ddd;
    --input-focus: #232f3e;
    --scrollbar-track: #f1f1f1;
    --scrollbar-thumb: #888;
    --scrollbar-thumb-hover: #555;
    --sidebar-width: 380px;
    --left-panel-width: 320px;
}

[data-theme="dark"] {
    --bg-primary: #2a3850;
    --bg-secondary: #2A3A4E;
    --bg-header: #161D26;
    --bg-tools-header: #161D26;
    --text-primary: #D5DBDB;
    --text-secondary: #879196;
    --text-inverse: #F2F3F3;
    --border-color: #37475A;
    --shadow: rgba(0, 0, 0, 0.5);
    --message-user-bg: #37475A;
    --message-user-text: #F2F3F3;
    --message-assistant-bg: #1A2332;
    --message-assistant-text: #D5DBDB;
    --tool-bg: #1A2332;
    --tool-border: #FF9900;
    --tool-content-bg: #161D26;
    --error-bg: #3f1f1f;
    --error-text: #fca5a5;
    --error-border: #7f1d1d;
    --input-border: #37475A;
    --input-focus: #FF9900;
    --scrollbar-track: #1A2332;
    --scrollbar-thumb: #37475A;
    --scrollbar-thumb-hover: #4A6078;
}

* { transition: background-color 1s ease, color 1s ease, border-color 1s ease; }
* { box-sizing: border-box; }

body {
    font-family: 'Ember Modern Display', -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Helvetica', 'Arial', sans-serif;
    margin: 0;
    padding: 0;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    height: 100vh;
    display: grid;
    grid-template-rows: auto 1fr auto;
    grid-template-columns: 1fr;
    overflow: hidden;
}

/* Middle row: left panel + main side by side */
.app-row {
    display: flex;
    flex-direction: row;
    min-height: 0;
    overflow: hidden;
}

/* ── Unified Left Panel ──────────────────────────────────────────── */
.left-panel {
    width: var(--left-panel-width);
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    background-color: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    transition: width 0.3s ease, opacity 0.3s ease;
    overflow: hidden;
    z-index: 150;
    position: relative;
    box-shadow: 2px 0 8px rgba(0, 0, 0, 0.5);
}

.left-panel.collapsed {
    width: 0;
    border-right: none;
}

/* ── Left Panel Tab Bar ──────────────────────────────────────────── */
.left-panel-tabs {
    display: flex;
    flex-shrink: 0;
    background-color: #161D26;
    border-bottom: 1px solid var(--border-color);
}

.left-panel-tab {
    flex: 1;
    padding: 0.6rem 1rem;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--text-secondary);
    font-family: inherit;
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    transition: color 0.2s, border-color 0.2s;
}

.left-panel-tab:hover {
    color: var(--text-primary);
}

.left-panel-tab.active {
    color: #FF9900;
    border-bottom-color: #FF9900;
}

/* ── Left Panel Content ──────────────────────────────────────────── */
.left-panel-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
}

.left-panel-tab-content {
    display: none;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

.left-panel-tab-content.active {
    display: flex;
}

/* Tools tab: the sidebar-content inside it scrolls */
#toolsTabContent .sidebar-content {
    flex: 1;
    overflow-y: auto;
    min-height: 0;
}

/* Chats tab: conversation list scrolls */
#chatsTabContent .conversation-list {
    flex: 1;
    overflow-y: auto;
    min-height: 0;
}

/* ── Header ──────────────────────────────────────────────────────── */
header {
    background-color: #161D26;
    color: var(--text-inverse);
    padding: 1rem 1rem;
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
    border-bottom: 1px solid #232F3E;
    flex-shrink: 0;
    z-index: 100;
    position: relative;
}

header h1 {
    margin: 0;
    font-size: 1.4rem;
    font-weight: 600;
    font-family: "Ember Modern Display";
    line-height: 2.5rem;
    color: #879196;
}

.header-left-zone {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    justify-self: start;
    cursor: pointer;
    padding: 0.25rem 0.5rem;
    border-radius: 6px;
    transition: background-color 0.2s;
}

.header-left-zone:hover {
    background-color: rgba(255, 255, 255, 0.05);
}

.header-starburst-btn {
    width: 28px;
    height: 28px;
    flex-shrink: 0;
    opacity: 0.6;
    transition: opacity 0.2s;
}

.header-starburst-btn.active {
    opacity: 1;
}

.header-left-zone:hover .header-starburst-btn {
    opacity: 1;
}

.header-left-labels {
    display: flex;
    flex-direction: column;
    gap: 0;
    line-height: 1.2;
}

.header-tools-label {
    font-size: 0.8rem;
    font-weight: 500;
    color: #879196;
}

.header-thinking-text {
    font-size: 0.65rem;
    color: #879196;
    opacity: 0.7;
    white-space: nowrap;
}

.thinking-container-inline {
    display: flex;
    align-items: center;
}

.header-center-zone {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    justify-self: center;
}

.header-logo {
    height: 2.5rem;
    width: auto;
}

.header-right-zone {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.25rem;
}

/* ── Server Info ─────────────────────────────────────────────────── */
.server-info {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.75rem;
    color: var(--text-inverse);
    opacity: 0.9;
}

.server-status {
    font-size: 0.6rem;
    animation: pulse 2s ease-in-out infinite;
}

.server-status.connected { color: #00AC00; animation: none; }
.server-status.disconnected { color: #ef4444; animation: none; }

@keyframes pulse {
    0%, 100% { opacity: 0.5; }
    50% { opacity: 1; }
}

.server-text { font-weight: 500; }

/* ── Model Selector ──────────────────────────────────────────────── */
.model-selector-wrapper {
    position: relative;
    display: block;
    text-align: right;
    margin: 0;
    line-height: 1;
}

.model-selector-selected {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    cursor: pointer;
    padding: 0 0.35rem;
    border-radius: 3px;
    transition: background-color 0.15s;
    line-height: 1;
}

.model-selector-selected:hover { background-color: rgba(255, 255, 255, 0.08); }

.model-selector-label {
    font-size: 0.55rem;
    font-weight: 500;
    opacity: 0.5;
    color: var(--text-inverse);
    transition: opacity 0.15s;
}

.model-selector-selected:hover .model-selector-label { opacity: 0.8; }

.model-selector-chevron {
    font-size: 0.5rem;
    opacity: 0.35;
    color: var(--text-inverse);
    transition: transform 0.2s, opacity 0.15s;
}

.model-selector-wrapper.open .model-selector-chevron { transform: rotate(180deg); opacity: 0.7; }
.model-selector-selected:hover .model-selector-chevron { opacity: 0.6; }

.model-selector-dropdown {
    position: absolute;
    right: 0;
    top: calc(100% + 4px);
    min-width: 200px;
    background: #1a1a1a;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    padding: 0.3rem;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
    z-index: 1000;
    opacity: 0;
    transform: translateY(-4px);
    pointer-events: none;
    transition: opacity 0.15s, transform 0.15s;
}

.model-selector-wrapper.open .model-selector-dropdown {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

.model-selector-option {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.45rem 0.6rem;
    border-radius: 5px;
    cursor: pointer;
    transition: background-color 0.1s;
}

.model-selector-option:hover { background-color: rgba(255, 255, 255, 0.07); }
.model-selector-option.active { background-color: rgba(139, 92, 246, 0.15); }

.model-option-name {
    font-size: 0.72rem;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.85);
}

.model-selector-option.active .model-option-name { color: rgb(167, 139, 250); }

.model-option-provider {
    font-size: 0.6rem;
    font-weight: 400;
    color: rgba(255, 255, 255, 0.3);
    margin-left: 1rem;
}

/* ── Theme Toggle ────────────────────────────────────────────────── */
.theme-toggle {
    background: none;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 600;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
}

.theme-toggle:hover { background-color: rgba(255, 255, 255, 0.1); transform: scale(1.05); }
.theme-toggle::before { content: '🌙'; font-size: 1.2rem; }
[data-theme="dark"] .theme-toggle::before { content: '☀️'; }


/* ── Main Content Area ───────────────────────────────────────────── */
main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    min-width: 0;
    overflow: hidden;
    background: linear-gradient(180deg, var(--bg-primary) 0%, color-mix(in srgb, var(--bg-primary) 78%, black) 100%);
}

#conversation {
    flex: 1;
    overflow-y: auto;
    overflow-x: visible;
    padding: 1rem 1rem 1rem 3.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    max-width: 1400px;
    width: 100%;
    margin: 0 auto;
}

/* ── Footer ───────────────────────────────────────────────────────── */
.app-footer {
    background-color: #161D26;
    border-top: 1px solid #232F3E;
    flex-shrink: 0;
    box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.5);
    z-index: 100;
    position: relative;
}

.input-area {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 1.25rem 1rem 0.5rem;
    max-width: 800px;
    margin: 0 auto;
    width: 100%;
}

#messageInput {
    flex: 1;
    padding: 0.5rem 0.75rem;
    border: 2px solid var(--input-border);
    border-radius: 8px;
    font-family: inherit;
    font-size: 0.95rem;
    resize: none;
    height: 2.5rem;
    min-height: 2.5rem;
    max-height: 2.5rem;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    outline: none;
    transition: border-color 0.2s;
    line-height: 1.4;
    overflow: hidden;
    box-sizing: border-box;
}

#messageInput:focus {
    border-color: var(--input-focus);
}

#sendButton {
    padding: 0 1.5rem;
    height: 2.5rem;
    background-color: #FF9900;
    color: #161D26;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-family: inherit;
    font-size: 0.95rem;
    font-weight: 600;
    transition: background-color 0.2s, opacity 0.2s;
}

#sendButton:hover { background-color: #EC7211; }
#sendButton:disabled { opacity: 0.5; cursor: not-allowed; }

/* ── Service Icons Row (footer) ──────────────────────────────────── */
.service-icons-row {
    display: flex;
    justify-content: center;
    gap: 1rem;
    padding: 0.25rem 0 0.5rem;
}

.service-icon {
    width: 24px;
    height: 24px;
    object-fit: contain;
    opacity: 0.3;
    filter: grayscale(100%);
    transition: opacity 0.3s, filter 0.3s, box-shadow 0.3s;
    cursor: default;
}

.service-icon.active {
    opacity: 1;
    filter: grayscale(0%);
    animation: serviceGlow 1.5s ease-in-out infinite;
}

@keyframes serviceGlow {
    0%, 100% { filter: grayscale(0%) drop-shadow(0 0 3px rgba(255, 153, 0, 0.4)); }
    50% { filter: grayscale(0%) drop-shadow(0 0 8px rgba(255, 153, 0, 0.7)); }
}

/* ── Message Bubbles ─────────────────────────────────────────────── */
.message {
    padding: 0.75rem 1rem;
    border-radius: 12px;
    max-width: 85%;
    word-wrap: break-word;
    animation: fadeIn 0.3s ease;
    font-size: 1.1rem;
    line-height: 1.6;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.4);
    flex-shrink: 0;
}

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

.message.assistant {
    background-color: var(--message-assistant-bg);
    color: var(--message-assistant-text);
    align-self: flex-start;
    border-bottom-left-radius: 4px;
    border: thin solid #23303e;
}

.message.assistant.streaming {
    opacity: 0.7;
    font-style: italic;
    white-space: pre-wrap;
}

.message.assistant.assistant-thought {
    opacity: 0.5;
    font-size: 0.85rem;
    font-style: italic;
    padding-left: 0.75rem;
    box-shadow: none;
}

/* Welcome message — wide enough for 2+ thumbnail columns */
.message.assistant.welcome-message {
    max-width: none;
    min-width: min(100%, 960px);
}

/* Any assistant message with an image grid gets at least 3 columns */
.message.assistant:has(.image-grid) {
    max-width: none;
    min-width: min(100%, 960px);
}

/* ── Message Content Styles ──────────────────────────────────────── */
.message p { margin: 0.25rem 0; }
.message p:first-child { margin-top: 0; }
.message p:last-child { margin-bottom: 0; }

.message code {
    background-color: rgba(0, 0, 0, 0.15);
    padding: 0.15rem 0.35rem;
    border-radius: 3px;
    font-size: 0.85em;
}

.message pre {
    background-color: #1e1e1e;
    padding: 0.75rem;
    border-radius: 6px;
    overflow-x: auto;
    margin: 0.5rem 0;
}

.message pre code {
    background: none;
    padding: 0;
    font-size: 0.85em;
    color: #d4d4d4;
}

.message a { color: #FF9900; text-decoration: none; }
.message a:hover { text-decoration: underline; }

.message table {
    border-collapse: collapse;
    margin: 0.5rem 0;
    width: 100%;
    font-size: 0.9em;
}

.message th, .message td {
    border: 1px solid var(--border-color);
    padding: 0.4rem 0.6rem;
    text-align: left;
}

.message th {
    background-color: rgba(0, 0, 0, 0.1);
    font-weight: 600;
}

.message img {
    max-width: 100%;
    border-radius: 4px;
}

/* ── Image Grid ──────────────────────────────────────────────────── */
.image-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, 302px);
    gap: 0.5rem;
    margin: 0.5rem 0;
}

.image-grid-item {
    width: 302px;
    overflow: hidden;
    border-radius: 6px;
    background: rgba(0,0,0,0.1);
    animation: gridCellFadeIn 0.4s ease both;
    position: relative;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
    border: 1px solid #232F3E;
}

.image-grid-item img {
    width: 302px;
    height: 170px;
    object-fit: cover;
    display: block;
    border-radius: 6px 6px 0 0;
}

.image-grid-item .image-caption {
    padding: 0.25rem 0.4rem;
    font-size: 0.75rem;
    max-width: 302px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    background-color: #161D26;
}

.image-grid-item .image-caption a {
    color: inherit;
    text-decoration: none;
}

.image-grid-item .image-caption a:hover {
    text-decoration: underline;
}

/* No-thumbnail placeholder */
.no-thumb-placeholder {
    width: 302px;
    height: 170px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px 6px 0 0;
    background: linear-gradient(135deg, #1a2332 0%, #2a3a4e 50%, #1e2d3d 100%);
    position: relative;
    overflow: hidden;
}

.no-thumb-placeholder::before {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(ellipse at 60% 40%, rgba(118, 56, 250, 0.08) 0%, transparent 70%);
}

.no-thumb-placeholder svg {
    width: 64px;
    height: 64px;
    opacity: 0.13;
    filter: grayscale(100%) brightness(1.8);
}

.filmstrip-active {
    cursor: ew-resize;
}

/* ── Grid Size Slider ────────────────────────────────────────────── */
.grid-size-bar {
    position: sticky;
    top: 0;
    z-index: 10;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.15rem 0.5rem;
    background: var(--message-assistant-bg);
    border-radius: 12px;
    margin-bottom: 0.15rem;
    opacity: 0.25;
    transition: opacity 0.3s;
}

.grid-size-bar:hover {
    opacity: 1;
}

.grid-size-slider {
    width: 80px;
    accent-color: var(--text-secondary);
    cursor: pointer;
    height: 2px;
}

.grid-size-label {
    font-size: 0.6rem;
    color: var(--text-secondary);
    opacity: 0;
    transition: opacity 0.2s;
    min-width: 3.5rem;
}

.grid-size-label.visible { opacity: 1; }

/* ── Tool Invocations (inside left panel) ────────────────────────── */
.tool-invocation {
    padding: 0.75rem;
    margin: 0.5rem;
    background-color: var(--tool-bg);
    border-radius: 6px;
    font-size: 0.8rem;
    animation: fadeIn 0.3s ease;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
    position: relative;
}

.tool-header {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    margin-bottom: 0.25rem;
}

.tool-header-text {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.tool-name {
    display: flex;
    align-items: center;
    font-weight: 600;
    color: var(--text-primary);
}

.tool-name-icon {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    width: 32px;
    height: 32px;
    object-fit: contain;
    flex-shrink: 0;
    opacity: 0.4;
}

.tool-name-icon-emoji {
    position: absolute;
    top: 0.4rem;
    right: 0.5rem;
    font-size: 1.4rem;
    opacity: 0.4;
}

.tool-section-collapsible {
    margin-top: 0.4rem;
}

.tool-section-collapsible summary {
    cursor: pointer;
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-secondary);
    user-select: none;
    padding: 0.15rem 0;
}

.tool-section-collapsible summary:hover {
    color: var(--text-primary);
}

.tool-summary-error {
    color: #ef4444 !important;
}

.tool-summary-skipped {
    color: #f59e0b !important;
}

.tool-parameters {
    margin-top: 0.25rem;
    max-height: 200px;
    overflow-y: auto;
}

.tool-parameters pre {
    margin: 0;
    font-size: 0.65rem;
    background: var(--tool-content-bg);
    padding: 0.4rem;
    border-radius: 4px;
    overflow-x: auto;
}

.tool-result, .tool-error {
    margin-top: 0.25rem;
    padding: 0.4rem;
    border-radius: 4px;
    font-size: 0.65rem;
    max-height: 300px;
    overflow-y: auto;
    word-break: break-word;
    background: var(--tool-content-bg);
}

.tool-error {
    color: #ef4444;
    border: 1px solid rgba(239, 68, 68, 0.3);
}

.tool-skipped {
    opacity: 0.6;
}

.tool-timing {
    font-size: 0.75em;
    color: #888;
}

.tool-phase {
    font-size: 0.65em;
    color: #f59e0b;
    font-style: italic;
    margin-top: 1px;
}

.tool-elapsed {
    color: #f59e0b;
}

/* ── JSON Tree ───────────────────────────────────────────────────── */
.json-tree {
    font-family: monospace;
    font-size: 0.8rem;
    line-height: 1.4;
}

.json-toggle {
    cursor: pointer;
    user-select: none;
}

.json-content {
    padding-left: 1rem;
}

/* ── Error Display ───────────────────────────────────────────────── */
#errorDisplay {
    padding: 0 1rem;
}

.error-message {
    background-color: var(--error-bg);
    color: var(--error-text);
    border: 1px solid var(--error-border);
    padding: 0.75rem 1rem;
    border-radius: 8px;
    margin: 0.5rem 0;
    animation: fadeIn 0.3s ease, shake 0.3s ease;
}

/* ── Thinking Placeholder (in conversation) ──────────────────────── */
.thinking-placeholder {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 1rem;
    background: transparent;
    max-width: 400px;
    box-shadow: none;
    border: none;
    position: relative;
    margin-left: 0;
}

.thinking-placeholder .agentcore-spinner {
    position: absolute;
    left: -44px;
    top: 50%;
    transform: translateY(-50%);
    flex-shrink: 0;
}

.thinking-placeholder .thinking-status {
    font-size: 0.8rem;
    color: var(--text-secondary);
    white-space: nowrap;
}

/* ── AgentCore Spinner SVG ───────────────────────────────────────── */
.agentcore-spinner {
    width: 36px;
    height: 36px;
    flex-shrink: 0;
}

.agentcore-spinner .starburst-outer,
.agentcore-spinner .starburst-inner {
    transition: opacity 0.3s;
}

.agentcore-spinner.tool-executing .starburst-outer,
.agentcore-spinner.tool-executing .starburst-inner {
    opacity: 0.3;
}

/* ── Header Starburst ────────────────────────────────────────────── */
.header-starburst {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    opacity: 0.3;
    transition: opacity 0.3s;
}

.header-starburst.active {
    opacity: 1;
}

/* ── Typing Indicator (in sidebar header) ────────────────────────── */
.typing-indicator {
    display: flex;
    align-items: center;
    gap: 0.3rem;
}

.typing-text {
    font-size: 0.65rem;
    opacity: 0.8;
}

/* ── Composing Grid (placeholder animation) ──────────────────────── */
.composing-grid {
    display: grid;
    grid-template-columns: repeat(3, 40px);
    gap: 4px;
    margin-top: 0.5rem;
}

.composing-grid-cell {
    width: 40px;
    height: 28px;
    border-radius: 3px;
    background: var(--border-color);
    animation: blink 1.5s ease-in-out infinite;
}

.composing-grid-cell:nth-child(2) { animation-delay: 0.2s; }
.composing-grid-cell:nth-child(3) { animation-delay: 0.4s; }
.composing-grid-cell:nth-child(4) { animation-delay: 0.6s; }
.composing-grid-cell:nth-child(5) { animation-delay: 0.8s; }
.composing-grid-cell:nth-child(6) { animation-delay: 1.0s; }

/* ── Streaming Cursor ────────────────────────────────────────────── */
.streaming-cursor::after {
    content: '▊';
    animation: blink 1s step-end infinite;
    color: var(--text-secondary);
}

/* ── Empty State ─────────────────────────────────────────────────── */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--text-secondary);
    font-size: 1.1rem;
    gap: 0.5rem;
}

/* ── Scrollbar Styles ────────────────────────────────────────────── */
#conversation::-webkit-scrollbar,
.sidebar-content::-webkit-scrollbar,
.conversation-list::-webkit-scrollbar {
    width: 6px;
}

#conversation::-webkit-scrollbar-track,
.sidebar-content::-webkit-scrollbar-track,
.conversation-list::-webkit-scrollbar-track {
    background: var(--scrollbar-track);
}

#conversation::-webkit-scrollbar-thumb,
.sidebar-content::-webkit-scrollbar-thumb,
.conversation-list::-webkit-scrollbar-thumb {
    background: var(--scrollbar-thumb);
    border-radius: 3px;
}

#conversation::-webkit-scrollbar-thumb:hover,
.sidebar-content::-webkit-scrollbar-thumb:hover,
.conversation-list::-webkit-scrollbar-thumb:hover {
    background: var(--scrollbar-thumb-hover);
}

/* ── Responsive ──────────────────────────────────────────────────── */
@media (max-width: 768px) {
    .left-panel {
        position: fixed;
        left: 0;
        top: 0;
        bottom: 0;
        z-index: 300;
        box-shadow: 2px 0 8px var(--shadow);
    }

    .left-panel.collapsed {
        width: 0;
        box-shadow: none;
    }

    .message { max-width: 95%; }
    
    header h1 { font-size: 0.85rem; }
}

/* ── Keyframes ───────────────────────────────────────────────────── */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(4px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

@keyframes typing {
    0%, 100% { opacity: 0.3; }
    50% { opacity: 1; }
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-4px); }
    75% { transform: translateX(4px); }
}

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

@keyframes agentcoreSpin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

@keyframes gridCellFadeIn {
    from { opacity: 0; transform: scale(0.95); }
    to { opacity: 1; transform: scale(1); }
}

/* ── Login Overlay ───────────────────────────────────────────────── */
.login-overlay {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(22, 29, 38, 0.95);
    backdrop-filter: blur(8px);
}

.login-overlay.hidden {
    display: none;
}

.login-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    padding: 2.5rem 3rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.6);
    max-width: 360px;
    width: 100%;
}

.login-logo-icon {
    width: 56px;
    height: 56px;
    opacity: 0.8;
}

.login-title {
    margin: 0;
    font-size: 1.4rem;
    font-weight: 600;
    color: var(--text-primary);
    font-family: 'Ember Modern Display';
}

.login-subtitle {
    margin: 0;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.login-button {
    margin-top: 0.5rem;
    padding: 0.6rem 2rem;
    background-color: #FF9900;
    color: #161D26;
    border: none;
    border-radius: 8px;
    font-family: inherit;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.2s;
}

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

/* ── Conversation List (inside Chats tab) ────────────────────────── */
.conversation-list-header {
    padding: 0.75rem;
    flex-shrink: 0;
}

.new-conversation-btn {
    width: 100%;
    padding: 0.5rem 0.75rem;
    background: transparent;
    color: var(--text-secondary);
    border: 1px dashed var(--border-color);
    border-radius: 6px;
    font-family: inherit;
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.2s, color 0.2s, border-color 0.2s;
}

.new-conversation-btn:hover {
    background-color: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
    border-color: var(--text-secondary);
}

.conversation-list {
    flex: 1;
    overflow-y: auto;
    padding: 0 0.5rem 0.5rem;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.conversation-item,
.conversation-list-item {
    padding: 0.5rem 0.6rem;
    border-radius: 6px;
    cursor: pointer;
    transition: background-color 0.15s;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.conversation-item:hover,
.conversation-list-item:hover {
    background-color: rgba(255, 255, 255, 0.05);
}

.conversation-item.active,
.conversation-list-item.active {
    background-color: rgba(255, 153, 0, 0.1);
    border-left: 2px solid #FF9900;
}

.conversation-item-title {
    font-size: 0.78rem;
    font-weight: 500;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.conversation-item-time,
.conversation-item-timestamp {
    font-size: 0.6rem;
    color: var(--text-secondary);
    opacity: 0.7;
}

.conversation-list-empty {
    padding: 1rem 0.6rem;
    font-size: 0.75rem;
    color: var(--text-secondary);
    opacity: 0.6;
    text-align: center;
}

.conversation-list-loading {
    padding: 1.2rem 0.6rem;
    font-size: 0.75rem;
    color: var(--text-secondary);
    opacity: 0.6;
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.session-loading-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--text-secondary);
    opacity: 0.5;
    animation: sessionPulse 1.2s ease-in-out infinite;
}

@keyframes sessionPulse {
    0%, 100% { opacity: 0.3; transform: scale(0.8); }
    50% { opacity: 0.8; transform: scale(1.2); }
}

.session-service-icons {
    display: flex;
    gap: 2px;
    margin-bottom: 2px;
}

.session-service-icon {
    width: 16px;
    height: 16px;
    border-radius: 3px;
    filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.4));
    opacity: 0.75;
    transition: opacity 0.15s;
}

.conversation-list-item:hover .session-service-icon {
    opacity: 1;
}

/* ── User Display (header) ───────────────────────────────────────── */
.user-display {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.user-display-name {
    font-size: 0.7rem;
    font-weight: 500;
    color: var(--text-secondary);
    opacity: 0.8;
}

/* ── Rich Content / Chart Container ──────────────────────────────── */
.rich-content {
    width: 100%;
    animation: fadeIn 0.3s ease;
    flex-shrink: 0;
}

.chart-container {
    background: var(--message-assistant-bg);
    border-radius: 12px;
    padding: 1rem;
    border: thin solid #23303e;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.4);
}

.chart-container canvas {
    width: 100% !important;
    max-height: 400px;
}

/* Visualization agent HTML iframe container */
.viz-container {
    margin: 0.5rem 0;
    overflow: hidden;
    flex-shrink: 0;
    min-width: 0;
    width: 100%;
}

.viz-iframe {
    display: block;
    width: 100%;
    height: 520px;
    min-height: 400px;
    border: none;
    background: transparent;
    flex-shrink: 0;
}

/* Gradient mask for visualization tool icon (starburst purple gradient) */
.tool-name-icon-gradient {
    -webkit-mask-image: url('/images/graphs.svg');
    mask-image: url('/images/graphs.svg');
    -webkit-mask-size: contain;
    mask-size: contain;
    -webkit-mask-repeat: no-repeat;
    mask-repeat: no-repeat;
    -webkit-mask-position: center;
    mask-position: center;
    background: linear-gradient(135deg, #7638fa 0%, #c084fc 50%, #9b6dfa 100%);
    opacity: 0.7;
}

/* Visualization placeholder (shown while viz agent is working) */
.viz-placeholder {
    position: relative;
    width: 100%;
    height: 520px;
    border-radius: 12px;
    background: linear-gradient(135deg, #1a2332 0%, #2a3a4e 50%, #1e2d3d 100%);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    overflow: hidden;
    border: 1px solid #23303e;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.4);
    flex-shrink: 0;
}

.viz-placeholder-icon {
    width: 72px;
    height: 72px;
    opacity: 0.15;
    animation: vizPlaceholderPulse 8s ease-in-out infinite;
}

.viz-placeholder-text {
    font-size: 0.85rem;
    color: var(--text-secondary);
    opacity: 0.6;
    animation: vizPlaceholderPulse 8s ease-in-out infinite;
}

.viz-placeholder-shimmer {
    position: absolute;
    inset: 0;
    background: linear-gradient(
        90deg,
        transparent 0%,
        rgba(255, 255, 255, 0.03) 40%,
        rgba(255, 255, 255, 0.06) 50%,
        rgba(255, 255, 255, 0.03) 60%,
        transparent 100%
    );
    background-size: 200% 100%;
    animation: vizShimmer 8s ease-in-out infinite;
    pointer-events: none;
}

@keyframes vizPlaceholderPulse {
    0%, 100% { opacity: 0.15; }
    50% { opacity: 0.3; }
}

@keyframes vizShimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}
