:root {
    --chat-bg-color: #0f172a;
    --chat-main-bg: #1e293b;
    --chat-primary: #3b82f6;
    --chat-primary-glow: rgba(59, 130, 246, 0.5);
    --chat-secondary: #10b981;
    --chat-text: #f8fafc;
    --chat-text-muted: #94a3b8;
    --chat-input-bg: #334155;
    --chat-user-msg: #2563eb;
    --chat-bot-msg: #334155;
    --chat-font: 'Outfit', sans-serif;
}

/* Scoped Wrapper to replace Body */
.chatbot-wrapper {
    background-color: var(--chat-bg-color);
    color: var(--chat-text);
    font-family: var(--chat-font);
    height: 600px;
    /* Fixed height for modal */
    display: flex;
    justify-content: center;
    overflow: hidden;
    position: relative;
    border-radius: 12px;
}

.chatbot-wrapper * {
    box-sizing: border-box;
}

.chatbot-wrapper .chat-wrapper {
    width: 100%;
    max-width: 100%;
    /* Fit container */
    height: 100%;
    display: flex;
    flex-direction: column;
    background-color: var(--chat-main-bg);
    position: relative;
}

/* Header */
.chatbot-wrapper .chat-header {
    padding: 15px 20px;
    background: rgba(30, 41, 59, 0.95);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 10;
}

.chatbot-wrapper .logo-area {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--chat-primary);
}

.chatbot-wrapper .logo-area h1 {
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--chat-text);
    margin: 0;
}

.chatbot-wrapper .tournament-badge {
    background: rgba(59, 130, 246, 0.2);
    border: 1px solid var(--chat-primary);
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 0.8rem;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.3s ease;
}

.chatbot-wrapper .tournament-badge.hidden {
    display: none;
}

.chatbot-wrapper .tournament-badge button {
    background: none;
    border: none;
    color: var(--chat-text);
    cursor: pointer;
    font-size: 0.8rem;
    opacity: 0.7;
}

.chatbot-wrapper .tournament-badge button:hover {
    opacity: 1;
    color: var(--chat-primary);
}

/* Chat Area */
.chatbot-wrapper .chat-container {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 15px;
    scroll-behavior: smooth;
    text-align: left;
    /* Ensure text alignment */
}

.chatbot-wrapper .message {
    display: flex;
    gap: 12px;
    max-width: 85%;
    animation: fadeIn 0.3s ease;
}

.chatbot-wrapper .message.user-message {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.chatbot-wrapper .avatar {
    width: 35px;
    height: 35px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--chat-primary), var(--chat-secondary));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
    flex-shrink: 0;
    color: white;
}

.chatbot-wrapper .bot-message .avatar {
    background: var(--chat-bot-msg);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.chatbot-wrapper .content {
    background: var(--chat-bot-msg);
    padding: 12px 16px;
    border-radius: 12px;
    border-top-left-radius: 2px;
    line-height: 1.5;
    font-size: 0.95rem;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
    color: var(--chat-text);
}

.chatbot-wrapper .user-message .content {
    background: var(--chat-user-msg);
    border-radius: 12px;
    border-top-right-radius: 2px;
    background: linear-gradient(135deg, var(--chat-primary), #2563eb);
}

/* Options / Buttons */
.chatbot-wrapper .options-container {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-left: 47px;
    animation: fadeIn 0.5s ease;
}

.chatbot-wrapper .option-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--chat-text);
    padding: 8px 16px;
    border-radius: 20px;
    cursor: pointer;
    font-family: inherit;
    font-size: 0.9rem;
    transition: all 0.2s ease;
}

.chatbot-wrapper .option-btn:hover {
    background: var(--chat-primary);
    border-color: var(--chat-primary);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px var(--chat-primary-glow);
}

/* Input Area */
.chatbot-wrapper .chat-input-area {
    padding: 20px;
    background: var(--chat-main-bg);
    border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.chatbot-wrapper #chat-form {
    display: flex;
    gap: 10px;
    background: var(--chat-input-bg);
    padding: 5px;
    border-radius: 30px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    transition: border-color 0.3s ease;
}

.chatbot-wrapper #chat-form:focus-within {
    border-color: var(--chat-primary);
    box-shadow: 0 0 15px rgba(59, 130, 246, 0.1);
}

.chatbot-wrapper #user-input {
    flex: 1;
    background: transparent;
    border: none;
    padding: 12px 20px;
    color: var(--chat-text);
    font-family: inherit;
    font-size: 1rem;
    outline: none;
}

.chatbot-wrapper #send-btn {
    background: var(--chat-primary);
    border: none;
    width: 45px;
    height: 45px;
    border-radius: 50%;
    color: white;
    cursor: pointer;
    transition: transform 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.chatbot-wrapper #send-btn:hover:not(:disabled) {
    transform: scale(1.05);
    background: #2563eb;
}

.chatbot-wrapper #send-btn:disabled {
    background: #475569;
    cursor: not-allowed;
    opacity: 0.7;
}

/* Report Table */
.chatbot-wrapper .report-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 10px;
    font-size: 0.9em;
}

.chatbot-wrapper .report-table th,
.chatbot-wrapper .report-table td {
    padding: 6px 4px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--chat-text);
}

.chatbot-wrapper .report-table th {
    color: var(--chat-text-muted);
    font-weight: 500;
}

.chatbot-wrapper .badge-gold {
    color: #ffd700;
    border: 1px solid #ffd700;
    padding: 2px 8px;
    border-radius: 12px;
}

.chatbot-wrapper .badge-silver {
    color: #c0c0c0;
    border: 1px solid #c0c0c0;
    padding: 2px 8px;
    border-radius: 12px;
}

.chatbot-wrapper .badge-bronze {
    color: #cd7f32;
    border: 1px solid #cd7f32;
    padding: 2px 8px;
    border-radius: 12px;
}

.chatbot-wrapper .rank-1 {
    color: #ffd700;
    font-weight: bold;
}

.chatbot-wrapper .rank-2 {
    color: #c0c0c0;
    font-weight: bold;
}

.chatbot-wrapper .rank-3 {
    color: #cd7f32;
    font-weight: bold;
}

.chatbot-wrapper .rank-other {
    color: var(--chat-text-muted);
}

/* Floating Button Styles (Global) */
#chatbot-trigger-btn {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 60px;
    height: 60px;
    background-color: var(--chat-primary, #3b82f6);
    border-radius: 50%;
    color: white;
    border: none;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
    cursor: pointer;
    z-index: 1000;
    transition: transform 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
}

#chatbot-trigger-btn:hover {
    transform: scale(1.1);
}

/* Modal Overlay Styles (Global) */
.chatbot-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    z-index: 2000;
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.chatbot-modal-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.chatbot-modal-container {
    width: 90%;
    max-width: 800px;
    position: relative;
    transform: translateY(20px);
    transition: transform 0.3s ease;
}

.chatbot-modal-overlay.active .chatbot-modal-container {
    transform: translateY(0);
}

.close-chatbot {
    position: absolute;
    top: -40px;
    right: 0;
    background: none;
    border: none;
    color: white;
    font-size: 24px;
    cursor: pointer;
}