/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #2563eb;
    --primary-hover: #1d4ed8;
    --secondary-color: #64748b;
    --success-color: #10b981;
    --warning-color: #f59e0b;
    --error-color: #ef4444;
    --background: #f8fafc;
    --surface: #ffffff;
    --surface-hover: #f1f5f9;
    --border: #e2e8f0;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;
    --shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    --radius: 8px;
    --radius-lg: 12px;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
    background: var(--background);
    color: var(--text-primary);
    line-height: 1.6;
    height: 100vh;
    overflow: hidden;
}

.container {
    display: flex;
    flex-direction: column;
    height: 100%;
    max-width: 1200px;
    margin: 0 auto;
    background: var(--surface);
    box-shadow: var(--shadow-lg);
}

/* Header Styles */
.header {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 1rem 2rem;
    flex-shrink: 0;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.logo i {
    font-size: 1.5rem;
    color: var(--primary-color);
}

.logo h1 {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text-primary);
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.new-conversation-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: var(--radius);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.new-conversation-btn:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
}

.new-conversation-btn:active {
    transform: translateY(0);
}

.new-conversation-btn i {
    font-size: 0.875rem;
}

.agent-status {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.status-indicator {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--warning-color);
    animation: pulse 2s infinite;
}

.status-indicator.connected {
    background: var(--success-color);
    animation: none;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* Main Content */
.main-content {
    flex: 1;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.chat-container {
    flex: 1;
    overflow-y: auto;
    padding: 1rem 2rem;
    display: flex;
    flex-direction: column;
}

/* Welcome Message */
.welcome-message {
    max-width: 600px;
    margin: 2rem auto;
    text-align: center;
}

.welcome-content i.fas {
    font-size: 3rem;
    color: var(--primary-color);
    margin-bottom: 1rem;
}

.welcome-content h2 {
    font-size: 1.875rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

.welcome-content > p {
    font-size: 1.125rem;
    color: var(--text-secondary);
    margin-bottom: 2rem;
}

.features {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.feature {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem;
    background: var(--surface-hover);
    border-radius: var(--radius);
    border: 1px solid var(--border);
}

.feature i {
    color: var(--primary-color);
    font-size: 1.125rem;
}

.example-prompts h3 {
    font-size: 1.125rem;
    font-weight: 500;
    margin-bottom: 1rem;
    color: var(--text-primary);
}

.prompt-examples {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.example-btn {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.75rem 1rem;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 0.875rem;
    text-align: left;
}

.example-btn:hover {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
    transform: translateY(-1px);
}

/* Messages */
.messages {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    padding-bottom: 1rem;
}

.message {
    display: flex;
    gap: 0.75rem;
    max-width: 80%;
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.message.user {
    margin-left: auto;
    flex-direction: row-reverse;
}

.message-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.875rem;
    flex-shrink: 0;
}

.message.user .message-avatar {
    background: var(--primary-color);
    color: white;
}

.message.assistant .message-avatar {
    background: var(--surface-hover);
    color: var(--text-secondary);
}

.message-content {
    background: var(--surface-hover);
    padding: 0.75rem 1rem;
    border-radius: var(--radius-lg);
    position: relative;
}

.message.user .message-content {
    background: var(--primary-color);
    color: white;
    border-bottom-right-radius: 4px;
}

.message.assistant .message-content {
    border-bottom-left-radius: 4px;
}

.message-text {
    word-wrap: break-word;
    white-space: pre-wrap;
}

.message-time {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
}

/* Typing Indicator */
.typing-indicator {
    display: flex;
    gap: 0.75rem;
    max-width: 80%;
}

.typing-bubble {
    background: var(--surface-hover);
    padding: 0.75rem 1rem;
    border-radius: var(--radius-lg);
    border-bottom-left-radius: 4px;
}

.typing-dots {
    display: flex;
    gap: 4px;
}

.typing-dots span {
    width: 6px;
    height: 6px;
    background: var(--text-muted);
    border-radius: 50%;
    animation: typing 1.4s infinite;
}

.typing-dots span:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-dots span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typing {
    0%, 60%, 100% {
        transform: translateY(0);
        opacity: 0.4;
    }
    30% {
        transform: translateY(-10px);
        opacity: 1;
    }
}

/* Input Area */
.input-area {
    background: var(--surface);
    border-top: 1px solid var(--border);
    padding: 1rem 2rem;
    flex-shrink: 0;
}

.input-container {
    max-width: 800px;
    margin: 0 auto;
}

.input-wrapper {
    display: flex;
    gap: 0.75rem;
    align-items: end;
    padding: 0.75rem;
    background: var(--surface-hover);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    transition: border-color 0.2s ease;
}

.input-wrapper:focus-within {
    border-color: var(--primary-color);
}

#message-input {
    flex: 1;
    border: none;
    background: transparent;
    font-size: 1rem;
    color: var(--text-primary);
    resize: none;
    outline: none;
    font-family: inherit;
    line-height: 1.5;
    min-height: 24px;
    max-height: 120px;
}

#message-input::placeholder {
    color: var(--text-muted);
}

.send-button {
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: var(--radius);
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.send-button:hover:not(:disabled) {
    background: var(--primary-hover);
    transform: scale(1.05);
}

.send-button:disabled {
    background: var(--text-muted);
    cursor: not-allowed;
    transform: none;
}

.input-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 0.5rem;
    font-size: 0.75rem;
    color: var(--text-muted);
}

.powered-by {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.powered-by strong {
    color: var(--text-secondary);
}

/* Responsive Design */
@media (max-width: 768px) {
    .container {
        height: 100vh;
        max-width: none;
        margin: 0;
    }
    
    .header {
        padding: 1rem;
    }
    
    .header-actions {
        gap: 0.5rem;
    }
    
    .new-conversation-btn span {
        display: none;
    }
    
    .new-conversation-btn {
        padding: 0.5rem;
        min-width: auto;
    }
    
    .chat-container {
        padding: 1rem;
    }
    
    .input-area {
        padding: 1rem;
    }
    
    .features {
        grid-template-columns: 1fr;
    }
    
    .message {
        max-width: 90%;
    }
    
    .logo h1 {
        font-size: 1.25rem;
    }
    
    .welcome-content h2 {
        font-size: 1.5rem;
    }
    
    .welcome-content > p {
        font-size: 1rem;
    }
}

@media (max-width: 480px) {
    .header-content {
        flex-direction: column;
        gap: 0.5rem;
        text-align: center;
    }
    
    .prompt-examples {
        gap: 0.5rem;
    }
    
    .example-btn {
        font-size: 0.8rem;
        padding: 0.5rem 0.75rem;
    }
}

/* ---- A2A Debug Layout ---- */
.a2a-layout { display:flex; height:100vh; width:100%; overflow:hidden; }
.a2a-chat-side { flex:1; display:flex; overflow:hidden; min-width:0; }
.a2a-chat-side > .container { flex:1; display:flex; flex-direction:column; max-width:none !important; margin:0 !important; width:100% !important; height:100% !important; }
.a2a-debug-side { width:380px; flex-shrink:0; display:flex; flex-direction:column; padding:0.5rem; gap:0.4rem; background:#0f172a; border-left:2px solid #1e293b; overflow-y:auto; z-index:100; position:relative; }
.a2a-panel { background:#1e1b4b; border-radius:10px; overflow:hidden; display:flex; flex-direction:column; flex-shrink:0; }
.a2a-panel-header { color:#fff; padding:0.4rem 0.8rem; font-size:0.8rem; font-weight:600; display:flex; justify-content:space-between; align-items:center; }
.a2a-panel-btn { background:rgba(255,255,255,0.15); color:#fff; border:none; border-radius:4px; padding:2px 8px; font-size:0.65rem; cursor:pointer; }
.a2a-diagram { position:relative; height:260px; background:linear-gradient(135deg, #1e1b4b 0%, #0f172a 100%); padding:0; overflow:hidden; isolation:isolate; }
.a2a-node { display:flex; flex-direction:column; align-items:center; z-index:2; transition:filter 0.3s; gap:3px; }
.a2a-icon { width:36px; height:36px; border-radius:50%; background:rgba(49,46,129,0.8); border:2px solid #6366f1; display:flex; align-items:center; justify-content:center; font-size:1rem; flex-shrink:0; transition:box-shadow 0.3s,border-color 0.3s,transform 0.3s; backdrop-filter:blur(4px); }
.a2a-lbl { color:#c4b5fd; font-size:0.58rem; white-space:nowrap; font-weight:600; letter-spacing:0.02em; text-shadow:0 1px 3px rgba(0,0,0,0.5); text-align:center; }
.a2a-node.active .a2a-icon { border-color:#22d3ee; box-shadow:0 0 14px 5px rgba(34,211,238,0.5); transform:scale(1.12); animation:a2a-pulse 1.2s infinite; }
.a2a-node.active .a2a-lbl { color:#22d3ee; font-weight:700; }
.a2a-node.done .a2a-icon { border-color:#10b981; box-shadow:0 0 8px 2px rgba(16,185,129,0.3); }
.a2a-node.done .a2a-lbl { color:#10b981; }
@keyframes a2a-pulse { 0%,100%{box-shadow:0 0 14px 5px rgba(34,211,238,0.5);} 50%{box-shadow:0 0 22px 9px rgba(34,211,238,0.7);} }

.a2a-flow { flex:1; padding:0.5rem; overflow-y:auto; background:#0c1929; color:#e0e7ff; font-size:0.72rem; line-height:1.4; font-family:'Inter',sans-serif; min-height:120px; }
@media (max-width:1100px) { .a2a-layout{flex-direction:column;} .a2a-debug-side{width:100%;max-height:45vh;flex-shrink:0;} .a2a-chat-side{flex:1;} }
