/**
 * TechVilo Chatbot Widget Styles
 * Branded theme: Red (#ed1c24) and Black (#131314)
 *
 * Features:
 * - Fully responsive (desktop & mobile)
 * - Smooth animations
 * - Accessible (high contrast, focus states)
 * - Self-contained (scoped class names)
 *
 * @version 1.0.0
 */

/* ============================================
   Floating Button
   ============================================ */

.techvilo-chatbot-button {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: linear-gradient(135deg, #ed1c24 0%, #c91820 100%);
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(237, 28, 36, 0.4),
                0 8px 32px rgba(0, 0, 0, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 9998;
    overflow: hidden;
}

.techvilo-chatbot-button:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(237, 28, 36, 0.6),
                0 12px 40px rgba(0, 0, 0, 0.4);
}

.techvilo-chatbot-button:focus {
    outline: 2px solid #ed1c24;
    outline-offset: 4px;
}

.techvilo-chatbot-button:active {
    transform: scale(0.95);
}

/* Button Icons */
.techvilo-chatbot-icon,
.techvilo-chatbot-close-icon {
    width: 28px;
    height: 28px;
    color: white;
    transition: all 0.3s ease;
    position: absolute;
}

.techvilo-chatbot-icon {
    opacity: 1;
    transform: rotate(0deg);
}

.techvilo-chatbot-close-icon {
    opacity: 0;
    transform: rotate(90deg);
}

.techvilo-chatbot-button-active .techvilo-chatbot-icon {
    opacity: 0;
    transform: rotate(-90deg);
}

.techvilo-chatbot-button-active .techvilo-chatbot-close-icon {
    opacity: 1;
    transform: rotate(0deg);
}

/* Pulse Animation */
.techvilo-chatbot-button::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: #ed1c24;
    animation: techvilo-pulse 2s ease-in-out infinite;
    opacity: 0;
}

@keyframes techvilo-pulse {
    0% {
        transform: scale(1);
        opacity: 0.6;
    }
    50% {
        transform: scale(1.3);
        opacity: 0;
    }
    100% {
        transform: scale(1);
        opacity: 0;
    }
}

/* ============================================
   Chat Window
   ============================================ */

.techvilo-chatbot-window {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 400px;
    max-width: calc(100vw - 48px);
    height: 600px;
    max-height: calc(100vh - 100px);
    background: #1a1a1c;
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5),
                0 0 1px rgba(255, 255, 255, 0.1);
    display: flex;
    flex-direction: column;
    z-index: 9999;
    opacity: 0;
    transform: translateY(20px) scale(0.95);
    pointer-events: none;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
}

.techvilo-chatbot-window.techvilo-chatbot-open {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: all;
}

/* ============================================
   Header
   ============================================ */

.techvilo-chatbot-header {
    background: linear-gradient(135deg, #131314 0%, #1f1f21 100%);
    padding: 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid rgba(237, 28, 36, 0.2);
    flex-shrink: 0;
}

.techvilo-chatbot-header-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.techvilo-chatbot-avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: linear-gradient(135deg, #ed1c24 0%, #c91820 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.techvilo-chatbot-avatar svg {
    width: 24px;
    height: 24px;
    color: white;
}

.techvilo-chatbot-title {
    color: #ffffff;
    font-size: 16px;
    font-weight: 600;
    margin: 0 0 4px 0;
    letter-spacing: -0.02em;
}

.techvilo-chatbot-status {
    color: #9ca3af;
    font-size: 12px;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 6px;
}

.techvilo-chatbot-status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #10b981;
    animation: techvilo-status-pulse 2s ease-in-out infinite;
}

@keyframes techvilo-status-pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

.techvilo-chatbot-minimize {
    width: 32px;
    height: 32px;
    border: none;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.techvilo-chatbot-minimize:hover {
    background: rgba(237, 28, 36, 0.2);
}

.techvilo-chatbot-minimize svg {
    width: 18px;
    height: 18px;
    color: #9ca3af;
}

/* ============================================
   Messages Area
   ============================================ */

.techvilo-chatbot-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    background: #131314;
    scroll-behavior: smooth;
}

/* Custom Scrollbar */
.techvilo-chatbot-messages::-webkit-scrollbar {
    width: 6px;
}

.techvilo-chatbot-messages::-webkit-scrollbar-track {
    background: transparent;
}

.techvilo-chatbot-messages::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
}

.techvilo-chatbot-messages::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* ============================================
   Message Bubbles
   ============================================ */

.techvilo-chatbot-message {
    display: flex;
    flex-direction: column;
    max-width: 85%;
    animation: techvilo-message-appear 0.3s ease;
}

