/**
 * MadBot Chat Styles
 * Specific styles for the chat page (fullpage.php)
 */

/* Enhanced Message Bubbles */
.message {
    display: flex;
    gap: 12px;
    margin-bottom: 16px;
    animation: fadeInUp 0.3s ease;
    align-items: flex-start;
}

.message.user {
    flex-direction: row-reverse;
}

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

.message-avatar.ai-avatar {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
}

.message-avatar.user-avatar {
    background: linear-gradient(135deg, #4b5563, #374151);
    font-size: 20px;
}

/* Light mode: user avatar */
.light-mode .message-avatar.user-avatar {
    background: linear-gradient(135deg, #94a3b8, #64748b);
}

.message-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.message-content {
    max-width: 70%;
    display: flex;
    flex-direction: column;
}

.message.user .message-content {
    align-items: flex-end;
}

.message-name {
    font-size: 12px;
    color: var(--gray);
    margin-bottom: 4px;
    font-weight: 500;
}

/* User message name aligned right */
.user-message-name {
    text-align: right;
}

.message-bubble {
    padding: 12px 16px;
    border-radius: 18px;
    line-height: 1.5;
    word-wrap: break-word;
}

.message.ai .message-bubble {
    background: rgba(255,255,255,0.08);
    border-top-left-radius: 4px;
}

/* Light mode: AI bubble with soft gray background */
.light-mode .message.ai .message-bubble {
    background: #E8EDF2;
}

.light-mode .message.ai .message-text {
    color: #1E293B;
}

.message.user .message-bubble {
    background: #374151;
    border-top-right-radius: 4px;
}

/* Light mode: user bubble */
.light-mode .message.user .message-bubble {
    background: #CBD5E1;
}

.light-mode .message.user .message-text {
    color: #1E293B;
}

.message-text {
    color: var(--light);
}

/* Edit message button */
.edit-message-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    background: transparent;
    border: none;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.2s;
    padding: 4px;
    border-radius: 4px;
    color: rgba(255,255,255,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
}

.message.user .message-bubble {
    position: relative;
}

.message.user .message-bubble:hover .edit-message-btn {
    opacity: 1;
}

.edit-message-btn:hover {
    color: rgba(255,255,255,0.9);
    background: rgba(255,255,255,0.1);
}

.edit-message-btn svg {
    width: 14px;
    height: 14px;
}

/* Light mode edit button */
.light-mode .edit-message-btn {
    color: rgba(0,0,0,0.4);
}

.light-mode .edit-message-btn:hover {
    color: rgba(0,0,0,0.7);
    background: rgba(0,0,0,0.1);
}

/* Markdown formatting in messages */
.message-text em {
    font-style: italic;
    opacity: 0.9;
}

.message-text strong {
    font-weight: 700;
}

.message-text strong em,
.message-text em strong {
    font-weight: 700;
    font-style: italic;
}

.message-text u {
    text-decoration: underline;
    text-underline-offset: 2px;
}

.message-text del {
    text-decoration: line-through;
    opacity: 0.7;
}

.message-time {
    font-size: 10px;
    color: var(--gray);
    opacity: 0.5;
    margin-top: 4px;
    padding: 0 4px;
    text-align: right;
}

/* Typing indicator */
.typing-bubble {
    display: flex;
    gap: 4px;
    padding: 16px 20px;
}

.typing-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--gray);
    animation: typingBounce 1.4s ease-in-out infinite;
}

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

@keyframes typingBounce {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
    30% { transform: translateY(-8px); opacity: 1; }
}

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

/* Menu separator styles are in menu.css */

#chatMenu button {
    width: 100%;
    text-align: left;
    padding: 10px 16px;
    background: transparent;
    border: none;
    color: var(--light);
    cursor: pointer;
    border-radius: 8px;
    font-size: 14px;
    transition: background 0.2s;
}

#chatMenu button:hover {
    background: rgba(255,255,255,0.08);
}

/* Light mode: menu buttons */
.light-mode #chatMenu button {
    color: var(--text-color);
}

.light-mode #chatMenu button:hover {
    background: rgba(0,0,0,0.06);
}

#chatMenu .menu-custom-link {
    display: block;
    width: 100%;
    text-align: left;
    padding: 10px 16px;
    color: var(--light);
    text-decoration: none;
    border-radius: 8px;
    font-size: 14px;
    transition: background 0.2s;
    box-sizing: border-box;
}

