/* ── Teams Chat Panel — Scoped Styles ── */
/* All selectors prefixed .teams-panel or .teams-panel__ to prevent collisions */

.teams-panel {
    --tp-primary: #3a57e8;
    --tp-primary-soft: #eef0fd;
    --tp-success: #1aa053;
    --tp-warning: #f16a1b;
    --tp-danger: #c03221;
    --tp-panel-width: 780px;
    position: fixed;
    top: var(--navbar-height, 65px);
    right: 0;
    width: var(--tp-panel-width);
    height: calc(100vh - var(--navbar-height, 65px));
    background: #fff;
    z-index: 1050;
    display: flex;
    flex-direction: column;
    box-shadow: -4px 0 24px rgba(0, 0, 0, 0.12);
    transform: translateX(100%);
    transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
    font-family: "Inter", "Segoe UI", sans-serif;
    font-size: 14px;
}
.teams-panel.open {
    transform: translateX(0);
}

.teams-panel__overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.25);
    z-index: 1049;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s;
}
.teams-panel__overlay.show {
    opacity: 1;
    pointer-events: all;
}

.teams-panel__inner {
    display: flex;
    height: 100%;
    overflow: hidden;
}

/* ── Nav button (in navbar) ── */
.teams-panel__nav-btn {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    border: none;
    background: transparent;
    color: #6c757d;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    cursor: pointer;
    transition: all 0.15s;
    position: relative;
}
.teams-panel__nav-btn:hover,
.teams-panel__nav-btn.active {
    background: var(--tp-primary-soft, #eef0fd);
    color: var(--tp-primary, #3a57e8);
}
.teams-panel__nav-badge {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 16px;
    height: 16px;
    background: #e63757;
    border-radius: 50%;
    font-size: 9px;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    border: 2px solid #fff;
}

/* ── Conversation List ── */
.teams-panel__conv-list {
    width: 280px;
    flex-shrink: 0;
    border-right: 1px solid #e9ecef;
    display: flex;
    flex-direction: column;
    background: #fafbfc;
}
.teams-panel__conv-header {
    padding: 16px;
    border-bottom: 1px solid #e9ecef;
    display: flex;
    align-items: center;
    gap: 8px;
}
.teams-panel__conv-title {
    margin: 0;
    font-size: 15px;
    font-weight: 700;
    color: #1e1e2d;
    flex: 1;
}
.teams-panel__teams-icon {
    font-size: 20px;
    color: #5b5ea6;
}
.teams-panel__icon-btn {
    width: 30px;
    height: 30px;
    border-radius: 8px;
    border: none;
    background: transparent;
    color: #6c757d;
    font-size: 15px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.15s;
}
.teams-panel__icon-btn:hover {
    background: var(--tp-primary-soft);
    color: var(--tp-primary);
}
.teams-panel__connect-btn {
    width: 30px;
    height: 30px;
    border-radius: 8px;
    border: none;
    background: #fff3ee;
    color: #f16a1b;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.15s;
    text-decoration: none;
}
.teams-panel__connect-btn:hover {
    background: #f16a1b;
    color: #fff;
}

/* Connect notice */
.teams-panel__connect-notice {
    background: #fffbea;
    border-bottom: 1px solid #fde68a;
    padding: 8px 14px;
    font-size: 12px;
    color: #6c757d;
}
.teams-panel__connect-notice a {
    color: #f16a1b;
}

/* Presence legend */
.teams-panel__presence-legend {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    padding: 8px 14px;
    border-bottom: 1px solid #e9ecef;
    background: #fafbfc;
}
.teams-panel__presence-badge {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 11px;
    color: #6c757d;
}
.teams-panel__dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}
.teams-panel__dot--available {
    background: #1aa053;
}
.teams-panel__dot--busy {
    background: #e63757;
}
.teams-panel__dot--away {
    background: #f16a1b;
}
.teams-panel__dot--dnd {
    background: #e63757;
}
.teams-panel__dot--offline {
    background: #adb5bd;
}

/* Search */
.teams-panel__search-wrap {
    padding: 10px 12px;
    border-bottom: 1px solid #e9ecef;
}
.teams-panel__search-input {
    width: 100%;
    padding: 7px 12px 7px 34px;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    font-size: 13px;
    background: #fff
        url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' fill='%23adb5bd' viewBox='0 0 16 16'%3E%3Cpath d='M11.742 10.344a6.5 6.5 0 1 0-1.397 1.398h-.001c.03.04.062.078.098.115l3.85 3.85a1 1 0 0 0 1.415-1.414l-3.85-3.85a1.007 1.007 0 0 0-.115-.099zm-5.242 1.656a5.5 5.5 0 1 1 0-11 5.5 5.5 0 0 1 0 11z'/%3E%3C/svg%3E")
        no-repeat 10px center;
    outline: none;
}
.teams-panel__search-input:focus {
    border-color: var(--tp-primary);
}

/* Conv items */
.teams-panel__conv-items {
    flex: 1;
    overflow-y: auto;
}
.teams-panel__conv-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 11px 14px;
    cursor: pointer;
    transition: background 0.15s;
    border-left: 3px solid transparent;
}
.teams-panel__conv-item:hover {
    background: #f0f2f5;
}
.teams-panel__conv-item.active {
    background: #dde3fb;
    border-left-color: var(--tp-primary);
    color: black;
    font-weight: bolder;
}
.teams-panel__conv-item.active .teams-panel__conv-name {
    color: #000;
    font-weight: 700;
}
.teams-panel__conv-item.active .teams-panel__conv-preview {
    color: #333;
}
.teams-panel__conv-loading {
    display: flex;
    align-items: center;
    padding: 16px;
}

