/* IM Popup Chat Windows - Berserk Theme */

#im-container {
    position: static;
    display: flex;
    flex-direction: row;
    align-items: flex-end;
    gap: 10px;
    padding: 0;
    pointer-events: none;
}

.im-window {
    width: 300px;
    height: 400px;
    background: var(--card-background);
    border: 2px solid var(--blood-red);
    border-radius: 8px 8px 0 0;
    display: flex;
    flex-direction: column;
    box-shadow: 0 -4px 20px rgba(139, 0, 0, 0.5);
    transition: height 0.2s ease;
    pointer-events: all;
    flex-shrink: 0;
    position: static;
}

.im-window.minimized {
    height: 45px;
}

.im-window.minimized .im-messages,
.im-window.minimized .im-input-area {
    display: none;
}

.im-header {
    padding: 10px 12px;
    background: linear-gradient(135deg, var(--blood-red), var(--crimson));
    color: white;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-radius: 6px 6px 0 0;
    user-select: none;
    flex-shrink: 0;
}

.im-user-info {
    display: flex;
    align-items: center;
    gap: 6px;
    flex: 1;
    min-width: 0;
}

.im-status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #4ade80;
    flex-shrink: 0;
}

.im-username {
    font-weight: 700;
    font-size: 13px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Unread badge — appears on minimized window header */
.im-unread-badge {
    background: white;
    color: var(--crimson);
    border-radius: 10px;
    padding: 1px 6px;
    font-size: 11px;
    font-weight: 900;
    flex-shrink: 0;
    animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50%       { opacity: 0.6; }
}

.im-controls {
    display: flex;
    gap: 6px;
    flex-shrink: 0;
}

.im-minimize,
.im-close {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    width: 22px;
    height: 22px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 16px;
    line-height: 1;
    transition: background 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.im-minimize:hover,
.im-close:hover {
    background: rgba(255, 255, 255, 0.35);
}

.im-messages {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    background: var(--background);
    min-height: 0;
}

.im-messages::-webkit-scrollbar { width: 5px; }
.im-messages::-webkit-scrollbar-thumb {
    background: var(--blood-red);
    border-radius: 3px;
}

.im-empty {
    text-align: center;
    color: #666;
    padding: 30px 16px;
    font-size: 13px;
}

.im-message {
    display: flex;
    flex-direction: column;
    max-width: 82%;
    animation: slideIn 0.15s ease;
}

@keyframes slideIn {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
}

.im-message.sent     { align-self: flex-end; }
.im-message.received { align-self: flex-start; }

.im-message-text {
    padding: 7px 11px;
    border-radius: 12px;
    word-wrap: break-word;
    font-size: 13px;
    line-height: 1.4;
}

.im-message.sent .im-message-text {
    background: linear-gradient(135deg, var(--blood-red), var(--crimson));
    color: white;
    border-bottom-right-radius: 3px;
}

.im-message.received .im-message-text {
    background: rgba(139, 0, 0, 0.1);
    border: 1px solid var(--border-color);
    color: var(--text-color);
    border-bottom-left-radius: 3px;
}

.im-message-time {
    font-size: 10px;
    color: #666;
    margin-top: 3px;
    padding: 0 3px;
}

.im-message.sent .im-message-time { text-align: right; }

.im-input-area {
    padding: 10px;
    border-top: 2px solid var(--border-color);
    display: flex;
    gap: 8px;
    background: var(--card-background);
    flex-shrink: 0;
}

.im-input {
    flex: 1;
    padding: 7px 11px;
    background: var(--dark-gray);
    border: 1px solid var(--border-color);
    border-radius: 14px;
    color: var(--text-color);
    font-family: inherit;
    font-size: 13px;
    resize: none;
    max-height: 80px;
    transition: border-color 0.2s ease;
}

.im-input:focus {
    outline: none;
    border-color: var(--blood-red);
}

.im-send {
    width: 34px;
    height: 34px;
    background: linear-gradient(135deg, var(--blood-red), var(--crimson));
    border: none;
    border-radius: 50%;
    color: white;
    cursor: pointer;
    font-size: 15px;
    transition: transform 0.15s ease;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.im-send:hover  { transform: scale(1.08); }
.im-send:active { transform: scale(0.95); }

/* Toast notifications */
#toast-container {
    position: fixed;
    top: 80px;
    right: 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    z-index: 10000;
    pointer-events: none;
}