#chatMenu .menu-custom-link:hover {
    background: rgba(255,255,255,0.08);
}

/* Light mode: menu custom links */
.light-mode #chatMenu .menu-custom-link {
    color: var(--text-color);
}

.light-mode #chatMenu .menu-custom-link:hover {
    background: rgba(0,0,0,0.06);
}

/* Light mode: Game button tooltip */
.light-mode .game-button::after {
    background: #FFFFFF;
    color: #1E293B;
    border: 1px solid #CBD5E1;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

/* Theme toggle styles are in menu.css */

/* Profile Modal */
.profile-avatars {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
    margin: 20px 0;
}

.profile-avatar-option {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    cursor: pointer;
    border: 3px solid transparent;
    transition: all 0.2s;
}

.profile-avatar-option:hover {
    transform: scale(1.1);
}

.profile-avatar-option.selected {
    border-color: var(--primary);
    box-shadow: 0 0 15px rgba(99, 102, 241, 0.5);
}

.profile-input {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid rgba(255,255,255,0.2);
    border-radius: 8px;
    background: rgba(255,255,255,0.05);
    color: var(--light);
    font-size: 16px;
    text-align: center;
    margin-bottom: 20px;
}

.profile-input:focus {
    outline: none;
    border-color: var(--primary);
}

.profile-input::placeholder {
    color: var(--gray);
}

/* Disclaimer - below input actions */
.chat-disclaimer {
    font-size: 11px;
    color: var(--gray);
    opacity: 0.7;
    text-align: center;
    padding: 4px 16px 12px;
}

/* ==========================================================================
   INPUT ACTIONS BAR
   ========================================================================== */

.input-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 4px 8px 8px 12px;
    gap: 12px;
}

.input-actions-left {
    display: flex;
    align-items: center;
    gap: 0;
}

.input-actions-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* Action buttons (Game, Clear, Suggestions) */
.action-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    color: var(--gray);
    cursor: pointer;
    padding: 6px 8px;
    border-radius: 8px;
    transition: background 0.15s, color 0.15s;
    position: relative;
    font-size: 14px;
}

.light-mode .action-btn {
    color: #64748B;
}

.light-mode .action-btn svg {
    stroke: #64748B;
}

.action-btn:hover {
    background: rgba(255, 255, 255, 0.08);
    color: var(--light);
}

.light-mode .action-btn:hover {
    background: rgba(0, 0, 0, 0.06);
    color: #1E293B;
}

.light-mode .action-btn:hover svg {
    stroke: #1E293B;
}

/* Action button emoji (for games) */
/* Action button emoji (for games) - same size as SVG icons */
.action-btn-emoji {
    font-size: 16px;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
}

/* Action button SVG icon */
.action-btn svg {
    width: 16px;
    height: 16px;
    opacity: 0.7;
    transition: opacity 0.15s;
}

.action-btn:hover svg {
    opacity: 1;
}

/* Instant tooltip for action buttons */
.action-btn-tooltip {
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    background: rgba(15, 15, 20, 0.95);
    color: #f8fafc;
    font-size: 12px;
    padding: 6px 10px;
    border-radius: 6px;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.15s, visibility 0.15s;
    pointer-events: none;
    z-index: 9999;
    box-shadow: 0 2px 8px rgba(0,0,0,0.4);
}

.action-btn-tooltip::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 5px solid transparent;
    border-top-color: var(--dark);
}

.action-btn:hover .action-btn-tooltip {
    opacity: 1;
    visibility: visible;
}

.light-mode .action-btn-tooltip {
    background: #1e293b;
    color: #f8fafc;
}

.light-mode .action-btn-tooltip::after {
    border-top-color: #1e293b;
}

/* Character Counter - in input actions */
.char-counter {
    font-size: 12px;
    color: var(--gray);
    transition: opacity 0.2s, color 0.2s;
    opacity: 0;
    pointer-events: none;
}

.char-counter.visible {
    opacity: 1;
    pointer-events: auto;
}

.char-counter.warning {
    color: #f59e0b;
}

.char-counter.error {
    color: #ef4444;
    font-weight: 600;
}

/* Confirm Modal Buttons */
.modal-btn {
    padding: 12px 24px;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    border: none;
}

.modal-btn-cancel {
    background: rgba(255,255,255,0.1);
    color: var(--light);
    border: 1px solid rgba(255,255,255,0.2);
}

.modal-btn-cancel:hover {
    background: rgba(255,255,255,0.15);
}

