:root {
    --vh: 1vh;
}

.chatbot-container {
    position: fixed;
    z-index: 9999;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

.chatbot-position-bottom {
    bottom: 0;
    left: 0;
    right: 0;
}

.chatbot-position-top {
    top: 0;
    left: 0;
    right: 0;
}

.chatbot-position-left {
    left: 0;
    top: 0;
    bottom: 0;
}

.chatbot-position-right {
    right: 0;
    top: 0;
    bottom: 0;
}

.chatbot-position-lightbox {
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    pointer-events: none;
}

.chatbot-position-lightbox::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.2);
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
    z-index: 1;
}

.chatbot-position-lightbox.chatbot-open::before {
    opacity: 1;
}

.chatbot-position-lightbox .chatbot-window {
    position: relative;
    z-index: 2;
}

.chatbot-position-lightbox .chatbot-bar {
    z-index: 2;
}

.chatbot-position-lightbox .chatbot-bar {
    pointer-events: auto;
}

.chatbot-position-lightbox .chatbot-window {
    pointer-events: auto;
}

.chatbot-bar {
    width: 100%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    cursor: pointer;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 24px;
    transition: box-shadow 0.2s;
}

.chatbot-position-top .chatbot-bar {
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.chatbot-position-left .chatbot-bar,
.chatbot-position-right .chatbot-bar {
    flex-direction: column;
    width: 60px;
    height: 100vh;
    padding: 24px 8px;
    writing-mode: vertical-lr;
}

.chatbot-bar:hover {
    box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.15);
}

.chatbot-position-top .chatbot-bar:hover {
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
}

.chatbot-bar-content {
    display: flex;
    align-items: center;
    gap: 12px;
}

.chatbot-bar-icon {
    width: 24px;
    height: 24px;
    flex-shrink: 0;
}

.chatbot-bar-icon svg {
    width: 100%;
    height: 100%;
}

.chatbot-bar-text {
    font-size: 16px;
    font-weight: 600;
}

.chatbot-position-left .chatbot-bar-text,
.chatbot-position-right .chatbot-bar-text {
    writing-mode: vertical-lr;
    transform: rotate(180deg);
}

.chatbot-window {
    background: white;
    box-shadow: 0 -4px 24px rgba(0, 0, 0, 0.12);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.chatbot-position-bottom .chatbot-window {
    width: 100%;
    height: 500px;
    max-height: 70vh;
    animation: slideUp 0.3s ease-out;
}

.chatbot-position-top .chatbot-window {
    width: 100%;
    height: 500px;
    max-height: 70vh;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.12);
    animation: slideDown 0.3s ease-out;
}

.chatbot-position-left .chatbot-window {
    height: 100vh;
    width: 400px;
    max-width: 90vw;
    animation: slideRight 0.3s ease-out;
}

.chatbot-position-right .chatbot-window {
    height: 100vh;
    width: 400px;
    max-width: 90vw;
    animation: slideLeft 0.3s ease-out;
}

.chatbot-position-lightbox .chatbot-window {
    width: calc(100vw - 40px);
    max-width: calc(100vw - 40px);
    height: 55vh;
    max-height: 55vh;
    border-radius: 24px;
    box-shadow: 0 -8px 32px rgba(0, 0, 0, 0.15);
    animation: slideUpFromBottom 0.4s ease-out;
    position: fixed;
    bottom: 20px;
    left: 20px;
    right: 20px;
    overflow: hidden;
    z-index: 9998;
}

