/* Floating Widget Styles */
.ai-chat-widget {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 10001; /* Higher than mobile-bottom-nav (9999) */
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    transition: bottom 0.3s ease;
}

@media (max-width: 767.98px) {
    .ai-chat-widget {
        bottom: 75px; /* Above mobile-bottom-nav (60px) + spacing */
        right: 15px;
        left: 15px; /* Set left and right to constrain max width */
        z-index: 100000;
        display: flex;
        flex-direction: column;
        align-items: flex-end;
    }
    .ai-chat-container {
        width: 100%;
        max-width: 100%;
    }
    .ai-chat-widget:not(.fullscreen) .card-body {
        height: 60vh !important;
        max-height: 400px;
    }
}

/* Toggle Button */
.ai-chat-toggle {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.3s;
}

.ai-chat-toggle:hover {
    transform: scale(1.1);
}

.notification-dot {
    position: absolute;
    top: 0;
    right: 0;
    width: 15px;
    height: 15px;
    background-color: #e74c3c;
    border-radius: 50%;
    border: 2px solid white;
}

/* Chat Container */
.ai-chat-container {
    width: 350px;
    display: none; /* Hidden by default, toggled by JS */
    border-radius: 15px;
    overflow: hidden;
    transition: all 0.3s ease;
}

/* Collapsed State (Only button visible) */
.ai-chat-widget.collapsed .ai-chat-container {
    display: none;
}
.ai-chat-widget.collapsed .ai-chat-toggle {
    display: flex;
}

/* Expanded State (Container visible, button hidden) */
.ai-chat-widget.expanded .ai-chat-container {
    display: block;
}
.ai-chat-widget.expanded .ai-chat-toggle {
    display: none;
}

/* Fullscreen State */
.ai-chat-widget.fullscreen {
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    bottom: 0;
    right: 0;
}

.ai-chat-widget.fullscreen .ai-chat-container {
    width: 100%;
    height: 100%;
    border-radius: 0;
}

.ai-chat-widget.fullscreen .card-body {
    height: calc(100vh - 50px) !important; /* Adjust based on header height */
}

/* Chat Box Styles */
.chat-box {
    background-color: #f8f9fa;
}

.message {
    margin-bottom: 10px;
    padding: 8px 12px;
    border-radius: 15px;
    max-width: 80%;
    font-size: 0.9rem;
}

.user-message {
    background-color: #3498db;
    color: white;
    margin-left: auto;
    border-bottom-right-radius: 5px;
}

.system-message {
    background-color: #e9ecef;
    color: #333;
    margin-right: auto;
    border-bottom-left-radius: 5px;
}

/* Voice Mode Styles */
.mode-btn {
    border: 1px solid #dee2e6;
    background: white;
    color: #666;
    transition: all 0.3s;
}

.mode-btn.active {
    background: #007bff;
    color: white;
    border-color: #007bff;
}

.mode-btn:not(.active) {
    background-color: white;
    color: #6c757d;
    border-color: #dee2e6;
}

.mic-button:hover {
    transform: scale(1.05);
}

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

.replay-btn {
    background: none;
    border: none;
    font-size: 14px;
    cursor: pointer;
    margin-left: 8px;
    opacity: 0.7;
    transition: opacity 0.2s;
}

.replay-btn:hover {
    opacity: 1;
}

/* Custom Range Slider Styles */
input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 6px;
    background: #ddd;
    border-radius: 3px;
    outline: none;
    opacity: 0.9;
    transition: opacity 0.2s;
}

input[type="range"]:hover {
    opacity: 1;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    background: #007bff;
    border-radius: 50%;
    cursor: pointer;
}

input[type="range"]::-moz-range-thumb {
    width: 16px;
    height: 16px;
    background: #007bff;
    border-radius: 50%;
    cursor: pointer;
    border: none;
}

input[type="range"]::-webkit-slider-runnable-track {
    width: 100%;
    height: 6px;
    background: #ddd;
    border-radius: 3px;
}

input[type="range"]::-moz-range-track {
    width: 100%;
    height: 6px;
    background: #ddd;
    border-radius: 3px;
}

/* Typing Indicator (3 Dots Animation) */
.typing-indicator {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    margin-bottom: 10px;
    background-color: #e9ecef;
    border-radius: 18px;
    max-width: 60px;
    margin-right: auto;
    animation: fadeIn 0.3s ease-in;
}

.typing-indicator span {
    height: 8px;
    width: 8px;
    margin: 0 2px;
    background-color: #90949c;
    border-radius: 50%;
    display: inline-block;
    animation: typing-bounce 1.4s infinite ease-in-out both;
}

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

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

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

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