:root {
    --chatbot-primary: #00A651;
    --chatbot-primary-dark: #008c44;
    --chatbot-primary-darker: #006633;
    --chatbot-light: #FFFFFF;
    --chatbot-gray-50: #f8f9fa;
    --chatbot-gray-100: #e9ecef;
    --chatbot-gray-200: #e2e8f0;
    --chatbot-gray-300: #d1d5db;
    --chatbot-gray-400: #9ca3af;
    --chatbot-gray-500: #64748b;
    --chatbot-gray-600: #475569;
    --chatbot-gray-700: #374151;
    --chatbot-gray-800: #2d3748;
    --chatbot-gray-900: #1a202c;
    --chatbot-shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.05);
    --chatbot-shadow-md: 0 4px 20px rgba(0, 0, 0, 0.1);
    --chatbot-shadow-lg: 0 8px 30px rgba(0, 0, 0, 0.15);
    --chatbot-shadow-primary: 0 4px 20px rgba(0, 166, 81, 0.3);
    --chatbot-shadow-primary-lg: 0 8px 30px rgba(0, 166, 81, 0.6);
    --chatbot-font-family: 'Poppins', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.tierp-chatbot-container {
    position: fixed;
    bottom: 80px;
    right: 20px;
    z-index: 9999;
    font-family: var(--chatbot-font-family);
}

.tierp-chat-toggle {
    background: linear-gradient(135deg, var(--chatbot-primary) 0%, var(--chatbot-primary-dark) 100%);
    color: var(--chatbot-light);
    border: none;
    padding: 18px;
    border-radius: 50%;
    cursor: pointer;
    box-shadow: var(--chatbot-shadow-primary);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    animation: tierp-pulse 3s infinite;
    -webkit-tap-highlight-color: transparent;
    position: relative;
    overflow: hidden;
    width: 60px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.tierp-chat-toggle:hover {
    transform: scale(1.1);
    box-shadow: var(--chatbot-shadow-primary-lg);
}

.tierp-chat-toggle::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    transition: all 0.3s ease;
    transform: translate(-50%, -50%);
}

.tierp-chat-toggle:hover::before {
    width: 100%;
    height: 100%;
}

.tierp-chat-toggle svg {
    width: 28px;
    height: 28px;
    fill: currentColor;
    position: relative;
    z-index: 1;
}

.tierp-chat-window {
    width: 320px;
    height: 480px;
    background: var(--chatbot-light);
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
    display: none;
    flex-direction: column;
    border: 1px solid var(--chatbot-gray-200);
    margin-bottom: 15px;
    overflow: hidden;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    transform: scale(0.8);
    opacity: 0;
    z-index: 9999;
}

.tierp-chat-window.open {
    display: flex;
    animation: chat-window-open 0.3s ease-out forwards;
}

.tierp-chat-header {
    background: linear-gradient(135deg, var(--chatbot-primary) 0%, var(--chatbot-primary-dark) 100%);
    color: var(--chatbot-light);
    padding: 20px;
    border-radius: 16px 16px 0 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: relative;
    overflow: hidden;
    min-height: 70px;
}

.tierp-chat-header::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.1), transparent);
    animation: chat-header-shine 3s infinite;
}

.tierp-chat-header h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
}

.tierp-chat-header h3::after {
    content: ' ♻️';
    font-size: 16px;
    margin-left: 6px;
}

.tierp-chat-header p {
    margin: 0;
    font-size: 13px;
    opacity: 0.9;
    margin-top: 2px;
}

.tierp-header-buttons {
    display: flex;
    gap: 8px;
}

