/**
 * Safety Officer Chat Window - Fun Zone
 * The overly-cautious, rule-obsessed Safety Officer AI
 * White hardhat theme with safety orange accents
 */

/* Chat backdrop overlay */
.safety-chat-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(4px);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.3s ease;
    padding: 20px;
}

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

/* Chat container */
.safety-chat-container {
    display: flex;
    gap: 20px;
    max-width: 1400px;
    width: 100%;
    height: 85vh;
    position: relative;
    animation: slideInUp 0.4s ease;
}

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

/* Safety Intro Panel */
.safety-intro-panel {
    background: linear-gradient(135deg, #FFFFFF, #F0F0F0);
    border: 3px solid #FF6B35;
    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.2);
}

.safety-intro-panel::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 80px;
    background: repeating-linear-gradient(
        45deg,
        #FFD700,
        #FFD700 10px,
        #000000 10px,
        #000000 20px
    );
    opacity: 0.1;
}

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

.safety-title {
    font-size: 2.5rem;
    font-weight: bold;
    color: #FF6B35;
    margin-bottom: 15px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.1);
}

.safety-subtitle {
    font-size: 1.2rem;
    color: #333;
    margin-bottom: 20px;
    font-style: italic;
}

.hazard-symbols {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin: 20px 0;
    font-size: 2rem;
}

.safety-rules {
    background: #FFF3E0;
    border: 2px dashed #FF6B35;
    border-radius: 10px;
    padding: 15px;
    margin: 20px 0;
}

.safety-rules h4 {
    color: #FF6B35;
    margin-bottom: 10px;
}

.safety-rules ul {
    list-style: none;
    padding: 0;
    text-align: left;
}

.safety-rules li {
    padding: 5px 0;
    color: #555;
}

.safety-rules li::before {
    content: '⚠️';
    margin-right: 8px;
}

/* Main Chat Window */
.safety-chat-window {
    background: white;
    border: 3px solid #FF6B35;
    border-radius: 20px;
    flex: 1;
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: hidden;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
}

/* Chat Header */
.safety-chat-header {
    background: linear-gradient(135deg, #FF6B35, #FFD700);
    padding: 20px 25px;
    color: white;
    position: relative;
    border-bottom: 3px solid #FF6B35;
}

.safety-chat-header::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: repeating-linear-gradient(
        90deg,
        #000000,
        #000000 5px,
        #FFD700 5px,
        #FFD700 10px
    );
}

.safety-chat-title {
    display: flex;
    align-items: center;
    gap: 15px;
    font-size: 1.4rem;
    font-weight: bold;
}

.hardhat-icon {
    font-size: 1.8rem;
}

/* Chat Subheader */
.safety-chat-subheader {
    background: #FFF3E0;
    padding: 12px 25px;
    border-bottom: 1px solid #FFE0B2;
    font-style: italic;
    color: #666;
}

