/* --- GLOBAL STYLES --- */
body {
    margin: 0;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    background-color: #e9eff1; 
    color: #333;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
}

.hidden {
    display: none !important; 
}

/* --- SETUP SCREEN --- */
.setup-container {
    background-color: #fff;
    padding: 40px;
    border-radius: 12px;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.1);
    width: 400px;
    text-align: center;
}

.setup-container h1 {
    color: #ff385c; /* Primary app color: deep pink/red */
    margin-bottom: 10px;
}

#profileSetupForm {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

#profileSetupForm label {
    text-align: left;
    font-weight: 600;
    margin-top: 5px;
    color: #555;
}

#profileSetupForm input {
    padding: 12px;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 16px;
}

#profileSetupForm button {
    background-color: #ff385c;
    color: white;
    padding: 15px;
    border: none;
    border-radius: 8px;
    font-size: 18px;
    cursor: pointer;
    transition: background-color 0.2s, transform 0.1s;
    margin-top: 20px;
}

#profileSetupForm button:hover {
    background-color: #e02a4a;
    transform: translateY(-1px);
}

/* --- MAIN APPLICATION LAYOUT --- */
.app-container {
    display: grid;
    grid-template-columns: 220px 1fr 300px;
    height: 95vh;
    width: 1000px;
    max-width: 95vw;
    background-color: #fff;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    overflow: hidden;
}

/* --- LEFT SIDEBAR (Profile List) --- */
.sidebar {
    background-color: #f7f7f7;
    padding: 15px;
    border-right: 1px solid #e0e0e0;
    overflow-y: auto;
}

.sidebar h2 {
    color: #333;
    border-bottom: 1px solid #ddd;
    padding-bottom: 10px;
    margin-top: 0;
    margin-bottom: 15px;
    font-size: 18px;
}

#profileCount {
    font-weight: 500;
    color: #777;
    margin-bottom: 15px;
    font-size: 14px;
}

.profile-card {
    background-color: #fff;
    padding: 10px;
    margin-bottom: 8px;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    cursor: pointer;
    transition: all 0.2s;
    border-left: 3px solid transparent;
}

.profile-card:hover {
    background-color: #fff0f5; 
    transform: translateY(-1px);
}

.profile-card.active {
    border-left: 3px solid #ff385c;
    background-color: #ffe6eb;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

.profile-card-header {
    display: flex;
    align-items: center;
}

.profile-card-header h3 {
    margin: 0;
    font-size: 15px;
    color: #333;
}

.profile-card-header p {
    margin: 0;
    font-size: 11px;
    color: #777;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.profile-photo-tiny {
    width: 35px;
    height: 35px;
    border-radius: 50%;
    margin-right: 10px;
    object-fit: cover;
    border: 2px solid #ff385c;
}

/* --- MIDDLE SECTION (Chat & Welcome) --- */
.chat-main {
    display: flex;
    flex-direction: column;
    height: 100%;
    background-color: #ffffff;
}

.welcome-screen {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    color: #aaa;
    background: linear-gradient(135deg, #fefefe, #f4f4f4); 
    padding: 20px;
}

.welcome-screen h2 {
    font-size: 32px;
    color: #555;
    margin-bottom: 5px;
}
.welcome-screen p {
    font-size: 16px;
    margin-top: 10px;
    max-width: 300px;
}

/* Active Chat Header */
.chat-header {
    display: none; 
    align-items: center;
    justify-content: space-between; 
    padding: 10px 20px;
    border-bottom: 1px solid #f0f0f0;
    background-color: #f7f7f7; 
}
.chat-header h3 {
    margin: 0;
    font-size: 18px;
    color: #333;
    font-weight: 600;
}
.chat-header img {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    margin-right: 10px;
    border: 2px solid #ff385c;
}


/* Chat bubbles */
.messages-container {
    flex-grow: 1;
    padding: 20px;
    overflow-y: auto;
    background-color: #fcfcfc;
    display: flex; 
    flex-direction: column;
}

.message {
    max-width: 70%;
    padding: 10px 15px;
    border-radius: 18px;
    margin-bottom: 8px;
    line-height: 1.4;
    font-size: 14px;
}

.message.user {
    background-color: #ff385c;
    color: white;
    align-self: flex-end; 
    border-bottom-right-radius: 4px; 
}

.message.other {
    background-color: #e6e6e6;
    color: #333;
    align-self: flex-start; 
    border-bottom-left-radius: 4px; 
}
.message .time {
    display: block;
    font-size: 10px;
    margin-top: 3px;
    text-align: right;
    color: rgba(255, 255, 255, 0.7); 
}
.message.other .time {
    color: #888; 
}

/* Type area */
.type-area {
    display: flex; 
    padding: 15px 20px;
    border-top: 1px solid #f0f0f0;
    background-color: #fff;
}
.type-area input {
    flex-grow: 1;
    padding: 10px 15px;
    border: 1px solid #ddd;
    border-radius: 20px;
    font-size: 14px;
    margin-right: 10px;
}
.type-area button {
    background-color: #ff385c; 
    color: white;
    border: none;
    border-radius: 20px;
    padding: 10px 15px;
    cursor: pointer;
    transition: background-color 0.2s;
}
.type-area button:hover:not(:disabled) {
    background-color: #e02a4a;
}
.type-area button:disabled {
    background-color: #ccc;
    cursor: not-allowed;
}


/* --- RIGHT SIDEBAR (Info) --- */
.info-area {
    background-color: #fcfcfc; 
    padding: 25px;
    border-left: 1px solid #e0e0e0;
    display: flex; 
    flex-direction: column;
    align-items: center;
    text-align: center;
    overflow-y: auto;
}

.info-area h3 {
    color: #ff385c;
    margin-bottom: 20px;
    font-size: 20px;
    width: 100%;
    border-bottom: 2px solid #ff385c; 
    padding-bottom: 10px;
}

.info-placeholder {
    margin-top: 50px;
    color: #aaa;
    font-style: italic;
    font-size: 16px;
}

.profile-photo-large {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    background-color: #ccc;
    background-size: cover;
    background-position: center;
    margin: 0 auto 15px;
    border: 4px solid #ff385c;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
}

.info-area h4 {
    margin: 5px 0 15px;
    font-size: 24px;
    color: #333;
}

.info-area p {
    text-align: left;
    margin-bottom: 10px;
    font-size: 14px;
    line-height: 1.5;
    width: 100%;
    padding: 5px 0;
}

.user-profile-badge {
  position: absolute;
  top: 15px;
  right: 20px;
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(255, 255, 255, 0.9);
  padding: 8px 15px;
  border-radius: 20px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.user-profile-badge img {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 2px solid #ff385c;
}

.user-profile-badge span {
  font-size: 14px;
  font-weight: 600;
  color: #333;
}

/* --- FIX: SCROLLING FOR MESSAGES --- */
.messages-container {
    flex-grow: 1;
    padding: 20px;
    overflow-y: auto !important; /* CRITICAL: Enable vertical scrolling */
    max-height: calc(100vh - 250px); /* Prevent container from growing infinitely */
    background-color: #fcfcfc;
    display: flex; 
    flex-direction: column;
}

/* Smooth scrolling behavior */
.messages-container {
    scroll-behavior: smooth;
}