* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    background: #0c1317;
    height: 100vh;
    overflow: hidden;
}

.chat-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    max-width: 450px;
    margin: 0 auto;
    background: #0b141a;
    position: relative;
}

/* Top Bar */
.top-bar {
    background: #202c33;
    padding: 10px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: fixed;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    max-width: 450px;
    z-index: 1000;
    border-bottom: 1px solid #2a3942;
}

.contact-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

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

.contact-details {
    display: flex;
    flex-direction: column;
}

.contact-name {
    color: #e9edef;
    font-size: 16px;
    font-weight: 400;
    margin-bottom: 2px;
}

.last-seen {
    color: #8696a0;
    font-size: 13px;
}

.top-bar-actions {
    display: flex;
    gap: 20px;
}

.action-btn {
    background: none;
    border: none;
    color: #8696a0;
    font-size: 20px;
    cursor: pointer;
    padding: 4px;
    border-radius: 50%;
    transition: background-color 0.2s;
}

.action-btn:hover {
    background: rgba(134, 150, 160, 0.1);
}

/* Chat Area */
.chat-area {
    flex: 1;
    padding: 80px 16px 70px;
    overflow-y: auto;
    background-image: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="60" height="60" viewBox="0 0 60 60"><rect width="60" height="60" fill="%23111b21"/><circle cx="15" cy="15" r="1" fill="%231f2937" opacity="0.3"/><circle cx="45" cy="15" r="1" fill="%231f2937" opacity="0.3"/><circle cx="30" cy="30" r="1" fill="%231f2937" opacity="0.3"/><circle cx="15" cy="45" r="1" fill="%231f2937" opacity="0.3"/><circle cx="45" cy="45" r="1" fill="%231f2937" opacity="0.3"/></svg>');
    background-size: 60px 60px;
}

.chat-area::-webkit-scrollbar {
    width: 6px;
}

.chat-area::-webkit-scrollbar-track {
    background: transparent;
}

.chat-area::-webkit-scrollbar-thumb {
    background: #374151;
    border-radius: 3px;
}

.message {
    margin-bottom: 12px;
    display: flex;
}

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

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

.message-content {
    max-width: 75%;
    padding: 8px 12px;
    border-radius: 8px;
    position: relative;
    word-wrap: break-word;
}

.message.sent .message-content {
    background: #005c4b;
    color: #e9edef;
    border-bottom-right-radius: 3px;
}

.message.received .message-content {
    background: #202c33;
    color: #e9edef;
    border-bottom-left-radius: 3px;
}

.message-content p {
    margin: 0;
    line-height: 1.4;
    font-size: 14px;
}

/* Markdown content styling */
.markdown-content {
    line-height: 1.4;
    font-size: 14px;
}

.markdown-content h1,
.markdown-content h2,
.markdown-content h3,
.markdown-content h4,
.markdown-content h5,
.markdown-content h6 {
    color: #e9edef;
    margin: 8px 0 4px 0;
    font-weight: 600;
}

.markdown-content h1 { font-size: 18px; }
.markdown-content h2 { font-size: 16px; }
.markdown-content h3 { font-size: 15px; }
.markdown-content h4,
.markdown-content h5,
.markdown-content h6 { font-size: 14px; }

.markdown-content p {
    margin: 4px 0;
    color: #e9edef;
}

.markdown-content strong {
    color: #00d4aa;
    font-weight: 600;
}

.markdown-content em {
    color: #8696a0;
    font-style: italic;
}

.markdown-content blockquote {
    border-left: 3px solid #00a884;
    padding-left: 12px;
    margin: 8px 0;
    background: rgba(0, 168, 132, 0.1);
    border-radius: 4px;
    padding: 8px 12px;
}

.markdown-content blockquote p {
    margin: 2px 0;
    color: #e9edef;
    font-style: italic;
}

.markdown-content ul,
.markdown-content ol {
    margin: 8px 0;
    padding-left: 20px;
}

.markdown-content li {
    margin: 2px 0;
    color: #e9edef;
}

.markdown-content code {
    background: rgba(134, 150, 160, 0.2);
    padding: 2px 4px;
    border-radius: 3px;
    font-family: 'Courier New', monospace;
    font-size: 13px;
    color: #00d4aa;
}

.markdown-content pre {
    background: rgba(134, 150, 160, 0.1);
    padding: 12px;
    border-radius: 6px;
    overflow-x: auto;
    margin: 8px 0;
}

.markdown-content pre code {
    background: none;
    padding: 0;
    color: #e9edef;
}

.markdown-content hr {
    border: none;
    border-top: 1px solid #374151;
    margin: 12px 0;
}

.markdown-content a {
    color: #00a884;
    text-decoration: none;
}

.markdown-content a:hover {
    text-decoration: underline;
}

.message-time {
    font-size: 11px;
    color: #8696a0;
    display: block;
    text-align: right;
    margin-top: 4px;
}

.message.received .message-time {
    text-align: left;
}

/* Bottom Bar */
.bottom-bar {
    background: #202c33;
    padding: 8px 16px;
    display: flex;
    align-items: center;
    gap: 8px;
    position: fixed;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    max-width: 450px;
    z-index: 1000;
    border-top: 1px solid #2a3942;
}

.attachment-btn {
    background: none;
    border: none;
    color: #8696a0;
    font-size: 20px;
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    transition: background-color 0.2s;
}

.attachment-btn:hover {
    background: rgba(134, 150, 160, 0.1);
}

.input-container {
    flex: 1;
    background: #2a3942;
    border-radius: 20px;
    display: flex;
    align-items: center;
    padding: 0 16px;
    gap: 8px;
}

#message-input {
    flex: 1;
    background: none;
    border: none;
    color: #e9edef;
    font-size: 15px;
    padding: 12px 0;
    outline: none;
}

#message-input::placeholder {
    color: #8696a0;
}

.emoji-btn {
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    padding: 4px;
    border-radius: 50%;
    transition: background-color 0.2s;
}

.emoji-btn:hover {
    background: rgba(134, 150, 160, 0.1);
}

.send-btn {
    background: #00a884;
    border: none;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background-color 0.2s;
    color: white;
}

.send-btn:hover {
    background: #00916a;
}

.send-btn:active {
    background: #007c5a;
}

/* Responsive Design */
@media (max-width: 480px) {
    .chat-container {
        max-width: 100%;
    }
    
    .top-bar {
        max-width: 100%;
    }
    
    .bottom-bar {
        max-width: 100%;
    }
    
    .message-content {
        max-width: 85%;
    }
}

@media (max-width: 320px) {
    .contact-name {
        font-size: 15px;
    }
    
    .last-seen {
        font-size: 12px;
    }
    
    .message-content p {
        font-size: 13px;
    }
    
    .top-bar-actions {
        gap: 15px;
    }
}

/* Animation for new messages */
@keyframes slideInRight {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes slideInLeft {
    from {
        transform: translateX(-100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.message.sent.new-message {
    animation: slideInRight 0.3s ease-out;
}

.message.received.new-message {
    animation: slideInLeft 0.3s ease-out;
}
