/* AnTinPhat AI Chatbot - Frontend Styles */

#atp-chatbot-container {
    position: fixed;
    z-index: 999999;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
}

/* Position variants */
#atp-chatbot-container.position-bottom-right {
    bottom: 20px;
    right: 15px;
}

#atp-chatbot-container.position-bottom-left {
    bottom: 20px;
    left: 20px;
}

#atp-chatbot-container.position-top-right {
    top: 20px;
    right: 20px;
}

#atp-chatbot-container.position-top-left {
    top: 20px;
    left: 20px;
}

/* Mobile: Adjust position to avoid taskbar */
@media (max-width: 768px) {
    #atp-chatbot-container.position-bottom-right {
        bottom: 100px;
        right: 12px;
    }

    #atp-chatbot-container.position-bottom-left {
        bottom: 100px;
    }
}

/* Chat Button */
.atp-chat-button {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.3);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    color: white;
    font-size: 32px;
    overflow: hidden;
}

/* Chat Button Icon - SVG */
.atp-chat-icon-svg {
    width: 32px;
    height: 32px;
    stroke: white;
    flex-shrink: 0;
}

/* Chat Button Icon - Custom Image */
.atp-chat-icon-img {
    width: 70%;
    height: 70%;
    object-fit: contain;
    flex-shrink: 0;
}

/* Button Size Variants */
.atp-button-size-small .atp-chat-button {
    width: 48px;
    height: 48px;
}

.atp-button-size-small .atp-chat-icon-svg {
    width: 24px;
    height: 24px;
}

.atp-button-size-small .atp-chat-icon-img {
    width: 60%;
    height: 60%;
}

.atp-button-size-medium .atp-chat-button {
    width: 64px;
    height: 64px;
}

.atp-button-size-medium .atp-chat-icon-svg {
    width: 32px;
    height: 32px;
}

.atp-button-size-medium .atp-chat-icon-img {
    width: 70%;
    height: 70%;
}

.atp-button-size-large .atp-chat-button {
    width: 80px;
    height: 80px;
}

.atp-button-size-large .atp-chat-icon-svg {
    width: 40px;
    height: 40px;
}

.atp-button-size-large .atp-chat-icon-img {
    width: 75%;
    height: 75%;
}

.atp-chat-button:hover {
    transform: scale(1.1);
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.4);
}

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

/* Mobile: Smaller button like call button */
@media (max-width: 768px) {
    .atp-chat-button {
        width: 38px;
        height: 38px;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25) !important;
    }

    .atp-chat-icon-svg {
        width: 24px !important;
        height: 24px !important;
    }

    .atp-chat-icon-img {
        width: 55% !important;
        height: 55% !important;
    }
}

/* Chat Window */
.atp-chat-window {
    background: white;
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    width: 400px;
    height: 600px;
    animation: slideUp 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

/* Mobile: Full screen chat with safe area */
@media (max-width: 768px) {
    .atp-chat-window {
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
        width: 100vw !important;
        height: 100vh !important;
        height: 100dvh !important; /* Dynamic viewport height for mobile browsers */
        max-height: -webkit-fill-available !important;
        border-radius: 0;
        animation: slideUpMobile 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    }

    @keyframes slideUpMobile {
        from {
            transform: translateY(100%);
        }
        to {
            transform: translateY(0);
        }
    }
}

/* Chat Header */
.atp-chat-header {
    padding: 20px;
    color: white;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    flex-shrink: 0;
}

/* Mobile: Add safe area for header */
@media (max-width: 768px) {
    .atp-chat-header {
        padding: max(env(safe-area-inset-top), 15px) 20px 15px 20px;
        min-height: 60px;
    }

    .atp-chat-header-info h3 {
        font-size: 16px;
    }

    .atp-chat-header-info p {
        font-size: 12px;
    }
}

.atp-chat-header-info h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 700;
}

.atp-chat-header-info p {
    margin: 5px 0 0 0;
    font-size: 13px;
    opacity: 0.9;
}

.atp-chat-close {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 20px;
    transition: background 0.2s;
}

.atp-chat-close:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* Chat Messages */
.atp-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: #f9fafb;
    scroll-behavior: smooth;
}

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

.atp-chat-messages::-webkit-scrollbar-track {
    background: transparent;
}

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

.atp-chat-messages::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* Message */
.atp-message {
    display: flex;
    margin-bottom: 16px;
    animation: messageIn 0.3s ease-out;
}

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

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

.atp-message.bot {
    justify-content: flex-start;
}

.atp-message-content {
    max-width: 75%;
    padding: 12px 16px;
    border-radius: 16px;
    font-size: 14px;
    line-height: 1.5;
    white-space: pre-wrap;
    word-wrap: break-word;
}

.atp-message.user .atp-message-content {
    background: rgb(0, 131, 62);
    color: white;
    border-bottom-right-radius: 4px;
}

.atp-message.bot .atp-message-content {
    background: white;
    color: #1f2937;
    border-bottom-left-radius: 4px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

/* Typing Indicator */
.atp-typing {
    display: flex;
    gap: 4px;
    padding: 12px 16px;
}

.atp-typing-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #94a3b8;
    animation: typing 1.4s infinite;
}

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

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

@keyframes typing {
    0%, 60%, 100% {
        transform: translateY(0);
        opacity: 0.7;
    }
    30% {
        transform: translateY(-10px);
        opacity: 1;
    }
}

/* Chat Input */
.atp-chat-input {
    padding: 20px;
    background: white;
    border-top: 1px solid #e5e7eb;
}

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

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

.atp-chat-input input:focus {
    border-color: rgb(0, 131, 62);
    box-shadow: 0 0 0 3px rgba(0, 131, 62, 0.1);
}

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

.atp-send-button {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: none;
    background: rgb(0, 131, 62);
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
}

.atp-send-button:hover:not(:disabled) {
    background: rgb(0, 110, 52);
    transform: scale(1.05);
}

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

.atp-send-button:disabled {
    background: #cbd5e1;
    cursor: not-allowed;
}

.atp-send-icon {
    width: 20px;
    height: 20px;
}

/* Hotline Footer */
.atp-hotline-footer {
    padding: 12px 20px;
    text-align: center;
    background: #f9fafb;
    border-top: 1px solid #e5e7eb;
    font-size: 12px;
    color: #6b7280;
}

.atp-hotline-footer a {
    color: rgb(0, 131, 62);
    font-weight: 600;
    text-decoration: none;
}

.atp-hotline-footer a:hover {
    text-decoration: underline;
}

/* Loading spinner */
.atp-spinner {
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top: 2px solid white;
    border-radius: 50%;
    width: 16px;
    height: 16px;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Utility classes */
.atp-hidden {
    display: none !important;
}

/* Accessibility */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Dark mode support (optional) */
@media (prefers-color-scheme: dark) {
    .atp-chat-window {
        background: #1f2937;
    }
    
    .atp-chat-messages {
        background: #111827;
    }
    
    .atp-message.bot .atp-message-content {
        background: #374151;
        color: #f3f4f6;
    }
    
    .atp-chat-input {
        background: #1f2937;
        border-top-color: #374151;
    }
    
    .atp-chat-input input {
        background: #374151;
        border-color: #4b5563;
        color: #f3f4f6;
    }
}
