/* Chat Widget CSS */
/* Author: Keybyte.hu */

/* Chat Widget Base Styles */
.chat-widget-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 99999;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
}

/* Chat Bubble */
.chat-bubble {
    width: 60px;
    height: 60px;
    background: linear-gradient(135deg, #D10024 0%, #a8001d 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(209, 0, 36, 0.4);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

.chat-bubble:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 30px rgba(209, 0, 36, 0.5);
}

.chat-bubble-icon {
    color: white;
    font-size: 24px;
}

.chat-bubble-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #28a745;
    color: white;
    font-size: 12px;
    font-weight: 700;
    min-width: 20px;
    height: 20px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid white;
    animation: pulse 2s infinite;
}

.chat-bubble-pulse {
    position: absolute;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: rgba(209, 0, 36, 0.3);
    animation: pulse-ring 2s infinite;
}

@keyframes pulse-ring {
    0% { transform: scale(1); opacity: 1; }
    100% { transform: scale(1.5); opacity: 0; }
}

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

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

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

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

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

.chat-header-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: white;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.chat-header-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.chat-header-text {
    display: flex;
    flex-direction: column;
}

.chat-header-title {
    font-weight: 600;
    font-size: 15px;
}

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

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #ccc;
}

.status-dot.online {
    background: #4ade80;
    box-shadow: 0 0 8px #4ade80;
}

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

