.floating-chat-panel {
    position: fixed;
    right: 30px;
    bottom: 95px;
    width: 370px;
    max-width: calc(100vw - 24px);
    height: 540px;
    max-height: calc(100vh - 110px);
    background: #ffffff;
    border: 1px solid #dbe3ee;
    border-radius: 18px;
    box-shadow: 0 20px 48px rgba(15, 23, 42, 0.2);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    transform: translateY(12px) scale(0.96);
    pointer-events: none;
    transition: opacity 0.22s ease, transform 0.22s ease;
    z-index: 104;
    padding: 0 !important;
    margin: 0 !important;
    box-sizing: border-box;
}

.floating-chat-panel::before {
    content: '';
    position: absolute;
    inset: 0;
    background-image: linear-gradient(rgba(148, 163, 184, 0.12) 1px, transparent 1px), linear-gradient(90deg, rgba(148, 163, 184, 0.12) 1px, transparent 1px);
    background-size: 28px 28px;
    opacity: 0.2;
    pointer-events: none;
}

.floating-chat-panel.open {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

.floating-chat-btn.active {
    background: linear-gradient(135deg, #22c55e, #16a34a);
}

.floating-chat-btn {
    overflow: visible;
}

.floating-chat-unread {
    position: absolute;
    top: -5px;
    right: -6px;
    min-width: 20px;
    height: 20px;
    border-radius: 999px;
    padding: 0 6px;
    background: #ef4444;
    color: #fff;
    font-size: 0.72rem;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 2px solid #fff;
}

.floating-chat-panel.shifted-up {
    bottom: 155px;
}

.chat-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem;
    background: linear-gradient(135deg, #f8fbff 0%, #edf3fb 100%);
    border-bottom: 1px solid #d8e1ec;
    position: relative;
    z-index: 1;
}

.chat-panel-header h4 {
    margin: 0;
    color: #1e293b;
    font-size: 1.02rem;
    font-weight: 700;
}

.chat-panel-header p {
    margin: 0.2rem 0 0;
    color: #2563eb;
    font-size: 0.78rem;
}

.chat-panel-header p.is-ok {
    color: #16a34a;
}

.chat-panel-header p.is-error {
    color: #dc2626;
}

.chat-close-btn {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    border: 1px solid #cfd8e3;
    background: #ffffff;
    color: #475569;
    cursor: pointer;
    transition: all 0.18s ease;
}

.chat-close-btn:hover {
    color: #0f172a;
    border-color: #94a3b8;
    transform: translateY(-1px);
}

.chat-room-tabs {
    display: flex;
    gap: 0.45rem;
    padding: 0.65rem 0.75rem;
    background: #f8fafc;
    border-bottom: 1px solid #e2e8f0;
    overflow-x: auto;
    position: relative;
    z-index: 1;
}

.chat-room-tabs::-webkit-scrollbar {
    height: 4px;
}

.chat-room-tabs::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 20px;
}

.chat-room-tab {
    border: 1px solid #cbd5e1;
    background: #ffffff;
    color: #334155;
    padding: 0.42rem 0.78rem;
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}

.chat-room-tab:hover {
    border-color: #60a5fa;
    color: #1d4ed8;
}

.chat-room-tab.active {
    border-color: #22c55e;
    background: #ecfdf5;
    color: #15803d;
}

.chat-room-tab.is-locked {
    border-color: #f59e0b;
    background: #fffbeb;
    color: #b45309;
}

.chat-room-tab.is-locked::after {
    content: '\f023';
    font-family: 'Font Awesome 5 Free';
    font-weight: 900;
    font-size: 0.68rem;
}

.chat-tab-unread {
    min-width: 18px;
    height: 18px;
    border-radius: 999px;
    background: #ef4444;
    color: #fff;
    font-size: 0.68rem;
    font-weight: 700;
    line-height: 18px;
    text-align: center;
    padding: 0 5px;
}

.chat-ticket-list {
    border-bottom: 1px solid #e2e8f0;
    background: #fff;
    max-height: 152px;
    overflow-y: auto;
    padding: 0.45rem;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    position: relative;
    z-index: 1;
}

.chat-ticket-list::-webkit-scrollbar {
    width: 6px;
}

.chat-ticket-list::-webkit-scrollbar-thumb {
    background: #c9d7e7;
    border-radius: 10px;
}

.chat-ticket-item {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.55rem;
    border: 1px solid #d7e2ee;
    border-radius: 10px;
    background: #f8fbff;
    padding: 0.5rem 0.55rem;
    cursor: pointer;
    text-align: left;
    transition: all 0.16s ease;
}

.chat-ticket-row {
    display: flex;
    align-items: stretch;
    gap: 0.4rem;
}

.chat-ticket-row .chat-ticket-item {
    flex: 1;
}

.chat-ticket-item:hover,
.chat-ticket-item.active {
    border-color: #60a5fa;
    background: #eef6ff;
}

.chat-ticket-delete {
    flex: 0 0 38px;
    width: 38px;
    border: 1px solid #fecdd3;
    border-radius: 10px;
    background: #fff1f2;
    color: #e11d48;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.16s ease;
}

.chat-ticket-delete:hover {
    background: #ffe4e6;
    border-color: #fb7185;
    transform: translateY(-1px);
}

.chat-ticket-main {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    overflow: hidden;
}

.chat-ticket-heading {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    min-width: 0;
}

.chat-ticket-main strong {
    font-size: 0.78rem;
    color: #0f172a;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-ticket-main span {
    font-size: 0.72rem;
    color: #64748b;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-ticket-unread {
    min-width: 18px;
    height: 18px;
    border-radius: 999px;
    background: #ef4444;
    color: #fff;
    font-size: 0.67rem;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 5px;
}

.chat-ticket-empty {
    font-size: 0.84rem;
    color: #64748b;
    text-align: center;
    padding: 0.5rem 0.35rem;
}

.chat-messages {
    flex: 1;
    padding: 0.75rem;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 0.55rem;
    justify-content: flex-start;
    position: relative;
    z-index: 1;
}

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

.chat-messages::-webkit-scrollbar-track {
    background: #eef2f7;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: #bfd0e2;
    border-radius: 8px;
}

.chat-empty-state {
    margin: 0;
    text-align: center;
    font-size: 0.91rem;
    color: #64748b;
    padding: 0.9rem 0.5rem;
}

.chat-message {
    max-width: 88%;
    padding: 0.65rem 0.72rem;
    border-radius: 12px;
    background: #ffffff;
    border: 1px solid #d8e4f0;
    color: #1f2937;
    line-height: 1.4;
    box-shadow: 0 4px 12px rgba(15, 23, 42, 0.06);
}

.chat-message.mine {
    margin-left: auto;
    background: linear-gradient(135deg, #2563eb, #3b82f6);
    border-color: #1d4ed8;
    color: #eff6ff;
}

.chat-message-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.65rem;
    margin-bottom: 0.32rem;
    font-size: 0.72rem;
}

.chat-message-sender-wrap {
    display: flex;
    align-items: center;
    gap: 0.42rem;
    min-width: 0;
}

.chat-message-sender {
    font-weight: 700;
    color: #1e3a8a;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-message.mine .chat-message-sender {
    color: #dbeafe;
}

.chat-plan-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.28rem;
    border-radius: 999px;
    padding: 0.18rem 0.5rem;
    font-size: 0.64rem;
    font-weight: 700;
    white-space: nowrap;
    border: 1px solid transparent;
}