/* Light mode */
.light-mode .modal-btn-cancel {
    background: rgba(0,0,0,0.05);
    color: #475569;
    border: 1px solid #CBD5E1;
}

.light-mode .modal-btn-cancel:hover {
    background: rgba(0,0,0,0.1);
}

.modal-btn-confirm {
    background: linear-gradient(135deg, #ef4444, #dc2626);
    color: white;
}

.modal-btn-confirm:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(239, 68, 68, 0.4);
}



/* Chat container - always centered */
.chat-container .messages-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    flex: 1;
    overflow-y: auto;
    padding: 20px;
}

.chat-container .messages-container .message {
    width: 100%;
    max-width: var(--chat-width-collapsed, 800px);
}

.chat-container .welcome-screen {
    max-width: var(--chat-width-collapsed, 800px);
    margin-left: auto;
    margin-right: auto;
}

/* Input container - always centered */
.chat-container .input-container {
    width: 100%;
    max-width: var(--chat-width-collapsed, 800px);
    margin-left: auto;
    margin-right: auto;
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    padding: 0 !important;
}

/* Input wrapper - keep visible border */
.chat-container .input-wrapper {
    outline: none !important;
    box-shadow: none !important;
}

/* Input full width mode */
.chat-container .input-container.input-mode-full {
    max-width: none;
    margin-left: 0;
}

/* Input custom width mode */
.sidebar.compact ~ .chat-container .input-container.input-mode-custom,
.sidebar.hidden ~ .chat-container .input-container.input-mode-custom {
    max-width: var(--input-width-custom, 800px);
}

/* Profile Menu styles are in menu.css */


/* =============================================================================
   ASSET IMAGES IN CHAT
   ============================================================================= */

/* Asset wrapper - inline block to flow with text */
.madbot-asset-wrapper {
    display: inline-block;
    vertical-align: middle;
    margin: 4px 2px;
}

/* Asset image styling */
.madbot-asset-image {
    max-width: 200px;
    height: auto;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    cursor: pointer;
}

.madbot-asset-image:hover {
    transform: scale(1.02);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
}

/* Light mode adjustments */
.light-mode .madbot-asset-image {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.light-mode .madbot-asset-image:hover {
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
}

/* Asset link wrapper */
.madbot-asset-link {
    display: inline-block;
    text-decoration: none;
}

/* Multiple assets in a row */
.message-text .madbot-asset-wrapper + .madbot-asset-wrapper {
    margin-left: 8px;
}

/* Larger assets for games (Tarot cards, etc.) */
.message-text .madbot-asset-wrapper.large .madbot-asset-image,
.message-text .madbot-asset-image[data-pack^="tarot"] {
    max-width: 150px;
}

/* Center asset when it's alone on a line */
.message-text br + .madbot-asset-wrapper,
.message-text .madbot-asset-wrapper:first-child:last-child {
    display: block;
    text-align: center;
    margin: 12px auto;
}

.message-text br + .madbot-asset-wrapper .madbot-asset-image,
.message-text .madbot-asset-wrapper:first-child:last-child .madbot-asset-image {
    max-width: 250px;
}


/* Loading Spinner for buttons */
.loading-spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: #fff;
    animation: spin 0.8s linear infinite;
    vertical-align: middle;
    margin-right: 8px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ==========================================================================
   CREATOR CHAT HEADER
   ========================================================================== */

.creator-chat-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 0;
    padding-left: 52px;
    margin-bottom: 16px;
    width: 100%;
    max-width: var(--chat-width-collapsed, 800px);
}

