/* Chat Component Styles */
.chat-container {
    position: fixed !important;
    bottom: 30px !important;
    /* Slightly higher */
    left: 30px !important;
    /* Slightly more to the right */
    z-index: 999999 !important;
    /* Higher than anything else */
    font-family: "Source Sans Pro", sans-serif;
    display: block !important;
}

/* Delete Button Styles */
.chat-delete-btn {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    background: #ff4444;
    color: white;
    border: none;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 10px;
    opacity: 0;
    transition: opacity 0.3s ease;
    z-index: 10;
}

.chat-user-item:hover .chat-delete-btn {
    opacity: 1;
}

.chat-delete-btn:hover {
    background: #cc0000;
}

@media (max-width: 640px) {
    .chat-label {
        display: none;
    }
}

/* Collapsed State */
.chat-collapsed {
    background: #ffffff;
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: 30px;
    padding: 10px 20px;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    display: inline-block;
}

.chat-collapsed:hover {
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.12);
    transform: translateY(-2px);
}

.chat-collapsed-content {
    display: flex;
    align-items: center;
    gap: 12px;
}

.chat-icon {
    font-size: 24px;
    color: #00c43a;
    display: flex;
    align-items: center;
}

.chat-label {
    font-size: 17px;
    font-weight: 600;
    color: #444;
}

.chat-badge {
    background: #00c43a;
    color: #ffffff;
    font-size: 11px;
    font-weight: 700;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    box-shadow: 0 2px 4px rgba(0, 196, 58, 0.3);
}

/* Expanded State */
.chat-expanded {
    background: #ffffff;
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: 16px;
    width: 340px;
    height: 570px;
    display: flex;
    flex-direction: column;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.15);
    overflow: hidden;
    position: absolute;
    bottom: 0px;
    left: 0px;
    animation: slideUp 0.4s cubic-bezier(0.165, 0.84, 0.44, 1);
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.chat-header {
    background: #00c43a;
    padding: 15px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.chat-header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.chat-header-center h3 {
    margin: 0;
    font-size: 18px;
    color: #ffffff;
    font-weight: 600;
}

.chat-header-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

.group-label {
    color: #ffffff;
    opacity: 0.9;
    font-size: 13px;
    font-weight: 500;
    margin-right: 5px;
}

/* Toggle Switch */
.switch {
    position: relative;
    display: inline-block;
    width: 38px;
    height: 20px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(255, 255, 255, 0.3);
    transition: .3s;
    border-radius: 34px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 14px;
    width: 14px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .3s;
    border-radius: 50%;
}

input:checked+.slider {
    background-color: #ffffff;
}

input:checked+.slider:before {
    transform: translateX(18px);
    background-color: #00c43a;
}

/* Search Bar */
.chat-search {
    padding: 12px 15px;
    background: #fdfdfd;
    border-bottom: 1px solid #f0f0f0;
}

.chat-search input {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #eee;
    border-radius: 8px;
    font-size: 13px;
    background: #fafafa;
    transition: all 0.3s ease;
}

/* User List */
.chat-user-list {
    flex: 1;
    overflow-y: auto;
    padding: 0;
}

.chat-user-item {
    display: flex;
    align-items: center;
    padding: 12px 18px;
    gap: 12px;
    cursor: pointer;
    border-bottom: 1px solid #f9f9f9;
    transition: all 0.2s ease;
    position: relative;
}

.chat-user-item:hover {
    background-color: #f5fcf5;
}

.chat-user-avatar {
    width: 44px;
    height: 44px;
    border-radius: 8px;
    position: relative;
    background: #eee;
    flex-shrink: 0;
}

.chat-unread-dot {
    position: absolute;
    top: -4px;
    left: -4px;
    width: 10px;
    height: 10px;
    background: #00c43a;
    border: 2px solid #ffffff;
    border-radius: 50%;
    z-index: 2;
}

.chat-user-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.chat-user-info {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    flex: 1;
}

.chat-user-name {
    font-size: 14px;
    font-weight: 600;
    color: #333;
    display: flex;
    align-items: center;
    gap: 5px;
}

.chat-user-handle {
    font-size: 12px;
    color: #00c43a;
    font-weight: 500;
}

.chat-user-item.selected {
    background-color: #f0fff0;
}

.chat-user-item.selected .chat-user-avatar {
    box-shadow: 0 0 0 2px #00c43a;
}

.chat-start-group-icon-btn {
    color: #ffffff;
    border: none;
    border-radius: 50%;
    width: 32px;
    height: 32px;
    display: none;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    position: relative;
    transition: all 0.2s ease;
    padding: 0;
}

.chat-start-group-icon-btn i {
    font-size: 16px;
    color: #fff;
}

.chat-start-group-icon-btn:hover {
    background: #00b033;
    transform: scale(1.05);
}

.chat-start-group-icon-btn .btn-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #ff3b30;
    color: white;
    font-size: 9px;
    padding: 2px 5px;
    border-radius: 10px;
    font-weight: bold;
    border: 2px solid #00c43a;
}

.chat-edit-icon-btn {
    background: transparent;
    color: #ffffff;
    border: none;
    border-radius: 50%;
    width: auto;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    padding: 0;
}

.chat-edit-icon-btn i {
    font-size: 18px;
    color: #fff;
}

.chat-edit-icon-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: scale(1.1);
}

