:root {
    /* Primary colors */
    --primary-color: #4a9eff;
    --primary-dark: #3d8de6;
    --primary-light: #1a1d23;
    
    /* Secondary colors */
    --secondary-color: #a855f7;
    --secondary-light: #1f1d24;
    
    /* Neutral colors */
    --background: #0a0b0d;
    --surface: #13141a;
    --border: #1f2128;
    
    /* Text colors */
    --text-primary: #e2e8f0;
    --text-secondary: #6b7280;
    
    /* Message colors */
    --message-bg: #1a1c22;
    
    /* Functional colors */
    --disabled: #374151;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: var(--background);
    height: 100vh;
    height: 100dvh; /* Dynamic viewport height for mobile */
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden; /* Prevent body scroll */
}

.chat-container {
    width: 100%;
    height: 100vh;
    height: 100dvh; /* Dynamic viewport height for mobile */
    background: var(--surface);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.chat-header {
    padding: 20px;
    border-bottom: 1px solid var(--border);
    background: var(--surface);
}

.chat-header h1 {
    font-size: 20px;
    font-weight: 600;
    color: var(--text-primary);
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.message {
    display: flex;
    gap: 12px;
    max-width: 80%;
    animation: fadeIn 0.3s ease;
}

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

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

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

.message.bot .message-avatar {
    background: var(--primary-light);
    color: var(--primary-color);
}

.message.user .message-avatar {
    background: var(--secondary-light);
    color: var(--secondary-color);
}

.message-content {
    background: var(--message-bg);
    padding: 12px 16px;
    border-radius: 18px;
    line-height: 1.5;
    color: var(--text-primary);
}

.message.user .message-content {
    background: var(--primary-color);
    color: white;
}

.chat-input-container {
    padding: 20px;
    border-top: 1px solid var(--border);
    background: var(--surface);
}

.chat-input-wrapper {
    display: flex;
    gap: 8px;
    align-items: center;
}

.chat-input {
    flex: 1;
    padding: 12px 16px;
    border: 1px solid var(--border);
    border-radius: 24px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
    background: var(--message-bg);
    color: var(--text-primary);
}

.chat-input:focus {
    border-color: var(--primary-color);
}

.send-button {
    width: 44px;
    height: 44px;
    border: none;
    border-radius: 50%;
    background: var(--primary-color);
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
    flex-shrink: 0;
    font-size: 20px; /* Increase arrow size */
}

.send-button:hover {
    background: var(--primary-dark);
}

.send-button:disabled {
    background: var(--disabled);
    cursor: not-allowed;
}

.send-ai-button {
    width: 44px;
    height: 44px;
    border: none;
    border-radius: 50%;
    background: var(--secondary-color);
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
    flex-shrink: 0;
    font-size: 20px;
}

.send-ai-button:hover {
    background: #9333ea; /* Darker purple */
}

.send-ai-button:disabled {
    background: var(--disabled);
    cursor: not-allowed;
}

.upload-button {
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 50%;
    background: var(--message-bg);
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
    font-size: 18px;
}

.upload-button:hover {
    background: var(--border);
    color: var(--text-primary);
}

.typing-indicator {
    display: none;
    gap: 4px;
    padding: 12px 16px;
}

.typing-indicator.active {
    display: flex;
}

.typing-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-secondary);
    animation: typing 1.4s infinite;
}

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

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

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

.empty-state {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    gap: 12px;
}

.empty-state-icon {
    font-size: 48px;
}

.empty-state-text {
    font-size: 16px;
}

/* Scrollbar styling */
.chat-messages::-webkit-scrollbar {
    width: 6px;
}

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

.chat-messages::-webkit-scrollbar-thumb {
    background: var(--disabled);
    border-radius: 3px;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
}

.words-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 4px;
    background: var(--background);
    border-radius: 8px;
    overflow: hidden;
}

.words-table thead {
    background: var(--border);
}

.words-table th {
    padding: 12px;
    text-align: left;
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border);
}

.words-table td {
    padding: 12px;
    border-bottom: 1px solid var(--border);
}

