/* ===== CSS Variables ===== */
:root {
    --color-primary: #2563eb;
    --color-primary-hover: #1d4ed8;
    --color-secondary: #64748b;
    --color-bg: #f8fafc;
    --color-surface: #ffffff;
    --color-border: #e2e8f0;
    --color-text: #0f172a;
    --color-text-muted: #64748b;
    --color-error: #ef4444;
    --color-success: #22c55e;
    --color-user-msg: #2563eb;
    --color-assistant-msg: #f1f5f9;
    --radius: 8px;
    --shadow: 0 1px 3px rgba(0,0,0,.1), 0 1px 2px rgba(0,0,0,.06);
    --shadow-md: 0 4px 6px rgba(0,0,0,.07), 0 2px 4px rgba(0,0,0,.06);
}

/* ===== Reset & Base ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: system-ui, -apple-system, sans-serif; background: var(--color-bg); color: var(--color-text); line-height: 1.6; }
a { color: var(--color-primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ===== Layout ===== */
.container { max-width: 768px; margin: 0 auto; padding: 2rem 1rem; }
.container-wide { max-width: 1024px; margin: 0 auto; padding: 2rem 1rem; }

/* ===== Navbar ===== */
.navbar {
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    padding: .75rem 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow);
}
.navbar-brand a { font-weight: 700; font-size: 1.1rem; color: var(--color-text); }
.navbar-links { display: flex; align-items: center; gap: 1.25rem; }
.navbar-links a { color: var(--color-text-muted); font-size: .9rem; }
.navbar-links a:hover { color: var(--color-text); text-decoration: none; }
.btn-link { background: none; border: none; cursor: pointer; color: var(--color-text-muted); font-size: .9rem; padding: 0; }
.btn-link:hover { color: var(--color-text); }

/* ===== Footer ===== */
.footer { text-align: center; padding: 2rem; color: var(--color-text-muted); font-size: .85rem; border-top: 1px solid var(--color-border); margin-top: 4rem; }

/* ===== Buttons ===== */
.btn {
    display: inline-flex;
    align-items: center;
    gap: .5rem;
    padding: .6rem 1.25rem;
    border-radius: var(--radius);
    font-size: .9rem;
    font-weight: 500;
    cursor: pointer;
    border: none;
    transition: background .15s, transform .1s;
    text-decoration: none;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--color-primary); color: white; }
.btn-primary:hover { background: var(--color-primary-hover); text-decoration: none; color: white; }
.btn-secondary { background: var(--color-surface); color: var(--color-text); border: 1px solid var(--color-border); }
.btn-secondary:hover { background: var(--color-bg); text-decoration: none; }
.btn-google { background: var(--color-surface); color: var(--color-text); border: 1px solid var(--color-border); width: 100%; justify-content: center; font-size: 1rem; padding: .75rem; }
.btn-google:hover { background: #f8f8f8; text-decoration: none; }
.btn:disabled { opacity: .6; cursor: not-allowed; }

/* ===== Hero ===== */
.hero { text-align: center; padding: 6rem 1rem; }
.hero h1 { font-size: 3rem; font-weight: 800; margin-bottom: 1rem; }
.hero-subtitle { font-size: 1.2rem; color: var(--color-text-muted); margin-bottom: 2rem; }

/* ===== Auth ===== */
.auth-container { display: flex; justify-content: center; align-items: center; min-height: calc(100vh - 120px); padding: 2rem; }
.auth-card { background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius); padding: 2.5rem; width: 100%; max-width: 400px; box-shadow: var(--shadow-md); }
.auth-card h2 { margin-bottom: .5rem; }
.auth-subtitle { color: var(--color-text-muted); margin-bottom: 2rem; font-size: .95rem; }

