/* AWS Platform Engineer Agent — Professional UI */
:root {
    --aws-orange: #ff9900;
    --aws-dark: #232f3e;
    --aws-blue: #146eb4;
    --aws-light: #f9fafb;
    --text-primary: #1a1a2e;
    --text-secondary: #5f6368;
    --border: #e0e0e0;
    --bubble-agent: #ffffff;
    --bubble-user: #e3f2fd;
    --error-red: #d32f2f;
    --success-green: #137333;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--aws-light);
    display: flex;
    flex-direction: column;
    height: 100vh;
    color: var(--text-primary);
}

/* Header */
header {
    background: var(--aws-dark);
    color: white;
    padding: 0.8rem 1.5rem;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}
header h1 {
    font-size: 1.3rem;
    font-weight: 600;
    margin-bottom: 0.2rem;
}
#context-display {
    font-size: 0.78rem;
    opacity: 0.85;
    font-family: 'Consolas', monospace;
}
#context-display .ctx-label { opacity: 0.6; }
#context-display .ctx-value { font-weight: 600; color: var(--aws-orange); }
#context-display .ctx-sep { margin: 0 0.5em; opacity: 0.4; }
.context-empty { font-style: italic; opacity: 0.6; }
#session-totals {
    font-size: 0.72rem;
    opacity: 0.75;
    font-family: 'Consolas', monospace;
    margin-top: 2px;
}
#session-totals .value { font-weight: 600; }
#session-totals .cost { color: var(--aws-orange); }
.session-empty { font-style: italic; opacity: 0.5; }

/* Region selector */
#region-selector {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    margin-top: 4px;
    font-size: 0.78rem;
}
#region-selector label {
    opacity: 0.7;
    font-family: 'Consolas', monospace;
}
#region-select {
    background: rgba(255,255,255,0.1);
    color: white;
    border: 1px solid rgba(255,255,255,0.25);
    border-radius: 4px;
    padding: 2px 6px;
    font-size: 0.78rem;
    font-family: 'Consolas', monospace;
    cursor: pointer;
    outline: none;
}
#region-select:hover { border-color: var(--aws-orange); }
#region-select:focus { border-color: var(--aws-orange); }
#region-select option { background: var(--aws-dark); color: white; }

/* Chat container */
#chat-container {
    flex: 1;
    overflow-y: auto;
    padding: 1rem 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
}

