/* Organization Chat Widget */

.org-chat-bubble {
    position: fixed;
    bottom: 24px;
    right: 16px;
    width: 50px;
    height: 50px;
    border-radius: 9999px;
    background: var(--umak-blue, #001035);
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    box-shadow: 0 8px 22px rgba(0, 16, 53, 0.28);
    cursor: grab;
    transition: left 0.3s ease, right 0.3s ease, bottom 0.1s ease, transform 0.15s ease;
    -webkit-tap-highlight-color: transparent;
    touch-action: none;
    user-select: none;
}

.org-chat-bubble:active,
.org-chat-bubble.dragging {
    cursor: grabbing;
    transform: scale(1.08);
}

.org-chat-bubble:hover {
    transform: translateY(-1px) scale(1.03);
}

.org-chat-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 9999px;
    background: #ef4444;
    color: #ffffff;
    font-family: "Metropolis", "Inter", system-ui, sans-serif;
    font-size: 9px;
    font-weight: 900;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.org-chat-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.4);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 999;
}

.org-chat-panel {
    position: fixed;
    z-index: 1001;
    overflow: hidden;
    font-family: "Metropolis", "Inter", system-ui, sans-serif;
    background: #ffffff;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.24s ease, transform 0.24s ease;
}

.org-chat-panel.open {
    opacity: 1;
    pointer-events: auto;
}

.org-chat-inbox,
.org-chat-thread {
    min-height: 0;
}

.org-chat-inbox {
    display: flex;
    flex-direction: column;
    border-right: 1px solid #e2e8f0;
    background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
}

.org-chat-thread {
    display: flex;
    flex-direction: column;
    min-width: 0;
    background: #ffffff;
}

.org-chat-inbox-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 14px 10px;
    border-bottom: 1px solid #eef2f7;
}

.org-chat-inbox-title {
    font-size: 12px;
    font-weight: 900;
    color: #0f172a;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.org-chat-mobile-close {
    width: 30px;
    height: 30px;
    border: none;
    border-radius: 8px;
    color: #64748b;
    background: #f1f5f9;
    display: none;
    align-items: center;
    justify-content: center;
}

.org-chat-mobile-close:hover {
    color: #1e293b;
    background: #e2e8f0;
}

.org-chat-tabs {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 10px;
    overflow-y: auto;
    flex: 1;
}

