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

:root {
    --bg:          #0c1017;
    --surface:     #161d2a;
    --card:        #1c2538;
    --accent:      #6c63ff;
    --accent-glow: rgba(108, 99, 255, 0.35);
    --user-bubble: #6c63ff;
    --bot-bubble:  #1e2a3a;
    --text:        #e4e8f0;
    --text-dim:    #8892a4;
    --border:      rgba(255,255,255,0.07);
    --radius:      16px;
    --danger:      #f87171;
    --success:     #34d399;
}

body {
    font-family: 'Inter', system-ui, sans-serif;
    background: var(--bg);
    color: var(--text);
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    background-image:
        radial-gradient(ellipse at 30% 20%, rgba(108,99,255,0.08) 0%, transparent 60%),
        radial-gradient(ellipse at 70% 80%, rgba(0,200,200,0.06) 0%, transparent 60%);
}

.hidden { display: none !important; }

/* ═══════════════════════════════
   Registration Overlay
   ═══════════════════════════════ */
#reg-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(12px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 100;
    animation: fadeSlide 0.4s ease forwards;
}

#reg-overlay.fade-out {
    animation: fadeOut 0.4s ease forwards;
}

@keyframes fadeOut {
    to { opacity: 0; transform: scale(0.97); }
}

#reg-card {
    width: 420px;
    max-width: 92vw;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 36px 32px 28px;
    box-shadow:
        0 0 80px rgba(108,99,255,0.1),
        0 24px 60px rgba(0,0,0,0.5);
}

.reg-header {
    text-align: center;
    margin-bottom: 28px;
}

.reg-icon {
    font-size: 2.4rem;
    display: block;
    margin-bottom: 10px;
}

.reg-brand {
    height: 48px;
    width: auto;
    object-fit: contain;
    margin-bottom: 12px;
}

.reg-header h2 {
    font-size: 1.3rem;
    font-weight: 700;
    letter-spacing: -0.3px;
}

.reg-header h2 span {
    color: var(--accent);
}

.reg-header p {
    color: var(--text-dim);
    font-size: 0.85rem;
    margin-top: 6px;
}

.field {
    margin-bottom: 16px;
}

.field label {
    display: block;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-dim);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.field input,
.field select {
    width: 100%;
    padding: 11px 14px;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 10px;
    color: var(--text);
    font-size: 0.9rem;
    font-family: inherit;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.field input::placeholder {
    color: var(--text-dim);
}

.field input:focus,
.field select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.field select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238892a4' stroke-width='2.5'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
    cursor: pointer;
}

.field select option {
    background: var(--card);
    color: var(--text);
}

#reg-btn {
    width: 100%;
    padding: 13px;
    margin-top: 6px;
    background: var(--accent);
    color: #fff;
    font-size: 0.95rem;
    font-weight: 600;
    font-family: inherit;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 4px 18px var(--accent-glow);
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
}

#reg-btn:hover:not(:disabled) {
    transform: translateY(-1px);
    background: #7b73ff;
}

#reg-btn:disabled {
    opacity: 0.7;
    cursor: wait;
}

.spinner {
    width: 18px;
    height: 18px;
    border: 2.5px solid rgba(255,255,255,0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.reg-error {
    text-align: center;
    color: var(--danger);
    font-size: 0.85rem;
    margin-top: 12px;
}

/* ═══════════════════════════════
   App Shell
   ═══════════════════════════════ */
#app {
    width: 520px;
    max-width: 96vw;
    height: 92vh;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow:
        0 0 80px rgba(108,99,255,0.08),
        0 20px 60px rgba(0,0,0,0.45);
}

/* ===== Header ===== */
header {
    padding: 18px 24px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: linear-gradient(180deg, rgba(108,99,255,0.06) 0%, transparent 100%);
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
}

.logo-icon {
    font-size: 1.6rem;
}

.chat-brand {
    height: 32px;
    width: auto;
    object-fit: contain;
}

.logo h1 {
    font-size: 1.15rem;
    font-weight: 700;
    letter-spacing: -0.3px;
}

.logo h1 span {
    color: var(--accent);
}

.status {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.78rem;
    color: var(--text-dim);
}

.dot {
    width: 7px;
    height: 7px;
    background: var(--success);
    border-radius: 50%;
    animation: blink 1.6s ease-in-out infinite;
}

@keyframes blink {
    0%, 100% { opacity: .4; }
    50% { opacity: 1; }
}

/* ===== Chat Area ===== */
#chat {
    flex: 1;
    overflow-y: auto;
    padding: 20px 22px;
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
}

