/* Chatbot Widget Styles */
.chatbot-widget {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 9999;
    font-family: 'Noto Sans Thai', 'Nunito', 'Poppins', Arial, sans-serif;
}

.chatbot-toggle {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, #003A70 0%, #0057A8 100%);
    color: #fff;
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(0, 58, 112, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    transition: all 0.3s ease;
    position: relative;
}

/* Invitation Message Tooltip */
.chatbot-invitation {
    position: absolute;
    bottom: 0;
    right: 75px;
    background: rgba(0, 58, 112, 0.45);
    color: #fff;
    padding: 12px 16px;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 500;
    white-space: nowrap;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    opacity: 0;
    transform: translateX(10px) scale(0.9);
    pointer-events: none;
    transition: all 0.3s ease;
    animation: invitationPulse 2s ease-in-out infinite;
    z-index: 10000;
    animation-delay: 1s;
    display: flex;
    align-items: center;
}

.chatbot-invitation.show {
    opacity: 1;
    transform: translateX(0) scale(1);
    pointer-events: auto;
}

.chatbot-invitation::after {
    content: '';
    position: absolute;
    right: -8px;
    top: 50%;
    transform: translateY(-50%);
    width: 0;
    height: 0;
    border-top: 8px solid transparent;
    border-bottom: 8px solid transparent;
    border-left: 8px solid rgba(0, 58, 112, 0.45);
}

.chatbot-widget:hover .chatbot-invitation.show,
.chatbot-toggle:hover ~ .chatbot-invitation.show {
    opacity: 1;
    transform: translateX(0) scale(1);
    pointer-events: auto;
}

@keyframes invitationPulse {
    0%, 100% {
        transform: translateX(0) scale(1);
    }
    50% {
        transform: translateX(-3px) scale(1.02);
    }
}

.chatbot-toggle:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(0, 58, 112, 0.4);
}

.chatbot-toggle .notification-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #F15A29;
    color: #fff;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    font-size: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
}

.chatbot-container {
    position: absolute;
    bottom: 80px;
    right: 0;
    width: 380px;
    max-width: calc(100vw - 40px);
    height: 600px;
    max-height: calc(100vh - 120px);
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.2);
    display: none;
    flex-direction: column;
    overflow: hidden;
    animation: slideUp 0.3s ease;
}

.chatbot-container.active {
    display: flex;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Override animation for mobile centering */
@keyframes slideUpMobile {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

@media (max-width: 640px) {
    .chatbot-container {
        animation: slideUpMobile 0.3s ease;
    }
}

.chatbot-header {
    background: linear-gradient(135deg, #003A70 0%, #0057A8 100%);
    color: #fff;
    padding: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.chatbot-header h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
}

.chatbot-close {
    background: none;
    border: none;
    color: #fff;
    font-size: 24px;
    cursor: pointer;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background 0.3s;
}

.chatbot-close:hover {
    background: rgba(255, 255, 255, 0.2);
}

.chatbot-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: #f8f9fa;
    display: flex;
    flex-direction: column;
    gap: 16px;
    min-height: 0;
}

/* Custom scrollbar for messages */
.chatbot-messages::-webkit-scrollbar {
    width: 6px;
}

.chatbot-messages::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 10px;
}

.chatbot-messages::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 10px;
}

.chatbot-messages::-webkit-scrollbar-thumb:hover {
    background: #555;
}

.chatbot-message {
    display: flex;
    gap: 12px;
    animation: fadeIn 0.3s ease;
    align-items: flex-start;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.chatbot-message.user {
    flex-direction: row-reverse;
}

.chatbot-message-avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
}

