:root {
    --font-primary: "Space Grotesk", sans-serif;
    --primary-color: #0084ff;
    --primary-hover: #006adc;
    --background: #f0f2f5;
    --card-background: rgba(255, 255, 255, 0.7);
    --text-primary: #050505;
    --text-secondary: #65676b;
    --border-color: #dcdee2;
    --success-color: #00c851;
    --error-color: #ff3b30;
    --shadow-color: rgba(0, 0, 0, 0.08);
    --message-sent: #0084ff;
    --message-received: #e4e6eb;
    --typing-indicator: #8a8d91;
    --link-color: #0866ff;
    --active-indicator: #31a24c;
}

.msg-widget * {
    box-sizing: border-box;
}

.msg-widget {
    font-family: var(--font-primary) !important;
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 380px;
    height: 600px;
    background: var(--card-background);
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
    backdrop-filter: blur(20px);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    box-shadow: 0 8px 30px var(--shadow-color);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: all 0.3s ease;
    opacity: 0;
    transform: translateY(100px);
    z-index: 1000;
    display: none;
    line-height: 1.6;
    letter-spacing: 0.5px;
}

.msg-widget.active {
    opacity: 1;
    transform: translateY(0);
    display: flex;
}

.msg-widget .widget-header {
    padding: 16px 20px;
    background: var(--primary-color);
    color: white;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.msg-widget .header-left {
    display: flex;
    align-items: center;
}

.msg-widget .header-actions {
    display: flex;
    gap: 12px;
    align-items: center;
}

.msg-widget .action-btn, .msg-widget .widget-close {
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    font-size: 18px;
    padding: 8px;
    border-radius: 8px;
    transition: background 0.2s;
}

.msg-widget .action-btn:hover, .msg-widget .widget-close:hover {
    background: var(--primary-hover);
}

.msg-widget .widget-title {
    font-weight: 600;
    margin: 0;
    font-size: 18px;
}

.msg-widget .widget-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: var(--background);
}

.msg-widget .search-box {
    padding: 16px;
    background: var(--card-background);
    border-bottom: 1px solid var(--border-color);
    position: relative;
}

.msg-widget .search-icon {
    position: absolute;
    left: 28px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-secondary);
}

.msg-widget .search-input {
    width: 100%;
    padding: 12px 12px 12px 40px;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    font-size: 15px;
    background: var(--background);
    color: var(--text-primary);
    transition: all 0.2s;
}

.msg-widget .search-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1);
}

.msg-widget .conversations {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
}

.msg-widget .conversation {
    padding: 16px;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s;
    margin-bottom: 8px;
    background: var(--card-background);
    box-shadow: 0 2px 8px var(--shadow-color);
}

.msg-widget .conversation:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px var(--shadow-color);
}

.msg-widget .conversation.active {
    background: #EBF5FB;
    border-left: 4px solid var(--primary-color);
}

.msg-widget .profile-image {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    margin-right: 12px;
    object-fit: cover;
}

.msg-widget .conversation {
    display: flex;
    align-items: center;
}

.msg-widget .conversation .conversation-items {
    display: flex;
    flex-direction: column;
    max-height: 50px;
}

.msg-widget .conversation .conversation-items .conversation-fullName {
    font-size: 16px;
    font-weight: 500;
    margin: 0;
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 200px;
}

.msg-widget .conversation .conversation-items .conversation-username {
    font-size: 14px;
    margin: 0;
    color: var(--text-secondary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 200px;
}

.msg-widget .conversation small {
    font-size: 12px;
    color: var(--text-secondary);
    margin-left: auto;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 50px;
}

.msg-widget .user-list {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
    display: none;
}

.msg-widget .user-item {
    padding: 16px;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s;
    margin-bottom: 8px;
    background: var(--card-background);
    box-shadow: 0 2px 8px var(--shadow-color);
    display: flex;
    align-items: center;
}

.msg-widget .user-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px var(--shadow-color);
}

.msg-widget .user-item img {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    margin-right: 12px;
    object-fit: cover;
}

.msg-widget .messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: none;
    background: var(--background);
}

.msg-widget .message {
    margin-bottom: 16px;
    max-width: 80%;
    animation: messageIn 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.msg-widget .message img {
    max-width: 100%;
    border-radius: 8px;
}

.msg-widget .message-content img {
    width: 100%;
    height: auto;
    border-radius: 8px;
}

@keyframes messageIn {
    0% {
        opacity: 0;
        transform: translateY(20px) scale(0.95);
    }
    60% {
        opacity: 1;
        transform: translateY(-5px) scale(1);
    }
    100% {
        transform: translateY(0) scale(1);
    }
}

.msg-widget .message.sent {
    margin-left: auto;
}

.msg-widget .message-content {
    padding: 12px 16px;
    border-radius: 16px;
    font-size: 15px;
    line-height: 1.4;
    box-shadow: 0 2px 8px var(--shadow-color);
    overflow-wrap: break-word;
}

.msg-widget .message-time {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 4px;
    text-align: right;
}

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

.msg-widget .sent .message-content {
    background: var(--primary-color);
    color: white;
    border-bottom-right-radius: 4px;
}

.msg-widget .sent .message-content a {
    text-decoration: underline;
    color: white;
}

.msg-widget .received .message-content a {
    text-decoration: underline;
    color: var(--link-color);
}

.msg-widget .received .message-content {
    background: var(--card-background);
    color: var(--text-primary);
    border-bottom-left-radius: 4px;
}

.msg-widget .message-input {
    padding: 16px;
    background: var(--card-background);
    border-top: 1px solid var(--border-color);
    display: none;
}

.msg-widget .message-form {
    display: flex;
    gap: 12px;
    align-items: flex-end;
}

.msg-widget .message-textbox {
    flex: 1;
    padding: 12px;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    font-size: 15px;
    resize: none;
    max-height: 120px;
    background: var(--background);
    color: var(--text-primary);
    transition: all 0.2s;
}

.msg-widget .message-textbox:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1);
}