.chat-plan-badge i {
    font-size: 0.62rem;
}

.chat-plan-badge.is-compact {
    padding: 0.15rem 0.42rem;
    font-size: 0.6rem;
}

.chat-plan-badge.is-free {
    background: #f1f5f9;
    border-color: #cbd5e1;
    color: #475569;
}

.chat-plan-badge.is-premium {
    background: #dbeafe;
    border-color: #93c5fd;
    color: #1d4ed8;
}

.chat-plan-badge.is-vip {
    background: #fef3c7;
    border-color: #fcd34d;
    color: #92400e;
}

.chat-plan-badge.is-admin {
    background: #ede9fe;
    border-color: #c4b5fd;
    color: #6d28d9;
}

.chat-message.mine .chat-plan-badge {
    background: rgba(255, 255, 255, 0.14);
    border-color: rgba(191, 219, 254, 0.35);
    color: #eff6ff;
}

.chat-message-time {
    color: #64748b;
    flex-shrink: 0;
}

.chat-message.mine .chat-message-time {
    color: rgba(219, 234, 254, 0.86);
}

.chat-message-body {
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
    word-break: break-word;
    font-size: 0.87rem;
}

.chat-message-text {
    word-break: break-word;
    font-size: 0.87rem;
}

.chat-message-reply-preview {
    border-left: 3px solid #60a5fa;
    background: #f8fbff;
    border-radius: 10px;
    padding: 0.45rem 0.55rem;
    display: flex;
    flex-direction: column;
    gap: 0.16rem;
}

