/**
 * Chatbot Responsive Styles
 * Optimized for all screen sizes: Mobile, Tablet, Desktop
 */

/* ============================================
   CHATBOT WIDGET BASE STYLES
   ============================================ */

.chatbot-widget {
    position: fixed;
    bottom: 30px;
    right: 30px;
    z-index: 9999;
}

.chatbot-button {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, #ff6b4a 0%, #ffb347 100%);
    color: white;
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(255, 107, 74, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    transition: all 0.3s ease;
    position: relative;
}

.chatbot-button:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(255, 107, 74, 0.6);
}

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

/* Pulse animation for attention */
.chatbot-button::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    border-radius: 50%;
    background: linear-gradient(135deg, #ff6b4a 0%, #ffb347 100%);
    opacity: 0;
    animation: pulse 2s infinite;
}

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

/* ============================================
   CHATBOT CONTAINER - DESKTOP (Default)
   ============================================ */

.chatbot-container {
    position: absolute;
    bottom: 80px;
    right: 0;
    width: 380px;
    height: 550px;
    background: white;
    border-radius: 16px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    display: none;
    flex-direction: column;
    overflow: hidden;
    animation: slideUp 0.3s ease;
}

.chatbot-container.open {
    display: flex;
}

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

/* ============================================
   CHATBOT HEADER
   ============================================ */