/* Messages */
.message {
    max-width: 82%;
    padding: 0.9rem 1.1rem;
    border-radius: 12px;
    line-height: 1.5;
    position: relative;
    font-size: 0.94rem;
}
.message.user {
    align-self: flex-end;
    background: var(--bubble-user);
    color: #1565c0;
    border-bottom-right-radius: 3px;
}
.message.agent {
    align-self: flex-start;
    background: var(--bubble-agent);
    border: 1px solid var(--border);
    border-bottom-left-radius: 3px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

/* Agent badge */
.agent-badge {
    display: inline-block;
    font-size: 0.65rem;
    padding: 2px 8px;
    border-radius: 10px;
    color: white;
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
}
.agent-badge.infra_query { background: var(--aws-blue); }
.agent-badge.log_analyst { background: #e53935; }
.agent-badge.provisioner { background: var(--aws-orange); color: #232f3e; }
.agent-badge.advisor { background: var(--success-green); }
.agent-badge.iam_admin { background: #7b1fa2; }
.agent-badge.coordinator { background: #757575; }
.agent-badge.error { background: var(--error-red); }

/* Agent content markdown */
.agent-content { line-height: 1.55; }
.agent-content p { margin: 0.4em 0; }
.agent-content p:first-child { margin-top: 0; }
.agent-content ul, .agent-content ol { margin: 0.4em 0; padding-left: 1.4em; }
.agent-content code {
    background: #f0f0f0;
    padding: 1px 5px;
    border-radius: 3px;
    font-family: 'Consolas', monospace;
    font-size: 0.88em;
}
.agent-content pre {
    background: #f5f5f5;
    padding: 10px 14px;
    border-radius: 6px;
    overflow-x: auto;
    font-size: 0.84em;
    line-height: 1.4;
    margin: 0.5em 0;
}
.agent-content pre code { background: none; padding: 0; }
.agent-content table { border-collapse: collapse; margin: 0.5em 0; font-size: 0.9em; width: 100%; }
.agent-content th, .agent-content td { border: 1px solid #ddd; padding: 5px 10px; text-align: left; }
.agent-content th { background: #f5f5f5; font-weight: 600; }
.agent-content h1, .agent-content h2, .agent-content h3 { margin: 0.6em 0 0.3em; }
.agent-content blockquote { border-left: 3px solid #ccc; padding-left: 0.8em; color: #555; margin: 0.4em 0; }

/* Capabilities panel */
.capabilities { font-size: 0.9rem; }
.capabilities h3 { margin: 0 0 6px; font-size: 0.95rem; color: var(--aws-dark); }
.capabilities ul { margin: 4px 0 10px; padding-left: 1.3em; }
.capabilities li { margin: 2px 0; line-height: 1.4; }
.pill {
    display: inline-block;
    padding: 1px 8px;
    margin-right: 5px;
    font-size: 0.7rem;
    border-radius: 10px;
    font-weight: 600;
}
.pill.read { background: #e3f2fd; color: var(--aws-blue); }
.pill.write { background: #fff3e0; color: #e65100; }
.pill.audit { background: #e8f5e9; color: var(--success-green); }
.pill.blocked { background: #fce4ec; color: var(--error-red); }

/* Example chips */
.example-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.example-chip {
    padding: 5px 12px;
    font-size: 0.82rem;
    border-radius: 16px;
    background: #f1f3f4;
    color: var(--aws-blue);
    cursor: pointer;
    border: 1px solid #dadce0;
    transition: all 0.15s;
}
.example-chip:hover { background: #e3f2fd; border-color: #90caf9; }

/* Suggestion chips */
.suggestion-chips { margin-top: 8px; display: flex; flex-wrap: wrap; gap: 5px; align-items: center; }
.suggestion-chips .label { font-size: 0.72rem; color: #888; margin-right: 4px; font-family: monospace; }
.suggestion-chips .example-chip { padding: 3px 9px; font-size: 0.76rem; background: #fafafa; color: #444; border-color: #e0e0e0; }
.suggestion-chips .example-chip:hover { background: #e3f2fd; color: var(--aws-blue); }

/* Token footer */
.token-footer {
    margin-top: 10px;
    padding-top: 6px;
    border-top: 1px solid #eee;
    font-size: 0.72rem;
    color: #888;
    font-family: 'Consolas', monospace;
}
.token-footer .value { font-weight: 600; color: #555; }
.token-footer .cost { color: #e65100; }
.token-footer .sep { margin: 0 0.4em; opacity: 0.5; }

/* Flow timeline */
.flow-toggle {
    background: transparent;
    border: none;
    color: var(--aws-blue);
    font-size: 0.78rem;
    cursor: pointer;
    padding: 4px 0 0;
    font-family: inherit;
}
.flow-toggle:hover { text-decoration: underline; }
.flow-timeline {
    margin-top: 0.4rem;
    padding: 0.5rem 0.7rem;
    background: #f8f9fa;
    border-left: 3px solid #dadce0;
    border-radius: 0 6px 6px 0;
    font-size: 0.8rem;
    display: none;
}
.flow-timeline.expanded { display: block; }
.flow-step { display: flex; gap: 0.5rem; padding: 0.2rem 0; line-height: 1.4; }
.flow-step-time { color: #80868b; font-family: monospace; font-size: 0.75rem; min-width: 3em; }
.flow-step-content { flex: 1; }
.flow-step-content .tool-name { font-family: monospace; color: var(--aws-blue); }

/* Thinking indicator */
.thinking-placeholder { padding: 0.7rem 1rem; min-width: 200px; }
.progress-line { font-size: 0.85rem; color: #444; margin-bottom: 6px; font-family: monospace; }
.thinking { display: inline-flex; gap: 5px; }
.thinking span {
    width: 7px; height: 7px; border-radius: 50%; background: #999;
    animation: bounce 1.2s infinite ease-in-out;
}
.thinking span:nth-child(2) { animation-delay: 0.15s; }
.thinking span:nth-child(3) { animation-delay: 0.3s; }
@keyframes bounce {
    0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
    40% { transform: scale(1); opacity: 1; }
}

/* Input area */
#input-area {
    background: white;
    padding: 0.8rem 1.5rem;
    display: flex;
    gap: 0.5rem;
    border-top: 1px solid var(--border);
}
#input-area input {
    flex: 1;
    padding: 0.75rem 1rem;
    border: 1px solid #ccc;
    border-radius: 8px;
    font-size: 0.95rem;
    outline: none;
    transition: border-color 0.15s;
}
#input-area input:focus { border-color: var(--aws-blue); }
#history-btn {
    padding: 0.75rem 0.9rem;
    background: #f1f3f4;
    color: #5f6368;
    border: 1px solid #dadce0;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.9rem;
}
#history-btn:hover { background: #e8eaed; }
#send-btn {
    padding: 0.75rem 1.5rem;
    background: var(--aws-orange);
    color: white;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    font-size: 0.95rem;
    transition: background 0.15s;
}
#send-btn:hover { background: #ec8b00; }
#send-btn:disabled { background: #ccc; cursor: default; }
#stop-btn {
    padding: 0.75rem 1.2rem;
    background: var(--error-red);
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.95rem;
}
#stop-btn:hover { background: #b71c1c; }

/* Responsive */
@media (max-width: 768px) {
    .message { max-width: 95%; }
    #input-area { padding: 0.6rem; }
}
