/* AI Chat Styles - Modern Design */

/* Main container - NO background gradient, just positioning */
.chat-container {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1;
    /* No background - background will be on chat-messages */
    background: transparent;
}

/* Chat messages area - with proper spacing and background */
.chat-messages {
    position: absolute;
    /* Toolbar is ~56px min-height + padding ~24px = ~80px, use 85px for safety margin */
    top: 85px;
    /* Input container is ~85-95px, nav bar is 64px (4rem), total ~180px for extra safety */
    bottom: 180px;
    left: 0;
    right: 0;
    overflow-y: auto;
    overflow-x: hidden;
    /* Extra padding top voor eerste bericht zichtbaarheid */
    padding: 1.5rem 0.75rem;
    padding-bottom: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    /* Witte achtergrond, geen gradient */
    background: #f8f9fa;
    /* Smooth scrolling */
    -webkit-overflow-scrolling: touch;
    scroll-behavior: smooth;
}

.chat-message {
    max-width: 85%;
    word-wrap: break-word;
    animation: messageSlideIn 0.3s ease-out;
    position: relative;
}

.user-message {
    align-self: flex-end;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-radius: 20px 20px 5px 20px;
    padding: 0.75rem 1rem;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.25);
    position: relative;
}

.user-message::before {
    content: '';
    position: absolute;
    bottom: 0;
    right: -8px;
    width: 0;
    height: 0;
    border: 8px solid transparent;
    border-left-color: #764ba2;
    border-bottom: none;
    border-right: none;
}

.assistant-message {
    align-self: flex-start;
    background: white;
    color: #333;
    border-radius: 20px 20px 20px 5px;
    padding: 0.75rem 1rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    border: 1px solid rgba(0, 0, 0, 0.05);
    position: relative;
}

.assistant-message::before {
    content: '';
    position: absolute;
    bottom: 0;
    left: -8px;
    width: 0;
    height: 0;
    border: 8px solid transparent;
    border-right-color: white;
    border-bottom: none;
    border-left: none;
}

.message-content {
    line-height: 1.5;
    font-size: 0.95rem;
}

.message-content strong {
    display: block;
    margin-bottom: 0.375rem;
    font-size: 0.8rem;
    opacity: 0.8;
    font-weight: 600;
}

.message-timestamp {
    font-size: 0.7rem;
    opacity: 0.6;
    margin-top: 0.25rem;
    text-align: right;
}

.user-message .message-timestamp {
    color: rgba(255, 255, 255, 0.85);
}

/* Input container - fixed above navigation bar */
.chat-input-container {
    position: fixed;
    /* Bottom nav bar is 64px (4rem), position input directly above it */
    bottom: 64px;
    left: 0;
    right: 0;
    padding: 0.75rem 1rem;
    padding-bottom: calc(0.75rem + env(safe-area-inset-bottom, 0px));
    background: white;
    border-top: 1px solid rgba(0, 0, 0, 0.08);
    display: flex;
    gap: 0.75rem;
    align-items: flex-end;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.05);
    z-index: 100;
    /* Ensure no purple background shows through */
    -webkit-transform: translateZ(0);
    transform: translateZ(0);
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
}

.input-group {
    display: flex;
    gap: 0.75rem;
    width: 100%;
    align-items: flex-end;
}

.input-group .form-control {
    flex: 1;
    border: 2px solid #e9ecef;
    border-radius: 25px;
    padding: 0.75rem 1.25rem;
    resize: none;
    min-height: 45px;
    max-height: 120px;
    font-family: inherit;
    font-size: 0.95rem;
    transition: all 0.3s ease;
    background: #f8f9fa;
    line-height: 1.4;
}

.input-group .form-control:focus {
    outline: none;
    border-color: #667eea;
    background: white;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.input-group .form-control::placeholder {
    color: #adb5bd;
    font-style: italic;
}

.input-group .btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 50%;
    width: 45px;
    height: 45px;
    min-width: 45px;
    min-height: 45px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
    font-size: 1.1rem;
    padding: 0;
    white-space: nowrap;
    position: relative;
    z-index: 6;
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    flex-shrink: 0;
}

.input-group .btn:hover:not(:disabled) {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.input-group .btn:active:not(:disabled) {
    transform: scale(0.95);
}

.input-group .btn:disabled {
    background: #adb5bd;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
    opacity: 0.6;
}

.input-group .btn:not(:disabled) {
    pointer-events: auto;
}

/* Disabled styling voor div button */
.input-group .btn.disabled,
.input-group .btn-secondary {
    background: #adb5bd !important;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
    opacity: 0.6;
    pointer-events: none;
}

.typing-indicator {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.875rem 1.125rem;
    color: #6c757d;
    font-style: italic;
    background: white;
    border-radius: 20px 20px 20px 5px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    align-self: flex-start;
    max-width: 85%;
}

.typing-indicator span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    animation: typing 1.4s infinite ease-in-out;
}