@keyframes techvilo-message-appear {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.techvilo-chatbot-message-user {
    align-self: flex-end;
}

.techvilo-chatbot-message-assistant {
    align-self: flex-start;
}

.techvilo-chatbot-message-content {
    padding: 12px 16px;
    border-radius: 12px;
    line-height: 1.5;
    font-size: 14px;
    word-wrap: break-word;
}

.techvilo-chatbot-message-user .techvilo-chatbot-message-content {
    background: linear-gradient(135deg, #ed1c24 0%, #c91820 100%);
    color: white;
    border-bottom-right-radius: 4px;
}

.techvilo-chatbot-message-assistant .techvilo-chatbot-message-content {
    background: #1f1f21;
    color: #e5e7eb;
    border-bottom-left-radius: 4px;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.techvilo-chatbot-message-time {
    font-size: 11px;
    color: #6b7280;
    margin-top: 4px;
    padding: 0 4px;
}

.techvilo-chatbot-message-user .techvilo-chatbot-message-time {
    text-align: right;
}

.techvilo-chatbot-message-assistant .techvilo-chatbot-message-time {
    text-align: left;
}

/* ============================================
   Typing Indicator
   ============================================ */

.techvilo-chatbot-typing .techvilo-chatbot-message-content {
    padding: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.techvilo-chatbot-typing-dots {
    display: flex;
    gap: 6px;
}

.techvilo-chatbot-typing-dots span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #6b7280;
    animation: techvilo-typing-bounce 1.4s ease-in-out infinite;
}

.techvilo-chatbot-typing-dots span:nth-child(2) {
    animation-delay: 0.2s;
}

.techvilo-chatbot-typing-dots span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes techvilo-typing-bounce {
    0%, 60%, 100% {
        transform: translateY(0);
        opacity: 0.7;
    }
    30% {
        transform: translateY(-10px);
        opacity: 1;
    }
}

/* ============================================
   Error Messages
   ============================================ */

.techvilo-chatbot-error {
    background: rgba(239, 68, 68, 0.1);
    color: #fca5a5;
    padding: 12px 16px;
    border-radius: 8px;
    font-size: 13px;
    text-align: center;
    border: 1px solid rgba(239, 68, 68, 0.2);
    animation: techvilo-error-shake 0.4s ease;
}

@keyframes techvilo-error-shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

/* ============================================
   Input Area
   ============================================ */

.techvilo-chatbot-input-area {
    padding: 16px 20px;
    background: #1a1a1c;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    display: flex;
    gap: 12px;
    align-items: flex-end;
    flex-shrink: 0;
}

.techvilo-chatbot-input {
    flex: 1;
    background: #131314;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 12px 16px;
    color: white;
    font-size: 14px;
    font-family: inherit;
    resize: none;
    min-height: 44px;
    max-height: 120px;
    transition: all 0.2s ease;
}

.techvilo-chatbot-input:focus {
    outline: none;
    border-color: #ed1c24;
    box-shadow: 0 0 0 3px rgba(237, 28, 36, 0.1);
}

.techvilo-chatbot-input::placeholder {
    color: #6b7280;
}

.techvilo-chatbot-send {
    width: 44px;
    height: 44px;
    border: none;
    background: linear-gradient(135deg, #ed1c24 0%, #c91820 100%);
    border-radius: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all 0.2s ease;
}

.techvilo-chatbot-send:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(237, 28, 36, 0.4);
}

.techvilo-chatbot-send:active {
    transform: translateY(0);
}

.techvilo-chatbot-send svg {
    width: 20px;
    height: 20px;
    color: white;
}

/* ============================================
   Mobile Responsive
   ============================================ */

@media (max-width: 768px) {
    .techvilo-chatbot-button {
        bottom: 16px;
        right: 16px;
        width: 56px;
        height: 56px;
    }

    .techvilo-chatbot-icon,
    .techvilo-chatbot-close-icon {
        width: 24px;
        height: 24px;
    }

    .techvilo-chatbot-window {
        bottom: 0;
        right: 0;
        left: 0;
        width: 100%;
        max-width: 100%;
        height: 100vh;
        max-height: 100vh;
        border-radius: 0;
    }

    .techvilo-chatbot-header {
        padding: 16px;
    }

    .techvilo-chatbot-avatar {
        width: 40px;
        height: 40px;
    }

    .techvilo-chatbot-title {
        font-size: 15px;
    }

    .techvilo-chatbot-status {
        font-size: 11px;
    }

    .techvilo-chatbot-messages {
        padding: 16px;
    }

    .techvilo-chatbot-input-area {
        padding: 12px 16px;
    }

    .techvilo-chatbot-message {
        max-width: 90%;
    }
}

@media (max-width: 480px) {
    .techvilo-chatbot-message {
        max-width: 95%;
    }

    .techvilo-chatbot-message-content {
        font-size: 13px;
        padding: 10px 14px;
    }
}

/* ============================================
   Accessibility
   ============================================ */

/* High contrast mode support */
@media (prefers-contrast: high) {
    .techvilo-chatbot-button {
        border: 2px solid white;
    }

    .techvilo-chatbot-input {
        border-width: 2px;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Focus visible for keyboard navigation */
.techvilo-chatbot-button:focus-visible,
.techvilo-chatbot-minimize:focus-visible,
.techvilo-chatbot-send:focus-visible,
.techvilo-chatbot-input:focus-visible {
    outline: 2px solid #ed1c24;
    outline-offset: 2px;
}

/* ============================================
   Print Styles
   ============================================ */

@media print {
    .techvilo-chatbot-button,
    .techvilo-chatbot-window {
        display: none !important;
    }
}