.chatbot-position-lightbox .chatbot-bar {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: auto;
    border-radius: 50%;
    padding: 0;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    pointer-events: auto;
    width: 60px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.chatbot-position-lightbox .chatbot-bar .chatbot-bar-content {
    flex-direction: column;
    gap: 0;
}

.chatbot-position-lightbox .chatbot-bar .chatbot-bar-icon {
    width: 32px;
    height: 32px;
}

.chatbot-position-lightbox .chatbot-bar .chatbot-bar-text,
.chatbot-position-lightbox .chatbot-bar svg:last-child {
    display: none;
}

.chatbot-position-lightbox.chatbot-open .chatbot-bar {
    display: none;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(100%);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-100%);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideRight {
    from {
        opacity: 0;
        transform: translateX(-100%);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes slideLeft {
    from {
        opacity: 0;
        transform: translateX(100%);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

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

@keyframes slideUpFromBottom {
    from {
        opacity: 0;
        transform: translateY(100%);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.chatbot-position-lightbox .chatbot-robot-banner {
    position: fixed;
    left: 20px;
    bottom: 20px;
    width: 280px;
    height: auto;
    z-index: 10000;
    pointer-events: none;
    transform: translateY(-40px);
}

.chatbot-robot-banner img {
    width: 100%;
    height: auto;
    display: block;
    filter: drop-shadow(0 8px 16px rgba(0, 0, 0, 0.15));
}

.chatbot-header {
    background: white;
    color: #2d3748;
    padding: 24px 32px 16px 32px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: relative;
    border-bottom: 1px solid #e5e7eb;
}

.chatbot-position-lightbox .chatbot-header {
    padding-left: 320px;
}

.chatbot-position-lightbox .chatbot-messages {
    padding-left: 320px;
}

.chatbot-position-lightbox .chatbot-input-form {
    padding-left: 320px;
}

.chatbot-header-content {
    display: flex;
    align-items: center;
    gap: 12px;
}

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

.chatbot-header-avatar {
    width: 32px;
    height: 32px;
}

.chatbot-header-avatar svg {
    width: 100%;
    height: 100%;
}

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

.chatbot-close-btn {
    background: transparent;
    border: none;
    color: #6b7280;
    cursor: pointer;
    padding: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    border-radius: 50%;
    width: 32px;
    height: 32px;
}

.chatbot-close-btn:hover {
    background: #f3f4f6;
    color: #1f2937;
}

.chatbot-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: #f7f8fa;
}

.starter-questions {
    margin: 20px 0;
    padding: 0 10px;
}

.starter-questions-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px;
    max-width: 100%;
}

.starter-question-card {
    background: white;
    border: 1px solid #e5e5e5;
    border-radius: 12px;
    padding: 16px;
    font-size: 14px;
    font-weight: 500;
    color: #2d3748;
    text-align: left;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    line-height: 1.5;
}

.starter-question-card:hover {
    background: #f8f9fa;
    border-color: #cbd5e0;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    transform: translateY(-1px);
}

.starter-question-card:active {
    transform: translateY(0);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

@media (max-width: 600px) {
    .starter-questions-grid {
        grid-template-columns: 1fr;
    }
}

.chatbot-message-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.chatbot-message {
    display: flex;
    gap: 8px;
    align-items: flex-start;
}

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

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

.message-avatar svg {
    width: 100%;
    height: 100%;
}

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

.message-bubble {
    max-width: 70%;
    padding: 12px 16px;
    border-radius: 12px;
    position: relative;
}

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

.message-user .message-bubble {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-bottom-right-radius: 4px;
}

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

.message-bubble a {
    color: #3B82F6;
    text-decoration: underline;
}

.message-content {
    word-break: break-word;
}

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

.chatbot-input-form {
    display: flex;
    gap: 8px;
    padding: 16px;
    background: white;
    border-top: 1px solid #e5e7eb;
}

.chatbot-input {
    flex: 1;
    padding: 12px 16px;
    border: 1px solid #e5e7eb;
    border-radius: 24px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s, opacity 0.2s;
}

.chatbot-input:focus {
    border-color: #667eea;
}

.chatbot-input:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    background: #f9fafb;
}

.chatbot-send-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: transform 0.2s, opacity 0.2s;
}

.chatbot-send-btn:hover:not(:disabled) {
    transform: scale(1.05);
}

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

.chatbot-send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.chatbot-send-btn svg {
    width: 20px;
    height: 20px;
}

.chatbot-input-wrapper {
    flex: 1;
    position: relative;
    display: flex;
    align-items: center;
}

.chatbot-input-wrapper .chatbot-input {
    width: 100%;
    padding-right: 70px;
}

.chatbot-char-counter {
    position: absolute;
    right: 12px;
    font-size: 11px;
    color: #9ca3af;
    pointer-events: none;
    transition: color 0.2s;
}

.chatbot-char-counter.near-limit {
    color: #f59e0b;
}

.chatbot-char-counter.at-limit {
    color: #ef4444;
    font-weight: 600;
}

.template-section {
    transition: opacity 0.3s ease;
}

.template-section:not(.active) {
    position: absolute;
    left: -9999px;
}

/* Typing Indicator Animations */
.typing-indicator {
    display: inline-flex;
    align-items: center;
    padding: 12px 16px;
    background: #f3f4f6;
    border-radius: 18px;
    margin: 8px 0;
}

/* Dots Animation */
.typing-dots span {
    display: inline-block;
    width: 8px;
    height: 8px;
    background: #9ca3af;
    border-radius: 50%;
    margin: 0 3px;
    animation: typing-dots 1.4s infinite;
}

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

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

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

/* Pulse Animation */
.typing-pulse .pulse-circle {
    width: 24px;
    height: 24px;
    background: #667eea;
    border-radius: 50%;
    animation: typing-pulse 1.5s ease-in-out infinite;
}

@keyframes typing-pulse {
    0%, 100% {
        transform: scale(0.8);
        opacity: 0.5;
    }
    50% {
        transform: scale(1.2);
        opacity: 1;
    }
}

/* Bounce Animation */
.typing-bounce span {
    display: inline-block;
    width: 10px;
    height: 10px;
    background: #667eea;
    border-radius: 50%;
    margin: 0 4px;
    animation: typing-bounce 0.6s infinite alternate;
}

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

.typing-bounce span:nth-child(3) {
    animation-delay: 0.2s;
}

@keyframes typing-bounce {
    from {
        transform: translateY(0);
    }
    to {
        transform: translateY(-12px);
    }
}

/* Typing Text Animation */
.typing-text span {
    font-size: 14px;
    color: #6b7280;
    font-style: italic;
    animation: typing-fade 1.5s ease-in-out infinite;
}

@keyframes typing-fade {
    0%, 100% {
        opacity: 0.4;
    }
    50% {
        opacity: 1;
    }
}

/* Spinner Animation */
.typing-spinner .spinner {
    width: 20px;
    height: 20px;
    border: 3px solid #e5e7eb;
    border-top-color: #667eea;
    border-radius: 50%;
    animation: typing-spinner 0.8s linear infinite;
}

@keyframes typing-spinner {
    to {
        transform: rotate(360deg);
    }
}

@media (max-width: 768px) {
    .chatbot-position-bottom .chatbot-window,
    .chatbot-position-top .chatbot-window {
        height: 400px;
        max-height: 60vh;
    }
    
    .chatbot-position-left .chatbot-window,
    .chatbot-position-right .chatbot-window {
        width: 320px;
        max-width: 85vw;
    }
    
    .chatbot-position-lightbox .chatbot-window {
        width: calc(100vw - 40px);
        max-width: calc(100vw - 40px);
        left: 20px;
        right: 20px;
        bottom: 20px;
        height: 66vh;
        max-height: 66vh;
    }
    
    .chatbot-position-lightbox .chatbot-robot-banner {
        left: 20px;
        bottom: 20px;
        width: 180px;
        transform: translateY(-40px);
    }
    
    .chatbot-position-lightbox .chatbot-header {
        padding-left: 220px;
    }
    
    .chatbot-position-lightbox .chatbot-messages {
        padding-left: 220px;
    }
    
    .chatbot-position-lightbox .chatbot-input-form {
        padding-left: 220px;
    }
    
    .chatbot-bar-text {
        font-size: 14px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .chatbot-window,
    .chatbot-position-bottom .chatbot-window,
    .chatbot-position-top .chatbot-window,
    .chatbot-position-left .chatbot-window,
    .chatbot-position-right .chatbot-window,
    .chatbot-position-lightbox .chatbot-window {
        animation: none !important;
    }
    
    .chatbot-bar,
    .chatbot-send-btn,
    .starter-question-card,
    .vr-stat-card {
        transition: none !important;
    }
    
    .typing-dots span,
    .typing-bounce span {
        animation: none !important;
        opacity: 0.7;
    }
    
    .typing-pulse .pulse-circle {
        animation: none !important;
        opacity: 1;
    }
    
    .typing-spinner .spinner {
        animation: none !important;
    }
    
    .typing-text span {
        animation: none !important;
        opacity: 1;
    }
    
    .chatbot-position-lightbox::before {
        transition: none !important;
    }
    
    .message-bubble,
    .chatbot-message {
        transition: none !important;
    }
}

@media (max-width: 768px) {
    .chatbot-position-lightbox .chatbot-window {
        width: calc(100vw - 40px);
        max-width: calc(100vw - 40px);
        left: 20px;
        right: 20px;
        bottom: 20px;
        height: calc(var(--vh, 1vh) * 77);
        max-height: calc(var(--vh, 1vh) * 77);
    }
    
    .chatbot-robot-banner {
        display: none !important;
        visibility: hidden !important;
        position: absolute !important;
        opacity: 0 !important;
    }
    
    .chatbot-position-lightbox .chatbot-robot-banner {
        display: none !important;
        visibility: hidden !important;
        position: absolute !important;
        opacity: 0 !important;
    }
    
    .chatbot-position-lightbox .chatbot-header {
        padding-left: 24px;
        padding-right: 16px;
    }
    
    .chatbot-position-lightbox .chatbot-messages {
        padding-left: 24px;
        padding-right: 24px;
    }
    
    .chatbot-position-lightbox .chatbot-input-form {
        padding-left: 24px;
        padding-right: 24px;
    }
    
    .chatbot-header h3 {
        font-size: 16px;
    }
}
