/* Chat Widget Styles */
.chat-widget {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 9999;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

/* Chat Button */
.chat-button {
    width: 60px;
    height: 60px;
    background: linear-gradient(135deg, #e5b141, #ffbd2f);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 24px;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(9, 66, 252, 0.4);
    transition: all 0.3s ease;
    position: relative;
    border: none;
    outline: none;
        bottom: 60px;

}

.chat-button:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 25px rgba(76, 175, 80, 0.6);
    background: linear-gradient(135deg, #e5b141, #e5b141);
}

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

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

/* Chat Container */
.chat-container {
    position: absolute;
    bottom: 80px;
    right: 0;
    width: 380px;
    height: 600px;
    background: white;
    border-radius: 15px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    display: none;
    flex-direction: column;
    overflow: hidden;
    transform: scale(0.8);
    opacity: 0;
    transition: all 0.3s ease;
    max-height: 90vh;
    min-height: 500px;
}

.chat-container.show {
    display: flex;
    transform: scale(1);
    opacity: 1;
}

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

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

.chat-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
}

.chat-header-info h4 {
    margin: 0;
    font-size: 16px;
}

.status {
    font-size: 12px;
    opacity: 0.9;
}

.status.online {
    color: #90EE90;
}

.status.offline {
    color: #FFB6C1;
}

.chat-controls {
    display: flex;
    gap: 10px;
}

.minimize-btn, .close-btn {
    background: transparent;
    border: none;
    color: white;
    cursor: pointer;
    padding: 5px;
    border-radius: 3px;
    transition: background 0.3s;
}

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

/* Chat Tabs */
.chat-tabs {
    display: flex;
    background: #f5f5f5;
    border-bottom: 1px solid #ddd;
    flex-shrink: 0;
}

.tab-btn {
    flex: 1;
    padding: 12px;
    background: transparent;
    border: none;
    cursor: pointer;
    font-size: 14px;
    color: #666;
    transition: all 0.3s;
    border-bottom: 3px solid transparent;
    font-weight: 500;
}

.tab-btn.active {
    background: white;
    color: #e5b141;
    border-bottom-color: #e5b141;
    font-weight: 600;
}

.tab-btn:hover {
    background: #e9e9e9;
    color: #e5b141;
}

.tab-btn:not(.active):hover {
    background: #e9e9e9;
    color: #333;
}

/* Chat Content */
.chat-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 100%;
    position: relative;
    z-index: 1;
    min-height: 0; /* Allow flex shrinking */
    background: white;
    overflow: hidden;
}

.chat-content.hidden {
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
    height: 0 !important;
    overflow: hidden !important;
    position: absolute !important;
    left: -9999px !important;
}

.chat-content:not(.hidden) {
    display: flex !important;
    visibility: visible !important;
    opacity: 1 !important;
    position: relative !important;
    left: auto !important;
    height: 100% !important;
}

/* Chat Messages */
.chat-messages {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 15px;
    min-height: 200px;
    max-height: calc(100% - 120px); /* Leave space for input */
}

.message {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    margin-bottom: 15px;
    animation: slideInUp 0.3s ease;
}

.message:last-child {
    margin-bottom: 0;
}

.user-message {
    flex-direction: row-reverse;
}

.message-avatar {
    width: 32px;
    height: 32px;
    flex-shrink: 0;
}

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

.message-content {
    max-width: 80%;
    position: relative;
}

.bot-message .message-content {
    background: #f0f0f0;
    border-radius: 15px 15px 15px 5px;
    padding: 12px 15px;
}

.user-message .message-content {
    background: #e5b141;
    color: white;
    border-radius: 15px 15px 5px 15px;
    padding: 12px 15px;
}

.message-content p {
    margin: 0;
    font-size: 14px;
    line-height: 1.4;
}

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

/* Quick Replies */
.quick-replies {
    padding: 15px 20px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    border-bottom: 1px solid #eee;
    background: white;
    flex-shrink: 0;
}

.quick-reply-btn {
    background: #e3f2fd;
    border: 1px solid #2196F3;
    color: #2196F3;
    padding: 8px 12px;
    border-radius: 20px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.3s;
}

.quick-reply-btn:hover {
    background: #2196F3;
    color: white;
}

/* Chat Input */
.chat-input-container {
    padding: 15px 20px;
    border-top: 1px solid #eee;
    background: white;
    flex-shrink: 0;
    position: relative;
    z-index: 100;
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    order: 999; /* Ensure it's always at the bottom */
}

.chat-input {
    display: flex !important;
    align-items: center;
    gap: 10px;
    background: #f5f5f5;
    border-radius: 25px;
    padding: 5px 15px;
    border: 1px solid #ddd;
    position: relative;
    visibility: visible !important;
    opacity: 1 !important;
}

.chat-input input {
    flex: 1;
    border: none;
    background: transparent;
    padding: 10px 0;
    font-size: 14px;
    outline: none;
    color: #333;
    z-index: 10;
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    pointer-events: auto !important;
}

.chat-input input::placeholder {
    color: #999;
    opacity: 1;
}

