/* Unified Desktop AI Chat Styles - Fun Zone */
/* Consistent UI/UX for all three AI characters: Foreman, Motley, Safety Officer */

/* === SHARED CHAT CONTAINER === */
.ai-chat-container {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.8);
    display: flex;
    gap: 20px;
    z-index: 10000;
    opacity: 0;
    transition: all 0.3s ease;
}

.ai-chat-container.chat-open {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
}

.ai-chat-container.chat-closing {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.8);
}

/* === SHARED BACKDROP === */
.chat-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(3px);
    z-index: 9999;
    animation: fadeIn 0.3s ease;
}

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

/* === UNIFIED CHAT WINDOW === */
.ai-chat-window {
    width: 850px;
    height: calc(100vh - 60px);
    max-height: 90vh;
    border-radius: 15px;
    display: flex;
    flex-direction: column;
    box-shadow:
        0 20px 60px rgba(0, 0, 0, 0.5),
        0 0 100px rgba(255, 176, 0, 0.2);
}

/* Character-specific window styles */
.foreman-chat-window {
    background: linear-gradient(135deg, #2C3E50 0%, #34495E 100%);
    border: 3px solid #FFB000;
}

.motley-chat-window {
    background: linear-gradient(135deg, #2C1810 0%, #3E2B23 100%);
    border: 3px solid #8B4513;
}

.safety-chat-window {
    background: linear-gradient(135deg, #F0F0F0 0%, #FFFFFF 100%);
    border: 3px solid #FF6B35;
}

/* === UNIFIED CHAT HEADER === */
.chat-header {
    padding: 15px 20px;
    border-radius: 12px 12px 0 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
}

/* Character-specific header styles */
.foreman-chat-window .chat-header {
    background: linear-gradient(135deg, #FFB000 0%, #FF7A00 100%);
    color: white;
}

.motley-chat-window .chat-header {
    background: linear-gradient(135deg, #8B4513 0%, #A0522D 100%);
    color: white;
}

.safety-chat-window .chat-header {
    background: linear-gradient(135deg, #FF6B35 0%, #FFD700 100%);
    color: white;
}

.chat-title {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: bold;
    font-size: 16px;
}

.chat-icon {
    font-size: 24px;
}

.chat-close {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.chat-close:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: rotate(90deg);
}

/* === STATUS BAR === */
.chat-status {
    padding: 10px 20px;
    background: rgba(0, 0, 0, 0.2);
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 12px;
    color: rgba(255, 255, 255, 0.8);
}

.status-indicator {
    display: flex;
    align-items: center;
    gap: 5px;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    animation: pulse 2s ease infinite;
}

.status-dot.connected {
    background: #4CAF50;
}

.status-dot.typing {
    background: #FFD700;
}

.status-dot.error {
    background: #FF5252;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

/* === MESSAGES AREA === */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

/* Custom scrollbar */
.chat-messages::-webkit-scrollbar {
    width: 8px;
}

.chat-messages::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: rgba(255, 176, 0, 0.5);
    border-radius: 10px;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 176, 0, 0.7);
}

/* === MESSAGE BUBBLES === */
.message {
    max-width: 70%;
    padding: 12px 16px;
    border-radius: 15px;
    animation: messageSlide 0.3s ease;
    word-wrap: break-word;
}

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

.message.user {
    align-self: flex-end;
    background: linear-gradient(135deg, #3498DB, #2980B9);
    color: white;
    border-bottom-right-radius: 5px;
}

.message.ai {
    align-self: flex-start;
    background: rgba(255, 255, 255, 0.1);
    color: white;
    border-bottom-left-radius: 5px;
}

/* Character-specific AI message styles */
.foreman-chat-window .message.ai {
    border-left: 3px solid #FFB000;
}

.motley-chat-window .message.ai {
    border-left: 3px solid #8B4513;
}

.safety-chat-window .message.ai {
    background: rgba(0, 0, 0, 0.05);
    color: #333;
    border-left: 3px solid #FF6B35;
}

/* === TYPING INDICATOR === */
.typing-indicator {
    display: none;
    align-self: flex-start;
    padding: 12px 16px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 15px;
    border-bottom-left-radius: 5px;
    margin-bottom: 10px;
}

.typing-indicator.active {
    display: flex;
    gap: 5px;
}

.typing-dot {
    width: 8px;
    height: 8px;
    background: #FFD700;
    border-radius: 50%;
    animation: typingBounce 1.4s ease infinite;
}

.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes typingBounce {
    0%, 80%, 100% {
        transform: translateY(0);
        opacity: 0.5;
    }
    40% {
        transform: translateY(-10px);
        opacity: 1;
    }
}

/* === INPUT AREA === */
.chat-input-area {
    padding: 15px 20px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 0 0 12px 12px;
    display: flex;
    gap: 10px;
    align-items: flex-end;
}

.chat-input-wrapper {
    flex: 1;
    position: relative;
}

.chat-input {
    width: 100%;
    padding: 12px 15px;
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid rgba(255, 176, 0, 0.3);
    border-radius: 25px;
    color: white;
    font-size: 14px;
    resize: vertical;
    min-height: 44px;
    max-height: 120px;
    transition: all 0.3s ease;
}

/* Character-specific input borders */
.foreman-chat-window .chat-input {
    border-color: rgba(255, 176, 0, 0.3);
}

.motley-chat-window .chat-input {
    border-color: rgba(139, 69, 19, 0.3);
}

.safety-chat-window .chat-input {
    background: white;
    color: #333;
    border-color: rgba(255, 107, 53, 0.3);
}

.chat-input:focus {
    outline: none;
    border-color: #FFD700;
}

.chat-input::placeholder {
    color: rgba(255, 255, 255, 0.5);
}

.safety-chat-window .chat-input::placeholder {
    color: rgba(0, 0, 0, 0.5);
}

/* === SEND BUTTON === */
.chat-send {
    width: 44px;
    height: 44px;
    border: none;
    border-radius: 50%;
    color: white;
    cursor: pointer;
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

/* Character-specific send buttons */
.foreman-chat-window .chat-send {
    background: linear-gradient(135deg, #FFB000, #FF7A00);
}

.motley-chat-window .chat-send {
    background: linear-gradient(135deg, #8B4513, #A0522D);
}

.safety-chat-window .chat-send {
    background: linear-gradient(135deg, #FF6B35, #FFD700);
}

.chat-send:hover {
    transform: scale(1.1);
    box-shadow: 0 5px 15px rgba(255, 176, 0, 0.3);
}

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

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

/* === QUICK ACTIONS === */
.quick-actions {
    display: flex;
    gap: 10px;
    padding: 10px 20px;
    background: rgba(0, 0, 0, 0.2);
    overflow-x: auto;
}

.quick-action {
    padding: 8px 15px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 176, 0, 0.3);
    border-radius: 20px;
    color: white;
    font-size: 12px;
    white-space: nowrap;
    cursor: pointer;
    transition: all 0.2s ease;
}

.quick-action:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: translateY(-2px);
}

/* === CHARACTER INTRO PANELS === */
.character-intro-panel {
    background: linear-gradient(135deg, #2C3E50, #34495E);
    border-radius: 20px;
    width: 400px;
    padding: 30px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    position: relative;
    overflow: hidden;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
}

/* Character-specific panel styles */
.foreman-intro-panel {
    background: linear-gradient(135deg, #2C3E50, #34495E);
    border: 3px solid #FFB000;
}

.motley-intro-panel {
    background: linear-gradient(135deg, #2C1810, #3E2B23);
    border: 3px solid #8B4513;
}

.safety-intro-panel {
    background: linear-gradient(135deg, #FFFFFF, #F0F0F0);
    border: 3px solid #FF6B35;
}

.panel-content {
    text-align: center;
    position: relative;
    z-index: 1;
}

.panel-title {
    font-size: 2.5rem;
    font-weight: bold;
    margin-bottom: 15px;
}

.foreman-intro-panel .panel-title {
    color: #FFB000;
}

.motley-intro-panel .panel-title {
    color: #D2691E;
}

.safety-intro-panel .panel-title {
    color: #FF6B35;
}

.panel-subtitle {
    font-size: 1.2rem;
    margin-bottom: 20px;
    color: rgba(255, 255, 255, 0.9);
}

.safety-intro-panel .panel-subtitle {
    color: #333;
}

/* === RESPONSIVE ADJUSTMENTS === */
@media (max-width: 1400px) {
    .ai-chat-container {
        flex-direction: column;
        align-items: center;
    }
    
    .character-intro-panel {
        display: none;
    }
    
    .ai-chat-window {
        width: 90%;
        max-width: 700px;
    }
}

@media (max-width: 768px) {
    .ai-chat-window {
        width: 95%;
        height: 90vh;
        margin: 5vh auto;
    }
    
    .chat-messages {
        padding: 15px;
    }
    
    .message {
        max-width: 85%;
    }
}