:root {
    --bg-color: #efeae2;
    --sidebar-bg: #ffffff;
    --header-bg: #f0f2f5;
    --search-bg: #f0f2f5;
    --border-color: #d1d7db;
    --text-primary: #111b21;
    --text-secondary: #667781;
    --sent-msg-bg: #d9fdd3;
    --received-msg-bg: #ffffff;
    --chat-hover: #f5f6f6;
    --chat-active: #f0f2f5;
    --timestamp-color: #667781;
    --whatsapp-teal: #008069;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Segoe UI', 'Helvetica Neue', Helvetica, Arial, sans-serif;
}

body {
    background-color: #d1d7db;
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
}

.app-container {
    display: flex;
    width: 100%;
    max-width: 1600px;
    height: 100vh;
    background-color: var(--sidebar-bg);
    box-shadow: 0 1px 1px 0 rgba(0,0,0,.06), 0 2px 5px 0 rgba(0,0,0,.2);
}

@media (min-width: 1440px) {
    .app-container {
        height: 95vh;
        margin: 20px 0;
    }
}

/* Sidebar Styles */
.sidebar {
    width: 30%;
    min-width: 300px;
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
}

.sidebar-header, .chat-header {
    height: 60px;
    background-color: var(--header-bg);
    display: flex;
    align-items: center;
    padding: 10px 16px;
    border-bottom: 1px solid var(--border-color);
}

.avatar img {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
}

.sidebar-header h3 {
    margin-left: 15px;
    color: var(--text-primary);
    font-size: 16px;
    font-weight: 500;
}

.search-bar {
    padding: 8px 12px;
    background-color: var(--sidebar-bg);
    border-bottom: 1px solid var(--border-color);
}

.search-bar input {
    width: 100%;
    padding: 8px 12px 8px 32px;
    background-color: var(--search-bg);
    border: none;
    border-radius: 8px;
    font-size: 14px;
    outline: none;
}

.chat-list {
    flex: 1;
    overflow-y: auto;
    background-color: var(--sidebar-bg);
}

.chat-item {
    display: flex;
    align-items: center;
    padding: 0 12px;
    height: 72px;
    cursor: pointer;
    border-bottom: 1px solid var(--header-bg);
}

.chat-item:hover {
    background-color: var(--chat-hover);
}

.chat-item.active {
    background-color: var(--chat-active);
}

.chat-item-info {
    flex: 1;
    margin-left: 15px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    border-bottom: 1px solid var(--header-bg);
    height: 100%;
}

.chat-item-info-top {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 2px;
}

.chat-name {
    font-size: 17px;
    color: var(--text-primary);
    font-weight: 400;
}

.chat-time {
    font-size: 12px;
    color: var(--timestamp-color);
}

/* Chat Area Styles */
.chat-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    background-color: var(--bg-color);
    position: relative;
    background-image: url('https://user-images.githubusercontent.com/15075759/28719144-86dc0f70-73b1-11e7-911d-60d70fcded21.png');
    background-repeat: repeat;
    background-size: 400px;
    opacity: 0.95;
}

.no-chat-selected {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    height: 100%;
    background-color: #f0f2f5;
    text-align: center;
    padding: 20px;
}

.no-chat-selected h2 {
    color: #41525d;
    font-weight: 300;
    font-size: 32px;
    margin-bottom: 15px;
}

.no-chat-selected p {
    color: var(--text-secondary);
    font-size: 14px;
}

.encryption-notice {
    margin-top: 30px;
    display: flex;
    align-items: center;
    gap: 5px;
}

.chat-main {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.chat-info h3 {
    margin-left: 15px;
    color: var(--text-primary);
    font-weight: 500;
    font-size: 16px;
}

.messages-container {
    flex: 1;
    overflow-y: auto;
    padding: 20px 60px;
    display: flex;
    flex-direction: column;
}

.message-wrapper {
    display: flex;
    margin-bottom: 12px;
    width: 100%;
    max-width: 100%;
}

.message-wrapper.sent {
    justify-content: flex-end;
}

.message-wrapper.received {
    justify-content: flex-start;
}

.message {
    max-width: 65%;
    padding: 6px 7px 8px 9px;
    border-radius: 7.5px;
    position: relative;
    font-size: 14.2px;
    line-height: 19px;
    color: var(--text-primary);
    box-shadow: 0 1px .5px rgba(11,20,26,.13);
}

.message.sent {
    background-color: var(--sent-msg-bg);
    border-top-right-radius: 0;
}

.message.received {
    background-color: var(--received-msg-bg);
    border-top-left-radius: 0;
}

.sender-name {
    color: #027eb5;
    font-size: 12.8px;
    font-weight: 500;
    margin-bottom: 2px;
}

.message-text {
    word-wrap: break-word;
    overflow-wrap: anywhere;
    word-break: break-word;
    white-space: pre-wrap;
    max-width: 100%;
}

.message-meta {
    float: right;
    margin: 10px 0 -5px 10px;
    color: var(--timestamp-color);
    font-size: 11px;
}

/* Tail shapes for bubbles */
.message.sent::before {
    content: "";
    position: absolute;
    top: 0;
    right: -8px;
    width: 0;
    height: 0;
    border-top: 0px solid transparent;
    border-left: 8px solid var(--sent-msg-bg);
    border-bottom: 8px solid transparent;
}

.message.received::before {
    content: "";
    position: absolute;
    top: 0;
    left: -8px;
    width: 0;
    height: 0;
    border-top: 0px solid transparent;
    border-right: 8px solid var(--received-msg-bg);
    border-bottom: 8px solid transparent;
}

/* Media Styles */
.message-media {
    margin: -4px -5px 5px -7px;
    border-radius: 6px;
    overflow: hidden;
    max-width: 300px;
}

.message-media img {
    width: 100%;
    height: auto;
    display: block;
    cursor: pointer;
    transition: opacity 0.2s;
}

.message-media img:hover {
    opacity: 0.9;
}

.message-media video {
    width: 100%;
    max-height: 400px;
    display: block;
}

.message-media audio {
    width: 100%;
    min-width: 250px;
}

.message-caption {
    font-size: 14.2px;
    margin-bottom: 5px;
    word-wrap: break-word;
}

.file-attachment {
    display: block;
    padding: 10px;
    background: rgba(0,0,0,0.05);
    text-decoration: none;
    color: var(--whatsapp-teal);
    border-radius: 4px;
    font-size: 13px;
}

.loading {
    padding: 20px;
    text-align: center;
    color: var(--text-secondary);
}
