/* MedConnect Premium Inline Chat Styles */
:root {
    --chat-primary: #1877f2;
    --chat-primary-dark: #1565c0;
    --chat-primary-light: #e7f3ff;
    --chat-bg: #ffffff;
    --chat-bg-dark: #0f172a;
    --chat-text-dark: #1e293b;
    --chat-text-light: #64748b;
    --chat-border: #e2e8f0;
    --chat-shadow: 0 10px 30px -5px rgba(0, 0, 0, 0.15), 0 5px 15px -3px rgba(0, 0, 0, 0.1);
    --chat-radius: 16px;
    --chat-bubble-sent: linear-gradient(135deg, #1877f2, #1565c0);
    --chat-bubble-received: #f1f5f9;
}

/* Floating Launcher Trigger */
#floating-chat-trigger {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 60px;
    height: 60px;
    background: linear-gradient(135deg, var(--chat-primary), var(--chat-primary-dark));
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(24, 119, 242, 0.4);
    z-index: 9999;
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

#floating-chat-trigger:hover {
    transform: scale(1.1) translateY(-3px);
    box-shadow: 0 8px 30px rgba(24, 119, 242, 0.5);
}

#floating-chat-trigger i {
    font-size: 24px;
}

#floating-chat-trigger .chat-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #ef4444;
    color: white;
    font-size: 11px;
    font-weight: 800;
    border-radius: 10px;
    padding: 3px 8px;
    border: 2px solid white;
    min-width: 22px;
    text-align: center;
    display: none;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
}

/* Chat Widget Container */
#floating-chat-widget {
    position: fixed;
    bottom: 100px;
    right: 30px;
    width: 400px;
    height: 580px;
    background: white;
    border-radius: var(--chat-radius);
    box-shadow: var(--chat-shadow);
    z-index: 9998;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    opacity: 0;
    transform: scale(0.9) translateY(30px);
    pointer-events: none;
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    border: 1px solid rgba(226, 232, 240, 0.8);
}

#floating-chat-widget.show {
    opacity: 1;
    transform: scale(1) translateY(0);
    pointer-events: auto;
}

/* Chat Header */
.inline-chat-header {
    padding: 15px 20px;
    background: linear-gradient(135deg, var(--chat-primary), var(--chat-primary-dark));
    color: white;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 70px;
    flex-shrink: 0;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
}

.inline-chat-header .header-info {
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    min-width: 0;
}

.inline-chat-header .header-avatar {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.2);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 18px;
    overflow: hidden;
    position: relative;
    border: 1.5px solid rgba(255,255,255,0.4);
}

.inline-chat-header .header-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.inline-chat-header .header-status-indicator {
    position: absolute;
    bottom: -2px;
    right: -2px;
    width: 11px;
    height: 11px;
    border-radius: 50%;
    background: #10b981;
    border: 2px solid var(--chat-primary);
    display: none;
}

.inline-chat-header .header-status-indicator.online {
    display: block;
}

.inline-chat-header .header-user-details {
    min-width: 0;
}

.inline-chat-header .header-user-name {
    font-weight: 700;
    font-size: 15.5px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.inline-chat-header .header-user-status {
    font-size: 11.5px;
    opacity: 0.85;
    display: flex;
    align-items: center;
    gap: 4px;
}

.inline-chat-header .header-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.inline-chat-header .header-actions i {
    font-size: 18px;
    cursor: pointer;
    opacity: 0.85;
    transition: opacity 0.2s;
}

.inline-chat-header .header-actions i:hover {
    opacity: 1;
}

/* Chat Body Wrapper (Multi-panel slider) */
.inline-chat-body-wrapper {
    flex: 1;
    display: flex;
    width: 200%; /* Holds conversations and chat panel side-by-side */
    height: calc(100% - 70px);
    transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

.inline-chat-body-wrapper.chat-active {
    transform: translateX(-50%);
}

/* Common Panel Styling */
.inline-chat-panel {
    width: 50%;
    height: 100%;
    display: flex;
    flex-direction: column;
    background: white;
}

/* Conversations List Panel */
.conversations-panel {
    border-right: 1px solid var(--chat-border);
}

.conv-search-box {
    padding: 15px 18px;
    border-bottom: 1px solid var(--chat-border);
    background: #f8fafc;
    position: relative;
}

.conv-search-box input {
    width: 100%;
    padding: 10px 14px 10px 38px;
    background: white;
    border: 1.5px solid var(--chat-border);
    border-radius: 12px;
    font-size: 14px;
    outline: none;
    font-weight: 500;
    color: var(--chat-text-dark);
    transition: all 0.2s;
}

.conv-search-box input:focus {
    border-color: var(--chat-primary);
    box-shadow: 0 0 0 3px rgba(24, 119, 242, 0.1);
}

.conv-search-box i.search-icon {
    position: absolute;
    left: 32px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--chat-text-light);
    font-size: 14px;
}

.conv-search-results {
    position: absolute;
    top: 100%;
    left: 18px;
    right: 18px;
    background: white;
    border: 1px solid var(--chat-border);
    border-radius: 12px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.1);
    z-index: 100;
    max-height: 250px;
    overflow-y: auto;
    display: none;
}

.conv-search-results .search-result-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    cursor: pointer;
    transition: background 0.2s;
    border-bottom: 1px solid #f1f5f9;
}

.conv-search-results .search-result-item:last-child {
    border-bottom: none;
}

.conv-search-results .search-result-item:hover {
    background: #f1f5f9;
}

.inline-conversation-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
}

.inline-conversation-list::-webkit-scrollbar {
    width: 4px;
}