.creator-chat-avatar,
.creator-chat-avatar-link {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    overflow: hidden;
    flex-shrink: 0;
    background: rgba(255,255,255,0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    transition: transform 0.2s, box-shadow 0.2s;
}

.creator-chat-avatar-link:hover {
    transform: scale(1.05);
    box-shadow: 0 0 0 2px var(--primary);
}

.creator-chat-avatar img,
.creator-chat-avatar-link img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.creator-chat-avatar span,
.creator-chat-avatar-link span {
    font-size: 18px;
    color: var(--text-muted);
    font-weight: 600;
}

.creator-chat-info {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
}

.creator-chat-name {
    font-weight: 600;
    font-size: 15px;
    color: var(--text-primary, #fff);
}

.creator-chat-link {
    font-size: 13px;
    color: var(--text-muted);
    text-decoration: none;
    transition: color 0.2s;
}

.creator-chat-link:hover {
    color: var(--primary);
}

/* Light mode */
.light-mode .creator-chat-avatar,
.light-mode .creator-chat-avatar-link {
    background: rgba(0,0,0,0.05);
}

.light-mode .creator-chat-name {
    color: var(--text-primary, #1a1a2e);
}

/* ==========================================================================
   MESSAGE RATING (Thumbs up/down)
   ========================================================================== */

.message-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 4px;
}

.message-footer .message-time {
    margin-left: auto;
}

.message-rating {
    display: flex;
    gap: 4px;
    opacity: 0;
    transition: opacity 0.2s;
}

.message.ai:hover .message-rating {
    opacity: 1;
}

/* Always show if a rating has been selected */
.message-rating:has(.active) {
    opacity: 1;
}

.rating-btn {
    background: transparent;
    border: none;
    padding: 4px 6px;
    cursor: pointer;
    border-radius: 4px;
    color: var(--text-muted);
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.rating-btn svg {
    width: 14px;
    height: 14px;
}

.rating-btn:hover {
    background: rgba(255,255,255,0.1);
    color: var(--text-primary);
}

.rating-btn.active.rating-up {
    color: #22c55e;
    background: rgba(34,197,94,0.15);
}

.rating-btn.active.rating-down {
    color: #ef4444;
    background: rgba(239,68,68,0.15);
}

/* Light mode */
.light-mode .rating-btn:hover {
    background: rgba(0,0,0,0.05);
}

.light-mode .rating-btn.active.rating-up {
    background: rgba(34,197,94,0.1);
}

.light-mode .rating-btn.active.rating-down {
    background: rgba(239,68,68,0.1);
}

/* ==========================================================================
   SCROLL TO BOTTOM BUTTON
   ========================================================================== */

.scroll-to-bottom-btn {
    position: absolute;
    bottom: 160px; /* Fallback, JS calculates dynamically */
    left: 50%;
    transform: translateX(-50%) scale(0.8);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(30, 30, 35, 0.9);
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: rgba(255, 255, 255, 0.8);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s ease;
    z-index: 100;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.scroll-to-bottom-btn.visible {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) scale(1);
}

.scroll-to-bottom-btn:hover {
    background: rgba(50, 50, 55, 0.95);
    border-color: rgba(255, 255, 255, 0.25);
    color: #fff;
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.4);
}

.scroll-to-bottom-btn:active {
    transform: translateX(-50%) scale(0.95);
}

.scroll-to-bottom-btn svg {
    width: 20px;
    height: 20px;
}

/* Light mode */
.light-mode .scroll-to-bottom-btn {
    background: rgba(255, 255, 255, 0.95);
    border-color: rgba(0, 0, 0, 0.1);
    color: rgba(0, 0, 0, 0.7);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.light-mode .scroll-to-bottom-btn:hover {
    background: #fff;
    border-color: rgba(0, 0, 0, 0.15);
    color: #000;
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2);
}


/* =====================================================
   SUGGESTIONS POPUP
   ===================================================== */

.input-actions-left {
    position: relative;
}

.suggestions-popup {
    position: absolute;
    bottom: calc(100% + 8px);
    left: 0;
    min-width: 220px;
    max-width: 300px;
    background: rgba(25, 25, 30, 0.98);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 12px;
    padding: 8px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
    z-index: 9999;
    animation: suggestionsSlideUp 0.15s ease-out;
}

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

.suggestions-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.suggestion-item {
    display: block;
    width: 100%;
    padding: 10px 12px;
    background: transparent;
    border: none;
    border-radius: 8px;
    color: rgba(255, 255, 255, 0.85);
    font-size: 13px;
    text-align: left;
    cursor: pointer;
    transition: all 0.15s ease;
    line-height: 1.4;
}

.suggestion-item:hover {
    background: rgba(99, 102, 241, 0.15);
    color: #fff;
}

.suggestion-item:active {
    background: rgba(99, 102, 241, 0.25);
    transform: scale(0.98);
}

/* Light mode */
.light-mode .suggestions-popup {
    background: rgba(255, 255, 255, 0.98);
    border-color: rgba(0, 0, 0, 0.1);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
}

.light-mode .suggestion-item {
    color: rgba(0, 0, 0, 0.75);
}

.light-mode .suggestion-item:hover {
    background: rgba(99, 102, 241, 0.1);
    color: #000;
}

.light-mode .suggestion-item:active {
    background: rgba(99, 102, 241, 0.2);
}