.chat-user-tagline {
    font-size: 11px;
    color: #888;
    margin-top: 1px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Individual Chat View */
.chat-conversation-view {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.chat-conversation-header {
    background: #00c43a;
    padding: 12px 15px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.chat-conversation-header-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

.chat-group-indicator {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    position: relative;
    cursor: pointer;
}

.chat-group-avatars {
    display: flex;
    flex-direction: row-reverse;
    align-items: center;
    margin-bottom: 2px;
}

.chat-header-avatar {
    width: 26px !important;
    height: 26px !important;
    border-radius: 50% !important;
    border: 2px solid #00c43a;
    margin-left: -12px;
    background: #fff;
    object-fit: cover;
}

.chat-header-avatar:last-child {
    margin-left: 0;
}

.chat-group-count {
    font-size: 11px;
    color: #ffffff;
    opacity: 0.9;
    text-align: right;
    display: block;
}

.chat-group-members-popup {
    position: absolute;
    top: 100%;
    right: 0;
    width: 200px;
    background: #ffffff;
    border: 1px solid #eee;
    border-radius: 12px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
    z-index: 100;
    margin-top: 10px;
    overflow: hidden;
    animation: fadeInDown 0.2s ease-out;
}

.chat-group-popup-header {
    background: #f8f8f8;
    padding: 8px 12px;
    font-size: 12px;
    font-weight: 600;
    color: #666;
    border-bottom: 1px solid #eee;
}

.chat-group-members-list {
    max-height: 250px;
    overflow-y: auto;
}

.chat-group-member-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    border-bottom: 1px solid #f9f9f9;
}

.chat-group-member-item:last-child {
    border-bottom: none;
}

.chat-group-member-avatar {
    width: 24px;
    height: 24px;
    border-radius: 6px;
    object-fit: cover;
}

.chat-group-member-name {
    font-size: 13px;
    color: #333;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.chat-input-area {
    padding: 10px 15px 55px 15px;
    background: #ffffff;
    border-top: 1px solid #f0f0f0;
    flex-shrink: 0;
}

.chat-attachments {
    display: flex;
    gap: 10px;
    margin-bottom: 10px;
    padding-bottom: 5px;
}

.chat-attach-btn {
    background: #f8f8f8;
    border: 1px solid #eee;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 12px;
    color: #666;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s ease;
}

.chat-attach-btn:hover {
    background: #eee;
    border-color: #ddd;
}

.chat-attach-btn#chat-attach-images i {
    color: #6f42c1;
}

.chat-attach-btn#chat-attach-videos i {
    color: #fd7e14;
}

.chat-attach-btn i {
    font-size: 14px;
    color: #888;
}

.chat-back-btn {
    background: none;
    border: none;
    color: #ffffff;
    font-size: 16px;
    cursor: pointer;
    padding: 5px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s ease;
}

.chat-back-btn:hover {
    transform: translateX(-2px);
}

.chat-current-user-info span {
    font-size: 16px;
    font-weight: 600;
    color: #ffffff;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 15px;
    background: #fdfdfd;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* Message Bubbles */
.message {
    max-width: 80%;
    padding: 8px 12px;
    border-radius: 12px;
    font-size: 14px;
    line-height: 1.4;
    position: relative;
}

.message.sent {
    background: #00c43a;
    color: #ffffff;
    align-self: flex-end;
    border-bottom-right-radius: 4px;
}

.message.received {
    background: #f0f0f0;
    color: #333;
    align-self: flex-start;
    border-bottom-left-radius: 4px;
}

.chat-input-container {
    display: flex;
    align-items: flex-end;
    gap: 10px;
}

.chat-input-container textarea {
    flex: 1;
    border: 1px solid #eee;
    border-radius: 10px;
    padding: 8px 12px;
    font-size: 14px;
    resize: none;
    max-height: 100px;
    background: #fafafa;
    transition: all 0.3s ease;
}

.chat-input-container textarea:focus {
    background: #fff;
    border-color: #00c43a;
    box-shadow: 0 0 0 3px rgba(0, 196, 58, 0.1);
}

.chat-send-btn {
    background: #00c43a;
    color: #ffffff;
    border: none;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.chat-send-btn:hover {
    background: #00a832;
    transform: scale(1.05);
}

.chat-loading {
    text-align: center;
    padding: 40px 20px;
    color: #aaa;
    font-size: 14px;
}

/* Message Attachments & Metadata */
.msg-sender {
    font-size: 11px;
    font-weight: bold;
    margin-bottom: 4px;
    color: #00c43a;
}

.message.sent .msg-sender {
    color: #fff;
    text-align: right;
}

.msg-time {
    font-size: 9px;
    margin-top: 4px;
    opacity: 0.7;
    text-align: right;
}

.chat-msg-image {
    max-width: 100%;
    border-radius: 8px;
    cursor: pointer;
    display: block;
}

.chat-msg-video {
    max-width: 100%;
    border-radius: 8px;
    display: block;
}

.chat-msg-file {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(255, 255, 255, 0.2);
    padding: 8px 12px;
    border-radius: 8px;
    color: inherit;
    text-decoration: none;
    font-weight: 500;
}

.message.received .chat-msg-file {
    background: rgba(0, 0, 0, 0.05);
}

.chat-msg-file:hover {
    background: rgba(255, 255, 255, 0.3);
}
.message.received .chat-msg-file:hover {
    background: rgba(0, 0, 0, 0.1);
}

/* Mobile Close Button */
.chat-mobile-close-btn {
    background: transparent;
    color: #ffffff;
    border: none;
    border-radius: 50%;
    width: 32px;
    height: 32px;
    display: none;
    /* Hidden by default */
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    padding: 0;
}

.chat-mobile-close-btn i {
    font-size: 20px;
    color: #fff;
}

.chat-mobile-close-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: scale(1.1);
}

@media (max-width: 640px) {
    .chat-mobile-close-btn {
        display: flex;
        /* Show on mobile */
    }
}