.inline-conversation-list::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 10px;
}

.inline-conv-item {
    display: flex;
    align-items: center;
    padding: 12px 14px;
    cursor: pointer;
    border-radius: 12px;
    transition: all 0.2s;
    gap: 12px;
    margin-bottom: 4px;
}

.inline-conv-item:hover {
    background: #f8fafc;
}

.inline-conv-item.active {
    background: var(--chat-primary-light);
}

.inline-conv-item .avatar-wrapper {
    position: relative;
    flex-shrink: 0;
}

.inline-conv-item .conv-avatar {
    width: 46px;
    height: 46px;
    border-radius: 14px;
    background: var(--chat-primary);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 18px;
    overflow: hidden;
}

.inline-conv-item .conv-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.inline-conv-item .status-indicator {
    position: absolute;
    bottom: -2px;
    right: -2px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #10b981;
    border: 2px solid white;
    display: none;
}

.inline-conv-item .status-indicator.online {
    display: block;
}

.inline-conv-item .conv-info {
    flex: 1;
    min-width: 0;
}

.inline-conv-item .conv-name {
    font-weight: 700;
    font-size: 14px;
    color: var(--chat-text-dark);
    margin-bottom: 3px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.inline-conv-item .conv-last-msg {
    font-size: 12.5px;
    color: var(--chat-text-light);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-weight: 500;
}

.inline-conv-item .conv-meta {
    text-align: right;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 5px;
}

.inline-conv-item .conv-time {
    font-size: 11px;
    color: var(--chat-text-light);
    font-weight: 600;
}

.inline-conv-item .unread-pill {
    background: var(--chat-primary);
    color: white;
    font-size: 10.5px;
    font-weight: 800;
    border-radius: 10px;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 5px rgba(24, 119, 242, 0.2);
}

/* Active Chat Panel */
.chat-messages-panel {
    display: flex;
    flex-direction: column;
    position: relative;
    height: 100%;
}

.inline-chat-messages {
    flex: 1;
    padding: 20px 16px;
    overflow-y: auto;
    background: #f8fafc;
    background-image: radial-gradient(#e2e8f0 0.5px, transparent 0.5px);
    background-size: 20px 20px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.inline-chat-messages::-webkit-scrollbar {
    width: 4px;
}

.inline-chat-messages::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 10px;
}

/* Messages Wrapper and Bubbles */
.inline-msg-wrapper {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    max-width: 85%;
    width: fit-content;
}

.inline-msg-wrapper.received {
    align-self: flex-start;
}

.inline-msg-wrapper.sent {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.inline-msg-wrapper .msg-avatar {
    width: 28px;
    height: 28px;
    border-radius: 8px;
    overflow: hidden;
    flex-shrink: 0;
    margin-bottom: 2px;
}

.inline-msg-wrapper .msg-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.inline-msg-wrapper .msg-bubble {
    padding: 8px 14px;
    border-radius: 16px;
    font-size: 13.5px;
    line-height: 1.45;
    word-break: break-word;
}

.inline-msg-wrapper.received .msg-bubble {
    background: white;
    color: var(--chat-text-dark);
    border-bottom-left-radius: 4px;
    border: 1px solid var(--chat-border);
    box-shadow: 0 1px 2px rgba(0,0,0,0.02);
}

.inline-msg-wrapper.sent .msg-bubble {
    background: var(--chat-bubble-sent);
    color: white;
    border-bottom-right-radius: 4px;
    box-shadow: 0 2px 6px rgba(24, 119, 242, 0.15);
}

.inline-msg-wrapper .msg-time {
    font-size: 9.5px;
    opacity: 0.6;
    display: block;
    margin-top: 4px;
    font-weight: 600;
}

.inline-msg-wrapper.sent .msg-time {
    text-align: right;
    color: rgba(255,255,255,0.85);
}

/* Chat Footer Input */
.inline-chat-footer {
    padding: 12px 16px;
    background: white;
    border-top: 1px solid var(--chat-border);
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

.inline-chat-input-wrapper {
    flex: 1;
    background: #f1f5f9;
    border-radius: 20px;
    padding: 8px 14px;
    display: flex;
    align-items: center;
}

.inline-chat-input-wrapper input {
    width: 100%;
    border: none;
    background: transparent;
    outline: none;
    font-size: 13.5px;
    color: var(--chat-text-dark);
    font-weight: 500;
}

.inline-chat-input-wrapper i {
    color: var(--chat-text-light);
    cursor: pointer;
    font-size: 15px;
    transition: color 0.2s;
}

.inline-chat-input-wrapper i:hover {
    color: var(--chat-primary);
}

.inline-chat-send-btn {
    width: 36px;
    height: 36px;
    background: var(--chat-primary);
    color: white;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 2px 8px rgba(24,119,242,0.25);
    border: none;
}

.inline-chat-send-btn:hover {
    background: var(--chat-primary-dark);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(24,119,242,0.35);
}

.inline-chat-send-btn i {
    font-size: 14px;
}

/* Responsive Mobile Chat Styling */
@media (max-width: 767px) {
    #floating-chat-trigger {
        bottom: 20px;
        right: 20px;
    }

    #floating-chat-widget {
        bottom: 0 !important;
        right: 0 !important;
        width: 100% !important;
        height: 100% !important;
        border-radius: 0 !important;
        border: none !important;
        transform: translateY(100%) !important;
        transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1) !important;
    }

    #floating-chat-widget.show {
        transform: translateY(0) !important;
    }

    .inline-chat-header {
        height: 60px;
        padding: 10px 15px;
    }
}
