/* Chat styles for VibeCraft */

/* Chat toggle button */
.chat-toggle {
    position: fixed;
    bottom: 80px;
    left: 20px;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: var(--ui-background-medium, #10141f);
    border: 2px solid var(--ui-background-light, #151d28);
    color: var(--ui-text-primary, #ebede9);
    font-size: 24px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    z-index: 100;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

/* T shortcut indicator - simplified */
.chat-toggle::before {
    content: 'T';
    position: absolute;
    bottom: -5px;
    right: -5px;
    background: var(--ui-primary, #5d9cec);
    color: white;
    font-size: 10px;
    font-weight: bold;
    padding: 2px 4px;
    border-radius: 3px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

.chat-toggle:hover {
    background: var(--ui-background-light, #151d28);
    transform: scale(1.05);
}

.chat-toggle.has-unread {
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% {
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    }

    50% {
        box-shadow: 0 4px 20px rgba(93, 156, 236, 0.5);
    }

    100% {
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    }
}

.chat-toggle.active {
    background: var(--ui-primary, #5d9cec);
    border-color: var(--ui-primary, #5d9cec);
}

.chat-toggle .chat-icon {
    pointer-events: none;
}

/* Unread badge */
.chat-unread-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #ff4444;
    color: white;
    font-size: 12px;
    font-weight: bold;
    min-width: 20px;
    height: 20px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

/* Chat container */
.chat-container {
    position: fixed;
    bottom: 100px;
    left: 80px;
    width: 400px;
    height: 400px;
    background: rgba(0, 0, 0, 0.85);
    border: 1px solid var(--ui-background-light, #151d28);
    border-radius: 12px;
    backdrop-filter: blur(10px);
    z-index: 98;
    display: none;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

/* Chat header */
.chat-header {
    padding: 12px 16px;
    border-bottom: 1px solid var(--ui-background-light, #151d28);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(255, 255, 255, 0.02);
    flex-shrink: 0;
}

.chat-unread-count {
    background: var(--ui-primary, #5d9cec);
    color: white;
    padding: 2px 6px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 600;
}

.chat-title {
    color: var(--ui-text-primary, #ebede9);
    font-weight: 600;
}

.chat-close {
    background: none;
    border: none;
    color: var(--ui-text-secondary, #a8b5b2);
    font-size: 18px;
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.chat-close:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--ui-text-primary, #ebede9);
}

/* Chat messages container - takes remaining space above typing indicator and input */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 8px 16px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-height: 0;
    /* Important for flex child to shrink */
    /* Add padding bottom to ensure space for scrollbar and avoid clipping */
    padding-bottom: 12px;
    /* Ensure this doesn't overflow over other elements */
    position: relative;
    z-index: 1;
}

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

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

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

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

/* Chat message */
.chat-message {
    display: flex;
    align-items: baseline;
    gap: 6px;
    padding: 6px 8px;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.03);
    word-wrap: break-word;
    max-width: 100%;
    animation: messageSlide 0.2s ease-out;
}

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

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Own messages */
.chat-message.own-message {
    background: rgba(93, 156, 236, 0.1);
    border-left: 3px solid var(--ui-primary, #5d9cec);
}

/* System messages */
.chat-message.system-message {
    background: rgba(255, 255, 255, 0.02);
    font-style: italic;
    color: var(--ui-text-secondary, #a8b5b2);
    justify-content: center;
    text-align: center;
    padding: 4px 8px;
}

/* Typing indicator message - appears as a chat message */
.chat-message.typing-indicator-message {
    background: rgba(93, 156, 236, 0.08);
    border-left: 3px solid rgba(93, 156, 236, 0.3);
    font-style: italic;
    padding: 6px 12px;
    margin: 2px 0;
    animation: typingPulse 1.5s ease-in-out infinite;
}

.typing-indicator-text {
    color: var(--ui-text-secondary, #a8b5b2);
    font-size: 13px;
}

@keyframes typingPulse {

    0%,
    100% {
        opacity: 0.7;
    }

    50% {
        opacity: 1;
    }
}

/* Message time */
.message-time {
    color: var(--ui-text-secondary, #a8b5b2);
    font-size: 11px;
    opacity: 0.7;
    flex-shrink: 0;
}

/* Message sender */
.message-sender {
    font-weight: 600;
    font-size: 14px;
    flex-shrink: 0;
}

/* Message text */
.message-text {
    color: var(--ui-text-primary, #ebede9);
    font-size: 14px;
    line-height: 1.4;
    flex: 1;
}

.system-message .message-text {
    color: var(--ui-text-secondary, #a8b5b2);
    font-size: 13px;
}



/* Input container */
.chat-input-container {
    padding: 12px;
    border-top: 1px solid var(--ui-background-light, #151d28);
    display: flex;
    gap: 8px;
    align-items: center;
    flex-shrink: 0;
}

/* Chat input */
.chat-input {
    flex: 1;
    background: var(--ui-background-dark, #0a0c12);
    border: 1px solid var(--ui-background-light, #151d28);
    color: var(--ui-text-primary, #ebede9);
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 14px;
    transition: all 0.2s ease;
    font-family: inherit;
}

/* Character count */
.chat-char-count {
    color: var(--ui-text-secondary, #a8b5b2);
    font-size: 11px;
    white-space: nowrap;
    margin: 0 4px;
}

.chat-input:focus {
    outline: none;
    border-color: var(--ui-primary, #5d9cec);
    background: rgba(93, 156, 236, 0.05);
}

.chat-input::placeholder {
    color: var(--ui-text-secondary, #a8b5b2);
    opacity: 0.6;
}

/* Send button */
.chat-send-button {
    background: var(--ui-primary, #5d9cec);
    border: none;
    color: white;
    width: 36px;
    height: 36px;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.chat-send-button:hover {
    background: #4a8ad9;
    transform: scale(1.05);
}

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

/* Mobile responsive adjustments */
@media (max-width: 768px) {
    .chat-container {
        width: calc(100vw - 40px);
        max-width: 350px;
        height: 350px;
        bottom: 200px;
        /* Higher on mobile */
    }

    .chat-toggle {
        bottom: 150px;
        /* Position above craft prompt bar */
        left: 10px;
        /* Slightly inset on mobile */
        width: 45px;
        /* Slightly smaller on mobile */
        height: 45px;
    }
}

/* Animations */
.chat-container {
    animation: slideUp 0.3s ease-out;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Chat error message */
.chat-error {
    background: rgba(255, 68, 68, 0.15);
    color: #ff6b6b;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 13px;
    margin: 4px 0;
    animation: messageSlide 0.2s ease-out;
    border-left: 3px solid #ff4444;
}

/* Chat notifications container */
.chat-notifications {
    position: fixed;
    bottom: 200px;
    /* Position higher, above chat button */
    left: 20px;
    display: flex;
    flex-direction: column-reverse;
    gap: 4px;
    z-index: 99;
    pointer-events: none;
    max-width: 400px;
}

/* Individual notification */
.chat-notification {
    /* No background - text only */
    padding: 4px 0;
    opacity: 0;
    transform: translateX(-20px);
    transition: all 0.3s ease-out;
    display: flex;
    align-items: baseline;
    gap: 6px;
    max-width: 100%;
    word-wrap: break-word;
    /* Add text shadow for readability */
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.8), 0 0 8px rgba(0, 0, 0, 0.6);
}

.chat-notification.show {
    opacity: 1;
    transform: translateX(0);
}

.chat-notification.fade-out {
    opacity: 0;
    transform: translateX(-20px);
}

/* System notification style */
.chat-notification.system-notification {
    color: rgba(255, 255, 255, 0.7);
    font-style: italic;
    justify-content: center;
    text-align: center;
}

/* Notification sender name */
.notification-sender {
    font-weight: 600;
    font-size: 14px;
    flex-shrink: 0;
    /* Make sure player colors are visible */
    filter: brightness(1.2);
}

/* Notification text */
.notification-text {
    color: #ffffff;
    font-size: 14px;
    line-height: 1.4;
}

.system-notification .notification-text {
    color: var(--ui-text-secondary, #a8b5b2);
    font-size: 13px;
}

/* Mobile adjustments for notifications */
@media (max-width: 768px) {
    .chat-notifications {
        max-width: calc(100vw - 20px);
        bottom: 210px;
        /* Position well above chat button on mobile */
        left: 10px;
    }
}