.typing-indicator span:nth-child(1) { 
    animation-delay: -0.32s; 
}

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

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

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

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

/* Scrollbar styling */
.chat-messages::-webkit-scrollbar {
    width: 4px;
}

.chat-messages::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.05);
    border-radius: 2px;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: rgba(102, 126, 234, 0.3);
    border-radius: 2px;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
    background: rgba(102, 126, 234, 0.5);
}

/* Mobile specific adjustments */
@media (max-width: 768px) {
    .chat-messages {
        /* Toolbar met extra veiligheidsmarge */
        top: 85px;
        /* Input + nav bar ruimte met extra marge voor laatste bericht */
        bottom: 180px;
        padding: 1.5rem 0.75rem;
        padding-bottom: 1.5rem;
        gap: 0.75rem;
    }
    
    .chat-input-container {
        bottom: 64px; /* Direct boven nav bar */
        padding: 0.75rem;
        padding-bottom: calc(0.75rem + env(safe-area-inset-bottom, 0px));
    }
    
    .chat-message {
        max-width: 90%;
    }
    
    .input-group .form-control {
        font-size: 16px; /* Prevents zoom on iOS */
    }
    
    .input-group .btn {
        width: 42px;
        height: 42px;
        min-width: 42px;
        min-height: 42px;
        font-size: 1rem;
    }
}

/* Extra small phones (iPhone SE, etc.) */
@media (max-width: 480px) {
    .chat-messages {
        top: 85px;
        bottom: 175px; /* Extra ruimte voor laatste bericht */
        padding: 1.25rem 0.6rem;
        padding-bottom: 1.25rem;
        gap: 0.6rem;
    }
    
    .chat-input-container {
        bottom: 64px;
        padding: 0.6rem;
        padding-bottom: calc(0.6rem + env(safe-area-inset-bottom, 0px));
    }
    
    .chat-message {
        max-width: 92%;
        padding: 0.65rem 0.9rem;
    }
    
    .input-group .form-control {
        font-size: 16px;
        padding: 0.65rem 1rem;
    }
    
    .input-group .btn {
        width: 40px;
        height: 40px;
        min-width: 40px;
        min-height: 40px;
        font-size: 0.95rem;
    }
}

/* Very small screens (landscape mode, etc.) */
@media (max-width: 360px) {
    .chat-messages {
        top: 85px;
        bottom: 170px;
        padding: 1rem 0.5rem;
        padding-bottom: 1rem;
        gap: 0.5rem;
    }
    
    .chat-input-container {
        bottom: 64px;
        padding: 0.5rem;
        padding-bottom: calc(0.5rem + env(safe-area-inset-bottom, 0px));
    }
    
    .chat-message {
        max-width: 95%;
        padding: 0.55rem 0.8rem;
    }
    
    .input-group .form-control {
        font-size: 16px;
        padding: 0.55rem 0.9rem;
    }
    
    .input-group .btn {
        width: 38px;
        height: 38px;
        min-width: 38px;
        min-height: 38px;
        font-size: 0.9rem;
    }
}

/* Force white background for chat messages - override any purple */
.chat-messages {
    background: #f8f9fa !important;
}

.assistant-message {
    background: white !important;
    color: #333 !important;
    border-color: rgba(0, 0, 0, 0.05) !important;
}

.assistant-message::before {
    border-right-color: white !important;
}

.chat-input-container {
    background: white !important;
    border-top-color: rgba(0, 0, 0, 0.08) !important;
}

.input-group .form-control {
    background: #f8f9fa !important;
    border-color: #e9ecef !important;
    color: #333 !important;
}

.input-group .form-control:focus {
    background: white !important;
    border-color: #667eea !important;
}

.input-group .form-control::placeholder {
    color: #adb5bd !important;
}

/* Ensure chat container itself has no background */
.chat-container {
    background: transparent !important;
}

/* Dark mode support - keep light theme */
@media (prefers-color-scheme: dark) {
    .chat-messages {
        background: #f8f9fa !important;
    }
    
    .assistant-message {
        background: white !important;
        color: #333 !important;
        border-color: rgba(0, 0, 0, 0.05) !important;
    }
    
    .assistant-message::before {
        border-right-color: white !important;
    }
    
    .chat-input-container {
        background: white !important;
        border-top-color: rgba(0, 0, 0, 0.08) !important;
    }
    
    .input-group .form-control {
        background: #f8f9fa !important;
        border-color: #e9ecef !important;
        color: #333 !important;
    }
    
    .input-group .form-control:focus {
        background: white !important;
        border-color: #667eea !important;
    }
    
    .input-group .form-control::placeholder {
        color: #adb5bd !important;
    }
    
    .chat-container {
        background: transparent !important;
    }
}