.words-table tbody tr:last-child td {
    border-bottom: none;
}

.words-table tbody tr:hover {
    background: var(--message-bg);
}

.word-swedish {
    color: var(--primary-color);
    font-weight: 600;
    font-size: 16px;
}

.word-english {
    color: var(--text-primary);
    font-size: 14px;
}

.word-function {
    color: var(--text-secondary);
    font-size: 12px;
    font-style: italic;
}

@media (max-width: 768px) {
    .chat-header {
        padding: 16px;
    }

    .chat-header h1 {
        font-size: 18px;
    }

    .chat-messages {
        padding: 16px;
        gap: 12px;
    }

    .message {
        max-width: 90%;
    }

    .message-avatar {
        width: 32px;
        height: 32px;
        font-size: 14px;
    }

    .message-content {
        padding: 10px 14px;
        font-size: 14px;
    }

    .chat-input-container {
        padding: 16px;
    }

    .chat-input {
        padding: 10px 14px;
        font-size: 16px; /* Prevents zoom on iOS */
    }

    .send-button {
        width: 40px;
        height: 40px;
        font-size: 18px; /* Slightly smaller on mobile */
    }

    .send-ai-button {
        width: 40px;
        height: 40px;
        font-size: 18px;
    }

    .upload-button {
        width: 32px;
        height: 32px;
        font-size: 16px;
    }

    .empty-state-icon {
        font-size: 40px;
    }

    .empty-state-text {
        font-size: 14px;
    }
    
    .words-table th,
    .words-table td {
        padding: 8px;
        font-size: 12px;
    }
    
    .word-swedish {
        font-size: 14px;
    }
    
    .word-english {
        font-size: 12px;
    }
    
    .word-function {
        font-size: 11px;
    }
}

/* Nickname label in messages */
.message-nickname {
    font-size: 0.75em;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 4px;
    opacity: 0.9;
}

.message.bot .message-nickname {
    color: var(--text-secondary);
}

.connection-status {
    font-size: 0.85em;
    color: #666;
}

.status-indicator {
    font-size: 0.7em;
    margin-right: 5px;
}

#statusText {
    font-weight: 500;
}

#userCount {
    color: #888;
    font-size: 0.9em;
}

/* Modal Styles */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    align-items: center;
    justify-content: center;
}

.modal-content {
    background-color: var(--surface);
    padding: 30px;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
    border: 1px solid var(--border);
    max-width: 400px;
    width: 90%;
}

.modal-content h2 {
    margin-top: 0;
    color: var(--text-primary);
}

.modal-content p {
    color: var(--text-secondary);
    margin-bottom: 20px;
}

#nicknameInput {
    width: 100%;
    padding: 12px;
    border: 2px solid var(--border);
    border-radius: 8px;
    font-size: 16px;
    margin-bottom: 15px;
    box-sizing: border-box;
    background: var(--message-bg);
    color: var(--text-primary);
}

#nicknameInput:focus {
    outline: none;
    border-color: var(--primary-color);
}

.terms-container {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 15px;
}

.terms-checkbox {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: var(--secondary-color);
}

.terms-label {
    color: var(--text-secondary);
    font-size: 14px;
    cursor: pointer;
    user-select: none;
}

.join-button {
    width: 100%;
    padding: 12px;
    background-color: var(--primary-color);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.3s;
}

.join-button:hover {
    background-color: var(--primary-dark);
}

.join-button:disabled {
    background-color: var(--disabled);
    cursor: not-allowed;
    opacity: 0.6;
}

#codeInput {
    width: 100%;
    padding: 12px;
    border: 2px solid var(--border);
    border-radius: 8px;
    font-size: 16px;
    margin-bottom: 15px;
    box-sizing: border-box;
    background: var(--message-bg);
    color: var(--text-primary);
}

#codeInput:focus {
    outline: none;
    border-color: var(--primary-color);
}

#codeError {
    color: #f44336;
    font-size: 14px;
    margin-bottom: 10px;
    min-height: 20px;
}

