/**
 * Floating Chat Widget Styles
 */

.floating-chat-widget {
    position: fixed !important;
    bottom: 20px !important;
    right: 20px !important;
    z-index: 99999 !important;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
}

/* Floating Toggle Button */
.chat-toggle-btn {
    width: 60px !important;
    height: 60px !important;
    border-radius: 50% !important;
    background: linear-gradient(135deg, #f97316 0%, #ea580c 100%) !important;
    color: white !important;
    border: none !important;
    cursor: pointer !important;
    box-shadow: 0 4px 12px rgba(249, 115, 22, 0.4) !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    font-size: 24px !important;
    transition: all 0.3s ease !important;
    position: relative !important;
    visibility: visible !important;
    opacity: 1 !important;
    z-index: 99999 !important;
}

.chat-toggle-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(249, 115, 22, 0.5);
}

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

/* Badge */
.chat-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #ef4444;
    color: white;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: bold;
    border: 2px solid white;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.1);
    }
}

/* Chat Window */
.chat-window {
    position: absolute;
    bottom: 80px;
    right: 0;
    width: 380px;
    height: 600px;
    max-height: calc(100vh - 100px);
    background: white;
    border-radius: 16px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: slideUp 0.3s ease-out;
}

@keyframes slideUp {
    from {
        opacity: 1 !important;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideDown {
    from {
        opacity: 1;
        transform: translateY(0);
    }
    to {
        opacity: 1 !important;
        transform: translateY(20px);
    }
}

/* Chat Header */
.chat-header {
    background: linear-gradient(135deg, #f97316 0%, #ea580c 100%);
    color: white;
    padding: 16px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.chat-header-info {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
}

.chat-avatar {
    width: 40px;
    height: 40px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
}

.chat-header-info h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
}

.chat-status {
    margin: 0;
    font-size: 12px;
    opacity: 0.9;
    display: flex;
    align-items: center;
    gap: 6px;
}

.status-dot {
    width: 8px;
    height: 8px;
    background: #10b981;
    border-radius: 50%;
    display: inline-block;
    animation: blink 2s infinite;
}

@keyframes blink {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

.chat-header-actions {
    display: flex;
    gap: 8px;
}

.chat-btn-icon {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

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

/* Messages Container */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: #f9fafb;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

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

.chat-messages::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 10px;
}

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

.chat-messages::-webkit-scrollbar-thumb:hover {
    background: #ea580c;
}

/* Welcome Message */
.chat-welcome {
    text-align: center;
    padding: 40px 20px;
    color: #6b7280;
}

.welcome-icon {
    width: 64px;
    height: 64px;
    background: #fef3c7;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 16px;
    font-size: 32px;
    color: #f97316;
}

.chat-welcome h4 {
    margin: 0 0 8px;
    color: #374151;
    font-size: 18px;
}

.chat-welcome p {
    margin: 0;
    font-size: 14px;
    line-height: 1.5;
}

/* Chat Messages */
.chat-message {
    position: relative !important;
    overflow: visible !important;
    display: flex;
    margin-bottom: 8px;
    animation: fadeInUp 0.3s ease-out;
}

@keyframes fadeInUp {
    from {
        opacity: 1 !important;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.chat-message-user {
    justify-content: flex-end;
}

.chat-message-admin {
    justify-content: flex-start;
}

.chat-message-content {
    position: relative !important;
    overflow: visible !important;
    max-width: 75%;
    padding: 12px 16px;
    border-radius: 18px;
    position: relative;
    display: flex;
    flex-direction: column;
}

.chat-message-user .chat-message-content {
    background: linear-gradient(135deg, #f97316 0%, #ea580c 100%);
    color: white;
    border-bottom-right-radius: 4px;
}

.chat-message-admin .chat-message-content {
    background: white;
    color: #374151;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    border-bottom-left-radius: 4px;
}

.chat-message-content p {
    margin: 0;
    font-size: 14px;
    line-height: 1.5;
    word-wrap: break-word;
}

.chat-message-time {
    display: block;
    font-size: 11px;
    margin-top: 4px;
    opacity: 0.7;
}

/* Message Menu Button */
.chat-message-menu-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 24px;
    height: 24px;
    background: transparent;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.7 !important;
    transition: opacity 0.2s;
    z-index: 10;
    padding: 0;
    color: inherit;
}

.chat-message-user .chat-message-menu-btn {
    color: rgba(255, 255, 255, 0.7);
}

.chat-message-admin .chat-message-menu-btn {
    color: rgba(55, 65, 81, 0.6);
}

.chat-message-content:hover .chat-message-menu-btn {
    opacity: 1;
}

.chat-message-menu-btn:hover {
    opacity: 1 !important;
}

.chat-message-menu-btn i {
    font-size: 14px;
}

/* Message Dropdown */
.chat-message-dropdown {
    position: absolute;
    top: 32px;
    right: 0;
    background: white;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    min-width: 140px;
    opacity: 1 !important;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.2s ease;
    z-index: 1000;
    overflow: hidden;
}

.chat-message-user .chat-message-dropdown {
    right: 0;
    left: auto;
}

.chat-message-admin .chat-message-dropdown {
    right: auto;
    left: 0;
}

.chat-message-dropdown.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.chat-dropdown-item {
    width: 100%;
    padding: 10px 16px;
    background: transparent;
    border: none;
    text-align: left;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 14px;
    color: #374151;
    transition: background-color 0.2s;
}

.chat-dropdown-item:hover {
    background: #f3f4f6;
}

.chat-dropdown-item i {
    width: 16px;
    font-size: 14px;
    color: #6b7280;
}

.chat-dropdown-item:hover i {
    color: #374151;
}

.chat-dropdown-item[data-action="reply"] i {
    color: #3b82f6;
}

.chat-dropdown-item[data-action="copy"] i {
    color: #10b981;
}

.chat-dropdown-item[data-action="delete"] i {
    color: #ef4444;
}

/* Fade Out Animation */
@keyframes fadeOut {
    from {
        opacity: 1;
        transform: translateY(0);
    }
    to {
        opacity: 1 !important;
        transform: translateY(-10px);
    }
}

/* Toast Notification */
.chat-toast {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: #374151;
    color: white;
    padding: 12px 20px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    font-size: 14px;
    opacity: 1 !important;
    transform: translateY(20px);
    transition: all 0.3s ease;
    z-index: 100000;
    max-width: 300px;
}

.chat-toast.show {
    opacity: 1;
    transform: translateY(0);
}

.chat-toast-success {
    background: #10b981;
}

.chat-toast-error {
    background: #ef4444;
}

/* Reply Preview Box (WhatsApp style) */
.chat-reply-preview {
    padding: 12px 16px;
    background: #f3f4f6;
    border-top: 1px solid #e5e7eb;
    border-bottom: 1px solid #e5e7eb;
}

.chat-reply-preview-content {
    display: flex;
    align-items: center;
    gap: 12px;
    position: relative;
}

.chat-reply-preview-line {
    width: 3px;
    height: 40px;
    background: #8b5cf6;
    border-radius: 2px;
    flex-shrink: 0;
}

.chat-reply-preview-info {
    flex: 1;
    min-width: 0;
}

.chat-reply-preview-name {
    font-size: 13px;
    font-weight: 600;
    color: #8b5cf6;
    margin-bottom: 2px;
}

.chat-reply-preview-text {
    font-size: 13px;
    color: #6b7280;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.chat-reply-preview-close {
    width: 24px;
    height: 24px;
    background: transparent;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #6b7280;
    padding: 0;
    flex-shrink: 0;
    transition: color 0.2s;
}

.chat-reply-preview-close:hover {
    color: #374151;
}

.chat-reply-preview-close i {
    font-size: 14px;
}

/* Message Reply Preview (in message bubble) */
.chat-message-reply {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    margin-bottom: 8px;
    padding: 8px;
    background: rgba(0, 0, 0, 0.1);
    border-radius: 6px;
    border-left: 3px solid rgba(255, 255, 255, 0.5);
}

.chat-message-user .chat-message-reply {
    background: rgba(255, 255, 255, 0.2);
    border-left-color: rgba(255, 255, 255, 0.5);
}

.chat-message-admin .chat-message-reply {
    background: #f3f4f6;
    border-left-color: #8b5cf6;
}

.chat-message-reply-line {
    width: 3px;
    height: 100%;
    background: rgba(255, 255, 255, 0.5);
    border-radius: 2px;
    flex-shrink: 0;
}

.chat-message-admin .chat-message-reply-line {
    background: #8b5cf6;
}

.chat-message-reply-content {
    flex: 1;
    min-width: 0;
}

.chat-message-reply-name {
    font-size: 12px;
    font-weight: 600;
    margin-bottom: 2px;
    color: rgba(255, 255, 255, 0.9);
}

.chat-message-admin .chat-message-reply-name {
    color: #8b5cf6;
}

.chat-message-reply-text {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.8);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.chat-message-admin .chat-message-reply-text {
    color: #6b7280;
}

/* Input Container */
.chat-input-container {
    padding: 16px;
    background: white;
    border-top: 1px solid #e5e7eb;
    display: flex;
    gap: 8px;
    align-items: center;
}

.chat-input {
    flex: 1;
    padding: 12px 16px;
    border: 2px solid #e5e7eb;
    border-radius: 24px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
}

.chat-input:focus {
    border-color: #f97316;
}

.chat-input:disabled {
    background: #f9fafb;
    cursor: not-allowed;
}

.chat-send-btn {
    width: 44px;
    height: 44px;
    background: linear-gradient(135deg, #f97316 0%, #ea580c 100%);
    color: white;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
}

.chat-send-btn:hover:not(:disabled) {
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(249, 115, 22, 0.4);
}

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

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

/* Error Message */
.chat-error {
    background: #fee2e2;
    color: #dc2626;
    padding: 12px;
    border-radius: 8px;
    font-size: 13px;
    text-align: center;
    margin: 8px 0;
}

/* Responsive */
@media (max-width: 480px) {
    .floating-chat-widget {
        bottom: 15px;
        right: 15px;
    }
    
    .chat-window {
        width: calc(100vw - 30px);
        height: calc(100vh - 100px);
        max-height: 600px;
        right: -15px;
        bottom: 80px;
    }
    
    .chat-toggle-btn {
        width: 56px;
        height: 56px;
        font-size: 22px;
    }
}

/* Loading Animation */
.chat-loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: white;
    animation: spin 1s ease-in-out infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}


/* File Upload Styles */
.chat-upload-btn {
    width: 44px;
    height: 44px;
    background: #f3f4f6;
    color: #6b7280;
    border: 2px solid #e5e7eb;
    border-radius: 50%;
    cursor: pointer;
    display: flex !important;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
    font-size: 18px;
    visibility: visible !important;
    opacity: 1 !important;
}

.chat-upload-btn:hover:not(:disabled) {
    background: #e5e7eb;
    color: #374151;
    border-color: #d1d5db;
}

.chat-upload-btn:active:not(:disabled) {
    transform: scale(0.95);
}

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

/* File Preview Container */
.file-preview-container {
    padding: 12px 16px;
    background: #f9fafb;
    border-top: 1px solid #e5e7eb;
    max-height: 150px;
    overflow-y: auto;
}

.file-preview-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
    font-size: 12px;
    color: #6b7280;
    font-weight: 500;
}

.clear-files-btn {
    background: none;
    border: none;
    color: #ef4444;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    transition: background 0.2s;
}

.clear-files-btn:hover {
    background: #fee2e2;
}

.file-preview-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.file-preview-item {
    position: relative;
    display: flex;
    align-items: center;
    gap: 8px;
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 8px;
    max-width: 200px;
    font-size: 12px;
}

.file-preview-image-container {
    width: 48px;
    height: 48px;
    border-radius: 4px;
    overflow: hidden;
    flex-shrink: 0;
    background: #f3f4f6;
}

.file-preview-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.file-preview-icon {
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f3f4f6;
    border-radius: 4px;
    color: #6b7280;
    font-size: 20px;
    flex-shrink: 0;
}

.file-preview-info {
    flex: 1;
    min-width: 0;
}

.file-preview-name {
    font-weight: 500;
    color: #374151;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 2px;
}

.file-preview-size {
    font-size: 11px;
    color: #9ca3af;
}

.file-preview-remove {
    position: absolute;
    top: -6px;
    right: -6px;
    width: 20px;
    height: 20px;
    background: #ef4444;
    color: white;
    border: 2px solid white;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    transition: transform 0.2s;
    flex-shrink: 0;
}

.file-preview-remove:hover {
    transform: scale(1.1);
}

/* Chat Message Files */
.chat-message-files {
    margin-top: 8px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.chat-file-item {
    border-radius: 8px;
    overflow: hidden;
    background: rgba(255, 255, 255, 0.1);
}

.chat-message-user .chat-file-item {
    background: rgba(255, 255, 255, 0.2);
}

.chat-message-admin .chat-file-item {
    background: #f3f4f6;
}

.chat-file-image {
    max-width: 300px;
    margin: 4px 0;
}

.chat-file-image .chat-image-wrapper {
    position: relative;
    display: inline-block;
    width: 100%;
}

.chat-file-image .chat-image-link {
    display: block;
    text-decoration: none;
    color: inherit;
}

.chat-file-image img {
    width: 100%;
    max-width: 100%;
    height: auto;
    display: block;
    border-radius: 8px;
    cursor: pointer;
    transition: transform 0.2s;
    object-fit: contain;
    background: #f5f5f5;
    min-height: 100px;
}

.chat-file-image img:hover {
    transform: scale(1.02);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.chat-file-image .chat-image-download {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.6);
    color: white;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    transition: all 0.2s ease;
    z-index: 10;
    opacity: 1 !important;
    transform: scale(1) !important;
}

.chat-file-image .chat-image-wrapper:hover .chat-image-download {
    opacity: 1;
    transform: scale(1);
}

.chat-file-image .chat-image-download:hover {
    background: rgba(0, 0, 0, 0.8);
    transform: scale(1.1);
}

.chat-file-image .chat-image-download:active {
    transform: scale(0.95);
}

.chat-file-image .chat-file-name {
    display: block;
    margin-top: 6px;
    font-size: 11px;
    opacity: 0.8;
    text-align: center;
    word-break: break-word;
}

.chat-file-document {
    padding: 8px 12px;
}

.chat-file-link {
    display: flex;
    align-items: center;
    gap: 8px;
    color: inherit;
    text-decoration: none;
    transition: opacity 0.2s;
}

.chat-file-link:hover {
    opacity: 0.8;
}

.chat-file-link i {
    font-size: 20px;
    flex-shrink: 0;
}

.chat-file-name {
    font-size: 13px;
    word-break: break-word;
}

.chat-message-user .chat-file-name {
    color: white;
}

.chat-message-admin .chat-file-name {
    color: #374151;
}

/* Scrollbar for file preview */
.file-preview-container::-webkit-scrollbar {
    width: 4px;
}

.file-preview-container::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 10px;
}

.file-preview-container::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 10px;
}

.file-preview-container::-webkit-scrollbar-thumb:hover {
    background: #9ca3af;
}

/* Screen reader only text */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}
