/*
 * Identity CoAnalyst (ICA) Chat Assistant — Styles
 * Self-contained dark navy / teal theme matching the ICA brand.
 * Author: William Leonard, CTI Global
 */

/* Brand palette (from the ICA design system) */
:root {
    --navy-deepest: #070e1a;
    --navy-deep:    #0a1628;
    --navy-mid:     #0f1f38;
    --navy-card:    #111f36;
    --navy-border:  #1e3050;
    --teal:         #00c6a7;
    --teal-bright:  #00ddb8;
    --amber:        #f5a623;
    --text-heading: #f0f4f8;
    --text-body:    #c2cede;
    --text-muted:   #8a9bb5;
    --danger:       #ff4d6a;

    --font-display: 'DM Serif Display', Georgia, serif;
    --font-body:    'Outfit', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-mono:    'JetBrains Mono', 'SF Mono', Menlo, monospace;
}

@import url('https://fonts.googleapis.com/css2?family=DM+Serif+Display&family=Outfit:wght@300;400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap');

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    height: 100%;
}

body {
    background: var(--navy-deepest);
    color: var(--text-body);
    font-family: var(--font-body);
    font-size: 16px;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

/* ── Layout shell: header / scrolling conversation / fixed composer ── */
.chat-shell {
    display: flex;
    flex-direction: column;
    height: 100dvh;
    max-width: 820px;
    margin: 0 auto;
    background: var(--navy-deep);
    border-left: 1px solid var(--navy-border);
    border-right: 1px solid var(--navy-border);
}

/* ── Header ── */
.chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--navy-border);
    background: var(--navy-deepest);
    flex-shrink: 0;
}
.chat-brand img {
    height: 28px;
    display: block;
}
.chat-header-right {
    display: flex;
    align-items: center;
    gap: 1rem;
}
.chat-reset {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    background: var(--navy-card);
    border: 1px solid var(--navy-border);
    color: var(--text-muted);
    font-family: var(--font-body);
    font-size: .8rem;
    padding: .4rem .75rem;
    border-radius: 8px;
    cursor: pointer;
    transition: border-color .2s, color .2s;
}
.chat-reset:hover {
    border-color: var(--teal);
    color: var(--text-heading);
}
.chat-reset svg { display: block; }
.chat-header-meta {
    display: flex;
    align-items: center;
    gap: .5rem;
    font-family: var(--font-mono);
    font-size: .72rem;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--text-muted);
}
.chat-status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--teal);
    box-shadow: 0 0 0 0 rgba(0, 198, 167, .5);
    animation: pulse 2.4s infinite;
}
@keyframes pulse {
    0%   { box-shadow: 0 0 0 0 rgba(0, 198, 167, .5); }
    70%  { box-shadow: 0 0 0 7px rgba(0, 198, 167, 0); }
    100% { box-shadow: 0 0 0 0 rgba(0, 198, 167, 0); }
}

/* ── Conversation area ── */
.chat-main {
    flex: 1;
    overflow-y: auto;
    padding: 2rem 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    scroll-behavior: smooth;
}

/* Welcome / empty state */
.chat-welcome {
    margin: auto 0;
    text-align: center;
    padding: 1rem 0;
}
.chat-welcome h1 {
    font-family: var(--font-display);
    font-size: clamp(1.8rem, 4vw, 2.4rem);
    color: var(--text-heading);
    line-height: 1.15;
    margin-bottom: 1rem;
}
.chat-welcome p {
    color: var(--text-muted);
    max-width: 520px;
    margin: 0 auto 2rem;
    font-size: 1rem;
}
.chat-suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: .65rem;
    justify-content: center;
    max-width: 640px;
    margin: 0 auto;
}
.suggestion {
    background: var(--navy-card);
    border: 1px solid var(--navy-border);
    color: var(--text-heading);
    padding: .6rem 1rem;
    border-radius: 999px;
    font-family: var(--font-body);
    font-size: .85rem;
    font-weight: 500;
    cursor: pointer;
    transition: border-color .2s, color .2s, background .2s, transform .15s;
}
.suggestion:hover {
    border-color: var(--teal);
    color: var(--teal);
    background: rgba(0, 198, 167, .06);
    transform: translateY(-2px);
}