.chat-message.mine .chat-message-reply-preview {
    background: rgba(219, 234, 254, 0.18);
    border-left-color: #bfdbfe;
}

.chat-message-reply-name {
    font-size: 0.7rem;
    font-weight: 700;
    color: #2563eb;
}

.chat-message.mine .chat-message-reply-name {
    color: #eff6ff;
}

.chat-message-reply-text {
    font-size: 0.78rem;
    color: #475569;
}

.chat-message.mine .chat-message-reply-text {
    color: rgba(239, 246, 255, 0.9);
}

.chat-message-footer {
    margin-top: 0.5rem;
    display: flex;
    justify-content: space-between;
    gap: 0.5rem;
    align-items: center;
}

.chat-message-meta {
    min-height: 18px;
    display: inline-flex;
    align-items: center;
}

.chat-message-edited {
    font-size: 0.68rem;
    color: #64748b;
    font-weight: 600;
}

.chat-message.mine .chat-message-edited {
    color: rgba(219, 234, 254, 0.86);
}

.chat-message-actions {
    display: inline-flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 0.3rem;
}

.chat-message-action {
    border: 1px solid #d4deea;
    background: #ffffff;
    color: #334155;
    border-radius: 999px;
    padding: 0.24rem 0.55rem;
    font-size: 0.68rem;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 0.28rem;
    cursor: pointer;
    transition: all 0.18s ease;
}

.chat-message-action:hover {
    border-color: #60a5fa;
    color: #1d4ed8;
}

.chat-message-action.is-danger:hover {
    border-color: #f87171;
    color: #dc2626;
}

.chat-message.mine .chat-message-action {
    background: rgba(255, 255, 255, 0.14);
    border-color: rgba(191, 219, 254, 0.35);
    color: #eff6ff;
}

.chat-message.mine .chat-message-action:hover {
    background: rgba(255, 255, 255, 0.2);
}

.chat-message.mine .chat-message-action.is-danger:hover {
    border-color: rgba(254, 202, 202, 0.85);
    color: #fee2e2;
}

.chat-input-wrapper {
    padding: 0.72rem;
    border-top: 1px solid #e2e8f0;
    background: #f8fafc;
    display: flex;
    flex-direction: column;
    gap: 0.55rem;
    position: relative;
    z-index: 1;
    margin: 0;
}

.chat-composer-state[hidden] {
    display: none !important;
}

.chat-composer-pill {
    border-radius: 12px;
    padding: 0.62rem 0.72rem;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.75rem;
    border: 1px solid #d7e2ee;
    background: #ffffff;
}

.chat-composer-pill.is-replying {
    border-left: 4px solid #22c55e;
}

.chat-composer-pill.is-editing {
    border-left: 4px solid #2563eb;
}

