.chat-widget-root {
    direction: rtl;
    font-family: inherit;
}

.chat-fab {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    border: none;
    background: #2563eb;
    color: #fff;
    box-shadow: 0 4px 16px rgba(37, 99, 235, 0.45);
    cursor: pointer;
    z-index: 9998;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.35rem;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.chat-svg-icon {
    width: 1.35em;
    height: 1.35em;
    display: block;
    flex-shrink: 0;
}

.chat-fab .chat-svg-icon {
    width: 26px;
    height: 26px;
}

.chat-panel-actions .chat-svg-icon {
    width: 18px;
    height: 18px;
}

.chat-input-btn .chat-svg-icon,
.chat-send-btn .chat-svg-icon {
    width: 18px;
    height: 18px;
}

.chat-widget-root .fa {
    font-family: FontAwesome !important;
    font-style: normal;
    font-weight: normal;
    line-height: 1;
}

.chat-fab:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 20px rgba(37, 99, 235, 0.55);
}

.chat-fab-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    border-radius: 10px;
    background: #ef4444;
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
}

.chat-panel {
    position: fixed;
    bottom: 92px;
    right: 24px;
    width: 380px;
    max-width: calc(100vw - 32px);
    height: 520px;
    max-height: calc(100vh - 120px);
    background: #f3f4f6;
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.18);
    z-index: 9998;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.chat-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: #fff;
    border-bottom: 1px solid #e5e7eb;
}

.chat-panel-title {
    font-weight: 700;
    font-size: 0.95rem;
    color: #111827;
    margin: 0;
}

.chat-panel-subtitle {
    font-size: 0.75rem;
    color: #6b7280;
    margin: 0;
}

.chat-panel-actions {
    display: flex;
    gap: 8px;
}

.chat-panel-actions button {
    background: none;
    border: none;
    color: #6b7280;
    cursor: pointer;
    padding: 4px;
    border-radius: 6px;
}

.chat-panel-actions button:hover {
    background: #f3f4f6;
    color: #111827;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.chat-message {
    display: flex;
    gap: 8px;
    max-width: 88%;
    align-self: flex-start;
}

.chat-message.mine {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.chat-message-bubble {
    background: #fff;
    border-radius: 12px;
    padding: 10px 14px;
    font-size: 0.875rem;
    line-height: 1.5;
    color: #111827;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
    word-break: break-word;
}

.chat-message.mine .chat-message-bubble {
    background: #2563eb;
    color: #fff;
}

.chat-message-meta {
    font-size: 0.7rem;
    color: #9ca3af;
    margin-top: 4px;
}

.chat-message-author {
    font-weight: 700;
    color: #4b5563;
}

.chat-message.mine .chat-message-author {
    color: #6b7280;
}

.chat-message-badge {
    display: inline-block;
    font-size: 0.65rem;
    font-weight: 700;
    padding: 1px 7px;
    border-radius: 999px;
    background: #f3e8ff;
    color: #7c3aed;
    margin: 0 4px;
    vertical-align: middle;
}

.chat-message.mine .chat-message-meta {
    text-align: left;
}

.chat-messages--page {
    min-height: 360px;
    max-height: 560px;
    background: #f9fafb;
}

.chat-attachment {
    margin-top: 6px;
}

.chat-attachment a {
    color: inherit;
    text-decoration: underline;
    font-size: 0.8rem;
}

.chat-attachments-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 8px;
}

.chat-attachment-thumb {
    display: block;
    width: 72px;
    height: 72px;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid #e5e7eb;
    background: #f9fafb;
    flex-shrink: 0;
    transition: box-shadow 0.15s ease;
}

.chat-attachment-thumb:hover {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
}

.chat-attachment-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.chat-attachment-file-icon {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    color: #4b5563;
    padding: 4px;
    text-align: center;
}

.chat-attachment-file-icon .fa {
    font-size: 1.5rem;
    margin-bottom: 4px;
}

.chat-attachment-ext {
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    color: #6b7280;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.chat-attachment-thumb--pending {
    opacity: 0.85;
    border-style: dashed;
}

.chat-input-bar {
    background: #fff;
    border-top: 1px solid #e5e7eb;
    padding: 12px;
}

.chat-input-row {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 24px;
    padding: 8px 12px;
}

.chat-input-row textarea {
    flex: 1;
    border: none;
    background: transparent;
    resize: none;
    max-height: 100px;
    font-size: 0.875rem;
    outline: none;
    line-height: 1.4;
}

.chat-input-btn {
    background: none;
    border: none;
    color: #6b7280;
    cursor: pointer;
    padding: 4px;
    font-size: 1.1rem;
    flex-shrink: 0;
}

.chat-send-btn {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: none;
    background: #2563eb;
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.chat-send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.chat-pending-files {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 8px;
}

.chat-pending-file {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: #e0e7ff;
    color: #3730a3;
    border-radius: 8px;
    padding: 4px 8px;
    font-size: 0.75rem;
}

.chat-pending-file button {
    background: none;
    border: none;
    cursor: pointer;
    color: #6366f1;
    padding: 0;
    font-size: 0.85rem;
}

.chat-form-step {
    padding: 16px;
    flex: 1;
    overflow-y: auto;
}

.chat-form-step .form-group {
    margin-bottom: 12px;
}

.chat-form-step label {
    display: block;
    font-size: 0.8rem;
    font-weight: 600;
    margin-bottom: 4px;
    color: #374151;
}

.chat-form-step input,
.chat-form-step select,
.chat-form-step textarea {
    width: 100%;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    padding: 8px 12px;
    font-size: 0.875rem;
    background: #fff;
    color: #111827;
}

.chat-form-step textarea {
    min-height: 88px;
    resize: vertical;
    line-height: 1.5;
}

.chat-dept-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.chat-dept-item {
    display: block;
    width: 100%;
    text-align: right;
    padding: 12px;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    background: #fff;
    cursor: pointer;
    transition: border-color 0.15s;
}

.chat-dept-item:hover,
.chat-dept-item.active {
    border-color: #2563eb;
    background: #eff6ff;
}

.chat-ticket-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
}

.chat-ticket-item {
    display: block;
    width: 100%;
    text-align: right;
    padding: 12px;
    border: none;
    border-bottom: 1px solid #e5e7eb;
    background: #fff;
    cursor: pointer;
}

.chat-ticket-item:hover {
    background: #f9fafb;
}

@media (max-width: 480px) {
    .chat-panel {
        right: 16px;
        bottom: 80px;
        width: calc(100vw - 32px);
        height: calc(100vh - 100px);
    }

    .chat-fab {
        right: 16px;
        bottom: 16px;
    }
}