.chatbot-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 1.2rem 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.chatbot-header h3 {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.chatbot-close {
    cursor: pointer;
    font-size: 1.8rem;
    line-height: 1;
    transition: transform 0.2s ease;
    background: none;
    border: none;
    color: white;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.chatbot-close:hover {
    transform: rotate(90deg) scale(1.2);
}

/* ============================================
   CHATBOT MESSAGES AREA
   ============================================ */

.chatbot-messages {
    flex: 1;
    padding: 1.5rem;
    overflow-y: auto;
    background: #f8f9fa;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

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

.chatbot-messages::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.chatbot-messages::-webkit-scrollbar-thumb {
    background: #667eea;
    border-radius: 3px;
}

.chatbot-messages::-webkit-scrollbar-thumb:hover {
    background: #764ba2;
}

/* Message bubbles */
.message {
    max-width: 80%;
    padding: 0.8rem 1rem;
    border-radius: 12px;
    word-wrap: break-word;
    animation: fadeIn 0.3s ease;
}

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

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

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

/* ============================================
   CHATBOT INPUT AREA
   ============================================ */

.chatbot-input {
    padding: 1rem 1.5rem;
    border-top: 1px solid #e0e0e0;
    display: flex;
    gap: 0.8rem;
    background: white;
    flex-shrink: 0;
}

.chatbot-input input {
    flex: 1;
    padding: 0.8rem 1rem;
    border: 1px solid #ddd;
    border-radius: 24px;
    font-size: 0.95rem;
    outline: none;
    transition: border-color 0.3s ease;
}

.chatbot-input input:focus {
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.chatbot-input button {
    width: 45px;
    height: 45px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    flex-shrink: 0;
}

.chatbot-input button:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.chatbot-input button:active {
    transform: scale(0.95);
}

/* ============================================
   LARGE DESKTOP (1440px+)
   ============================================ */

@media (min-width: 1440px) {
    .chatbot-container {
        width: 450px;
        height: 650px;
    }
    
    .chatbot-header h3 {
        font-size: 1.2rem;
    }
    
    .chatbot-messages {
        padding: 2rem;
    }
}

/* ============================================
   LAPTOP/DESKTOP (1024px - 1439px)
   ============================================ */

@media (min-width: 1024px) and (max-width: 1439px) {
    .chatbot-container {
        width: 400px;
        height: 600px;
    }
}

/* ============================================
   TABLET (768px - 1023px)
   ============================================ */

@media (max-width: 1023px) and (min-width: 768px) {
    .chatbot-widget {
        bottom: 20px;
        right: 20px;
    }
    
    .chatbot-button {
        width: 56px;
        height: 56px;
        font-size: 1.4rem;
    }
    
    .chatbot-container {
        width: 360px;
        height: 520px;
        bottom: 85px;
    }
    
    .chatbot-header {
        padding: 1rem 1.2rem;
    }
    
    .chatbot-messages {
        padding: 1.2rem;
    }
    
    .chatbot-input {
        padding: 0.9rem 1.2rem;
    }
}

/* ============================================
   MOBILE LANDSCAPE (481px - 767px)
   ============================================ */

@media (max-width: 767px) and (min-width: 481px) {
    .chatbot-widget {
        bottom: 20px;
        right: 20px;
    }
    
    .chatbot-button {
        width: 54px;
        height: 54px;
        font-size: 1.3rem;
    }
    
    .chatbot-container {
        width: 90%;
        max-width: 380px;
        height: 70vh;
        max-height: 500px;
        bottom: 80px;
        right: 5%;
    }
    
    .chatbot-header {
        padding: 1rem;
    }
    
    .chatbot-header h3 {
        font-size: 1rem;
    }
    
    .chatbot-messages {
        padding: 1rem;
    }
    
    .chatbot-input {
        padding: 0.8rem 1rem;
    }
    
    .chatbot-input input {
        font-size: 16px; /* Prevents zoom on iOS */
    }
}

/* ============================================
   MOBILE PORTRAIT (320px - 480px)
   ============================================ */

@media (max-width: 480px) {
    .chatbot-widget {
        bottom: 15px;
        right: 15px;
    }
    
    .chatbot-button {
        width: 52px;
        height: 52px;
        font-size: 1.2rem;
    }
    
    /* Full screen chatbot on small mobile */
    .chatbot-container {
        position: fixed;
        width: 100%;
        height: 100%;
        max-height: 100vh;
        bottom: 0;
        right: 0;
        left: 0;
        top: 0;
        border-radius: 0;
        max-width: none;
    }
    
    .chatbot-header {
        padding: 1rem;
    }
    
    .chatbot-header h3 {
        font-size: 1rem;
    }
    
    .chatbot-close {
        font-size: 1.6rem;
    }
    
    .chatbot-messages {
        padding: 1rem;
        gap: 0.8rem;
    }
    
    .message {
        max-width: 85%;
        padding: 0.7rem 0.9rem;
        font-size: 0.95rem;
    }
    
    .chatbot-input {
        padding: 0.8rem;
        gap: 0.6rem;
    }
    
    .chatbot-input input {
        padding: 0.7rem 0.9rem;
        font-size: 16px; /* Prevents zoom on iOS */
    }
    
    .chatbot-input button {
        width: 42px;
        height: 42px;
    }
}

/* ============================================
   EXTRA SMALL MOBILE (< 360px)
   ============================================ */

@media (max-width: 359px) {
    .chatbot-button {
        width: 48px;
        height: 48px;
        font-size: 1.1rem;
        bottom: 12px;
        right: 12px;
    }
    
    .chatbot-header {
        padding: 0.8rem;
    }
    
    .chatbot-header h3 {
        font-size: 0.95rem;
    }
    
    .chatbot-messages {
        padding: 0.8rem;
    }
    
    .message {
        font-size: 0.9rem;
        padding: 0.6rem 0.8rem;
    }
    
    .chatbot-input {
        padding: 0.7rem;
    }
    
    .chatbot-input input {
        padding: 0.6rem 0.8rem;
        font-size: 16px;
    }
    
    .chatbot-input button {
        width: 38px;
        height: 38px;
        font-size: 0.9rem;
    }
}

/* ============================================
   LANDSCAPE ORIENTATION (Mobile)
   ============================================ */

@media (max-height: 600px) and (orientation: landscape) {
    .chatbot-container {
        height: 90vh;
        max-height: 90vh;
    }
    
    .chatbot-messages {
        padding: 0.8rem;
    }
    
    .chatbot-input {
        padding: 0.6rem 0.8rem;
    }
}

/* ============================================
   TOUCH DEVICES OPTIMIZATION
   ============================================ */

@media (hover: none) and (pointer: coarse) {
    /* Larger touch targets */
    .chatbot-button {
        min-width: 52px;
        min-height: 52px;
    }
    
    .chatbot-close {
        min-width: 44px;
        min-height: 44px;
    }
    
    .chatbot-input button {
        min-width: 44px;
        min-height: 44px;
    }
    
    /* Remove hover effects on touch devices */
    .chatbot-button:hover {
        transform: none;
    }
    
    /* Add active states instead */
    .chatbot-button:active {
        transform: scale(0.95);
    }
}

/* ============================================
   PRINT STYLES
   ============================================ */

@media print {
    .chatbot-widget {
        display: none !important;
    }
}

/* ============================================
   ACCESSIBILITY IMPROVEMENTS
   ============================================ */

/* Focus visible for keyboard navigation */
.chatbot-button:focus-visible,
.chatbot-close:focus-visible,
.chatbot-input button:focus-visible {
    outline: 3px solid #667eea;
    outline-offset: 2px;
}

.chatbot-input input:focus-visible {
    outline: 2px solid #667eea;
    outline-offset: 2px;
}

/* Reduced motion for users who prefer it */
@media (prefers-reduced-motion: reduce) {
    .chatbot-container,
    .message,
    .chatbot-button,
    .chatbot-close {
        animation: none;
        transition: none;
    }
    
    .chatbot-button::before {
        animation: none;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .chatbot-container {
        border: 2px solid currentColor;
    }
    
    .chatbot-input input {
        border: 2px solid currentColor;
    }
}
