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

:root {
    --bg-primary: #0f0f0f;
    --bg-secondary: #1a1a1a;
    --bg-tertiary: #252525;
    --bg-hover: #2a2a2a;
    --text-primary: #ffffff;
    --text-secondary: #a0a0a0;
    --text-muted: #666666;
    --accent: #5865f2;
    --accent-hover: #4752c4;
    --success: #3ba55c;
    --error: #ed4245;
    --warning: #faa61a;
    --border: #333333;
    --shadow: rgba(0, 0, 0, 0.3);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.screen {
    display: flex;
    flex-direction: column;
    height: 100vh;
}

.hidden {
    display: none !important;
}

.login-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 20px;
}

.logo {
    text-align: center;
    margin-bottom: 40px;
}

.logo-icon {
    font-size: 64px;
    margin-bottom: 16px;
}

.logo h1 {
    font-size: 32px;
    font-weight: 700;
    color: var(--text-primary);
}

form {
    width: 100%;
    max-width: 360px;
    background: var(--bg-secondary);
    padding: 32px;
    border-radius: 16px;
    box-shadow: 0 8px 32px var(--shadow);
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-secondary);
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 12px 16px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 15px;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(88, 101, 242, 0.2);
}

.form-group input::placeholder {
    color: var(--text-muted);
}

.btn-primary {
    width: 100%;
    padding: 14px;
    background: var(--accent);
    border: none;
    border-radius: 8px;
    color: white;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s;
}

.btn-primary:hover {
    background: var(--accent-hover);
}

.btn-primary:active {
    transform: scale(0.98);
}

.btn-primary:disabled {
    background: var(--bg-tertiary);
    cursor: not-allowed;
}

.error {
    margin-top: 16px;
    padding: 12px;
    background: rgba(237, 66, 69, 0.1);
    border: 1px solid var(--error);
    border-radius: 8px;
    color: var(--error);
    font-size: 14px;
    text-align: center;
    display: none;
}

.error.visible {
    display: block;
}

.chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 20px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
}

.header-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

.logo-icon.small {
    font-size: 28px;
}

.server-name {
    font-weight: 600;
    font-size: 16px;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

#user-display {
    color: var(--text-secondary);
    font-size: 14px;
}

.btn-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background: transparent;
    border: none;
    border-radius: 8px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
}

.btn-icon:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.btn-logout:hover {
    background: rgba(237, 66, 69, 0.15);
    color: var(--error);
}

.messages-container {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    scroll-behavior: smooth;
    min-height: 0;
}

.messages {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-width: 800px;
    margin: 0 auto;
}

.message {
    display: flex;
    flex-direction: column;
    max-width: 75%;
    padding: 10px 14px;
    border-radius: 16px;
    position: relative;
    word-wrap: break-word;
}

.message.own {
    align-self: flex-end;
    background: var(--accent);
    border-bottom-right-radius: 4px;
}

.message.other {
    align-self: flex-start;
    background: var(--bg-secondary);
    border-bottom-left-radius: 4px;
}

.message.system {
    align-self: center;
    max-width: 90%;
    background: transparent;
    color: var(--text-muted);
    font-size: 13px;
    text-align: center;
    padding: 8px;
}

.message-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
}

.message-author {
    font-weight: 600;
    font-size: 13px;
}

.message.own .message-author {
    color: rgba(255, 255, 255, 0.9);
}

.message.other .message-author {
    color: var(--accent);
}

.message-lang {
    font-size: 10px;
    padding: 2px 6px;
    background: var(--bg-tertiary);
    border-radius: 4px;
    color: var(--text-muted);
    text-transform: uppercase;
}

.message.own .message-lang {
    background: rgba(255, 255, 255, 0.15);
}

.message-text {
    font-size: 15px;
    line-height: 1.4;
    color: var(--text-primary);
}

.message.own .message-text {
    color: white;
}

.message-time {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 4px;
    text-align: right;
}

.message.own .message-time {
    color: rgba(255, 255, 255, 0.7);
}

.message-translations {
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.message.own .message-translations {
    border-top-color: rgba(255, 255, 255, 0.2);
}

.translation-item {
    font-size: 12px;
    color: var(--text-secondary);
    display: flex;
    gap: 6px;
}

.translation-item strong {
    color: var(--accent);
    font-weight: 600;
    text-transform: uppercase;
    font-size: 10px;
    min-width: 50px;
}

.message.own .translation-item {
    color: rgba(255, 255, 255, 0.85);
}

.message.own .translation-item strong {
    color: rgba(255, 255, 255, 0.9);
}

.chat-footer {
    padding: 16px 20px;
    background: var(--bg-secondary);
    border-top: 1px solid var(--border);
}

.scroll-bottom-btn {
    position: fixed;
    bottom: 90px;
    right: 20px;
    width: 44px;
    height: 44px;
    background: var(--accent);
    border: none;
    border-radius: 50%;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    transition: transform 0.2s, opacity 0.2s;
    opacity: 0.8;
    z-index: 100;
}

.scroll-bottom-btn:hover {
    opacity: 1;
    transform: scale(1.1);
}

.message-form {
    display: flex;
    gap: 12px;
    max-width: 800px;
    margin: 0 auto;
}

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

.message-form input:focus {
    outline: none;
    border-color: var(--accent);
}

.message-form input::placeholder {
    color: var(--text-muted);
}

.btn-send {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    background: var(--accent);
    border: none;
    border-radius: 50%;
    color: white;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s;
}

.btn-send:hover {
    background: var(--accent-hover);
}

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

.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
}

.modal-content {
    width: 100%;
    max-width: 400px;
    background: var(--bg-secondary);
    border-radius: 16px;
    overflow: hidden;
    animation: modalIn 0.2s ease;
}

@keyframes modalIn {
    from {
        opacity: 0;
        transform: scale(0.95);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px;
    border-bottom: 1px solid var(--border);
}

.modal-header h2 {
    font-size: 18px;
    font-weight: 600;
}

.btn-close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background: transparent;
    border: none;
    border-radius: 8px;
    color: var(--text-secondary);
    font-size: 24px;
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
}

.btn-close:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

#settings-form {
    padding: 20px;
    border-radius: 0;
    box-shadow: none;
}

.status-bar {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    background: var(--bg-secondary);
    border-radius: 24px;
    box-shadow: 0 4px 16px var(--shadow);
    font-size: 14px;
    z-index: 999;
    transition: opacity 0.3s, transform 0.3s;
}

.status-bar.hidden {
    opacity: 0;
    transform: translateX(-50%) translateY(20px);
    pointer-events: none;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--warning);
    animation: pulse 1.5s infinite;
}

.status-dot.connected {
    background: var(--success);
    animation: none;
}

.status-dot.error {
    background: var(--error);
    animation: none;
}

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

@media (max-width: 600px) {
    .login-container {
        padding: 16px;
    }

    form {
        padding: 24px;
    }

    .logo-icon {
        font-size: 48px;
    }

    .logo h1 {
        font-size: 24px;
    }

    .message {
        max-width: 90%;
    }

    .chat-header {
        padding: 10px 16px;
    }

    .messages-container {
        padding: 16px;
    }

    .chat-footer {
        padding: 12px 16px;
    }
}

::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--bg-hover);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--border);
}
