/**
 * FORDIPS TECH - AI Chat Styles
 * Beautiful, modern chat interface
 */

/* ============================================
   CHAT WIDGET CONTAINER
   ============================================ */
.ai-chat-widget {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 10000;
    font-family: 'Inter', sans-serif;
}

/* ============================================
   CHAT BUTTON
   ============================================ */
.ai-chat-button {
    position: relative;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
    border: none;
    box-shadow: 0 4px 20px rgba(37, 99, 235, 0.4);
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    -webkit-tap-highlight-color: transparent; /* Remove tap highlight on mobile */
    touch-action: manipulation; /* Prevent double-tap zoom */
    user-select: none;
}

.ai-chat-button:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 30px rgba(37, 99, 235, 0.5);
}

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

/* Touch feedback for mobile */
@media (hover: none) and (pointer: coarse) {
    .ai-chat-button:active {
        background: linear-gradient(135deg, #1d4ed8 0%, #1e40af 100%);
    }
}

.ai-chat-button .chat-icon,
.ai-chat-button .close-icon {
    transition: all 0.3s ease;
}

.ai-chat-button .close-icon {
    display: none;
    position: absolute;
}

.ai-chat-button.active .chat-icon {
    display: none;
}

.ai-chat-button.active .close-icon {
    display: block;
}

/* Chat Badge */
.chat-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #ef4444;
    color: white;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    display: none;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 600;
    border: 2px solid white;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% {
        transform: scale(1);
        opacity: 1;
    }
    50% {
        transform: scale(1.1);
        opacity: 0.8;
    }
}

/* ============================================
   CHAT WINDOW
   ============================================ */
.ai-chat-window {
    position: absolute;
    bottom: 80px;
    right: 0;
    width: 380px;
    height: 600px;
    background: white;
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
    display: flex;
    flex-direction: column;
    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;
    will-change: transform, opacity; /* Hardware acceleration */
    -webkit-overflow-scrolling: touch; /* Smooth scrolling on iOS */
}

.ai-chat-window.active {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: all;
}

/* ============================================
   CHAT HEADER
   ============================================ */
.chat-header {
    background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
    color: white;
    padding: 16px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.chat-header-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.chat-avatar {
    width: 40px;
    height: 40px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(10px);
}

.chat-title {
    font-weight: 600;
    font-size: 16px;
}

.chat-status {
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 6px;
    opacity: 0.95;
}

.status-dot {
    width: 8px;
    height: 8px;
    background: #10b981;
    border-radius: 50%;
    animation: statusPulse 2s infinite;
}

@keyframes statusPulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

.chat-minimize {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    user-select: none;
}

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

.chat-minimize:active {
    background: rgba(255, 255, 255, 0.4);
    transform: scale(0.95);
}

/* ============================================
   CHAT MESSAGES
   ============================================ */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 20px;
    background: #f9fafb;
    display: flex;
    flex-direction: column;
    gap: 16px;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch; /* Smooth scrolling on iOS */
    overscroll-behavior: contain; /* Prevent scroll chaining */
}

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

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

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

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

/* Hide scrollbar on mobile for cleaner look */
@media (max-width: 768px) {
    .chat-messages::-webkit-scrollbar {
        width: 4px;
    }
}

/* ============================================
   MESSAGE BUBBLES
   ============================================ */
.chat-message {
    display: flex;
    flex-direction: column;
    animation: messageSlideIn 0.3s ease;
}

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

.chat-message.user {
    align-items: flex-end;
}

.chat-message.assistant {
    align-items: flex-start;
}

.message-bubble {
    max-width: 85%;
    padding: 12px 16px;
    border-radius: 16px;
    word-wrap: break-word;
    line-height: 1.5;
    font-size: 14px;
}

.chat-message.user .message-bubble {
    background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
    color: white;
    border-bottom-right-radius: 4px;
}

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

.message-time {
    font-size: 11px;
    color: #9ca3af;
    margin-top: 4px;
    padding: 0 4px;
}

/* ============================================
   MESSAGE ACTIONS
   ============================================ */
.message-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 12px;
}

.action-btn {
    background: #f3f4f6;
    border: 1px solid #e5e7eb;
    padding: 8px 14px;
    border-radius: 20px;
    font-size: 13px;
    color: #374151;
    cursor: pointer;
    transition: all 0.2s;
    font-weight: 500;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    user-select: none;
}

