* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    height: 100%;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

/* ---------------- Login ---------------- */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #ff9a9e 0%, #fad0c4 50%, #fbc2eb 100%);
}

.login-card {
    background: #fff;
    width: 92%;
    max-width: 360px;
    padding: 32px 26px;
    border-radius: 20px;
    box-shadow: 0 18px 50px rgba(0, 0, 0, 0.18);
    text-align: center;
}

.login-card h1 { margin: 0 0 6px; font-size: 24px; color: #d6336c; }
.subtitle { margin: 0 0 20px; color: #888; font-size: 14px; }

.role-picker { display: flex; gap: 14px; }

.role-btn {
    flex: 1;
    padding: 22px 0;
    font-size: 17px;
    border: 2px solid #ffd0dc;
    background: #fff5f8;
    border-radius: 16px;
    cursor: pointer;
    transition: transform 0.12s, background 0.12s;
}
.role-btn:hover { background: #ffe3ec; transform: translateY(-2px); }

.login-form { display: flex; flex-direction: column; gap: 14px; text-align: left; }
.login-form label { display: flex; flex-direction: column; font-size: 13px; color: #666; gap: 6px; }
.login-form input { padding: 12px; border: 1px solid #e3e3e3; border-radius: 10px; font-size: 15px; }

.submit-btn {
    padding: 13px; border: none; border-radius: 10px;
    background: #d6336c; color: #fff; font-size: 16px; cursor: pointer;
}
.submit-btn:hover { background: #b22455; }

.back-btn { background: none; border: none; color: #999; cursor: pointer; font-size: 14px; }

.error {
    background: #ffe3e3; color: #c92a2a; padding: 10px;
    border-radius: 10px; margin-bottom: 16px; font-size: 14px;
}

.hidden { display: none !important; }

/* ---------------- Chat ---------------- */
.chat-page {
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh;
    background-color: #d9d2c7;
    /* subtle WhatsApp-style wallpaper pattern */
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='80' height='80' viewBox='0 0 80 80'%3E%3Cg fill='%23c9bfb0' fill-opacity='0.35'%3E%3Cpath d='M20 30c-3-4-9-4-9 2 0 5 9 10 9 10s9-5 9-10c0-6-6-6-9-2z'/%3E%3Cpath d='M58 56c-2-3-7-3-7 1 0 4 7 8 7 8s7-4 7-8c0-4-5-4-7-1z'/%3E%3C/g%3E%3C/svg%3E");
}

.chat-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    background: #d6336c;
    color: #fff;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    z-index: 5;
}

.avatar {
    width: 40px; height: 40px; border-radius: 50%;
    background: rgba(255, 255, 255, 0.25);
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 18px;
}

.peer { display: flex; flex-direction: column; line-height: 1.2; }
.peer-name { font-weight: 700; font-size: 16px; }
.peer-status { font-size: 12px; opacity: 0.9; min-height: 14px; }
.peer-status.online { color: #c9ffd0; }
.peer-status.typing { color: #fff; font-style: italic; }

.logout {
    margin-left: auto;
    color: #fff; text-decoration: none; font-size: 20px;
    width: 36px; height: 36px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
}
.logout:hover { background: rgba(255, 255, 255, 0.18); }

.messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px 12px 8px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.loading { text-align: center; color: #6b6b6b; margin-top: 20px; }

.day-sep { text-align: center; margin: 12px 0; }
.day-sep span {
    background: rgba(255, 255, 255, 0.85);
    color: #555; font-size: 12px;
    padding: 4px 12px; border-radius: 10px;
    box-shadow: 0 1px 1px rgba(0, 0, 0, 0.08);
}

.msg { display: flex; max-width: 80%; }
.msg.mine   { align-self: flex-end; justify-content: flex-end; }
.msg.theirs { align-self: flex-start; }

.bubble {
    position: relative;
    padding: 6px 10px 6px 12px;
    border-radius: 10px;
    font-size: 15px;
    line-height: 1.4;
    word-wrap: break-word;
    white-space: pre-wrap;
    box-shadow: 0 1px 1px rgba(0, 0, 0, 0.12);
    max-width: 100%;
}

.msg.mine .bubble   { background: #f7d6e3; border-top-right-radius: 3px; }
.msg.theirs .bubble { background: #fff; border-top-left-radius: 3px; }

.bubble .text a { color: #1a73e8; }

.bubble .meta {
    float: right;
    margin: 6px 0 -2px 10px;
    font-size: 10.5px;
    color: #888;
    user-select: none;
    white-space: nowrap;
}

.tick { margin-left: 3px; color: #9a9a9a; letter-spacing: -2px; }
.tick.read { color: #34b7f1; }

.bubble.deleted { background: #efe7df !important; font-style: italic; }
.del-text { color: #777; }

.del-btn {
    position: absolute;
    top: 2px; right: 2px;
    border: none; background: rgba(0,0,0,0.06);
    border-radius: 50%;
    width: 22px; height: 22px;
    font-size: 11px; cursor: pointer;
    opacity: 0; transition: opacity 0.12s;
}
.msg.mine .bubble:hover .del-btn { opacity: 1; }

/* ---------------- Composer ---------------- */
.composer {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    padding: 8px 10px;
    background: #f0f0f0;
}

.emoji-btn, .send-btn {
    flex: none;
    border: none;
    cursor: pointer;
    border-radius: 50%;
    width: 44px; height: 44px;
    font-size: 20px;
}
.emoji-btn { background: transparent; }
.send-btn { background: #d6336c; color: #fff; }
.send-btn:hover { background: #b22455; }

.composer textarea {
    flex: 1;
    resize: none;
    max-height: 140px;
    padding: 11px 14px;
    border: none;
    border-radius: 22px;
    font-size: 15px;
    font-family: inherit;
    line-height: 1.4;
    outline: none;
}

.emoji-panel {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 2px;
    padding: 10px;
    background: #fff;
    border-top: 1px solid #e3e3e3;
    max-height: 200px;
    overflow-y: auto;
}
.emoji-panel button {
    border: none; background: none; cursor: pointer;
    font-size: 22px; padding: 6px; border-radius: 8px;
}
.emoji-panel button:hover { background: #f0f0f0; }

@media (max-width: 500px) {
    .emoji-panel { grid-template-columns: repeat(6, 1fr); }
}
