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

body {
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background: #031332;
    color: #e5e7eb;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    min-height: 100vh;
    padding: 16px;
    overflow-y: auto;
    position: relative;
}

/* App container */
.app-container {
    position: relative;
    z-index: 5;
    background: transparent;
    border-radius: 16px;
    width: 100%;
    max-width: 700px;
    display: flex;
    flex-direction: column;
    padding: 16px;
}

/* Desktop card styling */
@media (min-width: 769px) {
    body {
        padding-top: 24px;
        padding-bottom: 24px;
    }

    .app-container {
        background: rgba(2, 6, 23, 0.88);
        border: 1px solid rgba(255, 255, 255, 0.05);
        box-shadow: 0 20px 40px rgba(0, 0, 0, 0.45);
        backdrop-filter: blur(6px);
    }
}

/* Header */
.app-header {
    border-bottom: 1px solid #1f2937;
    margin-bottom: 12px;
    padding: 20px 20px 12px 20px;
}

.header-content {
    display: flex;
    align-items: center;
    gap: 15px;
}

.logo {
    margin-left: -10px;
    width: 70px;
    height: auto;
    object-fit: contain;
    filter: drop-shadow(0 0 4px rgba(0, 0, 0, 0.3));
}

.header-text h1 {
    font-size: 1.25rem;
    margin: 0;
}

.subtitle {
    display: block;
    font-size: 0.9rem;
    color: #ccc;
    margin-left: 10px;
    margin-top: 2px;
}

/* Chat window */
.chat-container {
    width: 100%;
    height: 55vh;
    min-height: 320px;
    max-height: 600px;
    overflow-y: auto;
}

#chat-window {
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    overflow-y: auto;
}

/* Message bubbles */
.message-row {
    display: flex;
    gap: 10px;
    margin: 8px 0;
}

.message-row.user {
    justify-content: flex-end;
}

.message-row.bot {
    justify-content: flex-start;
    align-items: flex-end;
}

.message-avatar {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    object-fit: contain;
    flex-shrink: 0;
    background: #111827;
    padding: 5px 4px 3px 4px;
    display: grid;
    place-items: center;
    box-shadow: 0 0 4px rgba(0, 0, 0, 0.3);
    transform: translate(-3px, 1px);
}

.message-bubble {
    max-width: 80%;
    padding: 10px 12px;
    border-radius: 12px;
    font-size: 0.95rem;
    line-height: 1.4;
}

.message-row.bot .message-bubble {
    background: #111827;
    border-bottom-left-radius: 4px;
}

/* Typing indicator */
.typing {
    font-style: italic;
    opacity: 0.7;
    padding: 10px 14px;
    margin: 6px 0;
    background: rgba(255, 255, 255, 0.07);
    border-radius: 12px;
    width: fit-content;
    color: #ccc;
}

.typing::after {
    content: " ...";
    animation: blink 1.2s infinite;
}

@keyframes blink {
    0% { opacity: 0.2; }
    50% { opacity: 1; }
    100% { opacity: 0.2; }
}

/* Form */
#chat-form {
    display: flex;
    gap: 8px;
    margin-top: 12px;
    border-top: 1px solid #1f2937;
    padding-top: 12px;
}

#message-input {
    flex: 1;
    padding: 12px 14px;
    font-size: 16px;
    border-radius: 999px;
    border: 1px solid #374151;
    background: #020617;
    color: #e5e7eb;
    outline: none;
}

#message-input:focus {
    border-color: #2563eb;
}

#chat-form button {
    padding: 10px 18px;
    border-radius: 999px;
    border: none;
    background: #2563eb;
    color: white;
    font-weight: 500;
    cursor: pointer;
}

#chat-form button:disabled {
    opacity: 0.6;
    cursor: default;
}

/* Advice pill */
.wellbeing-tip-pill {
    max-width: 700px;
    width: calc(100% - 24px);
    margin: 14px auto 8px auto;
    padding: 10px 18px;
    border-radius: 999px;
    background: rgba(13, 24, 46, 0.95);
    border: 1px solid rgba(255, 255, 255, 0.06);
    color: #cfd6ff;
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 10px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}

.wellbeing-tip-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #8ea2ff;
    background: rgba(142, 162, 255, 0.12);
    padding: 3px 8px;
    border-radius: 999px;
    flex-shrink: 0;
}

.wellbeing-tip-text {
    line-height: 1.4;
}

/* Safety banner */
#safety-banner {
    z-index: 5;
    position: static;
    margin: 8px auto 20px auto;
    max-width: 700px;
    width: calc(100% - 24px);
    text-align: center;
    font-size: 12px;
    line-height: 1.5;
    color: #9ca3af;
    padding: 10px 16px;
    background: rgba(0, 0, 0, 0.25);
    border-radius: 10px;
    backdrop-filter: blur(4px);
}

/* Ripple background */
.ripple-layer {
    position: fixed;
    inset: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    pointer-events: none;
    z-index: 0;
}

.ripple-circle {
    position: absolute;
    width: 32vmax;
    height: 32vmax;
    border-radius: 50%;
    border: 4px solid rgba(120, 170, 255, 0.16);
    background: transparent;
    box-shadow:
        0 0 0 14px rgba(120, 170, 255, 0.05),
        0 0 40px rgba(80, 130, 205, 0.08);
    animation: ripple 18s ease-out infinite;
    opacity: 0;
}

.circle2 { animation-delay: -6s; }
.circle3 { animation-delay: -12s; }

@keyframes ripple {
    0% {
        transform: scale(0.4);
        opacity: 0;
    }
    8% {
        opacity: 0.22;
    }
    60% {
        opacity: 0.12;
    }
    100% {
        transform: scale(6.5);
        opacity: 0;
    }
}

/* Mobile */
@media (max-width: 768px) {
    .ripple-circle {
        width: 42vmax;
        height: 42vmax;
        border-width: 3px;
    }
    body {
        padding: 10px;
    }

    .app-container {
        border-radius: 16px;
        padding: 12px;
    }

    .chat-container {
        height: 50vh;
        min-height: 260px;
        max-height: none;
    }

    .app-header {
        padding: 16px 16px 12px 16px;
    }

    .header-content {
        align-items: flex-start;
        gap: 12px;
    }

    .logo {
        width: 56px;
        margin-left: 0;
    }

    .header-text h1 {
        font-size: 1.05rem;
        line-height: 1.3;
    }

    .subtitle {
        font-size: 0.8rem;
        margin-left: 0;
    }

    #chat-window {
        padding: 10px;
    }

    .message-bubble {
        font-size: 0.9rem;
        max-width: 85%;
    }

    #chat-form {
        gap: 6px;
        padding-top: 10px;
    }

    #message-input {
        min-height: 44px;
    }

    #chat-form button {
        min-height: 44px;
        padding: 0 14px;
    }

    .wellbeing-tip-pill {
        width: 100%;
        margin: 12px 0 8px 0;
        padding: 10px 14px;
        border-radius: 16px;
        font-size: 12px;
    }

    #safety-banner {
        width: 100%;
        margin: 8px 0 12px 0;
        font-size: 10px;
        padding: 8px 12px;
    }
}