.chat-header-btn {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

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

/* Chat Body */
.chat-body {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: #f8f9fa;
    -webkit-overflow-scrolling: touch;
    scroll-behavior: smooth;
}

/* Start Form */
.chat-start-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.chat-welcome {
    text-align: center;
    margin-bottom: 10px;
}

.chat-welcome-icon {
    font-size: 48px;
    margin-bottom: 8px;
}

.chat-welcome h3 {
    color: #1a1a2e;
    margin: 0 0 4px 0;
    font-size: 20px;
}

.chat-welcome p {
    color: #6c757d;
    margin: 0;
    font-size: 14px;
}

.chat-user-info {
    background: #e8f5e9;
    padding: 12px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    gap: 10px;
    color: #2e7d32;
    font-size: 14px;
}

.chat-form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.chat-form-group label {
    font-size: 13px;
    font-weight: 600;
    color: #495057;
}

.chat-form-group .required {
    color: #D10024;
}

.chat-form-group input,
.chat-form-group textarea {
    padding: 12px;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    font-size: 14px;
    transition: border-color 0.2s, box-shadow 0.2s;
    resize: none;
}

.chat-form-group input:focus,
.chat-form-group textarea:focus {
    outline: none;
    border-color: #D10024;
    box-shadow: 0 0 0 3px rgba(209, 0, 36, 0.1);
}

.chat-form-error {
    background: #fff5f5;
    border: 1px solid #feb2b2;
    color: #c53030;
    padding: 10px 12px;
    border-radius: 8px;
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 8px;
    animation: shakeError 0.4s ease-in-out;
}

.chat-form-error i {
    font-size: 16px;
}

@keyframes shakeError {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

.chat-start-btn {
    background: linear-gradient(135deg, #D10024 0%, #a8001d 100%);
    color: white;
    border: none;
    padding: 14px;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: transform 0.2s, box-shadow 0.2s;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

.chat-start-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(209, 0, 36, 0.3);
}

/* Messages */
.chat-messages {
    display: flex;
    flex-direction: column;
    gap: 12px;
    min-height: 100%;
}

.chat-message {
    display: flex;
    flex-direction: row;
    align-items: flex-end;
    gap: 8px;
    max-width: 85%;
    animation: messageIn 0.3s ease-out;
}

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

.chat-message.user {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.chat-message.admin,
.chat-message.bot,
.chat-message.system {
    align-self: flex-start;
}

/* Chat Message Avatar */
.chat-message-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #e9ecef;
    color: #6c757d;
    font-size: 14px;
    overflow: hidden;
}

.chat-message-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
}

.chat-message.user .chat-message-avatar {
    background: linear-gradient(135deg, #D10024 0%, #a8001d 100%);
    color: white;
}

.chat-message-avatar.admin-avatar {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

/* Chat Message Bubble */
.chat-message-bubble {
    display: flex;
    flex-direction: column;
    max-width: calc(100% - 40px);
}

.chat-message-content {
    padding: 12px 16px;
    border-radius: 16px;
    font-size: 14px;
    line-height: 1.5;
    word-wrap: break-word;
}

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

.chat-message.admin .chat-message-content {
    background: white;
    color: #1a1a2e;
    border: 1px solid #e9ecef;
    border-bottom-left-radius: 4px;
}

.chat-message.bot .chat-message-content {
    background: #e3f2fd;
    color: #1565c0;
    border-bottom-left-radius: 4px;
}

.chat-message.system .chat-message-content {
    background: linear-gradient(135deg, #e8f5e9 0%, #c8e6c9 100%);
    color: #2e7d32;
    font-size: 13px;
    text-align: center;
    max-width: 100%;
    align-self: center;
    border: 1px solid #a5d6a7;
}

/* System messages - no avatar, centered */
.chat-message.system,
.chat-message.bot {
    max-width: 100%;
    justify-content: center;
}

.chat-message.system .chat-message-bubble,
.chat-message.bot .chat-message-bubble {
    max-width: 90%;
}

.chat-message-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 11px;
    color: #6c757d;
    margin-top: 4px;
    padding: 0 4px;
}

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

/* Admin Badge */
.chat-admin-badge {
    display: inline-flex;
    align-items: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    font-size: 9px;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    box-shadow: 0 1px 3px rgba(102, 126, 234, 0.3);
}

/* Loading */
.chat-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px;
    color: #6c757d;
}

.chat-loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid #e9ecef;
    border-top-color: #D10024;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 12px;
}

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

/* Chat Footer */
.chat-footer {
    padding: 12px 16px;
    background: white;
    border-top: 1px solid #e9ecef;
}

.chat-input-container {
    display: flex;
    gap: 8px;
    align-items: flex-end;
}

.chat-attach-btn {
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    color: #6c757d;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

.chat-attach-btn:hover {
    background: #e9ecef;
    color: #D10024;
    border-color: #D10024;
}

.chat-attach-btn i {
    font-size: 18px;
}

.chat-input-container textarea {
    flex: 1;
    padding: 12px;
    border: 1px solid #dee2e6;
    border-radius: 20px;
    font-size: 14px;
    resize: none;
    max-height: 100px;
    line-height: 1.4;
}

.chat-input-container textarea:focus {
    outline: none;
    border-color: #D10024;
}

.chat-send-btn {
    background: linear-gradient(135deg, #D10024 0%, #a8001d 100%);
    color: white;
    border: none;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s;
    flex-shrink: 0;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

.chat-send-btn:hover {
    transform: scale(1.1);
}

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

/* File Upload Preview */
.chat-upload-preview {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    margin-top: 8px;
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 10px;
    animation: slideUp 0.2s ease-out;
}

.chat-upload-file {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
    min-width: 0;
}

.chat-upload-icon {
    width: 32px;
    height: 32px;
    background: #e9ecef;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.chat-upload-icon i {
    color: #6c757d;
    font-size: 16px;
}

.chat-upload-name {
    flex: 1;
    font-size: 13px;
    color: #495057;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-upload-cancel {
    background: transparent;
    border: none;
    color: #dc3545;
    cursor: pointer;
    padding: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: background 0.2s;
}

.chat-upload-cancel:hover {
    background: #fee2e2;
}

.chat-upload-send {
    background: linear-gradient(135deg, #28a745 0%, #218838 100%);
    color: white;
    border: none;
    padding: 8px 14px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: transform 0.2s;
    white-space: nowrap;
}

.chat-upload-send:hover {
    transform: scale(1.05);
}

.chat-upload-send:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* Upload Progress */
.chat-upload-progress {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    margin-top: 8px;
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 10px;
}

.chat-upload-progress-bar {
    flex: 1;
    height: 6px;
    background: #e9ecef;
    border-radius: 3px;
    overflow: hidden;
}

.chat-upload-progress-fill {
    height: 100%;
    background: linear-gradient(135deg, #D10024 0%, #a8001d 100%);
    border-radius: 3px;
    transition: width 0.3s ease;
}

.chat-upload-progress-text {
    font-size: 12px;
    color: #6c757d;
    white-space: nowrap;
}

/* Chat Attachments in Messages */
.chat-attachment {
    margin-top: 10px;
}

.chat-attachment-image {
    max-width: 100%;
}

.chat-attachment-image img {
    max-width: 100%;
    max-height: 200px;
    border-radius: 8px;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    display: block;
}

.chat-attachment-image img:hover {
    transform: scale(1.02);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.chat-attachment-file {
    max-width: 100%;
}

.chat-file-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    background: rgba(0, 0, 0, 0.05);
    border-radius: 8px;
    text-decoration: none;
    color: inherit;
    transition: background 0.2s;
}

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

.chat-file-link:hover {
    background: rgba(0, 0, 0, 0.1);
}

.chat-message.user .chat-file-link:hover {
    background: rgba(255, 255, 255, 0.25);
}

.chat-file-icon {
    width: 36px;
    height: 36px;
    background: rgba(209, 0, 36, 0.1);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

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

.chat-file-icon i {
    font-size: 18px;
    color: #D10024;
}

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

.chat-file-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.chat-file-name {
    font-size: 13px;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-file-size {
    font-size: 11px;
    opacity: 0.7;
}

.chat-file-download {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.08);
    border-radius: 50%;
    flex-shrink: 0;
}

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

.chat-file-download i {
    font-size: 12px;
}

.chat-footer-info {
    margin-top: 10px;
    text-align: center;
}

.chat-end-btn {
    background: none;
    border: none;
    color: #6c757d;
    font-size: 12px;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    transition: color 0.2s, background 0.2s;
}

.chat-end-btn:hover {
    color: #dc3545;
    background: #fff5f5;
}

/* Typing indicator */
.typing-indicator {
    display: flex;
    gap: 4px;
    padding: 12px 16px;
    background: white;
    border-radius: 16px;
    border: 1px solid #e9ecef;
    width: fit-content;
}

.typing-indicator span {
    width: 8px;
    height: 8px;
    background: #6c757d;
    border-radius: 50%;
    animation: typing 1.4s infinite;
}

.typing-indicator span:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-indicator span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typing {
    0%, 60%, 100% { transform: translateY(0); }
    30% { transform: translateY(-6px); }
}

/* Confirm End Chat Dialog */
.chat-confirm-dialog {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.97);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    z-index: 10;
    animation: fadeIn 0.2s ease-out;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.chat-confirm-content {
    text-align: center;
    max-width: 280px;
}

.chat-confirm-icon {
    font-size: 48px;
    margin-bottom: 12px;
}

.chat-confirm-content h4 {
    color: #1a1a2e;
    font-size: 18px;
    font-weight: 600;
    margin: 0 0 8px 0;
}

.chat-confirm-content p {
    color: #6c757d;
    font-size: 14px;
    line-height: 1.5;
    margin: 0 0 20px 0;
}

.chat-confirm-buttons {
    display: flex;
    gap: 10px;
    justify-content: center;
}

.chat-confirm-btn {
    padding: 12px 20px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

.chat-confirm-btn.cancel {
    background: #f1f3f4;
    color: #495057;
}

.chat-confirm-btn.cancel:hover {
    background: #e2e6ea;
}

.chat-confirm-btn.confirm {
    background: linear-gradient(135deg, #D10024 0%, #a8001d 100%);
    color: white;
}

.chat-confirm-btn.confirm:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(209, 0, 36, 0.3);
}

/* Quick Action Buttons */
.chat-quick-actions {
    background: #f8f9fa;
    border-top: 1px solid #e9ecef;
    padding: 8px;
}

.chat-quick-actions-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 4px 8px;
    margin-bottom: 8px;
}

.chat-quick-actions-header span {
    font-size: 12px;
    color: #6c757d;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.chat-quick-toggle {
    background: none;
    border: none;
    color: #6c757d;
    cursor: pointer;
    padding: 4px;
    transition: transform 0.2s;
}

.chat-quick-toggle.collapsed {
    transform: rotate(-90deg);
}

.chat-quick-actions-content {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    overflow: hidden;
    transition: max-height 0.3s ease, opacity 0.3s ease;
    max-height: 200px;
    opacity: 1;
}

.chat-quick-actions-content.collapsed {
    max-height: 0;
    opacity: 0;
    padding: 0;
}

.chat-quick-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    background: white;
    border: 1px solid #e9ecef;
    border-radius: 20px;
    font-size: 12px;
    color: #495057;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

.chat-quick-btn:hover {
    background: #D10024;
    color: white;
    border-color: #D10024;
    transform: translateY(-1px);
}

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

/* Orders Panel */
.chat-orders-panel {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: white;
    z-index: 15;
    display: flex;
    flex-direction: column;
    animation: slideInRight 0.2s ease-out;
}

@keyframes slideInRight {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

.chat-orders-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px;
    background: linear-gradient(135deg, #1a1a2e 0%, #2d2d44 100%);
    color: white;
}

.chat-back-btn {
    background: rgba(255, 255, 255, 0.1);
    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-back-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

.chat-orders-header span {
    font-weight: 600;
    font-size: 16px;
}

.chat-orders-content {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
}

.chat-order-item {
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 12px;
    padding: 14px;
    margin-bottom: 12px;
    cursor: pointer;
    transition: all 0.2s;
}

.chat-order-item:hover {
    background: #fff;
    border-color: #D10024;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.chat-order-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 8px;
}

.chat-order-id {
    font-weight: 600;
    color: #1a1a2e;
    font-size: 14px;
}

.chat-order-status {
    font-size: 11px;
    padding: 4px 8px;
    border-radius: 12px;
    font-weight: 600;
}

.chat-order-status.pending {
    background: #fff3cd;
    color: #856404;
}

.chat-order-status.paid {
    background: #d4edda;
    color: #155724;
}

.chat-order-status.completed {
    background: #cce5ff;
    color: #004085;
}

.chat-order-status.cancelled {
    background: #f8d7da;
    color: #721c24;
}

.chat-order-product {
    font-size: 13px;
    color: #495057;
    margin-bottom: 6px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.chat-order-meta {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    color: #6c757d;
}

.chat-order-price {
    font-weight: 600;
    color: #D10024;
}

.chat-order-details {
    background: white;
    padding: 16px;
}

.chat-order-detail-item {
    display: flex;
    justify-content: space-between;
    padding: 10px 0;
    border-bottom: 1px solid #f0f0f0;
    font-size: 13px;
}

.chat-order-detail-item:last-child {
    border-bottom: none;
}

.chat-order-detail-label {
    color: #6c757d;
}

.chat-order-detail-value {
    color: #1a1a2e;
    font-weight: 500;
    text-align: right;
}

.chat-order-ask-btn {
    width: 100%;
    margin-top: 16px;
    padding: 12px;
    background: linear-gradient(135deg, #D10024 0%, #a8001d 100%);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.2s;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

.chat-order-ask-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(209, 0, 36, 0.3);
}

.chat-orders-empty {
    text-align: center;
    padding: 40px 20px;
    color: #6c757d;
}

.chat-orders-empty i {
    font-size: 48px;
    margin-bottom: 12px;
    opacity: 0.5;
}

.chat-orders-empty p {
    margin: 0;
    font-size: 14px;
}

/* Responsive - Tablet (768px and below) */
@media (max-width: 768px) {
    .chat-window {
        width: 340px;
        height: 500px;
    }
    
    .chat-header {
        padding: 14px;
    }
    
    .chat-header-avatar {
        width: 36px;
        height: 36px;
    }
    
    .chat-header-title {
        font-size: 14px;
    }
    
    .chat-header-status {
        font-size: 11px;
    }
    
    .chat-body {
        padding: 16px;
    }
    
    .chat-welcome-icon {
        font-size: 40px;
    }
    
    .chat-welcome h3 {
        font-size: 18px;
    }
    
    .chat-message-content {
        max-width: 85%;
        font-size: 13px;
        padding: 10px 14px;
    }
    
    .chat-quick-btn {
        padding: 6px 10px;
        font-size: 11px;
    }
}

/* Responsive - Mobile (576px and below) */
@media (max-width: 576px) {
    .chat-container {
        right: 10px;
        bottom: 10px;
    }
    
    .chat-bubble {
        width: 54px;
        height: 54px;
    }
    
    .chat-bubble-icon {
        font-size: 22px;
    }
    
    .chat-window {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        width: 100%;
        max-width: 100%;
        height: 100%;
        max-height: 100%;
        border-radius: 0;
        z-index: 10001;
    }
    
    .chat-header {
        padding: 12px 16px;
        border-radius: 0;
    }
    
    .chat-header-info {
        gap: 10px;
    }
    
    .chat-header-avatar {
        width: 38px;
        height: 38px;
    }
    
    .chat-header-btn {
        width: 36px;
        height: 36px;
    }
    
    .chat-body {
        padding: 12px;
    }
    
    .chat-welcome {
        margin-bottom: 16px;
    }
    
    .chat-welcome-icon {
        font-size: 36px;
    }
    
    .chat-welcome h3 {
        font-size: 17px;
    }
    
    .chat-welcome p {
        font-size: 13px;
    }
    
    .chat-user-info {
        padding: 10px;
        font-size: 13px;
    }
    
    .chat-form-group input,
    .chat-form-group textarea {
        padding: 10px 12px;
        font-size: 16px; /* Prevents zoom on iOS */
    }
    
    .chat-start-btn {
        padding: 12px;
        font-size: 14px;
    }
    
    .chat-message {
        gap: 6px;
        margin-bottom: 10px;
    }
    
    .chat-message-avatar {
        width: 28px;
        height: 28px;
        font-size: 12px;
    }
    
    .chat-message-bubble {
        max-width: calc(100% - 34px);
    }
    
    .chat-message-content {
        max-width: 100%;
        font-size: 14px;
        padding: 10px 12px;
        border-radius: 14px;
    }
    
    .chat-message-meta {
        font-size: 10px;
    }
    
    .chat-quick-actions {
        padding: 6px 8px;
    }
    
    .chat-quick-actions-header {
        padding: 4px 6px;
        margin-bottom: 6px;
    }
    
    .chat-quick-actions-header span {
        font-size: 11px;
    }
    
    .chat-quick-actions-content {
        gap: 4px;
    }
    
    .chat-quick-btn {
        padding: 6px 10px;
        font-size: 11px;
        border-radius: 16px;
    }
    
    .chat-quick-btn i {
        font-size: 12px;
    }
    
    .chat-footer {
        padding: 10px 12px;
    }
    
    .chat-input-container {
        gap: 6px;
    }
    
    .chat-input-container textarea {
        padding: 10px 14px;
        font-size: 16px; /* Prevents zoom on iOS */
        border-radius: 18px;
    }
    
    .chat-attach-btn {
        width: 38px;
        height: 38px;
    }
    
    .chat-attach-btn i {
        font-size: 16px;
    }
    
    .chat-send-btn {
        width: 40px;
        height: 40px;
    }
    
    .chat-end-btn {
        font-size: 11px;
    }
    
    .chat-footer-info {
        margin-top: 8px;
    }
    
    /* File upload mobile */
    .chat-upload-preview {
        flex-wrap: wrap;
        padding: 8px 10px;
    }
    
    .chat-upload-file {
        width: 100%;
    }
    
    .chat-upload-send {
        width: 100%;
        justify-content: center;
        margin-top: 6px;
    }
    
    .chat-upload-progress {
        padding: 8px 10px;
    }
    
    /* Attachment mobile */
    .chat-attachment-image img {
        max-height: 150px;
    }
    
    .chat-file-link {
        padding: 8px 10px;
    }
    
    .chat-file-icon {
        width: 32px;
        height: 32px;
    }
    
    .chat-file-icon i {
        font-size: 16px;
    }
    
    .chat-file-name {
        font-size: 12px;
    }
    
    /* Confirm Dialog Mobile */
    .chat-confirm-dialog {
        padding: 16px;
    }
    
    .chat-confirm-content {
        max-width: 100%;
    }
    
    .chat-confirm-icon {
        font-size: 40px;
        margin-bottom: 12px;
    }
    
    .chat-confirm-content h4 {
        font-size: 17px;
        margin-bottom: 8px;
    }
    
    .chat-confirm-content p {
        font-size: 13px;
        margin-bottom: 16px;
    }
    
    .chat-confirm-buttons {
        flex-direction: column;
        gap: 8px;
    }
    
    .chat-confirm-btn {
        width: 100%;
        justify-content: center;
        padding: 12px;
    }
    
    /* Orders Panel Mobile */
    .chat-orders-header {
        padding: 14px 16px;
    }
    
    .chat-orders-header span {
        font-size: 15px;
    }
    
    .chat-orders-content {
        padding: 12px;
    }
    
    .chat-order-item {
        padding: 12px;
        margin-bottom: 10px;
    }
    
    .chat-order-id {
        font-size: 13px;
    }
    
    .chat-order-status {
        font-size: 10px;
        padding: 3px 8px;
    }
    
    .chat-order-product {
        font-size: 12px;
    }
    
    .chat-order-details {
        font-size: 11px;
    }
    
    /* Order Details Mobile */
    .chat-order-detail-header h4 {
        font-size: 14px;
    }
    
    .chat-order-detail-status {
        font-size: 11px;
    }
    
    .chat-order-detail-info {
        padding: 12px;
    }
    
    .chat-order-detail-row {
        font-size: 12px;
    }
    
    .chat-order-ask-btn {
        padding: 10px;
        font-size: 13px;
    }
    
    /* Form error mobile */
    .chat-form-error {
        font-size: 12px;
        padding: 8px 10px;
    }
}

/* Responsive - Very Small Mobile (360px and below) */
@media (max-width: 360px) {
    .chat-container {
        right: 8px;
        bottom: 8px;
    }
    
    .chat-bubble {
        width: 50px;
        height: 50px;
    }
    
    .chat-bubble-icon {
        font-size: 20px;
    }
    
    .chat-header {
        padding: 10px 12px;
    }
    
    .chat-header-avatar {
        width: 34px;
        height: 34px;
    }
    
    .chat-header-title {
        font-size: 13px;
    }
    
    .chat-header-status {
        font-size: 10px;
    }
    
    .chat-header-btn {
        width: 32px;
        height: 32px;
    }
    
    .chat-body {
        padding: 10px;
    }
    
    .chat-welcome-icon {
        font-size: 32px;
    }
    
    .chat-welcome h3 {
        font-size: 16px;
    }
    
    .chat-welcome p {
        font-size: 12px;
    }
    
    .chat-form-group label {
        font-size: 12px;
    }
    
    .chat-message-content {
        font-size: 13px;
        padding: 8px 10px;
    }
    
    .chat-quick-btn {
        padding: 5px 8px;
        font-size: 10px;
    }
    
    .chat-footer {
        padding: 8px 10px;
    }
    
    .chat-send-btn {
        width: 38px;
        height: 38px;
    }
}

/* Landscape mode adjustments */
@media (max-height: 500px) and (orientation: landscape) {
    .chat-window {
        height: 100vh;
        max-height: 100vh;
    }
    
    .chat-body {
        padding: 8px 12px;
    }
    
    .chat-welcome {
        margin-bottom: 8px;
    }
    
    .chat-welcome-icon {
        font-size: 28px;
        margin-bottom: 4px;
    }
    
    .chat-welcome h3 {
        font-size: 15px;
        margin-bottom: 2px;
    }
    
    .chat-welcome p {
        font-size: 11px;
    }
    
    .chat-form-group {
        gap: 4px;
    }
    
    .chat-form-group input,
    .chat-form-group textarea {
        padding: 8px 10px;
    }
    
    .chat-start-btn {
        padding: 10px;
    }
    
    .chat-quick-actions {
        padding: 4px 8px;
    }
    
    .chat-footer {
        padding: 6px 10px;
    }
    
    .chat-footer-info {
        margin-top: 4px;
    }
}

/* Safe area insets for notched devices */
@supports (padding: max(0px)) {
    @media (max-width: 576px) {
        .chat-window {
            padding-top: max(0px, env(safe-area-inset-top));
            padding-bottom: max(0px, env(safe-area-inset-bottom));
            padding-left: max(0px, env(safe-area-inset-left));
            padding-right: max(0px, env(safe-area-inset-right));
        }
        
        .chat-header {
            padding-top: max(12px, calc(12px + env(safe-area-inset-top)));
        }
        
        .chat-footer {
            padding-bottom: max(10px, calc(10px + env(safe-area-inset-bottom)));
        }
    }
}

/* ==================== */
/* File Preview Modal   */
/* ==================== */

.chat-preview-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    z-index: 100002;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    animation: fadeIn 0.2s ease;
}

.chat-preview-modal-content {
    background: white;
    border-radius: 16px;
    width: 100%;
    max-width: 800px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    animation: slideUp 0.3s ease;
}

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

.chat-preview-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    background: linear-gradient(135deg, #D10024 0%, #a8001d 100%);
    color: white;
}

.chat-preview-modal-title {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 600;
    font-size: 14px;
    min-width: 0;
}

.chat-preview-modal-title i {
    font-size: 18px;
}

#chat-preview-modal-filename {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-preview-modal-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.chat-preview-download-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border-radius: 8px;
    font-size: 13px;
    text-decoration: none;
    transition: all 0.2s;
}

.chat-preview-download-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    color: white;
    text-decoration: none;
}

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

.chat-preview-close-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

.chat-preview-modal-body {
    flex: 1;
    overflow: auto;
    background: #f8f9fa;
    min-height: 300px;
}

/* Loading state */
.chat-preview-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 300px;
    color: #6c757d;
}

.chat-preview-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid #e9ecef;
    border-top-color: #D10024;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-bottom: 12px;
}

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

/* Image preview */
.chat-preview-image-container {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 300px;
    padding: 20px;
}

.chat-preview-image-container img {
    max-width: 100%;
    max-height: 70vh;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    opacity: 0;
    transition: opacity 0.3s;
}

.chat-preview-image-container.loaded img {
    opacity: 1;
}

/* PDF preview */
.chat-preview-pdf-container {
    height: 70vh;
    min-height: 400px;
}

.chat-preview-pdf-container iframe {
    width: 100%;
    height: 100%;
    border: none;
}

/* Text preview */
.chat-preview-text-container {
    padding: 20px;
    background: white;
    min-height: 300px;
}

.chat-preview-text-container pre {
    margin: 0;
    white-space: pre-wrap;
    word-wrap: break-word;
    font-family: 'Monaco', 'Consolas', monospace;
    font-size: 13px;
    color: #333;
    line-height: 1.6;
}

/* No preview state */
.chat-preview-no-preview {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 300px;
    color: #6c757d;
    text-align: center;
}

.chat-preview-no-preview i {
    font-size: 48px;
    color: #dee2e6;
    margin-bottom: 16px;
}

.chat-preview-no-preview p {
    margin: 0 0 8px 0;
}

.chat-preview-filename {
    font-size: 12px;
    color: #adb5bd;
}

/* Error state */
.chat-preview-error {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 300px;
    color: #dc3545;
    text-align: center;
}

.chat-preview-error i {
    font-size: 48px;
    margin-bottom: 16px;
}

/* Attachment action buttons in messages */
.chat-attachment-actions {
    display: flex;
    gap: 8px;
    margin-top: 10px;
    flex-wrap: wrap;
}

.chat-attachment-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
    border: none;
}

.chat-attachment-btn.preview {
    background: linear-gradient(135deg, #17a2b8 0%, #138496 100%);
    color: white;
}

.chat-attachment-btn.preview:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(23, 162, 184, 0.3);
}

.chat-attachment-btn.download {
    background: linear-gradient(135deg, #28a745 0%, #20903c 100%);
    color: white;
}

.chat-attachment-btn.download:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(40, 167, 69, 0.3);
    color: white;
    text-decoration: none;
}

/* Mobile responsive for preview modal */
@media (max-width: 576px) {
    .chat-preview-modal {
        padding: 10px;
    }
    
    .chat-preview-modal-content {
        max-height: 95vh;
        border-radius: 12px;
    }
    
    .chat-preview-modal-header {
        padding: 12px 16px;
        flex-wrap: wrap;
        gap: 10px;
    }
    
    .chat-preview-modal-title {
        font-size: 13px;
    }
    
    .chat-preview-download-btn {
        padding: 6px 10px;
        font-size: 12px;
    }
    
    .chat-preview-pdf-container {
        height: 60vh;
        min-height: 300px;
    }
    
    .chat-attachment-actions {
        flex-direction: column;
        gap: 6px;
    }
    
    .chat-attachment-btn {
        justify-content: center;
    }
}

/* ==================== */
/* Typing Indicator     */
/* ==================== */

.chat-typing-indicator {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    margin: 8px 0;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border-radius: 18px;
    border-top-left-radius: 4px;
    max-width: 200px;
    animation: fadeInUp 0.3s ease;
}

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

.typing-dots {
    display: flex;
    align-items: center;
    gap: 4px;
}

.typing-dots span {
    width: 8px;
    height: 8px;
    background: #D10024;
    border-radius: 50%;
    animation: typingBounce 1.4s infinite ease-in-out;
}

.typing-dots span:nth-child(1) {
    animation-delay: 0s;
}

.typing-dots span:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-dots span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typingBounce {
    0%, 60%, 100% {
        transform: translateY(0);
        opacity: 0.4;
    }
    30% {
        transform: translateY(-6px);
        opacity: 1;
    }
}

.typing-text {
    font-size: 12px;
    color: #6c757d;
    font-style: italic;
}

