/* Live Chat Widget Styles */
.live-chat-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 380px;
    height: 600px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 5px 30px rgba(0, 0, 0, 0.2);
    display: flex;
    flex-direction: column;
    z-index: 1000;
    transform: translateY(20px);
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    overflow: hidden;
}

.live-chat-container.chat-open {
    transform: translateY(0);
    opacity: 1;
    visibility: visible;
}

.chat-toggle {
    position: fixed;
    bottom: 25px;
    right: 30px;
    /* Aligned with others */
    width: 60px;
    height: 60px;
    background: var(--primary-color);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 1001;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    transition: all 0.3s ease;
}

.chat-toggle:hover {
    background: var(--secondary-color);
    transform: scale(1.05);
}

.chat-toggle.active {
    transform: scale(0.9);
    background: #dc3545;
}

.chat-toggle i {
    font-size: 24px;
}

/* Chat Header */
.chat-header {
    background: var(--primary-color);
    color: white;
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-radius: 12px 12px 0 0;
}

.chat-title {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 600;
    font-size: 1.1rem;
}

.chat-title i {
    font-size: 1.2rem;
}

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

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

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

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

.welcome-message {
    background: white;
    border-radius: 12px;
    padding: 15px;
    margin-bottom: 20px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.welcome-message p {
    margin: 0 0 15px 0;
    color: #333;
    line-height: 1.5;
}

.quick-questions {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.quick-question {
    background: #f0f4f8;
    border: 1px solid #dee2e6;
    border-radius: 20px;
    padding: 8px 15px;
    font-size: 0.85rem;
    color: #495057;
    cursor: pointer;
    text-align: left;
    transition: all 0.2s;
}

.quick-question:hover {
    background: #e2e8f0;
    border-color: #adb5bd;
}

#chatMessages {
    display: flex;
    flex-direction: column;
    gap: 15px;
    padding-top: 10px;
}

.message {
    max-width: 80%;
    padding: 12px 15px;
    border-radius: 18px;
    line-height: 1.4;
    position: relative;
    word-wrap: break-word;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
    animation: messageAppear 0.2s ease-out;
}

@keyframes messageAppear {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.message.sent {
    background: var(--primary-color);
    color: white;
    align-self: flex-end;
    border-bottom-right-radius: 4px;
    margin-left: 20%;
}

.message.received {
    background: white;
    color: #333;
    align-self: flex-start;
    border-bottom-left-radius: 4px;
    margin-right: 20%;
    border: 1px solid #e1e4e8;
}

.message.admin {
    background: #f8f9fa;
    border-left: 3px solid #ffc107;
}

.message-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 4px;
}

.message-username {
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--primary-color);
}

.message.sent .message-username {
    color: rgba(255, 255, 255, 0.9);
}

.admin-badge {
    background: #ffc107;
    color: #000;
    font-size: 0.65rem;
    padding: 2px 6px;
    border-radius: 10px;
    font-weight: bold;
    text-transform: uppercase;
}

.message-time {
    font-size: 0.7rem;
    opacity: 0.8;
    margin-top: 6px;
    text-align: right;
}

.message.sent .message-time {
    color: rgba(255, 255, 255, 0.8);
}

.message.received .message-time {
    color: #888;
}

/* Status message */
.status-message {
    align-self: center;
    font-size: 0.8rem;
    color: #666;
    margin: 10px 0;
    padding: 5px 15px;
    background: rgba(0, 0, 0, 0.05);
    border-radius: 15px;
    text-align: center;
}

/* User status indicator */
.user-status {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-right: 6px;
}

.user-status.online {
    background-color: #28a745;
}

.user-status.offline {
    background-color: #6c757d;
}

.user-status.typing {
    background-color: #17a2b8;
}

/* Typing indicator */
.typing-indicator {
    display: none;
    align-items: center;
    padding: 10px 15px;
    background: #f1f1f1;
    border-radius: 18px;
    margin: 5px 0;
    width: fit-content;
    font-size: 0.8rem;
    color: #666;
}

.typing-indicator span {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: #666;
    margin: 0 2px;
    animation: typing 1.4s infinite ease-in-out;
}

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

.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(-4px);
    }
}

/* Chat Input */
.chat-input-container {
    padding: 15px;
    border-top: 1px solid #eee;
    background: white;
    position: relative;
}

.input-wrapper {
    display: flex;
    gap: 10px;
    align-items: center;
    position: relative;
}

#messageInput {
    flex: 1;
    padding: 12px 50px 12px 20px;
    border: 1px solid #ddd;
    border-radius: 25px;
    outline: none;
    font-size: 0.9rem;
    transition: all 0.3s;
    background-color: #f8f9fa;
    height: 46px;
    box-sizing: border-box;
}

#messageInput:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.1);
    background-color: white;
}

#messageInput:disabled {
    background-color: #f1f1f1;
    cursor: not-allowed;
}

.send-btn {
    position: absolute;
    right: 8px;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--primary-color);
    color: white;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

.send-btn:hover:not(:disabled) {
    background: #0056b3;
    transform: scale(1.05);
}

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

.send-btn:disabled {
    background: #ccc;
    cursor: not-allowed;
    opacity: 0.7;
}

/* Chat header with user info */
.chat-header-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.chat-header-title {
    font-size: 1rem;
    font-weight: 600;
    color: white;
}

.chat-header-status {
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.8);
    display: flex;
    align-items: center;
}

/* Scrollbar styles */
.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;
}

/* Responsive adjustments */
@media (max-width: 480px) {
    .live-chat-container {
        width: 100%;
        height: 100%;
        bottom: 0;
        right: 0;
        border-radius: 0;
    }

    .chat-toggle {
        bottom: 20px;
        right: 20px;
    }

    .message {
        max-width: 85%;
    }
}

/* Scrollbar Styling */
::-webkit-scrollbar {
    width: 6px;
}

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

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

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

/* Mobile optimization for very small screens (≈360x740) */
@media (max-width: 400px) {
    .live-chat-container {
        width: 96vw;
        height: 70vh;
        right: 2vw;
        bottom: 12px;
        border-radius: 12px;
    }

    .chat-toggle {
        right: 20px;
        bottom: 20px;
        width: 50px;
        height: 50px;
    }

    .chat-header {
        padding: 10px 14px;
    }

    .chat-title {
        gap: 8px;
        font-size: 1rem;
    }

    .chat-title i {
        font-size: 1.05rem;
    }

    .chat-controls {
        gap: 8px;
    }

    .chat-btn {
        width: 26px;
        height: 26px;
    }

    .chat-messages {
        padding: 12px;
    }

    #chatMessages {
        gap: 12px;
    }

    .quick-questions {
        gap: 8px;
    }

    .quick-question {
        padding: 7px 12px;
        font-size: 0.8rem;
    }

    .message {
        max-width: 90%;
        padding: 10px 12px;
        font-size: 0.95rem;
        overflow-wrap: anywhere;
    }

    .message-username {
        font-size: 0.8rem;
    }

    .message-time {
        font-size: 0.65rem;
    }
}