.msg-widget .attachment-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 20px;
    padding: 8px;
    border-radius: 8px;
    transition: all 0.2s;
}

.msg-widget .attachment-btn:hover {
    color: var(--primary-color);
    background: var(--background);
}

.msg-widget .send-button {
    padding: 12px;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    font-size: 16px;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.msg-widget .send-button:hover {
    background: var(--primary-hover);
    transform: scale(1.05);
}

.widget-trigger {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 60px;
    height: 60px;
    border-radius: 30px;
    background: var(--primary-color);
    color: white;
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(52, 152, 219, 0.3);
    transition: all 0.3s ease;
    z-index: 1000;
    font-size: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
}

 .widget-trigger:hover {
    transform: scale(1.1);
    background: var(--primary-hover);
}

.msg-widget .back-button {
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    font-size: 18px;
    padding: 8px;
    margin-right: 8px;
    border-radius: 8px;
    transition: background 0.2s;
    display: none;
}

.msg-widget .back-button:hover {
    background: var(--primary-hover);
}

.msg-widget .user-info {
    display: none;
    align-items: center;
}

.msg-widget .user-info img {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    margin-right: 12px;
}

.msg-widget .user-info .user-name {
    color: white;
    font-weight: 500;
    margin: 0;
}

.msg-widget .loading {
    text-align: center;
    padding: 20px;
    color: var(--text-secondary);
    font-size: 14px;
}

.msg-widget .unseen-indicator {
    color: var(--primary-color);
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 12px;
}

.msg-widget .unseen-indicator::before {
    content: '';
    width: 7px;
    height: 7px;
    background: var(--primary-color);
    border-radius: 50%;
    display: inline-block;
    flex-shrink: 0;
}

.msg-widget .loading {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    font-size: 16px;
    color: var(--text-secondary);
    background: var(--background);
    animation: fadeIn 0.5s ease-in-out;
}

.msg-widget #context-menu {
    position: absolute;
    z-index: 1000;
    width: 200px;
    background: #ffffff;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    display: none;
    overflow: hidden;
    animation: fadeIn 0.2s ease-out;
}

.msg-widget #imageModal {
    animation: fadeIn 0.3s;
}

.msg-widget #imageModal img {
    transition: transform 0.3s;
}

.msg-widget #imageModal span:hover {
    color: #ccc;
}

@keyframes fadeIn {
    from { opacity: 0; transform: scale(0.95); }
    to { opacity: 1; transform: scale(1); }
}

.msg-widget #context-menu ul {
    list-style: none;
    margin: 0;
    padding: 0;
}

.msg-widget #context-menu li {
    padding: 12px 16px;
    cursor: pointer;
    transition: background-color 0.2s;
}

.msg-widget #context-menu li:hover {
    background-color: #f0f0f0;
}

.msg-widget .toast-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.msg-widget .toast {
    background-color: #ffffff;
    color: #333333;
    padding: 16px 20px;
    border-radius: 10px;
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.2);
    display: flex;
    flex-direction: column;
    min-width: 300px;
    max-width: 350px;
    animation: slideIn 0.5s ease, fadeOut 0.5s ease 4.5s forwards;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

.msg-widget .toast.success {
    border-left: 5px solid #28a745;
}

.msg-widget .toast.error {
    border-left: 5px solid #dc3545;
}

.msg-widget .toast.info {
    border-left: 5px solid #17a2b8;
}

.msg-widget .toast .message {
    font-size: 16px;
    margin-bottom: 10px;
}

.msg-widget .toast .progress-bar-container {
    width: 100%;
    background-color: #e0e0e0;
    border-radius: 5px;
    overflow: hidden;
}

.msg-widget .toast .progress-bar {
    height: 6px;
    background: linear-gradient(90deg, #4caf50, #81c784);
    width: 0%;
    transition: width 0.4s ease;
}

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

@keyframes fadeOut {
    to {
        opacity: 0;
        transform: translateX(100%);
    }
}

.msg-widget ::-webkit-scrollbar {
    width: 6px;
}

.msg-widget ::-webkit-scrollbar-track {
    background: var(--background);
}

.msg-widget ::-webkit-scrollbar-thumb {
    background: #BDC3C7;
    border-radius: 3px;
}

.msg-widget ::-webkit-scrollbar-thumb:hover {
    background: #95A5A6;
}

.msg-widget .call-link {
    display: inline-block;
    padding: 10px 20px;
    background-color: var(--active-indicator);
    color: var(--background);
    border-radius: 5px;
    cursor: pointer;
    text-decoration: none;
    margin: 5px 0;
    border: 1px solid var(--active-indicator);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.msg-widget  .call-link:hover {
    background-color: #45a049;
}