.action-btn:hover {
    background: #e5e7eb;
    border-color: #d1d5db;
    transform: translateY(-1px);
}

.action-btn:active {
    transform: translateY(0);
    background: #d1d5db;
}

/* Touch feedback for mobile */
@media (hover: none) and (pointer: coarse) {
    .action-btn:active {
        background: #cbd5e1;
        transform: scale(0.98);
    }
}

/* ============================================
   TYPING INDICATOR
   ============================================ */
.typing-indicator .message-bubble {
    background: white;
    padding: 16px 20px;
}

.typing-dots {
    display: flex;
    gap: 6px;
}

.typing-dots span {
    width: 8px;
    height: 8px;
    background: #9ca3af;
    border-radius: 50%;
    animation: typingBounce 1.4s infinite;
}

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

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

@keyframes typingBounce {
    0%, 60%, 100% {
        transform: translateY(0);
    }
    30% {
        transform: translateY(-8px);
    }
}

/* ============================================
   QUICK ACTIONS
   ============================================ */
.chat-quick-actions {
    padding: 12px 20px;
    background: white;
    border-top: 1px solid #e5e7eb;
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.quick-action-btn {
    background: linear-gradient(135deg, #f3f4f6 0%, #e5e7eb 100%);
    border: 1px solid #d1d5db;
    padding: 8px 12px;
    border-radius: 20px;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
    font-weight: 500;
    color: #374151;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    user-select: none;
}

.quick-action-btn:hover {
    background: linear-gradient(135deg, #e5e7eb 0%, #d1d5db 100%);
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.quick-action-btn:active {
    transform: translateY(0);
    background: linear-gradient(135deg, #d1d5db 0%, #cbd5e1 100%);
}

/* Touch feedback for mobile */
@media (hover: none) and (pointer: coarse) {
    .quick-action-btn:active {
        background: linear-gradient(135deg, #cbd5e1 0%, #b3bcc7 100%);
        transform: scale(0.98);
    }
}

/* ============================================
   INPUT AREA
   ============================================ */
.chat-input-area {
    background: white;
    padding: 16px 20px;
    border-top: 1px solid #e5e7eb;
}

.chat-input-wrapper {
    display: flex;
    gap: 8px;
    align-items: center;
}

.chat-input {
    flex: 1;
    padding: 12px 16px;
    border: 2px solid #334155;
    border-radius: 24px;
    font-size: 14px;
    background: #1e293b;
    color: #94a3b8;
    outline: none;
    transition: all 0.35s ease;
    font-family: inherit;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.chat-input::placeholder {
    color: #64748b;
    opacity: 1;
}

.chat-input:hover {
    border-color: #475569;
}

.chat-input:focus,
.chat-input:not(:placeholder-shown) {
    border-color: #2563eb;
    background: #ffffff;
    color: #1e293b;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.15);
}

.chat-input:focus::placeholder {
    color: #94a3b8;
}

.chat-send-btn {
    background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
    border: none;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    box-shadow: 0 2px 8px rgba(37, 99, 235, 0.3);
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    user-select: none;
}

.chat-send-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.4);
}

.chat-send-btn:active {
    transform: scale(0.95);
}

.chat-send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* Touch feedback for mobile */
@media (hover: none) and (pointer: coarse) {
    .chat-send-btn:active:not(:disabled) {
        background: linear-gradient(135deg, #1d4ed8 0%, #1e40af 100%);
        transform: scale(0.92);
    }
}

/* ============================================
   SUGGESTIONS
   ============================================ */
.chat-suggestions {
    display: flex;
    gap: 8px;
    margin-top: 8px;
    flex-wrap: wrap;
}

.suggestion-chip {
    background: #f3f4f6;
    border: 1px solid #e5e7eb;
    padding: 6px 12px;
    border-radius: 16px;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
}

.suggestion-chip:hover {
    background: #e5e7eb;
}

/* ============================================
   MOBILE RESPONSIVE
   ============================================ */
@media (max-width: 768px) {
    .ai-chat-widget {
        bottom: 15px;
        right: 15px;
    }

    .ai-chat-button {
        width: 60px;
        height: 60px;
        box-shadow: 0 4px 24px rgba(37, 99, 235, 0.5);
    }

    .ai-chat-window {
        width: 100vw;
        height: 100vh;
        bottom: 0;
        right: 0;
        border-radius: 0;
        max-height: 100vh;
    }

    .message-bubble {
        max-width: 85%;
        font-size: 15px;
        padding: 14px 16px;
    }

    .chat-header {
        padding: 16px 20px;
        padding-top: max(16px, env(safe-area-inset-top));
    }

    .chat-messages {
        padding: 16px;
        padding-bottom: max(16px, env(safe-area-inset-bottom));
    }

    .chat-input-area {
        padding: 16px 20px;
        padding-bottom: max(16px, env(safe-area-inset-bottom));
    }

    .chat-input {
        font-size: 16px; /* Prevents iOS zoom on focus */
        padding: 14px 18px;
        min-height: 48px; /* Touch-friendly */
    }

    .chat-send-btn {
        width: 48px;
        height: 48px;
        min-width: 48px;
        min-height: 48px;
    }

    .quick-action-btn {
        font-size: 14px;
        padding: 10px 16px;
        min-height: 44px; /* Touch-friendly */
        white-space: nowrap;
    }

    .action-btn {
        font-size: 14px;
        padding: 10px 16px;
        min-height: 44px;
    }

    .chat-minimize {
        width: 40px;
        height: 40px;
        min-width: 40px;
        min-height: 40px;
    }
}

@media (max-width: 480px) {
    .ai-chat-button {
        width: 56px;
        height: 56px;
    }

    .chat-header {
        padding: 14px 16px;
        padding-top: max(14px, env(safe-area-inset-top));
    }

    .chat-messages {
        padding: 12px;
        gap: 12px;
    }

    .chat-input-area {
        padding: 12px 16px;
        padding-bottom: max(12px, env(safe-area-inset-bottom));
    }

    .quick-action-btn {
        font-size: 13px;
        padding: 9px 14px;
    }

    .message-bubble {
        font-size: 14px;
        padding: 12px 14px;
    }
}

/* Landscape mode on mobile */
@media (max-width: 768px) and (orientation: landscape) {
    .ai-chat-window {
        height: 100vh;
    }

    .chat-messages {
        padding: 12px;
    }
}

/* Tablet optimizations */
@media (min-width: 481px) and (max-width: 768px) {
    .ai-chat-window {
        width: 420px;
        height: 650px;
        bottom: 80px;
        right: 0;
        border-radius: 16px;
        max-height: calc(100vh - 100px);
    }
}

/* Large screens */
@media (min-width: 1200px) {
    .ai-chat-window {
        width: 420px;
        height: 650px;
    }
}

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

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

/* ============================================
   ACCESSIBILITY
   ============================================ */
.ai-chat-button:focus,
.chat-send-btn:focus,
.action-btn:focus,
.quick-action-btn:focus {
    outline: 2px solid #2563eb;
    outline-offset: 2px;
}

.chat-input:focus {
    outline: none;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .ai-chat-window {
        border: 2px solid #000;
    }

    .message-bubble {
        border: 1px solid #000;
    }
}

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

/* ============================================
   DARK MODE (Optional)
   ============================================ */
@media (prefers-color-scheme: dark) {
    .ai-chat-window {
        background: #1f2937;
    }

    .chat-messages {
        background: #111827;
    }

    .chat-message.assistant .message-bubble {
        background: #374151;
        color: #f9fafb;
    }

    .message-time {
        color: #6b7280;
    }

    .action-btn {
        background: #374151;
        border-color: #4b5563;
        color: #f9fafb;
    }

    .action-btn:hover {
        background: #4b5563;
    }

    .quick-action-btn {
        background: #374151;
        border-color: #4b5563;
        color: #f9fafb;
    }

    .quick-action-btn:hover {
        background: #4b5563;
    }

    .chat-input {
        background: #374151;
        border-color: #4b5563;
        color: #f9fafb;
    }

    .chat-input::placeholder {
        color: #6b7280;
    }

    .chat-quick-actions,
    .chat-input-area {
        background: #1f2937;
        border-top-color: #374151;
    }
}
