:root {
    --primary-color: #667eea;
    --primary-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --background: #0f0f23;
    --surface: rgba(255, 255, 255, 0.05);
    --surface-hover: rgba(255, 255, 255, 0.1);
    --text-primary: #ffffff;
    --text-secondary: rgba(255, 255, 255, 0.7);
    --text-muted: rgba(255, 255, 255, 0.5);
    --border: rgba(255, 255, 255, 0.1);
    --shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
    --border-radius: 20px;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --own-message: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --other-message: rgba(255, 255, 255, 0.08);
}

[data-theme="light"] {
    --background: #f8fafc;
    --surface: rgba(255, 255, 255, 0.9);
    --surface-hover: rgba(255, 255, 255, 0.95);
    --text-primary: #1a202c;
    --text-secondary: #4a5568;
    --text-muted: #718096;
    --border: rgba(0, 0, 0, 0.1);
    --shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
    --own-message: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --other-message: rgba(0, 0, 0, 0.05);
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--background);
    background-image: 
        radial-gradient(circle at 20% 80%, rgba(120, 119, 198, 0.3) 0%, transparent 50%),
        radial-gradient(circle at 80% 20%, rgba(255, 119, 198, 0.3) 0%, transparent 50%),
        radial-gradient(circle at 40% 40%, rgba(120, 219, 255, 0.2) 0%, transparent 50%);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

/* Modal para nickname */
.nickname-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(10px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-content {
    background: var(--surface);
    backdrop-filter: blur(20px);
    border: 1px solid var(--border);
    border-radius: var(--border-radius);
    padding: 40px;
    max-width: 400px;
    width: 90%;
    text-align: center;
    box-shadow: var(--shadow);
    animation: modalSlide 0.4s ease-out;
}

@keyframes modalSlide {
    from {
        opacity: 0;
        transform: translateY(-20px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.modal-header h2 {
    color: var(--text-primary);
    font-size: 24px;
    font-weight: 600;
    margin-bottom: 8px;
}

.modal-header p {
    color: var(--text-secondary);
    font-size: 14px;
    margin-bottom: 24px;
}

.modal-body {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

#nicknameInput {
    background: var(--surface-hover);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 16px;
    color: var(--text-primary);
    font-size: 16px;
    font-family: inherit;
    outline: none;
    transition: var(--transition);
    text-align: center;
}

#nicknameInput:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

#nicknameInput::placeholder {
    color: var(--text-muted);
}

.join-btn {
    background: var(--primary-gradient);
    border: none;
    border-radius: 12px;
    padding: 16px 24px;
    color: white;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.join-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.4);
}

.join-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* Chat principal */
.chat-container {
    width: 100%;
    max-width: 600px;
    height: 600px;
    background: var(--surface);
    backdrop-filter: blur(20px);
    border: 1px solid var(--border);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: slideUp 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(30px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

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

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

.user-display {
    display: flex;
    align-items: center;
    gap: 12px;
}

.user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--primary-gradient);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 600;
    font-size: 16px;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.user-info {
    display: flex;
    flex-direction: column;
}

.user-name {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    line-height: 1.2;
}

.user-status {
    font-size: 12px;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 4px;
}

.user-status::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #10b981;
}

.header-controls {
    display: flex;
    gap: 8px;
}

.header-btn {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--surface-hover);
    color: var(--text-primary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    font-size: 14px;
}

.header-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    transform: translateY(-1px);
}

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

.messages-container::-webkit-scrollbar {
    width: 4px;
}

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

.messages-container::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 2px;
}

.welcome-message {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-secondary);
}

.welcome-icon {
    font-size: 48px;
    margin-bottom: 16px;
    background: var(--primary-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.welcome-message h3 {
    font-size: 20px;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--text-primary);
}

.welcome-message p {
    font-size: 14px;
    opacity: 0.8;
}

.message {
    max-width: 75%;
    padding: 16px 20px;
    border-radius: 20px;
    font-size: 14px;
    line-height: 1.5;
    word-wrap: break-word;
    animation: messageSlide 0.3s ease-out;
    position: relative;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

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

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

.message.other {
    align-self: flex-start;
    background: var(--other-message);
    color: var(--text-primary);
    border: 1px solid var(--border);
    border-bottom-left-radius: 8px;
}

.message-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 6px;
    font-size: 12px;
    opacity: 0.8;
}

.message-user {
    font-weight: 600;
}

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

.message.other .message-user {
    color: var(--primary-color);
}

.message-content {
    margin-bottom: 4px;
}

.input-container {
    padding: 20px;
    border-top: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.02);
}

.input-wrapper {
    display: flex;
    gap: 12px;
    align-items: flex-end;
    margin-bottom: 8px;
}

#messageInput {
    flex: 1;
    background: var(--surface-hover);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 12px 16px;
    color: var(--text-primary);
    font-size: 14px;
    font-family: inherit;
    resize: none;
    outline: none;
    transition: var(--transition);
}

#messageInput:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

#messageInput::placeholder {
    color: var(--text-muted);
}

.send-button {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: none;
    background: var(--primary-gradient);
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.send-button:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
}

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

.input-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 12px;
    color: var(--text-muted);
}

.user-info {
    color: var(--text-secondary);
}

.user-info strong {
    color: var(--primary-color);
}

.char-count {
    opacity: 0.6;
}

@media (max-width: 480px) {
    body {
        padding: 10px;
    }
    
    .chat-container {
        height: calc(100vh - 20px);
        border-radius: 16px;
    }
    
    .modal-content {
        padding: 30px 20px;
    }
    
    .header-controls {
        gap: 4px;
    }
    
    .header-btn {
        width: 32px;
        height: 32px;
        font-size: 12px;
    }
}

.notification {
    position: fixed;
    top: 20px;
    right: 20px;
    background: var(--surface);
    backdrop-filter: blur(20px);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 16px;
    color: var(--text-primary);
    box-shadow: var(--shadow);
    animation: slideInRight 0.3s ease-out;
    z-index: 1000;
}

@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(100%);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.system-message {
    text-align: center;
    font-size: 12px;
    color: var(--text-muted);
    font-style: italic;
    margin: 8px 0;
    opacity: 0.7;
    padding: 8px 16px;
    background: rgba(255, 255, 255, 0.02);
    border-radius: 12px;
    border: 1px solid var(--border);
}