.chatbot-message.user .chatbot-message-avatar {
    background: linear-gradient(135deg, #003A70 0%, #0057A8 100%);
    color: #fff;
}

.chatbot-message.bot .chatbot-message-avatar {
    background: #e8e8e8;
    color: #003A70;
}

.chatbot-message.admin .chatbot-message-avatar {
    background: #e8e8e8;
    color: #003A70;
}

.chatbot-message-content {
    max-width: 75%;
    padding: 14px 18px;
    border-radius: 16px;
    word-wrap: break-word;
    line-height: 1.6;
    font-size: 14px;
    letter-spacing: 0.01em;
}

.chatbot-message.user .chatbot-message-content {
    background: linear-gradient(135deg, #003A70 0%, #0057A8 100%);
    color: #fff;
    border-bottom-right-radius: 4px;
    font-weight: 400;
    box-shadow: 0 2px 8px rgba(0, 58, 112, 0.15);
}

.chatbot-message.bot .chatbot-message-content {
    background: #fff;
    color: #333;
    border: 1px solid #e8e8e8;
    border-bottom-left-radius: 4px;
    font-weight: 400;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
}

.chatbot-message.admin .chatbot-message-content {
    background: #fff;
    color: #333;
    border: 1px solid #e8e8e8;
    border-bottom-left-radius: 4px;
    font-weight: 400;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
}

.chatbot-message.admin .chatbot-message-content strong {
    color: #003A70;
    font-weight: 600;
    font-size: 14px;
    display: block;
    margin-bottom: 6px;
}

.chatbot-message-time {
    font-size: 11px;
    color: #999;
    margin-top: 6px;
    text-align: right;
    font-weight: 400;
    letter-spacing: 0.02em;
}

.chatbot-message.user .chatbot-message-time {
    text-align: left;
}

.chatbot-typing {
    display: flex;
    gap: 4px;
    padding: 12px 16px;
    background: #fff;
    border: 1px solid #e8e8e8;
    border-radius: 12px;
    border-bottom-left-radius: 4px;
    max-width: 75%;
}

.chatbot-typing span {
    width: 8px;
    height: 8px;
    background: #999;
    border-radius: 50%;
    animation: typing 1.4s infinite;
}

.chatbot-typing span:nth-child(2) {
    animation-delay: 0.2s;
}

.chatbot-typing span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typing {
    0%, 60%, 100% {
        transform: translateY(0);
        opacity: 0.7;
    }
    30% {
        transform: translateY(-10px);
        opacity: 1;
    }
}

.chatbot-input-container {
    padding: 20px;
    background: #fff;
    border-top: 1px solid #e8e8e8;
    display: flex;
    gap: 10px;
    flex-shrink: 0;
}

.chatbot-input {
    flex: 1;
    padding: 12px 16px;
    border: 1px solid #e8e8e8;
    border-radius: 24px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.3s;
}

.chatbot-input:focus {
    border-color: #0057A8;
}

.chatbot-send {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: linear-gradient(135deg, #003A70 0%, #0057A8 100%);
    color: #fff;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    transition: all 0.3s;
    flex-shrink: 0;
}

.chatbot-send:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(0, 87, 168, 0.3);
}

.chatbot-send:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.chatbot-request-human {
    margin-top: 8px;
    padding: 8px 12px;
    background: #fff3cd;
    border: 1px solid #ffc107;
    border-radius: 8px;
    font-size: 12px;
    color: #856404;
    text-align: center;
}

.chatbot-request-human a {
    color: #0057A8;
    text-decoration: none;
    font-weight: 600;
}

.chatbot-request-human a:hover {
    text-decoration: underline;
}

.chatbot-contact-form {
    margin-top: 10px;
}

.chatbot-contact-form input {
    font-family: 'Sarabun', 'Poppins', Arial, sans-serif;
}

.chatbot-contact-form input:focus {
    outline: none;
    border-color: #0057A8 !important;
    box-shadow: 0 0 0 3px rgba(0, 87, 168, 0.1);
}

.chatbot-contact-form button:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 87, 168, 0.3);
}

/* Responsive Design for All Screen Sizes */

/* Large Tablets and Small Desktops */
@media (max-width: 1024px) {
    .chatbot-container {
        width: 360px;
        height: 580px;
    }
    
    .chatbot-toggle {
        width: 56px;
        height: 56px;
        font-size: 22px;
    }
    
    .chatbot-invitation {
        font-size: 13px;
        padding: 10px 14px;
        bottom: 0;
        right: 70px;
    }
}

/* Tablets */
@media (max-width: 768px) {
    .chatbot-widget {
        bottom: 15px;
        right: 15px;
    }
    
    .chatbot-container {
        width: 340px;
        height: 550px;
        bottom: 75px;
    }
    
    .chatbot-toggle {
        width: 54px;
        height: 54px;
        font-size: 21px;
    }
    
    .chatbot-header {
        padding: 16px;
    }
    
    .chatbot-header h3 {
        font-size: 16px;
    }
    
    .chatbot-messages {
        padding: 16px;
    }
    
    .chatbot-input-container {
        padding: 16px;
    }
    
    .chatbot-invitation {
        font-size: 12px;
        padding: 10px 12px;
        bottom: 0;
        right: 65px;
    }
}

