/* Global Styles */
:root {
    --primary-color: #00a884;
    --secondary-color: #008069;
    --bg-color: #e9edef;
    --chat-bg: #efeae2;
    --white: #ffffff;
    --text-primary: #111b21;
    --text-secondary: #667781;
    --incoming-msg-bg: #ffffff;
    --outgoing-msg-bg: #d9fdd3;
    --border-color: #e9edef;
    --input-bg: #f0f2f5;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Segoe UI', 'Helvetica Neue', Helvetica, Arial, sans-serif;
}

body {
    background-color: var(--bg-color);
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
}

.app-container {
    width: 100%;
    max-width: 1400px;
    height: 100%;
    background-color: var(--white);
    display: flex;
    overflow: hidden;
    position: relative;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

@media (min-width: 1000px) {
    body {
        padding: 20px;
    }

    .app-container {
        height: 95vh;
        border-radius: 0;
    }
}

/* Sidebar (User List) */
.sidebar {
    width: 30%;
    min-width: 300px;
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    background: var(--white);
}

.sidebar-header {
    padding: 10px 16px;
    background-color: var(--input-bg);
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 60px;
}

.sidebar-header .user-profile {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 600;
}

.avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    background-color: #ccc;
}

.search-bar {
    padding: 10px;
    border-bottom: 1px solid var(--border-color);
}

.search-bar input {
    width: 100%;
    padding: 8px 12px;
    border-radius: 8px;
    border: none;
    background-color: var(--input-bg);
    outline: none;
}

.chat-list {
    flex: 1;
    overflow-y: auto;
}

.chat-item {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    cursor: pointer;
    border-bottom: 1px solid var(--border-color);
    transition: background 0.2s;
}

.chat-item:hover {
    background-color: var(--input-bg);
}

.chat-item.active {
    background-color: var(--input-bg);
}

.chat-info {
    margin-left: 15px;
    flex: 1;
}

.chat-name {
    font-weight: 500;
    color: var(--text-primary);
    display: flex;
    justify-content: space-between;
}

.chat-last-msg {
    font-size: 0.85rem;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 200px;
}

.chat-time {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

/* Chat Area */
.chat-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    background-color: var(--chat-bg);
    background-image: url('https://user-images.githubusercontent.com/15075759/28719144-86dc0f70-73b1-11e7-911d-60d70fcded21.png');
    /* Subtle pattern */
    background-repeat: repeat;
    position: relative;
}

.chat-header {
    background-color: var(--input-bg);
    padding: 10px 16px;
    height: 60px;
    display: flex;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
}

.chat-header-info {
    margin-left: 15px;
}

.chat-header-name {
    font-weight: 600;
}

.chat-header-status {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.messages-container {
    flex: 1;
    padding: 20px 50px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.message {
    max-width: 60%;
    padding: 8px 12px;
    border-radius: 8px;
    position: relative;
    font-size: 0.9rem;
    line-height: 1.4;
    box-shadow: 0 1px 0.5px rgba(0, 0, 0, 0.13);
}

.message.incoming {
    align-self: flex-start;
    background-color: var(--incoming-msg-bg);
    border-top-left-radius: 0;
}

.message.outgoing {
    align-self: flex-end;
    background-color: var(--outgoing-msg-bg);
    border-top-right-radius: 0;
}

.message-time {
    font-size: 0.7rem;
    color: var(--text-secondary);
    float: right;
    margin-left: 8px;
    margin-top: 4px;
}

/* Attachment Styles */
.msg-image {
    max-width: 100%;
    max-height: 300px;
    border-radius: 8px;
    margin-bottom: 5px;
    display: block;
    cursor: pointer;
}

.msg-video {
    max-width: 100%;
    max-height: 300px;
    border-radius: 8px;
    margin-bottom: 5px;
}

.msg-file {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px;
    background: rgba(0, 0, 0, 0.05);
    border-radius: 8px;
    margin-bottom: 5px;
}

.msg-file ion-icon {
    font-size: 1.5rem;
    color: var(--primary-color);
}

.msg-file a {
    text-decoration: none;
    color: var(--text-primary);
    font-weight: 500;
}

.chat-input-area {
    padding: 10px 16px;
    background-color: var(--input-bg);
    display: flex;
    align-items: center;
    gap: 10px;
}

.chat-input-area input {
    flex: 1;
    padding: 12px;
    border-radius: 8px;
    border: none;
    outline: none;
    font-size: 1rem;
}

.btn-send {
    background: transparent;
    border: none;
    cursor: pointer;
    color: var(--text-secondary);
    font-size: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-send:hover {
    color: var(--primary-color);
}

/* Login/Register Page */
.auth-container {
    width: 100%;
    max-width: 400px;
    background: white;
    padding: 40px;
    border-radius: 10px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    text-align: center;
}

.auth-title {
    margin-bottom: 20px;
    color: var(--primary-color);
    font-size: 2rem;
}

.form-group {
    margin-bottom: 15px;
    text-align: left;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
    color: var(--text-secondary);
}

.form-group input {
    width: 100%;
    padding: 10px;
    border: 1px solid #ccc;
    border-radius: 5px;
    outline: none;
}

.form-group input:focus {
    border-color: var(--primary-color);
}

.btn-primary {
    width: 100%;
    padding: 12px;
    background-color: var(--primary-color);
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 600;
}

.btn-primary:hover {
    background-color: var(--secondary-color);
}

.auth-link {
    margin-top: 15px;
    font-size: 0.9rem;
}

.auth-link a {
    color: var(--primary-color);
    text-decoration: none;
}

/* Attachment Preview Styles */
.attachment-preview {
    background-color: #f0f2f5;
    border-top: 1px solid var(--border-color);
    padding: 10px 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    max-height: 200px;
    position: relative;
    z-index: 10;
}

.preview-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    background: white;
    padding: 10px;
    border-radius: 8px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
    max-width: 90%;
}

#preview-media img,
#preview-media video {
    max-height: 120px;
    max-width: 100%;
    border-radius: 6px;
    object-fit: contain;
}

#preview-media .file-icon {
    font-size: 3rem;
    color: var(--primary-color);
}

.preview-info {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 5px;
    width: 100%;
    justify-content: space-between;
}

#preview-filename {
    font-size: 0.85rem;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 200px;
}

.btn-clear {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.5rem;
    color: #ff5f5f;
    display: flex;
    align-items: center;
}

.btn-clear:hover {
    color: red;
}

.btn-send.recording {
    color: red;
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.2);
    }

    100% {
        transform: scale(1);
    }
}

.msg-audio {
    width: 250px;
    margin-bottom: 5px;
}