/* Orchestration Lab — Styles
   Extends the A2A demo design language with a 6-tab strip. */

/* ---- Reset ---- */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

:root {
    --primary: #6366f1;
    --primary-hover: #4f46e5;
    --cyan: #22d3ee;
    --green: #10b981;
    --purple: #7c3aed;
    --dark-bg: #0f172a;
    --panel-bg: #1e1b4b;
    --surface: #ffffff;
    --surface-hover: #f1f5f9;
    --border: #e2e8f0;
    --text: #1e293b;
    --text-muted: #94a3b8;
    --error: #ef4444;
    --warning: #f59e0b;
    --radius: 8px;
    --radius-lg: 12px;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
    background: var(--dark-bg);
    color: var(--text);
    line-height: 1.6;
    height: 100vh;
    overflow: hidden;
}

/* ---- Layout ---- */
.lab-layout { display: flex; height: 100vh; width: 100%; overflow: hidden; }
.lab-chat-side { flex: 1; display: flex; flex-direction: column; overflow: hidden; min-width: 0; background: var(--surface); }
.lab-debug-side {
    width: 400px; flex-shrink: 0; display: flex; flex-direction: column;
    padding: 0.5rem; gap: 0.4rem; background: var(--dark-bg);
    border-left: 2px solid #1e293b; overflow-y: auto;
}

/* ---- Tab Strip ---- */
.lab-tabs {
    display: flex; gap: 0; border-bottom: 2px solid var(--border);
    background: linear-gradient(135deg, #312e81 0%, #1e1b4b 100%);
    padding: 0 0.5rem; flex-shrink: 0; overflow-x: auto;
}
.lab-tab {
    display: flex; align-items: center; gap: 0.4rem;
    padding: 0.6rem 0.9rem; cursor: pointer;
    color: #a5b4fc; font-size: 0.75rem; font-weight: 500;
    border-bottom: 3px solid transparent;
    transition: all 0.2s ease; white-space: nowrap;
    background: none; border-top: none; border-left: none; border-right: none;
}
.lab-tab:hover { color: #e0e7ff; background: rgba(255,255,255,0.05); }
.lab-tab.active {
    color: #fff; border-bottom-color: var(--cyan);
    background: rgba(34,211,238,0.1); font-weight: 600;
}
.lab-tab-icon { font-size: 1rem; }

/* ---- Header ---- */
.lab-header {
    background: var(--surface); border-bottom: 1px solid var(--border);
    padding: 0.6rem 1.5rem; display: flex; justify-content: space-between; align-items: center;
    flex-shrink: 0;
}
.lab-header h1 { font-size: 1.1rem; font-weight: 600; color: var(--text); }
.lab-header-actions { display: flex; align-items: center; gap: 0.75rem; }
.lab-status { display: flex; align-items: center; gap: 0.4rem; font-size: 0.8rem; color: var(--text-muted); }
.lab-status-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--green); }
.lab-new-btn {
    display: flex; align-items: center; gap: 0.4rem;
    padding: 0.4rem 0.8rem; background: var(--primary); color: white;
    border: none; border-radius: var(--radius); font-size: 0.8rem;
    font-weight: 500; cursor: pointer; transition: background 0.2s;
}
.lab-new-btn:hover { background: var(--primary-hover); }

/* ---- Chat area ---- */
.lab-chat-body { flex: 1; overflow-y: auto; padding: 1rem 1.5rem; display: flex; flex-direction: column; }

/* Welcome */
.lab-welcome { max-width: 560px; margin: 1.5rem auto; text-align: center; }
.lab-welcome h2 { font-size: 1.4rem; font-weight: 600; margin-bottom: 0.4rem; }
.lab-welcome p { font-size: 0.9rem; color: var(--text-muted); margin-bottom: 1rem; }
.lab-chips { display: flex; flex-wrap: wrap; gap: 0.5rem; justify-content: center; }
.lab-chip {
    background: var(--surface-hover); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 0.5rem 0.8rem; font-size: 0.8rem;
    color: var(--text-muted); cursor: pointer; transition: all 0.2s; text-align: left;
    max-width: 300px;
}
.lab-chip:hover { background: var(--primary); color: white; border-color: var(--primary); }

