/* Gift Genie – Bot / Chat: vult scherm, mobiel + desktop */

:root {
    --bg: #f0ebf5;
    --bg-chat: #e8e4ef;
    --bg-card: #ffffff;
    --text: #1a1a24;
    --text-muted: #5c5c6d;
    --primary: #5E35B1;
    --primary-light: #7C4DFF;
    --primary-pale: #ede7f6;
    --accent: #b388ff;
    --border: #e0d8e8;
    --radius: 16px;
    --radius-bubble: 18px;
    --genie-bubble: #ffffff;
    --user-bubble: #7C4DFF;
    --user-text: #ffffff;
    --shadow-bubble: 0 1px 3px rgba(94, 53, 177, 0.1);
    --shadow-input: 0 -2px 20px rgba(94, 53, 177, 0.1);
    --safe-top: env(safe-area-inset-top, 0);
    --safe-bottom: env(safe-area-inset-bottom, 0);
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    height: 100%;
    -webkit-text-size-adjust: 100%;
}

body {
    margin: 0;
    height: 100%;
    min-height: 100vh;
    min-height: 100dvh;
    font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 16px;
    line-height: 1.5;
    color: var(--text);
    background: var(--bg);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Header – volle breedte, vaste hoogte */
.header {
    flex-shrink: 0;
    z-index: 20;
    width: 100%;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
    color: white;
    padding: 12px 20px;
    padding-top: calc(12px + var(--safe-top));
    padding-bottom: 14px;
    box-shadow: 0 2px 16px rgba(94, 53, 177, 0.35);
}

.header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    max-width: 720px;
    margin: 0 auto;
}

.logo {
    display: flex;
    align-items: center;
    text-decoration: none;
    flex-shrink: 0;
    -webkit-tap-highlight-color: transparent;
}

.logo-img {
    height: 44px;
    width: 44px;
    object-fit: cover;
    border-radius: 50%;
    border: 2px solid rgba(255,255,255,0.4);
}

.header .title {
    font-weight: 600;
    font-size: 1.1rem;
    letter-spacing: 0.02em;
}

/* Chat – neemt alle resterende ruimte */
.chat-container {
    flex: 1 1 0;
    min-height: 0;
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: 720px;
    margin: 0 auto;
    background: var(--bg-chat);
}

.messages {
    flex: 1 1 auto;
    min-height: 120px;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    padding: 20px 16px 16px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* Bubbels */
.msg {
    display: flex;
    align-items: flex-end;
    max-width: 88%;
}

.msg.genie {
    align-self: flex-start;
}

.msg.user {
    align-self: flex-end;
}

.msg-bubble {
    padding: 14px 18px;
    border-radius: var(--radius-bubble);
    line-height: 1.55;
    word-wrap: break-word;
    box-shadow: var(--shadow-bubble);
}

.msg.genie .msg-bubble {
    background: var(--genie-bubble);
    color: var(--text);
    border-bottom-left-radius: 6px;
}

.msg.user .msg-bubble {
    background: var(--user-bubble);
    color: var(--user-text);
    border-bottom-right-radius: 6px;
}

.msg-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    flex-shrink: 0;
    margin-right: 10px;
    object-fit: cover;
}

.msg.user .msg-avatar {
    order: 2;
    margin-right: 0;
    margin-left: 10px;
}

.msg.genie .msg-avatar {
    background: rgba(255,255,255,0.95);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
}

.msg-text {
    margin: 0;
    white-space: pre-wrap;
}

.msg.genie .msg-text strong {
    color: var(--primary);
}

/* Invoer – vast onderaan */
.input-row {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    padding-bottom: calc(16px + var(--safe-bottom));
    background: var(--bg-card);
    box-shadow: var(--shadow-input);
    border-top: 1px solid var(--border);
}

.input-field {
    flex: 1;
    min-width: 0;
    min-height: 48px;
    padding: 14px 18px;
    font-family: inherit;
    font-size: 1rem;
    border: 2px solid var(--border);
    border-radius: 24px;
    background: var(--bg);
    color: var(--text);
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
    -webkit-appearance: none;
    appearance: none;
}

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

.input-field:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(94, 53, 177, 0.15);
}

.btn-send {
    flex-shrink: 0;
    min-width: 56px;
    min-height: 48px;
    padding: 0 20px;
    font-family: inherit;
    font-size: 0.95rem;
    font-weight: 600;
    color: white;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
    border: none;
    border-radius: 24px;
    cursor: pointer;
    transition: transform 0.15s, box-shadow 0.2s;
    -webkit-tap-highlight-color: transparent;
    box-shadow: 0 2px 10px rgba(94, 53, 177, 0.4);
}

.btn-send:hover {
    transform: scale(1.02);
    box-shadow: 0 4px 14px rgba(94, 53, 177, 0.45);
}

.btn-send:active {
    transform: scale(0.98);
}

.btn-send:disabled {
    opacity: 0.8;
    cursor: not-allowed;
    transform: none;
}

/* Desktop: pagina vult met achtergrond, chat in het midden */
@media (min-width: 768px) {
    body {
        background: linear-gradient(180deg, var(--primary-pale) 0%, var(--bg) 20%, var(--bg) 100%);
    }

    .chat-container {
        box-shadow: 0 0 0 1px var(--border), 0 8px 32px rgba(94, 53, 177, 0.12);
        border-radius: 16px 16px 0 0;
        overflow: hidden;
    }

    .messages {
        padding: 24px 20px 20px;
    }

    .msg-bubble {
        padding: 16px 20px;
    }
}

@media (min-width: 500px) {
    .messages {
        padding: 22px 18px 18px;
    }
}