/* Graph contact search results */
.teams-graph-results {
    border-top: 1px solid #e9ecef;
    margin-top: 4px;
    padding-top: 4px;
}
.teams-graph-results__label {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    color: #6c757d;
    letter-spacing: 0.05em;
    padding: 6px 12px 4px;
}
.teams-graph-results__item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    cursor: pointer;
    transition: background 0.15s;
    font-size: 13px;
    color: #212529;
}
.teams-graph-results__item:hover {
    background: #f0f2f5;
}
.teams-graph-results__item .teams-panel__avatar {
    flex-shrink: 0;
}
.teams-graph-results__empty {
    padding: 24px 12px;
    text-align: center;
    font-size: 13px;
    color: #6c757d;
}

.teams-panel__conv-avatar {
    position: relative;
    flex-shrink: 0;
}
.teams-panel__avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 14px;
    color: #fff;
}
.teams-panel__avatar-img {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    display: block;
}
.teams-panel__avatar-photo {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
}
.teams-panel__group-avatar {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    background: #e9ecef;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    color: #6c757d;
}
.teams-panel__presence-dot {
    position: absolute;
    bottom: 1px;
    right: 1px;
    width: 11px;
    height: 11px;
    border-radius: 50%;
    border: 2px solid #fff;
}
.teams-panel__conv-info {
    flex: 1;
    min-width: 0;
}
.teams-panel__conv-name {
    font-size: 13.5px;
    font-weight: 600;
    color: #1e1e2d;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.teams-panel__conv-preview {
    font-size: 12px;
    color: #6c757d;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-top: 2px;
}
.teams-panel__conv-meta {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 4px;
    flex-shrink: 0;
}
.teams-panel__conv-time {
    font-size: 11px;
    color: #adb5bd;
}
.teams-panel__conv-unread {
    width: 18px;
    height: 18px;
    background: var(--tp-primary);
    border-radius: 50%;
    font-size: 10px;
    color: #fff;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
}
.teams-panel__type-pill {
    font-size: 10px;
    font-weight: 600;
    padding: 1px 6px;
    border-radius: 20px;
    flex-shrink: 0;
    background: #e9ecef;
    color: #6c757d;
}