.chat-input:focus-within {
    border-color: #e5b141;
    box-shadow: 0 0 0 2px rgba(76, 175, 80, 0.2);
}

.attachment-btn, .send-btn {
    background: transparent;
    border: none;
    color: #666;
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    transition: all 0.3s;
}

.send-btn {
    color: #e5b141;
}

.attachment-btn:hover, .send-btn:hover {
    background: #e0e0e0;
}

/* Typing Indicator */
.typing-indicator {
    display: none;
    align-items: center;
    gap: 10px;
    padding: 10px 20px;
    background: #f9f9f9;
    font-size: 12px;
    color: #666;
}

.typing-indicator.show {
    display: flex;
}

.typing-dots {
    display: flex;
    gap: 3px;
}

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

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

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

@keyframes typing {
    0%, 80%, 100% {
        transform: scale(0.8);
        opacity: 0.5;
    }
    40% {
        transform: scale(1);
        opacity: 1;
    }
}

/* Ticket Form */
.ticket-form {
    padding: 20px;
    overflow-y: auto;
    height: 100%;
}

.ticket-form h3 {
    margin-bottom: 20px;
    color: #333;
    text-align: center;
}

.form-group {
    margin-bottom: 15px;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: 500;
    color: #333;
    font-size: 13px;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 5px;
    font-size: 14px;
    transition: border-color 0.3s;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #e5b141;
}

.form-group textarea {
    resize: vertical;
    min-height: 80px;
}

.submit-btn {
    width: 100%;
    background: #e5b141;
    color: white;
    border: none;
    padding: 12px;
    border-radius: 5px;
    font-size: 14px;
    cursor: pointer;
    transition: background 0.3s;
    margin-top: 10px;
}

.submit-btn:hover {
    background: #e5b141;
}

.submit-btn:disabled {
    background: #ccc;
    cursor: not-allowed;
}

/* Ensure messages are properly spaced and visible */
.message {
    margin-bottom: 15px;
    animation: slideInUp 0.3s ease;
}

.message:last-child {
    margin-bottom: 0;
}

/* Better scrollbar styling */
.chat-messages::-webkit-scrollbar {
    width: 6px;
}

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

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

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

/* Animation Keyframes */
@keyframes slideInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

@keyframes pulse {
    0% {
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(76, 175, 80, 0.7);
    }
    70% {
        transform: scale(1.05);
        box-shadow: 0 0 0 10px rgba(76, 175, 80, 0);
    }
    100% {
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(76, 175, 80, 0);
    }
}

@keyframes bounce {
    0%, 20%, 53%, 80%, 100% {
        transform: translate3d(0,0,0);
    }
    40%, 43% {
        transform: translate3d(0, -8px, 0);
    }
    70% {
        transform: translate3d(0, -4px, 0);
    }
    90% {
        transform: translate3d(0, -2px, 0);
    }
}

/* Critical input field fixes */
.chat-input-container {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    position: relative !important;
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
    z-index: 1000 !important;
    flex-shrink: 0 !important;
    order: 999 !important;
    background: white !important;
    border-top: 1px solid #eee !important;
    padding: 15px 20px !important;
}

.chat-input {
    display: flex !important;
    align-items: center !important;
    gap: 10px !important;
    background: #f5f5f5 !important;
    border-radius: 25px !important;
    padding: 5px 15px !important;
    border: 1px solid #ddd !important;
    position: relative !important;
    visibility: visible !important;
    opacity: 1 !important;
}

#messageInput {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    pointer-events: auto !important;
    flex: 1 !important;
    border: none !important;
    background: transparent !important;
    padding: 10px 0 !important;
    font-size: 14px !important;
    outline: none !important;
    color: #333 !important;
    z-index: 10 !important;
    min-height: 20px !important;
    width: auto !important;
}

/* Ensure proper flex layout */
.chat-container.show {
    display: flex !important;
    flex-direction: column !important;
}

.chat-content {
    display: flex !important;
    flex-direction: column !important;
    flex: 1 !important;
    min-height: 0 !important;
    overflow: hidden !important;
}

/* Animations */
@keyframes slideInUp {
    from {
        transform: translateY(20px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.message {
    animation: slideInUp 0.3s ease;
}

@keyframes bounce {
    0%, 20%, 53%, 80%, 100% {
        transform: translate3d(0,0,0);
    }
    40%, 43% {
        transform: translate3d(0, -8px, 0);
    }
    70% {
        transform: translate3d(0, -4px, 0);
    }
    90% {
        transform: translate3d(0, -2px, 0);
    }
}

.notification-badge {
    animation: bounce 2s infinite;
}

/* Force input field to always be visible */
#messageInput {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    pointer-events: auto !important;
    width: 100% !important;
    min-height: 20px !important;
}

.chat-input-container {
    order: 999 !important; /* Always at bottom */
}

.chat-content {
    display: flex !important;
    flex-direction: column !important;
    height: 100% !important;
}

/* Ensure proper layout */
.chat-widget .chat-container.show {
    display: flex !important;
    flex-direction: column !important;
}
