/* ... existing code ... */

/* Login Page Styling */
.login-bg {
    background-color: #fdf0f0;
    background-image:
        linear-gradient(180deg, #ff4d6d 0%, #ff4d6d 220px, #fdf0f0 220px, #fdf0f0 100%);
    width: 100vw;
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
}

.login-container {
    width: 100%;
    max-width: 900px;
    height: 70%;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2;
}

.login-card {
    background: white;
    padding: 0;
    border-radius: 3px;
    box-shadow: 0 17px 50px 0 rgba(11, 20, 26, .19), 0 12px 15px 0 rgba(11, 20, 26, .24);
    display: flex;
    overflow: hidden;
    width: 100%;
    max-width: 800px;
    height: 500px;
}

/* Create a split view like WhatsApp Web */
.login-left {
    flex: 2;
    padding: 40px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    position: relative;
}

.login-right {
    flex: 1;
    background-color: white;
    /* Or QR code area */
    display: flex;
    justify-content: center;
    align-items: center;
    border-left: 1px solid #efefef;
    position: relative;
}

/* Mobile responsive override */
@media (max-width: 768px) {
    .login-bg {
        background: white;
        flex-direction: column;
    }

    .login-card {
        box-shadow: none;
        flex-direction: column;
        height: auto;
        padding: 20px;
        max-width: 400px;
    }

    .login-left {
        padding: 20px 0;
    }

    .login-right {
        display: none;
        /* Hide decorative right side on mobile */
    }
}

.login-title {
    font-size: 28px;
    font-weight: 300;
    margin-bottom: 40px;
    color: #41525d;
}

.login-form input {
    width: 100%;
    padding: 10px 0;
    margin-bottom: 20px;
    border: none;
    border-bottom: 2px solid #ff4d6d;
    font-size: 16px;
    outline: none;
    transition: border-bottom-color 0.3s;
}

.login-form input:focus {
    border-bottom-color: #e91e63;
}

.login-btn {
    background-color: #ff4d6d;
    color: white;
    padding: 12px 24px;
    border: none;
    border-radius: 24px;
    font-size: 14px;
    font-weight: 600;
    letter-spacing: 1px;
    cursor: pointer;
    text-transform: uppercase;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
    align-self: flex-start;
}

.login-btn:hover {
    background-color: #ff0a54;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
}

.brand-footer {
    position: absolute;
    bottom: 20px;
    width: 100%;
    text-align: center;
    font-size: 12px;
    color: #8696a0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.brand-footer b {
    color: #3b4a54;
}

/* Restore or keep general styles */
:root {
    --app-background: #fdf0f0;
    --app-header: #ff4d6d;
    --chat-header: #ff4d6d;
    --incoming-msg: #ffffff;
    --outgoing-msg: #ffe3e8;
    --primary-text: #4a0e0e;
    --secondary-text: #c9184a;
    --input-bg: #ffffff;
    --send-btn: #ff4d6d;
    --send-btn-hover: #ff0a54;
    --panic-btn: #ffffff;
    --panic-btn-hover: #c2185b;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: 'Segoe UI', 'Helvetica Neue', Helvetica, Arial, sans-serif;
    background-color: #fce4ec;
    height: 100vh;
    height: 100dvh;
    /* Dynamic viewport height - accounts for mobile browser address bar */
    display: flex;
    flex-direction: column;
    overflow: hidden;
    /* Prevent body scroll on mobile */
}

/* Chat Layout & Components */
.chat-container {
    background-color: var(--app-background);
    width: 100%;
    max-width: 1000px;
    height: 100vh;
    height: 100dvh;
    /* Dynamic viewport height for mobile */
    display: flex;
    flex-direction: column;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    position: relative;
    overflow: hidden;
    margin: auto;
}

/* Desktop: rounded card look */
@media (min-width: 768px) {
    .chat-container {
        height: 95vh;
        height: 95dvh;
        border-radius: 12px;
        margin: auto;
    }
}

/* Mobile: true full-screen Android app feel */
@media (max-width: 767px) {

    html,
    body {
        height: 100%;
        background-color: var(--app-background);
    }

    .chat-container {
        /* Pin to all 4 edges — fills exactly the visible area above keyboard */
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        width: 100%;
        max-width: 100%;
        height: 100%;
        /* JS will set --kb-bottom on older Android */
        border-radius: 0;
        box-shadow: none;
        margin: 0;
        display: flex;
        flex-direction: column;
        overflow: hidden;
    }

    /* Header always visible at top */
    .chat-header {
        flex-shrink: 0;
        z-index: 100;
    }

    /* Chat messages: fills all remaining space and scrolls */
    #chat {
        flex: 1;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        overscroll-behavior: contain;
        min-height: 0;
        /* Critical for flex shrink to work */
    }

    /* Reply bar stays above footer */
    .reply-preview-bar {
        flex-shrink: 0;
    }

    /* Recording bar stays above footer */
    .recording-bar {
        flex-shrink: 0;
    }

    /* Footer always visible at bottom */
    .chat-footer {
        flex-shrink: 0;
        z-index: 100;
        padding-bottom: max(10px, env(safe-area-inset-bottom));
    }

    /* Emoji picker repositioned for mobile */
    .emoji-picker {
        bottom: 80px;
        left: 10px;
        right: 10px;
        width: auto;
    }

    /* Larger touch targets for mobile */
    .btn-icon {
        padding: 10px;
        min-width: 44px;
        min-height: 44px;
    }

    /* Messages take more width on mobile */
    .message {
        max-width: 82%;
    }

    /* Prevents iOS/Android from zooming in when tapping the input */
    .chat-footer input {
        font-size: 16px;
    }
}