/* Messages */
.lab-messages { flex: 1; display: flex; flex-direction: column; gap: 0.75rem; padding-bottom: 0.5rem; }
.lab-msg { display: flex; gap: 0.6rem; max-width: 85%; animation: labSlideIn 0.3s ease; }
.lab-msg.user { margin-left: auto; flex-direction: row-reverse; }
@keyframes labSlideIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
.lab-msg-avatar {
    width: 28px; height: 28px; border-radius: 50%; display: flex;
    align-items: center; justify-content: center; font-size: 0.75rem; flex-shrink: 0;
}
.lab-msg.user .lab-msg-avatar { background: var(--primary); color: white; }
.lab-msg.assistant .lab-msg-avatar { background: var(--surface-hover); color: var(--text-muted); }
.lab-msg-content {
    background: var(--surface-hover); padding: 0.6rem 0.8rem;
    border-radius: var(--radius-lg); font-size: 0.85rem; line-height: 1.5;
}
.lab-msg.user .lab-msg-content { background: var(--primary); color: white; border-bottom-right-radius: 4px; }
.lab-msg.assistant .lab-msg-content { border-bottom-left-radius: 4px; }
.lab-msg-agent { font-size: 0.65rem; font-weight: 600; color: var(--purple); margin-bottom: 2px; }
.lab-msg-time { font-size: 0.65rem; color: var(--text-muted); margin-top: 2px; }

