/* =========================
   RESET & BASE
========================= */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    height: 100%;
}

body {
    font-family: "Inter", "Segoe UI", Roboto, Arial, sans-serif;
    background: #0f172a;
    color: #e5e7eb;
    overflow: hidden;
}

@media (max-width: 768px) {
    body {
        overflow: hidden; /* keep locked */
    }
}

/* Prevent mobile zoom */
input, textarea {
    font-size: 16px;
}

/* =========================
   AUTH (LOGIN / REGISTER)
========================= */
form {
    background: #020617;
    width: 90%;
    max-width: 380px;
    margin: 12vh auto;
    padding: 28px;
    border-radius: 14px;
    box-shadow: 0 20px 40px rgba(0,0,0,0.5);
}

form h2 {
    text-align: center;
    margin-bottom: 22px;
    font-weight: 600;
}

form input {
    width: 100%;
    padding: 12px 14px;
    margin-bottom: 14px;
    border-radius: 10px;
    border: 1px solid #1e293b;
    background: #020617;
    color: #e5e7eb;
    outline: none;
}

form button {
    width: 100%;
    padding: 12px;
    background: linear-gradient(135deg, #22c55e, #16a34a);
    color: #020617;
    border: none;
    border-radius: 10px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
}

form a {
    display: block;
    margin-top: 12px;
    text-align: center;
    font-size: 14px;
    color: #94a3b8;
    text-decoration: none;
}

.error-msg {
    background: #fee2e2;
    color: #991b1b;
    padding: 10px;
    border-radius: 8px;
    margin-bottom: 12px;
    font-size: 14px;
    text-align: center;
}

/* Password toggle */
.password-box {
    position: relative;
}

.password-box input {
    padding-right: 40px;
}

.toggle-pass {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    cursor: pointer;
    font-size: 16px;
}

/* =========================
   CHAT LAYOUT
========================= */
.chat-app {
    display: flex;
    height: 100vh;
}

/* =========================
   SIDEBAR (USERS)
========================= */
.users-panel {
    width: 260px;
    background: #020617;
    border-right: 1px solid #1e293b;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    z-index: 999;
}

.users {
    background: #020617;
}

.user-search {
    padding: 10px;
    border-bottom: 1px solid #1e293b;
}

.user-search input {
    width: 100%;
    padding: 8px 10px;
    border-radius: 8px;
    border: 1px solid #1e293b;
    background: #020617;
    color: #e5e7eb;
    outline: none;
}

.user-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px;
    cursor: pointer;
    color: #e5e7eb;
}

.user-item:hover {
    background: #1e293b;
}

.dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.dot.online { background: #22c55e; }
.dot.offline { background: #64748b; }

.user-text {
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.user-name {
    font-size: 15px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-email {
    font-size: 13px;
    color: #94a3b8;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* =========================
   CHAT AREA
========================= */
.chat-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden; /* contain scroll inside */
    background: #0f172a;
}

/* =========================
   CHAT HEADER
========================= */
.chat-header {
    height: 56px;
    background: #020617;
    border-bottom: 1px solid #1e293b;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 14px;
}

.chat-user {
    display: flex;
    align-items: center;
    gap: 8px;
}

.chat-username {
    font-weight: 600;
    font-size: 14px;
}

.status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
}

.status-dot.online { background: #22c55e; }
.status-dot.offline { background: #64748b; }

.logout-btn {
    font-size: 13px;
    color: #f87171;
    text-decoration: none;
}

.icon-btn {
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    color: #94a3b8;
    padding: 6px;
    border-radius: 50%;
}

.icon-btn:hover {
    background: #1e293b;
}

/* =========================
   MESSAGE SEARCH
========================= */
.msg-search {
    padding: 6px 10px;
    border-radius: 8px;
    border: 1px solid #1e293b;
    background: #020617;
    color: #e5e7eb;
    font-size: 13px;
}

/* =========================
   MESSAGES
========================= */
#messages {
    flex: 1;
    padding: 16px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch; /* 👈 iOS smooth scroll */
}

@media (max-width: 768px) {
    #messages {
        padding-bottom: 100px; /* space for fixed input */
    }
}

@media (max-width: 768px) {
    .chat-app,
    .chat-area {
        height: 100vh; /* 👈 dynamic viewport height */
    }
}

.message {
    max-width: 75%;
    margin-bottom: 14px;
    padding: 12px 14px;
    border-radius: 14px;
    font-size: 14px;
    line-height: 1.5;
    background: #020617;
    word-wrap: break-word;
}

@media (max-width: 768px) {
    .message {
        max-width: 85%;
    }
}

.message strong {
    display: block;
    font-size: 12px;
    color: #38bdf8;
    margin-bottom: 4px;
}

.message img {
    max-width: 100%;
    border-radius: 10px;
    margin-top: 6px;
}

.message a {
    color: #38bdf8;
    text-decoration: none;
}

.message small {
    display: flex !important;
    align-items: center;
    justify-content: flex-end;
    gap: 4px;
    font-size: 12px;
    color: #94a3b8;
    margin-top: 6px;
    text-align: right;
}

/* Message alignment */
.message.me {
    margin-left: auto;
    background: linear-gradient(135deg, #22c55e, #16a34a);
    border-bottom-right-radius: 4px;
}

.message.me strong,
.message.me small {
    color: inherit;
}

.message.other {
    margin-right: auto;
    border-bottom-left-radius: 4px;
}

/* Edit / delete */
.msg-actions {
    display: flex;
    gap: 8px;
    margin-top: 6px;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.message:hover .msg-actions {
    opacity: 1;
}

.msg-actions span {
    font-size: 12px;
    padding: 4px 8px;
    border-radius: 6px;
    cursor: pointer;
    background: #020617;
    border: 1px solid #1e293b;
}

/* =========================
   INPUT AREA
========================= */
.chat-input-wrapper {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    background: #020617;
    border-top: 1px solid #1e293b;
}

.input-container {
    flex: 1;
    background: #0f172a;
    border: 1px solid #1e293b;
    border-radius: 999px;
    padding: 0 14px;
    display: flex;
    align-items: center;
}

.input-container input {
    width: 100%;
    border: none;
    outline: none;
    background: transparent;
    color: #e5e7eb;
    padding: 10px 0;
}

.send-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, #22c55e, #16a34a);
    border: none;
    color: #020617;
    cursor: pointer;
}

/* =========================
   EMOJI PANEL
========================= */
/* =========================
   EMOJI PANEL (MOBILE FIX)
========================= */

.emoji-panel {
    display: none;
    position: fixed;               /* 👈 important */
    bottom: 70px;                  /* above input bar */
    left: 0;
    width: 100%;
    max-height: 220px;
    background: #020617;
    border-top: 1px solid #1e293b;
    z-index: 2000;                 /* 👈 higher than input */
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 10px;
}

.emoji-panel.show {
    display: block;
}

.emoji-panel span {
    font-size: 22px;
    padding: 6px;
    cursor: pointer;
    display: inline-block;
}

/* =========================
   OVERLAY (MOBILE)
========================= */
.overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 998;
    display: none;
}

.users-panel.show ~ .overlay {
    display: block;
}

/* =========================
   MOBILE
========================= */
@media (max-width: 768px) {

    .chat-app {
        flex-direction: column;
    }

    .users-panel {
        position: fixed;
        left: -100%;
        top: 0;
        width: 85%;
        max-width: 320px;
        height: 100%;
        transition: left 0.3s ease;
    }

    .users-panel.show {
        left: 0;
    }

    .msg-search {
        display: none;
    }

    #messages {
        padding-bottom: 90px;
    }

    .chat-input-wrapper {
        position: fixed;
        bottom: 0;
        width: 100%;
        z-index: 999;
    }
}

/* Touch friendly */
button, .icon-btn, .user-item {
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

/* =========================
   MOBILE SCROLL FIX
========================= */

.chat-area {
    overflow: hidden;
}

#messages {
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.users-panel {
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

@media (max-width: 768px) {
    .chat-app,
    .chat-area {
        height: 100vh;
    }

    #messages {
        padding-bottom: 100px;
    }
}

/* =========================
   IMAGE DOWNLOAD BUTTON
========================= */

.image-wrapper {
    position: relative;
    display: inline-block;
    max-width: 220px;      /* 👈 desktop default */
    width: 100%;
}

.image-wrapper img {
    display: block;
    max-width: 100%;
    width: 100%;
    height: auto;
    border-radius: 10px;
    object-fit: cover;
}

/* Mobile: slightly bigger but controlled */
@media (max-width: 768px) {
    .image-wrapper {
        max-width: 180px;
    }
}

/* Download button */
.img-download-btn {
    position: absolute;
    bottom: 6px;
    right: 6px;
    background: rgba(0,0,0,0.6);
    color: #fff;
    border: none;
    border-radius: 50%;
    width: 32px;
    height: 32px;
    font-size: 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.img-download-btn:hover {
    background: rgba(0,0,0,0.8);
}

/* =========================
   USER PROFILE (CENTERED)
========================= */

.user-profile {
    display: flex;
    flex-direction: column;     /* 👈 stack vertically */
    align-items: center;        /* 👈 center horizontally */
    text-align: center;
    gap: 8px;
    padding: 16px 12px;
    border-bottom: 1px solid #1e293b;
    background: #020617;
}

.profile-avatar {
    width: 56px;                /* 👈 bigger looks better */
    height: 56px;
    border-radius: 50%;
    background: linear-gradient(135deg, #22c55e, #16a34a);
    color: #020617;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 22px;
    cursor: pointer;
    overflow: hidden;
}

.profile-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.profile-info {
    display: flex;
    flex-direction: column;
    align-items: center;        /* 👈 center text */
    overflow: hidden;
}

.profile-name {
    font-size: 15px;
    font-weight: 600;
    color: #e5e7eb;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}

.profile-email,
.profile-mobile {
    font-size: 12px;
    color: #94a3b8;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}

@media (max-width: 768px) {
    .profile-avatar {
        width: 50px;
        height: 50px;
        font-size: 20px;
    }

    .profile-name {
        font-size: 14px;
    }
}

/* =========================
   EMOJI CATEGORIES
========================= */

.emoji-tabs {
    display: flex;
    border-bottom: 1px solid #1e293b;
    margin-bottom: 8px;
}

.emoji-tabs button {
    flex: 1;
    background: none;
    border: none;
    font-size: 20px;
    padding: 8px 0;
    cursor: pointer;
    color: #94a3b8;
}

.emoji-tabs button.active {
    color: #22c55e;
    border-bottom: 2px solid #22c55e;
}

.emoji-content {
    max-height: 180px;
    overflow-y: auto;
}

.emoji-group {
    display: none;
}

.emoji-group.active {
    display: block;
}

.emoji-group span {
    font-size: 22px;
    padding: 6px;
    cursor: pointer;
    display: inline-block;
}

.user-avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: linear-gradient(135deg, #22c55e, #16a34a);
    color: #020617;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 14px;
    flex-shrink: 0;
    overflow: hidden;
}

.user-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
/* =========================
   MESSAGE TICKS
========================= */

.ticks {
    display: inline-flex !important;
    align-items: center;
    font-size: 12px !important;
    line-height: 1;
}

.ticks.delivered {
    color: #94a3b8 !important;
}

.ticks.seen {
    color: #3b82f6 !important; /* BLUE */
}

/* =========================
   FILE / IMAGE MENU
========================= */

.image-wrapper,
.file-box {
    position: relative;
    display: inline-block;
}

.file-menu-btn {
    position: absolute;
    top: 6px;
    right: 6px;
    background: rgba(0,0,0,0.6);
    border: none;
    color: #fff;
    font-size: 16px;
    padding: 2px 6px;
    border-radius: 6px;
    cursor: pointer;
}

.file-menu {
    position: absolute;
    top: 28px;
    right: 6px;
    background: #020617;
    border: 1px solid #1e293b;
    border-radius: 8px;
    display: none;
    z-index: 3000;
    min-width: 120px;
}

.file-menu a {
    display: block;
    padding: 8px 12px;
    color: #e5e7eb;
    text-decoration: none;
    font-size: 13px;
}

.file-menu a:hover {
    background: #1e293b;
}
.typing-indicator {
    padding: 6px 14px;
    font-size: 13px;
    color: #94a3b8;
    font-style: italic;
}
.typing-indicator::after {
    content: "...";
    animation: dots 1.5s infinite;
}

@keyframes dots {
    0% { content: "."; }
    33% { content: ".."; }
    66% { content: "..."; }
}

.icon-btn {
    background: none;
    border: none;
    font-size: 18px;
    cursor: pointer;
    padding: 6px;
}

.icon-btn:hover {
    background: #1e293b;
    border-radius: 50%;
}









