/* =========================
   GLOBAL PAGE STYLING
========================= */

body {
    background:  #FFFAF5;
    padding-top: 70px; /* navbar offset */
    margin: 0;
}

/* =========================
   MAIN LAYOUT (FULL SCREEN)
========================= */

.chat-layout {
    display: flex;
    width: 100%;
    height: calc(100vh - 70px);
    padding: 20px;
    gap: 20px;
}


/* =========================
   LEFT SIDEBAR (CHATS LIST)
========================= */

.chat-list {
    width: 28%;
    background: #ffffff;
    border-radius: 18px;
    padding: 18px;
    overflow-y: auto;
    border: 2px solid #A187E3;
 
  box-shadow: 0 10px 28px rgba(161, 135, 227, 0.18);
}



.chat-list h3 {
    font-size: 20px;
    font-weight: bold;
    margin-bottom: 15px;
    color: #38023B;
}

/* Chat preview card */
.chat-item {
    display: flex;
    align-items: center;
    gap: 12px;
    background: #FFFAF5;
    padding: 12px;
    border-radius: 14px;
    margin-bottom: 10px;
    cursor: pointer;
    transition: 0.2s;
    border: 2px solid #FFDBE2;
}

.chat-item:hover {
    background: #FFDBE2;
    border:#FFDBE2;
    transform: translateX(3px);
}

.chat-item.active {
   background: #A187E3;
  color: #38023B;
    
}

/* Avatar */
.chat-avatar {
    width: 45px;
    height: 45px;
    border-radius: 50%;
    object-fit: cover;
}

/* Text inside preview */
.chat-info {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.chat-name {
    font-weight: 600;
    font-size: 15px;
    margin-bottom: 2px;
    color: #38023B;
}

.chat-last {
    font-size: 13px;
    color: #6f579a;
    opacity: .8;
}

/* Right time + unread badge */
.chat-time {
    font-size: 12px;
    color: #8561c5;
}

.unread {
    background: #ff4b93;
    color:  #FFFAF5;
    font-size: 11px;
    padding: 2px 6px;
    border-radius: 10px;
    margin-left: 4px;
}


/* =========================
   RIGHT CHAT WINDOW
========================= */

.chat-container {
    flex: 1;
    background: white;
    border-radius: 18px;
    border: 2px solid #A187E3;
    box-shadow: 0 10px 28px rgba(161, 135, 227, 0.18);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}




/* =========================
   CHAT EMPTY STATE
   ========================= */

.chat-empty {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;

  text-align: center;
  font-size: 1.2rem;
  font-weight: 500;

  color: #38023B;
  background: #FFFAF5;

  border-radius: 20px;
  margin: 1.5rem;
  padding: 2rem;
 border: 2px solid #FFDBE2;
  box-shadow: none;
}






/* HEADER */
.chat-header {
    padding: 15px;
    background: #A187E3;

    color: white;
    display: flex;
    align-items: center;
    gap: 15px;
    /* Hidden chat header until a conversation is selected */
  display: none;


}

.chat-header img {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    border: 3px solid rgba(255,255,255,0.6);
    object-fit: cover;
}


/* =========================
   MESSAGES AREA
========================= */

.messages-box {
    flex: 1;
    overflow-y: auto;
    padding: 22px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* Message bubble default */
.message {
    max-width: 70%;
    padding: 10px 14px;
    border-radius: 16px;
    font-size: 15px;
    line-height: 1.35;
    word-wrap: break-word;
    width: fit-content;

    border: 1.5px solid #FFDBE2;
}

/* Received (left) */
.message.received {
   background: #A187E3;
    border: 2px solid #FFDBE2;
color: white;
box-shadow: none;  

    align-self: flex-start;
    border-bottom-left-radius: 4px;
}

/* Sent (right) */
.message.sent {
    background: #FFDBE2;
color: #38023B;
 border: 2px solid #A187E3;
    align-self: flex-end;
    border-bottom-right-radius: 4px;
}

/* Read receipt ✔✔ */
.msg-status {
    font-size: 11px;
    margin-left: 6px;
    opacity: 0.9;
}


/* =========================
   INPUT BAR
========================= */

.chat-input {
    display: flex;
    padding: 15px;
   background: white;
    border-top: 1.5px solid #A187E3;
}

.chat-input input {
    flex: 1;
    padding: 10px;
    border-radius: 10px;
     border: 2px solid #FFDBE2;
}

.chat-input button {
    margin-left: 10px;
    background:#A187E3;
    border: none;
    color: white;
    padding: 10px 15px;
    border-radius: 10px;
    cursor: pointer;
}

.chat-input button:hover {
  background: #ffc685;
}

.button-secondary {
  background: #FFDBE2;
  color: #38023B;
}



/* ===========================
   MOBILE RESPONSIVE LAYOUT
=========================== */

.back-btn {
    display: none;
    background:#A187E3;
    color:#fff;
    border:none;
    padding:8px 14px;
    font-size:16px;
    border-radius:8px;
    margin:10px;
    cursor:pointer;
}

/* MOBILE VIEW */
@media(max-width: 768px) {

    .chat-layout {
        padding: 0;
        height: calc(100vh - 70px);
    }

    /* Hide sidebar on chat page */
    .chat-list {
        width: 100%;
        height: calc(100vh - 70px);
        border-radius:0;
    }

    /* Chat is hidden until contact is opened */
    #chatWindow {
        display: none;
        width: 100%;
        height: calc(100vh - 70px);
        border-radius:0;
    }

    /* When chat open */
    #chatWindow.show {
        display: flex;
    }

    /* Back button visible only on mobile */
    .back-btn {
        display: block;
    }
}