/* Formatted message text */
.lab-msg-text p { margin: 0 0 0.5rem 0; }
.lab-msg-text p:last-child { margin-bottom: 0; }
.lab-msg-text strong { font-weight: 700; color: var(--text); }
.lab-msg-text em { font-style: italic; }
.lab-msg-text code {
    background: rgba(99,102,241,0.1); color: var(--primary);
    padding: 1px 4px; border-radius: 3px; font-size: 0.8em; font-family: monospace;
}
.lab-msg-text ul, .lab-msg-text ol {
    margin: 0.3rem 0 0.5rem 1.2rem; padding: 0;
}
.lab-msg-text li { margin-bottom: 0.2rem; }
.lab-product-id {
    display: inline-block; background: rgba(124,58,237,0.12); color: var(--purple);
    padding: 0 4px; border-radius: 3px; font-family: monospace;
    font-size: 0.78em; font-weight: 600;
}
.lab-price {
    font-weight: 700; color: var(--green);
}
.lab-msg.user .lab-msg-text .lab-product-id { background: rgba(255,255,255,0.2); color: white; }
.lab-msg.user .lab-msg-text .lab-price { color: #bbf7d0; }

/* Typing */
.lab-typing { display: none; gap: 0.6rem; max-width: 85%; }
.lab-typing.show { display: flex; }
.lab-typing-dots { display: flex; gap: 4px; padding: 0.6rem 0.8rem; background: var(--surface-hover); border-radius: var(--radius-lg); }
.lab-typing-dots span { width: 5px; height: 5px; background: var(--text-muted); border-radius: 50%; animation: labTyping 1.4s infinite; }
.lab-typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.lab-typing-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes labTyping { 0%,60%,100% { transform: translateY(0); opacity: 0.4; } 30% { transform: translateY(-8px); opacity: 1; } }

/* Input */
.lab-input-area { background: var(--surface); border-top: 1px solid var(--border); padding: 0.6rem 1.5rem; flex-shrink: 0; }
.lab-input-wrap {
    display: flex; gap: 0.5rem; align-items: end; padding: 0.5rem;
    background: var(--surface-hover); border: 1px solid var(--border);
    border-radius: var(--radius-lg); transition: border-color 0.2s;
}
.lab-input-wrap:focus-within { border-color: var(--primary); }
.lab-input {
    flex: 1; border: none; background: transparent; font-size: 0.9rem;
    color: var(--text); resize: none; outline: none; font-family: inherit;
    line-height: 1.5; min-height: 22px; max-height: 100px;
}
.lab-input::placeholder { color: var(--text-muted); }
.lab-send-btn {
    background: var(--primary); color: white; border: none;
    border-radius: var(--radius); width: 36px; height: 36px;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer; transition: background 0.2s; flex-shrink: 0;
}
.lab-send-btn:hover:not(:disabled) { background: var(--primary-hover); }
.lab-send-btn:disabled { background: var(--text-muted); cursor: not-allowed; }
.lab-input-footer { display: flex; justify-content: space-between; margin-top: 0.3rem; font-size: 0.7rem; color: var(--text-muted); }

/* ---- Right pane: panels ---- */
.lab-panel { background: var(--panel-bg); border-radius: 10px; overflow: hidden; display: flex; flex-direction: column; flex-shrink: 0; }
.lab-panel-header {
    color: #fff; padding: 0.4rem 0.8rem; font-size: 0.78rem; font-weight: 600;
    display: flex; justify-content: space-between; align-items: center;
}
.lab-panel-btn {
    background: rgba(255,255,255,0.15); color: #fff; border: none;
    border-radius: 4px; padding: 2px 8px; font-size: 0.62rem; cursor: pointer;
}

/* Diagram */
.lab-diagram {
    position: relative; height: 280px;
    background: linear-gradient(135deg, #1e1b4b 0%, #0f172a 100%);
    padding: 0; overflow: hidden; isolation: isolate;
}
.lab-node {
    display: flex; flex-direction: column; align-items: center; gap: 3px;
    z-index: 2; transition: filter 0.3s; position: absolute;
}
.lab-node-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);
}
.lab-node-lbl {
    color: #c4b5fd; font-size: 0.56rem; white-space: nowrap;
    font-weight: 600; letter-spacing: 0.02em;
    text-shadow: 0 1px 3px rgba(0,0,0,0.5); text-align: center;
}
/* Data source nodes — rectangular, orange border */
.lab-datasource .lab-node-icon {
    border-radius: 6px; border-color: #f59e0b;
    background: rgba(120,53,15,0.4); width: 34px; height: 34px; font-size: 0.9rem;
}
.lab-datasource .lab-node-lbl { color: #fbbf24; font-size: 0.52rem; }
.lab-datasource.active .lab-node-icon {
    border-color: #f59e0b; box-shadow: 0 0 14px 5px rgba(245,158,11,0.5);
    transform: scale(1.12); animation: labPulseDS 1.2s infinite;
}
.lab-datasource.active .lab-node-lbl { color: #fbbf24; font-weight: 700; }
.lab-datasource.done .lab-node-icon { border-color: #10b981; box-shadow: 0 0 8px 2px rgba(16,185,129,0.3); }
.lab-datasource.done .lab-node-lbl { color: #10b981; }
@keyframes labPulseDS { 0%,100% { box-shadow: 0 0 14px 5px rgba(245,158,11,0.5); } 50% { box-shadow: 0 0 22px 9px rgba(245,158,11,0.7); } }
.lab-node.active .lab-node-icon {
    border-color: var(--cyan); box-shadow: 0 0 14px 5px rgba(34,211,238,0.5);
    transform: scale(1.12); animation: labPulse 1.2s infinite;
}
.lab-node.active .lab-node-lbl { color: var(--cyan); font-weight: 700; }
.lab-node.done .lab-node-icon { border-color: var(--green); box-shadow: 0 0 8px 2px rgba(16,185,129,0.3); }
.lab-node.done .lab-node-lbl { color: var(--green); }
@keyframes labPulse { 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); } }

/* Flow log */
.lab-flow {
    flex: 1; padding: 0.5rem; overflow-y: auto;
    background: #0c1929; color: #e0e7ff; font-size: 0.7rem;
    line-height: 1.4; font-family: 'Inter', sans-serif; min-height: 120px;
}

/* ---- Responsive ---- */
@media (max-width: 1100px) {
    .lab-layout { flex-direction: column; }
    .lab-debug-side { width: 100%; max-height: 40vh; flex-shrink: 0; }
}
@media (max-width: 768px) {
    .lab-tabs { padding: 0; }
    .lab-tab { padding: 0.5rem 0.6rem; font-size: 0.68rem; }
}

/* ---- Sources ---- */
.lab-sources {
    animation: labSlideIn 0.3s ease; margin-top: 0.5rem;
    max-width: 90%; padding: 0;
}
.lab-sources-header {
    display: flex; align-items: center; gap: 0.4rem;
    font-size: 0.72rem; font-weight: 600; color: var(--purple);
    margin-bottom: 0.4rem; padding-left: 0.2rem;
}
.lab-sources-header i { font-size: 0.7rem; }
.lab-sources-grid {
    display: flex; flex-wrap: wrap; gap: 0.4rem;
}
.lab-source-card {
    background: var(--surface-hover); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 0.4rem 0.6rem;
    font-size: 0.72rem; line-height: 1.4; min-width: 140px; max-width: 200px;
    transition: border-color 0.2s;
}
.lab-source-card:hover { border-color: var(--purple); }
.lab-source-id {
    font-family: monospace; font-size: 0.62rem; color: var(--text-muted);
    margin-bottom: 1px;
}
.lab-source-name { font-weight: 600; color: var(--text); }
.lab-source-type { font-size: 0.65rem; color: var(--text-muted); }
.lab-source-price { font-weight: 600; color: var(--green); font-size: 0.72rem; }
.lab-source-origin {
    font-size: 0.58rem; color: var(--purple); margin-top: 2px;
    display: flex; align-items: center; gap: 0.2rem;
}
