/* css/chat.css */

html,
body {
    height: 100%;
    height: 100dvh;
    /* Mobile address bar fix */
    margin: 0;
    padding: 0;
    overflow: hidden;
    /* Prevent full page scroll */
    font-family: 'Inter', sans-serif;
    background-color: #f0f2f5;
}

#app {
    /* Matches structure in public_channel.php */
    height: 100%;
}

.chat-container {
    height: 100%;
    /* Fill viewport exactly */
    max-width: 600px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    background: #fff;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.05);
    position: relative;
}

.chat-header {
    flex-shrink: 0;
    /* Never shrink */
    padding: 1rem;
    border-bottom: 1px solid #f0f0f0;
    background: #fff;
    z-index: 100;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.02);
    position: relative;
}

.messages-area,
#messagesArea {
    flex: 1;
    /* Take all remaining space */
    overflow-y: auto;
    padding: 1rem;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
    /* iOS Momentum */
    background-color: #efeae2;
    /* WhatsApp-like background hint? Or stick to white/gray */
    background-image: radial-gradient(#e5e5e5 1px, transparent 1px);
    background-size: 20px 20px;
}

/* Ensure flex container works if ID is different */
#messagesArea.flex-grow-1 {
    flex-grow: 1 !important;
}

.chat-input-area {
    flex-shrink: 0;
    /* Never shrink */
    padding: 1rem;
    border-top: 1px solid #f0f0f0;
    background: #fff;
    position: relative;
    z-index: 100;
}

.message {
    margin-bottom: 1rem;
    max-width: 80%;
    padding: 0.75rem 1rem;
    border-radius: 12px;
    font-size: 0.95rem;
    line-height: 1.4;
    position: relative;
    word-wrap: break-word;
}

.message.outgoing {
    align-self: flex-end;
    background-color: #0d6efd;
    color: white;
    border-bottom-right-radius: 2px;
    margin-left: auto;
}

.message.incoming {
    align-self: flex-start;
    background-color: #f1f3f5;
    color: #333;
    border-bottom-left-radius: 2px;
    margin-right: auto;
}

.message-time {
    font-size: 0.7rem;
    margin-top: 4px;
    opacity: 0.8;
    text-align: right;
    display: block;
}

.message-failed {
    border: 1px solid red;
}

.start-screen {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    height: 100%;
    text-align: center;
    padding: 2rem;
}

/* Avatars */
.avatar-circle {
    width: 40px;
    height: 40px;
    background-color: #0d6efd;
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
}

/* Buttons */
.btn-icon {
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.btn-icon:hover {
    background-color: #f8f9fa;
}

@media (max-width: 768px) {

    /* Revert to Flexbox with JS sizing */
    /* Handled by chat.js Viewport correction */
    .chat-input-area {
        padding-bottom: calc(1rem + env(safe-area-inset-bottom));
    }
}