/* Global Styles */
#homey-chat-launcher {
    position: fixed;
    bottom: 30px;
    right: 30px;
    background: #0073aa;
    color: #fff;
    font-size: 24px;
    width: 55px;
    height: 55px;
    border-radius: 50%;
    text-align: center;
    line-height: 55px;
    cursor: pointer;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
    z-index: 10000;
    transition: all 0.3s ease-in-out;
}

#homey-chat-launcher:hover {
    background: linear-gradient(135deg, #0073aa, #005a87);
    transform: scale(1.1);
}

/* Chat Container */
#homey-chat-container {
    display: none;
    position: fixed;
    bottom: 100px;
    right: 30px;
    width: 340px;
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.15);
    overflow: hidden;
    z-index: 10000;
    flex-direction: column;
    transition: all 0.3s ease;
}

/* Header */
.chat-header {
    background: linear-gradient(135deg, #0073aa, #006299);
    color: #fff;
    padding: 12px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: bold;
    border-bottom: 1px solid #005a87;
    font-size: 15px;
}

#close-chat {
    cursor: pointer;
}

/* Body */
.chat-body {
    display: flex;
    flex-direction: column;
    height: 420px;
}

#chat-user-select {
    margin: 10px;
    padding: 6px;
    border-radius: 6px;
    border: 1px solid #ccc;
}

/* Messages */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 10px;
    background: #f4f4f4;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.sent,
.received {
    max-width: 75%;
    margin: 8px 0;
    border-radius: 18px;
    position: relative;
    display: inline-block;
    word-wrap: break-word;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.05);
    line-height: 1.5;
    padding: 10px 16px;
}

.sent {
    background: #cde9ff;
    align-self: flex-end;
}

.received {
    background: #d4f9d4;
    align-self: flex-start;
}

.sent::after,
.received::after {
    content: attr(data-time);
    font-size: 10px;
    color: #888;
    display: block;
    margin-top: 4px;
}

/* Footer */
.chat-footer {
    display: flex;
    padding: 10px;
    background: #fff;
    border-top: 1px solid #ddd;
}

#chat-input {
    flex: 1;
    padding: 10px 16px;
    border-radius: 16px;
    border: 1px solid #ccc;
    transition: box-shadow 0.3s ease;
}

#chat-input:focus {
    box-shadow: 0 0 5px rgba(0, 115, 170, 0.3);
    outline: none;
}

#send-msg {
    background: #0073aa;
    border: none;
    color: #fff;
    margin-left: 8px;
    border-radius: 16px;
    cursor: pointer;
    padding: 8px 18px;
    transition: background 0.3s ease;
}

#send-msg:hover {
    background: linear-gradient(135deg, #0073aa, #005a87);
}

/* Scrollbar */
.chat-messages::-webkit-scrollbar {
    width: 6px;
}

.chat-messages::-webkit-scrollbar-thumb {
    background-color: #bbb;
    border-radius: 4px;
}

/* Timestamps */
.message::after {
    content: attr(data-time);
    font-size: 11px;
    color: #777;
    margin-top: 4px;
    text-align: right;
}

/* Typing Indicator */
.typing-dots span {
    animation: pulse 1.2s infinite ease-in-out;
    font-weight: bold;
    font-size: 16px;
    color: #555;
}

.typing-dots span:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-dots span:nth-child(3) {
    animation-delay: 0.4s;
}

/* Animations */
@keyframes pulse {

    0%,
    100% {
        transform: scale(0.7);
        opacity: 0.3;
    }

    50% {
        transform: scale(1);
        opacity: 1;
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Message Bubbles Animation */
.sent,
.received {
    animation: fadeInUp 0.3s ease;
}

@keyframes fadeInUp {
    0% {
        opacity: 0;
        transform: translateY(10px);
    }

    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Media Queries */
@media (max-width: 480px) {
    #homey-chat-container {
        width: 95%;
        right: 2.5%;
        bottom: 80px;
    }
}

/* Chat Toast */
#chat-toast {
    position: fixed;
    bottom: 100px;
    right: 30px;
    background: #0073aa;
    color: #fff;
    padding: 12px 18px;
    border-radius: 6px;
    display: none;
    z-index: 10001;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.25);
    font-size: 14px;
}

/* Chat Badge */
.chat-badge {
    position: absolute;
    top: -6px;
    right: -6px;
    background: red;
    color: white;
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 12px;
    font-weight: bold;
    z-index: 10001;
    height: 25px;
    width: 25px;
}

/* Emoji Button */
#emoji-button {
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
}

/* Custom Select */
.custom-select {
    position: relative;
    font-family: Arial, sans-serif;
    margin: 6px;
    padding: 6px;
    border-radius: 6px;
}

.select-button {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    padding: 10px;
    border: 1px solid #ccc;
    border-radius: 8px;
    background-color: #fff;
    cursor: pointer;
    font-size: 14px;
    color: #333;
}

.select-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    width: 100%;
    background-color: #fff;
    border: 1px solid #ccc;
    border-radius: 8px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    max-height: 200px;
    overflow-y: auto;
    display: none;
    list-style: none;
    padding: 0;
    margin: 0;
    z-index: 999999;
}

.select-dropdown.show {
    display: block;
}

.select-option {
    display: flex;
    align-items: center;
    padding: 10px;
    cursor: pointer;
    font-size: 14px;
    color: #333;
}

.select-option:hover {
    background-color: #f0f0f0;
}

/* User Avatar */
.user-avatar {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background-color: #0073b1;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 10px;
}

.user-avatar::after {
    content: '';
    position: absolute;
    bottom: 0;
    right: 0;
    width: 8px;
    height: 8px;
    background-color: gray;
    border: 2px solid #fff;
    border-radius: 50%;
    display: none;
}

.user-avatar.online::after {
    display: block;
    background-color: #4caf50;
}

.user-avatar.offline::after {
    display: block;
    background-color: #bbb;
}

/* Spinner */
.cspinner {
    border: 4px solid #f3f3f3;
    border-top: 4px solid #0073aa;
    border-radius: 50%;
    width: 30px;
    height: 30px;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

/* Message Placeholder */
#no-messages-placeholder {
    font-style: italic;
    font-size: 14px;
    text-align: center;
    color: #777;
}

#chat-user-status {
    margin-left: 10px;
    font-size: 13px;
    color: #555;
}

.user-status-indicator {
    background-color: white;
    padding: 0 4px;
    border-radius: 8px;
}

.msg-status {
    font-size: 10px;
    color: #777;
    text-align: right;
    margin-top: 2px;
}