/* ── Message bubbles ── */
.msg {
    display: flex;
    gap: .85rem;
    max-width: 100%;
    animation: rise .25s ease;
}
@keyframes rise {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
}
.msg-avatar {
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-mono);
    font-size: .7rem;
    font-weight: 500;
    letter-spacing: .03em;
}
.msg-user .msg-avatar {
    background: var(--navy-mid);
    color: var(--text-muted);
    border: 1px solid var(--navy-border);
}
.msg-assistant .msg-avatar {
    background: rgba(0, 198, 167, .12);
    color: var(--teal);
    border: 1px solid rgba(0, 198, 167, .3);
}
.msg-body {
    flex: 1;
    min-width: 0;
    padding-top: .25rem;
}
.msg-role {
    font-family: var(--font-mono);
    font-size: .65rem;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: .35rem;
}
.msg-content {
    color: var(--text-body);
    overflow-wrap: break-word;
}
.msg-user .msg-content {
    color: var(--text-heading);
}
.msg-content p { margin-bottom: .75rem; }
.msg-content p:last-child { margin-bottom: 0; }
.msg-content ul {
    margin: .25rem 0 .85rem 1.1rem;
    display: flex;
    flex-direction: column;
    gap: .3rem;
}
.msg-content li { padding-left: .15rem; }
.msg-content strong { color: var(--text-heading); font-weight: 600; }
.msg-content a {
    color: var(--teal);
    text-decoration: none;
    border-bottom: 1px solid rgba(0, 198, 167, .3);
}
.msg-content a:hover { border-color: var(--teal); }

/* Typing indicator */
.typing {
    display: inline-flex;
    gap: 4px;
    align-items: center;
    padding: .35rem 0;
}
.typing span {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--text-muted);
    animation: blink 1.4s infinite both;
}
.typing span:nth-child(2) { animation-delay: .2s; }
.typing span:nth-child(3) { animation-delay: .4s; }
@keyframes blink {
    0%, 80%, 100% { opacity: .25; }
    40%           { opacity: 1; }
}

/* Error bubble */
.msg-error .msg-content {
    color: var(--danger);
    font-size: .92rem;
}

/* ── Composer ── */
.chat-composer {
    flex-shrink: 0;
    padding: 1rem 1.5rem 1.25rem;
    border-top: 1px solid var(--navy-border);
    background: var(--navy-deepest);
}
.chat-form {
    display: flex;
    align-items: flex-end;
    gap: .75rem;
    background: var(--navy-card);
    border: 1px solid var(--navy-border);
    border-radius: 14px;
    padding: .5rem .5rem .5rem 1rem;
    transition: border-color .2s;
}
.chat-form:focus-within {
    border-color: var(--teal);
}
.chat-input {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    resize: none;
    color: var(--text-heading);
    font-family: var(--font-body);
    font-size: 1rem;
    line-height: 1.5;
    max-height: 160px;
    padding: .4rem 0;
}
.chat-input::placeholder { color: var(--text-muted); }
.chat-send {
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 10px;
    background: var(--teal);
    color: var(--navy-deepest);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background .2s, opacity .2s;
}
.chat-send:hover { background: var(--teal-bright); }
.chat-send:disabled {
    opacity: .4;
    cursor: not-allowed;
}
.chat-disclaimer {
    margin-top: .75rem;
    text-align: center;
    font-size: .72rem;
    color: var(--text-muted);
    line-height: 1.5;
}
.chat-disclaimer a {
    color: var(--text-muted);
    text-decoration: underline;
}
.chat-disclaimer a:hover { color: var(--teal); }

/* ── Mobile ── */
@media (max-width: 600px) {
    .chat-main { padding: 1.5rem 1rem; }
    .chat-composer { padding: .75rem 1rem 1rem; }
    .chat-header { padding: .85rem 1rem; }
    .chat-reset span { display: none; }   /* icon-only "New chat" on small screens */
    .chat-reset { padding: .4rem .5rem; }
}
