/* Chatbox Styles - Reusable across all pages */

.idle-chat {
    position: fixed;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    z-index: 40;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 14px;
    border: 1px solid rgba(255, 255, 255, .12);
    border-right: none;
    border-radius: 14px 0 0 14px;
    color: #ffffff;
    background: linear-gradient(135deg, #1f9d63, #15794b);
    box-shadow: 0 18px 45px rgba(0, 0, 0, .4);
    cursor: pointer;
    font-family: 'Poppins', sans-serif;
    font-weight: 700;
    transition: all 0.3s ease;
}

.idle-chat:hover {
    padding-right: 18px;
    background: linear-gradient(135deg, #22b271, #1a8a54);
}

.idle-chat i {
    font-size: 21px;
}

.idle-chat span {
    writing-mode: vertical-rl;
    transform: rotate(180deg);
    letter-spacing: 1px;
    font-size: 12px;
}

.idle-badge {
    min-width: 22px;
    height: 22px;
    display: none;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: #f04444;
    color: #ffffff;
    font-size: 11px;
    font-weight: 700;
}

.idle-badge.show {
    display: inline-flex;
}

.chat-overlay {
    position: fixed;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: rgba(5, 9, 14, .64);
    z-index: 45;
}

.chat-overlay.open {
    display: flex;
}

.messenger {
    width: min(1120px, 100%);
    height: min(720px, calc(100vh - 48px));
    display: grid;
    grid-template-columns: 340px minmax(0, 1fr);
    overflow: hidden;
    border: 1px solid #2a3a4d;
    border-radius: 8px;
    background: #1a2432;
    box-shadow: 0 18px 45px rgba(0, 0, 0, .4);
}

.sidebar {
    border-right: 1px solid #2a3a4d;
    background: #16202d;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.sidebar-header,
.chat-header {
    min-height: 74px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 16px;
    background: #1d2a3a;
    border-bottom: 1px solid #2a3a4d;
}

.profile {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.avatar {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #1f9d63;
    color: #ffffff;
    font-weight: 700;
    flex: 0 0 auto;
    font-size: 12px;
}

.profile strong,
.chat-title strong {
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.profile span,
.chat-title span {
    display: block;
    color: #8fa3b8;
    font-size: 12px;
    margin-top: 2px;
}

.icon-btn {
    width: 42px;
    height: 42px;
    border: none;
    border-radius: 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #ffffff;
    background: rgba(255, 255, 255, .08);
    cursor: pointer;
    transition: background 0.2s;
    flex-shrink: 0;
}

.icon-btn:hover {
    background: rgba(255, 255, 255, .14);
}

.search-box {
    padding: 12px;
    border-bottom: 1px solid #2a3a4d;
}

.search-box input,
.composer input,
.new-contact-form input,
.new-contact-form select {
    width: 100%;
    padding: 12px 14px;
    border-radius: 8px;
    background: #101925;
    border: 1px solid #2a3a4d;
    color: #e7edf5;
    font-family: 'Poppins', sans-serif;
    outline: none;
}

.search-box input:focus,
.composer input:focus,
.new-contact-form input:focus,
.new-contact-form select:focus {
    border-color: #3d6fa3;
}

.contact-list {
    overflow-y: auto;
    flex: 1;
}

.contact {
    width: 100%;
    display: grid;
    grid-template-columns: 42px minmax(0, 1fr) auto;
    gap: 12px;
    align-items: center;
    padding: 14px 16px;
    border: none;
    border-bottom: 1px solid rgba(42, 58, 77, .72);
    background: transparent;
    color: #e7edf5;
    cursor: pointer;
    text-align: left;
    font-family: 'Poppins', sans-serif;
    transition: background 0.2s;
}

.contact:hover,
.contact.active {
    background: rgba(31, 157, 99, .12);
}

.contact.unread {
    background: rgba(31, 157, 99, .2);
}

.contact-meta {
    min-width: 0;
}

.contact-meta strong,
.contact-meta span {
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.contact-meta span {
    margin-top: 3px;
    color: #8fa3b8;
    font-size: 12px;
}

.contact-side {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 6px;
    color: #8fa3b8;
    font-size: 11px;
}

.unread-pill {
    min-width: 22px;
    height: 22px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: #1f9d63;
    color: #ffffff;
    font-weight: 700;
}

.chat-panel {
    min-width: 0;
    display: flex;
    flex-direction: column;
    background:
        linear-gradient(rgba(15, 23, 34, .94), rgba(15, 23, 34, .94)),
        radial-gradient(circle at top right, rgba(31, 157, 99, .28), transparent 34%);
}

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

.message {
    max-width: min(72%, 620px);
    padding: 11px 13px 8px;
    border-radius: 8px;
    background: #1d2a3a;
    color: #eef6ff;
    line-height: 1.45;
    font-size: 14px;
    align-self: flex-start;
    word-wrap: break-word;
}

.message.mine {
    align-self: flex-end;
    background: #166d47;
}

.message small {
    display: block;
    margin-top: 6px;
    color: rgba(255, 255, 255, .68);
    font-size: 10px;
    text-align: right;
}

.composer {
    display: grid;
    grid-template-columns: 42px minmax(0, 1fr) 48px;
    gap: 10px;
    align-items: center;
    padding: 14px 16px;
    border-top: 1px solid #2a3a4d;
    background: #1d2a3a;
}

.send-btn {
    width: 48px;
    height: 48px;
    border: none;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #ffffff;
    background: #1f9d63;
    cursor: pointer;
    transition: background 0.2s;
    flex-shrink: 0;
}

.send-btn:hover {
    background: #22b271;
}

.new-contact-form {
    display: none;
    padding: 12px;
    gap: 8px;
    border-top: 1px solid #2a3a4d;
    background: #101925;
}

.new-contact-form.open {
    display: grid;
}

.form-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.form-actions button {
    min-height: 38px;
    border: none;
    border-radius: 8px;
    color: #ffffff;
    background: #3d6fa3;
    cursor: pointer;
    transition: background 0.2s;
    font-family: 'Poppins', sans-serif;
}

.form-actions button:hover {
    background: #4a7fb5;
}

.form-actions button.secondary {
    background: #1d2a3a;
}

.form-actions button.secondary:hover {
    background: #243547;
}

.toast {
    position: fixed;
    right: 24px;
    bottom: 24px;
    width: min(360px, calc(100vw - 48px));
    display: none;
    gap: 12px;
    align-items: center;
    padding: 14px;
    border-radius: 8px;
    background: #102719;
    border: 1px solid rgba(31, 157, 99, .45);
    box-shadow: 0 18px 45px rgba(0, 0, 0, .4);
    color: #ffffff;
    z-index: 55;
    cursor: pointer;
    animation: slideUp 0.3s ease;
}

@keyframes slideUp {
    from {
        transform: translateY(120%);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.toast.show {
    display: flex;
}

.toast i {
    color: #7ee0aa;
}

.toast strong,
.toast span {
    display: block;
}

.toast span {
    color: #bad4c7;
    font-size: 12px;
    margin-top: 2px;
}

@media (max-width: 860px) {
    .messenger {
        grid-template-columns: 1fr;
        height: calc(100vh - 32px);
    }

    .sidebar {
        min-height: 260px;
        max-height: 44vh;
        border-right: none;
        border-bottom: 1px solid #2a3a4d;
    }
}

::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(61, 111, 163, 0.4);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(61, 111, 163, 0.6);
}