/* Chat Body Container */
.safety-chat-body-container {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* Chat Messages Area */
.safety-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: #FAFAFA;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

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

.safety-chat-messages::-webkit-scrollbar-track {
    background: #F0F0F0;
}

.safety-chat-messages::-webkit-scrollbar-thumb {
    background: #FF6B35;
    border-radius: 5px;
}

/* Chat Message */
.safety-chat-message {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    animation: messageSlide 0.3s ease;
}

@keyframes messageSlide {
    from {
        opacity: 0;
        transform: translateX(-20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.safety-message-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    flex-shrink: 0;
}

.safety-message-avatar.user {
    background: #E3F2FD;
}

.safety-message-avatar.assistant {
    background: #FFF3E0;
}

.safety-message-content {
    flex: 1;
    background: white;
    border-radius: 15px;
    padding: 12px 18px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    position: relative;
    color: #1a1a1a; /* Dark text color for better readability */
}

.safety-message-content.user {
    background: linear-gradient(135deg, #E3F2FD, #BBDEFB);
    margin-left: auto;
    max-width: 70%;
    color: #0d0d0d; /* Very dark text for user messages */
}

.safety-message-content.assistant {
    background: white;
    border: 2px solid #FF6B35;
    max-width: 80%;
    color: #1a1a1a; /* Dark text for assistant messages */
}

.safety-message-header {
    font-weight: bold;
    margin-bottom: 5px;
    font-size: 0.9rem;
    color: #333; /* Darker header text */
}

.safety-timestamp {
    font-size: 0.75rem;
    color: #999;
    margin-left: 10px;
}

/* Chat Input Area */
.safety-chat-input-area {
    background: white;
    border-top: 2px solid #FFE0B2;
    padding: 20px;
}

#safetyInput {
    width: 100%;
    padding: 15px;
    border: 2px solid #FFE0B2;
    border-radius: 15px;
    font-size: 1rem;
    resize: none;
    font-family: inherit;
    transition: all 0.3s ease;
}

#safetyInput:focus {
    outline: none;
    border-color: #FF6B35;
    box-shadow: 0 0 0 3px rgba(255, 107, 53, 0.1);
}

/* Chat Actions */
.safety-chat-actions {
    display: flex;
    gap: 10px;
    margin-top: 15px;
}

.safety-chat-send {
    background: linear-gradient(135deg, #FF6B35, #FFB74D);
    color: white;
    border: none;
    padding: 12px 30px;
    border-radius: 10px;
    font-size: 1rem;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
}

.safety-chat-send:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(255, 107, 53, 0.3);
}

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

.safety-chat-preset {
    background: white;
    color: #FF6B35;
    border: 2px solid #FF6B35;
    padding: 10px 20px;
    border-radius: 10px;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.3s ease;
}

.safety-chat-preset:hover {
    background: #FFF3E0;
}

/* Close Button */
.safety-chat-close {
    position: absolute;
    top: 15px;
    right: 15px;
    background: white;
    color: #FF6B35;
    border: 2px solid white;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    font-size: 24px;
    cursor: pointer;
    transition: all 0.3s ease;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.safety-chat-close:hover {
    background: #FF6B35;
    color: white;
    transform: rotate(90deg);
}

/* Typing Indicator */
.safety-typing-indicator {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 10px;
    color: #666;
}

.safety-typing-dot {
    width: 8px;
    height: 8px;
    background: #FF6B35;
    border-radius: 50%;
    animation: typingDot 1.4s infinite;
}

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

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

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

/* Connection Status */
.safety-connection-status {
    position: absolute;
    top: 20px;
    right: 60px;
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 5px 12px;
    background: rgba(255, 255, 255, 0.9);
    border-radius: 20px;
    font-size: 0.85rem;
}

.safety-status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #4CAF50;
    animation: pulse 2s infinite;
}

.safety-status-dot.disconnected {
    background: #F44336;
    animation: none;
}

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

/* Mobile Responsive */
@media (max-width: 1400px) {
    .safety-chat-container {
        flex-direction: column;
        align-items: center;
        max-width: 95vw;
    }

    .safety-intro-panel {
        width: 100%;
        max-width: 850px;
        height: auto;
        max-height: 200px;
        margin-bottom: 20px;
    }

    .safety-chat-window {
        width: 100%;
        max-width: 850px;
        height: calc(100vh - 300px);
    }
}

@media (max-width: 900px) {
    .safety-chat-container {
        gap: 10px;
    }

    .safety-chat-window {
        width: 95vw;
        height: calc(100vh - 250px);
    }

    .safety-intro-panel {
        width: 95vw;
        padding: 15px;
    }
}

@media (max-width: 700px) {
    .safety-chat-backdrop {
        background: rgba(0, 0, 0, 0.95);
    }

    .safety-chat-container {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        transform: none !important;
        gap: 0;
        flex-direction: column;
    }

    .safety-chat-window {
        width: 100%;
        height: 100%;
        flex: 1;
        border-radius: 0;
        border: none;
        max-height: none;
    }

    .safety-chat-header {
        padding: 15px 20px;
        border-radius: 0;
    }

    .safety-chat-title {
        font-size: 1rem;
    }

    .hardhat-icon {
        font-size: 1.5rem;
    }

    .safety-chat-subheader {
        padding: 10px 20px;
        font-size: 0.85rem;
    }

    .safety-chat-messages {
        padding: 15px;
    }

    .safety-chat-message .safety-message-content {
        max-width: 85%;
        font-size: 0.9rem;
    }

    .safety-chat-input-area {
        padding: 10px;
    }

    #safetyInput {
        font-size: 16px; /* Prevents zoom on iOS */
        padding: 10px;
    }

    .safety-chat-actions {
        flex-direction: row;
        flex-wrap: wrap;
        gap: 5px;
        margin-top: 8px;
    }

    .safety-chat-send {
        flex: 1 1 100%;
        padding: 10px;
        font-size: 14px;
    }

    .safety-chat-preset {
        flex: 1 1 calc(50% - 2.5px);
        padding: 8px;
        font-size: 12px;
    }

    .safety-chat-close {
        width: 44px;
        height: 44px;
        font-size: 28px;
    }

    .safety-intro-panel {
        display: none; /* Hide intro panel on mobile to save space */
    }
}

/* Extra small mobile screens */
@media (max-width: 480px) {
    .safety-chat-input-area {
        padding: 8px;
    }

    #safetyInput {
        padding: 8px;
        font-size: 14px;
        min-height: 50px; /* Smaller text area on mobile */
        max-height: 80px;
    }

    .safety-chat-actions {
        gap: 4px;
        margin-top: 6px;
    }

    .safety-chat-send {
        padding: 8px;
        font-size: 13px;
    }

    .safety-chat-preset {
        padding: 6px;
        font-size: 11px;
    }

    .safety-chat-messages {
        padding: 10px;
    }

    .safety-chat-header {
        padding: 12px 15px;
    }

    .safety-chat-title {
        font-size: 0.9rem;
    }

    .hardhat-icon {
        font-size: 1.3rem;
    }
}