/* Global Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Roboto', sans-serif;
}

:root {
    --primary-color: #00a884;
    --secondary-color: #d9fdd3;
    --light-bg: #f0f2f5;
    --dark-bg: #111b21;
    --chat-bg: #efeae2;
    --outgoing-msg-bg: #d9fdd3;
    --incoming-msg-bg: #ffffff;
    --text-primary: #111b21;
    --text-secondary: #667781;
    --border-color: #e9edef;
    --icon-color: #54656f;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

body {
    background-color: var(--light-bg);
    color: var(--text-primary);
    height: 100vh;
    overflow: hidden;
}

/* App Container */
.app-container {
    display: flex;
    height: 100vh;
    width: 100%;
    overflow: hidden;
}

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

.sidebar-header {
    padding: 10px;
    background-color: #f0f2f5;
}

.user-profile {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
}

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

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

.user-actions i {
    color: var(--icon-color);
    font-size: 18px;
    cursor: pointer;
}

.search-container {
    padding: 6px 0;
}

.search-box {
    display: flex;
    align-items: center;
    background-color: #ffffff;
    border-radius: 8px;
    padding: 8px 12px;
    box-shadow: var(--shadow);
}

.search-box i {
    color: var(--icon-color);
    margin-right: 10px;
}

.search-box input {
    border: none;
    outline: none;
    width: 100%;
    font-size: 14px;
}

.filter-options {
    padding: 8px 0;
}

.filter-options select {
    width: 100%;
    padding: 8px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    background-color: #ffffff;
    color: var(--text-primary);
    font-size: 14px;
    outline: none;
}

.contacts-list {
    flex: 1;
    overflow-y: auto;
}

.contact-item {
    display: flex;
    padding: 12px 15px;
    border-bottom: 1px solid var(--border-color);
    cursor: pointer;
    transition: background-color 0.2s;
}

.contact-item:hover {
    background-color: #f5f6f6;
}

.contact-item.active {
    background-color: #f0f2f5;
}

.contact-image {
    position: relative;
    margin-right: 15px;
}

.contact-image img {
    width: 49px;
    height: 49px;
    border-radius: 50%;
    object-fit: cover;
}

.status-indicator {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    border: 2px solid #ffffff;
}

.status-online {
    background-color: var(--primary-color);
}

.status-offline {
    background-color: #bdbdbd;
}

.contact-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.contact-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 5px;
}

.contact-name {
    font-weight: 500;
    font-size: 16px;
}

.contact-time {
    font-size: 12px;
    color: var(--text-secondary);
}

.last-message {
    font-size: 13px;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 200px;
}

/* Main Chat Area Styles */
.main-chat {
    flex: 1;
    display: flex;
    flex-direction: column;
    background-color: var(--chat-bg);
    background-image: url('/img/bg-chat-tile-light_a4be8c74.png');
    background-repeat: repeat;
    position: relative;
}

.empty-chat {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    height: 100%;
    background-color: #f0f2f5;
}

.empty-chat-content {
    text-align: center;
    padding: 20px;
}

.empty-chat-icon {
    font-size: 80px;
    color: var(--primary-color);
    margin-bottom: 20px;
}

.empty-chat h2 {
    font-size: 32px;
    margin-bottom: 10px;
    color: var(--text-primary);
}

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

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

.chat-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 16px;
    background-color: #f0f2f5;
    border-bottom: 1px solid var(--border-color);
}

.chat-header .contact-info {
    display: flex;
    flex-direction: row;
    align-items: center;
}

.chat-header .contact-image {
    margin-right: 15px;
}

.chat-header .contact-image img {
    width: 40px;
    height: 40px;
}

.contact-details h3 {
    font-size: 16px;
    font-weight: 500;
}

.contact-details p {
    font-size: 13px;
    color: var(--text-secondary);
}

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

.chat-actions i {
    color: var(--icon-color);
    font-size: 18px;
    cursor: pointer;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
}

.message-date-separator {
    text-align: center;
    margin: 15px 0;
    position: relative;
}

.message-date-separator span {
    background-color: #e1f3fb;
    padding: 5px 12px;
    border-radius: 5px;
    font-size: 12px;
    color: var(--text-secondary);
    position: relative;
    z-index: 1;
}