.tierp-header-button {
    background: none;
    border: none;
    color: var(--chatbot-light);
    cursor: pointer;
    padding: 10px;
    border-radius: 6px;
    transition: background-color 0.3s ease;
    -webkit-tap-highlight-color: transparent;
    min-width: 36px;
    min-height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.tierp-header-button:hover {
    background-color: rgba(255, 255, 255, 0.2);
    transform: scale(1.05);
}

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

.tierp-header-button svg {
    width: 18px;
    height: 18px;
    fill: currentColor;
}

.tierp-messages {
    flex: 1;
    overflow-y: auto;
    padding: 18px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    -webkit-overflow-scrolling: touch;
    scroll-behavior: smooth;
    max-height: calc(500px - 140px);
    background: linear-gradient(to bottom, #fafafa 0%, #ffffff 100%);
}

.tierp-messages::-webkit-scrollbar {
    width: 8px;
}

.tierp-messages::-webkit-scrollbar-track {
    background: var(--chatbot-gray-50);
    border-radius: 4px;
}

.tierp-messages::-webkit-scrollbar-thumb {
    background: var(--chatbot-primary);
    border-radius: 4px;
    opacity: 0.7;
}

.tierp-messages::-webkit-scrollbar-thumb:hover {
    background: var(--chatbot-primary-dark);
    opacity: 1;
}

.tierp-message {
    display: flex;
    animation: message-slide-in 0.3s ease-out;
}

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

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

.tierp-message-content {
    max-width: 85%;
    padding: 14px 18px;
    border-radius: 18px;
    font-size: 15px;
    line-height: 1.5;
    white-space: pre-line;
    word-wrap: break-word;
    position: relative;
}

.tierp-message.user .tierp-message-content {
    background: linear-gradient(135deg, var(--chatbot-primary) 0%, var(--chatbot-primary-dark) 100%);
    color: var(--chatbot-light);
    border-bottom-right-radius: 6px;
    box-shadow: 0 2px 8px rgba(0, 166, 81, 0.3);
}

.tierp-message.bot .tierp-message-content {
    background: linear-gradient(135deg, var(--chatbot-gray-50) 0%, var(--chatbot-gray-100) 100%);
    color: var(--chatbot-gray-800);
    border-bottom-left-radius: 6px;
    border-left: 4px solid var(--chatbot-primary);
    box-shadow: var(--chatbot-shadow-sm);
}

.tierp-message-content strong {
    color: var(--chatbot-primary);
    font-weight: 600;
}

.tierp-message.user .tierp-message-content strong {
    color: var(--chatbot-light);
    opacity: 0.95;
}

.tierp-message-content .emoji {
    font-size: 1.1em;
    margin: 0 2px;
}

.chat-form-link {
    color: var(--chatbot-primary) !important;
    text-decoration: underline;
    font-weight: 600;
    cursor: pointer;
    transition: color 0.2s ease;
}

.chat-form-link:hover {
    color: var(--chatbot-primary-dark) !important;
    text-decoration: none;
}

.tierp-message.bot .chat-form-link {
    color: var(--chatbot-primary) !important;
}

.tierp-message.user .chat-form-link {
    color: var(--chatbot-light) !important;
    opacity: 0.9;
}

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

.tierp-message.bot .tierp-message-time {
    text-align: left;
}

.tierp-typing-animation {
    display: flex;
    align-items: center;
    font-style: italic;
    color: var(--chatbot-gray-500);
    gap: 8px;
}

.tierp-typing-animation .dots {
    display: inline-block;
    animation: tierp-typing-dots 1.5s infinite;
}

.tierp-quick-replies {
    padding: 4px 15px 4px 15px !important;
    border-top: 1px solid var(--chatbot-gray-200);
    background: var(--chatbot-gray-50);
    min-height: 38px !important;
}

.tierp-quick-replies p {
    font-size: 10px !important;
    color: var(--chatbot-gray-500);
    margin: 3px 0 3px 0 !important;
    font-weight: 500;
}

.tierp-quick-reply {
    display: inline-block !important;
    background: var(--chatbot-light) !important;
    border: 1px solid var(--chatbot-primary) !important;
    color: var(--chatbot-primary) !important;
    padding: 3px 6px !important;
    margin: 1px 3px 1px 0 !important;
    border-radius: 8px !important;
    font-size: 10px !important;
    cursor: pointer;
    transition: all 0.2s ease;
    -webkit-tap-highlight-color: transparent;
    min-height: 20px !important;
    max-height: 20px !important;
    font-weight: 500;
    line-height: 1 !important;
    font-family: var(--chatbot-font-family) !important;
}

.tierp-quick-reply:hover,
.tierp-quick-reply:active {
    background: var(--chatbot-primary) !important;
    color: var(--chatbot-light) !important;
    transform: translateY(-1px);
}

.tierp-input-area {
    padding: 15px 18px 18px;
    border-top: 1px solid var(--chatbot-gray-200);
    display: flex;
    gap: 10px;
    align-items: flex-end;
    background: var(--chatbot-gray-50);
}

.tierp-input {
    flex: 1;
    padding: 12px 16px;
    border: 2px solid var(--chatbot-gray-200);
    border-radius: 20px;
    font-size: 14px;
    outline: none;
    transition: all 0.3s ease;
    -webkit-appearance: none;
    min-height: 42px;
    resize: none;
    font-family: var(--chatbot-font-family);
    background: var(--chatbot-light);
    line-height: 1.4;
}

.tierp-input:focus {
    border-color: var(--chatbot-primary);
    box-shadow: 0 0 0 3px rgba(0, 166, 81, 0.1);
}

.tierp-send-button {
    background: linear-gradient(135deg, var(--chatbot-primary) 0%, var(--chatbot-primary-dark) 100%);
    color: var(--chatbot-light);
    border: none;
    padding: 12px;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 42px;
    min-height: 42px;
    -webkit-tap-highlight-color: transparent;
    flex-shrink: 0;
}

.tierp-send-button:hover {
    background: linear-gradient(135deg, var(--chatbot-primary-dark) 0%, var(--chatbot-primary-darker) 100%);
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(0, 166, 81, 0.4);
}

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

.tierp-send-button:disabled {
    background: var(--chatbot-gray-300);
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.tierp-send-button svg {
    width: 20px;
    height: 20px;
    fill: currentColor;
}

@keyframes tierp-pulse {
    0%, 70%, 100% {
        transform: scale(1);
        box-shadow: var(--chatbot-shadow-primary);
    }
    35% {
        transform: scale(1.05);
        box-shadow: 0 6px 25px rgba(0, 166, 81, 0.5);
    }
}

@keyframes chat-window-open {
    from {
        transform: scale(0.8) translateY(20px);
        opacity: 0;
    }
    to {
        transform: scale(1) translateY(0);
        opacity: 1;
    }
}

@keyframes chat-header-shine {
    0% { left: -100%; }
    100% { left: 100%; }
}

@keyframes message-slide-in {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes tierp-typing-dots {
    0%, 20% { content: ''; }
    40% { content: '.'; }
    60% { content: '..'; }
    80%, 100% { content: '...'; }
}

.tierp-chat-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.3);
    z-index: 9998;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.tierp-chat-overlay.show {
    display: block;
    opacity: 1;
}


@media screen and (max-width: 992px) {
    .tierp-chat-window {
        width: 340px;
        height: 480px;
    }
}

@media screen and (max-width: 768px) {
    .tierp-chatbot-container {
        bottom: 75px;
        right: 15px;
        left: auto;
    }

    .tierp-chat-toggle {
        width: 56px;
        height: 56px;
        padding: 16px;
    }

    .tierp-chat-toggle svg {
        width: 24px;
        height: 24px;
    }

    .tierp-chat-window {
        width: calc(100vw - 30px);
        height: calc(100vh - 120px);
        max-height: 75vh;
        position: fixed;
        bottom: 140px;
        right: 15px;
        left: 15px;
        margin: 0;
        top: auto;
        z-index: 9999;
    }

    .tierp-chat-header {
        padding: 14px 18px;
        min-height: 55px;
        position: relative;
        z-index: 9999;
    }

    .tierp-chat-header h3 {
        font-size: 15px;
    }

    .tierp-chat-header p {
        font-size: 11px;
    }

    .tierp-messages {
        padding: 12px;
        max-height: calc(70vh - 75px);
    }

    .tierp-input-area {
        padding: 12px;
        gap: 8px;
    }

    .tierp-input {
        font-size: 16px;
        min-height: 40px;
        padding: 10px 14px;
    }

    .tierp-send-button {
        min-width: 40px;
        min-height: 40px;
        touch-action: manipulation;
        padding: 10px;
    }

    .tierp-send-button svg {
        width: 18px;
        height: 18px;
    }

    .tierp-quick-reply {
        font-size: 6px !important;
        padding: 0px 2px !important;
        margin: 0px !important;
        min-height: 10px !important;
        max-height: 10px !important;
        touch-action: manipulation;
        border-radius: 3px !important;
    }

    .tierp-quick-replies {
        padding: 1px 12px 1px 12px !important;
        min-height: 15px !important;
    }

    .tierp-quick-replies p {
        font-size: 6px !important;
        margin: 0px 0 1px 0 !important;
    }

    .tierp-header-button {
        min-width: 40px;
        min-height: 40px;
        touch-action: manipulation;
        padding: 10px;
    }

    .tierp-header-button svg {
        width: 16px;
        height: 16px;
    }

    .tierp-message-content {
        font-size: 13px;
        padding: 10px 14px;
        max-width: 90%;
    }
}

@media screen and (max-width: 576px) {
    .tierp-chat-window {
        height: calc(100vh - 100px);
        max-height: 80vh;
        bottom: 75px;
    }

    .tierp-messages {
        max-height: calc(85vh - 160px);
        padding: 12px;
        gap: 12px;
    }

    .tierp-input-area {
        padding: 12px;
        gap: 8px;
    }

    .tierp-message-content {
        font-size: 13px;
        padding: 10px 14px;
    }

    .tierp-quick-reply {
        font-size: 8px !important;
        padding: 2px 4px !important;
        min-height: 16px !important;
        max-height: 16px !important;
    }

    .tierp-quick-replies {
        min-height: 24px !important;
    }
}

@supports (-webkit-touch-callout: none) {
    @media screen and (max-width: 768px) {
        .tierp-chat-window {
            height: calc(100vh - 120px);
        }

        .tierp-messages {
            max-height: calc(100vh - 200px);
        }
    }
}

@media (prefers-reduced-motion: reduce) {
    .tierp-chat-toggle {
        animation: none;
    }

    .tierp-chat-header::before {
        animation: none;
    }

    * {
        transition-duration: 0.01ms !important;
        animation-duration: 0.01ms !important;
    }
}