.chat-header {
    background-color: var(--chat-header);
    color: white;
    padding: 10px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
    z-index: 10;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background-color: #ff4d6d;
    background-image: url('https://png.pngtree.com/png-clipart/20240808/original/pngtree-glossy-3d-hearts-the-essence-of-love-png-image_15733301.png');
    background-size: cover;
}

.chat-info h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 500;
}

.chat-info span {
    font-size: 13px;
    color: rgba(255, 255, 255, 0.85);
    min-height: 20px;
    display: block;
}

.status-typing {
    color: #ffd1dc !important;
    font-weight: 600;
    transition: color 0.2s;
}

#chat {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background-color: #fdf0f0;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='40' height='40' viewBox='0 0 40 40'%3E%3Cpath d='M20 10 C20 0 0 0 0 10 C0 20 20 35 20 35 C20 35 40 20 40 10 C40 0 20 0 20 10' fill='%23ff4d6d' fill-opacity='0.05'/%3E%3C/svg%3E");
    background-repeat: repeat;
    background-size: 40px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

#chat::-webkit-scrollbar {
    width: 6px;
}

#chat::-webkit-scrollbar-thumb {
    background-color: rgba(0, 0, 0, 0.2);
    border-radius: 3px;
}

.message {
    max-width: 65%;
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 14.2px;
    line-height: 19px;
    position: relative;
    word-wrap: break-word;
    box-shadow: 0 1px 0.5px rgba(0, 0, 0, 0.13);
}

.message-in {
    background-color: var(--incoming-msg);
    align-self: flex-start;
    border-top-left-radius: 0;
}

.message-out {
    background-color: var(--outgoing-msg);
    align-self: flex-end;
    border-top-right-radius: 0;
}

.msg-sender {
    font-size: 12px;
    font-weight: bold;
    color: var(--app-header);
    margin-bottom: 2px;
    display: block;
}

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