#chat::-webkit-scrollbar { width: 5px; }
#chat::-webkit-scrollbar-thumb { background: var(--border); border-radius: 10px; }

#messages {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

/* ===== Messages ===== */
.msg {
    display: flex;
    gap: 10px;
    max-width: 85%;
}

.msg.bot { align-self: flex-start; }
.msg.user { align-self: flex-end; flex-direction: row-reverse; }

.avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--card);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.95rem;
    flex-shrink: 0;
    border: 1px solid var(--border);
}

.bubble {
    padding: 11px 16px;
    border-radius: var(--radius);
    font-size: 0.9rem;
    line-height: 1.55;
}

.bot .bubble {
    background: var(--bot-bubble);
    border-bottom-left-radius: 4px;
}

.user .bubble {
    background: var(--user-bubble);
    color: #fff;
    border-bottom-right-radius: 4px;
    box-shadow: 0 4px 18px var(--accent-glow);
}

.time {
    font-size: 0.7rem;
    color: var(--text-dim);
    margin-top: 4px;
    display: block;
}

.msg.user .time { text-align: right; }

/* ===== Typing indicator ===== */
.typing {
    display: flex;
    gap: 5px;
    padding: 12px 18px !important;
}

.typing span {
    width: 6px;
    height: 6px;
    background: var(--text-dim);
    border-radius: 50%;
    animation: bounce 1.2s infinite ease-in-out;
}

.typing span:nth-child(2) { animation-delay: .15s; }
.typing span:nth-child(3) { animation-delay: .3s; }

@keyframes bounce {
    0%, 80%, 100% { transform: scale(.7); opacity: .4; }
    40% { transform: scale(1.1); opacity: 1; }
}

/* ===== Fade-in animation ===== */
.fade-in {
    animation: fadeSlide .3s ease forwards;
    opacity: 0;
}

@keyframes fadeSlide {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ===== Shortcut chips ===== */
#shortcuts {
    padding: 8px 22px 4px;
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: center;
}

.chip {
    background: var(--card);
    border: 1px solid var(--border);
    color: var(--text-dim);
    padding: 5px 13px;
    border-radius: 20px;
    font-size: 0.8rem;
    cursor: pointer;
    transition: all .2s ease;
    font-family: inherit;
}

.chip:hover {
    border-color: var(--accent);
    color: var(--accent);
    transform: translateY(-1px);
    box-shadow: 0 2px 12px var(--accent-glow);
}

/* ===== Footer / Input ===== */
footer {
    padding: 14px 22px 18px;
}

.input-bar {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 28px;
    padding: 6px 8px 6px 18px;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: border-color .2s;
}

.input-bar:focus-within {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

#user-input {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text);
    font-size: 0.9rem;
    outline: none;
    padding: 10px 0;
    font-family: inherit;
    resize: none;
    height: auto;
    max-height: 120px;
    line-height: 1.5;
    overflow-y: auto;
}

#user-input::placeholder {
    color: var(--text-dim);
}

#send-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    background: var(--accent);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all .2s;
    box-shadow: 0 3px 12px var(--accent-glow);
}

#send-btn:hover {
    transform: scale(1.08);
    background: #7b73ff;
}

/* ===== Responsive ===== */
@media (max-width: 560px) {
    #app {
        width: 100vw;
        height: 100vh;
        border-radius: 0;
    }
    #reg-card {
        margin: 16px;
    }
}