/* Small Tablets and Large Phones */
@media (max-width: 640px) {
    .chatbot-widget {
        bottom: 12px;
        right: 12px;
        left: auto;
    }
    
    .chatbot-container {
        position: fixed;
        width: calc(100vw - 30px);
        max-width: 400px;
        height: calc(100vh - 90px);
        max-height: calc(100vh - 90px);
        bottom: 75px;
        left: 50%;
        right: auto;
        transform: translateX(-50%);
        margin: 0;
    }
    
    .chatbot-toggle {
        width: 52px;
        height: 52px;
        font-size: 20px;
    }
    
    .chatbot-invitation {
        font-size: 12px;
        padding: 8px 12px;
        bottom: 0;
        right: 60px;
        white-space: normal;
        max-width: 200px;
        text-align: center;
    }
}

/* Mobile Phones */
@media (max-width: 480px) {
    .chatbot-widget {
        bottom: 10px;
        right: 10px;
        left: auto;
    }
    
    .chatbot-container {
        position: fixed;
        width: calc(100vw - 20px);
        max-width: 100%;
        height: calc(100vh - 80px);
        max-height: calc(100vh - 80px);
        bottom: 70px;
        left: 50%;
        right: auto;
        transform: translateX(-50%);
        margin: 0;
        border-radius: 12px;
    }
    
    .chatbot-toggle {
        width: 50px;
        height: 50px;
        font-size: 18px;
        bottom: 10px;
        right: 10px;
    }
    
    .chatbot-header {
        padding: 14px;
    }
    
    .chatbot-header h3 {
        font-size: 15px;
    }
    
    .chatbot-close {
        width: 28px;
        height: 28px;
        font-size: 20px;
    }
    
    .chatbot-messages {
        padding: 14px;
        gap: 12px;
    }
    
    .chatbot-message-content {
        font-size: 13px;
        padding: 12px 16px;
        max-width: 80%;
    }
    
    .chatbot-message-avatar {
        width: 34px;
        height: 34px;
        font-size: 16px;
    }
    
    .chatbot-input-container {
        padding: 14px;
        gap: 8px;
    }
    
    .chatbot-input {
        padding: 10px 14px;
        font-size: 13px;
    }
    
    .chatbot-send {
        width: 40px;
        height: 40px;
        font-size: 16px;
    }
    
    .chatbot-invitation {
        font-size: 11px;
        padding: 8px 10px;
        bottom: 0;
        right: 55px;
        max-width: 180px;
    }
    
    .chatbot-invitation::after {
        right: -8px;
        top: 50%;
        transform: translateY(-50%);
        border-top: 8px solid transparent;
        border-bottom: 8px solid transparent;
        border-left: 8px solid rgba(0, 58, 112, 0.45);
        border-top-color: transparent;
        border-right: none;
    }
}

/* Very Small Phones */
@media (max-width: 360px) {
    .chatbot-widget {
        bottom: 8px;
        right: 8px;
        left: auto;
    }
    
    .chatbot-container {
        position: fixed;
        width: calc(100vw - 16px);
        max-width: 100%;
        height: calc(100vh - 70px);
        max-height: calc(100vh - 70px);
        bottom: 65px;
        left: 50%;
        right: auto;
        transform: translateX(-50%);
        margin: 0;
    }
    
    .chatbot-toggle {
        width: 48px;
        height: 48px;
        font-size: 16px;
    }
    
    .chatbot-header {
        padding: 12px;
    }
    
    .chatbot-header h3 {
        font-size: 14px;
    }
    
    .chatbot-messages {
        padding: 12px;
    }
    
    .chatbot-message-content {
        font-size: 12px;
        padding: 10px 14px;
    }
    
    .chatbot-input-container {
        padding: 12px;
    }
    
    .chatbot-invitation {
        font-size: 10px;
        padding: 6px 8px;
        bottom: 0;
        right: 50px;
        max-width: 150px;
    }
    
    .chatbot-invitation::after {
        right: -8px;
        top: 50%;
        transform: translateY(-50%);
        border-top: 8px solid transparent;
        border-bottom: 8px solid transparent;
        border-left: 8px solid rgba(0, 58, 112, 0.45);
        border-top-color: transparent;
        border-right: none;
    }
}

/* Landscape Orientation for Mobile */
@media (max-width: 768px) and (orientation: landscape) {
    .chatbot-container {
        height: calc(100vh - 60px);
        bottom: 55px;
    }
    
    .chatbot-invitation {
        bottom: 0;
        right: 60px;
    }
}

/* High DPI Displays */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .chatbot-toggle {
        box-shadow: 0 4px 15px rgba(0, 58, 112, 0.25);
    }
    
    .chatbot-container {
        box-shadow: 0 8px 30px rgba(0, 0, 0, 0.15);
    }
}