/* ── Chat Window ── */
.teams-panel__chat-window {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.teams-panel__empty-state {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}
.teams-panel__active-chat {
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
}

/* Chat header */
.teams-panel__chat-header {
    padding: 12px 16px;
    border-bottom: 1px solid #e9ecef;
    display: flex;
    align-items: center;
    gap: 12px;
    background: #fff;
    flex-shrink: 0;
}
.teams-panel__chat-header-info {
    flex: 1;
}
.teams-panel__chat-header-info h6 {
    margin: 0;
    font-size: 14.5px;
    font-weight: 700;
    color: #1e1e2d;
}
.teams-panel__chat-header-info small {
    font-size: 12px;
}
.teams-panel__chat-actions {
    display: flex;
    gap: 4px;
}
.teams-panel__action-btn {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    border: 1px solid #e9ecef;
    background: #fff;
    color: #6c757d;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 16px;
    transition: all 0.15s;
}
.teams-panel__action-btn:hover {
    background: var(--tp-primary-soft);
    color: var(--tp-primary);
    border-color: var(--tp-primary);
}
.teams-panel__action-btn--call {
    color: #1aa053;
    border-color: #d1f0e0;
    background: #f0fbf5;
}
.teams-panel__action-btn--call:hover {
    background: #1aa053;
    color: #fff;
    border-color: #1aa053;
}
.teams-panel__action-btn--video {
    color: var(--tp-primary);
    border-color: #d6dcfb;
    background: var(--tp-primary-soft);
}
.teams-panel__action-btn--video:hover {
    background: var(--tp-primary);
    color: #fff;
    border-color: var(--tp-primary);
}

/* Messages */
.teams-panel__messages {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 20px 16px;
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 4px;
    background: #f8f9fb;
}
.teams-panel__day-divider {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 12px 0;
}
.teams-panel__day-divider span {
    font-size: 11.5px;
    font-weight: 600;
    color: #adb5bd;
    white-space: nowrap;
}
.teams-panel__day-divider::before,
.teams-panel__day-divider::after {
    content: "";
    flex: 1;
    height: 1px;
    background: #e9ecef;
}
.teams-panel__msg-group {
    display: flex;
    gap: 10px;
    margin-bottom: 6px;
}
.teams-panel__msg-group--outgoing {
    flex-direction: row-reverse;
}
.teams-panel__msg-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 700;
    color: #fff;
    flex-shrink: 0;
    margin-top: 2px;
}
.teams-panel__msg-content {
    max-width: 65%;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 3px;
}
.teams-panel__msg-group--outgoing .teams-panel__msg-content {
    align-items: flex-end;
}
.teams-panel__msg-sender {
    font-size: 11.5px;
    font-weight: 600;
    color: #6c757d;
    margin-bottom: 2px;
}
.teams-panel__msg-bubble {
    padding: 9px 13px;
    border-radius: 16px;
    word-break: break-word;
    overflow-wrap: anywhere;
    font-size: 13.5px;
    line-height: 1.5;
}
.teams-panel__msg-group:not(.teams-panel__msg-group--outgoing)
    .teams-panel__msg-bubble {
    background: #fff;
    color: #1e1e2d;
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}
.teams-panel__msg-group--outgoing .teams-panel__msg-bubble {
    background: var(--tp-primary);
    color: #fff;
    border-bottom-right-radius: 4px;
}
.teams-panel__msg-time {
    font-size: 11px;
    color: #adb5bd;
    padding: 0 4px;
}
.teams-panel__msg-group--outgoing .teams-panel__msg-time {
    text-align: right;
}

/* File messages */
.teams-panel__msg-file {
    background: #fff;
    border: 1px solid #e9ecef;
    border-radius: 14px;
    padding: 12px 14px;
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 200px;
    max-width: 260px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
    cursor: pointer;
    transition: background 0.15s;
    text-decoration: none;
}
.teams-panel__msg-file:hover {
    background: #f8f9fb;
}
.teams-panel__msg-group--outgoing .teams-panel__msg-file {
    border-color: rgba(255, 255, 255, 0.25);
    background: rgba(255, 255, 255, 0.15);
}
.teams-panel__msg-file-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    flex-shrink: 0;
}
.teams-panel__msg-file-info {
    flex: 1;
    min-width: 0;
}
.teams-panel__msg-file-name {
    font-size: 13px;
    font-weight: 600;
    color: #1e1e2d;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.teams-panel__msg-group--outgoing .teams-panel__msg-file-name {
    color: #fff;
}
.teams-panel__msg-file-size {
    font-size: 11.5px;
    color: #6c757d;
    margin-top: 2px;
}
.teams-panel__msg-group--outgoing .teams-panel__msg-file-size {
    color: rgba(255, 255, 255, 0.7);
}
.teams-panel__msg-file-download {
    color: var(--tp-primary);
    font-size: 18px;
    flex-shrink: 0;
}
.teams-panel__msg-group--outgoing .teams-panel__msg-file-download {
    color: rgba(255, 255, 255, 0.8);
}

/* Image in chat */
.teams-panel__msg-image {
    border-radius: 14px;
    overflow: hidden;
    max-width: 220px;
    cursor: pointer;
}
.teams-panel__msg-image img {
    width: 100%;
    display: block;
}