.org-chat-tab {
    width: 100%;
    border: 1px solid #e2e8f0;
    border-radius: 14px;
    background: #ffffff;
    cursor: pointer;
    text-align: left;
    padding: 10px;
    display: grid;
    grid-template-columns: 34px minmax(0, 1fr) auto;
    gap: 10px;
    align-items: center;
    transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.org-chat-tab:hover {
    border-color: #cbd5e1;
    box-shadow: 0 3px 12px rgba(15, 23, 42, 0.08);
}

.org-chat-tab.active {
    border-color: rgba(49, 108, 255, 0.4);
    background: #eef5ff;
    box-shadow: 0 4px 12px rgba(49, 108, 255, 0.18);
}

.org-chat-tab-avatar {
    width: 34px;
    height: 34px;
    border-radius: 10px;
    object-fit: cover;
    border: 1px solid #dbe3ef;
}

.org-chat-tab-copy {
    min-width: 0;
}

.org-chat-tab-name {
    font-size: 12px;
    font-weight: 800;
    color: #0f172a;
    line-height: 1.25;
    margin-bottom: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.org-chat-tab-preview {
    display: block;
    font-size: 11px;
    color: #64748b;
    line-height: 1.25;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.org-chat-tab-time {
    font-size: 10px;
    color: #94a3b8;
    font-weight: 700;
    white-space: nowrap;
}

.org-chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 12px 14px;
    border-bottom: 1px solid #eef2f7;
    flex-shrink: 0;
}

.org-chat-header-actions {
    display: flex;
    align-items: center;
    gap: 4px;
}

.org-chat-header-btn,
.org-chat-inbox-toggle {
    width: 32px;
    height: 32px;
    border-radius: 10px;
    border: none;
    color: #64748b;
    background: transparent;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: color 0.15s ease, background 0.15s ease;
}

.org-chat-header-btn:hover,
.org-chat-inbox-toggle:hover {
    color: #0f172a;
    background: #f1f5f9;
}

.org-chat-inbox-toggle {
    display: none;
    margin-right: -2px;
}

.org-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 12px 14px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.org-chat-messages::-webkit-scrollbar {
    width: 6px;
}

.org-chat-messages::-webkit-scrollbar-track {
    background: transparent;
}

.org-chat-messages::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 999px;
}

.org-msg-group {
    margin-top: 8px;
}

.org-msg-group:first-child {
    margin-top: 0;
}

.org-msg-group-continuation {
    margin-top: 4px;
}

.org-msg-other {
    display: flex;
    gap: 8px;
    align-items: flex-start;
    max-width: 88%;
}

.org-msg-other .org-msg-bubble {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 14px;
    padding: 9px 12px;
    font-size: 13px;
    font-weight: 500;
    color: #334155;
    line-height: 1.5;
    position: relative;
}

.org-msg-other .org-msg-avatar {
    width: 28px;
    height: 28px;
    border-radius: 8px;
    object-fit: cover;
    flex-shrink: 0;
}

.org-msg-other .org-msg-name {
    font-size: 11px;
    font-weight: 800;
    color: #0f172a;
    margin-bottom: 2px;
}

.org-msg-own {
    display: flex;
    justify-content: flex-end;
    max-width: 88%;
    margin-left: auto;
}

.org-msg-own .org-msg-bubble {
    background: var(--umak-blue, #001035);
    color: #ffffff;
    border-radius: 14px;
    padding: 9px 12px;
    font-size: 13px;
    font-weight: 500;
    line-height: 1.5;
}

.org-msg-time {
    font-size: 10px;
    color: #94a3b8;
    font-weight: 600;
    margin-top: 3px;
    padding: 0 3px;
    display: none;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.org-msg-time.visible {
    display: block;
    opacity: 1;
}

.org-msg-own .org-msg-time {
    text-align: right;
}

.org-msg-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 2px;
    margin-top: 4px;
    opacity: 0;
    transition: opacity 0.15s ease;
}

.org-msg-bubble:hover .org-msg-actions,
.org-msg-group:hover .org-msg-actions {
    opacity: 1;
}

.org-msg-action-btn {
    width: 26px;
    height: 26px;
    border-radius: 8px;
    border: none;
    background: transparent;
    color: #94a3b8;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.15s ease, background 0.15s ease;
}

.org-msg-action-btn:hover {
    background: rgba(0, 0, 0, 0.05);
    color: #475569;
}

.org-msg-like-btn:hover,
.org-msg-del-btn:hover {
    color: #ef4444;
    background: rgba(239, 68, 68, 0.08);
}

.org-msg-own .org-msg-action-btn {
    color: rgba(255, 255, 255, 0.55);
}

.org-msg-own .org-msg-action-btn:hover {
    color: #ffffff;
    background: rgba(255, 255, 255, 0.16);
}

.org-chat-composer {
    padding: 11px 14px;
    border-top: 1px solid #eef2f7;
    flex-shrink: 0;
    background: #ffffff;
    padding-bottom: max(11px, env(safe-area-inset-bottom));
}

.org-chat-attach-btn {
    width: 36px;
    height: 36px;
    border-radius: 11px;
    border: none;
    background: #f1f5f9;
    color: #64748b;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 0.15s ease, color 0.15s ease;
}

.org-chat-attach-btn:hover {
    background: #e2e8f0;
    color: #334155;
}

.org-chat-textarea {
    flex: 1;
    min-height: 36px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 8px 10px;
    font-family: "Metropolis", "Inter", system-ui, sans-serif;
    font-size: 16px;
    font-weight: 500;
    color: #334155;
    outline: none;
    resize: none;
    max-height: 120px;
    overflow-y: auto;
    line-height: 1.45;
    width: 100%;
}

.org-chat-textarea::placeholder {
    color: #94a3b8;
}

.org-chat-textarea:focus {
    border-color: rgba(49, 108, 255, 0.45);
    box-shadow: 0 0 0 2px rgba(49, 108, 255, 0.12);
}

.org-chat-send-btn {
    width: 36px;
    height: 36px;
    border-radius: 11px;
    background: var(--umak-blue, #001035);
    color: #ffffff;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
    transition: background 0.15s ease, transform 0.1s ease;
}

.org-chat-send-btn:hover {
    background: var(--umak-blue-bright, #316cff);
}

.org-chat-send-btn:active {
    transform: scale(0.95);
}

.org-chat-send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.org-chat-attachment-preview {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    margin: 0 0 8px;
    background: #f1f5f9;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 700;
    color: #475569;
}

.org-chat-attachment-preview .attachment-name {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.org-chat-attachment-preview .attachment-remove {
    width: 20px;
    height: 20px;
    border-radius: 6px;
    border: none;
    background: transparent;
    color: #94a3b8;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.org-chat-attachment-preview .attachment-remove:hover {
    color: #ef4444;
    background: #fee2e2;
}

.org-msg-link-embed {
    margin-top: 6px;
    padding: 8px 10px;
    background: rgba(0, 0, 0, 0.04);
    border-left: 3px solid var(--umak-blue, #001035);
    border-radius: 0 8px 8px 0;
    font-size: 11px;
    line-height: 1.35;
}

.org-msg-link-embed a {
    color: var(--umak-blue-bright, #316cff);
    font-weight: 700;
    text-decoration: none;
    word-break: break-all;
}

.org-msg-link-embed a:hover {
    text-decoration: underline;
}

.org-msg-own .org-msg-link-embed {
    background: rgba(255, 255, 255, 0.15);
    border-left-color: rgba(255, 255, 255, 0.45);
}

.org-msg-own .org-msg-link-embed a {
    color: #bfdbfe;
}

.org-msg-gdrive-embed img {
    transition: opacity 0.2s ease;
}

.org-msg-gdrive-embed img:hover {
    opacity: 0.85;
}

.org-msg-gdrive-embed a:hover {
    color: var(--umak-blue-bright, #316cff) !important;
}

@media (max-width: 767px) {
    .org-chat-backdrop {
        display: block;
    }

    .org-chat-panel {
        left: 0;
        right: 0;
        bottom: 0;
        height: min(92vh, 760px);
        border-radius: 18px 18px 0 0;
        border-top: 1px solid #dbe3ef;
        box-shadow: 0 -12px 36px rgba(15, 23, 42, 0.2);
        transform: translateY(100%);
        display: block;
    }

    .org-chat-panel.open {
        transform: translateY(0);
    }

    .org-chat-panel.show-inbox .org-chat-thread {
        display: none;
    }

    .org-chat-panel.show-thread .org-chat-inbox {
        display: none;
    }

    .org-chat-inbox {
        height: 100%;
        border-right: none;
    }

    .org-chat-thread {
        height: 100%;
    }

    .org-chat-mobile-close {
        display: inline-flex;
    }

    .org-chat-inbox-toggle {
        display: inline-flex;
    }
}

@media (min-width: 768px) {
    .org-chat-backdrop {
        display: none !important;
    }

    .org-chat-panel {
        right: 16px;
        bottom: 80px;
        width: min(860px, calc(100vw - 32px));
        height: min(560px, calc(100vh - 100px));
        border-radius: 16px;
        border: 1px solid #dbe3ef;
        box-shadow: 0 16px 44px rgba(15, 23, 42, 0.18);
        background: #ffffff;
        display: grid;
        grid-template-columns: minmax(240px, 280px) minmax(0, 1fr);
        transform: translateY(10px) scale(0.98);
        transition: opacity 0.2s ease, transform 0.2s ease, width 0.28s ease, height 0.28s ease;
    }

    .org-chat-panel.maximized {
        width: calc(100vw - 32px);
        height: calc(100vh - 32px);
        right: 16px;
        bottom: 16px;
        border-radius: 18px;
        grid-template-columns: minmax(260px, 320px) minmax(0, 1fr);
    }

    .org-chat-panel.open {
        transform: translateY(0) scale(1);
    }

    .org-chat-textarea {
        font-size: 14px;
    }
}

[data-theme="dark"] .org-chat-bubble {
    background: var(--umak-blue, #1a2744);
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.45);
}

[data-theme="dark"] .org-chat-panel {
    background: #0f172a;
    border-color: #334155;
}

[data-theme="dark"] .org-chat-inbox {
    background: linear-gradient(180deg, #0f172a 0%, #111c32 100%);
    border-color: #334155;
}

[data-theme="dark"] .org-chat-thread,
[data-theme="dark"] .org-chat-composer {
    background: #0f172a;
}

[data-theme="dark"] .org-chat-inbox-header,
[data-theme="dark"] .org-chat-header,
[data-theme="dark"] .org-chat-composer {
    border-color: #334155;
}

[data-theme="dark"] .org-chat-inbox-title,
[data-theme="dark"] #orgChatOrgName,
[data-theme="dark"] .org-msg-other .org-msg-name {
    color: #e2e8f0;
}

[data-theme="dark"] .org-chat-tab {
    background: #1e293b;
    border-color: #334155;
}

[data-theme="dark"] .org-chat-tab:hover {
    border-color: #475569;
    box-shadow: 0 4px 14px rgba(2, 6, 23, 0.4);
}

[data-theme="dark"] .org-chat-tab.active {
    background: rgba(49, 108, 255, 0.25);
    border-color: rgba(123, 170, 247, 0.45);
}

[data-theme="dark"] .org-chat-tab-name {
    color: #e2e8f0;
}

[data-theme="dark"] .org-chat-tab-preview,
[data-theme="dark"] .org-chat-tab-time,
[data-theme="dark"] #orgChatMemberCount {
    color: #94a3b8;
}

[data-theme="dark"] .org-chat-header-btn,
[data-theme="dark"] .org-chat-inbox-toggle {
    color: #94a3b8;
}

[data-theme="dark"] .org-chat-header-btn:hover,
[data-theme="dark"] .org-chat-inbox-toggle:hover {
    color: #e2e8f0;
    background: #1e293b;
}

[data-theme="dark"] .org-chat-messages::-webkit-scrollbar-thumb {
    background: #475569;
}

[data-theme="dark"] .org-msg-other .org-msg-bubble {
    background: #1e293b;
    border-color: #334155;
    color: #e2e8f0;
}

[data-theme="dark"] .org-msg-own .org-msg-bubble {
    background: var(--umak-blue-bright, #7baaf7);
}

[data-theme="dark"] .org-msg-time {
    color: #64748b;
}

[data-theme="dark"] .org-chat-attach-btn {
    background: #1e293b;
    color: #94a3b8;
}

[data-theme="dark"] .org-chat-attach-btn:hover {
    background: #334155;
    color: #e2e8f0;
}

[data-theme="dark"] .org-chat-textarea {
    background: #1e293b;
    border-color: #334155;
    color: #e2e8f0;
}

[data-theme="dark"] .org-chat-textarea::placeholder {
    color: #64748b;
}

[data-theme="dark"] .org-chat-textarea:focus {
    border-color: rgba(123, 170, 247, 0.45);
    box-shadow: 0 0 0 2px rgba(123, 170, 247, 0.2);
}

[data-theme="dark"] .org-chat-send-btn {
    background: var(--umak-blue-bright, #7baaf7);
}

[data-theme="dark"] .org-msg-action-btn {
    color: #64748b;
}

[data-theme="dark"] .org-msg-action-btn:hover {
    color: #cbd5e1;
    background: rgba(255, 255, 255, 0.08);
}

[data-theme="dark"] .org-chat-backdrop {
    background: rgba(0, 0, 0, 0.6);
}

[data-theme="dark"] .org-chat-attachment-preview {
    background: #1e293b;
    border-color: #334155;
    color: #cbd5e1;
}

[data-theme="dark"] .org-msg-link-embed {
    background: rgba(255, 255, 255, 0.07);
    border-left-color: #7baaf7;
}

[data-theme="dark"] .org-msg-link-embed a {
    color: #7baaf7;
}
