/* ── Reset & Base ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: #f5f7fa;
    color: #1a1a2e;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ── Header ── */
header {
    background: linear-gradient(135deg, #1a73e8, #0d47a1);
    color: #fff;
    text-align: center;
    padding: 2rem 1rem;
}
header h1 { font-size: 1.8rem; margin-bottom: 0.3rem; }
header p { opacity: 0.85; font-size: 0.95rem; }

/* ── Main ── */
main {
    flex: 1;
    max-width: 800px;
    margin: 0 auto;
    padding: 2rem 1rem;
}

.features {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.feature {
    background: #fff;
    border-radius: 12px;
    padding: 1.2rem;
    box-shadow: 0 1px 4px rgba(0,0,0,0.08);
}
.feature h3 { font-size: 1rem; margin-bottom: 0.3rem; }
.feature p { font-size: 0.85rem; color: #666; }

.cta {
    text-align: center;
    color: #666;
    font-size: 0.95rem;
}

/* ── Footer ── */
footer {
    text-align: center;
    padding: 1rem;
    font-size: 0.8rem;
    color: #999;
}

/* ── Chat Widget ── */
#chat-widget {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 9999;
}

#chat-fab {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: #1a73e8;
    color: #fff;
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(26, 115, 232, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s, box-shadow 0.2s;
}
#chat-fab:hover { transform: scale(1.08); box-shadow: 0 6px 18px rgba(26, 115, 232, 0.5); }

#chat-panel {
    position: absolute;
    bottom: 70px;
    right: 0;
    width: 380px;
    max-width: calc(100vw - 40px);
    height: 520px;
    max-height: calc(100vh - 100px);
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.18);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

#chat-panel.hidden { display: none; }

/* ── Chat Header ── */
.chat-header {
    background: #1a73e8;
    color: #fff;
    padding: 0.8rem 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 600;
}
#chat-close {
    background: none;
    border: none;
    color: #fff;
    font-size: 1.5rem;
    cursor: pointer;
    line-height: 1;
    padding: 0 4px;
}

/* ── Audience Selector ── */
.chat-audience {
    padding: 0.5rem 1rem;
    background: #f0f4f8;
    border-bottom: 1px solid #e0e0e0;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
}
.chat-audience label { color: #666; white-space: nowrap; }
.chat-audience select {
    flex: 1;
    padding: 0.3rem;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 0.85rem;
    background: #fff;
}

/* ── Messages ── */
#chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
}

.msg {
    max-width: 85%;
    padding: 0.7rem 1rem;
    border-radius: 12px;
    font-size: 0.9rem;
    line-height: 1.5;
    word-wrap: break-word;
}
.msg.user {
    align-self: flex-end;
    background: #1a73e8;
    color: #fff;
    border-bottom-right-radius: 4px;
}
.msg.bot {
    align-self: flex-start;
    background: #f0f4f8;
    color: #1a1a2e;
    border-bottom-left-radius: 4px;
}
.msg.bot .sources {
    margin-top: 0.5rem;
    font-size: 0.8rem;
    color: #666;
    border-top: 1px solid #e0e0e0;
    padding-top: 0.4rem;
}
.msg.bot .disclaimer {
    margin-top: 0.4rem;
    font-size: 0.8rem;
    color: #b71c1c;
    font-style: italic;
}
.msg.typing {
    align-self: flex-start;
    background: #f0f4f8;
    color: #999;
    font-style: italic;
}

/* ── Input ── */
.chat-input {
    display: flex;
    padding: 0.7rem;
    border-top: 1px solid #e0e0e0;
    gap: 0.5rem;
}
#chat-input {
    flex: 1;
    padding: 0.6rem 0.8rem;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 0.9rem;
    outline: none;
}
#chat-input:focus { border-color: #1a73e8; }
#chat-send {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    background: #1a73e8;
    color: #fff;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}
#chat-send:hover { background: #1557b0; }
#chat-send:disabled { background: #ccc; cursor: not-allowed; }

/* ── Mobile ── */
@media (max-width: 480px) {
    #chat-panel {
        width: calc(100vw - 20px);
        height: calc(100vh - 80px);
        bottom: 60px;
        right: 10px;
        border-radius: 12px;
    }
}