/* ── Input area ── */
.teams-panel__input-area {
    padding: 12px 16px;
    border-top: 1px solid #e9ecef;
    background: #fff;
    flex-shrink: 0;
}
.teams-panel__toolbar {
    display: flex;
    gap: 4px;
    margin-bottom: 8px;
}
.teams-panel__toolbar-btn {
    width: 30px;
    height: 30px;
    border: none;
    background: transparent;
    color: #6c757d;
    font-size: 15px;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
}
.teams-panel__toolbar-btn:hover {
    background: var(--tp-primary-soft);
    color: var(--tp-primary);
}
.teams-panel__file-strip {
    padding: 8px 12px;
    border-top: 1px solid #e9ecef;
    background: #fafbfc;
    gap: 8px;
    flex-wrap: wrap;
    display: flex;
}
.teams-panel__file-strip.d-none {
    display: none !important;
}
.teams-panel__file-chip {
    display: flex;
    align-items: center;
    gap: 8px;
    background: #fff;
    border: 1px solid #e9ecef;
    border-radius: 10px;
    padding: 6px 10px;
    font-size: 12.5px;
    max-width: 200px;
    position: relative;
}
.teams-panel__file-chip-name {
    font-weight: 600;
    color: #1e1e2d;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 120px;
}
.teams-panel__file-chip-size {
    font-size: 11px;
    color: #adb5bd;
}
.teams-panel__file-chip-remove {
    position: absolute;
    top: -5px;
    right: -5px;
    width: 16px;
    height: 16px;
    background: #6c757d;
    color: #fff;
    border-radius: 50%;
    border: none;
    font-size: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    line-height: 1;
}
.teams-panel__file-chip-remove:hover {
    background: #dc3545;
}
.teams-panel__input-row {
    display: flex;
    gap: 8px;
    align-items: flex-end;
}
.teams-panel__input {
    flex: 1;
    border: 1px solid #e9ecef;
    border-radius: 12px;
    padding: 9px 14px;
    font-size: 13.5px;
    resize: none;
    outline: none;
    min-height: 40px;
    max-height: 120px;
    overflow-y: auto;
    line-height: 1.5;
    transition: border-color 0.15s;
    font-family: inherit;
}
.teams-panel__input:focus {
    border-color: var(--tp-primary);
}
.teams-panel__send-btn {
    width: 40px;
    height: 40px;
    background: var(--tp-primary);
    border: none;
    border-radius: 12px;
    color: #fff;
    font-size: 17px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s;
    flex-shrink: 0;
}
.teams-panel__send-btn:hover {
    background: #2d46c0;
}

/* Load older messages bar */
.teams-panel__load-more-bar {
    text-align: center;
    padding: 8px 0 4px;
}
.teams-panel__load-more-bar button {
    background: none;
    border: 1px solid #d6dcfb;
    border-radius: 20px;
    color: var(--tp-primary);
    font-size: 12px;
    padding: 4px 14px;
    cursor: pointer;
    transition: background 0.15s;
}
.teams-panel__load-more-bar button:hover {
    background: var(--tp-primary-soft);
}

/* System events (calls, membership changes) */
.teams-panel__system-event {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin: 6px 0;
    font-size: 11.5px;
    color: #6c757d;
}
.teams-panel__system-event span:first-child {
    background: #f0f2f5;
    border-radius: 20px;
    padding: 3px 10px;
}
.teams-panel__system-time {
    color: #adb5bd;
    font-size: 11px;
}

/* Message loader */
.teams-panel__msg-loader {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 12px 0;
    background: #fff;
}
.teams-panel__msg-spinner {
    width: 32px;
    height: 32px;
    border: 3px solid #dee2e6;
    border-top-color: #3a57e8;
    border-radius: 50%;
    animation: teams-spin 0.7s linear infinite;
}
@keyframes teams-spin {
    to {
        transform: rotate(360deg);
    }
}

/* Scrollbar */
.teams-panel__messages::-webkit-scrollbar,
.teams-panel__conv-items::-webkit-scrollbar {
    width: 5px;
}
.teams-panel__messages::-webkit-scrollbar-track,
.teams-panel__conv-items::-webkit-scrollbar-track {
    background: transparent;
}
.teams-panel__messages::-webkit-scrollbar-thumb,
.teams-panel__conv-items::-webkit-scrollbar-thumb {
    background: #dee2e6;
    border-radius: 10px;
}

/* Responsive */
@media (max-width: 768px) {
    .teams-panel {
        width: 100%;
    }
    .teams-panel__conv-list {
        width: 240px;
    }
}

.teams-panel__msg-bubble a {
    color: var(--tp-primary);
}

.teams-panel__msg-bubble a:hover {
    text-decoration: underline;
}

.teams-panel__msg-group--outgoing .teams-panel__msg-bubble a {
    color: #ffffff;
}

.teams-panel__msg-group--outgoing .teams-panel__msg-bubble a:hover {
    text-decoration: underline;
}