/* ===== Alerts ===== */
.alert { padding: .75rem 1rem; border-radius: var(--radius); margin-bottom: 1rem; font-size: .9rem; }
.alert-error { background: #fef2f2; color: var(--color-error); border: 1px solid #fecaca; }
.alert-success { background: #f0fdf4; color: var(--color-success); border: 1px solid #bbf7d0; }

/* ===== Forms ===== */
.form-group { margin-bottom: 1.25rem; }
label { display: block; font-size: .9rem; font-weight: 500; margin-bottom: .4rem; }
input[type=text], input[type=email], textarea, select {
    width: 100%;
    padding: .6rem .75rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    font-size: .95rem;
    font-family: inherit;
    background: var(--color-surface);
    color: var(--color-text);
    transition: border-color .15s;
}
input:focus, textarea:focus { outline: none; border-color: var(--color-primary); }
.field-error { color: var(--color-error); font-size: .8rem; margin-top: .3rem; }
.field-hint { color: var(--color-text-muted); font-size: .8rem; margin-top: .3rem; }
textarea { resize: vertical; min-height: 200px; }

/* ===== Cards ===== */
.card { background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius); padding: 1.5rem; box-shadow: var(--shadow); }
.card + .card { margin-top: 1rem; }

/* ===== Chat ===== */
.chat-container { display: flex; flex-direction: column; height: calc(100vh - 200px); min-height: 400px; }
.chat-messages { flex: 1; overflow-y: auto; padding: 1rem; display: flex; flex-direction: column; gap: .75rem; }
.chat-message { max-width: 80%; padding: .75rem 1rem; border-radius: 12px; font-size: .95rem; line-height: 1.5; }
.chat-message.user { align-self: flex-end; background: var(--color-user-msg); color: white; border-bottom-right-radius: 4px; }
.chat-message.assistant { align-self: flex-start; background: var(--color-assistant-msg); color: var(--color-text); border-bottom-left-radius: 4px; }
.chat-input-area { display: flex; gap: .5rem; padding: 1rem; border-top: 1px solid var(--color-border); background: var(--color-surface); }
.chat-input { flex: 1; resize: none; min-height: 44px; max-height: 120px; padding: .6rem .75rem; }
.chat-send-btn { align-self: flex-end; }
.chat-suggestions { display: flex; flex-wrap: wrap; gap: .5rem; padding: .75rem 1rem; }
.suggestion-chip { padding: .4rem .9rem; background: var(--color-bg); border: 1px solid var(--color-border); border-radius: 20px; font-size: .85rem; cursor: pointer; transition: background .15s; }
.suggestion-chip:hover { background: var(--color-primary); color: white; border-color: var(--color-primary); }

/* Typing indicator */
.typing-indicator { display: flex; gap: 4px; align-items: center; padding: .75rem 1rem; }
.typing-indicator span { width: 8px; height: 8px; border-radius: 50%; background: var(--color-text-muted); animation: bounce 1.4s infinite; }
.typing-indicator span:nth-child(2) { animation-delay: .2s; }
.typing-indicator span:nth-child(3) { animation-delay: .4s; }
@keyframes bounce { 0%, 80%, 100% { transform: translateY(0); } 40% { transform: translateY(-6px); } }

/* ===== OCEAN Progress Bars ===== */
.ocean-trait { margin-bottom: 1rem; }
.ocean-trait-label { display: flex; justify-content: space-between; font-size: .9rem; margin-bottom: .3rem; }
.ocean-bar-track { height: 10px; background: var(--color-border); border-radius: 5px; overflow: hidden; }
.ocean-bar-fill { height: 100%; background: var(--color-primary); border-radius: 5px; transition: width .6s ease; }

/* ===== Progress Wizard ===== */
.wizard-progress { background: var(--color-border); height: 6px; border-radius: 3px; margin-bottom: 2rem; }
.wizard-progress-fill { height: 100%; background: var(--color-primary); border-radius: 3px; transition: width .3s ease; }

/* ===== Avatar ===== */
.avatar { width: 48px; height: 48px; border-radius: 50%; background: var(--color-primary); color: white; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 1.1rem; flex-shrink: 0; }
.avatar-lg { width: 80px; height: 80px; font-size: 1.8rem; }

/* ===== Badge ===== */
.badge { display: inline-block; padding: .2rem .6rem; border-radius: 20px; font-size: .75rem; font-weight: 600; }
.badge-primary { background: #dbeafe; color: #1d4ed8; }
.badge-secondary { background: #f1f5f9; color: var(--color-secondary); }

/* ===== Responsive ===== */
@media (max-width: 640px) {
    .hero h1 { font-size: 2rem; }
    .navbar { padding: .75rem 1rem; }
    .chat-message { max-width: 95%; }
}

/* ===== Section Divider (Setup page) ===== */
.form-section-divider {
    border: none;
    border-top: 1px solid var(--color-border);
    margin: 2rem 0 1.75rem;
}

/* ===== Session list ===== */
.session-list { display: flex; flex-direction: column; gap: 1rem; }
.session-card { padding: 1rem 1.25rem; display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.session-info { display: flex; align-items: center; gap: .75rem; flex: 1; }
.session-meta { font-size: .85rem; color: var(--color-text-muted); display: flex; gap: 1rem; }

/* ===== Status badges ===== */
.badge-lobby  { background: #fef9c3; border-color: #fde047; color: #854d0e; }
.badge-active { background: #dcfce7; border-color: #86efac; color: #166534; }
.badge-finished { background: #f1f5f9; border-color: #cbd5e1; color: #475569; }

/* ===== Tab buttons ===== */
.tab-btn { flex:1; padding:.6rem 1rem; border:none; background:none; cursor:pointer; font-size:.9rem; color:var(--color-text-muted); border-bottom:2px solid transparent; transition:color .15s, border-color .15s; }
.tab-btn:hover { color:var(--color-text); }
.tab-active { color:var(--color-primary); border-bottom-color:var(--color-primary); font-weight:600; }

/* ===== Chat messages ===== */
.msg-wrapper { display: flex; flex-direction: column; }
.msg-own { align-items: flex-end; }
.msg-bubble { max-width: 75%; padding: .5rem .875rem; border-radius: var(--radius); line-height: 1.4; }
.msg-player-team { background: var(--color-assistant-msg); }
.msg-own .msg-player-team { background: var(--color-primary); color: #fff; }
.msg-own .msg-player-agent { background: #7c3aed; color: #fff; }
.msg-player-agent { background: #ede9fe; }
.msg-agent { background: #f0fdf4; border: 1px solid #bbf7d0; max-width: 90%; }
.msg-header { display: flex; align-items: center; gap: .5rem; margin-bottom: .2rem; }
.msg-name { font-size: .78rem; font-weight: 600; color: var(--color-text-muted); }
.msg-own .msg-name { color: rgba(255,255,255,.75); }
.msg-tag { font-size: .7rem; background: rgba(124,58,237,.15); color: #7c3aed; padding: .1rem .35rem; border-radius: 9999px; }
.msg-own .msg-tag { background: rgba(255,255,255,.2); color: rgba(255,255,255,.9); }
.msg-agent .msg-name { color: #166534; }
.msg-content { font-size: .9rem; word-break: break-word; white-space: pre-wrap; }
.msg-system { text-align: center; font-size: .8rem; color: var(--color-text-muted); font-style: italic; padding: .25rem 0; }

/* ===== Info marker (clue extracted from [INFO: ...] in agent response) ===== */
.info-marker { font-weight: 700; color: #fbbf24; background: rgba(251,191,36,0.12); padding: .1em .4em; border-radius: 4px; }

/* ===== Agent think details ===== */
.think-details { font-size: .78rem; color: var(--color-text-muted); margin-bottom: .25rem; max-width: 90%; }
.think-details summary { cursor: pointer; list-style: none; display: inline-flex; align-items: center; gap: .35rem; padding: .2rem .5rem; border-radius: 20px; background: #f0fdf4; border: 1px solid #bbf7d0; color: #166534; user-select: none; }
.think-details summary::-webkit-details-marker { display: none; }
.think-details[open] summary { border-radius: var(--radius) var(--radius) 0 0; }
.think-content { background: #f0fdf4; border: 1px solid #bbf7d0; border-top: none; border-radius: 0 var(--radius) var(--radius) var(--radius); padding: .5rem .75rem; white-space: pre-wrap; line-height: 1.5; color: #166534; }