.message {
    display: flex;
    margin-bottom: 8px;
    max-width: 65%;
}

.message.outgoing {
    margin-left: auto;
    justify-content: flex-end;
}

.message.incoming {
    margin-right: auto;
    justify-content: flex-start;
}

.message-content {
    padding: 8px 12px;
    border-radius: 7.5px;
    position: relative;
}

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

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

.message-text {
    font-size: 14px;
    line-height: 19px;
    word-wrap: break-word;
}

.message-sender {
    font-size: 13px;
    font-weight: 500;
    color: var(--primary-color);
    margin-bottom: 2px;
}

.message-time {
    font-size: 11px;
    color: var(--text-secondary);
    margin-left: 8px;
    float: right;
    margin-top: 2px;
}

.message-status {
    margin-left: 4px;
    font-size: 14px;
}

.message-status.sent {
    color: #a5a5a5;
}

.message-status.delivered {
    color: #a5a5a5;
}

.message-status.read {
    color: #53bdeb;
}

.media-message {
    max-width: 300px;
}

.media-message img {
    width: 100%;
    border-radius: 5px;
    cursor: pointer;
}

.video-message {
    position: relative;
    max-width: 300px;
}

.video-message video {
    width: 100%;
    border-radius: 5px;
    cursor: pointer;
}

.video-play-button {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background-color: rgba(0, 0, 0, 0.5);
    color: white;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
}

.audio-message {
    display: flex;
    align-items: center;
    min-width: 200px;
}

.audio-waveform {
    flex: 1;
    height: 30px;
    background-color: rgba(0, 0, 0, 0.05);
    border-radius: 15px;
    margin: 0 10px;
    position: relative;
    overflow: hidden;
}

.waveform-bars {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 100%;
    padding: 0 5px;
}

.waveform-bar {
    width: 2px;
    background-color: var(--primary-color);
    margin: 0 1px;
}

.audio-controls {
    display: flex;
    align-items: center;
}

.audio-play-button {
    cursor: pointer;
    color: var(--primary-color);
    font-size: 18px;
}

.audio-duration {
    font-size: 12px;
    color: var(--text-secondary);
    margin-left: 5px;
}

.media-preview-zone {
    background-color: #f0f2f5;
    padding: 10px;
    border-top: 1px solid var(--border-color);
}

.preview-content {
    display: flex;
    gap: 10px;
    overflow-x: auto;
    padding-bottom: 5px;
}

.media-preview {
    position: relative;
    width: 100px;
    height: 100px;
    border-radius: 5px;
    overflow: hidden;
}

.media-preview img, 
.media-preview video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.close-preview {
    position: absolute;
    top: 10px;
    right: 10px;
    background-color: rgba(0, 0, 0, 0.5);
    color: white;
    border: none;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
}

.chat-input-area {
    display: flex;
    align-items: center;
    padding: 10px;
    background-color: #f0f2f5;
    border-top: 1px solid var(--border-color);
}

.input-actions {
    display: flex;
    align-items: center;
}

.input-actions.left {
    margin-right: 10px;
}

.input-actions.right {
    margin-left: 10px;
}

.emoji-button,
.attachment-button,
.template-button,
.voice-record-button,
.send-button {
    width: 40px;
    height: 40px;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    color: var(--icon-color);
    font-size: 20px;
    border-radius: 50%;
    transition: background-color 0.2s;
}

.emoji-button:hover,
.attachment-button:hover,
.template-button:hover,
.voice-record-button:hover,
.send-button:hover {
    background-color: rgba(0, 0, 0, 0.05);
}

.attachment-button {
    position: relative;
}

.attachment-options {
    position: absolute;
    bottom: 50px;
    left: 0;
    background-color: white;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    padding: 10px;
    display: none;
    flex-direction: column;
    gap: 10px;
    z-index: 10;
}

.attachment-option {
    display: flex;
    align-items: center;
    padding: 8px 12px;
    border-radius: 5px;
    cursor: pointer;
    transition: background-color 0.2s;
}

.attachment-option:hover {
    background-color: #f0f2f5;
}

.attachment-option i {
    margin-right: 10px;
    font-size: 18px;
}