.chat-composer-pill.is-locked {
    border-left: 4px solid #f59e0b;
    background: linear-gradient(135deg, #fffaf0, #ffffff);
    flex-direction: column;
    align-items: stretch;
}

.chat-composer-copy {
    display: flex;
    flex-direction: column;
    gap: 0.14rem;
    min-width: 0;
}

.chat-composer-copy strong {
    font-size: 0.74rem;
    color: #0f172a;
}

.chat-composer-copy span {
    font-size: 0.78rem;
    color: #64748b;
    white-space: normal;
    overflow: visible;
    text-overflow: unset;
    line-height: 1.45;
}

.chat-composer-cancel {
    width: 28px;
    height: 28px;
    border-radius: 999px;
    border: 1px solid #d7e2ee;
    background: #ffffff;
    color: #475569;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.16s ease;
}

.chat-composer-cancel:hover {
    border-color: #94a3b8;
    color: #0f172a;
}

.chat-composer-actions {
    display: inline-flex;
    align-items: center;
    gap: 0.6rem;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.chat-composer-action-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: none;
    border-radius: 999px;
    padding: 0.48rem 0.8rem;
    background: linear-gradient(135deg, #2563eb, #3b82f6);
    color: #eff6ff;
    font-size: 0.72rem;
    font-weight: 700;
    cursor: pointer;
    transition: transform 0.16s ease, filter 0.16s ease;
    text-align: center;
    min-height: 36px;
}

.chat-composer-pill.is-locked .chat-composer-actions {
    width: 100%;
    justify-content: stretch;
}

.chat-composer-pill.is-locked .chat-composer-action-btn {
    flex: 1 1 145px;
    padding: 0.72rem 1rem;
    font-size: 0.78rem;
}

.chat-composer-action-btn.is-secondary {
    background: #ffffff;
    color: #334155;
    border: 1px solid #d7e2ee;
}

.chat-composer-action-btn:hover {
    transform: translateY(-1px);
    filter: brightness(1.04);
}

.chat-input-row {
    display: flex;
    gap: 0.55rem;
}

.chat-input-wrapper input {
    flex: 1;
    background: #ffffff;
    border: 1px solid #cbd5e1;
    border-radius: 12px;
    color: #0f172a;
    padding: 0.7rem 0.78rem;
    font-size: 0.86rem;
}

.chat-input-wrapper input:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}

.chat-input-wrapper input::placeholder {
    color: #94a3b8;
}

.chat-input-wrapper button {
    width: 42px;
    border: none;
    border-radius: 10px;
    background: linear-gradient(135deg, #22c55e, #16a34a);
    color: #f0fdf4;
    cursor: pointer;
    transition: transform 0.16s ease, filter 0.16s ease;
}

.chat-input-wrapper button:hover {
    transform: translateY(-1px);
    filter: brightness(1.06);
}

.chat-input-wrapper button:disabled,
.chat-input-wrapper input:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

.chat-confirm-overlay {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.42);
    backdrop-filter: blur(5px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.18s ease;
    z-index: 5;
}

.chat-confirm-overlay.visible {
    opacity: 1;
    pointer-events: auto;
}

.chat-confirm-dialog {
    width: min(360px, 100%);
    background: #ffffff;
    border-radius: 18px;
    border: 1px solid #dbe3ee;
    box-shadow: 0 18px 36px rgba(15, 23, 42, 0.2);
    padding: 1.2rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    text-align: center;
    align-items: center;
}

.chat-confirm-icon {
    width: 48px;
    height: 48px;
    border-radius: 14px;
    background: linear-gradient(135deg, #fee2e2, #fecaca);
    color: #dc2626;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    margin: 0 auto;
}

.chat-confirm-copy h5 {
    margin: 0 0 0.35rem;
    color: #0f172a;
    font-size: 1rem;
}

.chat-confirm-copy p {
    margin: 0;
    color: #475569;
    font-size: 0.86rem;
    line-height: 1.5;
}

.chat-confirm-actions {
    display: flex;
    justify-content: center;
    gap: 0.55rem;
    width: 100%;
    flex-wrap: wrap;
}

.chat-confirm-btn {
    border-radius: 10px;
    padding: 0.68rem 1rem;
    font-size: 0.8rem;
    font-weight: 700;
    border: 1px solid transparent;
    cursor: pointer;
    transition: all 0.18s ease;
    min-width: 142px;
    min-height: 44px;
    flex: 1 1 142px;
}

.chat-confirm-btn.is-secondary {
    background: #ffffff;
    border-color: #cbd5e1;
    color: #334155;
}

.chat-confirm-btn.is-primary {
    background: #2563eb;
    color: #eff6ff;
}

.chat-confirm-btn.is-danger {
    background: #dc2626;
    color: #fff7f7;
}

.chat-confirm-btn:hover {
    transform: translateY(-1px);
    filter: brightness(1.03);
}

@media (max-width: 768px) {
    .floating-chat-panel {
        right: 12px;
        bottom: 86px;
        width: calc(100vw - 24px);
        height: min(510px, calc(100vh - 110px));
    }

    .floating-chat-panel.shifted-up {
        bottom: 145px;
    }

    .chat-message {
        max-width: 92%;
    }

    .chat-composer-actions {
        width: 100%;
        justify-content: flex-start;
    }
}