.chat-footer {
    background-color: #fdf0f0;
    padding: 10px 16px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.chat-footer input {
    flex: 1;
    padding: 12px 16px;
    border: none;
    border-radius: 20px;
    font-size: 15px;
    outline: none;
    background-color: var(--input-bg);
}

.btn-icon {
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    transition: background 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-icon:hover {
    background-color: rgba(0, 0, 0, 0.05);
}

.btn-send {
    color: var(--send-btn);
}

.btn-panic {
    color: var(--panic-btn);
}

.btn-logout {
    color: #ffffff;
}

.material-icons {
    font-size: 24px;
}

/* Existing styles... */

/* Message Status Ticks */
.msg-meta {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    margin-top: 2px;
    gap: 3px;
    float: right;
    margin-left: 6px;
    margin-bottom: -4px;
}

.msg-time {
    font-size: 11px;
    color: rgba(0, 0, 0, 0.45);
    margin-right: 2px;
}

.status-icon {
    font-size: 15px !important;
}

.status-sent {
    color: #8696a0;
}

.status-read {
    color: #53bdeb;
    /* Blue */
}

/* Update message padding to accommodate metadata */
.message {
    padding-bottom: 6px;
    /* Less padding at bottom */
}

/* ... existing styles ... */

/* Emoji Picker */
.emoji-picker {
    position: absolute;
    bottom: 70px;
    left: 20px;
    background: white;
    padding: 10px;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
    z-index: 100;
}

.emoji-picker span {
    font-size: 24px;
    cursor: pointer;
    transition: transform 0.2s;
}

.emoji-picker span:hover {
    transform: scale(1.2);
}

/* Chat Image Styles */
.chat-image {
    max-width: 100%;
    border-radius: 8px;
    cursor: pointer;
    margin-bottom: 2px;
    display: block;
}

/* Reply Feature Styles */
.reply-preview-bar {
    background-color: #fdf0f0;
    padding: 8px 16px;
    border-left: 5px solid #ff4d6d;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-top: 1px solid rgba(0, 0, 0, 0.1);
    animation: slideUp 0.2s ease-out;
}

@keyframes slideUp {
    from {
        transform: translateY(100%);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.reply-content {
    display: flex;
    flex-direction: column;
    width: 90%;
}

.reply-sender-name {
    color: #ff4d6d;
    font-weight: bold;
    font-size: 13px;
    margin-bottom: 2px;
}

.reply-message-text {
    font-size: 13px;
    color: #667781;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Reply Inside Message Bubble */
.reply-preview {
    background-color: rgba(0, 0, 0, 0.05);
    border-radius: 4px;
    padding: 6px;
    margin-bottom: 6px;
    border-left: 4px solid #ff4d6d;
    cursor: pointer;
    font-size: 12px;
}

.message-out .reply-preview {
    background-color: rgba(0, 0, 0, 0.1);
    border-left-color: #c9184a;
}

.reply-info {
    display: flex;
    flex-direction: column;
}

.reply-sender {
    font-weight: bold;
    color: #ff4d6d;
    margin-bottom: 2px;
}

.message-out .reply-sender {
    color: #800e13;
}

.reply-text {
    color: #54656f;
}

.highlight-message {
    animation: flash 1s ease;
}

@keyframes flash {
    0% {
        background-color: rgba(255, 77, 109, 0.3);
    }

    100% {
        background-color: transparent;
    }
}

/* Context Menu */
.context-menu {
    position: absolute;
    background: white;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
    border-radius: 4px;
    z-index: 1000;
    min-width: 120px;
    overflow: hidden;
    animation: fadeIn 0.1s ease-out;
}

.context-menu-item {
    padding: 10px 16px;
    cursor: pointer;
    font-size: 14px;
    color: #3b4a54;
    display: flex;
    align-items: center;
    gap: 8px;
}

.context-menu-item:hover {
    background-color: #fdf0f0;
}

.msg-edited {
    font-size: 10px;
    color: #8696a0;
    margin-right: 4px;
    font-style: italic;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: scale(0.95);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* ── Mic Button ────────────────────────────────────────────────────────────── */
.btn-mic {
    color: var(--send-btn);
}

/* ── Recording Bar ─────────────────────────────────────────────────────────── */
.recording-bar {
    background-color: #fdf0f0;
    padding: 10px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-top: 1px solid rgba(0, 0, 0, 0.08);
    animation: slideUp 0.2s ease-out;
    flex-shrink: 0;
    z-index: 100;
}

/* Pulsing red dot */
.recording-pulse {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background-color: #d32f2f;
    animation: pulse-dot 1s ease-in-out infinite;
    flex-shrink: 0;
}

@keyframes pulse-dot {

    0%,
    100% {
        transform: scale(1);
        opacity: 1;
    }

    50% {
        transform: scale(1.4);
        opacity: 0.6;
    }
}

.recording-label {
    font-size: 14px;
    color: #3b4a54;
    flex: 1;
}

.recording-timer {
    font-size: 14px;
    font-weight: 600;
    color: #d32f2f;
    min-width: 36px;
    text-align: right;
}

/* ── Voice Message Bubble ──────────────────────────────────────────────────── */
.voice-msg-player {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 180px;
    max-width: 260px;
    padding: 2px 0 4px;
}

.voice-play-btn {
    background: var(--send-btn);
    border: none;
    border-radius: 50%;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
    transition: background 0.2s;
}

.voice-play-btn:hover {
    background: var(--send-btn-hover);
}

.voice-play-btn .material-icons {
    color: white;
    font-size: 20px !important;
}

/* Waveform bars */
.voice-waveform {
    display: flex;
    align-items: center;
    gap: 2px;
    flex: 1;
    height: 28px;
}

.voice-bar {
    width: 3px;
    border-radius: 2px;
    background-color: #8696a0;
    transition: height 0.1s ease;
    /* Random-ish static heights to look like a real waveform */
}

/* Give bars varied heights for natural waveform look */
.voice-bar:nth-child(1) {
    height: 8px;
}

.voice-bar:nth-child(2) {
    height: 14px;
}

.voice-bar:nth-child(3) {
    height: 20px;
}

.voice-bar:nth-child(4) {
    height: 12px;
}

.voice-bar:nth-child(5) {
    height: 24px;
}

.voice-bar:nth-child(6) {
    height: 16px;
}

.voice-bar:nth-child(7) {
    height: 28px;
}

.voice-bar:nth-child(8) {
    height: 18px;
}

.voice-bar:nth-child(9) {
    height: 22px;
}

.voice-bar:nth-child(10) {
    height: 10px;
}

.voice-bar:nth-child(11) {
    height: 20px;
}

.voice-bar:nth-child(12) {
    height: 14px;
}

.voice-bar:nth-child(13) {
    height: 8px;
}

.voice-bar:nth-child(14) {
    height: 16px;
}

.voice-bar:nth-child(15) {
    height: 12px;
}

/* Animated waveform when playing */
.voice-bar.playing {
    background-color: var(--send-btn);
    animation: wave-dance 0.6s ease-in-out infinite alternate;
}

.voice-bar.playing:nth-child(odd) {
    animation-delay: 0s;
}

.voice-bar.playing:nth-child(even) {
    animation-delay: 0.15s;
}

@keyframes wave-dance {
    from {
        transform: scaleY(0.4);
    }

    to {
        transform: scaleY(1.2);
    }
}

/* Duration text */
.voice-duration {
    font-size: 11px;
    color: rgba(0, 0, 0, 0.45);
    min-width: 28px;
    text-align: right;
    flex-shrink: 0;
}

/* Outgoing voice bubble — tint play button differently */
.message-out .voice-play-btn {
    background: #ff4d6d;
}

.message-out .voice-bar {
    background-color: #667781;
}

/* ── Date Separators ───────────────────────────────────────────────────────── */
.date-separator {
    display: flex;
    justify-content: center;
    margin: 20px 0;
    position: sticky;
    top: 10px;
    z-index: 5;
}

.date-badge {
    background-color: #ffffff;
    color: #54656f;
    font-size: 12.5px;
    padding: 6px 12px;
    border-radius: 8px;
    box-shadow: 0 1px 1px rgba(11, 20, 26, .08);
    text-transform: uppercase;
    font-weight: 500;
}

/* ── Splash Screen ─────────────────────────────────────────────────────────── */
#splash-screen {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #fdf0f0;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    transition: opacity 0.5s ease-out, visibility 0.5s;
}

.splash-logo {
    width: 80px;
    height: 80px;
    margin-bottom: 40px;
    animation: splash-pulse 2s ease-in-out infinite;
}

@keyframes splash-pulse {

    0%,
    100% {
        transform: scale(1);
        opacity: 0.8;
    }

    50% {
        transform: scale(1.1);
        opacity: 1;
    }
}

.splash-loading-bar {
    width: 150px;
    height: 3px;
    background-color: #e9edef;
    border-radius: 2px;
    overflow: hidden;
    position: relative;
}

.splash-progress {
    width: 40%;
    height: 100%;
    background-color: #ff4d6d;
    position: absolute;
    animation: splash-load 1.5s ease-in-out infinite;
}

@keyframes splash-load {
    0% {
        left: -40%;
    }

    100% {
        left: 100%;
    }
}

.splash-footer {
    position: absolute;
    bottom: 40px;
    text-align: center;
}

.splash-footer .from {
    font-size: 12px;
    color: #8696a0;
    margin-bottom: 4px;
}

.splash-footer .brand {
    font-size: 16px;
    font-weight: bold;
    color: #3b4a54;
    letter-spacing: 2px;
}

.message-out .voice-bar.playing {
    background-color: #ff4d6d;
}