.attachment-option span {
    font-size: 14px;
}

.message-input {
    flex: 1;
}

.message-input input {
    width: 100%;
    padding: 9px 12px;
    border: none;
    border-radius: 8px;
    outline: none;
    font-size: 15px;
}

.send-button {
    color: var(--primary-color);
}

/* Templates Panel */
.templates-panel {
    position: absolute;
    bottom: 70px;
    right: 20px;
    width: 300px;
    background-color: white;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    display: none;
    z-index: 10;
}

.templates-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px;
    border-bottom: 1px solid var(--border-color);
}

.templates-header h3 {
    font-size: 16px;
    font-weight: 500;
}

.templates-header button {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--icon-color);
    font-size: 18px;
}

.templates-list {
    max-height: 300px;
    overflow-y: auto;
    padding: 10px;
}

.template-item {
    padding: 10px;
    border-radius: 5px;
    cursor: pointer;
    transition: background-color 0.2s;
}

.template-item:hover {
    background-color: #f0f2f5;
}

.template-title {
    font-weight: 500;
    margin-bottom: 5px;
}

.template-content {
    font-size: 14px;
    color: var(--text-secondary);
}

/* Voice Recording UI */
.voice-recording-ui {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background-color: #f0f2f5;
    padding: 15px;
    display: none;
    align-items: center;
    z-index: 5;
}

.recording-waveform {
    flex: 1;
    height: 40px;
    background-color: white;
    border-radius: 20px;
    margin: 0 15px;
    position: relative;
    overflow: hidden;
}

.waveform-animation {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
}

.waveform-bar {
    width: 3px;
    background-color: var(--primary-color);
    margin: 0 2px;
    border-radius: 3px;
}

.recording-timer {
    font-size: 14px;
    color: var(--text-primary);
    margin-right: 15px;
}

.recording-actions {
    display: flex;
    gap: 15px;
}

.recording-actions button {
    background: none;
    border: none;
    cursor: pointer;
    width: 40px;
    height: 40px;
    display: flex;
    justify-content: center;
    align-items: center;
    border-radius: 50%;
    transition: background-color 0.2s;
}

.recording-actions button:hover {
    background-color: rgba(0, 0, 0, 0.05);
}

#cancel-recording {
    color: #f15c6d;
}

#send-recording {
    color: var(--primary-color);
}

/* Date Picker Modal */
.date-picker-modal {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background-color: white;
    border-radius: 10px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    width: 300px;
    display: none;
    z-index: 20;
}

.date-picker-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px;
    border-bottom: 1px solid var(--border-color);
}

.date-picker-header h3 {
    font-size: 16px;
    font-weight: 500;
}

.date-picker-header button {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--icon-color);
    font-size: 18px;
}

.date-picker-calendar {
    padding: 15px;
}

.date-picker-actions {
    display: flex;
    justify-content: flex-end;
    padding: 15px;
    border-top: 1px solid var(--border-color);
    gap: 10px;
}

.date-picker-actions button {
    padding: 8px 15px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 14px;
}

#date-picker-cancel {
    background-color: #f0f2f5;
    color: var(--text-primary);
}

#date-picker-apply {
    background-color: var(--primary-color);
    color: white;
}

/* Overlay */
.overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.5);
    display: none;
    z-index: 15;
}

/* Responsive Design */
@media (max-width: 768px) {
    .sidebar {
        position: absolute;
        left: 0;
        top: 0;
        bottom: 0;
        z-index: 10;
        width: 80%;
        max-width: none;
        transform: translateX(-100%);
        transition: transform 0.3s ease;
    }
    
    .sidebar.open {
        transform: translateX(0);
    }
    
    .main-chat {
        width: 100%;
    }
    
    .chat-header .contact-info {
        position: relative;
    }
    
    .chat-header .contact-info:before {
        content: '\f0c9';
        font-family: 'Font Awesome 5 Free';
        font-weight: 900;
        margin-right: 15px;
        cursor: pointer;
        font-size: 18px;
        color: var(--icon-color);
    }
    
    .chat-actions {
        gap: 15px;
    }
    
    .chat-actions i:not(.fa-ellipsis-v) {
        display: none;
    }
    
    .message {
        max-width: 80%;
    }
    
}
